@vantran-se/openchamber-web 2.1.1 → 2.2.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 +32 -24
- package/bin/cli.js +1 -3
- package/bin/cli.test.js +40 -16
- package/bin/lib/DOCUMENTATION.md +6 -5
- package/bin/lib/cli-args.js +6 -1
- package/bin/lib/cli-args.test.js +34 -0
- package/bin/lib/cli-lifecycle.js +0 -1
- package/bin/lib/cli-network.js +8 -2
- package/bin/lib/cli-process.js +1 -1
- package/bin/lib/cli-settings-accessors.test.js +21 -13
- package/bin/lib/cli-startup.js +17 -11
- package/bin/lib/cli-startup.test.js +92 -2
- package/bin/lib/commands-connect-url.js +8 -1
- package/bin/lib/commands-schedule.js +8 -2
- package/bin/lib/commands-serve.js +15 -21
- package/bin/lib/commands-update.js +12 -24
- package/bin/lib/commands-update.test.js +14 -46
- package/dist/assets/DiffView-Cv9MSXl1.js +4 -0
- package/dist/assets/FilePreviewCommentMenu-D4kLseHj.js +4 -0
- package/dist/assets/FilesView-BVoD8I2x.js +14 -0
- package/dist/assets/{GitView-DzuzhIPx.js → GitView-Bzb8p-ew.js} +4 -4
- package/dist/assets/GuestSurfacePane-Crdbvsxo.js +1 -0
- package/dist/assets/InProgressOperationBanner-CwMjNQgk.js +2 -0
- package/dist/assets/{JsonTreeView-B_EPRjzy.js → JsonTreeView-DRKHZfsn.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DZtqT1Zn.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CqG7HCNd.js +10 -0
- package/dist/assets/OnboardingScreen-DMIxwYK5.js +1 -0
- package/dist/assets/{PatchDiff-6yh1csza.js → PatchDiff-CUcCg1jk.js} +1 -1
- package/dist/assets/PierreDiffViewer-CnnR-dnD.js +228 -0
- package/dist/assets/PlanView-RCBadcY7.js +5 -0
- package/dist/assets/SettingsView-CjBjZFRO.js +30 -0
- package/dist/assets/SettingsWindow-DyM7QuhI.js +1 -0
- package/dist/assets/SubmoduleDiffSummary-BWIfgMED.js +1 -0
- package/dist/assets/ToolOutputDialog-Q0P3FuAi.js +15 -0
- package/dist/assets/ToolPartDiffPreview-p7qR9FpU.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-BTJVRkyo.js → VirtualizedFileDiff-CFpjL8Ns.js} +3 -3
- package/dist/assets/{Virtualizer-xCEYz34p.js → Virtualizer-C0IsclZn.js} +1 -1
- package/dist/assets/WalkthroughView-DI31zD02.js +4 -0
- package/dist/assets/appThemeRegistry-B9gkFq9i.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-CmPe29DM.js → computeVirtualFileMetrics-C2WM6JC2.js} +2 -2
- package/dist/assets/de-YKfk5MmC.js +14 -0
- package/dist/assets/es-_gwT0kr-.js +20 -0
- package/dist/assets/fileTreeStatus-D438yi8M.js +1 -0
- package/dist/assets/fr-DqzvXmIm.js +18 -0
- package/dist/assets/index-BLaHKdtx.js +1 -0
- package/dist/assets/index-BkMXRrVQ.css +1 -0
- package/dist/assets/index-DxNa7xYB.js +65 -0
- package/dist/assets/initializeSharedPreferences-Bck5EAWP.js +1 -0
- package/dist/assets/{isDiffPlainText-CQmDCnEv.js → isDiffPlainText-Dgbw8VKk.js} +1 -1
- package/dist/assets/{isFilePlainText-CYBUzW4I.js → isFilePlainText-_ZS5UYRj.js} +1 -1
- package/dist/assets/ja-B-GFYhQE.js +20 -0
- package/dist/assets/ko-mzksfqDC.js +20 -0
- package/dist/assets/main-C5Xx8dn_.js +2 -0
- package/dist/assets/main-CfBSQM1H.js +990 -0
- package/dist/assets/markdownCore-BmWwW1ll.js +7 -0
- package/dist/assets/miniChat-mnKwy4vQ.js +2 -0
- package/dist/assets/mobile-DeEQd0wZ.js +2 -0
- package/dist/assets/nl-CWQr6NSq.js +20 -0
- package/dist/assets/{parseDiffFromFile-Cy0PNxun.js → parseDiffFromFile-BUgn-T9p.js} +2 -2
- package/dist/assets/patchFileDiff-Dt8LhgBh.js +13 -0
- package/dist/assets/pl-UmRcDUX2.js +20 -0
- package/dist/assets/pt-BR-BSLybvVF.js +20 -0
- package/dist/assets/relocateRestoredSession-B5E9xb3T.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-C0a9A5_J.js +2 -0
- package/dist/assets/renderMobileApp-BNncg3Pk.js +25 -0
- package/dist/assets/runtimeEndpointReset-CZ5aafpl.js +62 -0
- package/dist/assets/{selectionMarkdown-TkYk5h9l.js → selectionMarkdown-CUN3wUld.js} +9 -9
- package/dist/assets/{sessionOwnership-Bs1xbRfB.js → sessionOwnership-BSuxCEhb.js} +1 -1
- package/dist/assets/shikiHighlight-DHDx-6eM.js +1 -0
- package/dist/assets/space-apply-DM_2pRW7.js +1 -0
- package/dist/assets/space-close-Bpomt8z0.js +1 -0
- package/dist/assets/{surface-B6n7wJtt.js → surface-C-jQaGnL.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-CDlKffWz.js → textMateThemeFromAppTheme-DlsTphbY.js} +1 -1
- package/dist/assets/tr-gaTrX_HK.js +11 -0
- package/dist/assets/uk-CnJF6ykl.js +20 -0
- package/dist/assets/{useAppFontEffects-DCqCVGlT.js → useAppFontEffects-DGlvOqP_.js} +194 -233
- package/dist/assets/useInlineCommentController-kMN4Wg_D.js +2 -0
- package/dist/assets/{useRootScrollLock-BowwS8kq.js → useRootScrollLock-DMPpvpNP.js} +2 -2
- package/dist/assets/{vendor-base-ui-DX96QhTP.js → vendor-base-ui-Det7U81h.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-DW1FQz9_.js → vendor-codemirror-autocomplete-BSHQHbKu.js} +1 -1
- package/dist/assets/{vendor-codemirror-commands-DpmhalwN.js → vendor-codemirror-commands-C4G_dPWe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-BqExbN1M.js → vendor-codemirror-lang-angular-B6LbBGHB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-DZA36HfS.js → vendor-codemirror-lang-cpp-BWWXBx7W.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-B07blnnZ.js → vendor-codemirror-lang-css-Cayfb29q.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-BM8K9D1-.js → vendor-codemirror-lang-go-BoKlCNKw.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-DaH9adfE.js → vendor-codemirror-lang-html-BQWerHsJ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CsdC0viz.js → vendor-codemirror-lang-java-DWX7Fq_K.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-CpGYXGuo.js → vendor-codemirror-lang-javascript-DbpEcZM0.js} +2 -2
- package/dist/assets/{vendor-codemirror-lang-jinja-BBeGzXw5.js → vendor-codemirror-lang-jinja-D1JIJRA7.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-58T70Hqs.js → vendor-codemirror-lang-json-BzgckzmB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-BI-xCA59.js → vendor-codemirror-lang-less-B9EpDXFi.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-zEcMa-zy.js → vendor-codemirror-lang-liquid-9U7kRbSf.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-BLKnlLP4.js → vendor-codemirror-lang-markdown-D2TEBIvZ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-9f35M83-.js → vendor-codemirror-lang-php-BT6sDVzE.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-python-jAMtYiA9.js +3 -0
- package/dist/assets/{vendor-codemirror-lang-rust-MNDL_jZQ.js → vendor-codemirror-lang-rust-CVO56EiL.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-p9epsSNm.js → vendor-codemirror-lang-sass-DZlOoUWu.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-Bqzh0EXX.js → vendor-codemirror-lang-sql-fZ6t1DPw.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-BnNUWV-p.js → vendor-codemirror-lang-vue-DxbqrLiE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-C2a-oLmk.js → vendor-codemirror-lang-wast-DyU1Gt-I.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-xml-C9a_K5_p.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-yaml-C0sjswB0.js → vendor-codemirror-lang-yaml-Cptq8l0e.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-ByBn5zIW.js → vendor-codemirror-language-DufXoQvE.js} +2 -2
- package/dist/assets/vendor-codemirror-language-data-CtwSWKtX.js +2 -0
- package/dist/assets/{vendor-codemirror-search-ib-sHD5W.js → vendor-codemirror-search-CvXM_pZg.js} +1 -1
- package/dist/assets/{vendor-codemirror-state-G3UuR-be.js → vendor-codemirror-state-Dek9sMtw.js} +1 -1
- package/dist/assets/{vendor-codemirror-view-Bniqp7p5.js → vendor-codemirror-view-1e0FQ6Wn.js} +1 -1
- package/dist/assets/vendor-framer-motion-DxDVhOLc.js +9 -0
- package/dist/assets/vendor-katex-CuQvj9-L.js +257 -0
- package/dist/assets/vendor-katex-DdZNUVNG.css +1 -0
- package/dist/assets/{vendor-motion-dom-DcCgeG69.js → vendor-motion-dom-HXPOMxb7.js} +1 -1
- package/dist/assets/{vendor-opencode-client-DHzhmLwV.js → vendor-opencode-client-BmFcUkbQ.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-DkzqxN2H.js → vendor-replit-codemirror-vim-BlJRn-cW.js} +2 -2
- package/dist/assets/{vendor-tanstack-react-virtual-H_JmXOFV.js → vendor-tanstack-react-virtual-CvuLsk7D.js} +1 -1
- package/dist/assets/{vendor-tanstack-virtual-core-Dxc8hSTB.js → vendor-tanstack-virtual-core-DPaNcJcT.js} +1 -1
- package/dist/assets/zh-CN-t2vigSB1.js +20 -0
- package/dist/assets/zh-TW-jAgqBokB.js +20 -0
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +6 -6
- package/dist/mobile.html +6 -6
- package/package.json +8 -5
- package/server/index.js +80 -36
- package/server/lib/agent-memory/actions.js +1 -6
- package/server/lib/agent-memory/routes.js +1 -2
- package/server/lib/agent-memory/runtime.js +1 -8
- package/server/lib/agent-tool/DOCUMENTATION.md +7 -3
- package/server/lib/agent-tool/runtime.js +3 -6
- package/server/lib/agent-tool/runtime.test.js +0 -2
- package/server/lib/browser-control/DOCUMENTATION.md +6 -0
- package/server/lib/changelog/update-notes.js +1 -1
- package/server/lib/context-obligatory/runtime.js +1 -2
- package/server/lib/dev-tunnel/DOCUMENTATION.md +8 -0
- package/server/lib/dev-tunnel/client.js +21 -10
- package/server/lib/dev-tunnel/tunnel.test.js +34 -0
- package/server/lib/dispatch-results/runtime.js +1 -1
- package/server/lib/enterprise-mode.d.ts +1 -0
- package/server/lib/enterprise-mode.js +13 -2
- package/server/lib/enterprise-mode.test.js +21 -0
- package/server/lib/event-stream/DOCUMENTATION.md +2 -2
- package/server/lib/event-stream/index.js +1 -3
- package/server/lib/event-stream/translate-v2.js +1 -9
- package/server/lib/event-stream/translate-v2.test.js +0 -11
- package/server/lib/fs/DOCUMENTATION.md +5 -2
- package/server/lib/fs/routes.js +62 -15
- package/server/lib/fs/routes.test.js +278 -48
- package/server/lib/fs/workspace-file-names.js +104 -0
- package/server/lib/fs/workspace-file-names.test.js +62 -0
- package/server/lib/git/DOCUMENTATION.md +17 -5
- package/server/lib/git/contributor-provenance-storage.js +9 -6
- package/server/lib/git/contributor-provenance-storage.test.js +29 -0
- package/server/lib/git/credential-broker.js +1 -1
- package/server/lib/git/credential-resolver.js +1 -4
- package/server/lib/git/credentials.js +1 -0
- package/server/lib/git/discovery-endpoint.js +1 -1
- package/server/lib/git/identity-provisioning.js +2 -1
- package/server/lib/git/identity-storage.js +3 -4
- package/server/lib/git/lfs-discovery.js +14 -14
- package/server/lib/git/lfs-discovery.test.js +16 -6
- package/server/lib/git/network-operation-plan.js +50 -62
- package/server/lib/git/network-operation-plan.test.js +103 -1
- package/server/lib/git/network-operation-registry.js +4 -6
- package/server/lib/git/network-operation-storage.js +4 -6
- package/server/lib/git/network-operations.js +12 -4
- package/server/lib/git/network-operations.test.js +19 -6
- package/server/lib/git/redaction.js +2 -1
- package/server/lib/git/repository-credential-runtime.js +5 -3
- package/server/lib/git/repository-credential-runtime.test.js +22 -0
- package/server/lib/git/routes.js +31 -137
- package/server/lib/git/routes.test.js +2 -2
- package/server/lib/git/service.js +143 -27
- package/server/lib/git/service.test.js +215 -1
- package/server/lib/git/ssh-credential-storage.js +1 -4
- package/server/lib/git/submodule-discovery.js +1 -1
- package/server/lib/git/worktree-bootstrap-storage.js +3 -4
- package/server/lib/git/worktree-bootstrap-storage.test.js +15 -0
- package/server/lib/git/worktree-creation.js +194 -0
- package/server/lib/git/worktree-creation.test.js +155 -0
- package/server/lib/github/DOCUMENTATION.md +11 -6
- package/server/lib/github/auth.js +2 -4
- package/server/lib/github/device-flow.js +2 -2
- package/server/lib/github/gh-cli-credential.js +1 -0
- package/server/lib/github/octokit.js +31 -0
- package/server/lib/github/pr-status.js +35 -18
- package/server/lib/github/pr-status.test.js +271 -3
- package/server/lib/github/reference-search.js +102 -13
- package/server/lib/github/reference-search.test.js +48 -7
- package/server/lib/github/routes.auth.test.js +18 -0
- package/server/lib/github/routes.js +360 -6
- package/server/lib/github/routes.mutations.test.js +239 -0
- package/server/lib/github/routes.test.js +134 -2
- package/server/lib/gitlab/DOCUMENTATION.md +5 -1
- package/server/lib/gitlab/auth-storage.test.js +1 -0
- package/server/lib/gitlab/mappers.js +30 -1
- package/server/lib/gitlab/resources.js +230 -6
- package/server/lib/gitlab/resources.test.js +179 -0
- package/server/lib/gitlab/routes.js +200 -6
- package/server/lib/gitlab/routes.test.js +186 -2
- package/server/lib/gitlab/validation.js +1 -5
- package/server/lib/guests/DOCUMENTATION.md +1 -1
- package/server/lib/guests/oauth.js +2 -2
- package/server/lib/guests/service.js +1 -1
- package/server/lib/guests/sockets.js +1 -1
- package/server/lib/injected-env.d.ts +8 -0
- package/server/lib/injected-env.js +50 -0
- package/server/lib/injected-env.test.js +56 -0
- package/server/lib/linear/DOCUMENTATION.md +5 -6
- package/server/lib/linear/issues.js +62 -4
- package/server/lib/linear/issues.test.js +68 -0
- package/server/lib/linear/oauth.js +5 -5
- package/server/lib/linear/parse.js +2 -9
- package/server/lib/message-queue/DOCUMENTATION.md +23 -1
- package/server/lib/message-queue/runtime.js +85 -12
- package/server/lib/message-queue/runtime.test.js +172 -2
- package/server/lib/notifications/apns-runtime.js +5 -6
- package/server/lib/notifications/apns-runtime.test.js +20 -4
- package/server/lib/openchamber-control/DOCUMENTATION.md +19 -1
- package/server/lib/openchamber-control/actions.js +2 -1
- package/server/lib/openchamber-control/service.js +119 -20
- package/server/lib/openchamber-control/service.test.js +166 -0
- package/server/lib/openchamber-sessions/archive-store.js +1 -6
- package/server/lib/openchamber-sessions/routes.js +47 -12
- package/server/lib/openchamber-sessions/routes.test.js +65 -2
- package/server/lib/openchamber-sessions/session-metadata-store.js +1 -6
- package/server/lib/opencode/DOCUMENTATION.md +22 -8
- package/server/lib/opencode/agents.js +62 -0
- package/server/lib/opencode/auth-state-runtime.js +3 -1
- package/server/lib/opencode/auth.d.ts +1 -1
- package/server/lib/opencode/auth.js +8 -0
- package/server/lib/opencode/auth.test.js +31 -0
- package/server/lib/opencode/config-entity-routes.js +16 -0
- package/server/lib/opencode/config-entity-v2.test.js +16 -1
- package/server/lib/opencode/config-paths.test.js +2 -2
- package/server/lib/opencode/config-v2.js +2 -4
- package/server/lib/opencode/feature-routes-runtime.js +89 -49
- package/server/lib/opencode/lifecycle.js +41 -21
- package/server/lib/opencode/lifecycle.test.js +50 -2
- package/server/lib/opencode/model-discovery.js +1 -1
- package/server/lib/opencode/model-discovery.test.js +17 -0
- package/server/lib/opencode/models-metadata.js +0 -2
- package/server/lib/opencode/openchamber-routes.test.js +3 -3
- package/server/lib/opencode/plugins.js +6 -9
- package/server/lib/opencode/provider-source-route.test.js +101 -3
- package/server/lib/opencode/providers-disabled.test.js +59 -0
- package/server/lib/opencode/providers.js +34 -0
- package/server/lib/opencode/proxy.js +11 -3
- package/server/lib/opencode/routes.js +40 -2
- package/server/lib/opencode/settings-helpers.js +27 -1
- package/server/lib/opencode/settings-helpers.test.js +19 -7
- package/server/lib/opencode/settings-registry.json +27 -16
- package/server/lib/opencode/settings-runtime.test.js +18 -0
- package/server/lib/opencode/shared-service-runtime.js +23 -104
- package/server/lib/opencode/shared.js +77 -46
- package/server/lib/opencode/shared.test.js +12 -12
- package/server/lib/opencode/shutdown-runtime.test.js +2 -3
- package/server/lib/opencode/skill-routes.js +123 -38
- package/server/lib/opencode/skill-routes.test.js +201 -0
- package/server/lib/opencode/skills.js +81 -34
- package/server/lib/opencode/skills.test.js +176 -21
- package/server/lib/opencode/startup-pipeline-runtime.js +6 -3
- package/server/lib/opencode/startup-pipeline-runtime.test.js +2 -1
- package/server/lib/opencode/watcher.test.js +0 -54
- package/server/lib/outbound-proxy.js +52 -0
- package/server/lib/outbound-proxy.test.js +55 -0
- package/server/lib/package-manager.js +23 -17
- package/server/lib/package-manager.test.js +5 -18
- package/server/lib/permission-auto-accept/DOCUMENTATION.md +1 -1
- package/server/lib/permission-auto-accept/runtime.js +19 -47
- package/server/lib/permission-auto-accept/runtime.test.js +2 -2
- package/server/lib/project-context/DOCUMENTATION.md +7 -1
- package/server/lib/project-context/routes.js +1 -2
- package/server/lib/project-context/runtime.js +12 -14
- package/server/lib/project-context/runtime.test.js +78 -2
- package/server/lib/projects/project-config.js +30 -15
- package/server/lib/projects/project-config.test.js +30 -0
- package/server/lib/projects/project-setup.js +1 -2
- package/server/lib/projects/routes.js +1 -2
- package/server/lib/quota/DOCUMENTATION.md +35 -7
- package/server/lib/quota/index.js +1 -0
- package/server/lib/quota/providers/claude/index.js +1 -1
- package/server/lib/quota/providers/cline-pass.js +1 -1
- package/server/lib/quota/providers/exe-dev.js +1 -1
- package/server/lib/quota/providers/google/index.js +1 -1
- package/server/lib/quota/providers/hyper.js +1 -1
- package/server/lib/quota/providers/kimi.js +116 -36
- package/server/lib/quota/providers/kimi.test.js +128 -3
- package/server/lib/quota/providers/opencode-go.js +144 -21
- package/server/lib/quota/providers/opencode-go.test.js +229 -6
- package/server/lib/quota/providers/openrouter.js +1 -1
- package/server/lib/quota/providers/zenmux.js +1 -1
- package/server/lib/quota/utils/auth.js +1 -0
- package/server/lib/quota/utils/transformers.js +2 -6
- package/server/lib/relay/DOCUMENTATION.md +18 -3
- package/server/lib/relay/e2ee.js +7 -7
- package/server/lib/relay/host-client.js +84 -13
- package/server/lib/relay/host-client.test.js +201 -1
- package/server/lib/relay/identity.js +6 -29
- package/server/lib/relay/identity.test.js +18 -28
- package/server/lib/relay/key-store.js +141 -0
- package/server/lib/relay/key-store.test.js +138 -0
- package/server/lib/relay/service.js +8 -8
- package/server/lib/relay/service.test.js +10 -5
- package/server/lib/relay/signing-key.js +13 -36
- package/server/lib/relay/tunnel-codec.js +10 -10
- package/server/lib/route-module-exports.test.js +22 -0
- package/server/lib/routing/DOCUMENTATION.md +23 -3
- package/server/lib/routing/cache.js +87 -0
- package/server/lib/routing/defaults.js +11 -0
- package/server/lib/routing/history.js +12 -4
- package/server/lib/routing/runtime.js +39 -3
- package/server/lib/routing/runtime.test.js +81 -2
- package/server/lib/routing/store.js +12 -1
- package/server/lib/routing/store.test.js +13 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +59 -1
- package/server/lib/scheduled-tasks/existing-session.js +119 -0
- package/server/lib/scheduled-tasks/existing-session.test.js +350 -0
- package/server/lib/scheduled-tasks/loops.js +1 -8
- package/server/lib/scheduled-tasks/routes.js +8 -8
- package/server/lib/scheduled-tasks/runtime.js +103 -13
- package/server/lib/scheduled-tasks/runtime.test.js +48 -0
- package/server/lib/scheduled-tasks/service.js +33 -11
- package/server/lib/scheduled-tasks/service.test.js +128 -2
- package/server/lib/scheduled-tasks/session-defaults.js +27 -0
- package/server/lib/scheduled-tasks/session-defaults.test.js +19 -0
- package/server/lib/session-assist/context.js +1 -0
- package/server/lib/session-folders/routes.js +2 -2
- package/server/lib/session-goal/objectives.js +1 -1
- package/server/lib/session-knowledge/routes.js +2 -2
- package/server/lib/session-knowledge/runtime.js +1 -2
- package/server/lib/session-work/DOCUMENTATION.md +39 -14
- package/server/lib/session-work/questions.js +31 -2
- package/server/lib/session-work/runtime.js +22 -13
- package/server/lib/session-work/runtime.test.js +43 -26
- package/server/lib/session-work/state.js +10 -4
- package/server/lib/session-work/state.test.js +8 -1
- package/server/lib/shared/DOCUMENTATION.md +89 -0
- package/server/lib/shared/guards.js +53 -0
- package/server/lib/shared/guards.test.js +112 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +10 -8
- package/server/lib/skills-catalog/cache.js +3 -2
- package/server/lib/skills-catalog/curated-sources.js +5 -1
- package/server/lib/skills-catalog/git.js +107 -20
- package/server/lib/skills-catalog/git.test.js +78 -0
- package/server/lib/skills-catalog/install.js +21 -12
- package/server/lib/skills-catalog/scan.js +25 -15
- package/server/lib/skills-catalog/source.js +26 -1
- package/server/lib/skills-catalog/source.test.js +27 -0
- package/server/lib/source-control/DOCUMENTATION.md +2 -1
- package/server/lib/source-control/audit-storage.js +7 -6
- package/server/lib/source-control/audit-storage.test.js +11 -0
- package/server/lib/source-control/binding-service.js +2 -5
- package/server/lib/source-control/change-request-worktree.js +90 -0
- package/server/lib/source-control/change-request-worktree.test.js +121 -0
- package/server/lib/source-control/mutation-executor.js +1 -1
- package/server/lib/source-control/mutation-storage.js +11 -5
- package/server/lib/source-control/provider-instance.js +1 -2
- package/server/lib/source-control/repository-identity.js +1 -1
- package/server/lib/source-control/routes.js +14 -2
- package/server/lib/spaces/DOCUMENTATION.md +42 -17
- package/server/lib/spaces/command-stream.test.js +15 -0
- package/server/lib/spaces/dispatcher.js +7 -0
- package/server/lib/spaces/dispatcher.test.js +17 -0
- package/server/lib/spaces/hardening.js +2 -2
- package/server/lib/spaces/hardening.test.js +1 -1
- package/server/lib/spaces/host.js +2 -0
- package/server/lib/spaces/journey.js +66 -5
- package/server/lib/spaces/journey.test.js +95 -4
- package/server/lib/spaces/layout.js +1 -1
- package/server/lib/spaces/places/docker-disk.js +38 -14
- package/server/lib/spaces/places/docker-disk.test.js +80 -1
- package/server/lib/spaces/places/docker.js +35 -11
- package/server/lib/spaces/places/fake-docker.js +22 -3
- package/server/lib/spaces/places/memory-place.js +3 -0
- package/server/lib/spaces/places/packed.docker.live.test.js +1 -1
- package/server/lib/spaces/routes.js +5 -0
- package/server/lib/spaces/routes.test.js +4 -2
- package/server/lib/spaces/run-command.js +9 -2
- package/server/lib/spaces/tools.js +4 -5
- package/server/lib/spaces/tools.test.js +2 -2
- package/server/lib/terminal/runtime.js +18 -6
- package/server/lib/terminal/runtime.test.js +66 -0
- package/server/lib/tts/index.js +3 -0
- package/server/lib/tts/service.js +4 -2
- package/server/lib/walkthrough/DOCUMENTATION.md +3 -1
- package/server/lib/walkthrough/index.js +2 -3
- package/server/lib/walkthrough/pr-source.test.js +22 -0
- package/server/lib/walkthrough/sources.js +6 -1
- package/server/opencode-proxy.test.js +127 -0
- package/bin/lib/commands-startup.test.js +0 -15
- package/dist/assets/CodeMirrorCommentWidgets-CVDSjcrP.js +0 -1
- package/dist/assets/DiffView-Ct7vL3fD.js +0 -4
- package/dist/assets/FilesView-DT0uEYgT.js +0 -17
- package/dist/assets/GuestSurfacePane-DVvk1VPu.js +0 -1
- package/dist/assets/LinearIssuesView-C10MwA9h.js +0 -1
- package/dist/assets/MarkdownImageGallery-BbN_K_3d.js +0 -1
- package/dist/assets/MarkdownRendererImpl-BLt2Tkk9.js +0 -10
- package/dist/assets/OnboardingScreen-Bgp5A3WB.js +0 -1
- package/dist/assets/PierreDiffViewer-CWJLj-S-.js +0 -210
- package/dist/assets/PlanView-DsRWnsOI.js +0 -5
- package/dist/assets/PublishDialog-CCeKloRu.js +0 -2
- package/dist/assets/SettingsView-BuPPsNPp.js +0 -30
- package/dist/assets/SettingsWindow-CM5fL8Ot.js +0 -1
- package/dist/assets/SubmoduleDiffSummary-CfsMcfiQ.js +0 -1
- package/dist/assets/ToolOutputDialog-mZrfSofz.js +0 -15
- package/dist/assets/ToolPartDiffPreview-BUGCRYEL.js +0 -8
- package/dist/assets/WalkthroughView-ClBo7PPd.js +0 -4
- package/dist/assets/appThemeRegistry-CxzMxR-H.js +0 -1
- package/dist/assets/de-CBla4hjd.js +0 -14
- package/dist/assets/es-BmnZtxTD.js +0 -20
- package/dist/assets/fileTreeStatus-BSHFIGEg.js +0 -1
- package/dist/assets/fr-OVKIBUZO.js +0 -18
- package/dist/assets/index-CKCFKmjF.js +0 -1
- package/dist/assets/index-Dbx4V4GN.css +0 -1
- package/dist/assets/index-vQ1Pg1cr.js +0 -61
- package/dist/assets/ja-6v-yr-gE.js +0 -20
- package/dist/assets/ko-I_ZLvgQ9.js +0 -20
- package/dist/assets/main-CmO4dRtR.js +0 -2
- package/dist/assets/main-b9vqhlYM.js +0 -999
- package/dist/assets/markdownCore-BPEZRQfP.js +0 -7
- package/dist/assets/miniChat-B5Oi7B-6.js +0 -2
- package/dist/assets/mobile-CVtShif9.js +0 -2
- package/dist/assets/nl-DcvIJf46.js +0 -20
- package/dist/assets/patchFileDiff-CW3wCH1O.js +0 -13
- package/dist/assets/pl-JxCUl0sd.js +0 -20
- package/dist/assets/pt-BR-L89mjja2.js +0 -20
- package/dist/assets/relocateRestoredSession-DYh_9oBa.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-BD-1JHSg.js +0 -2
- package/dist/assets/renderMobileApp-7s5InXt1.js +0 -25
- package/dist/assets/runtimeEndpointReset-DqLJC6L1.js +0 -53
- package/dist/assets/shikiHighlight-CXgZnvHh.js +0 -1
- package/dist/assets/space-apply-1trGVIl8.js +0 -1
- package/dist/assets/space-close-y7j-NuBv.js +0 -1
- package/dist/assets/tr-ka5J1flt.js +0 -11
- package/dist/assets/uk-PyGe6Q_u.js +0 -20
- package/dist/assets/useInlineCommentController-CrjSGCpi.js +0 -2
- package/dist/assets/vendor-codemirror-lang-python-B7ClrMIT.js +0 -3
- package/dist/assets/vendor-codemirror-lang-xml-C8tGnS64.js +0 -1
- package/dist/assets/vendor-codemirror-language-data-q2bKO1EM.js +0 -2
- package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +0 -1
- package/dist/assets/vendor-katex-CHD9BdDO.js +0 -257
- package/dist/assets/vendor-katex-Cp579UoJ.css +0 -1
- package/dist/assets/zh-CN-B0P2tybJ.js +0 -20
- package/dist/assets/zh-TW-Bs9C5cN8.js +0 -20
|
@@ -1,999 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-ClBo7PPd.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-DCqCVGlT.js","assets/index-vQ1Pg1cr.js","assets/vendor-zod-CxRSdNoV.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DHzhmLwV.js","assets/index-Dbx4V4GN.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-base-ui-DX96QhTP.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.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-tanstack-react-virtual-H_JmXOFV.js","assets/vendor-tanstack-virtual-core-Dxc8hSTB.js","assets/vendor-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.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-ByBn5zIW.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-G3UuR-be.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-Bniqp7p5.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-CpGYXGuo.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DW1FQz9_.js","assets/vendor-codemirror-lang-json-58T70Hqs.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-B07blnnZ.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-DaH9adfE.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BLKnlLP4.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-q2bKO1EM.js","assets/vendor-codemirror-lang-python-B7ClrMIT.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-DpmhalwN.js","assets/vendor-legendapp-list-DViGR95I.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-DqLJC6L1.js","assets/space-apply-1trGVIl8.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/patchFileDiff-CW3wCH1O.js","assets/parseDiffFromFile-Cy0PNxun.js","assets/computeVirtualFileMetrics-CmPe29DM.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/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-CWJLj-S-.js","assets/isDiffPlainText-CQmDCnEv.js","assets/VirtualizedFileDiff-BTJVRkyo.js","assets/Virtualizer-xCEYz34p.js","assets/useInlineCommentController-CrjSGCpi.js","assets/appThemeRegistry-CxzMxR-H.js","assets/textMateThemeFromAppTheme-CDlKffWz.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-BowwS8kq.js","assets/fileTreeStatus-BSHFIGEg.js","assets/sessionOwnership-Bs1xbRfB.js","assets/DiffView-Ct7vL3fD.js","assets/SubmoduleDiffSummary-CfsMcfiQ.js","assets/changesTree-CePHbFcj.js","assets/FilesView-DT0uEYgT.js","assets/shikiHighlight-CXgZnvHh.js","assets/vendor-codemirror-search-ib-sHD5W.js","assets/vendor-replit-codemirror-vim-DkzqxN2H.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-B_EPRjzy.js","assets/Virtualizer-CGNyscoc.js","assets/isFilePlainText-CYBUzW4I.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-CVDSjcrP.js","assets/GitView-DzuzhIPx.js","assets/PublishDialog-CCeKloRu.js","assets/LinearIssuesView-C10MwA9h.js","assets/PlanView-DsRWnsOI.js","assets/GuestSurfacePane-DVvk1VPu.js","assets/SettingsWindow-CM5fL8Ot.js","assets/SettingsView-BuPPsNPp.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-Bgp5A3WB.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as He,R as l,j as s,r as Ms,c as um,h as fm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{L as En,N as lo,O as pm,P as su,h as Zs,C as nu,u as Ce,Q as _t,R as Fl,S as mm,y as _o,T as cn,a as ss,D as co,o as at,U as Hs,V as eo,W as ru,X as hm,Y as gm,Z as bm,_ as xm,$ as ou,n as Fs,a0 as Un,a1 as ta,e as Yo,a2 as ym,a3 as vm,a4 as wm,a5 as Sm,a6 as jm,a7 as km,a8 as iu,B as xn,H as to,a9 as Dr,aa as Cm,ab as fi,ac as au,ad as _n,ae as Kn,af as Nm,ag as lu,ah as Am,ai as Pm,aj as Im,ak as Dm,al as cr,am as Qo,an as sa,ao as qa,d as Xo,z as kr,v as Ds,ap as Em,aq as cu,ar as Rm,as as na,at as du,au as uu,x as Mm,i as Tm,q as Om,t as Bm,av as Ko,aw as Wo,ax as Fm,ay as Ll,az as Lm,aA as $m,aB as _m,aC as Km,aD as $l,aE as _l,aF as Kl,aG as Wl,aH as Wm,F as zl,aI as zm,aJ as Vm,aK as Um,aL as Hm,I as Gm,J as qm,K as Ym}from"./index-vQ1Pg1cr.js";import{_ as Sn}from"./vendor-vite-runtime-DD1OZmLC.js";import{a6 as Vl,a7 as Ri,a8 as un,a9 as ra,aa as Ul,ab as Qm,ac as Xm,ad as Jm,ae as Zm,af as eh,ag as th,ah as sh,ai as Hl,aj as nh,ak as rh,al as oh,am as Ya,c as ih,l as fu,an as ah,a as lh,S as ch,ao as pu,h as oa,ap as dh,aq as Mi,ar as Gl,as as ql,at as Yl,au as uh,av as fh,y as ph,N as mh,A as hh,z as gh,E as bh,aw as mu,ax as Sr,ay as Ql,az as Xl,aA as Ti,aB as Jl,P as xh,a0 as hu,T as yh,aC as vh,aD as wh,aE as Sh,aF as jh,i as Zl,aG as kh,aH as Ch,C as Nh,b as gu,aI as bu,k as Ah,aJ as xu,aK as Ph,j as Ih,aL as Dh,e as Eh,aM as jr,f as Oi,aN as Rh,aO as ec,aP as Mh,u as Qr,s as Th,r as Oh,D as Bh,aQ as Fh,d as Lh,F as $h,$ as _h,L as Kh,aR as Wh,V as zh,W as Vh,X as Uh,Y as Hh,Z as Gh,a1 as qh,aS as Yh,aT as Qh,a2 as Xh,a5 as Jh,aU as Zh,aV as eg,aW as tg,O as sg,aX as ng,J as rg,K as og,M as ig,Q as ag,U as lg,R as cg,_ as dg,aY as ug}from"./runtimeEndpointReset-DqLJC6L1.js";import{f as vt,h as Se,bN as ts,I as T,g as ur,t as Be,aU as qs,bO as Vs,aW as Ys,aT as Qs,_ as uo,N as jn,aA as fr,bP as Yn,o as Gn,bQ as tc,bR as fg,bS as pg,av as Ct,aw as Nt,ax as jt,b as as,z as Je,J as mg,bT as yu,bU as yo,u as Ls,r as vn,D as vu,C as wu,bV as ia,bW as hg,bX as Su,bY as ju,G as ku,bZ as gg,b_ as bg,b$ as sc,c0 as nc,c1 as Cu,c2 as xg,c3 as rc,c4 as yg,c5 as Nu,c6 as Qa,c7 as aa,c8 as Au,c9 as vg,ca as wg,cb as Sg,R as Pu,cc as jg,cd as kg,ce as Cg,n as Nr,cf as Ng,cg as Ag,ch as Pg,p as Ig,ci as Iu,cj as Dg,ck as Eg,cl as Rg,cm as Du,cn as Eu,co as Ru,cp as Mu,cq as Tu,cr as Ou,cs as Bu,ct as fo,cu as Xa,bf as Ja,cv as dr,cw as po,cx as Mg,cy as en,cz as tn,cA as pn,cB as mn,cC as hn,cD as pr,B as ut,cE as Mn,b4 as zs,cF as Tg,cG as Og,cH as Fu,cI as Lu,aG as Hn,cJ as Cr,cK as Bg,cL as Fg,cM as $u,aS as zn,cN as vs,aK as _u,cO as la,cP as Ar,cQ as Ku,cR as Wu,cS as zu,cT as Vu,cU as Lg,cV as ca,cW as $g,cX as _g,cY as Za,cZ as oc,c_ as ic,c$ as ac,d0 as lc,d1 as vo,b6 as Uu,a8 as Xr,d2 as wo,d3 as cc,d4 as Kg,Z as Hu,d5 as Wg,d6 as zg,d7 as Vg,aB as Ug,aC as el,aD as Hg,K as Gg,L as mr,d8 as Gu,an as qg,d9 as Yg,da as Qg,a$ as Xg,db as Jg,dc as tl,dd as Zg,de as qu,df as da,dg as lr,b3 as sl,dh as eb,di as Yu,dj as Qu,dk as Xu,dl as zo,dm as Ju,dn as tb,l as js,s as sb,dp as nb,dq as rb,bi as Qn,dr as ob,O as Zu,ds as ib,dt as ab,du as lb,dv as hr,dw as ef,dx as cb,dy as db,dz as ub,dA as Bi,dB as fb,dC as pb,dD as mb,dE as tf,dF as hb,dG as nl,dH as gb,dI as sf,dJ as bb,be as ua,dK as fa,dL as dc,dM as xb,dN as uc,dO as Hr,dP as yb,dQ as fc,dR as vb,dS as Fn,c as Tr,d as rl,ac as ol,dT as nf,dU as Rn,dV as wb,dW as rf,dX as Sb,dY as jb,dZ as kb,b5 as Cb,d_ as Nb,ai as Ab,ae as of,d$ as Pb,bb as pa,e0 as Ib,e1 as Db,e2 as Eb,e3 as Rb,e4 as sr,e5 as Mb,e6 as Tb,am as Jo,az as Ob,e7 as af,e8 as As,e9 as Bb,ea as Fb,eb as lf,ec as Lb,ed as il,af as al,ee as pc,ak as Zo,e as ll,ef as $b,aj as cl,eg as cf,eh as ma,P as df,$ as uf,a0 as ff,a1 as pf,ei as _b,ej as Kb,ek as cs,el as Wb,em as dl,en as mf,eo as hf,ep as gf,eq as so,er as mc,es as zb,et as no,eu as Vb,ev as Ub,ew as ul,ex as ei,ey as fl,ez as bf,eA as xf,eB as yf,eC as vf,eD as wf,eE as Hb,E as Gb,a2 as qb,a6 as pl,ar as Yb,a4 as Qb,a3 as hc,eF as Xb,eG as Jb,F as Sf,eH as Zb,eI as ex,eJ as tx,eK as sx,S as Fi,eL as Jr,bq as pi,a7 as ha,eM as nx,eN as rx,eO as ox,eP as ix,as as ax,eQ as jf,ab as lx,eR as mi,eS as cx,eT as dx,eU as ro,ah as ux,H as ml,eV as fx,eW as px,eX as gc,eY as mx,eZ as hx,ad as gx,ag as bx,e_ as xx,e$ as nr,f0 as yx,f1 as vx,f2 as wx,f3 as Sx,bv as bc,aq as xc,ap as yc,f4 as jx,ao as kx,f5 as Cx,Q as vc,T as Li,U as Nx,f6 as Ax,Y as Px,f7 as Ix,f8 as Dx,f9 as Ex,fa as Rx,fb as Mx,fc as Tx,fd as ti,fe as Ox,ff as Bx,fg as wc,fh as Fx,fi as Lx,fj as $x,fk as Sc,fl as _x,a as kf,fm as ga,fn as hl,a5 as Cf,fo as Kx,fp as Vo,fq as Wx,i as zx,fr as Vx,fs as Ux,ft as Hx,fu as Gx,fv as qx,fw as Yx,fx as jc,fy as Qx,bj as Xx,bk as Jx,bm as Zx,bl as ey,bo as ty,bp as sy,br as ny,bu as ry,bs as oy,bt as iy,bJ as ay,bK as ly,bL as cy,bM as dy,bD as uy,bF as fy,bG as py,bH as my,bI as hy}from"./useAppFontEffects-DCqCVGlT.js";import{u as Nf,S as kc,C as gy,t as by,W as Af,f as xy,G as yy,a as vy}from"./useRootScrollLock-BowwS8kq.js";import{u as rr,O as Cc,D as wy,a as Sy,b as jy,G as ky}from"./fileTreeStatus-BSHFIGEg.js";import{i as Cy}from"./space-apply-1trGVIl8.js";import{f as hi,h as In,T as gi,M as bi,D as xi,j as yi,d as Ny,b as Ay,k as Py,i as Iy}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as vi,S as gl,h as Dy,a as Pf,v as If,s as Ey}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as wi}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Df,M as Ef,C as Rf,a as ba,b as xa,c as ya,d as Mf,e as Ry,f as My}from"./vendor-base-ui-DX96QhTP.js";import{c as bl,u as Or,p as Ty}from"./vendor-zustand-BAGL70zf.js";import{r as xl,a as Si,n as Oy,s as qn,o as Nc,b as Ac}from"./vendor-zod-CxRSdNoV.js";import{c as By}from"./sessionOwnership-Bs1xbRfB.js";import{u as Fy}from"./vendor-tanstack-react-virtual-H_JmXOFV.js";import{d as Ly}from"./vendor-tanstack-virtual-core-Dxc8hSTB.js";const $y="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",_y="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",$i=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?$y:t.id==="terminal"?_y:void 0}),Pc=t=>{const e=He.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:o}=t,[i,d]=l.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const c=a,u=r||o;if(u&&!i){let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>d(!0),e[2]=m):m=e[2];let y;return e[3]!==u?(y=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:m}),e[3]=u,e[4]=y):y=e[4],y}let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=Se("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=f):f=e[5];let p;return e[6]!==c?(p=s.jsx("span",{className:f,children:c}),e[6]=c,e[7]=p):p=e[7],p},Ky=t=>{const e=He.c(75),{directory:n,className:r}=t,{t:o}=vt(),i=rr(Wy),d=rr(zy),a=rr(Vy),c=rr(Uy),u=rr(Hy),f=rr(Gy),p=rr(qy);let m,y;e[0]!==u?(m=()=>{u()},y=[u],e[0]=u,e[1]=m,e[2]=y):(m=e[1],y=e[2]),l.useEffect(m,y);const x=En()&&lo();let w;e:{let pe;e[3]!==d||e[4]!==i?(pe=d.find(de=>de.id===i)??d.find(Yy)??d[0]??Cc[0],e[3]=d,e[4]=i,e[5]=pe):pe=e[5];const J=pe;if(J){let de;e[6]!==J?(de=$i(J),e[6]=J,e[7]=de):de=e[7],w=de;break e}let ge;e[8]===Symbol.for("react.memo_cache_sentinel")?(ge=$i(Cc[0]),e[8]=ge):ge=e[8],w=ge}const b=w;if(!x||!n||d.length===0)return null;let g;e[9]!==n?(g=async pe=>{await pm(n,pe.id,pe.appName)||await su(n,pe.appName)},e[9]=n,e[10]=g):g=e[10];const h=g;let v;e[11]!==h||e[12]!==p?(v=async pe=>{await p(pe.id),await h(pe)},e[11]=h,e[12]=p,e[13]=v):v=e[13];const S=v;let j;e[14]!==n||e[15]!==o?(j=async()=>{(await ur(n)).ok&&Be.success(o("openInApp.toast.pathCopied"))},e[14]=n,e[15]=o,e[16]=j):j=e[16];const N=j;let C;e[17]!==r?(C=Se("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]=C):C=e[18];let B;e[19]!==h||e[20]!==b?(B=()=>{h(b)},e[19]=h,e[20]=b,e[21]=B):B=e[21];const W=c&&"animate-pulse";let F;e[22]!==W?(F=Se("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",W),e[22]=W,e[23]=F):F=e[23];let $;e[24]!==b.label||e[25]!==o?($=o("openInApp.actions.openInAria",{app:b.label}),e[24]=b.label,e[25]=o,e[26]=$):$=e[26];let K;e[27]!==b.fallbackIconDataUrl||e[28]!==b.iconDataUrl||e[29]!==b.label?(K=s.jsx(Pc,{label:b.label,iconDataUrl:b.iconDataUrl,fallbackIconDataUrl:b.fallbackIconDataUrl}),e[27]=b.fallbackIconDataUrl,e[28]=b.iconDataUrl,e[29]=b.label,e[30]=K):K=e[30];let I;e[31]!==F||e[32]!==$||e[33]!==K||e[34]!==B?(I=s.jsx("button",{type:"button",onClick:B,className:F,"aria-label":$,children:K}),e[31]=F,e[32]=$,e[33]=K,e[34]=B,e[35]=I):I=e[35];let z;e[36]===Symbol.for("react.memo_cache_sentinel")?(z=Se("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]=z):z=e[36];let k;e[37]!==o?(k=o("openInApp.actions.chooseAppAria"),e[37]=o,e[38]=k):k=e[38];let M;e[39]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(T,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=M):M=e[39];let V;e[40]!==k?(V=s.jsx(qs,{asChild:!0,children:s.jsx("button",{type:"button",className:z,"aria-label":k,children:M})}),e[40]=k,e[41]=V):V=e[41];let O;e[42]!==N?(O=()=>{N()},e[42]=N,e[43]=O):O=e[43];let E;e[44]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[44]=E):E=e[44];let R;e[45]!==o?(R=o("openInApp.actions.copyPath"),e[45]=o,e[46]=R):R=e[46];let _;e[47]!==R?(_=s.jsx("span",{className:"typography-ui-label text-foreground",children:R}),e[47]=R,e[48]=_):_=e[48];let U;e[49]!==O||e[50]!==_?(U=s.jsxs(ts,{className:"flex items-center gap-2",onClick:O,children:[E,_]}),e[49]=O,e[50]=_,e[51]=U):U=e[51];let me;e[52]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(Vs,{}),e[52]=me):me=e[52];let ce;if(e[53]!==d||e[54]!==S||e[55]!==b.id){let pe;e[57]!==S||e[58]!==b.id?(pe=J=>{const ge=$i(J);return s.jsxs(ts,{className:"flex items-center gap-2",onClick:()=>{S(J)},children:[s.jsx(Pc,{label:J.label,iconDataUrl:J.iconDataUrl,fallbackIconDataUrl:ge.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:J.label}),b.id===J.id?s.jsx(T,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},J.id)},e[57]=S,e[58]=b.id,e[59]=pe):pe=e[59],ce=d.map(pe),e[53]=d,e[54]=S,e[55]=b.id,e[56]=ce}else ce=e[56];let oe;e[60]!==a||e[61]!==f||e[62]!==o?(oe=a?s.jsxs(ts,{className:"flex items-center gap-2",onClick:()=>{f(!0)},children:[s.jsx(T,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=f,e[62]=o,e[63]=oe):oe=e[63];let ie;e[64]!==U||e[65]!==ce||e[66]!==oe?(ie=s.jsxs(Ys,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[U,me,ce,oe]}),e[64]=U,e[65]=ce,e[66]=oe,e[67]=ie):ie=e[67];let xe;e[68]!==V||e[69]!==ie?(xe=s.jsxs(Qs,{children:[V,ie]}),e[68]=V,e[69]=ie,e[70]=xe):xe=e[70];let G;return e[71]!==I||e[72]!==xe||e[73]!==C?(G=s.jsxs("div",{className:C,children:[I,xe]}),e[71]=I,e[72]=xe,e[73]=C,e[74]=G):G=e[74],G};function Wy(t){return t.selectedAppId}function zy(t){return t.availableApps}function Vy(t){return t.isCacheStale}function Uy(t){return t.isScanning}function Hy(t){return t.initialize}function Gy(t){return t.loadInstalledApps}function qy(t){return t.selectApp}function Yy(t){return t.id===wy}const si=new Map,va=new Set,Tf=()=>{for(const t of va)t()},_i=(t,e)=>{const n=t.trim();n&&(e.length===0?si.delete(n):si.set(n,[...e]),Tf())},Qy=t=>{si.delete(t.trim())&&Tf()},Of=[],Xy=t=>si.get(t.trim())??Of,Jy=t=>(va.add(t),()=>{va.delete(t)}),Zy=t=>{const e=He.c(2);let n;return e[0]!==t?(n=()=>Xy(t),e[0]=t,e[1]=n):n=e[1],l.useSyncExternalStore(Jy,n,ev)};function ev(){return Of}const tv=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],sv=["dev","start","preview","serve"];async function nv(t,e,n){if(!t)return null;const r=iv(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const o=av(n);if(o){const i=await lv(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await rv(t)){const o=await ov(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function rv(t){const e=`${t}/index.html`,n=await ni(e,t);return typeof n=="string"&&n.trim().length>0}async function ov(){try{const t=await Zs("/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 iv(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(sv.some(o=>n.includes(o)))return e}return null}function av(t){for(const{pattern:e}of tv)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function lv(t){const e=await ni(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.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,o]of n){const i=await ni(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function ni(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await Zs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=nu()?.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 Zs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function cv(t){try{const e=await ni(`${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 dv=/\{(worktree|branch)\}/g,Ki=63,uv=new Set(["main","master"]),Bf=t=>/\{(worktree|branch)\}/.test(t??""),fv=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const n=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},Ff=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Ki)return e;const n=await fv(e);return n?`${e.slice(0,Ki-7).replace(/-+$/,"")}-${n}`:e.slice(0,Ki).replace(/-+$/,"")},pv=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},mv=async(t,e,n)=>{const r=n.includes("{branch}"),o=n.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:pv(i.current),linkedWorktree:o}},hv=async t=>!t.linkedWorktree||!t.branch||uv.has(t.branch)?"":Ff(t.branch.split("/").pop()??""),gv=t=>{const e=t.lastIndexOf("@"),n=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,d=o>=0?r.slice(o):"",a=i.split(".").map(c=>c.replace(/^-+|-+$/g,"")).filter(Boolean);return`${n}${a.join(".")}${d}`},bv=async(t,e)=>{const n={worktree:await hv(e),branch:e.branch?await Ff(e.branch):""},r=t.replace(dv,(c,u)=>n[u]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",d="",a=""]=o;return`${i}${gv(d)}${a}`},xv=async(t,e,n)=>Bf(e)?bv(e,await mv(t,n,e)):e,fn="__openchamber_auto_discover_preview__",yv=15e3,vv=3e3,Wi=t=>t.id===fn?"scan-2":rh.find(n=>n.key===t.icon)?.Icon??"play",wv=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}},Sv=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:o=!1})=>{const{t:i}=vt(),{currentTheme:d}=uo(),{terminal:a,runtime:c,git:u}=jn(),f=fr(),{isMobile:p}=Yn(),m=l.useMemo(()=>En(),[]),y=Vl(L=>L.instances),x=Vl(L=>L.load),w=Ce(L=>L.terminalShell),b=Ce(L=>L.terminalLoginShells.includes(L.terminalShell)),g=Ce(L=>L.setSettingsPage),h=Ce(L=>L.setSettingsDialogOpen),v=Ce(L=>L.setSettingsProjectsSelectedId),S=Ce(L=>L.openContextPreview),j=_t(L=>L.ensureDirectory),N=_t(L=>L.reconcileServerSessions),C=_t(L=>L.setTabLabel),B=_t(L=>L.setTabIconKey),W=_t(L=>L.setActiveTab),F=_t(L=>L.setConnecting),$=_t(L=>L.setTabSessionId),K=_t(L=>L.setTabPurpose),I=_t(L=>L.allocateActionExecution),z=_t(L=>L.setTabLifecycle),k=_t(L=>L.setTabPreviewUrl),M=_t(L=>L.matchesActionExecution),V=_t(L=>L.captureStartedActionMutationRevisions),[O,E]=l.useState([]),R=l.useRef(null),[_,U]=l.useState(null),[me,ce]=l.useState(!1),oe=l.useRef({}),ie=l.useRef({}),xe=l.useRef({}),G=l.useRef(new Set),pe=l.useRef(0),[J,ge]=l.useState({}),de=t?.id??null,Ae=t?.path??"",he=l.useMemo(()=>de?{id:de,path:Ae}:null,[de,Ae]);l.useEffect(()=>{m&&x().catch(()=>{})},[m,x]);const Re=l.useCallback(async L=>{await Gn(L)},[]),se=l.useCallback(async()=>{if(!he)return;const L=pe.current+1;pe.current=L,ce(!0);try{const te=await tc(he);if(pe.current!==L)return;R.current=te;const ve=te.projectActions;E(ve),U(P=>P===fn||P&&ve.some(Z=>Z.id===P)?P:null)}catch{if(pe.current!==L)return}finally{pe.current===L&&ce(!1)}},[he]),Ne=l.useMemo(()=>Ri(e||he?.path||""),[e,he?.path]),be=l.useMemo(()=>Ri(he?.path||""),[he?.path]),we=l.useMemo(()=>Ri(f||"")||Ne,[f,Ne]),ye=l.useRef(we);l.useEffect(()=>{ye.current=we},[we]);const Pe=_t(L=>Ne?L.getDirectoryState(Ne):void 0),Oe=_t(L=>be&&be!==Ne?L.getDirectoryState(be):void 0),$e=l.useMemo(()=>{const L=Ne?[{directory:Ne,state:Pe}]:[];return be&&be!==Ne&&L.push({directory:be,state:Oe}),L},[Pe,Ne,be,Oe]),ze=l.useMemo(()=>{const L=Ne?[Ne]:[];return be&&be!==Ne&&L.push(be),L},[Ne,be]),Ue=l.useCallback(L=>L.id!==fn&&L.runIn==="parent"&&be||Ne,[Ne,be]),q=l.useCallback((L,te,ve)=>`${L}::${te}::${ve}`,[]),ue=l.useCallback((L,te,ve=_t.getState())=>L?ve.getDirectoryState(L)?.tabs.find(P=>P.purpose.type==="project-action"&&P.purpose.actionId===te)??null:null,[]),A=l.useMemo(()=>{const L={};for(const{directory:te,state:ve}of $e)for(const P of ve?.tabs??[]){if(P.purpose.type!=="project-action"||!P.purpose.executionId||!P.terminalSessionId||P.lifecycle==="idle"||P.lifecycle==="exited")continue;const Z=un(te,P.purpose.actionId),Te=q(te,P.purpose.actionId,P.purpose.executionId);L[Z]={directory:te,actionId:P.purpose.actionId,tabId:P.id,sessionId:P.terminalSessionId,executionId:P.purpose.executionId,status:P.lifecycle==="stopping"?"stopping":J[Te]?"waiting-for-preview":"running"}}return L},[q,J,$e]),Q=l.useCallback((L,te,ve)=>{const P=un(L,te),Z=q(L,te,ve),Le=oe.current[P]?.executionId===ve,We=globalThis.window,Ge=zt=>{We?.clearTimeout(xe.current[zt]),delete xe.current[zt]};Le&&(delete oe.current[P],Ge(P)),ie.current[Z]?.(),delete ie.current[Z],Ge(Z),ge(zt=>{if(!zt[Z])return zt;const Ye={...zt};return delete Ye[Z],Ye})},[q]),le=l.useCallback(L=>{ie.current[L]?.(),delete ie.current[L]},[]),Ie=l.useCallback(L=>{window.clearTimeout(xe.current[L]),delete xe.current[L]},[]);l.useEffect(()=>{const L=ie.current,te=xe.current;return()=>{for(const ve of Object.keys(L))le(ve);for(const ve of Object.keys(te))Ie(ve)}},[Ie,le]),l.useEffect(()=>{const L=new Set(ze);for(const te of Object.values(oe.current))L.has(te.directory)||Q(te.directory,te.actionId,te.executionId);for(const te of Object.keys(ie.current)){const ve=te.split("::",1)[0]??"";L.has(ve)||le(te)}},[Q,le,ze]);const re=l.useCallback((L,te)=>{Ce.getState().openContextPanelTab(L,{mode:"terminal",targetDirectory:te===L?null:te})},[]),H=l.useMemo(()=>_?O.find(L=>L.id===_)??null:null,[O,_]),ne=l.useMemo(()=>({id:fn,name:i("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[i]),X=!p,fe=l.useMemo(()=>X?[ne,...O]:O,[O,ne,X]);l.useEffect(()=>{se()},[se]),l.useEffect(()=>{const L=ze.map(te=>ra(a,te,V,ve=>N(te,ve.sessions,{startedActionMutationRevisions:ve.startedActionMutationRevisions})));return()=>{for(const te of L)te()}},[V,N,a,ze]),l.useEffect(()=>{for(const{directory:L,state:te}of $e)if(L)for(const ve of te?.tabs??[]){if(ve.purpose.type!=="project-action")continue;const P=ve.purpose.actionId,Z=fe.find(We=>We.id===P),Te=Z?.name??P,Le=Z?.icon||"play";ve.label!==Te&&C(L,ve.id,Te),ve.iconKey!==Le&&B(L,ve.id,Le)}},[fe,B,C,$e]),l.useEffect(()=>{const L=globalThis.window;if(!L)return;const te=ve=>{const P=ve.detail;de&&(P?.projectId&&P.projectId!==de||se())};return L.addEventListener(Ul,te),()=>{L.removeEventListener(Ul,te)}},[se,de]),l.useEffect(()=>{_&&(_===fn&&X||O.some(L=>L.id===_)||U(null))},[O,X,_]),l.useEffect(()=>{const L=ve=>{delete xe.current[ve];const P=oe.current[ve];if(!P||P.openedUrl)return;const Z=q(P.directory,P.actionId,P.executionId),Te=P.announced;if(Te.length!==0){if(window.clearTimeout(xe.current[Z]),delete xe.current[Z],P.openedUrl=!0,ge(Le=>{if(!Le[Z])return Le;const We={...Le};return delete We[Z],We}),Te.length===1){_i(P.directory,[]),k(P.directory,P.tabId,Te[0],{locked:!1,autoOpened:!0}),S(P.directory,Te[0]);return}P.offering=!0,_i(P.directory,Te),Ce.getState().openContextSurface(P.directory,"browser"),Be.info(i("projectActions.toast.multipleServers"))}},te=()=>{const ve=_t.getState(),P=ve.sessions,Z=A;for(const[Te,Le]of Object.entries(Z)){const Ge=P.get(Le.directory)?.tabs.find(St=>St.id===Le.tabId);if(!Ge||Ge.terminalSessionId!==Le.sessionId){Q(Le.directory,Le.actionId,Le.executionId);continue}const zt=oe.current[Te],Ye=zt?.executionId===Le.executionId?zt:{hostDirectory:ye.current||Le.directory,directory:Le.directory,tabId:Le.tabId,actionId:Le.actionId,executionId:Le.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};oe.current[Te]=Ye;const Ee=fe.find(St=>St.id===Le.actionId),Pt=ve.getBuffer(Le.directory,Le.tabId).chunks;if(!Ee||Pt.length===0)continue;const Lt=Pt.filter(St=>Ye.lastSeenChunkId===null||St.id>Ye.lastSeenChunkId);if(Lt.length===0)continue;const os=Lt.map(St=>St.data).join(""),it=`${Ye.tail}${os}`;for(const St of th(it))Ye.proxiedPorts.includes(St)||Ye.proxiedPorts.push(St);if(Ye.openInPreview&&(!Ye.openedUrl||Ye.offering)){const St=sh(it,{proxiedPorts:Ye.proxiedPorts,namedAddressesReachable:!Hl()}),Yt=Ye.announced.length;for(const Vt of St)Ye.announced.includes(Vt)||Ye.announced.push(Vt);const ft=Ye.announced.length-Yt;Ye.offering&&ft>0?_i(Le.directory,Ye.announced):!Ye.openedUrl&&Yt===0&&Ye.announced.length>0&&(window.clearTimeout(xe.current[Te]),xe.current[Te]=window.setTimeout(()=>L(Te),vv))}const Ve=!Ye.openedUrl&&Ee.autoOpenUrl===!0&&!Ye.openInPreview?nh(it,{proxiedPorts:Ye.proxiedPorts,namedAddressesReachable:!Hl()}):null,Qt=Lt[Lt.length-1]?.id??Ye.lastSeenChunkId;if(Ye.lastSeenChunkId=Qt,Ye.tail=it.slice(-512),Ve)if(Ye.openedUrl=!0,Ye.openInPreview){const St=Z[Te];St&&(k(St.directory,St.tabId,Ve,{locked:!1,autoOpened:!1,expectedExecutionId:St.executionId}),St.status==="waiting-for-preview"&&ge(Yt=>{const ft=q(St.directory,St.actionId,St.executionId);if(!Yt[ft])return Yt;const Vt={...Yt};return delete Vt[ft],Vt}),window.clearTimeout(xe.current[Te]),delete xe.current[Te],S(St.directory,Ve))}else Re(Ve),Be.success(i("projectActions.toast.openedUrlFromOutput"));oe.current[Te]=Ye}for(const Te of Object.keys(oe.current))if(!Z[Te]){const Le=oe.current[Te],We=Le?P.get(Le.directory)?.tabs.find(zt=>zt.id===Le.tabId):void 0;if(We?.purpose.type==="project-action"&&We.purpose.executionId===Le?.executionId&&!!We.terminalSessionId&&We.lifecycle!=="idle"&&We.lifecycle!=="exited")continue;delete oe.current[Te],window.clearTimeout(xe.current[Te]),delete xe.current[Te]}};return te(),_t.subscribe((ve,P)=>{(ve.sessions!==P.sessions||ve.buffers!==P.buffers)&&te()})},[Q,ye,fe,q,S,Re,A,k,i]),l.useEffect(()=>{for(const{directory:L,state:te}of $e)for(const ve of te?.tabs??[]){if(ve.purpose.type!=="project-action"||!ve.purpose.executionId||!ve.terminalSessionId||ve.lifecycle!=="running")continue;const P=ve.purpose.actionId,Z=ve.purpose.executionId,Te=q(L,P,Z);if(ie.current[Te])continue;const Le=a.connect(ve.terminalSessionId,{onEvent:We=>{if(!M(L,ve.id,Z))return;We.type==="snapshot"&&(_t.getState().replaceBuffer(L,ve.id,We.data??"",We.sequence??0,Fl(We)),We.status==="running"&&_t.getState().setTabLifecycle(L,ve.id,"running",{expectedExecutionId:Z}),We.status==="exited"&&(_t.getState().setTabLifecycle(L,ve.id,"exited",{expectedExecutionId:Z}),_t.getState().setTabPurpose(L,ve.id,{type:"project-action",actionId:P,executionId:null}),Q(L,P,Z)));const Ge=We.type==="data"?We.data??"":"";Ge&&_t.getState().appendToBuffer(L,ve.id,Ge,We.sequence,We.replayData),We.type==="exit"&&(_t.getState().setTabLifecycle(L,ve.id,"exited",{expectedExecutionId:Z}),_t.getState().setTabPurpose(L,ve.id,{type:"project-action",actionId:P,executionId:null}),Q(L,P,Z))},onError:(We,Ge)=>{!Ge||!M(L,ve.id,Z)||(_t.getState().setTabLifecycle(L,ve.id,"exited",{expectedExecutionId:Z}),_t.getState().setTabSessionId(L,ve.id,null,{expectedExecutionId:Z}),_t.getState().setTabPurpose(L,ve.id,{type:"project-action",actionId:P,executionId:null}),Q(L,P,Z))}},L);ie.current[Te]=Le.close}},[Q,q,M,a,$e]);const Fe=l.useCallback(async L=>{const te=Ue(L);if(!te)throw new Error(i("projectActions.error.noActiveDirectory"));const ve=un(te,L.id);j(te);const P=_t.getState(),Z=ue(te,L.id,P),Te=Z?.id??P.createTab(te);C(te,Te,L.name),B(te,Te,L.icon||"play"),Z||K(te,Te,{type:"project-action",actionId:L.id,executionId:null}),W(te,Te);const We=_t.getState().getDirectoryState(te)?.tabs.find(Ge=>Ge.id===Te);return{executionDirectory:te,key:ve,tabId:Te,sessionId:We?.terminalSessionId??null,executionId:We?.purpose.type==="project-action"?We.purpose.executionId:null}},[j,Ue,ue,W,B,C,K,i]),Me=l.useCallback(async L=>{if(c.isVSCode||!o&&p)return;if(!Ne){Be.error(i("projectActions.error.noActiveDirectoryForAction"));return}const te=un(Ue(L),L.id),ve=A[te];if(ve&&ve.status==="running"||G.current.has(te))return;G.current.add(te);let P=null;try{const Z=L.id===fn?await(async()=>{const[It,ke]=await Promise.all([fg({id:he?.id??"",path:Ne}),cv(Ne)]),qe=await nv(Ne,It.actions,ke);if(!qe)throw new Error(i("contextPanel.preview.noDevServer"));return{id:fn,name:i("projectActions.actions.autoDiscover"),command:qe.command,icon:"scan-2",autoOpenUrl:!0,openUrl:qe.previewUrlHint||""}})():L,Te=Z.autoOpenUrl===!0&&(Z.openUrl||"").trim().length>0,Le=!Te&&L.id!==fn,We=ye.current||Ne,{executionDirectory:Ge,key:zt,tabId:Ye}=await Fe(Z),Ee=Qm(Z.command);if(!Ee)throw new Error(i("projectActions.error.failedToRunAction"));const Pt=Z.autoOpenUrl===!0&&m&&(Z.desktopOpenSshForward||"").trim().length>0,Lt=Z.autoOpenUrl&&Z.openUrl||"";let os=!1;const it=Bf(Lt)?await xv(u,Lt,Ge).catch(()=>(os=!0,"")):Lt,Ve=Z.autoOpenUrl?wv(it):null,Qt=Z.autoOpenUrl&&m?Xm(Z.desktopOpenSshForward,y):null;if(a.listSessions){const It=ue(Ge,Z.id);if(It?.purpose.type==="project-action"&&It.purpose.executionId===null){const ke=await Jm(a,Ge,{captureStartedActionMutationRevisions:V});ke&&N(Ge,ke.sessions,{startedActionMutationRevisions:ke.startedActionMutationRevisions})}}const St=ue(Ge,Z.id);let Yt,ft;if(St?.lifecycle==="running"&&St.terminalSessionId&&St.purpose.type==="project-action"&&St.purpose.executionId)Yt=St.terminalSessionId,ft=St.purpose.executionId;else{const It=St?.purpose.type==="project-action"?St.purpose.executionId:null;It&&Q(Ge,Z.id,It);const ke=I(Ge,Ye,Z.id);if(!ke)throw new Error(i("projectActions.error.failedToCreateTerminalSession"));P={directory:Ge,tabId:Ye,id:ke},F(Ge,Ye,!0,{expectedExecutionId:ke});const qe=await Zm({terminal:a,createOptions:{cwd:Ge,shell:w,loginShell:b,themeMode:d.metadata.variant==="light"?"light":"dark",terminalBackground:d.colors.surface.background,terminalForeground:d.colors.syntax.base.foreground},command:Ee,isRunStillExpected:()=>M(Ge,Ye,ke),purpose:{type:"project-action",actionId:Z.id,executionId:ke}});if(!M(Ge,Ye,ke)){qe.sessionId===ke&&await a.close(qe.sessionId).catch(()=>{});return}ft=qe.purpose?.type==="project-action"?qe.purpose.executionId:ke,Yt=qe.sessionId,K(Ge,Ye,{type:"project-action",actionId:Z.id,executionId:ft}),$(Ge,Ye,Yt,{expectedExecutionId:ft}),F(Ge,Ye,!1,{expectedExecutionId:ft})}Le&&We&&re(We,Ge),oe.current[zt]={hostDirectory:We,directory:Ge,tabId:Ye,actionId:Z.id,executionId:ft,lastSeenChunkId:null,openedUrl:!!Qt||!!Ve||Te,tail:"",openInPreview:Z.id===fn,announced:[],offering:!1,proxiedPorts:[]};const Vt=q(Ge,Z.id,ft);F(Ge,Ye,!0,{expectedExecutionId:ft});const et=a.connect(Yt,{onEvent:It=>{if(!M(Ge,Ye,ft)||It.purpose?.type==="project-action"&&It.purpose.executionId!==ft)return;It.type==="snapshot"&&(_t.getState().replaceBuffer(Ge,Ye,It.data??"",It.sequence??0,Fl(It)),_t.getState().setConnecting(Ge,Ye,!1,{expectedExecutionId:ft}),It.purpose?.type==="project-action"&&_t.getState().setTabPurpose(Ge,Ye,{type:"project-action",actionId:It.purpose.actionId,executionId:It.purpose.executionId}),It.status==="running"&&_t.getState().setTabLifecycle(Ge,Ye,"running",{expectedExecutionId:ft}),It.status==="exited"&&(_t.getState().setTabLifecycle(Ge,Ye,"exited",{expectedExecutionId:ft}),_t.getState().setTabPurpose(Ge,Ye,{type:"project-action",actionId:Z.id,executionId:null}),Q(Ge,Z.id,ft)));const ke=It.type==="data"?It.data??"":"";ke&&_t.getState().appendToBuffer(Ge,Ye,ke,It.sequence,It.replayData),It.type==="exit"&&(_t.getState().setTabLifecycle(Ge,Ye,"exited",{expectedExecutionId:ft}),_t.getState().setConnecting(Ge,Ye,!1,{expectedExecutionId:ft}),_t.getState().setTabPurpose(Ge,Ye,{type:"project-action",actionId:Z.id,executionId:null}),Q(Ge,Z.id,ft))},onError:(It,ke)=>{M(Ge,Ye,ft)&&(_t.getState().setConnecting(Ge,Ye,!1,{expectedExecutionId:ft}),ke&&(_t.getState().setTabLifecycle(Ge,Ye,"exited",{expectedExecutionId:ft}),_t.getState().setTabSessionId(Ge,Ye,null,{expectedExecutionId:ft}),_t.getState().setTabPurpose(Ge,Ye,{type:"project-action",actionId:Z.id,executionId:null}),Q(Ge,Z.id,ft)))}},Ge);if(!M(Ge,Ye,ft)){et.close();return}ie.current[Vt]?.(),ie.current[Vt]=et.close,window.clearTimeout(xe.current[Vt]),delete xe.current[Vt],Z.id===fn&&!Ve&&(ge(It=>({...It,[Vt]:!0})),xe.current[Vt]=window.setTimeout(()=>{delete xe.current[Vt];const It=oe.current[zt];!It||It.executionId!==ft||It.openedUrl||It.offering||M(Ge,Ye,ft)&&(ge(ke=>{if(!ke[Vt])return ke;const qe={...ke};return delete qe[Vt],qe}),_t.getState().setActiveTab(Ge,Ye),re(It.hostDirectory,Ge))},yv)),Qt?(k(Ge,Ye,null,{locked:!0,expectedExecutionId:ft}),Re(Qt),Be.success(i("projectActions.toast.openedForwardedUrl"))):Ve?(k(Ge,Ye,Ve,{locked:!0,autoOpened:!0,expectedExecutionId:ft}),S(We,Ve),Be.success(i("projectActions.toast.openedActionUrl"))):os?(k(Ge,Ye,null,{locked:!0,expectedExecutionId:ft}),Be.error(i("projectActions.error.openUrlTemplateUnresolved"))):Te?(k(Ge,Ye,null,{locked:!0,expectedExecutionId:ft}),Be.error(i("projectActions.error.invalidCustomUrlFormat"))):Pt?(k(Ge,Ye,null,{locked:!0,expectedExecutionId:ft}),Be.error(i("projectActions.error.selectedDesktopSshForwardUnavailable"))):k(Ge,Ye,null,{locked:!1,autoOpened:!1,expectedExecutionId:ft})}catch(Z){if(P&&M(P.directory,P.tabId,P.id)){const{directory:Te,tabId:Le,id:We}=P;Q(Te,L.id,We),z(Te,Le,"exited",{expectedExecutionId:We}),K(Te,Le,{type:"project-action",actionId:L.id,executionId:null})}if(Z instanceof Error&&Z.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Z instanceof Error&&(Z.message==="COMMAND_MODE_UNSUPPORTED"||Z.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Be.error(i("projectActions.error.failedToCreateTerminalSession"));return}Be.error(Z instanceof Error?Z.message:i("projectActions.error.failedToRunAction"))}finally{G.current.delete(te)}},[d.colors.surface.background,d.colors.syntax.base.foreground,d.metadata.variant,ye,y,Fe,u,o,p,m,Ne,b,w,Re,S,A,re,c.isVSCode,Ue,M,Q,q,ue,N,I,V,F,z,K,k,$,he?.id,i,a]),tt=l.useCallback(async L=>{const te=un(Ue(L),L.id),ve=A[te];ve&&await eh({terminal:a,sessionId:ve.sessionId,isExecutionStillCurrent:()=>M(ve.directory,ve.tabId,ve.executionId),markStopping:()=>{z(ve.directory,ve.tabId,"stopping",{expectedExecutionId:ve.executionId})},restoreRunning:()=>{z(ve.directory,ve.tabId,"running",{expectedExecutionId:ve.executionId})},clearSession:()=>{$(ve.directory,ve.tabId,null,{expectedExecutionId:ve.executionId})},finalizeExit:()=>{z(ve.directory,ve.tabId,"exited",{expectedExecutionId:ve.executionId}),K(ve.directory,ve.tabId,{type:"project-action",actionId:ve.actionId,executionId:null}),Q(ve.directory,ve.actionId,ve.executionId)}})},[Q,Ue,M,A,z,K,$,a]),nt=l.useCallback(()=>{const L=H??fe[0];if(!L)return;const te=un(Ue(L),L.id),ve=A[te];if(ve?.status!=="stopping"){if(ve){tt(L);return}Me(L)}},[fe,Ue,Me,A,H,tt]),Qe=l.useCallback(async L=>{if(L.source==="shared"&&he){const te=R.current?.trust.trusted?R.current:await tc(he);if(R.current=te,!await pg(he,te))return;R.current={...te,trust:{...te.trust,trusted:!0}}}await Me(L)},[Me,he]),_e=l.useCallback((L,te=!1)=>{if(U(L.id),!te){Qe(L);return}const ve=un(Ue(L),L.id),P=A[ve];if(P?.status!=="stopping"){if(P){tt(L);return}Qe(L)}},[Ue,Qe,A,tt]),wt=l.useCallback(()=>{he?.id&&(v(he.id),g("projects"),h(!0))},[h,g,v,he?.id]),ct=H??fe[0]??null,gt=ct?A[un(Ue(ct),ct.id)]:null,Kt=_t(L=>gt?L.getDirectoryState(gt.directory)?.tabs.find(te=>te.id===gt.tabId)?.previewUrl??null:null);if(c.isVSCode||!o&&p||!he||!Ne)return null;const kt=H??fe[0]??null;if(!kt)return null;const Ht=Wi(kt),At=un(Ue(kt),kt.id),Et=A[At],Bt=Et?.status==="stopping",Rt=Et?.status==="waiting-for-preview",Wt=!!(Et&&Kt),D=()=>{!Et||!Kt||S(Et.directory,Kt)},je=kt.id===fn;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:me||Bt,className:Se("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-ring","disabled:cursor-not-allowed",n),onClick:nt,"aria-label":Et?i("projectActions.actions.stopNamedAria",{name:kt.name}):i("projectActions.actions.runNamedAria",{name:kt.name}),children:Bt||Rt?s.jsx(T,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):Et?s.jsx(T,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(T,{name:Ht,className:"h-5 w-5"})})}),je?s.jsx(jt,{sideOffset:6,children:i("projectActions.actions.autoDiscoverTooltip")}):null]}),Wt?s.jsxs(Ct,{children:[s.jsx(Nt,{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-ring","aria-label":i("projectActions.actions.openPreview"),onClick:D,children:s.jsx(T,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:i("projectActions.actions.openPreview")})]}):null,s.jsxs(Qs,{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-ring","aria-label":i("projectActions.actions.chooseActionAria"),children:s.jsx(T,{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(ts,{className:"flex items-center gap-2",onClick:wt,children:[s.jsx(T,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("projectActions.actions.addNewAction")})]}),s.jsx(Vs,{}),fe.map(L=>{const te=Wi(L),ve=un(Ue(L),L.id),P=A[ve],Z=!!P,Te=P?.status==="stopping";return s.jsxs(ts,{className:"flex items-center gap-2",onClick:()=>{_e(L,!0)},children:[s.jsx(T,{name:te,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:L.name}),L.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:i("projectActions.menu.sharedBadge")}):null,Te||P?.status==="waiting-for-preview"?s.jsx(T,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Z?s.jsx(T,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},L.id)})]})]})]}):s.jsxs("div",{className:Se("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(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:nt,disabled:me||Bt,className:Se("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-ring disabled:cursor-not-allowed"),"aria-label":Et?i("projectActions.actions.stopNamedAria",{name:kt.name}):i("projectActions.actions.runNamedAria",{name:kt.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:Bt||Rt?s.jsx(T,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):Et?s.jsx(T,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(T,{name:Ht,className:"h-4 w-4"})})})}),je?s.jsx(jt,{sideOffset:6,children:i("projectActions.actions.autoDiscoverTooltip")}):null]}),Wt?s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:D,className:Se(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-ring"),"aria-label":i("projectActions.actions.openPreview"),children:s.jsx(T,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:i("projectActions.actions.openPreview")})]}):null,s.jsxs(Qs,{children:[s.jsx(qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Se(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-ring"),"aria-label":i("projectActions.actions.chooseActionAria"),children:s.jsx(T,{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(ts,{className:"flex items-center gap-2",onClick:wt,children:[s.jsx(T,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("projectActions.actions.addNewAction")})]}),s.jsx(Vs,{}),fe.map(L=>{const te=Wi(L),ve=un(Ue(L),L.id),P=A[ve],Z=!!P,Te=P?.status==="stopping";return s.jsxs(ts,{className:"flex items-center gap-2",onClick:()=>{_e(L,!0)},children:[s.jsx(T,{name:te,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:L.name}),L.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:i("projectActions.menu.sharedBadge")}):null,Te||P?.status==="waiting-for-preview"?s.jsx(T,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Z?s.jsx(T,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},L.id)})]})]})]})},jv=t=>{const e=He.c(23),{directory:n,className:r,iconClassName:o}=t,{t:i}=vt(),d=Ce(kv);let a;e[0]!==n?(a=mm(n),e[0]=n,e[1]=a):a=e[1];const c=a;let u;e[2]!==c?(u=S=>Cy(c?S.journey?.get(c):void 0),e[2]=c,e[3]=u):u=e[3];const f=_o(u);let p;e[4]!==c?(p=S=>c?S.actions.get(c)?.kind==="running":!1,e[4]=c,e[5]=p):p=e[5];const m=_o(p);if(!d||!c||!f||cn())return null;let y;e[6]!==i?(y=i("spaces.header.apply"),e[6]=i,e[7]=y):y=e[7];const x=y;let w;e[8]!==c?(w=()=>_o.getState().openApplyDialog(c),e[8]=c,e[9]=w):w=e[9];let b;e[10]!==o?(b=s.jsx(T,{name:"git-merge",className:o}),e[10]=o,e[11]=b):b=e[11];let g;e[12]!==m||e[13]!==r||e[14]!==x||e[15]!==w||e[16]!==b?(g=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":x,disabled:m,onClick:w,className:r,children:b})}),e[12]=m,e[13]=r,e[14]=x,e[15]=w,e[16]=b,e[17]=g):g=e[17];let h;e[18]!==x?(h=s.jsx(jt,{side:"bottom",children:x}),e[18]=x,e[19]=h):h=e[19];let v;return e[20]!==g||e[21]!==h?(v=s.jsxs(Ct,{children:[g,h]}),e[20]=g,e[21]=h,e[22]=v):v=e[22],v};function kv(t){return t.isolatedSpacesEnabled}const Gr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Cv=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const o=Gr(n??"");if(o){const i=yu(t,e,o);if(i)return i}return t.find(i=>i.id===r)??null};function Nv(){const t=as(x=>x.projects),e=as(x=>x.activeProjectId),n=Je(x=>x.availableWorktreesByProject),r=Je(x=>x.currentSessionId),o=mg(r??null),i=Je(x=>r?x.worktreeMetadata.get(r)?.path??"":""),d=Je(x=>x.newSessionDraft?.open?Gr(x.newSessionDraft.bootstrapPendingDirectory??x.newSessionDraft.directoryOverride??""):""),a=l.useMemo(()=>Gr(i||""),[i]),c=l.useMemo(()=>{const x=typeof o?.directory=="string"?o.directory:"";return Gr(x||"")},[o?.directory]),u=a||c||d,f=l.useMemo(()=>Cv({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),p=l.useMemo(()=>Gr(u||f?.path||""),[u,f?.path]),m=l.useMemo(()=>f?{id:f.id,path:f.path}:null,[f]),y=l.useRef(null);return l.useEffect(()=>{m&&p&&(y.current={projectRef:m,directory:p})},[p,m]),l.useMemo(()=>m&&p?{projectRef:m,directory:p}:y.current,[m,p])}const Av=({transform:t})=>({...t,y:0}),Pv=16,Iv=t=>{if(t.shiftKey||t.ctrlKey||t.metaKey||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;const e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*Pv:t.deltaY;t.currentTarget.scrollLeft+=e},Dv={Item:ts,Separator:Vs},Ev={Item:({className:t,...e})=>s.jsx(Ef,{className:Se(ju,t),...e}),Separator:({className:t,...e})=>s.jsx(Df,{className:Se(Su,t),...e})},Rv=t=>{const e=He.c(63),{tab:n,isActive:r,suppressControls:o,onSelect:i,onClose:d,renderMenu:a,closeOtherTabs:c,onMenuOpenChangeComplete:u,children:f}=t,{t:p}=vt(),[m,y]=l.useState(!1),[x,w]=l.useState(!1),[b,g]=l.useState(!1);let h;e[0]!==n.id?(h={id:n.id},e[0]=n.id,e[1]=h):h=e[1];const{attributes:v,listeners:S,setNodeRef:j,transform:N,transition:C,isDragging:B}=vi(h);let W;e[2]!==p||e[3]!==n.session.title?(W=n.session.title?.trim()||p("sessions.sidebar.session.untitled"),e[2]=p,e[3]=n.session.title,e[4]=W):W=e[4];const F=W,$=!o&&(m||x),K=n.id;let I;e[5]!==n.session?(I=vn(n.session),e[5]=n.session,e[6]=I):I=e[6];const z=Ya(K,I),k=vu(n.id),M=k!==null,O=wu(n.id)>0&&!r&&!M,E=M||O;let R;e[7]!==c||e[8]!==b||e[9]!==r||e[10]!==m||e[11]!==i||e[12]!==n?(R=se=>({session:n.session,open:m||b,isActive:r,select:()=>i(n),closeOtherTabs:()=>c(n.id),components:se}),e[7]=c,e[8]=b,e[9]=r,e[10]=m,e[11]=i,e[12]=n,e[13]=R):R=e[13];const _=R;let U;e[14]!==N?(U=wi.Translate.toString(N),e[14]=N,e[15]=U):U=e[15];let me;e[16]!==U||e[17]!==C?(me={transform:U,transition:C},e[16]=U,e[17]=C,e[18]=me):me=e[18];const ce=B&&"z-10 opacity-60";let oe;e[19]!==ce?(oe=Se("session-tab-slot flex h-7 w-44 shrink-0 touch-none",ce),e[19]=ce,e[20]=oe):oe=e[20];const ie=r?"true":"false";let xe;e[21]!==r?(xe=r?{"data-active-session-tab":!0}:{},e[21]=r,e[22]=xe):xe=e[22];let G;e[23]!==u?(G=se=>u?.(se),e[23]=u,e[24]=G):G=e[24];let pe;e[25]!==f||e[26]!==r||e[27]!==z||e[28]!==_||e[29]!==m||e[30]!==d||e[31]!==u||e[32]!==i||e[33]!==$||e[34]!==a||e[35]!==E||e[36]!==o||e[37]!==p||e[38]!==n||e[39]!==F||e[40]!==k?(pe=s.jsx(Rf,{render:se=>s.jsxs("div",{...se,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>i(n),onKeyDown:r?void 0:Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),i(n))},onAuxClick:Ne=>{Ne.button===1&&(Ne.preventDefault(),d(n.id))},"data-controls-open":$?"true":"false",className:Se("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 text-interactive-selection-foreground":Se("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",$&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Se("flex min-w-0 flex-1 items-center",!o&&"group-hover/session-tab:pr-10",$&&"pr-10"),children:[s.jsx("div",{className:Se("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!o&&"session-tab-title"),children:r?f:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap text-left text-[13px] font-medium leading-4",children:F})})}),z?s.jsx(T,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":p("sessions.aiRename.generating")}):E?s.jsx(ku,{state:k??"unread",className:Se("ml-1.5 shrink-0",!o&&"group-hover/session-tab:opacity-0",$&&"opacity-0")}):null]}),o?null:s.jsxs("div",{onClick:Tv,onPointerDown:Ov,className:Se("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",$&&"flex opacity-100"),children:[s.jsxs(Qs,{open:m,onOpenChange:Ne=>{y(Ne),Ne&&w(!0)},onOpenChangeComplete:Ne=>{Ne||w(!1),u?.(Ne)},children:[s.jsx(qs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":p("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(T,{name:"more",className:"size-4"})})}),s.jsx(Ys,{align:"start",className:"min-w-[190px]",children:a(_(Dv))})]}),s.jsx("button",{type:"button","aria-label":p("header.sessionTabs.closeTab"),onClick:()=>d(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(T,{name:"close",className:"size-4"})})]})]})}),e[25]=f,e[26]=r,e[27]=z,e[28]=_,e[29]=m,e[30]=d,e[31]=u,e[32]=i,e[33]=$,e[34]=a,e[35]=E,e[36]=o,e[37]=p,e[38]=n,e[39]=F,e[40]=k,e[41]=pe):pe=e[41];let J,ge;e[42]===Symbol.for("react.memo_cache_sentinel")?(J={color:"var(--surface-elevated-foreground)"},ge=Se(ia,"min-w-[190px]"),e[42]=J,e[43]=ge):(J=e[42],ge=e[43]);let de;e[44]!==_||e[45]!==a?(de=a(_(Ev)),e[44]=_,e[45]=a,e[46]=de):de=e[46];let Ae;e[47]!==de?(Ae=s.jsx(ba,{children:s.jsx(xa,{className:"app-region-no-drag z-50",children:s.jsx(ya,{"data-slot":"dropdown-menu-content",style:J,className:ge,children:de})})}),e[47]=de,e[48]=Ae):Ae=e[48];let he;e[49]!==b||e[50]!==G||e[51]!==pe||e[52]!==Ae?(he=s.jsxs(Mf,{open:b,onOpenChange:g,onOpenChangeComplete:G,children:[pe,Ae]}),e[49]=b,e[50]=G,e[51]=pe,e[52]=Ae,e[53]=he):he=e[53];let Re;return e[54]!==v||e[55]!==S||e[56]!==j||e[57]!==ie||e[58]!==xe||e[59]!==he||e[60]!==me||e[61]!==oe?(Re=s.jsx("div",{ref:j,style:me,className:oe,"data-active":ie,...xe,...v,...S,children:he}),e[54]=v,e[55]=S,e[56]=j,e[57]=ie,e[58]=xe,e[59]=he,e[60]=me,e[61]=oe,e[62]=Re):Re=e[62],Re},Mv=t=>{const e=He.c(65),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,d=o===void 0?!1:o,{t:a}=vt(),c=yo(Bv),u=yo(Fv),f=yo(Lv),p=yo($v),m=Je(_v),y=Je(Kv),x=Ls(Wv),w=oh(m);let b,g;e[0]!==w||e[1]!==m||e[2]!==u?(b=()=>{m&&u(m,w)},g=[m,w,u],e[0]=w,e[1]=m,e[2]=u,e[3]=b,e[4]=g):(b=e[3],g=e[4]),l.useEffect(b,g);let h;if(e[5]!==x){h=new Map;for(const ye of x)h.set(ye.id,ye);e[5]=x,e[6]=h}else h=e[6];const v=h;let S;if(e[7]!==v||e[8]!==c){S=[];for(const ye of c){const Pe=v.get(ye);Pe&&S.push({id:ye,session:Pe})}e[7]=v,e[8]=c,e[9]=S}else S=e[9];const j=S;let N;e[10]!==y?(N=ye=>{y(ye.id,vn(ye.session))},e[10]=y,e[11]=N):N=e[11];const C=N,B=zv;let W;e[12]!==f||e[13]!==m||e[14]!==C||e[15]!==j?(W=ye=>{if(f(ye),m&&m!==ye){const Pe=j.find(Oe=>Oe.id===ye);Pe&&C(Pe)}},e[12]=f,e[13]=m,e[14]=C,e[15]=j,e[16]=W):W=e[16];const F=W;let $;e[17]===Symbol.for("react.memo_cache_sentinel")?($={activationConstraint:{distance:8}},e[17]=$):$=e[17];let K;e[18]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{delay:200,tolerance:6}},e[18]=K):K=e[18];const I=hi(In(bi,$),In(gi,K));let z;e[19]!==p?(z=ye=>{const{active:Pe,over:Oe}=ye;Oe&&Pe.id!==Oe.id&&p(String(Pe.id),String(Oe.id))},e[19]=p,e[20]=z):z=e[20];const k=z,M=l.useRef(null);let V;e[21]===Symbol.for("react.memo_cache_sentinel")?(V={left:!1,right:!1},e[21]=V):V=e[21];const[O,E]=l.useState(V);let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const ye=M.current;if(!ye)return;const Pe=ye.scrollLeft>2,Oe=ye.scrollLeft+ye.clientWidth<ye.scrollWidth-2;E($e=>$e.left===Pe&&$e.right===Oe?$e:{left:Pe,right:Oe})},e[22]=R):R=e[22];const _=R;let U;e[23]===Symbol.for("react.memo_cache_sentinel")?(U=()=>{_();const ye=M.current;if(!ye||!globalThis.ResizeObserver)return;const Pe=new ResizeObserver(_);return Pe.observe(ye),()=>Pe.disconnect()},e[23]=U):U=e[23];let me;e[24]!==j.length?(me=[_,j.length],e[24]=j.length,e[25]=me):me=e[25],l.useEffect(U,me);let ce;e[26]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>{M.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[26]=ce):ce=e[26];let oe;e[27]!==m?(oe=[m],e[27]=m,e[28]=oe):oe=e[28],l.useEffect(ce,oe);const ie=O.left&&O.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":O.left?"linear-gradient(to right, transparent, black 24px)":O.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let xe;e[29]!==j?(xe=j.map(Vv),e[29]=j,e[30]=xe):xe=e[30];const G=xe;let pe;e[31]!==m||e[32]!==j?(pe=!m||!j.some(ye=>ye.id===m),e[31]=m,e[32]=j,e[33]=pe):pe=e[33];const J=pe;let ge;e[34]!==a?(ge=a("header.sessionTabs.stripAria"),e[34]=a,e[35]=ge):ge=e[35];let de;e[36]!==ie?(de=ie?{maskImage:ie,WebkitMaskImage:ie}:void 0,e[36]=ie,e[37]=de):de=e[37];let Ae;e[38]===Symbol.for("react.memo_cache_sentinel")?(Ae=[Av],e[38]=Ae):Ae=e[38];let he;e[39]!==i||e[40]!==m||e[41]!==F||e[42]!==C||e[43]!==r||e[44]!==n||e[45]!==d||e[46]!==j?(he=j.map(ye=>s.jsx(Rv,{tab:ye,isActive:ye.id===m,suppressControls:ye.id===m&&d,onSelect:C,onClose:B,renderMenu:n,closeOtherTabs:F,onMenuOpenChangeComplete:r,children:ye.id===m?i:null},ye.id)),e[39]=i,e[40]=m,e[41]=F,e[42]=C,e[43]=r,e[44]=n,e[45]=d,e[46]=j,e[47]=he):he=e[47];let Re;e[48]!==he||e[49]!==G?(Re=s.jsx(gl,{items:G,strategy:Dy,children:he}),e[48]=he,e[49]=G,e[50]=Re):Re=e[50];let se;e[51]!==k||e[52]!==I||e[53]!==Re?(se=s.jsx(xi,{sensors:I,collisionDetection:yi,modifiers:Ae,onDragEnd:k,children:Re}),e[51]=k,e[52]=I,e[53]=Re,e[54]=se):se=e[54];let Ne;e[55]!==i||e[56]!==J?(Ne=J?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:i})}):null,e[55]=i,e[56]=J,e[57]=Ne):Ne=e[57];let be;e[58]!==de||e[59]!==se||e[60]!==Ne?(be=s.jsxs("div",{ref:M,onScroll:_,onWheel:Iv,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:de,children:[se,Ne]}),e[58]=de,e[59]=se,e[60]=Ne,e[61]=be):be=e[61];let we;return e[62]!==ge||e[63]!==be?(we=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ge,children:be}),e[62]=ge,e[63]=be,e[64]=we):we=e[64],we};function Tv(t){return t.stopPropagation()}function Ov(t){return t.stopPropagation()}function Bv(t){return t.tabIds}function Fv(t){return t.ensureTab}function Lv(t){return t.closeOtherTabs}function $v(t){return t.reorderTabs}function _v(t){return t.currentSessionId}function Kv(t){return t.setCurrentSession}function Wv(t){return t.activeSessions}function zv(t){hg(t)}function Vv(t){return t.id}const Uv=500;function ds(t){const e=He.c(9),{hint:n,children:r}=t,[o,i]=l.useState(!1);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=(f,p)=>{f&&p.reason==="trigger-focus"||i(f)},e[0]=d):d=e[0];let a;e[1]!==r?(a=s.jsx(Nt,{asChild:!0,children:r}),e[1]=r,e[2]=a):a=e[2];let c;e[3]!==n?(c=s.jsx(jt,{side:"right",sideOffset:8,className:"max-w-64",children:n}),e[3]=n,e[4]=c):c=e[4];let u;return e[5]!==o||e[6]!==a||e[7]!==c?(u=s.jsxs(Ct,{delayDuration:Uv,open:o,onOpenChange:d,children:[a,c]}),e[5]=o,e[6]=a,e[7]=c,e[8]=u):u=e[8],u}function Ic(t){const e=He.c(28),{sessionId:n,onArchive:r,Item:o}=t,{t:i}=vt();let d;e[0]!==n?(d=N=>!!N.entityById.get(n)?.time.archived,e[0]=n,e[1]=d):d=e[1];const a=Ls(d);let c;e[2]!==n?(c=N=>!!N.entityById.get(n)?.parentID,e[2]=n,e[3]=c):c=e[3];const u=Ls(c),f=Je(Hv);let p;e[4]!==n||e[5]!==i||e[6]!==f?(p=async()=>{await f(n)?Be.success(i("sessions.sidebar.session.restore.success")):Be.error(i("sessions.sidebar.session.restore.error"))},e[4]=n,e[5]=i,e[6]=f,e[7]=p):p=e[7];const m=p;if(a&&u)return null;const y=a?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let x;e[8]!==i||e[9]!==y?(x=i(y),e[8]=i,e[9]=y,e[10]=x):x=e[10];let w;e[11]!==a||e[12]!==r||e[13]!==m?(w=a?()=>{m()}:r,e[11]=a,e[12]=r,e[13]=m,e[14]=w):w=e[14];const b=a?"inbox-unarchive":"inbox-archive";let g;e[15]!==b?(g=s.jsx(T,{name:b,className:"mr-1 size-4"}),e[15]=b,e[16]=g):g=e[16];const h=a?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let v;e[17]!==i||e[18]!==h?(v=i(h),e[17]=i,e[18]=h,e[19]=v):v=e[19];let S;e[20]!==o||e[21]!==v||e[22]!==w||e[23]!==g?(S=s.jsxs(o,{onClick:w,children:[g,v]}),e[20]=o,e[21]=v,e[22]=w,e[23]=g,e[24]=S):S=e[24];let j;return e[25]!==S||e[26]!==x?(j=s.jsx(ds,{hint:x,children:S}),e[25]=S,e[26]=x,e[27]=j):j=e[27],j}function Hv(t){return t.unarchiveSession}const Lf=async t=>{const{entry:e,session:n}=t,r=ss(),o={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(gg(e.action)&&bg(e.guest,"conversation"))){await sc(e,nc(e.action.id,o),t.t,r);return}let d=!1;const a=co(()=>{d=!0});let c;try{c=await t.loadRecords()}finally{a()}if(!d){if(!c){t.onLoadFailed();return}await sc(e,nc(e.action.id,o,c),t.t,r)}};function wa(t){const e=He.c(14),{sessionID:n,directory:r,open:o,Item:i}=t,{t:d}=vt(),{pending:a,disabled:c,hint:u,run:f}=ih(n,r,o),p=a?"loader-4":"ai-generate-2",m=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let y;e[0]!==p||e[1]!==m?(y=s.jsx(T,{name:p,className:m}),e[0]=p,e[1]=m,e[2]=y):y=e[2];let x;e[3]!==d?(x=d("sessions.aiRename.action"),e[3]=d,e[4]=x):x=e[4];let w;e[5]!==i||e[6]!==c||e[7]!==f||e[8]!==y||e[9]!==x?(w=s.jsx("span",{className:"block",children:s.jsxs(i,{disabled:c,onClick:f,className:"w-full",children:[y,x]})}),e[5]=i,e[6]=c,e[7]=f,e[8]=y,e[9]=x,e[10]=w):w=e[10];let b;return e[11]!==u||e[12]!==w?(b=s.jsx(ds,{hint:u,children:w}),e[11]=u,e[12]=w,e[13]=b):b=e[13],b}const Sa=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class $f extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const ji=bl(()=>({pendingSessionIds:new Set})),_f=t=>{const e=He.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],ji(n)},Dc=(t,e)=>{ji.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}})},Gv=async(t,e)=>{try{const c=(await Sg(t,{mode:"light"})).current?.trim();if(c)return c}catch{}const n=at(t),r=at(e)??e,o=Je.getState().availableWorktreesByProject,d=(o.get(r)??o.get(e)??[]).find(a=>at(a.path)===n)?.branch?.trim();if(d)return d;throw new Error("Unable to determine the current branch")},Ec=t=>{for(const e of t){const n=yg(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class qv extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const Yv=(t,e)=>{const n=e.map(({sessionId:r,error:o})=>`${r}: ${o.message}`).join(", ");return new qv(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},Qv=async(t,e,n,r)=>{const o=[];for(const i of[...t].reverse()){if(Nu(i.id)){o.push({sessionId:i.id,error:new Error("Session is not idle")});continue}try{await Cu(i,n,e),Je.getState().setWorktreeMetadata(i.id,r.get(i.id)??null)}catch(d){o.push({sessionId:i.id,error:d instanceof Error?d:new Error(String(d))})}}return o},Rc=async(t,e,n)=>{try{await Pu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},Mc=async(t,e)=>{const n=e?[t,e]:[t];try{await Qa(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},Kf=async(t,e)=>{if(ji.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Dc(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,Je.getState().getWorktreeMetadata(a.id)]));Ec(n);let o=null;const i=[];let d=!1;try{o=await e();for(const[a,c]of n.entries()){Ec(n.slice(a));try{await Cu(c,t.sourceDirectory,o.directory)}catch(u){throw xg(u)&&(d=!0),u}i.push(c),c.id!==t.root.id&&Je.getState().setWorktreeMetadata(c.id,rc(o.metadata))}}catch(a){const c=a instanceof Error?a:new Error(String(a)),u=await Qv(i,t.sourceDirectory,o?.directory??t.sourceDirectory,r);if(d&&await Mc(t.sourceDirectory,o?.directory),u.length>0)throw Yv(c,u);if(o?.onMoveFailure&&!d)return o.onMoveFailure(c);throw o?.onMoveFailure&&d?new $f(c):c}return Je.getState().setWorktreeMetadata(t.root.id,rc(o.metadata)),await Mc(t.sourceDirectory,o.directory),o.directory}finally{Dc(t.root.id,!1)}},Xv=async t=>{const e=at(t.sourceDirectory)??t.sourceDirectory,n=at(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 Kf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},Jv=async t=>Kf(t,async()=>{const e=aa(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await Au(t.sourceDirectory)?await Gv(t.sourceDirectory,e.path):null,r=await vg(e,n?{startRef:n}:{});try{await wg(r.path)}catch(o){const i=o instanceof Error?o:new Error(String(o));return Rc(e,r,i)}return{directory:r.path,metadata:r,onMoveFailure:async o=>Rc(e,r,o)}}),Zv=t=>{(t.kind==="existing"?Xv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):Jv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>Be.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));Be.error(t.messages.failure,{description:r instanceof $f?t.messages.outcomeUnknown:r.message})})},ja=t=>{ji.getState().pendingSessionIds.has(t.root.id)||Zv(t)},Pr="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-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",ew=l.memo(function(e){const n=He.c(17),{visible:r,title:o,ariaLabel:i,onClick:d,className:a,Icon:c,iconClassName:u,pressed:f}=e,p=r===void 0?!0:r,m=f===void 0?!1:f;if(!p)return null;const y=a??Pr,x=m&&"bg-interactive-selection text-interactive-selection-foreground";let w;n[0]!==y||n[1]!==x?(w=Se(y,x),n[0]=y,n[1]=x,n[2]=w):w=n[2];const b=u??"h-[18px] w-[18px]";let g;n[3]!==c||n[4]!==b?(g=s.jsx(T,{name:c,className:b}),n[3]=c,n[4]=b,n[5]=g):g=n[5];let h;n[6]!==i||n[7]!==d||n[8]!==m||n[9]!==w||n[10]!==g?(h=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,"aria-label":i,"aria-pressed":m,className:w,children:g})}),n[6]=i,n[7]=d,n[8]=m,n[9]=w,n[10]=g,n[11]=h):h=n[11];let v;n[12]!==o?(v=s.jsx(jt,{children:s.jsx("p",{children:o})}),n[12]=o,n[13]=v):v=n[13];let S;return n[14]!==h||n[15]!==v?(S=s.jsxs(Ct,{children:[h,v]}),n[14]=h,n[15]=v,n[16]=S):S=n[16],S}),tw=l.memo(function(e){const n=He.c(43),{isDesktopApp:r,currentInstanceLabel:o,currentInstanceIsLocal:i,isDesktopServicesOpen:d,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:c,shortcutLabel:u,remoteUpdateInfo:f,remoteUpdateChecking:p,remoteUpdateError:m,onOpenRemoteUpdate:y}=e,{t:x}=vt();let w;n[0]!==c||n[1]!==a?(w=K=>{a(K),K&&c()},n[0]=c,n[1]=a,n[2]=w):w=n[2];let b;n[3]!==o||n[4]!==r||n[5]!==x?(b=r?x("header.services.openWithCurrent",{current:o}):x("header.services.open"),n[3]=o,n[4]=r,n[5]=x,n[6]=b):b=n[6];const g=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let h;n[7]!==g?(h=Se(Pr,g),n[7]=g,n[8]=h):h=n[8];let v;n[9]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(T,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=v):v=n[9];let S;n[10]!==o||n[11]!==r?(S=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:o}):null,n[10]=o,n[11]=r,n[12]=S):S=n[12];let j;n[13]!==b||n[14]!==h||n[15]!==S?(j=s.jsx(Nt,{asChild:!0,children:s.jsx(qs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":b,className:h,children:[v,S]})})}),n[13]=b,n[14]=h,n[15]=S,n[16]=j):j=n[16];let N;n[17]!==o||n[18]!==u||n[19]!==x?(N=x("header.services.tooltip.currentInstance",{current:o,toggle:u("toggle_services_menu")}),n[17]=o,n[18]=u,n[19]=x,n[20]=N):N=n[20];let C;n[21]!==N?(C=s.jsx(jt,{children:s.jsx("p",{children:N})}),n[21]=N,n[22]=C):C=n[22];let B;n[23]!==j||n[24]!==C?(B=s.jsxs(Ct,{children:[j,C]}),n[23]=j,n[24]=C,n[25]=B):B=n[25];let W;n[26]!==i||n[27]!==r||n[28]!==d||n[29]!==y||n[30]!==p||n[31]!==m||n[32]!==f||n[33]!==a||n[34]!==x?(W=r?s.jsxs("div",{children:[i?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:x("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:f?.available?x("header.services.remoteUpdate.available",{version:f.version||""}):p?x("header.services.remoteUpdate.checking"):m||x("header.services.remoteUpdate.upToDate")})]}),f?.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:y,children:x("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(jg,{embedded:!0,open:d,onOpenChange:nw,onHostSwitched:()=>a(!1)})]}):null,n[26]=i,n[27]=r,n[28]=d,n[29]=y,n[30]=p,n[31]=m,n[32]=f,n[33]=a,n[34]=x,n[35]=W):W=n[35];let F;n[36]!==W?(F=s.jsx(Ys,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:W}),n[36]=W,n[37]=F):F=n[37];let $;return n[38]!==d||n[39]!==w||n[40]!==B||n[41]!==F?($=s.jsxs(Qs,{open:d,onOpenChange:w,children:[B,F]}),n[38]=d,n[39]=w,n[40]=B,n[41]=F,n[42]=$):$=n[42],$}),kn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Tc=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,sw=()=>{Hs("ui.header.render");const{t}=vt(),e=Ce(ee=>ee.isSidebarOpen),n=Ce(ee=>ee.openContextOverview),r=Ce(ee=>ee.closeContextPanel),o=Ce(ee=>ee.shortcutOverrides),i=Ce(ee=>ee.sessionTabsEnabled),d=Je(ee=>ee.getContextUsage),a=Je(ee=>!!ee.newSessionDraft?.open),c=Je(ee=>ee.currentSessionId),u=kg(c??""),f=Cg(c??""),p=_f(c??""),m=Ls(Or(l.useCallback(ee=>{if(!c)return null;const Xe=[...ee.activeSessions,...ee.archivedSessions].find(Jt=>Jt.id===c);if(!Xe)return null;const bt=Xe;return{title:Xe.title??null,directory:bt.directory??null,created:Xe.time?.created??null,slug:bt.slug??null,parentId:Xe.parentID??null}},[c]))),y=as(Or(ee=>{if(!ee.activeProjectId)return null;const Xe=ee.projects.find(bt=>bt.id===ee.activeProjectId);return Xe?{id:Xe.id,path:Xe.path,label:Xe.label}:null})),x=l.useMemo(()=>{if(!y)return null;const ee=y.label?.trim();if(ee)return ee;const Xe=y.path.split(/[\\/]/).filter(Boolean);return Xe[Xe.length-1]??null},[y]),w=Nr(ee=>ee.loadSettings),{isMobile:b}=Yn(),g=l.useRef(null),[h,v]=l.useState(()=>typeof window>"u"?!1:En()),S=l.useMemo(()=>eo(),[]),j=Ng(),[N,C]=l.useState(!1),B=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:W,side:F}=Nf(),$=l.useMemo(()=>{if(typeof window>"u")return null;const ee=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof ee=="number"&&Number.isFinite(ee)&&ee>0)return ee;if(typeof navigator>"u")return null;const Xe=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Xe)return null;const bt=Number.parseInt(Xe[1],10),Jt=Number.parseInt(Xe[2],10);return Number.isNaN(bt)?null:bt===10?Jt:bt},[]);Ms.useEffect(()=>{typeof window>"u"||v(En())},[]);const{context:K,output:I}=Ag(c),z=d(K,I),[k,M]=l.useState(null),V=!c||u;Ms.useEffect(()=>{if(!c){M(ee=>ee===null?ee:null);return}if(z){M(ee=>Pg(ee,z)?ee:z);return}V&&M(ee=>ee===null?ee:null)},[z,c,V]);const[O,E]=l.useState(!1),[R,_]=l.useState("Local"),[U,me]=l.useState(!0),[ce,oe]=l.useState(!1),[ie,xe]=l.useState(null),[G,pe]=l.useState(!1),[J,ge]=l.useState(null),de=l.useMemo(()=>cn(),[]),Ae=Ce(ee=>ee.workStatusPanelVisible),he=Ce(ee=>ee.workStatusPanelEnabled),Re=Ce(ee=>ee.setWorkStatusPanelEnabled),se=Ce(ee=>ee.workStatusPanelFits),Ne=Ce(ee=>ee.workStatusOverlayOpen),be=Ce(ee=>ee.setWorkStatusOverlayOpen),ye=he&&se||Ne,Pe=l.useCallback(()=>{if(he&&!se){be(!Ne);return}Re(!he)},[be,Re,Ne,he,se]),Oe=!de&&!Ae&&!!k,$e=l.useCallback(async()=>{if(!(typeof window>"u"||!h))try{if(lo()){_("Local"),me(!0);return}me(!1);const ee=await ru(),Xe=hm(),bt=gm([bm(Xe),...ee.hosts]);if(bt.id===xm){_("Local"),me(!0);return}_(ou(bt.label.trim()||"Instance"))}catch{_("Local"),me(!0)}},[h]);Ms.useEffect(()=>($e(),co(()=>{$e()})),[$e]);const ze=l.useCallback(async()=>{if(U){xe(null),ge(null);return}pe(!0),ge(null);try{const ee=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Xe=await Zs(`/api/openchamber/update-check?${ee.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Xe.ok)throw new Error(`Server responded with ${Xe.status}`);const bt=await Xe.json();xe({available:bt.available??!1,version:bt.version,currentVersion:bt.currentVersion??"unknown",body:bt.body,nextSuggestedCheckInSec:typeof bt.nextSuggestedCheckInSec=="number"?bt.nextSuggestedCheckInSec:void 0,packageManager:bt.packageManager,updateCommand:bt.updateCommand})}catch(ee){xe(null),ge(ee instanceof Error?ee.message:t("header.services.remoteUpdate.error"))}finally{pe(!1)}},[U,t]);l.useEffect(()=>{xe(null),ge(null),oe(!1)},[U,R]),l.useEffect(()=>{if(!h||U)return;const ee=3e3,Xe=3600*1e3;let bt=!1,Jt=null;const gs=Ps=>{Jt=window.setTimeout(()=>{if(bt||typeof document<"u"&&document.visibilityState!=="visible"){gs(Xe);return}ze().finally(()=>{bt||gs(Xe)})},Ps)};return gs(ee),()=>{bt=!0,Jt!==null&&window.clearTimeout(Jt)}},[ze,U,R,h]);const Ue=l.useCallback(()=>{if(ie?.available){oe(!0);return}ze()},[ze,ie?.available]);Ig(),l.useEffect(()=>{w()},[w]);const q=c?m??null:null,ue=l.useRef(null),[A,Q]=l.useState(0);l.useEffect(()=>{if(!c){ue.current&&(ue.current=null,Q(Jt=>Jt+1));return}if(q){ue.current={sessionId:c,session:q,expiresAt:Date.now()+2e3};return}const ee=ue.current;if(!ee||ee.sessionId!==c)return;const Xe=ee.expiresAt-Date.now();if(Xe<=0){ue.current=null,Q(Jt=>Jt+1);return}const bt=window.setTimeout(()=>{ue.current?.sessionId===c&&(ue.current=null),Q(Jt=>Jt+1)},Xe);return()=>{window.clearTimeout(bt)}},[c,q]);const le=(()=>{if(q)return q;if(!c)return null;const ee=ue.current;return ee&&ee.sessionId===c&&ee.expiresAt>Date.now()?ee.session:null})(),Ie=Je(ee=>c?ee.worktreeMetadata.get(c)?.path??"":""),re=Je(ee=>c?ee.worktreeMetadata.get(c)?.branch?.trim()??null:null),H=Iu(ee=>c?ee.getAttachment(c):void 0),ne=l.useMemo(()=>H?Dg(H,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,H]),X=l.useMemo(()=>H?H.legacy?"legacy":H.degraded?"degraded":H.worktreeStatus==="pending"?"pending":H.worktreeStatus==="missing"?"missing":H.worktreeStatus==="invalid"?"invalid":H.attentionReason?"attention":null:null,[H]),fe=l.useMemo(()=>kn(Ie||""),[Ie]),Fe=l.useMemo(()=>{const ee=typeof le?.directory=="string"?le.directory:"";return kn(ee||"")},[le?.directory]),Me=Ya(c??"",Fe),tt=Je(ee=>ee.newSessionDraft?.open?kn(ee.newSessionDraft.bootstrapPendingDirectory??ee.newSessionDraft.directoryOverride??""):""),nt=Je(ee=>ee.newSessionDraft.target),Qe=Je(ee=>ee.newSessionDraft.selectedProjectId),_e=Je(ee=>ee.currentSessionDirectory),wt=Fs(ee=>ee.homeDirectory),ct=l.useMemo(()=>fe||Fe||tt,[tt,Fe,fe]),gt=Ce(l.useCallback(ee=>{const Xe=kn(ct||"");return Xe?Tc(ee.contextPanelByDirectory[Xe]):null},[ct])),Kt=Je(ee=>{const Xe=kn(fe||Fe||"");if(!Xe)return null;for(const bt of ee.availableWorktreesByProject.values()){const gs=bt.find(Ps=>kn(Ps.path)===Xe)?.branch?.trim();if(gs)return gs}return null}),Ht=Eg(ct||null)||re||Kt,At=a?nt==="chat":Rg(Fe||_e,wt),Et=!At&&!Ae&&!!(x||Ht||!a&&X),Bt=l.useMemo(()=>{if(!c)return x??"OpenChamber";const ee=le?.title?.trim();return ee&&ee.length>0?ee:"Untitled Session"},[x,le?.title,c]),Rt=Du(),Wt=Je(ee=>ee.updateSessionTitle),D=Je(ee=>ee.archiveSessions),je=Je(ee=>ee.deleteSessions),[L,te]=l.useState(!1),[ve,P]=l.useState(!1),Z=l.useRef(null),[Te,Le]=l.useState(""),[We,Ge]=l.useState(null),zt=l.useRef(null),Ye=l.useCallback(()=>{c&&(Le(le?.title?.trim()||Bt),te(!0))},[le?.title,c,Bt]),Ee=l.useRef(Ye);Ee.current=Ye;const Pt=l.useCallback(ee=>{ee&&(ee.focus(),ee.select())},[]);l.useEffect(()=>{if(P(!1),Ge(null),c&&Z.current===c){Z.current=null,Ee.current();return}te(!1),Le("")},[c]);const Lt=l.useCallback(async()=>{if(!c)return;const ee=Te.trim();ee&&ee!==le?.title?.trim()&&await Wt(c,ee),te(!1)},[le?.title,c,Te,Wt]);l.useEffect(()=>{if(!L)return;const ee=Xe=>{const bt=Xe.target;(!bt||!zt.current?.contains(bt))&&Lt()};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[L,Lt]);const os=l.useCallback(ee=>{ee&&ur(ee).then(Xe=>{Be[Xe.ok?"success":"error"](t(Xe.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Be.error(t("sessions.sidebar.session.copyId.error")))},[t]),it=l.useCallback(async()=>{if(!c||!ct){Be.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ee=await Rt({sessionID:c,directory:ct}).catch(()=>null);if(!ee){Be.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(ee.length===0){Be.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Xe=Eu(ee,le?.title??null),bt=Ru(le?.title??null);await Mu(Xe,bt)||Tu(Xe,bt),Be.success(t("sessions.sidebar.session.export.success"))},[le?.title,c,Rt,ct,t]),Ve=Ou(),Qt=l.useMemo(()=>Bu(Ve),[Ve]),St=l.useCallback(ee=>{c&&Lf({entry:ee,t,session:{id:c,title:le?.title,directory:Fe??ct},loadRecords:async()=>{if(!ct)return null;try{return await Rt({sessionID:c,directory:ct})}catch{return null}},onLoadFailed:()=>Be.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[le?.title,c,Rt,ct,Fe,t]),Yt=l.useCallback(ee=>Qt.map(Xe=>s.jsxs(ee,{onClick:()=>St(Xe),children:[s.jsx(fo,{icon:Xe.icon,iconSrc:Xe.iconSrc,className:"mr-1 size-4"}),Xe.action.label]},`${Xe.guest.id}:${Xe.action.id}`)),[Qt,St]),ft=f?.type==="busy"||f?.type==="retry",Vt=l.useCallback(()=>{if(!c||!Fe||ft||p)return;const ee=Ls.getState().activeSessions,Xe=ee.find(gs=>gs.id===c);if(!Xe)return;const bt=[],Jt=[c];for(let gs=0;gs<Jt.length;gs+=1){const Ps=Jt[gs];for(const Cs of ee)Cs.parentID===Ps&&(bt.push(Cs),Jt.push(Cs.id))}ja({kind:"quick",root:Xe,descendants:bt,sourceDirectory:Fe,messages:Sa(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[c,ft,p,Fe,t]),et=l.useCallback(async(ee,Xe)=>{const bt=[Xe,...fu(Xe,[],ee==="delete")],Jt=Je.getState().currentSessionId===Xe?Xe:null;if(ee==="delete"){const{failedIds:Cs}=await je(bt);Cs.length>0?Be.error(t("sessions.sidebar.session.delete.error")):Be.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:gs,failedIds:Ps}=await D(bt);if(Ps.length>0){Be.error(t("sessions.sidebar.session.archive.error"));return}Be.success(t("sessions.sidebar.session.archive.success"),ah(gs,Jt,t))},[D,je,t]),It=l.useCallback(async()=>{if(!We)return;const{action:ee,sessionId:Xe}=We;Ge(null),await et(ee,Xe)},[We,et]),ke=Ce(ee=>ee.openGuestPageId),qe=Xa(ee=>ee.guests.find(Xe=>Xe.id===ke)),Ze=Ce(ee=>ee.isScheduledTasksDialogOpen),Mt=Ce(ee=>ee.isArchivePageOpen),$t=Ce(ee=>ee.isUsageStatsPageOpen),Gt=Ce(ee=>ee.worktreesPageProjectId),Ot=Ce(ee=>ee.isolatedSpacesEnabled?ee.spacesPageProjectId:null),xt=Ce(ee=>ee.runOverviewKey),Tt=lh(xt),bs=Gt??Ot,ht=as(ee=>{if(!bs)return null;const Xe=ee.projects.find(bt=>bt.id===bs);return Xe?.label?.trim()||Xe?.path?.split("/").pop()||null}),xs=l.useMemo(()=>qe?{title:qe.pageTitle??qe.name,subtitle:null}:Ze?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Mt?{title:t("sessions.archivePage.title"),subtitle:null}:$t?{title:t("usageStats.title"),subtitle:null}:Gt?{title:t("sessions.worktreesPage.title",{project:ht??""}),subtitle:null}:Ot?{title:t("spaces.page.title",{project:ht??""}),subtitle:null}:xt?{title:Tt??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[qe,Mt,Tt,xt,Ze,$t,Ot,ht,t,Gt]),ls=l.useMemo(()=>kn(ct||y?.path||""),[y?.path,ct]),ys=Nv(),Es=Ja(ee=>ee.planModeEnabled),De=Je(ee=>ee.isSessionPlanAvailable),ot=Es&&c?De(c):!1,dt=l.useRef("");l.useEffect(()=>{if(!Es||!c)return;const ee=`${c||"none"}:${Fe||"none"}:${le?.created||0}:${le?.slug||"none"}`;dt.current!==ee&&(dt.current=ee)},[Es,ot,le?.slug,le?.created,c,Fe]);const st=l.useCallback(()=>{Un("desktop_open_draft_mini_chat_window",{directory:At?"":tt,projectId:At?null:Qe,apiBaseUrl:Yo(),clientToken:ta()}).catch(ee=>{console.warn("[header] failed to open draft mini chat window",ee)})},[tt,Qe,At]),pt=l.useCallback(()=>{if(a){st();return}c&&Un("desktop_open_session_mini_chat_window",{sessionId:c,directory:Fe||kn(_e||"")||fe,apiBaseUrl:Yo(),clientToken:ta()}).catch(ee=>{console.warn("[header] failed to open session mini chat window",ee)})},[c,st,a,_e,Fe,fe]),Xt=l.useCallback(()=>{const ee=kn(ct||"");if(!ee)return;const Xe=Ce.getState().contextPanelByDirectory[ee];if(Tc(Xe)==="context"){r(ee);return}n(ee)},[r,n,ct]),us=gt==="context",is=Pr,fs=l.useMemo(()=>h&&B&&!N?"88px":j?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!h||W)&&!de?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[h,N,B,j,de,W]);Ms.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",fs)},[fs]);const ws=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Xs=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";Ms.useEffect(()=>{if(!h||!B){C(!1);return}let ee=!1;const Xe=async()=>{try{const Jt=await Un("desktop_is_window_fullscreen");ee||C(Jt===!0)}catch{ee||C(!1)}},bt=()=>{Xe()};return Xe(),window.addEventListener("openchamber:window-resized",bt),()=>{ee=!0,window.removeEventListener("openchamber:window-resized",bt)}},[h,B]);const Ts=l.useMemo(()=>!h||!B||$===null?"":$>=26?"h-12":$<=15?"h-14":"",[h,B,$]),sn=l.useMemo(()=>h&&B&&!N?$!==null&&$<=15?"56px":"48px":"0px",[h,N,B,$]),ks=l.useMemo(()=>{const ee=`max(3rem, ${sn}, var(--oc-wco-titlebar-height, 0px))`,Xe=h&&!W||de,bt=W&&F==="right";if(Xe&&sn==="0px")return{};const Jt={minHeight:ee,height:ee};return!Xe&&!bt&&(Jt.paddingRight="calc(0.75rem + var(--oc-wco-right-inset, 0px))"),Jt},[h,de,sn,W,F]),$s=l.useCallback(()=>{if(typeof document>"u")return;const ee=g.current?.getBoundingClientRect().height;ee&&document.documentElement.style.setProperty("--oc-header-height",`${ee}px`)},[]);Ms.useEffect(()=>{if(typeof window>"u")return;$s();const ee=g.current;if(!ee||typeof ResizeObserver>"u")return()=>{};let Xe=0;const bt=()=>{Xe||(Xe=requestAnimationFrame(()=>{Xe=0,$s()}))},Jt=new ResizeObserver(bt);return Jt.observe(ee),window.addEventListener("resize",bt),window.addEventListener("orientationchange",bt),()=>{Xe&&cancelAnimationFrame(Xe),Jt.disconnect(),window.removeEventListener("resize",bt),window.removeEventListener("orientationchange",bt)}},[$s]),Ms.useEffect(()=>{$s()},[$s,b,Ts]);const _s=l.useCallback(async ee=>{const Xe=ee.target;Xe.closest(".app-region-no-drag")||Xe.closest("button, a, input, select, textarea")||ee.button===0&&h&&await ym()},[h]),Tn=l.useCallback(ee=>dr(po(ee,o)),[o]);Mg({rename_current_session:()=>{if(!c||b)return!1;Ye()},archive_current_session:()=>{if(!c||b||Ls.getState().entityById.get(c)?.time.archived)return!1;if(Ce.getState().showDeletionDialog){Ge({action:"archive",sessionId:c});return}et("archive",c)},toggle_services_menu:()=>{if(O){E(!1);return}E(!0),$e()}});const gr=s.jsxs(s.Fragment,{children:[ys?s.jsx(Sv,{projectRef:ys.projectRef,directory:ys.directory,className:"mr-2"}):null,s.jsx(jv,{directory:ct,className:Se(Pr,"mr-1 text-muted-foreground hover:text-foreground"),iconClassName:"h-[18px] w-[18px]"}),s.jsx(ch,{directory:ct,className:Se(Pr,"mr-1 text-muted-foreground hover:text-foreground"),iconClassName:"h-[18px] w-[18px]"}),s.jsx(Ky,{directory:ls,className:"mr-1"}),h?s.jsx(tw,{isDesktopApp:h,currentInstanceLabel:R,currentInstanceIsLocal:U,isDesktopServicesOpen:O,setIsDesktopServicesOpen:E,refreshCurrentInstanceLabel:$e,shortcutLabel:Tn,remoteUpdateInfo:ie,remoteUpdateChecking:G,remoteUpdateError:J,onOpenRemoteUpdate:Ue}):null]}),gn=S&&(a||!!c),bn=l.useCallback(({session:ee,open:Xe,isActive:bt,select:Jt,closeOtherTabs:gs,components:Ps})=>{const{Item:Cs,Separator:br}=Ps,Xn=bt&&!de&&!At&&le&&!le.parentId;return s.jsxs(s.Fragment,{children:[s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Cs,{onClick:()=>{bt||Jt(),Z.current=ee.id},children:[s.jsx(T,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),s.jsx(wa,{sessionID:ee.id,directory:ee.directory,open:Xe,Item:Cs}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Cs,{onClick:()=>os(ee.id),children:[s.jsx(T,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(br,{}),bt?s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Cs,{onClick:()=>{it()},children:[s.jsx(T,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,bt?Yt(Cs):null,Xn?s.jsx(ds,{hint:t(p?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ft?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Cs,{disabled:!Fe||ft||p,onClick:Vt,className:"w-full",children:[s.jsx(T,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,s.jsx(br,{}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:s.jsxs(Cs,{onClick:gs,children:[s.jsx(T,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),s.jsx(br,{}),s.jsx(Ic,{sessionId:ee.id,Item:Cs,onArchive:()=>Ge({action:"archive",sessionId:ee.id})}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Cs,{className:"text-destructive focus:text-destructive",onClick:()=>Ge({action:"delete",sessionId:ee.id}),children:[s.jsx(T,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[os,le,it,At,ft,p,de,Vt,Yt,Fe,t]),Ks=()=>s.jsxs("div",{onMouseDown:_s,className:Se("app-region-drag relative flex h-12 select-none items-center",W&&F==="right"?"pr-0":"pr-3",Ts),style:ks,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:ws}}),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:Xs}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[xs?s.jsxs(s.Fragment,{children:[s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Ce.getState().closeMainSurfaces(),children:s.jsx(T,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),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:xs.title}),xs.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:xs.subtitle}):null]})]}):de||!i?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:[Me?s.jsx(T,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(kc,{align:"start",children:s.jsx("button",{type:"button",className:is,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(T,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[L?s.jsxs("form",{ref:zt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:ee=>ee.stopPropagation(),onSubmit:ee=>{ee.preventDefault(),Lt()},children:[s.jsx("input",{ref:Pt,value:Te,onChange:ee=>Le(ee.target.value),onKeyDown:ee=>oa(ee,()=>te(!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(T,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>te(!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(T,{name:"close",className:"size-4"})})]}):a?null:s.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Bt}),Et?s.jsxs("span",{className:Se("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",a?"typography-ui-label text-[14px] text-foreground":"typography-micro text-[10.5px] text-muted-foreground/75"),children:[x?s.jsx("span",{className:"truncate",children:x}):null,Ht?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(T,{name:"git-branch",className:Se("flex-shrink-0 text-muted-foreground/70",a?"h-3.5 w-3.5":"h-3 w-3")}),s.jsx("span",{className:Se("truncate",a&&"text-muted-foreground"),children:Ht})]}):null,!a&&X?s.jsxs("span",{className:Se("inline-flex min-w-0 items-center gap-0.5",X==="attention"||X==="invalid"||X==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(T,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:ne})]}):null]}):null]}),s.jsx("div",{className:Se("flex h-[18px] shrink-0 items-center justify-center",Et?"self-start":"self-center"),children:c&&!a&&!L?s.jsxs(Qs,{open:ve,onOpenChange:P,onOpenChangeComplete:ee=>{!ee&&Z.current&&Z.current===c&&(Z.current=null,Ye())},children:[s.jsx(qs,{asChild:!0,children:s.jsx(ut,{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(T,{name:"more",className:"size-4"})})}),s.jsxs(Ys,{align:"end",className:"min-w-[190px]",children:[s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(ts,{onClick:()=>{Z.current=c},children:[s.jsx(T,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),s.jsx(wa,{sessionID:c,directory:Fe,open:ve,Item:ts}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(ts,{onClick:()=>c&&os(c),children:[s.jsx(T,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(Vs,{}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(ts,{onClick:()=>{it()},children:[s.jsx(T,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),Yt(ts),!de&&!At&&le&&!le.parentId?s.jsx(ds,{hint:t(p?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ft?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(ts,{disabled:!Fe||ft||p,onClick:Vt,className:"w-full",children:[s.jsx(T,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,s.jsx(Vs,{}),s.jsx(Ic,{sessionId:c,Item:ts,onArchive:()=>Ge({action:"archive",sessionId:c})}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(ts,{className:"text-destructive focus:text-destructive",onClick:()=>{c&&Ge({action:"delete",sessionId:c})},children:[s.jsx(T,{name:"delete-bin",className:"mr-1 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(kc,{align:"start",children:s.jsx("button",{type:"button",className:is,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(T,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Mv,{renderMenu:bn,suppressActiveTabControls:L,onMenuOpenChangeComplete:ee=>{!ee&&Z.current&&Z.current===c&&(Z.current=null,Ye())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:L?s.jsxs("form",{ref:zt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:ee=>ee.stopPropagation(),onSubmit:ee=>{ee.preventDefault(),Lt()},children:[s.jsx("input",{ref:Pt,value:Te,onChange:ee=>Le(ee.target.value),onKeyDown:ee=>oa(ee,()=>te(!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(T,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>te(!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(T,{name:"close",className:"size-4"})})]}):s.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap text-left text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):Bt})})})]}),xs||de||!i?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Oe&&k?s.jsx(gy,{reading:by(k),contextLimit:k.contextLimit,outputLimit:k.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Xt,pressed:us,className:gn?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(ew,{visible:gn,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:pt,className:Se(is,"mr-1"),Icon:"picture-in-picture-2"}),de?null:s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":ye,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:Pe,className:Se(Pr,"mr-1",ye?"text-foreground":"text-muted-foreground/50"),children:s.jsx(T,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t(he&&!se?Ne?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":he?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),gr,s.jsx(Af,{visible:W&&F==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:g,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:Ks()}),s.jsx(en,{open:We!==null,onOpenChange:ee=>{ee||Ge(null)},children:s.jsxs(tn,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(pn,{children:[s.jsx(mn,{children:We?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(hn,{children:We?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Bt}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Bt})})]}),s.jsxs(pr,{children:[s.jsx(ut,{variant:"outline",size:"sm",onClick:()=>Ge(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",size:"sm",onClick:()=>{It()},children:We?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(pu,{open:ce,onOpenChange:oe,info:ie,downloading:!1,downloaded:!1,progress:null,error:J,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function nw(){}const Oc=280,Bc=264,Fc=500,rw=({isOpen:t,isMobile:e,children:n,className:r,topBar:o})=>{const{t:i}=vt(),d=Ce(C=>C.sidebarWidth),a=Ce(C=>C.setSidebarWidth),[c,u]=l.useState(!1),f=l.useRef(0),p=l.useRef(d||Oc),m=l.useRef(null),y=l.useRef(null),x=l.useRef(null),w=l.useCallback(C=>Math.min(Fc,Math.max(Bc,C)),[]),b=l.useCallback(C=>{const B=x.current;B&&(B.style.width=`${C}px`,B.style.minWidth=`${C}px`,B.style.maxWidth=`${C}px`,B.style.setProperty("--oc-left-sidebar-width",`${C}px`))},[]);if(l.useEffect(()=>{e&&c&&u(!1)},[e,c]),l.useEffect(()=>{c||(m.current=null,y.current=null)},[c]),e)return null;const g=Math.min(Fc,Math.max(Bc,d||Oc)),h=t?g:0,v=C=>{if(t){try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}y.current=C.pointerId,u(!0),f.current=C.clientX,p.current=h,m.current=h,b(h),C.preventDefault()}},S=C=>{if(e||!c||y.current!==C.pointerId)return;const B=C.clientX-f.current,W=w(p.current+B);m.current!==W&&(m.current=W,b(W))},j=C=>{if(y.current!==C.pointerId||e)return;try{C.currentTarget.releasePointerCapture(C.pointerId)}catch{}const B=w(m.current??h);y.current=null,m.current=null,u(!1),a(B)},N=c?m.current??h:h;return s.jsxs("aside",{ref:x,className:Se("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:`${N}px`,minWidth:`${N}px`,maxWidth:`${N}px`,"--oc-left-sidebar-width":`${c?N:g}px`,overflowX:"clip",transitionProperty:c?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||h===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:Se("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",c&&"bg-[var(--interactive-border)]"),onPointerDown:v,onPointerMove:S,onPointerUp:j,onPointerCancel:j,role:"separator","aria-orientation":"vertical","aria-label":i("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Se("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",c&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[o,s.jsx(Mn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(zs,{children:n})})]})]})},ow=()=>{const t=He.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},So="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-ring hover:bg-interactive-hover transition-colors",iw=()=>{const t=He.c(40),{t:e,locale:n}=vt(),r=Ce(aw),o=Ce(lw),i=Ce(cw),d=l.useRef(null),a=dr(po("toggle_sidebar",i)),c=dw,{usesFramelessChrome:u,side:f}=Nf();let p;t[0]!==n?(p=V=>{const O=V.currentTarget.getBoundingClientRect();Un("desktop_show_app_menu",{x:O.left,y:O.bottom,locale:n}).catch(uw)},t[0]=n,t[1]=p):p=t[1];const m=p;let y,x;t[2]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{if(typeof document>"u")return;const V=d.current;if(!V)return;const O=()=>{const R=Math.max(V.getBoundingClientRect().width,V.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(R)}px`)};if(O(),typeof ResizeObserver>"u")return;const E=new ResizeObserver(O);return E.observe(V),()=>{E.disconnect()}},x=[],t[2]=y,t[3]=x):(y=t[2],x=t[3]),l.useEffect(y,x);const w="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let b;t[4]===Symbol.for("react.memo_cache_sentinel")?(b={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[4]=b):b=t[4];const g="flex items-center gap-2";let h;t[5]!==u||t[6]!==f?(h=u&&f==="left"?s.jsx(Af,{visible:!0,position:"left"}):null,t[5]=u,t[6]=f,t[7]=h):h=t[7];let v;t[8]!==m||t[9]!==e||t[10]!==u?(v=u?s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,"aria-label":e("header.actions.openAppMenuAria"),className:Se(So,"shrink-0"),children:s.jsx(T,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[8]=m,t[9]=e,t[10]=u,t[11]=v):v=t[11];const S=Ct;let j;t[12]!==e?(j=e("header.actions.openSessionsAria"),t[12]=e,t[13]=j):j=t[13];let N,C;t[14]===Symbol.for("react.memo_cache_sentinel")?(C=Se(So,"shrink-0"),N=s.jsx(T,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[14]=N,t[15]=C):(N=t[14],C=t[15]);let B;t[16]!==j||t[17]!==r?(B=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,"aria-label":j,className:C,children:N})}),t[16]=j,t[17]=r,t[18]=B):B=t[18];const W=jt,F=e("header.actions.openSessionsWithShortcut",{shortcut:a});let $;t[19]!==F?($=s.jsx("p",{children:F}),t[19]=F,t[20]=$):$=t[20];let K;t[21]!==W||t[22]!==$?(K=s.jsx(W,{children:$}),t[21]=W,t[22]=$,t[23]=K):K=t[23];let I;t[24]!==S||t[25]!==B||t[26]!==K?(I=s.jsxs(S,{children:[B,K]}),t[24]=S,t[25]=B,t[26]=K,t[27]=I):I=t[27];let z;t[28]!==c||t[29]!==o||t[30]!==e?(z=o?s.jsxs("button",{type:"button",onClick:c,className:Se(So,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(T,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:c,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Se(So,"-ml-1 shrink-0"),children:s.jsx(T,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[28]=c,t[29]=o,t[30]=e,t[31]=z):z=t[31];let k;t[32]!==I||t[33]!==z||t[34]!==h||t[35]!==v?(k=s.jsxs("div",{ref:d,className:g,children:[h,v,I,z]}),t[32]=I,t[33]=z,t[34]=h,t[35]=v,t[36]=k):k=t[36];let M;return t[37]!==k||t[38]!==b?(M=s.jsx("div",{className:w,style:b,children:k}),t[37]=k,t[38]=b,t[39]=M):M=t[39],M};function aw(t){return t.toggleSidebar}function lw(t){return t.isSidebarOpen}function cw(t){return t.shortcutOverrides}function dw(){Ce.getState().closeMainSurfaces(),Je.getState().openNewSessionDraft()}function uw(t){console.warn("[titlebar] failed to open app menu",t)}function Wf(t){const e=He.c(5),{className:n}=t,o=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let i,d,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),d=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(T,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=i,e[1]=d,e[2]=a):(i=e[0],d=e[1],a=e[2]);let c;return e[3]!==o?(c=s.jsxs("span",{"aria-hidden":"true",className:o,children:[i,d,a]}),e[3]=o,e[4]=c):c=e[4],c}function fw(t,e,n){const r=He.c(5),[o,i]=l.useState();let d,a;return r[0]!==n||r[1]!==t||r[2]!==e?(d=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let c=!1;return(async()=>{const[u,f]=await Promise.all([Tg(t),Og(t)]).catch(pw);if(c)return;const p=at(u),m=at(f);if(!p||!m||m===p)return;const y=n||"",x=m.split("/").filter(Boolean).pop()||m;i({source:"sdk",path:m,projectDirectory:p,branch:y,label:y||x,name:x,worktreeRoot:m,worktreeStatus:"ready",headState:y?"branch":"unborn",worktreeSource:"existing"})})(),()=>{c=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=d,r[4]=a):(d=r[3],a=r[4]),l.useEffect(d,a),e??o}function pw(){return["",""]}const mw=()=>{const t=He.c(3),e=Ce(hw),n=Ce(gw);let r;return t[0]!==e||t[1]!==n?(r=()=>{n("integrations"),e(!0)},t[0]=e,t[1]=n,t[2]=r):r=t[2],r};function hw(t){return t.setSettingsDialogOpen}function gw(t){return t.setSettingsPage}const bw="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)]",Lc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",xw=({className:t,identity:e=Lu})=>{const{t:n}=vt(),{sourceControl:r}=jn(),o=Fu(e),i=e.provider==="gitlab",d=i?"gitlab":"github-fill",a=o?.status??null,c=Hn(g=>g.setStatus),[u,f]=l.useState(!1),p=l.useCallback(async g=>{if(!(!g||u)){f(!0);try{c(e,await r.authActivate(e,g))}catch(h){console.error("Failed to switch source control account:",h)}finally{f(!1)}}},[e,u,c,r]);if(a?.status!=="connected")return null;const m=a.user.username||null,y=a.user.avatarUrl??null,x=a.accounts,w=i?m?n("header.gitlab.connectedWithLogin",{login:m}):n("header.gitlab.connected"):m?n("header.github.connectedWithLogin",{login:m}):n("header.github.connected"),b=y?s.jsx("img",{src:y,alt:m?n("header.github.avatarWithLogin",{login:m}):n(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(T,{name:d,className:"h-3.5 w-3.5 text-foreground"});return x.length<=1?s.jsx("div",{className:Se(Lc,t),title:w,children:b}):s.jsxs(Qs,{children:[s.jsx(qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Se(Lc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:w,disabled:u,children:b})}),s.jsxs(Ys,{align:"end",className:"w-64",children:[s.jsx(Cr,{className:"typography-ui-header font-semibold text-foreground",children:n(i?"header.gitlab.accountsTitle":"header.github.accountsTitle")}),s.jsx(Vs,{}),x.map(g=>{const h=g.user,v=!!g.current,S=n(Bg(g.source??"oauth"));return s.jsxs(ts,{className:"gap-2",disabled:u,onSelect:()=>{v||p(g.id)},children:[h?.avatarUrl?s.jsx("img",{src:h.avatarUrl,alt:h.username?n("header.github.avatarWithLogin",{login:h.username}):n(i?"header.gitlab.avatar":"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(T,{name:d,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:h?.name?.trim()||h.username||(i?"GitLab":"GitHub")}),h.username?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:h.username}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:S})]}):null]}),v?s.jsx(T,{name:"check",className:"h-4 w-4 text-primary"}):null]},g.id)})]})]})},yw=t=>JSON.stringify(Fg(t)),vw=async(t,e)=>{const n=await t.projectUpstream(e);if(!n?.isFork||!n.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,n.upstream.owner,n.upstream.name);return{upstream:n.upstream,branches:r}},qr=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function ww(t){if(!qr(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}const zf="openchamber:pr-merge-method:v1",Sw=t=>t==="merge"||t==="squash"||t==="rebase",jw=()=>{try{const t=localStorage.getItem(zf);return Sw(t)?t:"squash"}catch{return"squash"}},kw=t=>{try{localStorage.setItem(zf,t)}catch{}},Cw=35e3,zi=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const o=e?Date.parse(e):n??Date.now();if(!Number.isFinite(o)||o<=r)return null;const i=Math.floor((o-r)/6e4);if(i<1)return"<1m";if(i<60)return`${i}m`;const d=Math.floor(i/60),a=i%60;return a>0?`${d}h ${a}m`:`${d}h`},Vi=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},$c=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"}},Nw=(t,e)=>{const{currentSessionId:n,getDirectoryForSession:r}=Je.getState(),o=n?r(n):null;!n||!o||at(o)!==at(t)||Wg(n,o,zg({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},Aw=t=>{const e=t?.changeRequest??t?.pr;return e?Vg({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},Pw=[2e3,5e3];let _c=0;const Iw=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(_c+=1,`source-control-${Date.now().toString(36)}-${_c.toString(36)}`)},jo=(t,e,n,r)=>JSON.stringify([t,e,n.provider,n.instance,n.directory,n.repositoryId,n.accountId,n.bindingRevision,n.primaryRemote,...r]),Kc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Ln=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):""},Dw=(t,e)=>{const n=Ln(t);if(!n||n.includes("->"))return"";if(e){const o=`${e}/`;return n.startsWith(o)?n.slice(o.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},Ew=(t,e)=>`${t}::${e}`,Ui=(t,e)=>{const n={project:{owner:t.owner,name:t.name},number:e.number,head:e.head,base:e.base};return e.headSha&&(n.headSha=e.headSha),n},Wr=new Map,ko=Gn;function Rw(t,e,n){const r=He.c(14);let o;r[0]!==n?(o=n?yw(n):null,r[0]=n,r[1]=o):o=r[1];const i=o;let d;r[2]===Symbol.for("react.memo_cache_sentinel")?(d={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=d):d=r[2];const[a,c]=l.useState(d);let u,f;r[3]!==i||r[4]!==t||r[5]!==n||r[6]!==e?(u=()=>{if(!t||!n||!i)return;let m=!1;return(async()=>{try{const y=await vw(e,n);m||c({contextKey:i,detectedUpstream:y.upstream,upstreamBranches:y.branches})}catch{}})(),()=>{m=!0}},f=[i,t,n,e],r[3]=i,r[4]=t,r[5]=n,r[6]=e,r[7]=u,r[8]=f):(u=r[7],f=r[8]),l.useEffect(u,f);let p;return r[9]!==i||r[10]!==a.contextKey||r[11]!==a.detectedUpstream||r[12]!==a.upstreamBranches?(p=a.contextKey===i?{detectedUpstream:a.detectedUpstream,upstreamBranches:a.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=i,r[10]=a.contextKey,r[11]=a.detectedUpstream,r[12]=a.upstreamBranches,r[13]=p):p=r[13],p}const Mw=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remoteBranches:o=[],onGeneratedDescription:i})=>{const{t:d}=vt(),a=$u(t),c=l.useCallback((Y,Ke)=>d(zn(Y,a?.provider),Ke),[a?.provider,d]),u=l.useCallback(Y=>a?.provider==="gitlab"?`!${Y??""}`:`PR #${Y??""}`,[a?.provider]),f=Ce(Y=>Y.timeFormatPreference),p=mw(),{sourceControl:m}=jn(),y=Hn(Y=>Y.entries),x=Je(Y=>Y.currentSessionId),w=Je(Y=>!!Y.newSessionDraft?.open),{isMobile:b,hasTouchInput:g,screenWidth:h}=Yn(),v=Ce(Y=>Y.openContextSurface),S=dh(Y=>Y.requestTarget),j=!b&&h>=768&&!cn(),N=l.useMemo(()=>Ew(t,e),[t,e]),C=l.useMemo(()=>Wr.get(N)??null,[N]),B=vs(Y=>Y.ensureEntry),W=vs(Y=>Y.setParams),F=vs(Y=>Y.beginActiveContextsLoad),$=vs(Y=>Y.commitActiveContexts),K=vs(Y=>Y.releaseActiveContexts),I=l.useId(),z=vs(Y=>Y.startWatching),k=vs(Y=>Y.stopWatching),M=vs(Y=>Y.refresh),V=vs(Y=>Y.updateStatus),[O,E]=l.useState(()=>C?.title??Kc(e)),[R,_]=l.useState(()=>C?.body??""),[U,me]=l.useState(()=>C?.draft??!1),[ce,oe]=l.useState(()=>C?.additionalContext??""),[ie,xe]=l.useState(()=>{const Y=typeof C?.targetBaseBranch=="string"?Ln(C.targetBaseBranch):"";return Y||Ln(n)}),[G,pe]=l.useState(jw),[J,ge]=l.useState(!1),[de,Ae]=l.useState(!1),[he,Re]=l.useState(!1),[se,Ne]=l.useState(!1),[be,we]=l.useState(!1),[ye,Pe]=l.useState(!1),[Oe,$e]=l.useState(null),[ze,Ue]=l.useState(""),[q,ue]=l.useState(""),[A,Q]=l.useState(!1),[le,Ie]=l.useState(!1),re=_u(t,m),H=re.scope.runtimeKey;l.useEffect(()=>{if(!t)return;const Y=re.scope.runtimeKey,Ke=F(Y,t,I),rt=re.contexts.filter(lt=>la(y[Ar(lt)],lt).connected);return $(Y,t,I,Ke,rt),()=>{K(Y,t,I)}},[F,re.contexts,re.scope.runtimeKey,$,t,K,y,I]);const X=re.contexts[0]??null,fe=Hn(Y=>a?Y.entries[Ar(a)]?.hasChecked===!0:!1),Fe=X?.primaryRemote??null,Me=l.useMemo(()=>X?Ar(X):"",[X]),tt=Hn(Y=>Y.entries[Me]),nt=tt?.status??null,Qe=X?la(tt,X):{authChecked:tt?.hasChecked??!1,connected:!1},_e=Qe.authChecked,[wt,ct]=l.useState(0),[gt,Kt]=l.useState({key:"",status:"loading",capabilities:null}),[kt,Ht]=l.useState(!1),{detectedUpstream:At,upstreamBranches:Et}=Rw(t,m,X);l.useEffect(()=>{if(!X)return;let Y=!1;const Ke=Ar(X);return Kt({key:Ke,status:"loading",capabilities:null}),m.capabilities(X).then(rt=>{Y||Kt({key:Ke,status:"ready",capabilities:rt})}).catch(()=>{Y||Kt({key:Ke,status:"error",capabilities:null})}),()=>{Y=!0}},[wt,X,m]);const Bt=gt.key===Me?gt:null,Rt=Bt?.status==="ready"?Bt.capabilities:null,Wt=l.useMemo(()=>Rt?.mergeMethods??[],[Rt?.mergeMethods]);l.useEffect(()=>{Wt.length>0&&!Wt.includes(G)&&pe(Wt[0])},[G,Wt]),l.useEffect(()=>{Ht(!1)},[t]);const je=!!(t&&e&&n&&(e!==n||At!==null)),L=l.useMemo(()=>X?Ku(X,e):"",[e,X]),te=l.useRef(L);te.current=L;const ve=l.useCallback((Y,Ke)=>Y===ss()&&Ke===te.current,[]),P=vs(Y=>Y.entries[L]),Z=l.useMemo(()=>L?[L]:[],[L]);Wu(zu(Z));const Te=P?.isLoading??!1,Le=Qe.connected?P?.status??null:null,We=re.error?c("settings.gitlab.status.operationFailed"):P?.error??null,Ge=P?.isInitialStatusResolved??!1,zt=l.useMemo(()=>{const Y=kt?null:Fe,Ke=new Set;for(const Ft of o){const yt=Dw(Ft,Y);!yt||yt==="HEAD"||Ke.add(yt)}if(kt)for(const Ft of Et)Ft&&Ft!=="HEAD"&&Ke.add(Ft);const rt=Ln(n);rt&&rt!=="HEAD"&&Ke.add(rt);const lt=Ln(ie);return lt&<!=="HEAD"&&Ke.add(lt),Array.from(Ke).sort((Ft,yt)=>Ft.localeCompare(yt))},[n,o,Fe,ie,Et,kt]);l.useEffect(()=>{const Y=Ln(n);if(!ie&&Y){xe(Y);return}if(zt.length!==0&&!zt.includes(ie)){const Ke=zt.includes(Y)?Y:zt[0];Ke&&xe(Ke)}},[zt,n,ie]);const[Ye,Ee]=l.useState(()=>C?.activeSegment??"overview"),[Pt,Lt]=l.useState(new Set),[os,it]=l.useState(new Set),Ve=l.useRef(new Set),Qt=l.useRef(null),St=l.useRef([]),Yt=l.useRef(new Map),ft=l.useCallback(Y=>{const Ke=Yt.current.get(Y);if(Ke?.inFlight)return null;if(Ke)return Ke.inFlight=!0,Ke.key;const rt=Iw();return Yt.current.set(Y,{key:rt,inFlight:!0}),rt},[]),Vt=l.useCallback((Y,Ke,rt)=>{const lt=Yt.current.get(Y);!lt||lt.key!==Ke||(rt?lt.inFlight=!1:Yt.current.delete(Y))},[]);l.useEffect(()=>{At&&Ht(!0)},[At]),l.useEffect(()=>{kt&&At?.defaultBranch&&xe(At.defaultBranch)},[kt,At?.defaultBranch]);const et=Le?.changeRequest??Le?.pr??null,It=Le?.identity??X,ke=l.useMemo(()=>Le?.project??(Le?.repo&&It?{...Le.repo,...It,id:`${Le.repo.owner}/${Le.repo.repo}`,name:Le.repo.repo}:null),[Le?.project,Le?.repo,It]),qe=l.useMemo(()=>ke?{owner:ke.owner,name:ke.name}:void 0,[ke]),Ze=et?.state==="merged"||et?.state==="closed",Mt=Ze?null:et,$t=Mt&&X?Mi(X,Mt.number,qe):null,Gt=Gl(Y=>$t?Y.entries[$t]:void 0),Ot=Gl(Y=>Y.ensure),xt=Gt?.result??null,Tt=Gt?.isLoading??!1,bs=l.useCallback(Y=>{Ee(Y);const Ke=Wr.get(N);Ke&&Wr.set(N,{...Ke,activeSegment:Y})},[N]);l.useEffect(()=>{!Mt||!X||Ye==="overview"||Ot(m,X,Mt.number,{includeCIDetails:Ye==="checks",project:qe})},[Ye,Ot,Mt,qe,X,m]);const ht=Le?.ci?.summary??Le?.checks??null,xs=(ht?.pending??0)>0,ls=xt?.ci?.summary??null,ys=xt?.fetchedAt;l.useEffect(()=>{ls&&V(L,Y=>{if(!Y?.changeRequest&&!Y?.pr||typeof ys=="number"&&typeof Y.fetchedAt=="number"&&ys<Y.fetchedAt)return Y;const Ke=Y.ci?.summary??Y.checks;return Ke&&Ke.state===ls.state&&Ke.total===ls.total&&Ke.success===ls.success&&Ke.failure===ls.failure&&Ke.pending===ls.pending&&Ke.inProgress===ls.inProgress&&Ke.queued===ls.queued&&Ke.startedAt===ls.startedAt?Y:{...Y,ci:xt?.ci??{summary:ls},checks:ls,...typeof ys=="number"?{fetchedAt:ys}:{}}})},[ls,ys,xt?.ci,L,V]),l.useEffect(()=>{if(Ye!=="checks"||!xs||!et||!X)return;const Y=window.setInterval(()=>{Ot(m,X,et.number,{includeCIDetails:!0,project:qe,force:!0})},Cw);return()=>window.clearInterval(Y)},[Ye,xs,Ot,et,qe,X,m]);const[Es,De]=l.useState(()=>Date.now());l.useEffect(()=>{if(!xs)return;De(Date.now());const Y=window.setInterval(()=>De(Date.now()),3e4);return()=>window.clearInterval(Y)},[xs]);const ot=et&&X?Mi(X,et.number,qe):null,dt=!!(ot&&Oe===ot);l.useEffect(()=>{if(!et||!X||typeof et.body=="string"&&et.body.length>0)return;const Y=Mi(X,et.number,qe);if(Ve.current.has(Y))return;Ve.current.add(Y),$e(Y);let Ke=!1;return Ot(m,X,et.number,{project:qe}).then(rt=>{if(Ke)return;const lt=rt?.changeRequest;lt&&V(L,Ft=>{const yt=Ft?.changeRequest??Ft?.pr;if(!Ft||!yt||yt.number!==et.number)return Ft;const mt={...yt,body:lt.body||""};return{...Ft,changeRequest:Ft.changeRequest?{...Ft.changeRequest,body:lt.body||""}:Ft.changeRequest,pr:mt}})}).catch(()=>{}).finally(()=>{Ke||$e(rt=>rt===Y?null:rt)}),()=>{Ke=!0}},[t,Ot,et,L,qe,X,m,V]),l.useEffect(()=>{if(!et){Pe(!1),Ue(""),ue(""),Qt.current=null;return}const Y=Qt.current!==null&&Qt.current!==et.number;Y&&Pe(!1),(!ye||Y)&&(Ue(et.title||""),ue(et.body||"")),Qt.current=et.number},[ye,et]);const st=l.useCallback(Y=>{if(!Y)return"";const Ke=Date.parse(Y);return Number.isFinite(Ke)?Vu(Ke,f,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):Y},[f]),pt=X&&nt?.connected?nt.accounts.find(Y=>Y.id===X.accountId)?.user.username.trim()??"":"",Xt=l.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)]",[]),us=l.useCallback(Y=>{if(!It)return Y;const Ke=pt.toLowerCase(),rt=Lg(It),lt=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return Y.replace(lt,(Ft,yt,mt)=>{const Zt=`@${mt}`,es=mt.toLowerCase();return`${yt}[${Zt}](${rt}/${es}${Ke&&es===Ke?"?oc-self-mention=1":""})`})},[pt,It]),is=l.useMemo(()=>{const Y=(xt?.issueComments??[]).map(lt=>({id:`issue-${lt.id}`,body:lt.body||"",authorName:lt.author?.name||lt.author?.username||c("gitView.pr.comments.unknownAuthor"),authorLogin:lt.author?.username||null,avatarUrl:lt.author?.avatarUrl||null,createdAt:lt.createdAt,context:c("gitView.pr.comments.generalContext"),path:null,line:null})),Ke=(xt?.reviewComments??[]).map(lt=>({id:`review-${lt.id}`,body:lt.body||"",authorName:lt.author?.name||lt.author?.username||c("gitView.pr.comments.unknownAuthor"),authorLogin:lt.author?.username||null,avatarUrl:lt.author?.avatarUrl||null,createdAt:lt.createdAt,context:c("gitView.pr.comments.reviewContext"),path:lt.path||null,line:lt.line??null})),rt=[...Y,...Ke];return rt.sort((lt,Ft)=>{const yt=lt.createdAt?Date.parse(lt.createdAt):0,mt=Ft.createdAt?Date.parse(Ft.createdAt):0,Zt=Number.isFinite(yt)?yt:0,es=Number.isFinite(mt)?mt:0;return Zt-es}),rt},[xt,c]),fs=l.useCallback(()=>{const Y=x??(w?"draft":null);return Y?{directory:t,sessionKey:Y}:(Be.error(c("gitView.pr.toast.noActiveSession"),{description:c("gitView.pr.toast.noActiveSessionDescription")}),null)},[x,t,w,c]),ws=l.useCallback((Y,Ke)=>{const rt=Ke.authorLogin?`@${Ke.authorLogin}`:Ke.authorName,lt=Ke.path?` · ${Ke.path}${Ke.line?`:${Ke.line}`:""}`:"";ca.getState().addDraft(Y,{source:"pr-comment",fileLabel:`${u(et?.number)} ${rt}${lt}`,...a?.provider?{provider:a.provider}:{},startLine:Ke.line??0,endLine:Ke.line??0,code:Ke.body,language:"markdown",text:""})},[u,et?.number,a?.provider]),Xs=l.useCallback((Y,Ke)=>{const rt=Y.status||"unknown",lt=Y.conclusion??void 0,Ft=lt?`${rt} / ${lt}`:rt,yt=Y.application?.name||Y.application?.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:Y.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:yt?`${yt} · ${Ft}`:Ft})]}),Y.detailsUrl?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:Y.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(T,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),Y.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:Y.output.title}):null,Y.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:Y.output.summary}):null,Y.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:Y.output.text}):null,Array.isArray(Y.annotations)&&Y.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",Y.annotations.length>20?` (showing 20/${Y.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:Y.annotations.slice(0,20).map((mt,Zt)=>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:[mt.title||mt.level||"Issue",mt.path?` · ${mt.path}`:"",typeof mt.startLine=="number"?`:${mt.startLine}`:"",typeof mt.endLine=="number"&&mt.endLine!==mt.startLine?`-${mt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:mt.message}),mt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:mt.rawDetails}):null]},`${mt.path||"file"}:${mt.startLine||Zt}:${Zt}`))})]}):null,Y.job?.steps&&Y.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:c("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:Y.job.steps.map((mt,Zt)=>{const es=(mt.conclusion||"").toLowerCase(),qt=es&&!["success","neutral","skipped"].includes(es),ps=`${Y.id??"run"}:${Y.job?.jobId??"job"}:${mt.number??Zt}:${mt.name}`,Ws=Pt.has(ps);return qt?s.jsxs(ql,{open:Ws,children:[s.jsxs("button",{type:"button",onClick:()=>{Lt(tr=>{const Os=new Set(tr);return Os.has(ps)?Os.delete(ps):Os.add(ps),Os})},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:[Ws?s.jsx(T,{name:"arrow-down-s",className:"size-4"}):s.jsx(T,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:mt.name}),mt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:mt.conclusion}):null]}),s.jsx(Yl,{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 mt.number=="number"?s.jsxs("div",{children:[c("gitView.pr.checks.stepLabel"),": ",mt.number]}):null,mt.status?s.jsxs("div",{children:[c("gitView.pr.checks.statusLabel"),": ",mt.status]}):null,mt.conclusion?s.jsxs("div",{children:[c("gitView.pr.checks.conclusionLabel"),": ",mt.conclusion]}):null,mt.startedAt?s.jsxs("div",{children:[c("gitView.pr.checks.startedLabel"),": ",st(mt.startedAt)]}):null,mt.completedAt?s.jsxs("div",{children:[c("gitView.pr.checks.completedLabel"),": ",st(mt.completedAt)]}):null]})})]},ps):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:mt.name}),mt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:mt.conclusion}):null]},ps)})})]}):null]})},[Pt,st,c]),[Ts,sn]=l.useState(!1),[ks,$s]=l.useState(!1),_s=l.useCallback(async()=>{if(!t||!et||!X)return;const Y=fs();if(Y){sn(!0);try{const Ke=await Ot(m,X,et.number,{includeCIDetails:!0,project:qe});if(!Ke){Be.error(c("gitView.pr.toast.loadChecksFailed"));return}const lt=(Ke.ci?.runs??[]).filter(yt=>Vi(yt.conclusion));if(lt.length===0){Be.message(c("gitView.pr.toast.noFailedChecks"));return}const Ft=ca.getState();for(const yt of lt){const mt=(yt.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(`
|
|
3
|
-
`)),Zt=(yt.job?.steps??[]).filter(qt=>Vi(qt.conclusion)).map(qt=>`step ${qt.number??"?"}: ${qt.name} → ${qt.conclusion}`),es=[`check: ${yt.job?.workflowName?`${yt.job.workflowName} / ${yt.name}`:yt.name}`,`status: ${yt.status??"unknown"} / ${yt.conclusion??"unknown"}`,yt.detailsUrl?`url: ${yt.detailsUrl}`:null,yt.output?.title?`title: ${yt.output.title}`:null,yt.output?.summary?`summary:
|
|
4
|
-
${yt.output.summary}`:null,Zt.length>0?`failed steps:
|
|
5
|
-
${Zt.join(`
|
|
6
|
-
`)}`:null,mt.length>0?`annotations:
|
|
7
|
-
${mt.join(`
|
|
8
|
-
---
|
|
9
|
-
`)}`:null].filter(Boolean).join(`
|
|
10
|
-
|
|
11
|
-
`);Ft.addDraft(Y,{source:"pr-check",fileLabel:`${u(et.number)} · ${yt.name}`,...a?.provider?{provider:a.provider}:{},startLine:0,endLine:0,code:es,language:"text",text:""})}}catch(Ke){const rt=Ke instanceof Error?Ke.message:String(Ke);Be.error(c("gitView.pr.toast.loadChecksFailed"),{description:rt})}finally{sn(!1)}}},[u,t,Ot,et,qe,X,a?.provider,fs,m,c]),Tn=l.useCallback(async()=>{if(!t||!et||!X)return;const Y=fs();if(Y){$s(!0);try{if(!await Ot(m,X,et.number,{project:qe})){Be.error(c("gitView.pr.toast.loadPrCommentsFailed"));return}if(is.length===0){Be.message(c("gitView.pr.toast.noPrComments"));return}for(const rt of is)ws(Y,rt)}catch(Ke){const rt=Ke instanceof Error?Ke.message:String(Ke);Be.error(c("gitView.pr.toast.loadPrCommentsFailed"),{description:rt})}finally{$s(!1)}}},[ws,t,Ot,et,qe,X,fs,m,c,is]),gr=l.useCallback(async Y=>{const Ke=fs();Ke&&ws(Ke,Y)},[ws,fs]),[gn,bn]=l.useState(!1),Ks=l.useRef(!0);l.useEffect(()=>(Ks.current=!0,()=>{Ks.current=!1}),[]);const hs=l.useCallback(async Y=>{await M(L,Y)},[L,M]),ee=l.useCallback((Y,Ke)=>{St.current.forEach(rt=>{window.clearTimeout(rt)}),St.current=Pw.map(rt=>window.setTimeout(()=>{ve(Y,Ke)&&M(Ke,{force:!0,silent:!0,markInitialResolved:!0})},rt))},[ve,M]),Xe=l.useCallback(async(Y,Ke,rt)=>{await ww({error:Y,isCurrent:()=>ve(Ke,rt),refresh:()=>M(rt,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>ee(Ke,rt)})},[ve,M,ee]);l.useEffect(()=>{!X||!L||(B(L),W(L,{directory:t,branch:e,remoteName:X.primaryRemote,canShow:je,identity:X,readContext:X,sourceControl:m,authChecked:Qe.authChecked,connected:Qe.connected}))},[e,je,t,B,L,X,m,Qe.authChecked,Qe.connected,W]);const bt=600,Jt=l.useCallback(async()=>{if(gn)return;bn(!0);const Y=Date.now();try{await hs({force:!0})}finally{const Ke=bt-(Date.now()-Y);Ke>0&&await new Promise(rt=>window.setTimeout(rt,Ke)),Ks.current&&bn(!1)}},[gn,hs]);l.useEffect(()=>{if(!(!X||!L))return z(L),()=>{k(L)}},[L,X,z,k]),l.useEffect(()=>{const Y=Wr.get(N)??null;E(Y?.title??Kc(e)),_(Y?.body??""),me(Y?.draft??!1),xe(Y?.targetBaseBranch?Ln(Y.targetBaseBranch):Ln(n))},[n,e,N]),l.useEffect(()=>{!X||!L||!Qe.connected||hs({markInitialResolved:!0})},[L,X,hs,Qe.connected]),l.useEffect(()=>{!je||!X||!Qe.connected||hs({force:!0,silent:!0,markInitialResolved:!0})},[je,X,hs,Qe.connected]),l.useEffect(()=>{const Y=()=>{const rt=vs.getState().entries[L]?.lastRefreshAt??0;Date.now()-rt>6e4&&hs({force:!0,silent:!0})},Ke=()=>{document.visibilityState==="visible"&&Y()};return window.addEventListener("focus",Y),document.addEventListener("visibilitychange",Ke),()=>{window.removeEventListener("focus",Y),document.removeEventListener("visibilitychange",Ke)}},[L,hs]),l.useEffect(()=>{_e&&!Qe.connected&&hs({force:!0,silent:!0,markInitialResolved:!0})},[hs,Qe.connected,_e]),l.useEffect(()=>{!t||!e||Wr.set(N,{title:O,body:R,draft:U,additionalContext:ce,targetBaseBranch:ie,activeSegment:Ye})},[N,O,R,U,ce,ie,t,e,Ye]),l.useEffect(()=>()=>{St.current.forEach(Y=>{window.clearTimeout(Y)}),St.current=[]},[L,H]),l.useEffect(()=>()=>{Yt.current.clear()},[]);const gs=l.useCallback(async()=>{if(!J&&t){ge(!0);try{const Ke={base:kt&&At?.defaultBranchSha?At.defaultBranchSha:X?`${X.primaryRemote}/${ie}`:ie,head:e,...X?.provider?{changeRequestProvider:X.provider}:{}};ce&&(Ke.context=ce);const rt=await $g(t,Ke);rt.title?.trim()&&E(rt.title.trim()),rt.body?.trim()&&_(rt.body.trim()),i?.()}catch(Y){const Ke=Y instanceof Error?Y.message:String(Y);Be.error(c("gitView.pr.toast.generateDescriptionFailed"),{description:Ke})}finally{ge(!1)}}},[ce,e,At?.defaultBranchSha,t,J,i,X,ie,c,kt]),Ps=l.useCallback(async()=>{if(Rt?.changeRequests!==!0){Be.error(c("gitView.pr.toast.createPrFailed"),{description:c("gitView.pr.capabilitiesUnavailable")});return}const Y=O.trim();if(!Y){Be.error(c("gitView.pr.toast.titleRequired"));return}const Ke=ie.trim();if(!Ke){Be.error(c("gitView.pr.toast.baseBranchRequired"));return}if(!kt&&Ke===e){Be.error(c("gitView.pr.toast.baseMustDifferFromHead"));return}const rt=kt?At:ke;if(!X||!rt){Be.error(c("gitView.pr.toast.createPrFailed"),{description:c("gitView.pr.statusUnavailable")});return}const lt=ss(),Ft=L,yt={owner:rt.owner,name:rt.name},mt=R.trim()?R:void 0,Zt=kt?void 0:X.primaryRemote,es=kt?X.primaryRemote:void 0,qt=jo("create",lt,X,[yt.owner,yt.name,e,Ke,Y,mt,U,Zt,es]),ps=ft(qt);if(!ps)return;Ae(!0);let Ws=!1,tr=!1;try{const Os={...X,idempotencyKey:ps,target:{project:yt,head:e,base:Ke},title:Y,draft:U};mt!==void 0&&(Os.body=mt),Zt&&(Os.remote=Zt),es&&(Os.headRemote=es);const Bn=await m.changeRequestCreate(Os);if(tr=!0,Vt(qt,ps,!1),!ve(lt,Ft)||(Be.success(c("gitView.pr.toast.prCreated")),await hs({force:!0}),!ve(lt,Ft)))return;const vr=vs.getState().entries[Ft]?.status,_r=vr?.changeRequest??vr?.pr;_r&&_r.number===Bn.target.number&&Nw(t,_r),ee(lt,Ft)}catch(Os){const Bn=Os instanceof Error?Os:new Error(String(Os));Ws=qr(Bn);const vr=Bn.message;Be.error(c("gitView.pr.toast.createPrFailed"),{description:vr}),Ws&&await Xe(Bn,lt,Ft)}finally{tr||Vt(qt,ps,Ws),Ae(!1)}},[ft,R,e,At,t,U,Vt,ve,L,X,Xe,hs,ee,m,Rt?.changeRequests,ke,ie,O,kt,c]),Cs=l.useCallback(async Y=>{if(!X||!ke){Be.error(c("gitView.pr.toast.mergeFailed"),{description:c("gitView.pr.statusUnavailable")});return}const Ke=ss(),rt=L,lt=Ui(ke,Y),Ft=jo("merge",Ke,X,[lt.project.owner,lt.project.name,lt.number,lt.head,lt.base,lt.headSha,G]),yt=ft(Ft);if(!yt)return;Ne(!0);let mt=!1,Zt=!1;try{const es=await m.changeRequestMerge({...X,idempotencyKey:yt,target:lt,method:G});if(Zt=!0,Vt(Ft,yt,!1),!ve(Ke,rt)||(es.result.merged?Be.success(c("gitView.pr.toast.prMerged")):Be.message(c("gitView.pr.toast.prNotMerged"),{description:es.result.message||c("gitView.pr.notMergeable")}),await hs({force:!0}),!ve(Ke,rt)))return;ee(Ke,rt)}catch(es){const qt=es instanceof Error?es:new Error(String(es));mt=qr(qt);const ps=qt.message;Be.error(c("gitView.pr.toast.mergeFailed"),{description:ps}),mt&&await Xe(qt,Ke,rt),Y.url&&ko(Y.url)}finally{Zt||Vt(Ft,yt,mt),Ne(!1)}},[ft,Vt,ve,G,L,X,Xe,hs,ee,m,ke,c]),br=l.useCallback(async Y=>{if(!X||!ke){Be.error(c("gitView.pr.toast.markReadyFailed"),{description:c("gitView.pr.statusUnavailable")});return}const Ke=ss(),rt=L,lt=Ui(ke,Y),Ft=jo("ready",Ke,X,[lt.project.owner,lt.project.name,lt.number,lt.head,lt.base,lt.headSha]),yt=ft(Ft);if(!yt)return;we(!0);let mt=!1,Zt=!1;try{if(await m.changeRequestReady({...X,idempotencyKey:yt,target:lt}),Zt=!0,Vt(Ft,yt,!1),!ve(Ke,rt)||(Be.success(c("gitView.pr.toast.markedReady")),await hs({force:!0}),!ve(Ke,rt)))return;ee(Ke,rt)}catch(es){const qt=es instanceof Error?es:new Error(String(es));mt=qr(qt);const ps=qt.message;Be.error(c("gitView.pr.toast.markReadyFailed"),{description:ps}),mt&&await Xe(qt,Ke,rt),Y.url&&ko(Y.url)}finally{Zt||Vt(Ft,yt,mt),we(!1)}},[ft,Vt,ve,L,X,Xe,hs,ee,m,ke,c]),Xn=l.useCallback(async Y=>{const Ke=ze.trim();if(!Ke){Be.error(c("gitView.pr.toast.titleRequired"));return}if(!X||!ke){Be.error(c("gitView.pr.toast.updatePrFailed"),{description:c("gitView.pr.statusUnavailable")});return}const rt=ss(),lt=L,Ft=Ui(ke,Y),yt=jo("update",rt,X,[Ft.project.owner,Ft.project.name,Ft.number,Ft.head,Ft.base,Ft.headSha,Ke,q]),mt=ft(yt);if(!mt)return;Re(!0);let Zt=!1,es=!1;try{if(await m.changeRequestUpdate({...X,idempotencyKey:mt,target:Ft,title:Ke,body:q}),es=!0,Vt(yt,mt,!1),!ve(rt,lt)||(Pe(!1),Be.success(c("gitView.pr.toast.prUpdated")),await hs({force:!0}),!ve(rt,lt)))return;ee(rt,lt)}catch(qt){const ps=qt instanceof Error?qt:new Error(String(qt));Zt=qr(ps);const Ws=ps.message;Be.error(c("gitView.pr.toast.updatePrFailed"),{description:Ws}),Zt&&await Xe(ps,rt,lt)}finally{es||Vt(yt,mt,Zt),Re(!1)}},[ft,q,ze,Vt,ve,L,X,Xe,hs,ee,m,ke,c]);if(!je)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:c("gitView.pullRequest.title")}),s.jsx(xw,{identity:a??void 0})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:c("gitView.pullRequest.availableOnFeatureBranches")})]})});const ho=ke?.url||null,xr=kt&&At?.url?At.url:ho,Jn=Bt?.status==="ready",go=Bt?.status==="error",Zn=!!(Le?.canMerge&&Rt?.mergeChangeRequests===!0&&Wt.includes(G)),ki=!!Le?.connected,Ci=!!(!X&&a&&re.status==="ready"&&fe),Fr=!!(It&&_e&&Le?.connected===!1)||Ci,bo=It??a,Us=bo?_g(bo.provider):null,On=Aw(Le),er=On?`var(--pr-${On})`:"var(--status-info)",yr=On==="draft"?"git-pr-draft":On==="merged"?"git-merge":On==="closed"?"git-close-pull-request":"git-pull-request",Lr=et?[`${et.state}${et.draft?" (draft)":""}`,et.state==="open"&&et.mergeable===!1?c("gitView.pr.notMergeable"):null,et.state==="open"&&typeof et.mergeableState=="string"&&et.mergeableState&&et.mergeableState!=="unknown"?et.mergeableState:null].filter(Boolean).join(" · "):"",$r=ht?ht.total>0?`${ht.success}/${ht.total} ${c("gitView.pr.checks.label")}`:`${ht.state} ${c("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:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[et?s.jsxs(ut,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{ko(et.url)},"aria-label":Us?c("gitView.pr.actions.openOnProviderAria",{provider:Us}):c("gitView.header.openPullRequest"),children:[s.jsx(T,{name:yr,className:"size-4 shrink-0",style:{color:er}}),Us?c("gitView.pr.actions.openOnProvider",{provider:Us}):c("gitView.header.openPullRequest")]}):s.jsx(T,{name:yr,className:"size-4 shrink-0",style:{color:"var(--surface-muted-foreground)"}}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:c("gitView.pullRequest.title")}),et?s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:Za(It?.provider,et.number)}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Te||gn?s.jsx(T,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):null,s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Te||gn,onClick:()=>{Jt()},"aria-label":c("gitView.pr.actions.refreshAria"),children:s.jsx(T,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(jt,{children:s.jsx("p",{children:c("gitView.pr.actions.refresh")})})]})]})]}),et?s.jsxs("div",{className:"@container/pr-actions 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:er},children:Lr}),ht?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${$c(ht.state)}`}),$r]}):null,r&&Fe&&r.split("/")[0]!==Fe?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",Fe]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[j&&(X?.provider==="github"||X?.provider==="gitlab")?s.jsxs(ut,{variant:"outline",size:"sm",className:Se("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",bw),onClick:()=>{S(t,{source:{kind:"pr",number:et.number,...ke?{sourceRepo:{owner:ke.owner,repo:ke.name}}:{}},context:X}),v(t,"walkthrough")},"aria-label":c("walkthrough.action.open"),children:[s.jsx(T,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:c("walkthrough.action.open")})]}):null,Zn&&Rt?.draftChangeRequests===!0&&et.draft&&et.state==="open"?s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx(ut,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>br(et),disabled:be||se||he||ye,"aria-label":c("gitView.pr.actions.markReadyAria"),children:be?s.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(T,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:c("gitView.pr.actions.markReady")})})]}):null,Zn?s.jsxs(s.Fragment,{children:[s.jsxs(oc,{value:G,onValueChange:Y=>{pe(Y),kw(Y)},disabled:se||et.state!=="open",children:[s.jsx(ic,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(ac,{})}),s.jsxs(lc,{children:[Wt.includes("squash")?s.jsx(vo,{value:"squash",children:c("gitView.pr.mergeMethod.squash")}):null,Wt.includes("merge")?s.jsx(vo,{value:"merge",children:c("gitView.pr.mergeMethod.merge")}):null,Wt.includes("rebase")?s.jsx(vo,{value:"rebase",children:c("gitView.pr.mergeMethod.rebase")}):null]})]}),s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx(ut,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>Cs(et),disabled:se||be||et.state!=="open"||et.draft||he||ye,"aria-label":c("gitView.pr.actions.mergePrAria"),children:se?s.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(T,{name:"git-merge",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:c("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[go?s.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3",children:[s.jsx("div",{className:"typography-ui-label text-[var(--status-error)]",children:c("gitView.pr.capabilitiesUnavailable")}),s.jsx(ut,{variant:"outline",size:"sm",onClick:()=>ct(Y=>Y+1),children:c("settings.sourceControl.transport.retry")})]}):null,Fr&&Us?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:c("gitView.pr.providerNotConnected",{provider:Us})}),s.jsx(ut,{variant:"outline",size:"sm",onClick:p,className:"w-fit",children:c("gitView.pr.actions.openSettings")})]}):null,We?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:c("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:We}),re.error?s.jsx(ut,{variant:"outline",size:"sm",onClick:()=>{re.retry()},disabled:re.status==="loading",children:c("settings.sourceControl.transport.retry")}):null,xr?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:xr,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(T,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!et&&!Ge&&!We&&!Fr&&(re.status==="loading"||X)?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),c("gitView.pr.checkingStatus")]}):et&&!Ze?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(Uu,{className:"h-full",items:[{id:"overview",label:c("gitView.pr.segment.overview")},{id:"checks",label:ht&&ht.total>0?`${c("gitView.pr.segment.checks")} ${ht.success}/${ht.total}`:c("gitView.pr.segment.checks"),icon:ht?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${$c(ht.state)}`}):void 0},{id:"comments",label:xt?`${c("gitView.pr.segment.comments")} ${(xt.issueComments?.length??0)+(xt.reviewComments?.length??0)}`:c("gitView.pr.segment.comments")}],activeId:Ye,onSelect:Y=>bs(Y),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),Ye==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Zn&&et.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:c("gitView.pr.draftMustBeReady")}):null,!Zn&&Jn?s.jsx("div",{className:"typography-micro text-muted-foreground",children:c("gitView.pr.noMergePermission")}):null,s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:ye?s.jsx(Xr,{value:ze,onChange:Y=>Ue(Y.target.value),placeholder:c("gitView.pr.placeholder.title"),autoCorrect:g?"on":"off",autoCapitalize:g?"sentences":"off",spellCheck:g}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:et.title})}),et.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:ye?s.jsxs(s.Fragment,{children:[s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx(ut,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Pe(!1),Ue(et.title||""),ue(et.body||"")},disabled:he,"aria-label":c("gitView.pr.actions.cancelEditingAria"),children:s.jsx(T,{name:"close",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:c("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx(ut,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>Xn(et),disabled:he||!ze.trim(),"aria-label":c("gitView.pr.actions.savePrAria"),children:he?s.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(T,{name:"check",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:c("gitView.pr.actions.savePr")})})]})]}):s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx(ut,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Pe(!0),"aria-label":c("gitView.pr.actions.editPrAria"),children:s.jsx(T,{name:"edit",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:c("gitView.pr.actions.editPr")})})]})}):null]}),ye?s.jsx(wo,{value:q,onChange:Y=>ue(Y.target.value),outerClassName:"min-h-[60vh]",placeholder:c("gitView.pr.placeholder.description"),autoCorrect:g?"on":"off",autoCapitalize:g?"sentences":"off",spellCheck:g}):null,ye?null:et.body?.trim()?s.jsx(cc,{content:et.body,className:"typography-markdown-body min-w-0 text-muted-foreground break-words [&_img]:h-auto [&_img]:max-w-full",enableFileReferences:!1,allowRawHtml:!0}):s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:c(dt?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,Ye==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[ht&&ht.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:[ht.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${ht.success/ht.total*100}%`}}):null,ht.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${ht.failure/ht.total*100}%`}}):null,ht.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${ht.pending/ht.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[ht.success,"/",ht.total," ",c("gitView.pr.checks.label")]}),(ht.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(T,{name:"loader-4",className:"size-3.5 animate-spin"}),zi(ht.startedAt,void 0,Es)]}):null]}):null,ht?.failure?s.jsxs(ut,{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:_s,disabled:Ts,"aria-label":c("gitView.pr.actions.resolveFailedChecksAria"),children:[Ts?s.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(T,{name:"ai-generate-2",className:"size-4"}),c("gitView.pr.actions.resolveFailedChecks")]}):null,(xt?.ci?.runs?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(xt?.ci?.runs??[]).map((Y,Ke)=>{const rt=`${Y.id??"run"}:${Y.name}:${Ke}`,lt=Y.status==="in_progress",Ft=Y.status==="queued",yt=Vi(Y.conclusion),mt=os.has(rt),Zt=!!(Y.output?.title||Y.output?.summary||Y.output?.text||(Y.annotations?.length??0)>0||(Y.job?.steps?.length??0)>0||Y.detailsUrl),es=Y.job?.workflowName,qt=lt?zi(Y.startedAt,void 0,Es):zi(Y.startedAt,Y.completedAt);return s.jsxs("div",{className:Se("rounded-md border border-border/40",yt&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!Zt,onClick:()=>{it(ps=>{const Ws=new Set(ps);return Ws.has(rt)?Ws.delete(rt):Ws.add(rt),Ws})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[lt?s.jsx(T,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):Ft?s.jsx(T,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):yt?s.jsx(T,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(T,{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:es&&es!==Y.name?`${es} / ${Y.name}`:Y.name}),qt?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:qt}):null,Zt?s.jsx(T,{name:"arrow-down-s",className:Se("size-4 shrink-0 text-muted-foreground transition-transform",mt&&"rotate-180")}):null]}),mt&&Zt?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:Xs(Y,{hideHeader:!0})}):null]},rt)})}):Tt?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),c("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:c("gitView.pr.checkDetails.empty")})]}):null,Ye==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[is.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(ut,{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:Tn,disabled:ks,"aria-label":c("gitView.pr.actions.shareCommentsAria"),children:[ks?s.jsx(T,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(T,{name:"ai-generate-2",className:"size-3.5"}),c("gitView.pr.comments.addAll")]})}):null,is.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:is.map((Y,Ke)=>{const rt=(Y.authorName||"?").charAt(0).toUpperCase(),lt=Ke===is.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[lt?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:Y.avatarUrl?s.jsx("img",{src:Y.avatarUrl,alt:Y.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:rt})}),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:[Y.authorName,Y.authorLogin&&Y.authorLogin!==Y.authorName?` · @${Y.authorLogin}`:""]}),Y.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:st(Y.createdAt)}):null,s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsxs(ut,{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:()=>{gr(Y)},"aria-label":c("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(T,{name:"ai-generate-2",className:"size-3.5"}),c("gitView.pr.actions.sendToAgent")]})}),s.jsx(jt,{children:s.jsx("p",{children:c("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[Y.context,Y.path?` · ${Y.path}`:"",Y.line?`:${Y.line}`:""]}),s.jsx(cc,{content:us(Y.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",Xt].filter(Boolean).join(" "),enableFileReferences:!1,allowRawHtml:!0})]})]},Y.id)})})}):Tt&&!xt?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),c("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:c("gitView.pr.comments.empty")})]}):null]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[et&&Ze?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(T,{name:et.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:er}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:et.state==="merged"?c("gitView.pr.history.merged",{number:et.number,base:et.base||ie}):c("gitView.pr.history.closed",{number:et.number})}),s.jsx(ut,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{ko(et.url)},"aria-label":c("gitView.pr.actions.openOnProviderAria",{provider:Us}),children:s.jsx(T,{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:c("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",ie," ",s.jsxs("span",{className:"opacity-60",children:["(",kt&&At?"upstream":"remote",")"]})]})]}),xr?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:xr,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(T,{name:"external-link",className:"size-4"}),c("gitView.pr.actions.repo")]})}):null]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:c("gitView.pr.field.title")}),s.jsx(Xr,{value:O,onChange:Y=>E(Y.target.value),placeholder:c("gitView.pr.placeholder.title"),autoCorrect:g?"on":"off",autoCapitalize:g?"sentences":"off",spellCheck:g})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:c("gitView.pr.field.baseBranch")}),zt.length>0?s.jsxs(oc,{value:ie,onValueChange:xe,children:[s.jsx(ic,{size:"lg","aria-label":c("gitView.pr.field.baseBranch"),children:s.jsx(ac,{placeholder:c("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(lc,{children:zt.map(Y=>s.jsx(vo,{value:Y,children:Y},Y))})]}):s.jsx(Xr,{value:ie,onChange:Y=>xe(Y.target.value),placeholder:c("gitView.pr.placeholder.main"),"aria-label":c("gitView.pr.field.baseBranch")})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:c("gitView.pr.field.description")}),s.jsx(wo,{value:R,onChange:Y=>_(Y.target.value),className:"min-h-[110px]",placeholder:c("gitView.pr.placeholder.whatChanged"),autoCorrect:g?"on":"off",autoCapitalize:g?"sentences":"off",spellCheck:g})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":U,onClick:()=>me(Y=>!Y),onKeyDown:Y=>{(Y.key===" "||Y.key==="Enter")&&(Y.preventDefault(),me(Ke=>!Ke))},children:[s.jsx(Kg,{size:"sm",checked:U,onChange:Y=>me(Y),ariaLabel:c("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:c("gitView.pr.field.draft")})]}),b?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:c("gitView.pr.additionalContext.optional")}),s.jsx(ut,{variant:"outline",size:"sm",onClick:()=>Ie(!0),children:ce.trim()?c("gitView.pr.actions.edit"):c("gitView.pr.actions.add")})]}),ce.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:c("gitView.pr.additionalContext.added")})})]}):s.jsxs(ql,{open:A,onOpenChange:Q,children:[s.jsxs(uh,{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:c("gitView.pr.additionalContext.optional")}),s.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:A?c("gitView.pr.actions.hide"):ce.trim()?c("gitView.pr.actions.edit"):c("gitView.pr.actions.add")})]}),s.jsx(Yl,{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(wo,{value:ce,onChange:Y=>oe(Y.target.value),className:"min-h-[100px] bg-transparent",placeholder:c("gitView.pr.placeholder.additionalContext")}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:c("gitView.pr.additionalContext.hint")})]})})]}),s.jsx(Hu,{open:le,onClose:()=>Ie(!1),title:c("gitView.pr.additionalContext.title"),footer:s.jsx(ut,{size:"sm",onClick:()=>Ie(!1),className:"w-full",children:c("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(wo,{value:ce,onChange:Y=>oe(Y.target.value),className:"min-h-[200px] bg-transparent",placeholder:c("gitView.pr.placeholder.additionalContext"),autoFocus:!0}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:c("gitView.pr.additionalContext.hint")})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ut,{variant:"outline",size:"sm",onClick:gs,disabled:J||de,children:[J?s.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(T,{name:"ai-generate-2",className:"size-4 text-primary"}),c("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(ut,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:Ps,disabled:de||!ki||Rt?.changeRequests!==!0||!ie.trim()||!kt&&ie.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:de?s.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(T,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:c("gitView.pr.actions.createPr")})]})]})]})]})]})},Tw=()=>{const t=He.c(99),{t:e}=vt(),{git:n,sourceControl:r}=jn(),o=fr(),{rootIsGitRepo:i,gitDirectory:d,nestedRepos:a}=Ug(o??null),c=el(d??null),u=Hg(d??null),f=Gg(d??null),p=_u(d,r),{ensureAll:m,ensureNestedRepos:y,selectNestedRepo:x}=mr(Or(Ow)),w=Je(Bw),b=Je(Fw),g=Je(Lw),h=Je($w);let v;t[0]!==o?(v=at(o),t[0]=o,t[1]=v):v=t[1];const S=v;let j;if(t[2]!==h||t[3]!==S||t[4]!==g){e:{if(!S){j=void 0;break e}let be;if(t[6]!==h||t[7]!==S){let ye;t[9]!==S?(ye=Pe=>at(Pe.path)===S,t[9]=S,t[10]=ye):ye=t[10],be=h.find(ye),t[6]=h,t[7]=S,t[8]=be}else be=t[8];const we=be;if(we){j=we;break e}for(const ye of g.values())if(at(ye.path)===S){j=ye;break e}j=void 0}t[2]=h,t[3]=S,t[4]=g,t[5]=j}else j=t[5];const N=j;let C;t[11]!==w||t[12]!==N||t[13]!==b?.open||t[14]!==g?(C=()=>{if(w)return g.get(w)??N;if(b?.open)return N},t[11]=w,t[12]=N,t[13]=b?.open,t[14]=g,t[15]=C):C=t[15],b?.open;let B;t[16]!==C?(B=C(),t[16]=C,t[17]=B):B=t[17];const W=B;let F;t[18]!==w?(F=be=>w?be.getAttachment(w):void 0,t[18]=w,t[19]=F):F=t[19];const $=Iu(F),K=$&&!$.degraded&&!$.legacy?$.worktreeRoot??void 0:void 0,I=fw(o,W,c?.current??void 0);let z,k;t[20]!==m||t[21]!==n||t[22]!==d?(z=()=>{!d||!n||m(d,n)},k=[d,m,n],t[20]=m,t[21]=n,t[22]=d,t[23]=z,t[24]=k):(z=t[23],k=t[24]),l.useEffect(z,k);const[M,V]=l.useState(null);let O;t[25]!==K||t[26]!==I?.projectDirectory?(O=()=>{const be=K||I?.projectDirectory;if(!be){V(null);return}let we=!1;return Gu(be).then(ye=>{if(we)return;const Pe=ye.trim();V(Pe&&Pe!=="HEAD"?Pe:null)}).catch(()=>{we||V(null)}),()=>{we=!0}},t[25]=K,t[26]=I?.projectDirectory,t[27]=O):O=t[27];const E=I?.projectDirectory;let R;t[28]!==K||t[29]!==E?(R=[K,E],t[28]=K,t[29]=E,t[30]=R):R=t[30],l.useEffect(O,R);let _;e:{if(!u?.all){let we;t[31]===Symbol.for("react.memo_cache_sentinel")?(we=[],t[31]=we):we=t[31],_=we;break e}let be;t[32]!==u.all?(be=u.all.filter(_w).sort(),t[32]=u.all,t[33]=be):be=t[33],_=be}const U=_;let me;e:{if(!u?.all){let we;t[34]===Symbol.for("react.memo_cache_sentinel")?(we=[],t[34]=we):we=t[34],me=we;break e}let be;t[35]!==u.all?(be=u.all.filter(Kw).map(Ww).sort(),t[35]=u.all,t[36]=be):be=t[36],me=be}const ce=me,oe=c?.current??null,ie=p.contexts[0]?.primaryRemote,xe=ie?u?.defaultBranches?.[ie]:void 0;let G;t[37]!==p.contexts[0]||t[38]!==p.read?.repository.remotes||t[39]!==oe||t[40]!==xe||t[41]!==U||t[42]!==M||t[43]!==I?.createdFromBranch?(G=()=>fh({remoteNames:new Set(p.contexts[0]?.primaryRemote?[p.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(p.read?.repository.remotes.map(zw)??[]),localBranches:U,worktreeCreatedFromBranch:I?.createdFromBranch,rootBranchHint:M,defaultBranch:xe,headBranch:oe,fallbackToConventional:!1}),t[37]=p.contexts[0],t[38]=p.read?.repository.remotes,t[39]=oe,t[40]=xe,t[41]=U,t[42]=M,t[43]=I?.createdFromBranch,t[44]=G):G=t[44],I?.createdFromBranch;let pe;t[45]!==G?(pe=G(),t[45]=G,t[46]=pe):pe=t[46];const J=pe,ge=$u(o??null)?.provider;if(!o){let be;t[47]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(T,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[47]=be):be=t[47];let we;t[48]!==ge||t[49]!==e?(we=e(zn("gitView.pullRequest.title",ge)),t[48]=ge,t[49]=e,t[50]=we):we=t[50];let ye;t[51]!==we?(ye=s.jsx("div",{className:"typography-ui-header text-foreground",children:we}),t[51]=we,t[52]=ye):ye=t[52];let Pe;t[53]!==ge||t[54]!==e?(Pe=e(zn("gitView.pullRequest.createHint",ge)),t[53]=ge,t[54]=e,t[55]=Pe):Pe=t[55];let Oe;t[56]!==Pe?(Oe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Pe}),t[56]=Pe,t[57]=Oe):Oe=t[57];let $e;return t[58]!==ye||t[59]!==Oe?($e=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[be,ye,Oe]}),t[58]=ye,t[59]=Oe,t[60]=$e):$e=t[60],$e}if(i===!1&&f!==!0){let be;t[61]!==o||t[62]!==y?(be=()=>{y(o,{force:!0})},t[61]=o,t[62]=y,t[63]=be):be=t[63];let we;return t[64]!==o||t[65]!==f||t[66]!==a||t[67]!==i||t[68]!==be?(we=s.jsx(ph,{root:o,rootIsGitRepo:i,resolvedIsGitRepo:f,nestedRepos:a,onRetryDiscovery:be}),t[64]=o,t[65]=f,t[66]=a,t[67]=i,t[68]=be,t[69]=we):we=t[69],we}if(!oe){let be;t[70]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(T,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[70]=be):be=t[70];let we;t[71]!==ge||t[72]!==e?(we=e(zn("gitView.pullRequest.title",ge)),t[71]=ge,t[72]=e,t[73]=we):we=t[73];let ye;t[74]!==we?(ye=s.jsx("div",{className:"typography-ui-header text-foreground",children:we}),t[74]=we,t[75]=ye):ye=t[75];let Pe;t[76]!==ge||t[77]!==e?(Pe=e(zn("gitView.pullRequest.createHint",ge)),t[76]=ge,t[77]=e,t[78]=Pe):Pe=t[78];let Oe;t[79]!==Pe?(Oe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Pe}),t[79]=Pe,t[80]=Oe):Oe=t[80];let $e;return t[81]!==ye||t[82]!==Oe?($e=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[be,ye,Oe]}),t[81]=ye,t[82]=Oe,t[83]=$e):$e=t[83],$e}const de=i===!1&&Array.isArray(a)&&a.length>0;let Ae;t[84]!==o||t[85]!==d||t[86]!==a||t[87]!==x||t[88]!==de?(Ae=de?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(mh,{repositories:a,selectedRepository:d??null,onSelectRepository:be=>{o&&x(o,be)},repositoryRoot:o??void 0})}):null,t[84]=o,t[85]=d,t[86]=a,t[87]=x,t[88]=de,t[89]=Ae):Ae=t[89];const he=d??o,Re=c?.tracking??void 0;let se;t[90]!==J||t[91]!==oe||t[92]!==ce||t[93]!==he||t[94]!==Re?(se=s.jsx(Mn,{as:qg,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(Mw,{directory:he,branch:oe,baseBranch:J,trackingBranch:Re,remoteBranches:ce})}),t[90]=J,t[91]=oe,t[92]=ce,t[93]=he,t[94]=Re,t[95]=se):se=t[95];let Ne;return t[96]!==Ae||t[97]!==se?(Ne=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[Ae,se]}),t[96]=Ae,t[97]=se,t[98]=Ne):Ne=t[98],Ne};function Ow(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function Bw(t){return t.currentSessionId}function Fw(t){return t.newSessionDraft}function Lw(t){return t.worktreeMetadata}function $w(t){return t.availableWorktrees}function _w(t){return!t.startsWith("remotes/")}function Kw(t){return t.startsWith("remotes/")}function Ww(t){return t.replace(/^remotes\//,"")}function zw(t){return t.name}const ka=2e4,Vw=(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},Co=(t,e)=>vm(wm.getState().dictionary,t,e),Uw=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"},Hw=async(t,e,n)=>{const r=!!(n?.directory&&!Zg(e,n.directory));if(t.readFile)return(await t.readFile(e,{optional:!0,directory:n?.directory,allowOutsideWorkspace:r})).content??"";const o=new URLSearchParams({path:e,optional:"true"});n?.directory&&o.set("directory",n.directory),r&&o.set("allowOutsideWorkspace","true");const i=await Zs(`/api/fs/read?${o.toString()}`,{cache:"no-store",headers:n?.directory?{"x-opencode-directory":n.directory}:void 0});if(!i.ok){const d=await i.json().catch(()=>({error:i.statusText}));throw new Error(d.error||"Failed to read file")}return i.text()},Vf=async(t,e,n)=>{if(Yg(e)||Qg(e)||Xg(e))return{ok:!0};try{const r=await Hw(t,e,n);return Jg(r)?{ok:!1,reason:"binary"}:Vw(r,ka)>ka?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:Uw(r)}}},Uf=t=>{if(t==="too-large"){const e=ka.toLocaleString(tl());return Co("contextFileOpen.failure.tooLarge",{count:e})}return Co(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},Wc=8;let Ca=null;const Hf=t=>{Ca={x:t.clientX,y:t.clientY}},Gf=t=>{const e=Ca;return Ca=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=Wc&&Math.abs(t.clientY-e.y)<=Wc},Er=t=>Array.from(t.types).includes("Files"),Gw=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]:[]})},qw=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),Ss=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},yl=(t,e)=>{const n=Ss(e),r=Ss(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Yw=(t,e)=>{const n=yl(t,e);if(n!==".")return n;const r=Ss(t);return r.split("/").filter(Boolean).pop()??r},Na=t=>{const e=Ss(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},Qw=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),Xw=new Set(["node_modules"]),Jw=t=>Xw.has(t),Zw=t=>{const e=Ss(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},eS=8,yn=new Map,vl=t=>JSON.stringify([ss(),t]),tS=t=>{const e=vl(t),n=yn.get(e);return n?(n.touchedAt=Date.now(),yn.delete(e),yn.set(e,n),n):null},Hi=t=>{const e=vl(t),n=yn.get(e);if(n)return n.touchedAt=Date.now(),n;if(yn.size>=eS){const o=yn.keys().next().value;o!==void 0&&yn.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return yn.set(e,r),r},qf=(t,e)=>s.jsx(sl,{filePath:t,extension:e}),sS=t=>{const e=He.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 o=r[n];let i;return e[1]!==o?(i=s.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:o}}),e[1]=o,e[2]=i):i=e[2],i},nS=t=>{const e=He.c(95),{node:n,root:r,isExpanded:o,isActive:i,isBrowserClient:d,status:a,badge:c,isDropTarget:u,canUpload:f,permissions:p,downloadFile:m,onSelect:y,onToggle:x,onRevealPath:w,onOpenDialog:b,onSetDropTarget:g,onDropFiles:h,onPickFiles:v}=t,{t:S}=vt(),j=n.type==="directory";let N;e[0]!==j||e[1]!==n.path?(N=j?n.path:Na(n.path),e[0]=j,e[1]=n.path,e[2]=N):N=e[2];const C=N,{canRename:B,canCreateFile:W,canCreateFolder:F,canDelete:$,canReveal:K}=p,I=!j&&!!m,z=K&&!d,k=j&&f,M=B||W||F||k||$||I||z,[V,O]=l.useState(!1),[E,R]=l.useState(!1);let _;e[3]!==M?(_=ne=>{M&&(ne?.preventDefault(),R(!0))},e[3]=M,e[4]=_):_=e[4];const U=_;let me;e[5]!==j||e[6]!==n||e[7]!==y||e[8]!==x?(me=()=>{j?x(n.path):y(n)},e[5]=j,e[6]=n,e[7]=y,e[8]=x,e[9]=me):me=e[9];const ce=me;let oe;e[10]!==j||e[11]!==n||e[12]!==y?(oe=()=>{j||y(n,{pin:!0})},e[10]=j,e[11]=n,e[12]=y,e[13]=oe):oe=e[13];const ie=oe;let xe;e[14]===Symbol.for("react.memo_cache_sentinel")?(xe=ne=>{ne.stopPropagation(),R(!1),O(!0)},e[14]=xe):xe=e[14];const G=xe;let pe;e[15]!==W||e[16]!==F||e[17]!==$||e[18]!==B||e[19]!==z||e[20]!==k||e[21]!==m||e[22]!==d||e[23]!==j||e[24]!==n||e[25]!==b||e[26]!==v||e[27]!==w||e[28]!==S?(pe=ne=>{const{Item:X,Separator:fe}=ne;return s.jsxs(s.Fragment,{children:[B&&s.jsxs(X,{onClick:Fe=>{Fe.stopPropagation(),b("rename",n)},children:[s.jsx(T,{name:"edit",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.rename")]}),s.jsxs(X,{onClick:Fe=>{Fe.stopPropagation(),ur(n.path).then(Me=>{if(Me.ok){Be.success(S("sidebarFilesTree.toast.pathCopied"));return}Be.error(S("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(T,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.copyPath")]}),!j&&m&&s.jsxs(X,{onClick:Fe=>{Fe.stopPropagation(),m(n.path).catch(Me=>{console.error("Download failed:",Me),Be.error(S("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(T,{name:"download",className:"mr-2 h-4 w-4"})," ",S(d?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),z&&s.jsxs(X,{onClick:Fe=>{Fe.stopPropagation(),w(n.path)},children:[s.jsx(T,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",S(eb())]}),!j&&z&&lo()&&s.jsxs(X,{onClick:Fe=>{Fe.stopPropagation(),su(n.path).then(Me=>{Me||Be.error(S("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(T,{name:"external-link",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.openInDefaultApp")]}),j&&(W||F||k)&&s.jsxs(s.Fragment,{children:[s.jsx(fe,{}),W&&s.jsxs(X,{onClick:Fe=>{Fe.stopPropagation(),b("createFile",n)},children:[s.jsx(T,{name:"file-add",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.newFile")]}),F&&s.jsxs(X,{onClick:Fe=>{Fe.stopPropagation(),b("createFolder",n)},children:[s.jsx(T,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.newFolder")]}),k&&s.jsxs(X,{onClick:Fe=>{Fe.stopPropagation(),v(n.path)},children:[s.jsx(T,{name:"upload-2",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.uploadFiles")]})]}),$&&s.jsxs(s.Fragment,{children:[s.jsx(fe,{}),s.jsxs(X,{onClick:Fe=>{Fe.stopPropagation(),b("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(T,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.delete")]})]})]})},e[15]=W,e[16]=F,e[17]=$,e[18]=B,e[19]=z,e[20]=k,e[21]=m,e[22]=d,e[23]=j,e[24]=n,e[25]=b,e[26]=v,e[27]=w,e[28]=S,e[29]=pe):pe=e[29];const J=pe;let ge;e[30]!==n.path||e[31]!==r?(ge=ne=>{Hf(ne);const X=yl(r,n.path);!X||X==="."||(ne.dataTransfer.setData("application/x-openchamber-file-path",X),ne.dataTransfer.effectAllowed="copy")},e[30]=n.path,e[31]=r,e[32]=ge):ge=e[32];const de=ge;let Ae;e[33]!==ce?(Ae=ne=>{Gf(ne)&&ce()},e[33]=ce,e[34]=Ae):Ae=e[34];const he=Ae;let Re;e[35]!==f||e[36]!==g||e[37]!==C?(Re=ne=>{!f||!C||!Er(ne.dataTransfer)||(ne.preventDefault(),ne.stopPropagation(),ne.dataTransfer.dropEffect="copy",g(C))},e[35]=f,e[36]=g,e[37]=C,e[38]=Re):Re=e[38];const se=Re;let Ne;e[39]!==f||e[40]!==g||e[41]!==C?(Ne=ne=>{!f||!C||!Er(ne.dataTransfer)||ne.relatedTarget instanceof Node&&ne.currentTarget.contains(ne.relatedTarget)||(ne.stopPropagation(),g(null))},e[39]=f,e[40]=g,e[41]=C,e[42]=Ne):Ne=e[42];const be=Ne;let we;e[43]!==f||e[44]!==h||e[45]!==C?(we=ne=>{!f||!C||!Er(ne.dataTransfer)||(ne.preventDefault(),ne.stopPropagation(),h(C,ne.dataTransfer))},e[43]=f,e[44]=h,e[45]=C,e[46]=we):we=e[46];const ye=we;let Pe;e[47]===Symbol.for("react.memo_cache_sentinel")?(Pe={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[47]=Pe):Pe=e[47];let Oe;e[48]!==U||e[49]!==be||e[50]!==se||e[51]!==ye?(Oe=s.jsx("div",{className:"group relative flex items-center typography-meta",style:Pe,onContextMenu:U,onDragEnter:se,onDragOver:se,onDragLeave:be,onDrop:ye}),e[48]=U,e[49]=be,e[50]=se,e[51]=ye,e[52]=Oe):Oe=e[52];const $e=u?"bg-interactive-selection ring-2 ring-inset ring-primary":i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ze;e[53]!==$e?(ze=Se("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",$e),e[53]=$e,e[54]=ze):ze=e[54];let Ue;e[55]!==j||e[56]!==o||e[57]!==n.extension||e[58]!==n.path?(Ue=j?o?s.jsx(T,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(T,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):qf(n.path,n.extension),e[55]=j,e[56]=o,e[57]=n.extension,e[58]=n.path,e[59]=Ue):Ue=e[59];let q;e[60]!==n.name||e[61]!==n.path?(q=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[60]=n.name,e[61]=n.path,e[62]=q):q=e[62];let ue;e[63]!==j||e[64]!==a?(ue=!j&&a&&s.jsx(sS,{status:a}),e[63]=j,e[64]=a,e[65]=ue):ue=e[65];let A;e[66]!==c||e[67]!==j?(A=j&&c&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[c.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",c.modified]}),c.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",c.added]})]}),e[66]=c,e[67]=j,e[68]=A):A=e[68];let Q;e[69]!==U||e[70]!==ie||e[71]!==he||e[72]!==de||e[73]!==ce||e[74]!==ze||e[75]!==Ue||e[76]!==q||e[77]!==ue||e[78]!==A?(Q=s.jsxs("button",{type:"button",onClick:ce,onDoubleClick:ie,onContextMenu:U,draggable:!0,onDragStart:de,onDragEnd:he,className:ze,children:[Ue,q,ue,A]}),e[69]=U,e[70]=ie,e[71]=he,e[72]=de,e[73]=ce,e[74]=ze,e[75]=Ue,e[76]=q,e[77]=ue,e[78]=A,e[79]=Q):Q=e[79];let le;e[80]!==V||e[81]!==M||e[82]!==J||e[83]!==S?(le=M&&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(Qs,{open:V,onOpenChange:O,children:[s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(qs,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:G,title:S("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":S("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(T,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:S("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(Ys,{align:"end",side:"bottom",onCloseAutoFocus:()=>O(!1),children:J({Item:ts,Separator:Vs})})]})}),e[80]=V,e[81]=M,e[82]=J,e[83]=S,e[84]=le):le=e[84];let Ie;e[85]!==Oe||e[86]!==Q||e[87]!==le?(Ie=s.jsxs(Yu,{render:Oe,children:[Q,le]}),e[85]=Oe,e[86]=Q,e[87]=le,e[88]=Ie):Ie=e[88];let re;e[89]!==J?(re=s.jsx(qu,{className:"min-w-[180px]",children:J({Item:lr,Separator:da})}),e[89]=J,e[90]=re):re=e[90];let H;return e[91]!==E||e[92]!==Ie||e[93]!==re?(H=s.jsxs(Qu,{open:E,onOpenChange:R,children:[Ie,re]}),e[91]=E,e[92]=Ie,e[93]=re,e[94]=H):H=e[94],H},rS=(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&&t.onPickFiles===e.onPickFiles,oS=l.memo(nS,rS),iS=t=>{const e=He.c(6),{visible:n}=t,r=n===void 0?!0:n,o=mr(lS),i=fr();let d;e[0]!==i||e[1]!==o?(d=JSON.stringify([o,i]),e[0]=i,e[1]=o,e[2]=d):d=e[2];let a;return e[3]!==d||e[4]!==r?(a=s.jsx(aS,{visible:r},d),e[3]=d,e[4]=r,e[5]=a):a=e[5],a},aS=({visible:t})=>{const e=l.useRef(t);e.current=t;const{t:n}=vt(),{files:r,runtime:o}=jn(),i=Sm(o.platform),d=fr()??"",a=Ss(d.trim()),c=vl(a),u=jm(),f=km(),p=iu(D=>D.searchFiles),m=Ce(D=>D.openContextFile),y=el(t?d:null),[x,w]=l.useState(""),b=Xu(x,200),g=l.useRef(null),[h,v]=l.useState([]),[S,j]=l.useState(!1),[N,C]=l.useState(null),[B,W]=l.useState({}),[F,$]=l.useState({}),K=l.useRef(new Set),I=l.useRef(new Map),z=l.useMemo(()=>new Sy,[]);l.useEffect(()=>()=>z.clear(),[z]);const k=l.useRef(null);l.useEffect(()=>{if(C(null),!a){W({}),$({}),K.current=new Set;return}const D=tS(a);D?(W({...D.childrenByDir}),$({...D.loadErrorsByDir}),K.current=new Set(D.loadedDirs)):(W({}),$({}),K.current=new Set)},[a]),l.useEffect(()=>{if(!a)return;const D=Hi(a);D.childrenByDir=B},[a,B]),l.useEffect(()=>{if(!a)return;const D=Hi(a);D.loadErrorsByDir=F},[a,F]),l.useEffect(()=>{if(!a)return;const D=Hi(a);D.loadedDirs=new Set(K.current)},[a,B,F]),l.useEffect(()=>()=>{if(!a)return;const D=yn.get(c);D&&D.loadedDirs.size===0&&Object.keys(D.childrenByDir).length===0&&yn.delete(c)},[c,a]);const M=l.useMemo(()=>[],[]),V=l.useMemo(()=>[],[]),O=xn(D=>a?D.byRoot[a]?.expandedPaths??M:M),E=l.useMemo(()=>new Set(O),[O]),R=xn(D=>a?D.byRoot[a]?.selectedPath??null:null),_=xn(D=>D.setSelectedPath),U=l.useRef(null),me=l.useRef(null);l.useEffect(()=>{me.current=R},[R]);const ce=xn(D=>D.addOpenPath),oe=xn(D=>D.removeOpenPathsByPrefix),ie=xn(D=>D.toggleExpandedPath),xe=xn(D=>D.collapseAllExpandedPaths),G=Ce(D=>a?D.contextPanelByDirectory[a]?.tabs??V:V),pe=l.useMemo(()=>new Set(G.map(D=>D.mode==="file"?D.targetPath:null).filter(D=>typeof D=="string"&&D.length>0).map(D=>Ss(D))),[G]),[J,ge]=l.useState(null),[de,Ae]=l.useState(null),[he,Re]=l.useState(""),[se,Ne]=l.useState(!1),be=!!r.writeFile,we=!!r.createDirectory,ye=!!r.rename,Pe=!!r.delete,Oe=!!r.revealPath,$e=l.useMemo(()=>({canRename:ye,canCreateFile:be,canCreateFolder:we,canDelete:Pe,canReveal:Oe}),[ye,be,we,Pe,Oe]),ze=l.useCallback(D=>{r.revealPath&&r.revealPath(D).catch(()=>{Be.error(n("sidebarFilesTree.toast.revealFailed"))})},[r,n]),Ue=l.useCallback((D,je)=>{ge(D),Ae(je),Re(D==="rename"&&je.name||""),Ne(!1)},[]),q=l.useCallback((D,je)=>{const L=je.filter(te=>te&&typeof te.name=="string"&&te.name.length>0).filter(te=>u||!te.name.startsWith(".")).filter(te=>f||!Jw(te.name)).map(te=>{const ve=te.name,P=Ss(te.path||""),Z=P?Qw(P)?P:Ss(`${D}/${P}`):Ss(`${D}/${ve}`),Te=te.isDirectory?"directory":"file",Le=Te==="file"&&ve.includes(".")?ve.split(".").pop()?.toLowerCase():void 0;return{name:ve,path:Z,type:Te,extension:Le}});return qw(L)},[f,u]),ue=l.useCallback(async(D,je,L=!1)=>{if(!e.current||je?.())return;const te=Ss(D.trim());if(!te||!L&&K.current.has(te))return;const ve=ss();return z.run(te,async P=>{const Z=()=>!P()||ss()!==ve;try{const Te=r.listDirectory?(await r.listDirectory(te)).entries:await to.listLocalDirectory(te);if(Z())return;I.current.set(te,Te.length);const Le=q(te,Te);K.current=new Set(K.current),K.current.add(te),$(We=>{if(!We[te])return We;const Ge={...We};return delete Ge[te],Ge}),W(We=>We[te]&&jy(We[te],Le)?We:{...We,[te]:Le})}catch(Te){if(Z())return;const Le=Te instanceof Error?Te.message:String(Te??"");console.error("Failed to load sidebar directory:",Te),$(We=>({...We,[te]:Le}))}},L)},[z,r,q]),A=l.useCallback(async()=>{if(!a)return;k.current?.abort();const D=new AbortController;k.current=D,z.clear();try{const L=(xn.getState().byRoot[a]?.expandedPaths??[]).map(P=>Ss(P)).filter(P=>!!P&&P!==a&&P.startsWith(`${a}/`)),te=[a,...L];K.current=new Set(K.current);for(const P of te)K.current.delete(P);$(P=>{if(Object.keys(P).length===0)return P;const Z={...P};let Te=!1;for(const Le of te)Le in Z&&(delete Z[Le],Te=!0);return Te?Z:P});const ve=()=>D.signal.aborted;await ue(a,ve);for(let P=0;P<L.length&&!D.signal.aborted;P+=3){const Z=L.slice(P,P+3);await Promise.all(Z.map(Te=>ue(Te,ve)))}}catch(je){if(D.signal.aborted)return;console.error("Failed to refresh sidebar tree:",je)}finally{k.current===D&&(k.current=null)}},[z,ue,a]),Q=l.useCallback(async D=>{if(!D){await A();return}const je=Ss(D);K.current=new Set(K.current),K.current.delete(je),await ue(je,void 0,!0)},[ue,A]);l.useEffect(()=>{a&&(k.current?.abort(),K.current=new Set,z.clear(),$({}),W(D=>Object.keys(D).length===0?D:{}),ue(a))},[z,ue,a,u,f]),l.useEffect(()=>{if(!t||!a||O.length===0)return;const D=O.map(te=>Ss(te)).filter(te=>!!te&&te!==a&&te.startsWith(`${a}/`)&&!K.current.has(te)&&!z.has(te)).sort((te,ve)=>te.split("/").length-ve.split("/").length);if(D.length===0)return;let je=!1;const L=()=>je;return(async()=>{for(let te=0;te<D.length&&!je;te+=3){const ve=D.slice(te,te+3);await Promise.all(ve.map(P=>ue(P,L)))}})(),()=>{je=!0}},[z,O,ue,a,t]);const le=l.useRef(t);l.useEffect(()=>{const D=t&&!le.current;le.current=t,D&&A()},[A,t]);const Ie=l.useCallback(({directories:D})=>{if(!a)return;const je=new Set((xn.getState().byRoot[a]?.expandedPaths??[]).map(Le=>Ss(Le))),L=a==="/"?"/":`${a}/`,te=Le=>{for(let We=Le;We!==a;We=Na(We))if(!We.startsWith(L)||!je.has(We))return!1;return!0},ve=Le=>{for(let We=Le;We===a||We.startsWith(L);We=Na(We)){if(K.current.has(We))return We;if(We===a)break}return null},P=new Set,Z=new Set;for(const Le of D??K.current){const We=ve(Ss(Le));We&&(te(We)?P:Z).add(We)}Z.size>0&&(K.current=new Set([...K.current].filter(Le=>!Z.has(Le))));const Te=[...P].filter(Le=>(I.current.get(Le)??0)<=hh);(async()=>{for(let Le=0;Le<Te.length;Le+=3)await Promise.all(Te.slice(Le,Le+3).map(We=>ue(We,void 0,!0)))})()},[ue,a]);gh({root:a,active:t,whileInactive:"drop",onChanges:Ie}),l.useEffect(()=>{if(!t)return;if(!d){v([]),j(!1);return}const D=b.trim();if(!D){v([]),j(!1);return}let je=!1;return j(!0),p(d,D,150,{includeHidden:u,respectGitignore:!f,type:"file"}).then(L=>{if(je)return;const ve=L.filter(P=>f||!Zw(P.path)).map(P=>({name:P.name,path:Ss(P.path),type:"file",extension:P.extension,relativePath:P.relativePath}));v(ve)}).catch(()=>{je||v([])}).finally(()=>{je||j(!1)}),()=>{je=!0}},[d,b,p,u,f,t]);const re=l.useMemo(()=>{const D=new Map;if(!y?.files)return D;for(const je of y.files)je.index==="A"||je.working_dir==="?"?D.set(je.path,"git-added"):je.index==="D"?D.set(je.path,"git-deleted"):(je.index==="M"||je.working_dir==="M")&&D.set(je.path,"git-modified");return D},[y]),H=l.useMemo(()=>{const D=new Map;if(!y?.files||!a)return D;for(const je of y.files){const L=je.index==="M"||je.working_dir==="M",te=je.index==="A"||je.working_dir==="?";if(!L&&!te)continue;const ve=je.path.split("/");if(ve.length<=1)continue;let P=a;for(let Z=0;Z<ve.length-1;Z++){P=`${P}/${ve[Z]}`;let Te=D.get(P);Te||(Te={modified:0,added:0},D.set(P,Te)),L&&Te.modified++,te&&Te.added++}}return D},[y,a]),ne=l.useCallback(D=>{if(pe.has(D))return"open";if(re.size===0)return null;const je=D.startsWith(a+"/")?D.slice(a.length+1):D;return re.get(je)??null},[pe,re,a]),X=l.useCallback(D=>{if(H.size===0)return null;const je=H.get(D);return je&&je.modified+je.added>0?je:null},[H]),fe=l.useCallback(async(D,je)=>{if(!a)return;const L=await Vf(r,D.path,{directory:a});if(!L.ok){Be.error(Uf(L.reason));return}_(a,D.path),ce(a,D.path),m(a,D.path,{preview:!je?.pin&&!Ce.getState().isMobile})},[ce,r,m,a,_]),Fe=l.useCallback(async D=>{const je=Ss(D);a&&(ie(a,je),K.current.has(je)||await ue(je))},[ue,a,ie]),{canUpload:Me,uploadingDirectory:tt,uploadFiles:nt,pickFiles:Qe,uploadElements:_e}=bh({root:a,refreshDirectory:Q}),wt=tt!==null,ct=tt??N,gt=l.useCallback((D,je)=>{const L=Gw(je);L.length!==0&&(C(null),nt(D,L))},[nt]),Kt=l.useCallback(D=>{!Me||wt||!a||!Er(D.dataTransfer)||(D.preventDefault(),D.dataTransfer.dropEffect="copy",C(a))},[Me,wt,a]),kt=l.useCallback(D=>{Er(D.dataTransfer)&&(D.relatedTarget instanceof Node&&D.currentTarget.contains(D.relatedTarget)||C(null))},[]),Ht=l.useCallback(D=>{!Me||wt||!a||!Er(D.dataTransfer)||(D.preventDefault(),gt(a,D.dataTransfer))},[Me,gt,wt,a]),At=l.useCallback(async D=>{if(D?.preventDefault(),!de||!J)return;Ne(!0);const je=()=>Ne(!1),L=()=>ge(null);if(J==="createFile"){if(!he.trim()){Be.error(n("sidebarFilesTree.toast.filenameRequired")),je();return}if(!r.writeFile){Be.error(n("sidebarFilesTree.toast.writeNotSupported")),je();return}const te=de.path,ve=te?`${te}/`:"",P=Ss(`${ve}${he.trim()}`);await r.writeFile(P,"").then(async Z=>{Z.success&&(Be.success(n("sidebarFilesTree.toast.fileCreated")),await Q(te)),L()}).catch(()=>Be.error(n("sidebarFilesTree.toast.operationFailed"))).finally(je);return}if(J==="createFolder"){if(!he.trim()){Be.error(n("sidebarFilesTree.toast.folderNameRequired")),je();return}const te=de.path,ve=te?`${te}/`:"",P=Ss(`${ve}${he.trim()}`);await r.createDirectory(P).then(async Z=>{Z.success&&(Be.success(n("sidebarFilesTree.toast.folderCreated")),await Q(te)),L()}).catch(()=>Be.error(n("sidebarFilesTree.toast.operationFailed"))).finally(je);return}if(J==="rename"){if(!he.trim()){Be.error(n("sidebarFilesTree.toast.nameRequired")),je();return}if(!r.rename){Be.error(n("sidebarFilesTree.toast.renameNotSupported")),je();return}const te=de.path,ve=te.split("/").slice(0,-1).join("/"),P=ve?`${ve}/`:"",Z=Ss(`${P}${he.trim()}`);await r.rename(te,Z).then(async Te=>{Te.success&&(Be.success(n("sidebarFilesTree.toast.renamedSuccessfully")),await Q(ve),a&&oe(a,te),(R===te||R&&R.startsWith(`${te}/`))&&_(a,null)),L()}).catch(()=>Be.error(n("sidebarFilesTree.toast.operationFailed"))).finally(je);return}if(J==="delete"){if(!r.delete){Be.error(n("sidebarFilesTree.toast.deleteNotSupported")),je();return}const te=de.path,ve=te.split("/").slice(0,-1).join("/");await r.delete(te).then(async P=>{P.success&&(Be.success(n("sidebarFilesTree.toast.deletedSuccessfully")),await Q(ve),a&&oe(a,te),(R===te||R&&R.startsWith(te+"/"))&&_(a,null)),L()}).catch(()=>Be.error(n("sidebarFilesTree.toast.operationFailed"))).finally(je);return}je()},[J,de,he,r,Q,oe,a,R,_,n]);function Et(D,je){const L=B[D]??[];return L.map((te,ve)=>{const P=te.type==="directory",Z=P&&E.has(te.path),Te=R===te.path,Le=ve===L.length-1;return s.jsxs("li",{className:"relative","data-file-tree-path":P?void 0:te.path,children:[je>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),Le&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(oS,{node:te,root:a,isExpanded:Z,isActive:Te,isBrowserClient:i,status:P?void 0:ne(te.path),badge:P?X(te.path):void 0,isDropTarget:P&&ct===te.path,canUpload:Me&&!wt,permissions:$e,downloadFile:r.downloadFile,onSelect:fe,onToggle:Fe,onRevealPath:ze,onOpenDialog:Ue,onSetDropTarget:C,onDropFiles:gt,onPickFiles:Qe}),P&&Z&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[F[te.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:F[te.path],children:F[te.path]}),s.jsxs(ut,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Q(te.path)},children:[s.jsx(T,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):null,Et(te.path,je+1)]})]},te.path)})}l.useEffect(()=>{const D=me.current,je=U.current;if(!D||!je)return;const L=je.querySelector(`[data-file-tree-path="${CSS.escape(D)}"]`);!L||L.offsetParent===null||(me.current=null,L.scrollIntoView({block:"nearest"}))});const Bt=!!(a&&B[a]),Rt=a?F[a]:null,Wt=ct?Yw(a,ct):"";return s.jsxs("section",{ref:U,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:[be&&s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>Ue("createFile",{path:d,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFileTitle"),"aria-label":n("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(T,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFileTitle")})]}),we&&s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>Ue("createFolder",{path:d,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFolderTitle"),"aria-label":n("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(T,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFolderTitle")})]}),Me&&s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>Qe(a),disabled:!a||wt,className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":n("sidebarFilesTree.actions.uploadFilesTitle"),children:s.jsx(T,{name:"upload-2",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.uploadFilesTitle")})]}),s.jsx(ky,{className:"h-8 w-8"}),s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>{A()},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.refreshTitle"),"aria-label":n("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(T,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>{a&&xe(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":n("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(T,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(T,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(Xr,{ref:g,value:x,onChange:D=>w(D.target.value),placeholder:n("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),x.trim().length>0?s.jsx("button",{type:"button","aria-label":n("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:()=>{w(""),g.current?.focus()},children:s.jsx(T,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(Mn,{outerClassName:"h-full min-h-0",className:Se("p-2",ct===a&&"bg-interactive-selection/10"),onDragEnter:Kt,onDragOver:Kt,onDragLeave:kt,onDrop:Ht,children:s.jsx("ul",{className:"flex flex-col",children:S?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(T,{name:"loader-4",className:"h-4 w-4 animate-spin"}),n("sidebarFilesTree.state.searching")]}):h.length>0?h.map(D=>{const je=R===D.path;return s.jsx("li",{"data-file-tree-path":D.path,children:s.jsxs("button",{type:"button",onClick:()=>fe(D),onDoubleClick:()=>fe(D,{pin:!0}),draggable:!0,onDragStart:L=>{Hf(L);const te=D.relativePath||yl(a??"",D.path);!te||te==="."||(L.dataTransfer.setData("application/x-openchamber-file-path",te),L.dataTransfer.effectAllowed="copy")},onDragEnd:L=>{Gf(L)&&fe(D)},className:Se("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",je?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:D.path,children:[qf(D.path,D.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:`${D.relativePath??D.path}`})]})},D.path)}):Rt?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:Rt}),s.jsxs(ut,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{A()},children:[s.jsx(T,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):Bt&&a?Et(a,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:n("sidebarFilesTree.state.loading")})})}),ct?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(T,{name:wt?"loader-4":"folder-received",className:Se("size-4 flex-shrink-0",wt&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Wt,children:n(wt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Wt})})]}):null]}),_e,s.jsx(en,{open:!!J,onOpenChange:D=>!D&&ge(null),children:s.jsxs(tn,{children:[s.jsxs(pn,{children:[s.jsxs(mn,{children:[J==="createFile"&&n("sidebarFilesTree.dialog.createFile.title"),J==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.title"),J==="rename"&&n("sidebarFilesTree.dialog.rename.title"),J==="delete"&&n("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(hn,{children:[J==="createFile"&&n("sidebarFilesTree.dialog.createFile.description",{path:de?.path??n("sidebarFilesTree.dialog.rootFallback")}),J==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.description",{path:de?.path??n("sidebarFilesTree.dialog.rootFallback")}),J==="rename"&&n("sidebarFilesTree.dialog.rename.description",{name:de?.name??""}),J==="delete"&&n("sidebarFilesTree.dialog.delete.description",{name:de?.name??""})]})]}),J!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Xr,{value:he,onChange:D=>Re(D.target.value),placeholder:n(J==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:D=>{D.key==="Enter"&&At()},autoFocus:!0})}),s.jsxs(pr,{children:[s.jsx(ut,{variant:"outline",onClick:()=>ge(null),disabled:se,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(ut,{variant:J==="delete"?"destructive":"default",onClick:()=>{At()},disabled:se||J!=="delete"&&!he.trim(),children:se?s.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):n(J==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function lS(t){return t.runtimeKey}const zc=60,cS=t=>{try{return new URL(t).origin}catch{return""}},Gi=new Set,Yf=bl()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const o=cS(n);!o||!r||e().byOrigin[o]||Gi.has(o)||(Gi.add(o),zo("desktop_browser_fetch_favicon",{url:r}).then(i=>{const d=typeof i?.dataUrl=="string"?i.dataUrl:"";d&&t(a=>{const c={...a.byOrigin,[o]:d},u=Object.keys(c);if(u.length<=zc)return{byOrigin:c};for(const f of u.slice(0,u.length-zc))delete c[f];return{byOrigin:c}})}).catch(()=>{}).finally(()=>{Gi.delete(o)}))}})),wl=t=>t,Aa=t=>{const e=wl(t).type;return typeof e=="string"?e:""},dS=t=>{const e=wl(t).tool;return typeof e=="string"?e:""},uS=t=>{const e=wl(t).text;return typeof e=="string"?e:""},fS=t=>{const e=Aa(t);return e==="tool"?dS(t).trim().toLowerCase()||"tool":e||"unknown"},pS=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=fS(n);e.includes(r)||e.push(r)}return e.join(" + ")},mS=t=>t.replace(/\s+/g," ").trim(),hS=t=>{for(const n of t)if(Aa(n)==="text"){const r=mS(uS(n));if(r.length===0)continue;return r}const e=t.filter(n=>Aa(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},gS=(t,e,n)=>`${n(t)} / ${n(e)}`,bS=t=>{if(t==="12h")return!0;if(t==="24h")return!1},xS=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=bS(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}})},Pa={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Uo={user:0,assistant:0,tool:0,other:0},$n=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Vc=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof n=="number")return{...Pa,total:$n(n)};if(!n||typeof n!="object")return Pa;const r=n,o=$n(r.input),i=$n(r.output),d=$n(r.reasoning),a=$n(r.cache?.read),c=$n(r.cache?.write),u=$n(r.total);return{input:o,output:i,reasoning:d,cacheRead:a,cacheWrite:c,total:u>0?u:o+i+d+a+c}},yS=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Js=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+Js(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+Js(n),0):0,vS=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Uo,assistant:Js(n.text)+Js(n.content)};const o=yS(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Js(n.input)+Js(n.output)+Js(n.error)+Js(n.call?.input)+Js(n.call?.output)+Js(n.call?.error)+Js(n.raw)+Math.round(Js(n.metadata)*.25)+Math.round(Js(n.state)*.1),other:0}:e==="user"?{user:o.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:o.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:o.length}},Uc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),wS=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",SS=(t,e)=>{if(t.length===0)return{...Uo};const n=t.reduce((r,o)=>{const i=wS(o);let d={...Uo};for(const a of o.parts)d=Uc(d,vS(a,i));return Uc(r,d)},{...Uo});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)}},ir=t=>t.toLocaleString(tl()),jS=(t,e)=>!t||!Number.isFinite(t)?"-":Vu(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),kS=(t,e,n)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===n);return{providerName:r?.name||e||"-",modelName:o?.name||n||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},CS=()=>{const t=He.c(209),{t:e}=vt(),n=Ce(NS);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[o,i]=l.useState(r),[d,a]=l.useState(null),c=l.useRef(null),u=Je(AS),f=Je(PS),p=Ju(f??void 0),m=tb(u??"",f??void 0),y=js(IS);let x;t[1]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i(DS),a(null)},t[1]=x):x=t[1];let w;t[2]!==f||t[3]!==u?(w=[f,u],t[2]=f,t[3]=u,t[4]=w):w=t[4],l.useEffect(x,w);let b,g;t[5]===Symbol.for("react.memo_cache_sentinel")?(b=()=>()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},g=[],t[5]=b,t[6]=g):(b=t[5],g=t[6]),l.useEffect(b,g);let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=async(it,Ve)=>{(await ur(Ve)).ok?(a(it),c.current!==null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{a(St=>St===it?null:St),c.current=null},2e3)):a(null)},t[7]=h):h=t[7];const v=h;let S;t[8]!==u||t[9]!==p?(S=u?p.find(it=>it.id===u)??null:null,t[8]=u,t[9]=p,t[10]=S):S=t[10];const j=S;let N,C,B,W,F,$,K;if(t[11]!==m){N=m.filter(ES),K=m.filter(RS);const it=sb(m.map(MS));B=it?m[it.index]??null:null,W=it?.state==="compacted";let Ve;t[19]!==B?($=B?Vc(B):Pa,Ve=nb({input:$.input,cache:{read:$.cacheRead,write:$.cacheWrite}}),t[19]=B,t[20]=Ve,t[21]=$):(Ve=t[20],$=t[21]),C=Ve,F=N.reduce(TS,0),t[11]=m,t[12]=N,t[13]=C,t[14]=B,t[15]=W,t[16]=F,t[17]=$,t[18]=K}else N=t[12],C=t[13],B=t[14],W=t[15],F=t[16],$=t[17],K=t[18];const I=F,z=B?.info??null,k=y,M=z?.providerID||"",V=z?.modelID||"";let O;t[22]!==V||t[23]!==k||t[24]!==M?(O=kS(k,M,V),t[22]=V,t[23]=k,t[24]=M,t[25]=O):O=t[25];const E=O,R=E.contextLimit,_=W?null:R&&R>0?Math.min(999,$.total/R*100):0;let U;if(t[26]!==m){const it=[...m].reverse().find(OS),Ve=it?.info.role==="system"?it.info.text:"";U=SS(m,Ve),t[26]=m,t[27]=U}else U=t[27];const me=U,ce=me.user,oe=me.assistant,ie=me.tool,xe=Math.max(0,$.input-ce-oe-ie),G=ce+oe+ie+xe,pe=m[0]?.info?.time?.created,J=m.length>0?m[m.length-1]?.info?.time?.created:null;let ge;t[28]!==j?.title||t[29]!==e?(ge=j?.title||e("contextSidebar.session.untitled"),t[28]=j?.title,t[29]=e,t[30]=ge):ge=t[30];const de=j?.time?.created??pe??null,Ae=J??j?.time?.created??null;let he;t[31]!==oe||t[32]!==xe||t[33]!==ie||t[34]!==ce?(he={user:ce,assistant:oe,tool:ie,other:xe},t[31]=oe,t[32]=xe,t[33]=ie,t[34]=ce,t[35]=he):he=t[35];let Re;t[36]!==N.length||t[37]!==G||t[38]!==C||t[39]!==R||t[40]!==E||t[41]!==m.length||t[42]!==ge||t[43]!==de||t[44]!==Ae||t[45]!==he||t[46]!==$||t[47]!==I||t[48]!==_||t[49]!==K.length?(Re={sessionTitle:ge,messagesCount:m.length,userMessagesCount:K.length,assistantMessagesCount:N.length,createdAt:de,lastActivityAt:Ae,providerModel:E,tokenBreakdown:$,usagePercent:_,cacheHitRate:C,totalAssistantCost:I,contextLimit:R,breakdown:he,breakdownTotal:G},t[36]=N.length,t[37]=G,t[38]=C,t[39]=R,t[40]=E,t[41]=m.length,t[42]=ge,t[43]=de,t[44]=Ae,t[45]=he,t[46]=$,t[47]=I,t[48]=_,t[49]=K.length,t[50]=Re):Re=t[50];const se=Re;if(!u){let it;t[51]!==e?(it=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=it):it=t[52];let Ve;return t[53]!==it?(Ve=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:it}),t[53]=it,t[54]=Ve):Ve=t[54],Ve}let Ne;t[55]!==e?(Ne=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=Ne):Ne=t[56];let be;t[57]!==Ne||t[58]!==se.breakdown.user?(be={key:"user",label:Ne,value:se.breakdown.user,color:"var(--status-success)"},t[57]=Ne,t[58]=se.breakdown.user,t[59]=be):be=t[59];let we;t[60]!==e?(we=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=we):we=t[61];let ye;t[62]!==we||t[63]!==se.breakdown.assistant?(ye={key:"assistant",label:we,value:se.breakdown.assistant,color:"var(--primary-base)"},t[62]=we,t[63]=se.breakdown.assistant,t[64]=ye):ye=t[64];let Pe;t[65]!==e?(Pe=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=Pe):Pe=t[66];let Oe;t[67]!==Pe||t[68]!==se.breakdown.tool?(Oe={key:"tool",label:Pe,value:se.breakdown.tool,color:"var(--status-warning)"},t[67]=Pe,t[68]=se.breakdown.tool,t[69]=Oe):Oe=t[69];let $e;t[70]!==e?($e=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=$e):$e=t[71];let ze;t[72]!==$e||t[73]!==se.breakdown.other?(ze={key:"other",label:$e,value:se.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=$e,t[73]=se.breakdown.other,t[74]=ze):ze=t[74];let Ue;t[75]!==be||t[76]!==ye||t[77]!==Oe||t[78]!==ze?(Ue=[be,ye,Oe,ze],t[75]=be,t[76]=ye,t[77]=Oe,t[78]=ze,t[79]=Ue):Ue=t[79];const q=Ue;let ue;t[80]!==se.sessionTitle?(ue=s.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate text-left",children:se.sessionTitle}),t[80]=se.sessionTitle,t[81]=ue):ue=t[81];let A;t[82]!==se.providerModel.modelName||t[83]!==se.providerModel.providerName?(A=s.jsxs("span",{children:[se.providerModel.providerName," / ",se.providerModel.modelName]}),t[82]=se.providerModel.modelName,t[83]=se.providerModel.providerName,t[84]=A):A=t[84];let Q;t[85]!==n||t[86]!==se.createdAt?(Q=se.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:jS(se.createdAt,n)})]}),t[85]=n,t[86]=se.createdAt,t[87]=Q):Q=t[87];let le;t[88]!==A||t[89]!==Q?(le=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:[A,Q]}),t[88]=A,t[89]=Q,t[90]=le):le=t[90];let Ie;t[91]!==ue||t[92]!==le?(Ie=s.jsxs("div",{className:"mb-6",children:[ue,le]}),t[91]=ue,t[92]=le,t[93]=Ie):Ie=t[93];let re;t[94]!==e?(re=e("contextSidebar.section.context"),t[94]=e,t[95]=re):re=t[95];let H;t[96]!==re?(H=s.jsx("span",{className:"typography-micro text-muted-foreground",children:re}),t[96]=re,t[97]=H):H=t[97];let ne;t[98]!==se.tokenBreakdown.total||t[99]!==se.usagePercent?(ne=se.usagePercent===null?"—":ir(se.tokenBreakdown.total),t[98]=se.tokenBreakdown.total,t[99]=se.usagePercent,t[100]=ne):ne=t[100];let X;t[101]!==se.contextLimit?(X=se.contextLimit?` / ${ir(se.contextLimit)}`:"",t[101]=se.contextLimit,t[102]=X):X=t[102];let fe;t[103]!==ne||t[104]!==X?(fe=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[ne,X]}),t[103]=ne,t[104]=X,t[105]=fe):fe=t[105];let Fe;t[106]!==H||t[107]!==fe?(Fe=s.jsxs("div",{className:"flex items-baseline justify-between",children:[H,fe]}),t[106]=H,t[107]=fe,t[108]=Fe):Fe=t[108];let Me;t[109]!==se.usagePercent?(Me=se.usagePercent!==null&&se.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,se.usagePercent)}%`,backgroundColor:se.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[109]=se.usagePercent,t[110]=Me):Me=t[110];let tt;t[111]!==Me?(tt=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Me}),t[111]=Me,t[112]=tt):tt=t[112];let nt;t[113]!==e||t[114]!==se.usagePercent?(nt=se.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:se.usagePercent.toFixed(1)}),t[113]=e,t[114]=se.usagePercent,t[115]=nt):nt=t[115];let Qe;t[116]!==nt?(Qe=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:nt}),t[116]=nt,t[117]=Qe):Qe=t[117];let _e;t[118]!==Fe||t[119]!==tt||t[120]!==Qe?(_e=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Fe,tt,Qe]}),t[118]=Fe,t[119]=tt,t[120]=Qe,t[121]=_e):_e=t[121];let wt;t[122]!==e?(wt=e("contextSidebar.stats.messages"),t[122]=e,t[123]=wt):wt=t[123];let ct;t[124]!==se.messagesCount?(ct=ir(se.messagesCount),t[124]=se.messagesCount,t[125]=ct):ct=t[125];let gt;t[126]!==wt||t[127]!==ct?(gt={label:wt,value:ct},t[126]=wt,t[127]=ct,t[128]=gt):gt=t[128];let Kt;t[129]!==e?(Kt=e("contextSidebar.stats.user"),t[129]=e,t[130]=Kt):Kt=t[130];let kt;t[131]!==se.userMessagesCount?(kt=ir(se.userMessagesCount),t[131]=se.userMessagesCount,t[132]=kt):kt=t[132];let Ht;t[133]!==Kt||t[134]!==kt?(Ht={label:Kt,value:kt},t[133]=Kt,t[134]=kt,t[135]=Ht):Ht=t[135];let At;t[136]!==e?(At=e("contextSidebar.stats.assistant"),t[136]=e,t[137]=At):At=t[137];let Et;t[138]!==se.assistantMessagesCount?(Et=ir(se.assistantMessagesCount),t[138]=se.assistantMessagesCount,t[139]=Et):Et=t[139];let Bt;t[140]!==At||t[141]!==Et?(Bt={label:At,value:Et},t[140]=At,t[141]=Et,t[142]=Bt):Bt=t[142];let Rt;t[143]!==e?(Rt=e("contextSidebar.stats.cost"),t[143]=e,t[144]=Rt):Rt=t[144];let Wt;t[145]!==se.totalAssistantCost?(Wt=xy(se.totalAssistantCost),t[145]=se.totalAssistantCost,t[146]=Wt):Wt=t[146];let D;t[147]!==Rt||t[148]!==Wt?(D={label:Rt,value:Wt},t[147]=Rt,t[148]=Wt,t[149]=D):D=t[149];let je;t[150]!==gt||t[151]!==Ht||t[152]!==Bt||t[153]!==D?(je=[gt,Ht,Bt,D],t[150]=gt,t[151]=Ht,t[152]=Bt,t[153]=D,t[154]=je):je=t[154];const L=je;let te;t[155]!==L?(te=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:L.map(BS)}),t[155]=L,t[156]=te):te=t[156];let ve;t[157]!==e?(ve=e("contextSidebar.section.lastAssistantMessage"),t[157]=e,t[158]=ve):ve=t[158];let P;t[159]!==ve?(P=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:ve}),t[159]=ve,t[160]=P):P=t[160];let Z;t[161]!==e||t[162]!==se.cacheHitRate.hasInput||t[163]!==se.cacheHitRate.percent||t[164]!==se.tokenBreakdown.cacheRead||t[165]!==se.tokenBreakdown.cacheWrite||t[166]!==se.tokenBreakdown.input||t[167]!==se.tokenBreakdown.output||t[168]!==se.tokenBreakdown.reasoning?(Z=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:se.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:se.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:se.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:se.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:se.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:se.cacheHitRate.hasInput?se.cacheHitRate.percent:null,format:"percent"}].map(FS)}),t[161]=e,t[162]=se.cacheHitRate.hasInput,t[163]=se.cacheHitRate.percent,t[164]=se.tokenBreakdown.cacheRead,t[165]=se.tokenBreakdown.cacheWrite,t[166]=se.tokenBreakdown.input,t[167]=se.tokenBreakdown.output,t[168]=se.tokenBreakdown.reasoning,t[169]=Z):Z=t[169];let Te;t[170]!==P||t[171]!==Z?(Te=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[P,Z]}),t[170]=P,t[171]=Z,t[172]=Te):Te=t[172];let Le;t[173]!==q||t[174]!==se.breakdownTotal?(Le=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:q.map(it=>it.value<=0||se.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${it.value/se.breakdownTotal*100}%`,backgroundColor:it.color}},it.key))}),t[173]=q,t[174]=se.breakdownTotal,t[175]=Le):Le=t[175];let We;t[176]!==q||t[177]!==se.breakdownTotal?(We=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:q.map(it=>{const Ve=se.breakdownTotal>0?it.value/se.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:it.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[it.label," ",s.jsxs("span",{className:"tabular-nums",children:[Ve.toFixed(0),"%"]})]})]},it.key)})}),t[176]=q,t[177]=se.breakdownTotal,t[178]=We):We=t[178];let Ge;t[179]!==Le||t[180]!==We?(Ge=s.jsxs("div",{className:"mb-6",children:[Le,We]}),t[179]=Le,t[180]=We,t[181]=Ge):Ge=t[181];let zt;t[182]!==e?(zt=e("contextSidebar.section.rawMessages"),t[182]=e,t[183]=zt):zt=t[183];let Ye;t[184]!==zt?(Ye=s.jsx("div",{className:"typography-micro text-muted-foreground",children:zt}),t[184]=zt,t[185]=Ye):Ye=t[185];let Ee;if(t[186]!==d||t[187]!==o||t[188]!==m||t[189]!==e||t[190]!==n){let it;t[192]!==d||t[193]!==o||t[194]!==e||t[195]!==n?(it=Ve=>{const Qt=Ve.info.role,St=Qt==="assistant",Yt=Qt==="user",ft=o[Ve.info.id]===!0,Vt=d===Ve.info.id,et=Ve.info.time?.created??null,It=pS(Ve.parts),ke=St?Vc({info:Ve.info,parts:Ve.parts}):null,qe=Yt?hS(Ve.parts):"",Ze=xS(et,n),Mt=It||"—",$t=ke?gS(ke.input,ke.output,ir):"",Gt=Qt||"unknown",Ot=It?`${Gt}: ${It}`:Gt,xt=ft?JSON.stringify({info:Ve.info,parts:Ve.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":ft,onClick:()=>{i(Tt=>({...Tt,[Ve.info.id]:Tt[Ve.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:St?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Yt?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",qe]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:St?Mt:Ot}),St&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:$t})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Ze})]})}),ft&&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:Tt=>{Tt.stopPropagation(),v(Ve.info.id,xt)},"aria-label":e(Vt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(Vt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:Vt?s.jsx(T,{name:"check",className:"size-3.5"}):s.jsx(T,{name:"file-copy",className:"size-3.5"})})}),s.jsx(rb,{language:"json",code:xt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Ve.info.id)},t[192]=d,t[193]=o,t[194]=e,t[195]=n,t[196]=it):it=t[196],Ee=[...m].reverse().map(it),t[186]=d,t[187]=o,t[188]=m,t[189]=e,t[190]=n,t[191]=Ee}else Ee=t[191];let Pt;t[197]!==Ee?(Pt=s.jsx("div",{className:"mt-2.5 space-y-1",children:Ee}),t[197]=Ee,t[198]=Pt):Pt=t[198];let Lt;t[199]!==Ye||t[200]!==Pt?(Lt=s.jsxs("div",{children:[Ye,Pt]}),t[199]=Ye,t[200]=Pt,t[201]=Lt):Lt=t[201];let os;return t[202]!==Ie||t[203]!==_e||t[204]!==te||t[205]!==Te||t[206]!==Ge||t[207]!==Lt?(os=s.jsx(Mn,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[Ie,_e,te,Te,Ge,Lt]})}),t[202]=Ie,t[203]=_e,t[204]=te,t[205]=Te,t[206]=Ge,t[207]=Lt,t[208]=os):os=t[208],os};function NS(t){return t.timeFormatPreference}function AS(t){return t.currentSessionId}function PS(t){return t.currentSessionDirectory}function IS(t){return t.providers}function DS(t){return Object.keys(t).length>0?{}:t}function ES(t){return t.info.role==="assistant"}function RS(t){return t.info.role==="user"}function MS(t){return t.info}function TS(t,e){const n=$n(e.info.cost);return t+n}function OS(t){return t.info.role==="system"}function BS(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 FS(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)}%`:ir(t.value):"—"})]},t.label)}const LS=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"},$S=async t=>{try{const e=await Zs("/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(LS)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},_S=async t=>{try{const e=await Zs("/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}},KS=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}},WS=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const o=KS(r);o!==null&&!n.has(o)&&n.set(o,r)}return e?e.map(r=>{const o=n.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...n.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},Ia="__openchamberBrowserAnnotationActive",zS=`(() => {
|
|
12
|
-
try {
|
|
13
|
-
var host = document.querySelector('[data-openchamber-annotation]');
|
|
14
|
-
if (host && host.parentNode) host.parentNode.removeChild(host);
|
|
15
|
-
} catch (error) { /* page navigated away */ }
|
|
16
|
-
try {
|
|
17
|
-
var cursor = document.getElementById('openchamber-annotation-cursor');
|
|
18
|
-
if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
|
|
19
|
-
} catch (error) { /* page navigated away */ }
|
|
20
|
-
try { delete window['${Ia}']; } catch (error) { /* non-configurable */ }
|
|
21
|
-
})();`,VS=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
|
|
22
|
-
var CONFIG = ${n};
|
|
23
|
-
var THEME = CONFIG.theme;
|
|
24
|
-
var LABELS = CONFIG.labels;
|
|
25
|
-
var OVERLAY_ATTR = 'data-openchamber-annotation';
|
|
26
|
-
var Z_OVERLAY = 2147483646;
|
|
27
|
-
var MAX_TEXT = 400;
|
|
28
|
-
var MIN_RECT = 3;
|
|
29
|
-
var EDITOR_GAP = 10;
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
|
|
33
|
-
if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
|
|
34
|
-
} catch (error) { /* nothing to clean */ }
|
|
35
|
-
|
|
36
|
-
window['${Ia}'] = true;
|
|
37
|
-
|
|
38
|
-
var counter = 0;
|
|
39
|
-
var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
|
|
40
|
-
|
|
41
|
-
var selected = null;
|
|
42
|
-
var regions = [];
|
|
43
|
-
var strokes = [];
|
|
44
|
-
var tool = 'select';
|
|
45
|
-
var settled = false;
|
|
46
|
-
|
|
47
|
-
// ---------------------------------------------------------------- geometry
|
|
48
|
-
|
|
49
|
-
var rectFrom = function (domRect) {
|
|
50
|
-
return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
|
|
51
|
-
};
|
|
52
|
-
var normalizeRect = function (ax, ay, bx, by) {
|
|
53
|
-
return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
|
|
54
|
-
};
|
|
55
|
-
var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
|
|
56
|
-
|
|
57
|
-
// ------------------------------------------------------------- description
|
|
58
|
-
|
|
59
|
-
var isOverlayNode = function (element) {
|
|
60
|
-
var node = element;
|
|
61
|
-
while (node) {
|
|
62
|
-
if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
|
|
63
|
-
node = node.parentNode || (node.host || null);
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var elementFromPoint = function (x, y) {
|
|
69
|
-
var found = document.elementFromPoint(x, y);
|
|
70
|
-
if (!found || isOverlayNode(found)) return null;
|
|
71
|
-
return found;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
var selectorPart = function (element) {
|
|
75
|
-
var part = element.tagName.toLowerCase();
|
|
76
|
-
if (element.id) return part + '#' + element.id;
|
|
77
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
78
|
-
if (className) {
|
|
79
|
-
var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
|
|
80
|
-
if (first) part += '.' + first;
|
|
81
|
-
}
|
|
82
|
-
return part;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
var buildSelector = function (element) {
|
|
86
|
-
if (element.id) return '#' + element.id;
|
|
87
|
-
var parts = [];
|
|
88
|
-
var node = element;
|
|
89
|
-
var depth = 0;
|
|
90
|
-
while (node && node.nodeType === 1 && depth < 5) {
|
|
91
|
-
var part = selectorPart(node);
|
|
92
|
-
var parent = node.parentElement;
|
|
93
|
-
if (parent) {
|
|
94
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
95
|
-
return child.tagName === node.tagName;
|
|
96
|
-
});
|
|
97
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
98
|
-
}
|
|
99
|
-
parts.unshift(part);
|
|
100
|
-
if (node.id) break;
|
|
101
|
-
node = parent;
|
|
102
|
-
depth += 1;
|
|
103
|
-
}
|
|
104
|
-
return parts.join(' > ');
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
|
|
108
|
-
var STYLE_PROPS = [
|
|
109
|
-
'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
|
|
110
|
-
'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
|
|
111
|
-
'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
var describe = function (element) {
|
|
115
|
-
var computed = window.getComputedStyle(element);
|
|
116
|
-
var attributes = {};
|
|
117
|
-
for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
|
|
118
|
-
var name = INTERESTING_ATTRS[i];
|
|
119
|
-
var value = element.getAttribute(name);
|
|
120
|
-
if (value) attributes[name] = String(value).slice(0, 200);
|
|
121
|
-
}
|
|
122
|
-
var computedStyle = {};
|
|
123
|
-
for (var j = 0; j < STYLE_PROPS.length; j += 1) {
|
|
124
|
-
var prop = STYLE_PROPS[j];
|
|
125
|
-
computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
|
|
126
|
-
}
|
|
127
|
-
var ancestry = [];
|
|
128
|
-
var node = element.parentElement;
|
|
129
|
-
var depth = 0;
|
|
130
|
-
while (node && node.nodeType === 1 && depth < 4) {
|
|
131
|
-
var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
|
|
132
|
-
if (node.id) entry.id = node.id;
|
|
133
|
-
var cls = typeof node.className === 'string' ? node.className.trim() : '';
|
|
134
|
-
if (cls) entry.className = cls.slice(0, 200);
|
|
135
|
-
ancestry.unshift(entry);
|
|
136
|
-
node = node.parentElement;
|
|
137
|
-
depth += 1;
|
|
138
|
-
}
|
|
139
|
-
var box = element.getBoundingClientRect();
|
|
140
|
-
var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
|
|
141
|
-
return {
|
|
142
|
-
tag: element.tagName.toLowerCase(),
|
|
143
|
-
text: text.slice(0, MAX_TEXT),
|
|
144
|
-
selector: buildSelector(element),
|
|
145
|
-
path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
|
|
146
|
-
bounds: rectFrom(box),
|
|
147
|
-
center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
|
|
148
|
-
attributes: attributes,
|
|
149
|
-
computedStyle: computedStyle,
|
|
150
|
-
ancestry: ancestry
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// ------------------------------------------------------------------ chrome
|
|
155
|
-
|
|
156
|
-
var host = document.createElement('div');
|
|
157
|
-
host.setAttribute(OVERLAY_ATTR, '');
|
|
158
|
-
// A manual popover: shown, it joins the browser's top layer without making
|
|
159
|
-
// the rest of the page inert. See "top layer" below.
|
|
160
|
-
host.setAttribute('popover', 'manual');
|
|
161
|
-
// Every declaration is !important: as a popover, and later inside a page
|
|
162
|
-
// dialog, the host matches page rules such as [popover]{background:...},
|
|
163
|
-
// which would otherwise paint a sheet over the whole page.
|
|
164
|
-
host.style.cssText = [
|
|
165
|
-
'all:initial', 'display:block', 'position:fixed', 'inset:0', 'width:auto', 'height:auto',
|
|
166
|
-
'max-width:none', 'max-height:none', 'margin:0', 'padding:0', 'border:0', 'background:transparent',
|
|
167
|
-
'overflow:visible', 'opacity:1', 'transform:none', 'z-index:' + Z_OVERLAY, 'pointer-events:none'
|
|
168
|
-
].join(' !important;') + ' !important';
|
|
169
|
-
var shadow = host.attachShadow({ mode: 'closed' });
|
|
170
|
-
|
|
171
|
-
var style = document.createElement('style');
|
|
172
|
-
style.textContent = [
|
|
173
|
-
':host{all:initial}',
|
|
174
|
-
'*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
|
|
175
|
-
'.layer{position:fixed;inset:0;pointer-events:none}',
|
|
176
|
-
'.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
|
|
177
|
-
'.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}',
|
|
178
|
-
'.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}',
|
|
179
|
-
'.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}',
|
|
180
|
-
'.tools button:hover{background:' + THEME.primaryFaint + '}',
|
|
181
|
-
'.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
|
|
182
|
-
'.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}',
|
|
183
|
-
'.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}',
|
|
184
|
-
'.editor textarea::placeholder{color:' + THEME.mutedText + '}',
|
|
185
|
-
'.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}',
|
|
186
|
-
'.editor button svg{width:16px;height:16px;display:block}',
|
|
187
|
-
'.editor button[disabled]{opacity:.5;cursor:default}'
|
|
188
|
-
].join('');
|
|
189
|
-
shadow.appendChild(style);
|
|
190
|
-
|
|
191
|
-
var cursorStyle = document.createElement('style');
|
|
192
|
-
cursorStyle.id = 'openchamber-annotation-cursor';
|
|
193
|
-
document.head.appendChild(cursorStyle);
|
|
194
|
-
var setCursor = function (value) {
|
|
195
|
-
cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
var svgNS = 'http://www.w3.org/2000/svg';
|
|
199
|
-
var svg = document.createElementNS(svgNS, 'svg');
|
|
200
|
-
svg.setAttribute('class', 'layer');
|
|
201
|
-
svg.style.overflow = 'visible';
|
|
202
|
-
shadow.appendChild(svg);
|
|
203
|
-
|
|
204
|
-
var hoverBox = document.createElement('div');
|
|
205
|
-
hoverBox.className = 'box';
|
|
206
|
-
var hoverLabel = document.createElement('div');
|
|
207
|
-
hoverLabel.className = 'label';
|
|
208
|
-
var marqueeBox = document.createElement('div');
|
|
209
|
-
marqueeBox.className = 'box';
|
|
210
|
-
shadow.append(hoverBox, hoverLabel, marqueeBox);
|
|
211
|
-
|
|
212
|
-
var positionBox = function (node, rect) {
|
|
213
|
-
node.style.display = 'block';
|
|
214
|
-
node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
|
|
215
|
-
node.style.width = rect.width + 'px';
|
|
216
|
-
node.style.height = rect.height + 'px';
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
var tools = document.createElement('div');
|
|
220
|
-
tools.className = 'tools';
|
|
221
|
-
shadow.appendChild(tools);
|
|
222
|
-
|
|
223
|
-
var toolButtons = {};
|
|
224
|
-
[['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
|
|
225
|
-
var button = document.createElement('button');
|
|
226
|
-
button.type = 'button';
|
|
227
|
-
button.textContent = entry[1];
|
|
228
|
-
button.addEventListener('click', function () { setTool(entry[0]); });
|
|
229
|
-
toolButtons[entry[0]] = button;
|
|
230
|
-
tools.appendChild(button);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
var editor = document.createElement('div');
|
|
234
|
-
editor.className = 'editor';
|
|
235
|
-
shadow.appendChild(editor);
|
|
236
|
-
|
|
237
|
-
var comment = document.createElement('textarea');
|
|
238
|
-
comment.rows = 1;
|
|
239
|
-
comment.placeholder = LABELS.commentPlaceholder;
|
|
240
|
-
var submit = document.createElement('button');
|
|
241
|
-
submit.type = 'button';
|
|
242
|
-
// Icon-only attach button (Remix attachment-2), matching the chat comment
|
|
243
|
-
// input; the localized label stays available to assistive tech.
|
|
244
|
-
submit.setAttribute('aria-label', LABELS.submit);
|
|
245
|
-
submit.title = LABELS.submit;
|
|
246
|
-
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>';
|
|
247
|
-
editor.append(comment, submit);
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Grows the box with its content.
|
|
251
|
-
*
|
|
252
|
-
* A hidden element reports scrollHeight 0, so measuring one collapses the
|
|
253
|
-
* field to nothing — which is what left a sliver of a click target and an
|
|
254
|
-
* invisible caret. Measuring only while visible, and never below the CSS
|
|
255
|
-
* min-height, keeps it usable.
|
|
256
|
-
*/
|
|
257
|
-
var resizeComment = function () {
|
|
258
|
-
if (editor.style.display === 'none') return;
|
|
259
|
-
comment.style.height = 'auto';
|
|
260
|
-
comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
|
|
261
|
-
};
|
|
262
|
-
comment.addEventListener('input', resizeComment);
|
|
263
|
-
|
|
264
|
-
// -------------------------------------------------------------- selection
|
|
265
|
-
|
|
266
|
-
var lastTargetRect = null;
|
|
267
|
-
|
|
268
|
-
/** Places the comment box under whatever was just marked, kept on screen. */
|
|
269
|
-
var positionEditor = function () {
|
|
270
|
-
if (!lastTargetRect) {
|
|
271
|
-
editor.style.display = 'none';
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
var wasHidden = editor.style.display === 'none';
|
|
275
|
-
editor.style.display = 'flex';
|
|
276
|
-
// Measured now that it is laid out, not while it was still hidden.
|
|
277
|
-
if (wasHidden) resizeComment();
|
|
278
|
-
var box = editor.getBoundingClientRect();
|
|
279
|
-
var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
|
|
280
|
-
var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
|
|
281
|
-
// Above the target when there is no room below, so the box is never left
|
|
282
|
-
// half off the bottom of the page.
|
|
283
|
-
if (top + box.height > window.innerHeight - 8) {
|
|
284
|
-
top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
|
|
285
|
-
}
|
|
286
|
-
left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
|
|
287
|
-
editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
/** Focus after layout: focusing a zero-height field puts the caret nowhere. */
|
|
291
|
-
var focusComment = function () {
|
|
292
|
-
requestAnimationFrame(function () {
|
|
293
|
-
try {
|
|
294
|
-
comment.focus({ preventScroll: true });
|
|
295
|
-
comment.setSelectionRange(comment.value.length, comment.value.length);
|
|
296
|
-
} catch (error) { /* field went away */ }
|
|
297
|
-
});
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
var hasTargets = function () {
|
|
301
|
-
return Boolean(selected) || regions.length > 0 || strokes.length > 0;
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
var syncChrome = function () {
|
|
305
|
-
submit.disabled = !hasTargets();
|
|
306
|
-
if (!hasTargets()) {
|
|
307
|
-
lastTargetRect = null;
|
|
308
|
-
editor.style.display = 'none';
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
positionEditor();
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
var syncSelectionVisuals = function () {
|
|
315
|
-
if (!selected) return;
|
|
316
|
-
var rect = rectFrom(selected.element.getBoundingClientRect());
|
|
317
|
-
if (!usableRect(rect)) {
|
|
318
|
-
selected.outline.style.display = 'none';
|
|
319
|
-
selected.badge.style.display = 'none';
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
positionBox(selected.outline, rect);
|
|
323
|
-
selected.badge.style.display = 'block';
|
|
324
|
-
selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
325
|
-
lastTargetRect = rect;
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
var dropSelection = function () {
|
|
329
|
-
if (!selected) return;
|
|
330
|
-
selected.outline.remove();
|
|
331
|
-
selected.badge.remove();
|
|
332
|
-
selected = null;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
var selectElement = function (element) {
|
|
336
|
-
var wasSelected = selected && selected.element === element;
|
|
337
|
-
dropSelection();
|
|
338
|
-
if (wasSelected) {
|
|
339
|
-
// Clicking the chosen element again clears it, so a misclick costs one
|
|
340
|
-
// click rather than starting over.
|
|
341
|
-
lastTargetRect = null;
|
|
342
|
-
syncChrome();
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
var outline = document.createElement('div');
|
|
346
|
-
outline.className = 'box';
|
|
347
|
-
var badge = document.createElement('div');
|
|
348
|
-
badge.className = 'label';
|
|
349
|
-
badge.textContent = selectorPart(element);
|
|
350
|
-
shadow.append(outline, badge);
|
|
351
|
-
selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
|
|
352
|
-
syncSelectionVisuals();
|
|
353
|
-
syncChrome();
|
|
354
|
-
focusComment();
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
var setTool = function (next) {
|
|
358
|
-
tool = next;
|
|
359
|
-
hoverBox.style.display = 'none';
|
|
360
|
-
hoverLabel.style.display = 'none';
|
|
361
|
-
marqueeBox.style.display = 'none';
|
|
362
|
-
setCursor(next === 'select' ? '' : 'crosshair');
|
|
363
|
-
for (var key in toolButtons) {
|
|
364
|
-
if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
|
|
365
|
-
toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
// ------------------------------------------------------------- interaction
|
|
371
|
-
|
|
372
|
-
var drag = null;
|
|
373
|
-
|
|
374
|
-
var onPointerMove = function (event) {
|
|
375
|
-
if (drag) {
|
|
376
|
-
if (drag.kind === 'marquee') {
|
|
377
|
-
drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
|
|
378
|
-
positionBox(marqueeBox, drag.rect);
|
|
379
|
-
} else if (drag.kind === 'draw') {
|
|
380
|
-
drag.points.push({ x: event.clientX, y: event.clientY });
|
|
381
|
-
drag.path.setAttribute('d', drag.points.map(function (point, index) {
|
|
382
|
-
return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
|
|
383
|
-
}).join(' '));
|
|
384
|
-
}
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (tool !== 'select') return;
|
|
389
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
390
|
-
if (!element) {
|
|
391
|
-
hoverBox.style.display = 'none';
|
|
392
|
-
hoverLabel.style.display = 'none';
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
var rect = rectFrom(element.getBoundingClientRect());
|
|
396
|
-
positionBox(hoverBox, rect);
|
|
397
|
-
hoverLabel.textContent = selectorPart(element);
|
|
398
|
-
hoverLabel.style.display = 'block';
|
|
399
|
-
hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
var onPointerDown = function (event) {
|
|
403
|
-
if (event.button !== 0) return;
|
|
404
|
-
if (isOverlayNode(event.target)) return;
|
|
405
|
-
event.preventDefault();
|
|
406
|
-
event.stopPropagation();
|
|
407
|
-
|
|
408
|
-
if (tool === 'select') {
|
|
409
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
410
|
-
if (element) selectElement(element);
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
if (tool === 'marquee') {
|
|
415
|
-
drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
var path = document.createElementNS(svgNS, 'path');
|
|
420
|
-
path.setAttribute('fill', 'none');
|
|
421
|
-
path.setAttribute('stroke', THEME.primary);
|
|
422
|
-
path.setAttribute('stroke-width', '2.5');
|
|
423
|
-
path.setAttribute('stroke-linecap', 'round');
|
|
424
|
-
path.setAttribute('stroke-linejoin', 'round');
|
|
425
|
-
svg.appendChild(path);
|
|
426
|
-
drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
var onPointerUp = function () {
|
|
430
|
-
if (!drag) return;
|
|
431
|
-
var finished = drag;
|
|
432
|
-
drag = null;
|
|
433
|
-
|
|
434
|
-
if (finished.kind === 'marquee') {
|
|
435
|
-
marqueeBox.style.display = 'none';
|
|
436
|
-
var rect = finished.rect;
|
|
437
|
-
if (!rect || !usableRect(rect)) return;
|
|
438
|
-
// A region marks an area, not the elements inside it: expanding it into a
|
|
439
|
-
// selection made the result depend on the page's markup rather than on
|
|
440
|
-
// what was drawn.
|
|
441
|
-
regions.push({ id: nextId('region'), rect: rect });
|
|
442
|
-
var outline = document.createElementNS(svgNS, 'rect');
|
|
443
|
-
outline.setAttribute('x', String(rect.x));
|
|
444
|
-
outline.setAttribute('y', String(rect.y));
|
|
445
|
-
outline.setAttribute('width', String(rect.width));
|
|
446
|
-
outline.setAttribute('height', String(rect.height));
|
|
447
|
-
outline.style.fill = THEME.primarySoft;
|
|
448
|
-
outline.setAttribute('stroke', THEME.primary);
|
|
449
|
-
outline.setAttribute('stroke-width', '1.5');
|
|
450
|
-
outline.setAttribute('rx', '2');
|
|
451
|
-
svg.appendChild(outline);
|
|
452
|
-
lastTargetRect = rect;
|
|
453
|
-
syncChrome();
|
|
454
|
-
focusComment();
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
var points = finished.points;
|
|
459
|
-
if (points.length < 2) {
|
|
460
|
-
if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
|
|
464
|
-
for (var p = 1; p < points.length; p += 1) {
|
|
465
|
-
minX = Math.min(minX, points[p].x);
|
|
466
|
-
minY = Math.min(minY, points[p].y);
|
|
467
|
-
maxX = Math.max(maxX, points[p].x);
|
|
468
|
-
maxY = Math.max(maxY, points[p].y);
|
|
469
|
-
}
|
|
470
|
-
var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
471
|
-
strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
|
|
472
|
-
lastTargetRect = bounds;
|
|
473
|
-
syncChrome();
|
|
474
|
-
focusComment();
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* Swallows the page's own mouse handling while annotating.
|
|
479
|
-
*
|
|
480
|
-
* Blocking pointerdown is not enough: a click still follows it, so marking a
|
|
481
|
-
* button pressed that button and marking a link navigated away from the page
|
|
482
|
-
* being annotated. These are the events that reach page code, so these are
|
|
483
|
-
* the ones that have to stop.
|
|
484
|
-
*/
|
|
485
|
-
var blockPageInteraction = function (event) {
|
|
486
|
-
if (isOverlayNode(event.target)) return;
|
|
487
|
-
event.preventDefault();
|
|
488
|
-
event.stopPropagation();
|
|
489
|
-
};
|
|
490
|
-
var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
|
|
491
|
-
|
|
492
|
-
var onScrollOrResize = function () {
|
|
493
|
-
syncSelectionVisuals();
|
|
494
|
-
positionEditor();
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
var onKeyDown = function (event) {
|
|
498
|
-
if (event.isComposing || event.keyCode === 229) return;
|
|
499
|
-
if (event.key === 'Escape') {
|
|
500
|
-
event.preventDefault();
|
|
501
|
-
event.stopImmediatePropagation();
|
|
502
|
-
finish(null);
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
var onCommentKeyDown = function (event) {
|
|
507
|
-
// Do not let the annotated page treat typed letters as its own shortcuts.
|
|
508
|
-
event.stopPropagation();
|
|
509
|
-
// WebKit can report the composition-confirming Enter as keyCode 229.
|
|
510
|
-
if (event.isComposing || event.keyCode === 229) return;
|
|
511
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
|
512
|
-
event.preventDefault();
|
|
513
|
-
attach();
|
|
514
|
-
}
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
document.addEventListener('pointermove', onPointerMove, true);
|
|
518
|
-
document.addEventListener('pointerdown', onPointerDown, true);
|
|
519
|
-
document.addEventListener('pointerup', onPointerUp, true);
|
|
520
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
521
|
-
window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
|
|
522
|
-
});
|
|
523
|
-
window.addEventListener('scroll', onScrollOrResize, true);
|
|
524
|
-
window.addEventListener('resize', onScrollOrResize, true);
|
|
525
|
-
window.addEventListener('keydown', onKeyDown, true);
|
|
526
|
-
comment.addEventListener('keydown', onCommentKeyDown);
|
|
527
|
-
|
|
528
|
-
// --------------------------------------------------------------- top layer
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* Keeps the chrome above a modal dialog or popover the page opens.
|
|
532
|
-
*
|
|
533
|
-
* Those render in the browser's top layer, which no z-index reaches, and a
|
|
534
|
-
* modal dialog also makes everything outside itself inert: the outlines drew
|
|
535
|
-
* under the dialog and the comment box took no typing. So the host is shown
|
|
536
|
-
* as a popover, which puts it in the top layer too, and it lives inside the
|
|
537
|
-
* page's topmost modal dialog, where that inertness does not reach. Showing it
|
|
538
|
-
* again whenever the page puts something new on top keeps it last, so above.
|
|
539
|
-
*
|
|
540
|
-
* Opening our own modal dialog instead would make the page's dialog inert,
|
|
541
|
-
* which is the thing being annotated.
|
|
542
|
-
*/
|
|
543
|
-
var modals = [];
|
|
544
|
-
|
|
545
|
-
var isModalDialog = function (element) {
|
|
546
|
-
if (element.tagName !== 'DIALOG') return false;
|
|
547
|
-
try { return element.matches(':modal'); } catch (error) { return false; }
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
var trackDialog = function (dialog) {
|
|
551
|
-
var index = modals.indexOf(dialog);
|
|
552
|
-
if (index !== -1) modals.splice(index, 1);
|
|
553
|
-
// Opened last, so on top. Dialogs already open when annotation starts are
|
|
554
|
-
// taken in document order, which is the usual order of nesting.
|
|
555
|
-
if (isModalDialog(dialog)) modals.push(dialog);
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
var topModal = function () {
|
|
559
|
-
for (var i = modals.length - 1; i >= 0; i -= 1) {
|
|
560
|
-
if (modals[i].isConnected && isModalDialog(modals[i])) return modals[i];
|
|
561
|
-
}
|
|
562
|
-
return null;
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
var placeHost = function () {
|
|
566
|
-
var parent = topModal() || document.body || document.documentElement;
|
|
567
|
-
var hadFocus = shadow.activeElement === comment;
|
|
568
|
-
if (host.parentNode !== parent) parent.appendChild(host);
|
|
569
|
-
try {
|
|
570
|
-
if (host.matches(':popover-open')) host.hidePopover();
|
|
571
|
-
host.showPopover();
|
|
572
|
-
} catch (error) { /* no popover support: the z-index still covers ordinary pages */ }
|
|
573
|
-
// Moving the host blurs the comment box mid-sentence.
|
|
574
|
-
if (hadFocus) comment.focus({ preventScroll: true });
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
var topLayerObserver = new window.MutationObserver(function (records) {
|
|
578
|
-
var changed = false;
|
|
579
|
-
for (var i = 0; i < records.length; i += 1) {
|
|
580
|
-
if (records[i].type === 'attributes' && records[i].target.tagName === 'DIALOG') {
|
|
581
|
-
trackDialog(records[i].target);
|
|
582
|
-
changed = true;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
if (!host.isConnected) {
|
|
586
|
-
// Removed on purpose, not along with a dialog: the session was cancelled
|
|
587
|
-
// from the app or replaced by a new one. End it, so its listeners stop
|
|
588
|
-
// swallowing the page's clicks and nothing brings the host back.
|
|
589
|
-
for (var j = 0; j < records.length; j += 1) {
|
|
590
|
-
if (Array.prototype.indexOf.call(records[j].removedNodes, host) !== -1) {
|
|
591
|
-
finish(null);
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
changed = true;
|
|
596
|
-
}
|
|
597
|
-
if (!changed) return;
|
|
598
|
-
placeHost();
|
|
599
|
-
// Our own move is not a page change.
|
|
600
|
-
topLayerObserver.takeRecords();
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
var onToggle = function (event) {
|
|
604
|
-
if (event.target === host || event.newState !== 'open') return;
|
|
605
|
-
placeHost();
|
|
606
|
-
topLayerObserver.takeRecords();
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
// With the host inside the page's dialog, clicks on our chrome would reach
|
|
610
|
-
// the dialog's own handlers, and a click outside its box commonly closes it.
|
|
611
|
-
// Typing in the comment box would reach its key handlers the same way.
|
|
612
|
-
var CHROME_EVENTS = BLOCKED_EVENTS.concat([
|
|
613
|
-
'pointerdown', 'pointerup', 'keydown', 'keyup', 'keypress', 'beforeinput', 'input'
|
|
614
|
-
]);
|
|
615
|
-
var keepChromeEvent = function (event) { event.stopPropagation(); };
|
|
616
|
-
CHROME_EVENTS.forEach(function (name) {
|
|
617
|
-
host.addEventListener(name, keepChromeEvent);
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
var startTopLayer = function () {
|
|
621
|
-
Array.prototype.forEach.call(document.querySelectorAll('dialog'), trackDialog);
|
|
622
|
-
placeHost();
|
|
623
|
-
topLayerObserver.observe(document.documentElement, {
|
|
624
|
-
subtree: true,
|
|
625
|
-
childList: true,
|
|
626
|
-
attributes: true,
|
|
627
|
-
attributeFilter: ['open']
|
|
628
|
-
});
|
|
629
|
-
document.addEventListener('toggle', onToggle, true);
|
|
630
|
-
};
|
|
631
|
-
|
|
632
|
-
// ------------------------------------------------------------------ finish
|
|
633
|
-
|
|
634
|
-
var teardown = function () {
|
|
635
|
-
document.removeEventListener('pointermove', onPointerMove, true);
|
|
636
|
-
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
637
|
-
document.removeEventListener('pointerup', onPointerUp, true);
|
|
638
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
639
|
-
window.removeEventListener(name, blockPageInteraction, true);
|
|
640
|
-
});
|
|
641
|
-
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
642
|
-
window.removeEventListener('resize', onScrollOrResize, true);
|
|
643
|
-
window.removeEventListener('keydown', onKeyDown, true);
|
|
644
|
-
comment.removeEventListener('keydown', onCommentKeyDown);
|
|
645
|
-
topLayerObserver.disconnect();
|
|
646
|
-
document.removeEventListener('toggle', onToggle, true);
|
|
647
|
-
setCursor('');
|
|
648
|
-
if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
|
|
649
|
-
if (host.parentNode) host.parentNode.removeChild(host);
|
|
650
|
-
try { delete window['${Ia}']; } catch (error) { /* non-configurable */ }
|
|
651
|
-
};
|
|
652
|
-
|
|
653
|
-
var finish = function (payload) {
|
|
654
|
-
if (settled) return;
|
|
655
|
-
settled = true;
|
|
656
|
-
teardown();
|
|
657
|
-
// Removing the chrome is not enough: the host screenshots this page right
|
|
658
|
-
// after we resolve, and the compositor can still hold a frame containing
|
|
659
|
-
// our outlines. Yield two frames so the page has actually repainted.
|
|
660
|
-
requestAnimationFrame(function () {
|
|
661
|
-
requestAnimationFrame(function () { resolve(payload); });
|
|
662
|
-
});
|
|
663
|
-
};
|
|
664
|
-
|
|
665
|
-
var attach = function () {
|
|
666
|
-
if (!hasTargets()) return;
|
|
667
|
-
finish({
|
|
668
|
-
id: 'annotation-' + Date.now(),
|
|
669
|
-
pageUrl: String(location.href),
|
|
670
|
-
pageTitle: String(document.title || ''),
|
|
671
|
-
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
672
|
-
devicePixelRatio: window.devicePixelRatio || 1,
|
|
673
|
-
comment: comment.value,
|
|
674
|
-
// Zero or one element, never more. Kept as a list so elements, regions
|
|
675
|
-
// and strokes stay one uniform shape for everything downstream.
|
|
676
|
-
elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
|
|
677
|
-
regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
|
|
678
|
-
strokes: strokes.map(function (entry) {
|
|
679
|
-
return { id: entry.id, points: entry.points, bounds: entry.bounds };
|
|
680
|
-
})
|
|
681
|
-
});
|
|
682
|
-
};
|
|
683
|
-
|
|
684
|
-
submit.addEventListener('click', attach);
|
|
685
|
-
|
|
686
|
-
startTopLayer();
|
|
687
|
-
setTool('select');
|
|
688
|
-
syncChrome();
|
|
689
|
-
});`},US={kind:"idle"},wn=t=>typeof t=="object"&&t!==null,Pn=t=>typeof t=="number"&&Number.isFinite(t),Hc=t=>wn(t)&&Object.values(t).every(e=>typeof e=="string"),Sl=t=>wn(t)&&Pn(t.x)&&Pn(t.y)&&Pn(t.width)&&Pn(t.height),Qf=t=>wn(t)&&Pn(t.x)&&Pn(t.y),HS=t=>wn(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"),GS=t=>wn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&Sl(t.bounds)&&Qf(t.center)&&Hc(t.attributes)&&Hc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(HS),qS=t=>wn(t)&&typeof t.id=="string"&&GS(t.element),YS=t=>wn(t)&&typeof t.id=="string"&&Sl(t.rect),QS=t=>wn(t)&&typeof t.id=="string"&&Sl(t.bounds)&&Array.isArray(t.points)&&t.points.every(Qf),XS=t=>wn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&wn(t.viewport)&&Pn(t.viewport.width)&&Pn(t.viewport.height)&&Pn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(qS)&&Array.isArray(t.regions)&&t.regions.every(YS)&&Array.isArray(t.strokes)&&t.strokes.every(QS),JS=1600,ZS=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}),e1=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:o,cssHeight:i,payload:d,accentColor:a,accentFill:c})=>{if(!t)return null;try{const u=await ZS(`data:${e};base64,${t}`),f=Math.max(1,u.naturalWidth||n),p=Math.max(1,u.naturalHeight||r),m=f/Math.max(1,o||f),y=p/Math.max(1,i||p),x=Math.min(1,JS/f),w=document.createElement("canvas");w.width=Math.max(1,Math.floor(f*x)),w.height=Math.max(1,Math.floor(p*x));const b=w.getContext("2d");if(!b)return null;b.scale(x,x),b.drawImage(u,0,0,f,p);const g=j=>({x:j.x*m,y:j.y*y,width:j.width*m,height:j.height*y}),h=Math.max(2,2.5*m/Math.max(x,.2));b.strokeStyle=a,b.fillStyle=c;const v=j=>{const N=g(j);b.lineWidth=h,b.fillRect(N.x,N.y,N.width,N.height),b.strokeRect(N.x,N.y,N.width,N.height)};for(const j of d.elements)v(j.element.bounds);for(const j of d.regions)v(j.rect);for(const j of d.strokes)j.points.length<2||(b.beginPath(),j.points.forEach((N,C)=>{const B=N.x*m,W=N.y*y;C===0?b.moveTo(B,W):b.lineTo(B,W)}),b.lineCap="round",b.lineJoin="round",b.lineWidth=h*1.4,b.stroke());const S=await new Promise(j=>w.toBlob(j,"image/jpeg",.85));return S?new File([S],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},t1="({ width: window.innerWidth, height: window.innerHeight })",s1=async t=>{try{const e=await t.executeJavaScript(t1,!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}},Ho=async t=>{try{await t.executeJavaScript(zS,!1)}catch{}},n1=async({host:t,theme:e,labels:n})=>{const r=VS(e,n),o=await t.executeJavaScript(r,!0);if(o==null)return null;if(!XS(o))return await Ho(t),null;const i=o;try{const d=await s1(t)??i.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:i,screenshot:null};const c=await e1({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:d.width,cssHeight:d.height,payload:i,accentColor:e.primary,accentFill:e.primarySoft});return{payload:i,screenshot:c}}catch{return{payload:i,screenshot:null}}},on={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)"},r1=()=>{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()}},o1=t=>{const e=r1();if(!e)return{...on,colorScheme:t};try{const n=(a,c)=>e.read(`var(${a})`)||c,r=(a,c,u)=>e.read(`color-mix(in srgb, var(${a}) ${c}%, transparent)`)||u,o=e.readVariable("--oc-glass-tooltip-opacity")||"62%",i=e.readVariable("--oc-glass-blur")||"26px",d=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${o}, transparent)`)||on.glassSurface,glassFilter:`blur(${i}) saturate(${d})`,primary:n("--primary",on.primary),primarySoft:r("--primary",16,on.primarySoft),primaryFaint:r("--primary",10,on.primaryFaint),primaryContrast:n("--primary-foreground",on.primaryContrast),surface:n("--surface-background",on.surface),surfaceElevated:n("--surface-elevated",on.surfaceElevated),border:n("--border",on.border),text:n("--foreground",on.text),mutedText:n("--muted-foreground",on.mutedText)}}catch{return{...on,colorScheme:t}}finally{e.dispose()}},i1=2e3,a1=50,l1=400,dn=new Map,Dn=new Map;let Go=null,Vn=null,Zr=null;const Da=async t=>{try{const e=await Zs("/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}},c1=async(t,e)=>{try{const n=await Zs("/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)}},Xf=async(t,e=i1)=>{const n=Date.now()+e;for(;!dn.has(t)&&Date.now()<n;)await new Promise(r=>setTimeout(r,a1));return dn.get(t)??null},Ea=t=>dn.has(t)||Dn.has(t),Gc=t=>{let e=null;for(const n of t.keys())e=n;return e},Jf=()=>Go&&Ea(Go)?Go:Gc(dn)??Gc(Dn),Zf=async t=>{const e=dn.get(t);if(e)return e;const n=Dn.get(t);return n?(n.wake(),Xf(t)):null},d1=()=>{const t=Jf();return[...dn.values(),...[...Dn.values()].filter(n=>!dn.has(n.tabId))].map(n=>{let r={title:"",url:""};try{r=n.describe()}catch{}return{id:n.tabId,title:r.title,url:r.url,active:n.tabId===t}})},ep=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,u1=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use the tab the user is looking at.`,An=(t,e)=>c1(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:ob()})}:e),f1=async t=>{const e=t.action==="browser.open",{tabId:n,...r}=t.parameters,o=n===void 0?null:String(n);if(o!==null){if(!Ea(o)){if(dn.size===0&&Dn.size===0&&!Vn)return;if(await new Promise(d=>setTimeout(d,l1)),Ea(o)){await qc(t,o,r);return}if(!await Da(t.requestId))return;await An(t,{ok:!1,error:u1(o)});return}await qc(t,o,r);return}const i=Jf();if(!(!i&&!(e&&Vn))&&await Da(t.requestId))try{const d=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!d){await An(t,{ok:!1,error:"url is required"});return}const a=e&&Vn?Vn(d):null;if(e&&!a&&!i){await An(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(a){const u=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!u||u==="fill"){await An(t,{ok:!0,data:{url:d,opened:!0,tabId:a}});return}const f=await Xf(a);if(!f){await An(t,{ok:!0,data:{url:d,opened:!0,tabId:a,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 p=await f.run("browser.resize",{viewport:u}),m=p&&typeof p=="object"?p.viewport??null:null;await An(t,{ok:!0,data:{url:d,opened:!0,tabId:a,viewportApplied:!0,viewport:m}});return}const c=await Zf(i);await An(t,c?await tp(c,t.action,r):{ok:!1,error:ep(i)})}catch(d){await An(t,{ok:!1,error:d instanceof Error?d.message:String(d)})}},qc=async(t,e,n)=>{if(!await Da(t.requestId))return;const r=await Zf(e);await An(t,r?await tp(r,t.action,n):{ok:!1,error:ep(e)})},tp=async(t,e,n)=>{try{const r=await t.run(e,n);return e==="browser.snapshot"&&Object(r)===r?{ok:!0,data:{...Object(r),tabs:d1()}}:{ok:!0,data:r}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},jl=()=>{Zr||(Zr=Qn(t=>{t.type==="browser-control-request"&&f1({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},kl=()=>{dn.size>0||Dn.size>0||Vn||!Zr||(Zr(),Zr=null)},p1=t=>(dn.set(t.tabId,t),jl(),()=>{dn.get(t.tabId)===t&&dn.delete(t.tabId),kl()}),m1=t=>(Dn.set(t.tabId,t),jl(),()=>{Dn.get(t.tabId)===t&&Dn.delete(t.tabId),kl()}),h1=t=>{Go=t},g1=t=>(Vn=t,jl(),()=>{Vn===t&&(Vn=null),kl()}),b1=50,x1=6,y1=2048,v1=200,sp=t=>{const e=Dr(String(t??"").trim());if(!e||e.length>y1)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},w1=(t,e)=>{const n=sp(e.url);if(!n)return t;const r=t.find(d=>d.url===n),o=String(e.title??"").trim().slice(0,v1)||r?.title||"";return[{url:n,title:o,lastVisitedAt:e.at},...t.filter(d=>d.url!==n)].slice(0,b1)},S1=(t,e)=>{const n=sp(e);return t.filter(r=>r.url!==n)},j1=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),np=(t,e,n=x1)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((d,a)=>a.lastVisitedAt-d.lastVisitedAt);if(!r)return o.slice(0,n);const i=r.replace(/^https?:\/\//,"");return o.filter(d=>{const a=j1(d);return d.url===r||a===i?!1:a.includes(i)}).slice(0,n)},Yc=20,qo=t=>{const e=at((t||"").trim());return e?JSON.stringify([ss(),e]):""},k1=t=>{const e=Object.keys(t);if(e.length<=Yc)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,Yc);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},Rr=bl()(Ty(t=>({byProject:{},recordVisit:(e,n)=>{const r=qo(e);r&&t(o=>{const i=o.byProject[r]??[],d=w1(i,{...n,at:Date.now()});return d===i?o:{byProject:k1({...o.byProject,[r]:d})}})},forget:(e,n)=>{const r=qo(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:S1(i,n)}}:o})},clear:e=>{const n=qo(e);n&&t(r=>{if(!(n in r.byProject))return r;const o={...r.byProject};return delete o[n],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Cm(),partialize:t=>({byProject:t.byProject})})),C1=[],rp=t=>e=>{const n=qo(t);return(n?e.byProject[n]:void 0)??C1},Qc=6e3,N1=120,A1=80,P1=`
|
|
690
|
-
var MAX_ELEMENTS = ${N1};
|
|
691
|
-
var MAX_LABEL_CHARS = ${A1};
|
|
692
|
-
var visible = function (element) {
|
|
693
|
-
var rect = element.getBoundingClientRect();
|
|
694
|
-
if (rect.width < 1 || rect.height < 1) return false;
|
|
695
|
-
var style = window.getComputedStyle(element);
|
|
696
|
-
return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
|
|
697
|
-
};
|
|
698
|
-
var label = function (element) {
|
|
699
|
-
var aria = element.getAttribute('aria-label');
|
|
700
|
-
if (aria) return aria.trim();
|
|
701
|
-
var value = element.getAttribute('value');
|
|
702
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
703
|
-
if (text) return text.slice(0, MAX_LABEL_CHARS);
|
|
704
|
-
if (value) return String(value).slice(0, MAX_LABEL_CHARS);
|
|
705
|
-
var placeholder = element.getAttribute('placeholder');
|
|
706
|
-
return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
|
|
707
|
-
};
|
|
708
|
-
var isUnique = function (selector) {
|
|
709
|
-
try {
|
|
710
|
-
return document.querySelectorAll(selector).length === 1;
|
|
711
|
-
} catch (error) {
|
|
712
|
-
return false;
|
|
713
|
-
}
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* Names an element by what it is, falling back to where it sits.
|
|
718
|
-
*
|
|
719
|
-
* A positional chain like 'main > section:nth-of-type(3) > div > a' survives
|
|
720
|
-
* only until the markup shifts, and says nothing about what it points at.
|
|
721
|
-
* Anything the page states about identity — an id, a test id, an accessible
|
|
722
|
-
* name — outlives edits and reads as the thing it selects. The chain remains
|
|
723
|
-
* as the last resort, because something always has to work.
|
|
724
|
-
*/
|
|
725
|
-
var cssPath = function (element) {
|
|
726
|
-
var tag = element.tagName.toLowerCase();
|
|
727
|
-
|
|
728
|
-
if (element.id) {
|
|
729
|
-
var byId = '#' + CSS.escape(element.id);
|
|
730
|
-
if (isUnique(byId)) return byId;
|
|
731
|
-
}
|
|
732
|
-
var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
|
|
733
|
-
for (var a = 0; a < stableAttrs.length; a += 1) {
|
|
734
|
-
var value = element.getAttribute(stableAttrs[a]);
|
|
735
|
-
if (!value) continue;
|
|
736
|
-
var raw = String(value);
|
|
737
|
-
// A value containing a quote would need escaping for no real gain: such
|
|
738
|
-
// attributes are rare, and the positional chain still covers them.
|
|
739
|
-
if (raw.indexOf('"') !== -1) continue;
|
|
740
|
-
var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
|
|
741
|
-
if (isUnique(byAttr)) return byAttr;
|
|
742
|
-
}
|
|
743
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
744
|
-
if (className) {
|
|
745
|
-
var classes = className.split(/\\s+/).filter(Boolean);
|
|
746
|
-
for (var c = 0; c < classes.length; c += 1) {
|
|
747
|
-
var byClass = tag + '.' + CSS.escape(classes[c]);
|
|
748
|
-
if (isUnique(byClass)) return byClass;
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
var parts = [];
|
|
753
|
-
var node = element;
|
|
754
|
-
var depth = 0;
|
|
755
|
-
while (node && node.nodeType === 1 && depth < 6) {
|
|
756
|
-
var part = node.tagName.toLowerCase();
|
|
757
|
-
var parent = node.parentElement;
|
|
758
|
-
if (!parent) { parts.unshift(part); break; }
|
|
759
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
760
|
-
return child.tagName === node.tagName;
|
|
761
|
-
});
|
|
762
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
763
|
-
parts.unshift(part);
|
|
764
|
-
if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
|
|
765
|
-
node = parent;
|
|
766
|
-
depth += 1;
|
|
767
|
-
}
|
|
768
|
-
return parts.join(' > ');
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
/** What a screen reader would announce, or '' when there is nothing to say. */
|
|
772
|
-
var accessibleName = function (element) {
|
|
773
|
-
var aria = element.getAttribute('aria-label');
|
|
774
|
-
if (aria && aria.trim()) return aria.trim();
|
|
775
|
-
var labelled = element.getAttribute('aria-labelledby');
|
|
776
|
-
if (labelled) {
|
|
777
|
-
var source = document.getElementById(labelled.split(/\\s+/)[0]);
|
|
778
|
-
if (source && (source.innerText || '').trim()) return source.innerText.trim();
|
|
779
|
-
}
|
|
780
|
-
var title = element.getAttribute('title');
|
|
781
|
-
if (title && title.trim()) return title.trim();
|
|
782
|
-
var alt = element.getAttribute('alt');
|
|
783
|
-
if (alt && alt.trim()) return alt.trim();
|
|
784
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
785
|
-
if (text) return text;
|
|
786
|
-
var value = element.getAttribute('value');
|
|
787
|
-
return value && String(value).trim() ? String(value).trim() : '';
|
|
788
|
-
};
|
|
789
|
-
var findByText = function (needle) {
|
|
790
|
-
var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
|
|
791
|
-
var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
|
|
792
|
-
var exact = null;
|
|
793
|
-
var partial = null;
|
|
794
|
-
for (var i = 0; i < candidates.length; i += 1) {
|
|
795
|
-
var element = candidates[i];
|
|
796
|
-
if (!visible(element)) continue;
|
|
797
|
-
var text = label(element).toLowerCase();
|
|
798
|
-
if (!text) continue;
|
|
799
|
-
if (text === wanted) { exact = element; break; }
|
|
800
|
-
if (!partial && text.indexOf(wanted) !== -1) partial = element;
|
|
801
|
-
}
|
|
802
|
-
return exact || partial;
|
|
803
|
-
};
|
|
804
|
-
`,mo=t=>`(() => {
|
|
805
|
-
${P1}
|
|
806
|
-
${t}
|
|
807
|
-
})()`,I1=({selector:t}={})=>mo(`
|
|
808
|
-
var scopeSelector = ${JSON.stringify(t??"")};
|
|
809
|
-
var root = document;
|
|
810
|
-
if (scopeSelector) {
|
|
811
|
-
try { root = document.querySelector(scopeSelector); }
|
|
812
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
|
|
813
|
-
if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
|
|
814
|
-
}
|
|
815
|
-
var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
|
|
816
|
-
var elements = [];
|
|
817
|
-
var visibleTotal = 0;
|
|
818
|
-
for (var i = 0; i < interactive.length; i += 1) {
|
|
819
|
-
var element = interactive[i];
|
|
820
|
-
if (!visible(element)) continue;
|
|
821
|
-
visibleTotal += 1;
|
|
822
|
-
if (elements.length >= MAX_ELEMENTS) continue;
|
|
823
|
-
|
|
824
|
-
var rect = element.getBoundingClientRect();
|
|
825
|
-
// Empty and default-valued fields are left out rather than serialized as
|
|
826
|
-
// "" and false. Repeated across a hundred entries that overhead dwarfed
|
|
827
|
-
// the information it carried.
|
|
828
|
-
var entry = {
|
|
829
|
-
selector: cssPath(element),
|
|
830
|
-
tag: element.tagName.toLowerCase(),
|
|
831
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
832
|
-
};
|
|
833
|
-
// The list covers the whole document so anything can be clicked without
|
|
834
|
-
// scrolling to it first, which means bounds alone do not say what is on
|
|
835
|
-
// screen — a negative y reads as a bug otherwise.
|
|
836
|
-
if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
|
|
837
|
-
var type = element.getAttribute('type');
|
|
838
|
-
if (type) entry.type = type;
|
|
839
|
-
var role = element.getAttribute('role');
|
|
840
|
-
if (role) entry.role = role;
|
|
841
|
-
var labelText = label(element);
|
|
842
|
-
if (labelText) entry.label = labelText;
|
|
843
|
-
if (element.disabled === true) entry.disabled = true;
|
|
844
|
-
// Flagged rather than described: reporting the accessible name of every
|
|
845
|
-
// element would cost more than it tells, while its absence on something
|
|
846
|
-
// clickable is a defect worth naming.
|
|
847
|
-
if (!accessibleName(element)) entry.missingAccessibleName = true;
|
|
848
|
-
elements.push(entry);
|
|
849
|
-
}
|
|
850
|
-
var body = document.body ? (document.body.innerText || '') : '';
|
|
851
|
-
var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
|
|
852
|
-
var docEl = document.documentElement;
|
|
853
|
-
var result = {
|
|
854
|
-
ok: true,
|
|
855
|
-
url: String(location.href),
|
|
856
|
-
title: String(document.title || ''),
|
|
857
|
-
scope: scopeSelector || 'document',
|
|
858
|
-
scrollY: Math.round(window.scrollY),
|
|
859
|
-
maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
|
|
860
|
-
text: text.slice(0, ${Qc}),
|
|
861
|
-
elements: elements
|
|
862
|
-
};
|
|
863
|
-
// State what was dropped. A capped list that reports only its own length
|
|
864
|
-
// reads as the whole page, and the agent acts as if it had seen everything.
|
|
865
|
-
if (text.length > ${Qc}) {
|
|
866
|
-
result.textTruncated = true;
|
|
867
|
-
result.textTotalChars = text.length;
|
|
868
|
-
}
|
|
869
|
-
if (visibleTotal > elements.length) {
|
|
870
|
-
result.elementsTruncated = true;
|
|
871
|
-
result.interactiveElementsOnPage = visibleTotal;
|
|
872
|
-
}
|
|
873
|
-
return result;
|
|
874
|
-
`),D1=({selector:t,text:e})=>mo(`
|
|
875
|
-
var selector = ${JSON.stringify(t??"")};
|
|
876
|
-
var text = ${JSON.stringify(e??"")};
|
|
877
|
-
var target = null;
|
|
878
|
-
if (selector) {
|
|
879
|
-
try { target = document.querySelector(selector); }
|
|
880
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
881
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
882
|
-
} else {
|
|
883
|
-
target = findByText(text);
|
|
884
|
-
if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
|
|
885
|
-
}
|
|
886
|
-
if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
|
|
887
|
-
target.scrollIntoView({ block: 'center', inline: 'center' });
|
|
888
|
-
target.click();
|
|
889
|
-
return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
|
|
890
|
-
`),E1=({selector:t,value:e,submit:n})=>mo(`
|
|
891
|
-
var selector = ${JSON.stringify(t)};
|
|
892
|
-
var value = ${JSON.stringify(e)};
|
|
893
|
-
var target = null;
|
|
894
|
-
try { target = document.querySelector(selector); }
|
|
895
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
896
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
897
|
-
|
|
898
|
-
var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
899
|
-
if (!editable) return { ok: false, error: selector + ' is not a text field' };
|
|
900
|
-
if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
|
|
901
|
-
|
|
902
|
-
target.scrollIntoView({ block: 'center' });
|
|
903
|
-
target.focus();
|
|
904
|
-
if (target.isContentEditable) {
|
|
905
|
-
target.textContent = value;
|
|
906
|
-
} else {
|
|
907
|
-
// Frameworks track the value through the native setter; assigning the
|
|
908
|
-
// property directly leaves React and friends unaware of the change.
|
|
909
|
-
var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
910
|
-
var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
|
|
911
|
-
if (setter && setter.set) setter.set.call(target, value);
|
|
912
|
-
else target.value = value;
|
|
913
|
-
}
|
|
914
|
-
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
915
|
-
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
916
|
-
|
|
917
|
-
if (${n?"true":"false"}) {
|
|
918
|
-
var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
|
|
919
|
-
target.dispatchEvent(new KeyboardEvent('keydown', enter));
|
|
920
|
-
target.dispatchEvent(new KeyboardEvent('keyup', enter));
|
|
921
|
-
var form = target.form;
|
|
922
|
-
if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
|
|
923
|
-
}
|
|
924
|
-
return { ok: true, selector: cssPath(target), url: String(location.href) };
|
|
925
|
-
`),R1=({selector:t,direction:e})=>mo(`
|
|
926
|
-
var selector = ${JSON.stringify(t??"")};
|
|
927
|
-
var direction = ${JSON.stringify(e??"")};
|
|
928
|
-
|
|
929
|
-
var settle = function (extra) {
|
|
930
|
-
return new Promise(function (resolve) {
|
|
931
|
-
requestAnimationFrame(function () {
|
|
932
|
-
requestAnimationFrame(function () {
|
|
933
|
-
var doc = document.documentElement;
|
|
934
|
-
var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
935
|
-
var scrollY = Math.round(window.scrollY);
|
|
936
|
-
var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
|
|
937
|
-
result.atTop = scrollY <= 1;
|
|
938
|
-
result.atBottom = scrollY >= maxScrollY - 1;
|
|
939
|
-
for (var key in extra) {
|
|
940
|
-
if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
|
|
941
|
-
}
|
|
942
|
-
resolve(result);
|
|
943
|
-
});
|
|
944
|
-
});
|
|
945
|
-
});
|
|
946
|
-
};
|
|
947
|
-
|
|
948
|
-
if (selector) {
|
|
949
|
-
var target = null;
|
|
950
|
-
try { target = document.querySelector(selector); }
|
|
951
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
952
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
953
|
-
// Instant on purpose: the page's own smooth scrolling would still be
|
|
954
|
-
// animating when the next action runs against it.
|
|
955
|
-
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
956
|
-
return settle({ scrolledTo: cssPath(target) });
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
var doc = document.documentElement;
|
|
960
|
-
var page = Math.round(window.innerHeight * 0.85);
|
|
961
|
-
var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
962
|
-
if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
|
|
963
|
-
else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
|
|
964
|
-
else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
|
|
965
|
-
else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
|
|
966
|
-
else return { ok: false, error: 'Unknown scroll direction: ' + direction };
|
|
967
|
-
return settle({ direction: direction });
|
|
968
|
-
`),M1=["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"],T1=({selector:t})=>mo(`
|
|
969
|
-
var selector = ${JSON.stringify(t)};
|
|
970
|
-
var target = null;
|
|
971
|
-
try { target = document.querySelector(selector); }
|
|
972
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
973
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
974
|
-
|
|
975
|
-
var computed = window.getComputedStyle(target);
|
|
976
|
-
var styles = {};
|
|
977
|
-
var props = ${JSON.stringify(M1)};
|
|
978
|
-
for (var i = 0; i < props.length; i += 1) {
|
|
979
|
-
var value = computed.getPropertyValue(props[i]);
|
|
980
|
-
if (value) styles[props[i]] = String(value).trim();
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
var rect = target.getBoundingClientRect();
|
|
984
|
-
return {
|
|
985
|
-
ok: true,
|
|
986
|
-
selector: cssPath(target),
|
|
987
|
-
tag: target.tagName.toLowerCase(),
|
|
988
|
-
label: label(target),
|
|
989
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
990
|
-
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
991
|
-
styles: styles
|
|
992
|
-
};
|
|
993
|
-
`),O1=t=>{const e=He.c(18),{entries:n,activeIndex:r,onSelect:o,onForget:i,onHighlight:d}=t,{t:a}=vt();if(n.length===0)return null;let c;e[0]!==a?(c=a("contextPanel.browser.history.label"),e[0]=a,e[1]=c):c=e[1];let u;if(e[2]!==r||e[3]!==n||e[4]!==i||e[5]!==d||e[6]!==o||e[7]!==a){let p;e[9]!==r||e[10]!==i||e[11]!==d||e[12]!==o||e[13]!==a?(p=(m,y)=>s.jsxs("div",{role:"option","aria-selected":y===r,className:Se("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",y===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:x=>{x.preventDefault(),o(m.url)},onPointerEnter:()=>d(y),children:[s.jsx(T,{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:m.title||fi(m.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.url})]}),s.jsx("button",{type:"button",className:Se("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:x=>{x.preventDefault(),x.stopPropagation(),i(m.url)},children:s.jsx(T,{name:"close",className:"size-3","aria-hidden":"true"})})]},m.url),e[9]=r,e[10]=i,e[11]=d,e[12]=o,e[13]=a,e[14]=p):p=e[14],u=n.map(p),e[2]=r,e[3]=n,e[4]=i,e[5]=d,e[6]=o,e[7]=a,e[8]=u}else u=e[8];let f;return e[15]!==c||e[16]!==u?(f=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":c,children:u}),e[15]=c,e[16]=u,e[17]=f):f=e[17],f},an=t=>{const e=He.c(17),{icon:n,label:r,onClick:o,disabled:i,pressed:d}=t,a=d?"secondary":"ghost",c=d&&"text-foreground";let u;e[0]!==c?(u=Se("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",c),e[0]=c,e[1]=u):u=e[1];let f;e[2]!==n?(f=s.jsx(T,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=f):f=e[3];let p;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==d||e[8]!==a||e[9]!==u||e[10]!==f?(p=s.jsx(Nt,{asChild:!0,children:s.jsx(ut,{type:"button",variant:a,size:"xs",className:u,onClick:o,disabled:i,"aria-label":r,"aria-pressed":d,children:f})}),e[4]=i,e[5]=r,e[6]=o,e[7]=d,e[8]=a,e[9]=u,e[10]=f,e[11]=p):p=e[11];let m;e[12]!==r?(m=s.jsx(jt,{sideOffset:6,children:r}),e[12]=r,e[13]=m):m=e[13];let y;return e[14]!==p||e[15]!==m?(y=s.jsxs(Ct,{children:[p,m]}),e[14]=p,e[15]=m,e[16]=y):y=e[16],y},op=t=>{const e=He.c(105),{address:n,suggestions:r,onForgetSuggestion:o,onAddressChange:i,onSubmit:d,onBack:a,onForward:c,onReload:u,onOpenExternal:f,canOpenExternal:p,canGoBack:m,canGoForward:y,isLoading:x,onAnnotate:w,onOpenDevTools:b,isAnnotating:g,onHardReload:h,onZoomIn:v,onZoomOut:S,onZoomReset:j,zoomPercent:N,onClearCookies:C,onClearCache:B,onToggleDeviceBar:W,isDeviceBarOpen:F}=t;let $;e[0]!==r?($=r===void 0?[]:r,e[0]=r,e[1]=$):$=e[1];const K=$,I=p===void 0?!0:p,z=N===void 0?100:N,{t:k}=vt(),[M,V]=l.useState(!1),[O,E]=l.useState(-1);let R;e[2]!==M||e[3]!==K?(R=M?K:[],e[2]=M,e[3]=K,e[4]=R):R=e[4];const _=R;let U;e[5]===Symbol.for("react.memo_cache_sentinel")?(U=()=>{E(-1)},e[5]=U):U=e[5];let me;e[6]!==n||e[7]!==M?(me=[n,M],e[6]=n,e[7]=M,e[8]=me):me=e[8],l.useEffect(U,me);let ce;e[9]!==d?(ce=Me=>{V(!1),E(-1),d(Me)},e[9]=d,e[10]=ce):ce=e[10];const oe=ce;let ie;e[11]!==O||e[12]!==oe||e[13]!==_?(ie=Me=>{if(_.length!==0){if(Me.key==="ArrowDown"||Me.key==="ArrowUp"){Me.preventDefault();const tt=Me.key==="ArrowDown"?1:-1,nt=_.length;E(Qe=>{const _e=Qe+tt;return _e<-1?nt-1:_e>=nt?-1:_e});return}if(Me.key==="Escape"&&O>=0){Me.preventDefault(),E(-1);return}if(Me.key==="Enter"&&O>=0){Me.preventDefault();const tt=_[O];tt&&oe(tt.url)}}},e[11]=O,e[12]=oe,e[13]=_,e[14]=ie):ie=e[14];const xe=ie;let G;e[15]!==k?(G=k("contextPanel.browser.back"),e[15]=k,e[16]=G):G=e[16];const pe=!m;let J;e[17]!==a||e[18]!==G||e[19]!==pe?(J=s.jsx(an,{icon:"arrow-left",label:G,onClick:a,disabled:pe}),e[17]=a,e[18]=G,e[19]=pe,e[20]=J):J=e[20];let ge;e[21]!==k?(ge=k("contextPanel.browser.forward"),e[21]=k,e[22]=ge):ge=e[22];const de=!y;let Ae;e[23]!==c||e[24]!==ge||e[25]!==de?(Ae=s.jsx(an,{icon:"arrow-right",label:ge,onClick:c,disabled:de}),e[23]=c,e[24]=ge,e[25]=de,e[26]=Ae):Ae=e[26];let he;e[27]!==x||e[28]!==k?(he=k(x?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=x,e[28]=k,e[29]=he):he=e[29];let Re;e[30]!==u||e[31]!==he?(Re=s.jsx(an,{icon:"refresh",label:he,onClick:u}),e[30]=u,e[31]=he,e[32]=Re):Re=e[32];let se;e[33]!==h||e[34]!==k?(se=h?s.jsx(an,{icon:"restart",label:k("contextPanel.browser.hardReload"),onClick:h}):null,e[33]=h,e[34]=k,e[35]=se):se=e[35];let Ne;e[36]!==n||e[37]!==oe?(Ne=Me=>{Me.preventDefault(),oe(n)},e[36]=n,e[37]=oe,e[38]=Ne):Ne=e[38];let be;e[39]!==i?(be=Me=>i(Me.target.value),e[39]=i,e[40]=be):be=e[40];let we,ye;e[41]===Symbol.for("react.memo_cache_sentinel")?(we=()=>V(!0),ye=()=>V(!1),e[41]=we,e[42]=ye):(we=e[41],ye=e[42]);const Pe=_.length>0;let Oe;e[43]===Symbol.for("react.memo_cache_sentinel")?(Oe=Se("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]=Oe):Oe=e[43];let $e;e[44]!==k?($e=k("contextPanel.browser.addressAria"),e[44]=k,e[45]=$e):$e=e[45];let ze;e[46]!==n||e[47]!==xe||e[48]!==be||e[49]!==Pe||e[50]!==$e?(ze=s.jsx("input",{value:n,onChange:be,onFocus:we,onBlur:ye,onKeyDown:xe,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Pe,"aria-controls":"openchamber-browser-address-suggestions",className:Oe,"aria-label":$e}),e[46]=n,e[47]=xe,e[48]=be,e[49]=Pe,e[50]=$e,e[51]=ze):ze=e[51];let Ue;e[52]!==o?(Ue=Me=>o?.(Me),e[52]=o,e[53]=Ue):Ue=e[53];let q;e[54]!==O||e[55]!==oe||e[56]!==Ue||e[57]!==_?(q=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(O1,{entries:_,activeIndex:O,onSelect:oe,onForget:Ue,onHighlight:E})}),e[54]=O,e[55]=oe,e[56]=Ue,e[57]=_,e[58]=q):q=e[58];let ue;e[59]!==Ne||e[60]!==ze||e[61]!==q?(ue=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:Ne,children:[ze,q]}),e[59]=Ne,e[60]=ze,e[61]=q,e[62]=ue):ue=e[62];let A;e[63]!==v||e[64]!==S||e[65]!==j||e[66]!==k||e[67]!==z?(A=S&&v?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(an,{icon:"subtract",label:k("contextPanel.browser.zoomOut"),onClick:S}),z!==100&&j?s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsxs(ut,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:j,"aria-label":k("contextPanel.browser.zoomReset"),children:[z,"%"]})}),s.jsx(jt,{sideOffset:6,children:k("contextPanel.browser.zoomReset")})]}):null,s.jsx(an,{icon:"add",label:k("contextPanel.browser.zoomIn"),onClick:v})]}):null,e[63]=v,e[64]=S,e[65]=j,e[66]=k,e[67]=z,e[68]=A):A=e[68];let Q;e[69]!==C||e[70]!==k?(Q=C?s.jsx(an,{icon:"delete-bin",label:k("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=k,e[71]=Q):Q=e[71];let le;e[72]!==B||e[73]!==k?(le=B?s.jsx(an,{icon:"database-2",label:k("contextPanel.browser.clearCache"),onClick:B}):null,e[72]=B,e[73]=k,e[74]=le):le=e[74];let Ie;e[75]!==F||e[76]!==W||e[77]!==k?(Ie=W?s.jsx(an,{icon:"smartphone",label:k("contextPanel.browser.deviceToolbar"),onClick:W,pressed:F}):null,e[75]=F,e[76]=W,e[77]=k,e[78]=Ie):Ie=e[78];let re;e[79]!==g||e[80]!==w||e[81]!==k?(re=w?s.jsx(an,{icon:"markup",label:k("contextPanel.browser.annotate.toggle"),onClick:w,pressed:g}):null,e[79]=g,e[80]=w,e[81]=k,e[82]=re):re=e[82];let H;e[83]!==b||e[84]!==k?(H=b?s.jsx(an,{icon:"terminal-box",label:k("contextPanel.browser.devTools"),onClick:b}):null,e[83]=b,e[84]=k,e[85]=H):H=e[85];let ne;e[86]!==k?(ne=k("contextPanel.browser.openExternal"),e[86]=k,e[87]=ne):ne=e[87];const X=!I;let fe;e[88]!==f||e[89]!==ne||e[90]!==X?(fe=s.jsx(an,{icon:"external-link",label:ne,onClick:f,disabled:X}),e[88]=f,e[89]=ne,e[90]=X,e[91]=fe):fe=e[91];let Fe;return e[92]!==J||e[93]!==Ae||e[94]!==Re||e[95]!==se||e[96]!==ue||e[97]!==A||e[98]!==Q||e[99]!==le||e[100]!==Ie||e[101]!==re||e[102]!==H||e[103]!==fe?(Fe=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[J,Ae,Re,se,ue,A,Q,le,Ie,re,H,fe]}),e[92]=J,e[93]=Ae,e[94]=Re,e[95]=se,e[96]=ue,e[97]=A,e[98]=Q,e[99]=le,e[100]=Ie,e[101]=re,e[102]=H,e[103]=fe,e[104]=Fe):Fe=e[104],Fe},ri={kind:"fill"},Xc=240,B1=3840,ip=[{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}],Jc=t=>Number.isFinite(t)?Math.round(Math.min(B1,Math.max(Xc,t))):Xc,oi=t=>t.kind==="fill"?null:{width:t.width,height:t.height},ap=t=>{const e=ip.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},F1=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},L1=(t,e)=>{const n=oi(t);if(!n)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/n.width,o/n.height);return{width:n.width,height:n.height,scale:i}},$1=["mobile","tablet","desktop","fill"],_1={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Zc=t=>typeof t=="string"&&$1.includes(t),Ra=t=>t==="fill"?ri:ap(_1[t])??ri,No=t=>{const e=oi(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=Ra(n),o=oi(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},K1=t=>{const e=He.c(70),{viewport:n,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:d}=t,{t:a}=vt();let c;e[0]!==n?(c=oi(n),e[0]=n,e[1]=c):c=e[1];const u=c,f=n.kind==="preset"?n.id:"";let p;e[2]!==r||e[3]!==u?(p=(xe,G)=>{const pe=Number.parseInt(G,10);if(!Number.isFinite(pe))return;const J=u??{width:1280,height:800};r({kind:"custom",width:Jc(xe==="width"?pe:J.width),height:Jc(xe==="height"?pe:J.height)})},e[2]=r,e[3]=u,e[4]=p):p=e[4];const m=p;let y;e[5]===Symbol.for("react.memo_cache_sentinel")?(y=Se("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]=y):y=e[5];const x=y;let w;e[6]!==r?(w=xe=>{const G=ap(xe.target.value);r(G??ri)},e[6]=r,e[7]=w):w=e[7];let b;e[8]!==a?(b=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=b):b=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=Se("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]=g):g=e[10];let h;e[11]!==a?(h=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=h):h=e[12];let v;e[13]!==h?(v=s.jsx("option",{value:"",children:h}),e[13]=h,e[14]=v):v=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=ip.map(W1),e[15]=S):S=e[15];let j;e[16]!==f||e[17]!==w||e[18]!==b||e[19]!==v?(j=s.jsxs("select",{value:f,onChange:w,"aria-label":b,className:g,children:[v,S]}),e[16]=f,e[17]=w,e[18]=b,e[19]=v,e[20]=j):j=e[20];const N=u?String(u.width):"";let C;e[21]!==m?(C=xe=>m("width",xe.target.value),e[21]=m,e[22]=C):C=e[22];let B;e[23]!==a?(B=a("contextPanel.browser.device.width"),e[23]=a,e[24]=B):B=e[24];let W;e[25]!==N||e[26]!==C||e[27]!==B?(W=s.jsx("input",{value:N,onChange:C,placeholder:"—",inputMode:"numeric","aria-label":B,className:x}),e[25]=N,e[26]=C,e[27]=B,e[28]=W):W=e[28];let F;e[29]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=F):F=e[29];const $=u?String(u.height):"";let K;e[30]!==m?(K=xe=>m("height",xe.target.value),e[30]=m,e[31]=K):K=e[31];let I;e[32]!==a?(I=a("contextPanel.browser.device.height"),e[32]=a,e[33]=I):I=e[33];let z;e[34]!==$||e[35]!==K||e[36]!==I?(z=s.jsx("input",{value:$,onChange:K,placeholder:"—",inputMode:"numeric","aria-label":I,className:x}),e[34]=$,e[35]=K,e[36]=I,e[37]=z):z=e[37];let k;e[38]!==r||e[39]!==n?(k=()=>r(F1(n)),e[38]=r,e[39]=n,e[40]=k):k=e[40];const M=!u;let V;e[41]!==a?(V=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=V):V=e[42];let O;e[43]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(T,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=O):O=e[43];let E;e[44]!==k||e[45]!==M||e[46]!==V?(E=s.jsx(Nt,{asChild:!0,children:s.jsx(ut,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:k,disabled:M,"aria-label":V,children:O})}),e[44]=k,e[45]=M,e[46]=V,e[47]=E):E=e[47];let R;e[48]!==a?(R=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=R):R=e[49];let _;e[50]!==R?(_=s.jsx(jt,{sideOffset:6,children:R}),e[50]=R,e[51]=_):_=e[51];let U;e[52]!==E||e[53]!==_?(U=s.jsxs(Ct,{children:[E,_]}),e[52]=E,e[53]=_,e[54]=U):U=e[54];let me;e[55]!==d||e[56]!==u?(me=u&&d<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(d*100),"%"]}):null,e[55]=d,e[56]=u,e[57]=me):me=e[57];let ce;e[58]===Symbol.for("react.memo_cache_sentinel")?(ce=["system","light","dark"],e[58]=ce):ce=e[58];let oe;e[59]!==o||e[60]!==i||e[61]!==a?(oe=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ce.map(xe=>s.jsx(ut,{type:"button",variant:o===xe?"secondary":"ghost",size:"xs",className:Se("shrink-0 rounded-full px-2.5 typography-micro",o===xe?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(xe),"aria-pressed":o===xe,children:a(xe==="system"?"contextPanel.browser.device.schemeSystem":xe==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},xe))}),e[59]=o,e[60]=i,e[61]=a,e[62]=oe):oe=e[62];let ie;return e[63]!==j||e[64]!==W||e[65]!==z||e[66]!==U||e[67]!==me||e[68]!==oe?(ie=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[j,W,F,z,U,me,oe]}),e[63]=j,e[64]=W,e[65]=z,e[66]=U,e[67]=me,e[68]=oe,e[69]=ie):ie=e[69],ie};function W1(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const lp="oc.browser.hiddenDevServerPorts.v1",z1=xl(qn(),Si(Oy().int().positive())),Ma=new Set,cp=[];let Ao=null;const Cl=()=>{const t=au().getItem(lp);if(Ao&&Ao.raw===t)return Ao.value;let e={};if(t!==null)try{const n=z1.safeParse(JSON.parse(t));n.success&&(e=n.data)}catch{e={}}return Ao={raw:t,value:e},e},dp=t=>{au().setItem(lp,JSON.stringify(t));for(const e of Ma)e()},V1=(t=ss())=>Cl()[t]??cp,U1=t=>{const e=ss(),n=Cl(),r=n[e]??[];r.includes(t)||dp({...n,[e]:[...r,t].sort((o,i)=>o-i)})},H1=()=>{const t=ss(),e=Cl();if(!e[t])return;const n={...e};delete n[t],dp(n)},G1=t=>(Ma.add(t),()=>{Ma.delete(t)}),q1=()=>l.useSyncExternalStore(G1,Y1,Q1);function Y1(){return V1()}function Q1(){return cp}const X1=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},J1=2e3,Z1=()=>mu("http://localhost"),up=t=>{const e=He.c(40),{onOpen:n,directory:r}=t,o=r===void 0?"":r,{t:i}=vt();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={kind:"loading"},e[0]=d):d=e[0];const[a,c]=l.useState(d),u=Zy(o),[f]=l.useState(Z1);let p,m;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{let I=!0,z=null;const k=new AbortController,M=()=>{$S(k.signal).then(V=>{I&&(c(V),z=setTimeout(M,J1))})};return M(),()=>{I=!1,z&&clearTimeout(z),k.abort()}},m=[],e[1]=p,e[2]=m):(p=e[1],m=e[2]),l.useEffect(p,m);const y=a.kind==="ready"?a.servers:null;let x;e[3]!==u||e[4]!==y?(x=WS({announced:u,discovered:y}),e[3]=u,e[4]=y,e[5]=x):x=e[5];const w=x,b=q1();let g;if(e[6]!==w||e[7]!==b){let I;e[9]!==b?(I=z=>z.announced||!b.includes(z.port),e[9]=b,e[10]=I):I=e[10],g=w.filter(I),e[6]=w,e[7]=b,e[8]=g}else g=e[8];const h=g,v=w.length-h.length;let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Zu,{width:110,height:110,className:"shrink-0 opacity-20"}),e[11]=S):S=e[11];let j;e[12]!==i?(j=i("contextPanel.browser.empty"),e[12]=i,e[13]=j):j=e[13];let N;e[14]!==j?(N=s.jsx("span",{className:"typography-ui-header text-foreground",children:j}),e[14]=j,e[15]=N):N=e[15];let C;e[16]!==i?(C=i("contextPanel.browser.emptyHint"),e[16]=i,e[17]=C):C=e[17];let B;e[18]!==C?(B=s.jsx("span",{className:"typography-micro text-muted-foreground",children:C}),e[18]=C,e[19]=B):B=e[19];let W;e[20]!==N||e[21]!==B?(W=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[N,B]}),e[20]=N,e[21]=B,e[22]=W):W=e[22];let F;e[23]!==u||e[24]!==w.length||e[25]!==o||e[26]!==v||e[27]!==n||e[28]!==f||e[29]!==i||e[30]!==h?(F=w.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:u.length>0?i("contextPanel.browser.devServers.justStarted"):i("contextPanel.browser.devServers.title")}),f?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:h.map(I=>s.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[s.jsxs(ut,{type:"button",variant:"outline",size:"sm",className:"min-w-0 flex-1 justify-start gap-2",disabled:f,onClick:()=>{Qy(o),n(I.url)},children:[s.jsx(T,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:fi(I.url)||I.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:X1(I.url)})]}),I.announced?null:s.jsx(ut,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>U1(I.port),"aria-label":i("contextPanel.browser.devServers.hide",{port:I.port}),title:i("contextPanel.browser.devServers.hide",{port:I.port}),children:s.jsx(T,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},I.port))}),v>0?s.jsx(ut,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:H1,children:v===1?i("contextPanel.browser.devServers.showHiddenSingle",{count:v}):i("contextPanel.browser.devServers.showHiddenPlural",{count:v})}):null]}):null,e[23]=u,e[24]=w.length,e[25]=o,e[26]=v,e[27]=n,e[28]=f,e[29]=i,e[30]=h,e[31]=F):F=e[31];let $;e[32]!==w.length||e[33]!==a.kind||e[34]!==i?($=w.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.unavailable")}):null,e[32]=w.length,e[33]=a.kind,e[34]=i,e[35]=$):$=e[35];let K;return e[36]!==W||e[37]!==F||e[38]!==$?(K=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:[S,W,F,$]}),e[36]=W,e[37]=F,e[38]=$,e[39]=K):K=e[39],K},Gs=t=>Math.round(t),ej=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,c])=>`${a}="${c}"`).join(" "),o=t.ancestry.map(a=>a.selectorPart).join(" > "),i=t.computedStyle,d=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,o?`- Ancestry: ${o}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Gs(d.x)}, y=${Gs(d.y)}, width=${Gs(d.width)}, height=${Gs(d.height)}`,`- Styles: display=${i.display??""}; position=${i.position??""}; font=${i.fontWeight??""} ${i.fontSize??""} / ${i.lineHeight??""} ${i.fontFamily??""}; color=${i.color??""}; background=${i.backgroundColor??""}`].filter(a=>typeof a=="string")},tj=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Gs(n.x)}, y=${Gs(n.y)}, width=${Gs(n.width)}, height=${Gs(n.height)}`},sj=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Gs(n.x)}, y=${Gs(n.y)}, width=${Gs(n.width)}, height=${Gs(n.height)}`},nj=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),o=t.comment.trim(),i=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Gs(t.viewport.width)}x${Gs(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,o?`Comment: ${o}`:null];for(const[d,a]of t.elements.entries())i.push("",...ej(a.element,d));return t.regions.length>0&&(i.push(""),t.regions.forEach((d,a)=>i.push(tj(d,a)))),t.strokes.length>0&&(i.push(""),t.strokes.forEach((d,a)=>i.push(sj(d,a)))),i.filter(d=>typeof d=="string").join(`
|
|
994
|
-
`)},rj=t=>{const e=He.c(7),{t:n}=vt(),r=Je(ij),o=Je(aj),i=ca(lj),d=ib(cj);let a;return e[0]!==d||e[1]!==i||e[2]!==r||e[3]!==t||e[4]!==o||e[5]!==n?(a=async c=>{const u=r??(o?"draft":null);if(!u){Be.error(n("contextPanel.browser.annotate.noSession"));return}let f=!1;if(c.screenshot)try{await d(c.screenshot),f=!0}catch{f=!1}i({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:c.payload.pageUrl||"browser",startLine:1,endLine:1,code:nj({payload:c.payload,screenshotAttached:f,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Be.success(n("contextPanel.browser.annotate.attached")),requestAnimationFrame(ab)},e[0]=d,e[1]=i,e[2]=r,e[3]=t,e[4]=o,e[5]=n,e[6]=a):a=e[6],a},oj=()=>{const t=He.c(16),{t:e}=vt();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 o;t[4]!==e?(o=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=i):i=t[7];let d;t[8]!==e?(d=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=d):d=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==o||t[13]!==i||t[14]!==d?(a={select:n,marquee:r,draw:o,commentPlaceholder:i,submit:d},t[10]=n,t[11]=r,t[12]=o,t[13]=i,t[14]=d,t[15]=a):a=t[15],a};function ij(t){return t.currentSessionId}function aj(t){return t.newSessionDraft?.open}function lj(t){return t.addDraft}function cj(t){return t.addAttachedFile}const dj=3e4,uj=3,fj=250,pj={attempts:0,windowStartedAt:null},mj=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=dj,r=n?0:t.attempts;return r>=uj?null:{delayMs:fj*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},hj=-3,Po=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",Ir=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},gj=(t,{initialUrl:e,onUrlChange:n})=>{const[r,o]=l.useState(e?{kind:"loading",url:e}:US),[i,d]=l.useState(e),[a,c]=l.useState(""),[u,f]=l.useState(!1),[p,m]=l.useState(!1),y=l.useRef(n);y.current=n;const x=l.useRef(pj);return l.useEffect(()=>{if(!t)return;const w=()=>{try{const F=t.getURL();return Po(F)?F:""}catch{return""}},b=()=>{try{f(t.canGoBack()),m(t.canGoForward())}catch{}},g=F=>{Po(F)&&(d(F),y.current(F))},h=()=>{const F=w();o({kind:"loading",url:F})},v=()=>{const F=w();let $="";try{$=t.getTitle()||""}catch{$=""}c($),g(F),b(),o(K=>K.kind==="failed"?K:{kind:"ready",url:F,title:$})},S=F=>{const $=Ir(F);Po($.url)&&(g($.url),b())},j=F=>{const $=Ir(F),K=Array.isArray($.favicons)?$.favicons.find(Boolean):"",I=w();K&&I&&Yf.getState().resolve(I,K)},N=F=>{const $=Ir(F);typeof $.title=="string"&&c($.title)},C=F=>{const $=Ir(F);if($.isMainFrame===!1)return;const K=typeof $.errorCode=="number"?$.errorCode:0;K!==hj&&o({kind:"failed",url:Po($.validatedURL)?$.validatedURL:w(),code:K,description:typeof $.errorDescription=="string"?$.errorDescription:""})};let B=null;const W=()=>{const F=w(),$=mj(x.current,Date.now());if(!$){o({kind:"failed",url:F,code:0,description:"",crashed:!0});return}x.current=$.state,o({kind:"loading",url:F}),B=setTimeout(()=>{B=null;try{t.reload()}catch{o({kind:"failed",url:F,code:0,description:"",crashed:!0})}},$.delayMs)};t.addEventListener("did-start-loading",h),t.addEventListener("did-stop-loading",v),t.addEventListener("did-navigate",S),t.addEventListener("did-navigate-in-page",S),t.addEventListener("page-title-updated",N),t.addEventListener("page-favicon-updated",j),t.addEventListener("did-fail-load",C),t.addEventListener("render-process-gone",W),t.addEventListener("crashed",W);try{!t.isLoading()&&w()&&v()}catch{}return()=>{B!==null&&clearTimeout(B),t.removeEventListener("render-process-gone",W),t.removeEventListener("crashed",W),t.removeEventListener("did-start-loading",h),t.removeEventListener("did-stop-loading",v),t.removeEventListener("did-navigate",S),t.removeEventListener("did-navigate-in-page",S),t.removeEventListener("page-title-updated",N),t.removeEventListener("page-favicon-updated",j),t.removeEventListener("did-fail-load",C)}},[t]),{status:r,url:i,title:a,canGoBack:u,canGoForward:p}},bj=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Io=.5,xj=-3,yj=4,vj="persist:openchamber-browser",ed=20,wj=600,Sj=2e4,jj=15e3,kj=t=>{if(!t)return()=>{};const e=t.getBoundingClientRect();if(e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0}))return()=>{};const r=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${e.top}px`,left:`${Math.max(0,Math.min(e.left,window.innerWidth-e.width))}px`,width:`${e.width}px`,height:`${e.height}px`,visibility:"visible",opacity:"0",pointerEvents:"none"}),()=>{t.style.cssText=r}},Cj=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=vt(),{currentTheme:o}=uo(),i=l.useRef(null),[d,a]=l.useState(null),c=l.useCallback(H=>{i.current=H,a(H)},[]),u=Ce(H=>H.setContextPanelTabTargetPath),f=l.useRef(Dr(t)),p=f.current!==_n?f.current:"",[m,y]=l.useState(p?null:_n),[x,w]=l.useState(p),[b,g]=l.useState(!1),[h,v]=l.useState(!1),[S,j]=l.useState(0),N=l.useRef(0),[C,B]=l.useState(!1),[W,F]=l.useState(ri),$=l.useRef(W);$.current=W;const K=l.useRef([]),[I,z]=l.useState("system"),[k,M]=l.useState({width:0,height:0}),V=l.useRef(null),O=l.useRef(null),E=Kn(e),R=l.useRef(!!p&&!Nm(E,n));l.useEffect(()=>{lu(E,n)},[E,n]);const _=l.useRef(!1),U=l.useRef(Date.now()),me=l.useCallback(H=>{!H||H===_n||!e||!n||u(e,n,H)},[e,n,u]),ce=gj(d,{initialUrl:p,onUrlChange:l.useCallback(H=>{const ne=Sr(H);w(ne),me(ne)},[me])}),[oe,ie]=l.useState(null),xe=rj(e),G=oj(),pe=ce.status.kind==="loading",J=Rr(rp(e)),ge=Rr(H=>H.recordVisit),de=Rr(H=>H.forget);l.useEffect(()=>{ce.status.kind==="ready"&&ge(e,{url:Sr(ce.status.url),title:ce.status.title})},[e,ce.status,ge]);const Ae=l.useMemo(()=>np(J,x),[J,x]),he=l.useCallback(H=>{const ne=Dr(H);ne!==_n&&(R.current=!1,w(ne),ie(null),Ql(ne).then(X=>{const fe=i.current;if(!fe){y(X);return}try{fe.loadURL(X)}catch{y(X)}}).catch(X=>{X instanceof Xl&&ie(ne)}))},[]);l.useEffect(()=>{if(!p)return;let H=!0;return Ql(p).then(ne=>{H&&y(ne)}).catch(ne=>{if(H){if(ne instanceof Xl){ie(p),R.current=!1,y(_n);return}y(p)}}),()=>{H=!1}},[]);const Re=l.useMemo(()=>({executeJavaScript:async(H,ne)=>{const X=i.current;if(!X)throw new Error("Browser view is not available");return X.executeJavaScript(H,ne)},capturePage:async()=>{const H=i.current;if(!H)return null;const ne=H.getWebContentsId();return Number.isFinite(ne)?await zo("desktop_browser_capture_page",{webContentsId:ne}):null}}),[]),se=l.useCallback(()=>{if(b){g(!1),Ho(Re);return}if(!ce.url){Be.error(r("contextPanel.browser.annotate.noPage"));return}const H=o1(o.metadata.variant==="light"?"light":"dark");g(!0),n1({host:Re,theme:H,labels:G}).then(async ne=>{g(!1),ne&&await xe(ne)}).catch(()=>{g(!1),Be.error(r("contextPanel.browser.annotate.failed"))})},[Re,xe,o,b,ce.url,G,r]);l.useEffect(()=>{if(!b)return;const H=ne=>{lb(ne)||ne.key!=="Escape"||(ne.preventDefault(),ne.stopImmediatePropagation(),g(!1),Ho(Re))};return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[Re,b]);const Ne=l.useRef(!1);l.useEffect(()=>{if(!d)return;const H=()=>{Ne.current=!0};return d.addEventListener("dom-ready",H),d.addEventListener("did-fail-load",H),()=>{d.removeEventListener("dom-ready",H),d.removeEventListener("did-fail-load",H)}},[d]);const be=l.useCallback(async()=>{const H=Date.now()+jj;for(;!(i.current&&Ne.current)&&Date.now()<H;)await new Promise(ne=>setTimeout(ne,100));return i.current},[]),we=l.useCallback(async(H=8e3)=>{const ne=Date.now();for(;;){const X=i.current;if(!X)return!1;let fe=!1;try{fe=X.isLoading()}catch{return!1}if(!fe)return!0;if(Date.now()-ne>H)return!1;await new Promise(Fe=>setTimeout(Fe,120))}},[]),ye=l.useCallback(async(H,ne)=>{const X=await be();if(!X)throw new Error("The browser panel is not ready");const fe=()=>{Zc(ne.viewport)&&(F(Ra(ne.viewport)),B(!0))};if(H==="browser.back"||H==="browser.forward"){const _e=H==="browser.back";if(!(_e?X.canGoBack():X.canGoForward()))throw new Error(_e?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");_e?X.goBack():X.goForward(),await new Promise(gt=>setTimeout(gt,150)),await we();let ct="";try{ct=X.getTitle()||""}catch{ct=""}return{url:Sr(X.getURL()),title:ct}}if(H==="browser.capture"){const _e=kj(V.current);try{await new Promise(gt=>{requestAnimationFrame(()=>requestAnimationFrame(()=>gt()))}),await we();const wt=await Re.capturePage();if(!wt)throw new Error("The page could not be captured");let ct="";try{ct=X.getTitle()||""}catch{ct=""}return{...wt,url:Sr(X.getURL()),title:ct,viewport:No($.current)}}finally{_e()}}if(H==="browser.resize"){if(!Zc(ne.viewport))throw new Error("viewport is required");return fe(),await new Promise(_e=>setTimeout(_e,200)),await we(),{viewport:No(Ra(ne.viewport))}}if(H==="browser.open"){const _e=typeof ne.url=="string"?ne.url:"";if(!_e)throw new Error("url is required");fe(),he(_e),await new Promise(gt=>setTimeout(gt,150));const wt=await we(25e3);let ct="";try{ct=X.getTitle()||""}catch{ct=""}return{url:Dr(_e),title:ct,opened:!0,settled:wt,viewport:No($.current)}}await we();const Fe=_e=>typeof _e=="string"&&_e?_e:void 0,tt=(()=>{switch(H){case"browser.snapshot":return I1({selector:Fe(ne.selector)});case"browser.click":return D1({selector:Fe(ne.selector),text:Fe(ne.text)});case"browser.type":return E1({selector:String(ne.selector??""),value:String(ne.value??""),submit:ne.submit===!0});case"browser.inspect":return T1({selector:String(ne.selector??"")});case"browser.scroll":return R1({selector:Fe(ne.selector),direction:Fe(ne.direction)});default:return null}})();if(!tt)throw new Error(`Unsupported browser action: ${H}`);(H==="browser.click"||H==="browser.type")&&X.focus({preventScroll:!0});const nt=await X.executeJavaScript(tt,!0);if(!nt||typeof nt!="object")throw new Error("The page returned no result");const Qe=nt;if(Qe.ok!==!0)throw new Error(typeof Qe.error=="string"&&Qe.error?Qe.error:"Browser action failed");if(H==="browser.snapshot"){const _e=K.current;return{...Qe,viewport:No($.current),..._e.length>0?{consoleProblems:[..._e]}:{}}}return(H==="browser.click"||H==="browser.type"&&ne.submit===!0)&&(await new Promise(_e=>setTimeout(_e,150)),await we()),nt},[Re,he,we,be]),Pe=l.useCallback(()=>{const H=i.current;if(!H)return{title:"",url:""};let ne="",X="";try{ne=H.getTitle()||""}catch{ne=""}try{X=Sr(H.getURL())}catch{X=""}return{title:ne,url:X}},[]);l.useEffect(()=>p1({tabId:n,describe:Pe,run:ye}),[Pe,ye,n]),l.useEffect(()=>{const H=Re;return()=>{Ho(H)}},[Re]),l.useEffect(()=>{if(!d)return;const H=X=>{const fe=X;if(typeof fe.level!="number"||fe.level<2)return;const Fe=fe.sourceId?`${fe.sourceId}${fe.line?`:${fe.line}`:""}`:"";K.current.push({level:fe.level>=3?"error":"warning",message:String(fe.message??"").slice(0,400),source:Fe}),K.current.length>ed&&K.current.splice(0,K.current.length-ed)},ne=()=>{K.current=[]};return d.addEventListener("console-message",H),d.addEventListener("did-start-loading",ne),()=>{d.removeEventListener("console-message",H),d.removeEventListener("did-start-loading",ne)}},[d]);const Oe=l.useRef(new Set),$e=l.useCallback(H=>{Oe.current.clear(),he(H)},[he]),ze=l.useRef(ce.status);ze.current=ce.status;const Ue=l.useRef(!1);ce.status.kind==="ready"&&ce.status.url&&(Ue.current=!0),l.useEffect(()=>Am(E,n,H=>{Dm(ze.current,Ue.current)&&$e(H)}),[$e,E,n]),l.useEffect(()=>{if(!d)return;const H=X=>{const fe=Ir(X),Fe=typeof fe.url=="string"?fe.url:"";!Fe||!Jl(Fe)||(X.preventDefault(),he(Fe))},ne=X=>{const fe=Ir(X);if(fe.isMainFrame===!1||fe.errorCode===-3)return;const Fe=typeof fe.validatedURL=="string"?fe.validatedURL:"";!Fe||!Jl(Fe)||Oe.current.has(Fe)||(Oe.current.add(Fe),he(Fe))};return d.addEventListener("will-navigate",H),d.addEventListener("did-fail-load",ne),()=>{d.removeEventListener("will-navigate",H),d.removeEventListener("did-fail-load",ne)}},[he,d]),l.useEffect(()=>{if(!d)return;const H=ne=>{const X=ne.detail;ne.preventDefault(),X?.url&&he(X.url)};return d.addEventListener("new-window",H),()=>d.removeEventListener("new-window",H)},[he,d]);const q=l.useCallback(H=>{const ne=Math.min(yj,Math.max(xj,H));N.current=ne,j(ne);try{i.current?.setZoomLevel(ne)}catch{}},[]);l.useEffect(()=>{const H=ne=>{if(!(ne instanceof CustomEvent))return;const X=ne.detail,fe=i.current;!fe||document.activeElement!==fe||(X==="zoom-in"?q(N.current+Io):X==="zoom-out"?q(N.current-Io):X==="zoom-reset"&&q(0))};return window.addEventListener("openchamber:zoom",H),()=>window.removeEventListener("openchamber:zoom",H)},[q]);const ue=l.useCallback(H=>{zo("desktop_browser_clear_data",{partition:vj,cookies:H==="cookies",cache:H==="cache"}).then(()=>{Be.success(r(H==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{i.current?.reloadIgnoringCache()}catch{}}).catch(()=>Be.error(r("contextPanel.browser.clearFailed")))},[r]);l.useEffect(()=>{const H=V.current;if(!H||typeof ResizeObserver>"u")return;const ne=new ResizeObserver(X=>{const fe=X[0]?.contentRect;fe&&M({width:fe.width,height:fe.height})});return ne.observe(H),()=>ne.disconnect()},[]);const A=l.useCallback(H=>{z(H);const ne=i.current;if(!ne)return;let X=-1;try{X=ne.getWebContentsId()}catch{return}zo("desktop_browser_set_color_scheme",{webContentsId:X,scheme:H}).catch(fe=>{z("system"),Be.error(fe instanceof Error?fe.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),Q=l.useCallback(()=>{try{pe?i.current?.stop():i.current?.reload()}catch{}},[pe]),le=ce.status;l.useEffect(()=>{const H=()=>{v(!0);const Fe=setTimeout(()=>{try{i.current?.reload()}catch{}},wj);return()=>clearTimeout(Fe)};if(le.kind==="loading")return;const ne=R.current;if((le.kind==="failed"||le.kind==="ready"&&le.url)&&(R.current=!1),le.kind==="failed"){const Fe=Pm(le,{run:O.current,restored:ne,now:Date.now()});if(O.current=Fe.run,!Fe.retry){v(!1);return}return H()}if(O.current=null,le.kind!=="ready"||!le.url||!Im(le.url)){_.current=!0,v(!1);return}if(ne||_.current||Date.now()-U.current>Sj){_.current=!0,v(!1);return}let X=!1,fe=null;return _S(Sr(le.url)).then(Fe=>{if(!X){if(Fe===null||Fe<500){_.current=!0,v(!1);return}fe=H()}}),()=>{X=!0,fe?.()}},[le]);const Ie=ce.status.kind==="failed"&&!h?ce.status:null,re=L1(W,k);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(op,{address:x,onAddressChange:w,onSubmit:$e,suggestions:Ae,onForgetSuggestion:H=>de(e,H),onBack:()=>{try{i.current?.goBack()}catch{}},onForward:()=>{try{i.current?.goForward()}catch{}},onReload:Q,onOpenExternal:()=>{Gn(ce.url||x)},canGoBack:ce.canGoBack,canGoForward:ce.canGoForward,isLoading:pe,onAnnotate:se,isAnnotating:b,onOpenDevTools:()=>{try{i.current?.openDevTools()}catch{}},onHardReload:()=>{try{i.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>q(S+Io),onZoomOut:()=>q(S-Io),onZoomReset:()=>q(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>ue("cookies"),onClearCache:()=>ue("cache"),onToggleDeviceBar:()=>B(H=>!H),isDeviceBarOpen:C}),C?s.jsx(K1,{viewport:W,onViewportChange:F,colorScheme:I,onColorSchemeChange:A,scale:re?.scale??1}):null,s.jsxs("div",{ref:V,className:Se("relative min-h-0 flex-1 bg-background",re&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[m!==null?s.jsx("webview",{ref:c,src:m,partition:"persist:openchamber-browser",allowpopups:!0,style:re?{width:`${re.width}px`,height:`${re.height}px`,transform:`scale(${re.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,m!==null&&!p&&!ce.url&&!pe?s.jsx(up,{onOpen:$e,directory:e}):null,h?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,oe?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:oe})})]}):null,Ie&&!oe?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:Ie.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:Ie.crashed?r("contextPanel.browser.crashedHint"):Ie.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,pe?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]})]})},Nj=t=>{const e=He.c(60),{initialUrl:n,directory:r,tabID:o}=t,{t:i}=vt(),d=Ce(Pj);let a;e[0]!==n?(a=Dr(n),e[0]=n,e[1]=a):a=e[1];const c=a,u=c!==_n?c:"",[f,p]=l.useState(u);let m;e[2]!==u?(m=Ti(u),e[2]=u,e[3]=m):m=e[3];const[y,x]=l.useState(m);let w;e[4]!==u?(w=mu(u)?u:"",e[4]=u,e[5]=w):w=e[5];const[b,g]=l.useState(w);let h;e[6]!==u?(h=u?[u]:[],e[6]=u,e[7]=h):h=e[7];const[v,S]=l.useState(h),[j,N]=l.useState(u?0:-1),[C,B]=l.useReducer(Ij,0);let W,F;e[8]!==r||e[9]!==o?(W=()=>{lu(Kn(r),o)},F=[r,o],e[8]=r,e[9]=o,e[10]=W,e[11]=F):(W=e[10],F=e[11]),l.useEffect(W,F);let $;e[12]!==r||e[13]!==d||e[14]!==o?($=Ae=>{!Ae||Ae===_n||!r||!o||d(r,o,Ae)},e[12]=r,e[13]=d,e[14]=o,e[15]=$):$=e[15];const K=$;let I;e[16]!==r?(I=rp(r),e[16]=r,e[17]=I):I=e[17];const z=Rr(I),k=Rr(Dj),M=Rr(Ej);let V;e[18]!==f||e[19]!==z?(V=np(z,f),e[18]=f,e[19]=z,e[20]=V):V=e[20];const O=V;let E;e[21]!==r||e[22]!==j||e[23]!==K||e[24]!==k?(E=Ae=>{const he=Dr(Ae);if(he===_n)return;p(he);const Re=Ti(he);x(Re),g(Re?"":he),K(he),k(r,{url:he}),S(se=>{const Ne=j>=0?se.slice(0,j+1):[];return Ne[Ne.length-1]===he?(N(Ne.length-1),Ne):(N(Ne.length),[...Ne,he])})},e[21]=r,e[22]=j,e[23]=K,e[24]=k,e[25]=E):E=e[25];const R=E;let _;e[26]!==v||e[27]!==K?(_=Ae=>{const he=v[Ae];if(!he)return;N(Ae),p(he);const Re=Ti(he);x(Re),g(Re?"":he),K(he)},e[26]=v,e[27]=K,e[28]=_):_=e[28];const U=_;let me;e[29]!==r||e[30]!==M?(me=Ae=>M(r,Ae),e[29]=r,e[30]=M,e[31]=me):me=e[31];let ce,oe;e[32]!==U||e[33]!==j?(ce=()=>U(j-1),oe=()=>U(j+1),e[32]=U,e[33]=j,e[34]=ce,e[35]=oe):(ce=e[34],oe=e[35]);let ie;e[36]!==f||e[37]!==y?(ie=()=>{Gn(y||f)},e[36]=f,e[37]=y,e[38]=ie):ie=e[38];const xe=!b,G=j>0,pe=j>=0&&j<v.length-1;let J;e[39]!==f||e[40]!==R||e[41]!==O||e[42]!==me||e[43]!==ce||e[44]!==oe||e[45]!==ie||e[46]!==xe||e[47]!==G||e[48]!==pe?(J=s.jsx(op,{address:f,onAddressChange:p,onSubmit:R,suggestions:O,onForgetSuggestion:me,onBack:ce,onForward:oe,onReload:B,onOpenExternal:ie,canOpenExternal:xe,canGoBack:G,canGoForward:pe,isLoading:!1}),e[39]=f,e[40]=R,e[41]=O,e[42]=me,e[43]=ce,e[44]=oe,e[45]=ie,e[46]=xe,e[47]=G,e[48]=pe,e[49]=J):J=e[49];let ge;e[50]!==r||e[51]!==y||e[52]!==R||e[53]!==C||e[54]!==i||e[55]!==b?(ge=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children: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:i("contextPanel.browser.remoteLoopback.title",{url:fi(b)})}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.remoteLoopback.hint")})]}):y?s.jsx("iframe",{src:y,title:i("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${y}|${C}`):s.jsx(up,{onOpen:R,directory:r})}),e[50]=r,e[51]=y,e[52]=R,e[53]=C,e[54]=i,e[55]=b,e[56]=ge):ge=e[56];let de;return e[57]!==J||e[58]!==ge?(de=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[J,ge]}),e[57]=J,e[58]=ge,e[59]=de):de=e[59],de},Aj=t=>{const e=He.c(3),[n]=l.useState(bj);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Cj,{...t}):s.jsx(Nj,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Pj(t){return t.setContextPanelTabTargetPath}function Ij(t){return t+1}function Dj(t){return t.recordVisit}function Ej(t){return t.forget}const Rj=hr(()=>Sn(()=>import("./WalkthroughView-ClBo7PPd.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,124,125,126])).then(t=>({default:t.WalkthroughView}))),Mj=hr(()=>Sn(()=>import("./DiffView-Ct7vL3fD.js"),__vite__mapDeps([127,1,2,4,5,6,7,8,9,86,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,83,84,85,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,128,115,116,117,118,119,120,121,129,122,123,124,125,126])).then(t=>({default:t.DiffView}))),Tj=hr(()=>Sn(()=>import("./FilesView-DT0uEYgT.js"),__vite__mapDeps([130,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,131,132,133,134,125,135,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,136,137,120,121,82,83,84,85,118,138,119,139])).then(t=>({default:t.FilesView}))),Oj=hr(()=>Sn(()=>import("./GitView-DzuzhIPx.js"),__vite__mapDeps([140,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,83,84,85,141,129,115,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,116,117,118,119,120,121,122,123,124,125,126])).then(t=>({default:t.GitView}))),Bj=hr(()=>Sn(()=>import("./LinearIssuesView-C10MwA9h.js"),__vite__mapDeps([142,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])).then(t=>({default:t.LinearIssuesView}))),Fj=hr(()=>Sn(()=>import("./PlanView-DsRWnsOI.js"),__vite__mapDeps([143,1,2,4,5,6,7,8,9,131,56,57,58,59,60,61,78,54,55,62,132,133,134,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,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,119,82,83,84,85,139,120,121,105,106,90,91,92,93,94,95,96,97,98,99,100,101,102,103])).then(t=>({default:t.PlanView}))),fp=l.lazy(()=>Sn(()=>import("./useAppFontEffects-DCqCVGlT.js").then(t=>t.mc),__vite__mapDeps([3,1,2,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])).then(t=>({default:t.PluginPane}))),pp={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-r border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-l border-border",vertical:!1}},Lj=t=>{const e=He.c(12),{mode:n,docking:r}=t,[o,i]=l.useState(null),d=pp[r.dock],a=Math.max(hb,o??r.size),c=d.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==d.page||e[1]!==c?(u=Se("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",c,d.page),e[0]=d.page,e[1]=c,e[2]=u):u=e[2];let f;e[3]!==d.vertical||e[4]!==a?(f=d.vertical?{height:a}:{width:a},e[3]=d.vertical,e[4]=a,e[5]=f):f=e[5];let p;e[6]!==n?(p=s.jsx(fp,{mode:n,onResize:i}),e[6]=n,e[7]=p):p=e[7];let m;return e[8]!==u||e[9]!==f||e[10]!==p?(m=s.jsx("div",{className:u,style:f,children:p}),e[8]=u,e[9]=f,e[10]=p,e[11]=m):m=e[11],m},td=l.lazy(()=>Sn(()=>import("./GuestSurfacePane-DVvk1VPu.js"),__vite__mapDeps([144,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])).then(t=>({default:t.GuestSurfacePane}))),mp=320,Nl=600,$j=400,_j=100,Kj=24,ii=new Map,Wj=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},sd=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(mp,Math.round(t))):Nl,nd=t=>{const e=t??(typeof window<"u"?window.innerWidth:Nl*2);return Math.max(mp,e-$j)},zj=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Vj=(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},hp=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):cr(t)?Xa.getState().guests.find(r=>r.id===Qo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),Uj=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},Hj=(t,e,n)=>{if(t.mode==="chat"){const r=Ta(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||n("contextPanel.mode.chat")}return t.mode==="browser"?fi(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Uj(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):hp(t.mode,n)},Gj=t=>{const e=He.c(8),{mode:n}=t,r=nl();let o;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=f=>f.mode===n,e[3]=n,e[4]=u):u=e[4],o=r.find(u),e[0]=n,e[1]=r,e[2]=o}else o=e[2];const i=o,d=i?.icon??gb,a=i?.iconSrc;let c;return e[5]!==d||e[6]!==a?(c=s.jsx(fo,{icon:d,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=d,e[6]=a,e[7]=c):c=e[7],c},rd=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(sl,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(Wf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(T,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(T,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(T,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(T,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(T,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(T,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(T,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(T,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(T,{name:"chat-4",className:"h-3.5 w-3.5"});if(cr(t.mode))return s.jsx(Gj,{mode:t.mode});if(t.mode==="browser"){const n=qj(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(T,{name:"global",className:"h-3.5 w-3.5"})}},qj=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Yj=({visible:t,active:e,fill:n=!1})=>{const{t:r}=vt(),o=Ce(h=>h.contextEditorTreeWidth),i=Ce(h=>h.setContextEditorTreeWidth),[d,a]=l.useState(!1),c=l.useRef(0),u=l.useRef(o),f=l.useRef(null),p=l.useRef(null),m=l.useRef(null),y=l.useCallback(h=>{const v=m.current;v&&(v.style.width=`${h}px`,v.style.setProperty("--oc-editor-tree-width",`${h}px`))},[]),x=h=>{if(t){try{h.currentTarget.setPointerCapture(h.pointerId)}catch{}p.current=h.pointerId,a(!0),c.current=h.clientX,u.current=o,f.current=o,h.preventDefault()}},w=h=>{if(!d||p.current!==h.pointerId)return;const v=c.current-h.clientX,S=sa(u.current+v);f.current!==S&&(f.current=S,y(S))},b=h=>{if(p.current!==h.pointerId)return;try{h.currentTarget.releasePointerCapture(h.pointerId)}catch{}const v=sa(f.current??o);p.current=null,f.current=null,a(!1),i(v)},g=t?o:0;return s.jsxs("div",{ref:m,className:Se("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${d?f.current??g:g}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${d?f.current??o:o}px`,overflowX:"clip",transitionProperty:d?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Se("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",d&&"bg-[var(--interactive-border)]"),onPointerDown:x,onPointerMove:w,onPointerUp:b,onPointerCancel:b,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Se("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(iS,{visible:t&&e})})]})},Ta=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Qj=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},Xj=(t,e)=>{if(e.length===0)return ii;const n=new Set(e),r=new Map;for(const o of t){if(!n.has(o.id))continue;const i=o.title?.trim();i&&r.set(o.id,i)}return r.size===0?ii:r},Jj=(t,e)=>{const n=mb(t),r=l.useRef(ii),o=l.useRef(e);return o.current=e,l.useSyncExternalStore(n.subscribe,l.useCallback(()=>{const i=Xj(n.getState().session,o.current);return Qj(r.current,i)?r.current:(r.current=i,i)},[n]),()=>ii)},Zj=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,e0=()=>{const{t}=vt(),e=fr()??"",n=ef(e||null),r=l.useCallback((D,je)=>t(zn(D,n),je),[n,t]),o=l.useMemo(()=>Wj(e),[e]),i=Ce(D=>o?D.contextPanelByDirectory[o]:void 0),d=Ce(D=>D.closeContextPanel),a=Ce(D=>D.closeContextPanelTab),c=Ce(D=>D.pinContextPanelTab),u=Ce(D=>D.openContextPanelTab),f=Ce(D=>D.toggleContextPanelExpanded),p=Ce(D=>D.setContextPanelWidth),m=Ce(D=>D.setActiveContextPanelTab),y=Ce(D=>D.openAgentBrowserTab),[x,w]=l.useState(()=>new Set),b=l.useCallback(D=>{w(je=>je.has(D)?je:new Set(je).add(D))},[]);l.useEffect(()=>{if(e)return g1(D=>{const je=y(e,D);return je&&b(je),je})},[e,y,b]);const g=Ce(D=>D.openContextFile);l.useEffect(()=>Qn(D=>{if(D.type!=="file-open-request")return;const je=D.directory??e;je&&g(je,D.path)}),[e,g]);const h=Ce(D=>D.reorderContextPanelTabs),v=xn(D=>D.setSelectedPath),S=Ce(D=>D.contextEditorTreeVisible),j=Ce(D=>D.contextEditorTreeWidth),N=Ce(D=>D.setContextEditorTreeWidth),C=Ce(D=>D.toggleContextEditorTree),B=Ce(D=>D.contextEditorVisible),W=Ce(D=>D.toggleContextEditor),F=Ce(D=>D.openNewContextBrowserTab),$=Yf(D=>D.byOrigin),K=l.useMemo(()=>i?.tabs??[],[i?.tabs]),I=K.find(D=>D.id===i?.activeTabId)??K[K.length-1]??null,z=I?.mode==="browser"?I.id:null;l.useEffect(()=>{z&&h1(z)},[z]);const k=!!(i?.isOpen&&I),[M,V]=l.useState(null),O=l.useMemo(()=>K.some(D=>D.mode==="file"&&D.targetPath),[K]),E=O&&(B||!S),R=I?.mode??null,_=R==="file"&&!E,U=!!(k&&i?.expanded&&!_),me=R?i?.widthByMode?.[R]:void 0,ce=R?i?.widthFractionByMode?.[R]:void 0,oe=R?cb(R):.5,ie=M??(typeof window<"u"?window.innerWidth:Nl*2),xe=ce!=null&&M!=null?Math.round(ce*M):me,G=_?j:sd(xe??Math.round(oe*ie),nd(M??ie));l.useEffect(()=>{!o||!R||_||ce!=null||me==null||M==null||p(o,R,me,M)},[R,M,o,_,me,ce,p]);const pe=l.useMemo(()=>{const D=[];for(const je of K){if(je.mode!=="chat")continue;const L=Ta(je.dedupeKey);L&&!D.includes(L)&&D.push(L)}return D},[K]),J=Jj(o||void 0,pe),[ge,de]=l.useState(!1),Ae=l.useRef(0),he=l.useRef(G),Re=l.useRef(null),se=l.useRef(null),Ne=l.useRef(null),be=l.useRef(!1);l.useLayoutEffect(()=>{const D=Ne.current?.parentElement;if(!D||typeof ResizeObserver>"u")return;const je=new ResizeObserver(()=>{V(D.clientWidth||null)});return je.observe(D),V(D.clientWidth||null),()=>je.disconnect()},[]),l.useEffect(()=>{if(!k||be.current){be.current=k;return}const D=window.requestAnimationFrame(()=>{Ne.current?.focus({preventScroll:!0})});return be.current=!0,()=>window.cancelAnimationFrame(D)},[k]);const we=l.useRef(null),ye=l.useRef(null),Pe=l.useCallback(()=>{ye.current=null;const D=Ne.current,je=Re.current;!D||je===null||D.style.setProperty("--oc-context-panel-width",`${je}px`)},[]);l.useEffect(()=>()=>{ye.current!==null&&clearTimeout(ye.current)},[]);const Oe=l.useCallback(D=>{const je=we.current,L=_?sa(D):sd(D,nd(je));return je===null?L:Math.min(L,Math.max(1,je))},[_]),$e=l.useCallback(D=>{!k||U||!o||(se.current=D.pointerId,de(!0),Ae.current=D.clientX,he.current=G,Re.current=G,we.current=zj(Ne.current),document.documentElement.style.cursor="col-resize",D.preventDefault())},[o,U,k,G]),ze=l.useCallback(()=>{const D=Oe(Re.current??G),je=we.current;Re.current=null,we.current=null,ye.current!==null&&(clearTimeout(ye.current),ye.current=null),document.documentElement.style.cursor="",_?N(D):o&&R&&p(o,R,D,je??void 0),de(!1),se.current=null},[R,Oe,o,_,N,p,G]);l.useEffect(()=>{if(!ge)return;const D=te=>{if(se.current!==te.pointerId)return;const ve=Ae.current-te.clientX,P=Oe(he.current+ve);Re.current!==P&&(Re.current=P,ye.current===null&&(ye.current=setTimeout(Pe,_j)))},je=te=>{se.current===te.pointerId&&ze()},L=()=>{ze()};return window.addEventListener("pointermove",D),window.addEventListener("pointerup",je),window.addEventListener("pointercancel",je),window.addEventListener("blur",L),()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",je),window.removeEventListener("pointercancel",je),window.removeEventListener("blur",L)}},[Pe,Oe,ze,ge]),l.useEffect(()=>{ge||(Re.current=null,document.documentElement.style.cursor="")},[ge]);const Ue=l.useCallback(()=>{o&&d(o)},[d,o]),q=l.useCallback(()=>{o&&f(o)},[o,f]),ue=l.useCallback(D=>{D.key==="Escape"&&(D.target instanceof Node&&!D.currentTarget.contains(D.target)||db(D.target)||ub(D.target)||D.defaultPrevented||(D.preventDefault(),D.stopPropagation(),Ue()))},[Ue]);l.useEffect(()=>{if(!(!o||!I)&&I.mode==="file"&&I.targetPath){v(o,I.targetPath,{allowOutsideRoot:!0});return}},[I,o,v]);const A=l.useMemo(()=>K.filter(D=>D.mode==="chat"),[K]),Q=k&&I?.mode==="chat"?I.id:null,le=k&&I?.mode==="chat"?Ta(I.dedupeKey):null,Ie=Q?A.find(D=>D.id===Q)??null:null,re=l.useMemo(()=>le?{sessionId:le,directory:o||null}:null,[le,o]);l.useEffect(()=>{if(!k||!o||!le||typeof window>"u")return;const D=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Bi(o,le,!1);return}tf(le),Bi(o,le,!0)};D();const je=window.setInterval(D,1e4);return window.addEventListener("focus",D),window.addEventListener("blur",D),document.addEventListener("visibilitychange",D),()=>{window.clearInterval(je),window.removeEventListener("focus",D),window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",D),Bi(o,le,!1)}},[le,o,k]);const H=l.useCallback(D=>{!o||I?.mode!=="diff"||u(o,{mode:"diff",targetPath:I.targetPath,stagedDiff:D==="staged",diffScope:D})},[I,o,u]),ne=I?.mode==="file"||I?.mode==="chat"||I?.mode==="browser",X=l.useMemo(()=>I?K.filter(D=>D.mode===I.mode):[],[I,K]),fe=l.useMemo(()=>X.map(D=>{const je=Hj(D,J,r),L=Zj(je,Kj),te=Vj(D.targetPath,e);return{id:D.id,label:L,icon:rd(D,$),title:te?`${je}: ${te}`:je,closeLabel:t("contextPanel.tab.closeTabAria",{label:L}),preview:D.preview}}),[X,e,$,J,t]),Fe=I?.mode==="context"?s.jsx(CS,{}):I?.mode==="git"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Oj,{isActive:k})}):I?.mode==="pr"?s.jsx(Tw,{}):I?.mode==="linear"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Bj,{})}):I?.mode==="notes"?s.jsx(xh,{}):I?.mode==="plan"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Fj,{targetPath:I.targetPath,savedProjectPlan:I.projectPlanId&&I.projectPlanRef?{projectRef:I.projectPlanRef,planId:I.projectPlanId}:null})}):null,Me=l.useMemo(()=>K.filter(D=>D.mode==="browser"),[K]),tt=k&&I?.mode==="browser"?I.id:null;l.useEffect(()=>{tt&&b(tt)},[tt,b]);const nt=l.useMemo(()=>Me.filter(D=>D.id===tt||x.has(D.id)),[Me,tt,x]);l.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const D=Me.filter(je=>!nt.includes(je)).map(je=>m1({tabId:je.id,describe:()=>({title:"",url:je.targetPath??""}),wake:()=>b(je.id)}));return()=>D.forEach(je=>je())},[Me,nt,b]);const Qe=l.useMemo(()=>K.filter(D=>D.mode==="diff"),[K]),_e=l.useMemo(()=>K.find(D=>D.mode==="terminal")??null,[K]),wt=l.useMemo(()=>K.some(D=>D.mode==="walkthrough"),[K]),ct=l.useMemo(()=>K.filter(D=>cr(D.mode)),[K]),gt=Xa(D=>D.guests),Kt=l.useMemo(()=>new Set(gt.filter(fb).map(D=>D.id)),[gt]),kt=l.useMemo(()=>{const D=new Map;for(const je of gt){const L=pb(je);L&&D.set(je.id,L)}return D},[gt]),Ht=l.useMemo(()=>K.some(D=>D.mode==="file"),[K]),At=I?.mode==="file",Et=Ce(D=>D.closeContextPanelTabs),Bt=l.useCallback(D=>{if(!o)return null;const{id:je,index:L,allIds:te,close:ve}=D,P=()=>Et(o,te.filter(Ye=>Ye!==je)),Z=()=>Et(o,te.slice(0,L)),Te=()=>Et(o,te.slice(L+1)),Le=()=>Et(o,te),We=te.length>1,Ge=L===0,zt=L===te.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(lr,{onClick:ve,children:[s.jsx(T,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(da,{}),s.jsxs(lr,{onClick:P,disabled:!We,children:[s.jsx(T,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(lr,{onClick:Z,disabled:Ge,children:[s.jsx(T,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(lr,{onClick:Te,disabled:zt,children:[s.jsx(T,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(da,{}),s.jsxs(lr,{onClick:Le,disabled:!We,children:[s.jsx(T,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[Et,o,t]),Rt=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ne?s.jsx(Uu,{items:fe,activeId:I?.id??null,onSelect:D=>{o&&m(o,D)},onClose:D=>{o&&a(o,D)},onReorder:(D,je)=>{o&&h(o,D,je)},onDoubleClickTab:D=>{o&&c(o,D)},layoutMode:"scrollable",variant:"default",tabContextMenu:Bt}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[I?.mode==="pr"&&n==="gitlab"?s.jsx(T,{name:"gitlab",className:"h-3.5 w-3.5"}):I?rd(I,$):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:I?.mode==="pr"&&n==="gitlab"?t("contextPanel.mode.mr"):I?hp(I.mode,r):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[I?.mode==="browser"?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:()=>{o&&F(o)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(T,{name:"add",className:"h-3.5 w-3.5"})}):null,At&&O?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:W,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":E,children:s.jsx(T,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,At?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:C,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":S,children:s.jsx(T,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,_?null:s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:q,className:"h-7 w-7 p-0",title:t(U?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(U?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:U?s.jsx(T,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(T,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:Ue,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(T,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Wt=k?U?{"--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":`${G}px`}:{"--oc-context-panel-width":`${G}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:Ne,"data-context-panel":"true",tabIndex:-1,inert:!k||void 0,className:Se("flex min-h-0 flex-col overflow-hidden bg-background",U?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!k&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:ue,style:Wt,children:[k&&!U&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),k&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!U&&s.jsx("div",{className:Se("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",ge&&"bg-[var(--interactive-border)]"),onPointerDown:$e,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Se("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]",!k&&"pointer-events-none select-none opacity-0"),style:{width:U?M!==null?`${M}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!k,children:[Rt,s.jsxs("div",{className:Se("relative min-h-0 flex-1 overflow-hidden",ge&&"pointer-events-none"),children:[Ht?s.jsxs("div",{className:Se("absolute inset-0 flex",At?"flex":"hidden"),children:[O||!S?s.jsx("div",{className:Se("h-full min-w-0 flex-1",O&&!E&&"hidden"),children:O?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Tj,{mode:"editor-only",visible:k&&At&&E})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(T,{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")})]})}):null,s.jsx(Yj,{visible:S,active:k&&At,fill:!E})]}):null,Ie&&le&&re?s.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:le}),className:"absolute inset-0 bg-background",children:s.jsx(hu,{pinnedSession:re,readOnly:Ie.readOnly})},Ie.id):null,nt.map(D=>s.jsx("div",{className:Se("absolute inset-0",I?.id!==D.id&&"invisible pointer-events-none"),"aria-hidden":I?.id!==D.id||void 0,children:s.jsx(Aj,{initialUrl:D.targetPath??"",directory:o,tabID:D.id})},D.id)),Qe.map(D=>s.jsx("div",{className:Se("absolute inset-0",I?.id!==D.id&&"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(Mj,{visible:k&&I?.id===D.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:D.diffScope??(D.stagedDiff?"staged":"working"),onDiffScopeChange:H,targetFilePath:D.targetPath,flushContent:!0})})},D.id)),_e?s.jsx("div",{className:Se("absolute inset-0",I?.mode==="terminal"?"block":"hidden"),children:s.jsx(yh,{visible:k&&I?.mode==="terminal",directory:_e.targetDirectory,onLastTabClosed:()=>{o&&a(o,_e.id)}})}):null,wt?s.jsx("div",{className:Se("absolute inset-0",I?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(Rj,{directory:e,visible:k&&I?.mode==="walkthrough"})})}):null,ct.map(D=>{if(!cr(D.mode))return null;const je=Qo(D.mode),L=Kt.has(je),te=kt.get(je),ve=I?.id===D.id,P=ve&&k;return L&&!te&&!P?null:s.jsx("div",{className:Se("absolute inset-0",ve?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:L?te?s.jsxs("div",{className:Se("flex h-full",pp[te.dock].container),children:[s.jsx(Lj,{mode:D.mode,docking:te}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:P?s.jsx(td,{mode:D.mode}):null})]}):s.jsx(td,{mode:D.mode}):s.jsx(fp,{mode:D.mode})})},D.id)}),I?.mode!=="chat"&&!At&&I?.mode!=="browser"&&I?.mode!=="diff"&&I?.mode!=="terminal"&&I?.mode!=="walkthrough"&&!(I&&cr(I.mode))?Fe:null]})]})]})},t0=t=>{const e=He.c(43),{open:n,onOpenChange:r}=t,{t:o}=vt(),i=Ce(s0),d=Ce(n0),a=Ce(r0),c=Ce(o0),u=nl();let f;e[0]!==i||e[1]!==u?(f=sf(i,u),e[0]=i,e[1]=u,e[2]=f):f=e[2];const p=f,m=d.length===0;let y;if(e[3]!==d||e[4]!==p){let W;e[6]!==d?(W=F=>d.includes(F.id),e[6]=d,e[7]=W):W=e[7],y=p.every(W),e[3]=d,e[4]=p,e[5]=y}else y=e[5];const x=y;let w;e[8]!==o?(w=o("contextRail.configure.dialogTitle"),e[8]=o,e[9]=w):w=e[9];let b;e[10]!==w?(b=s.jsx(mn,{children:w}),e[10]=w,e[11]=b):b=e[11];let g;e[12]!==o?(g=o("contextRail.configure.dialogDescription"),e[12]=o,e[13]=g):g=e[13];let h;e[14]!==g?(h=s.jsx(hn,{children:g}),e[14]=g,e[15]=h):h=e[15];let v;e[16]!==b||e[17]!==h?(v=s.jsxs(pn,{children:[b,h]}),e[16]=b,e[17]=h,e[18]=v):v=e[18];let S;if(e[19]!==d||e[20]!==a||e[21]!==p||e[22]!==o){let W;e[24]!==d||e[25]!==a||e[26]!==o?(W=F=>s.jsx(bb,{settingsItem:`layout.context-rail.surface.${F.id}`,checked:!d.includes(F.id),onChange:$=>a(F.id,$),label:F.label??o(F.labelKey),ariaLabel:F.label??o(F.labelKey)},F.id),e[24]=d,e[25]=a,e[26]=o,e[27]=W):W=e[27],S=p.map(W),e[19]=d,e[20]=a,e[21]=p,e[22]=o,e[23]=S}else S=e[23];let j;e[28]!==S?(j=s.jsx("div",{className:"flex flex-col",children:S}),e[28]=S,e[29]=j):j=e[29];let N;e[30]!==m||e[31]!==x||e[32]!==c||e[33]!==o?(N=m?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[x?s.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ut,{variant:"link",size:"xs",onClick:()=>c([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[30]=m,e[31]=x,e[32]=c,e[33]=o,e[34]=N):N=e[34];let C;e[35]!==N||e[36]!==v||e[37]!==j?(C=s.jsxs(tn,{className:"max-w-md",children:[v,j,N]}),e[35]=N,e[36]=v,e[37]=j,e[38]=C):C=e[38];let B;return e[39]!==r||e[40]!==n||e[41]!==C?(B=s.jsx(en,{open:n,onOpenChange:r,children:C}),e[39]=r,e[40]=n,e[41]=C,e[42]=B):B=e[42],B};function s0(t){return t.contextRailOrder}function n0(t){return t.contextRailHiddenSurfaces}function r0(t){return t.setContextRailSurfaceVisible}function o0(t){return t.setContextRailHiddenSurfaces}const gp=150,i0=500,a0=[],l0=t=>t>99?"99+":String(t),c0=t=>{const e=He.c(52),{surface:n,isActive:r,showActivityDot:o,label:i,description:d,badgeCount:a,badgeAriaLabel:c,badgeDescription:u,orderNumber:f,showOrderNumber:p,onSelect:m}=t;let y;e[0]!==n.id?(y={id:n.id},e[0]=n.id,e[1]=y):y=e[1];const{attributes:x,listeners:w,setNodeRef:b,transform:g,transition:h,isDragging:v}=vi(y);let S;e[2]!==a?(S=a!=null&&a>0?l0(a):null,e[2]=a,e[3]=S):S=e[3];const j=S;let N;e[4]!==g?(N=wi.Translate.toString(g),e[4]=g,e[5]=N):N=e[5];let C;e[6]!==N||e[7]!==h?(C={transform:N,transition:h},e[6]=N,e[7]=h,e[8]=C):C=e[8];const B=v&&"z-10 opacity-70";let W;e[9]!==B?(W=Se("relative",B),e[9]=B,e[10]=W):W=e[10];let F;e[11]!==m||e[12]!==n?(F=()=>m(n),e[11]=m,e[12]=n,e[13]=F):F=e[13];const $=c??i,K=r?"text-primary":"text-muted-foreground hover:text-foreground";let I;e[14]!==K?(I=Se("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",K),e[14]=K,e[15]=I):I=e[15];let z;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?(z=n.id==="diff"?s.jsx(Wf,{className:"h-[18px] w-[18px]"}):s.jsx(fo,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=z):z=e[19];let k;e[20]!==j||e[21]!==f||e[22]!==o||e[23]!==p?(k=p&&f!=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:f===10?"0":f}):j?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:j}):o?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[20]=j,e[21]=f,e[22]=o,e[23]=p,e[24]=k):k=e[24];let M;e[25]!==x||e[26]!==r||e[27]!==w||e[28]!==I||e[29]!==z||e[30]!==k||e[31]!==F||e[32]!==$?(M=s.jsx(Nt,{asChild:!0,children:s.jsxs("button",{type:"button",...x,...w,onClick:F,"aria-label":$,"aria-pressed":r,className:I,children:[z,k]})}),e[25]=x,e[26]=r,e[27]=w,e[28]=I,e[29]=z,e[30]=k,e[31]=F,e[32]=$,e[33]=M):M=e[33];let V;e[34]!==i?(V=s.jsx("span",{children:i}),e[34]=i,e[35]=V):V=e[35];let O;e[36]!==d?(O=s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}),e[36]=d,e[37]=O):O=e[37];let E;e[38]!==u?(E=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=E):E=e[39];let R;e[40]!==V||e[41]!==O||e[42]!==E?(R=s.jsx(jt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[V,O,E]})}),e[40]=V,e[41]=O,e[42]=E,e[43]=R):R=e[43];let _;e[44]!==M||e[45]!==R?(_=s.jsxs(Ct,{delayDuration:gp,children:[M,R]}),e[44]=M,e[45]=R,e[46]=_):_=e[46];let U;return e[47]!==b||e[48]!==_||e[49]!==C||e[50]!==W?(U=s.jsx("div",{ref:b,style:C,className:W,children:_}),e[47]=b,e[48]=_,e[49]=C,e[50]=W,e[51]=U):U=e[51],U},d0=()=>{const t=He.c(97),{t:e}=vt(),n=fr();let r;t[0]!==n?(r=n?Kn(n):"",t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=ue=>o?ue.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const d=Ce(i),a=Ce(u0),c=Ce(f0),u=Ce(p0),f=Ce(m0),p=Ce(h0),m=Ce(g0),y=Ce(b0),x=Ja(x0),w=ua(y0),b=ua(v0),g=Fu(Lu)?.hasChecked??!1,h=Hn(S0),v=ef(o||null),{screenWidth:S}=Yn(),j=el(o||null);let N;t[4]!==y?(N=fa("switch_context_surface",y),t[4]=y,t[5]=N):N=t[5];const C=N,[B,W]=l.useState(!1);let F,$;t[6]!==C?(F=()=>{const ue=new Set;let A=null,Q=!1;const le=j0,Ie=()=>{uc(C,ue)?!Q&&A===null&&(A=setTimeout(()=>W(!0),i0)):(Q=!1,A!==null&&(clearTimeout(A),A=null),W(!1))},re=X=>{if(ue.add(X.key.toLowerCase()),le(X.key)&&uc(C,ue)){Q=!0,A!==null&&(clearTimeout(A),A=null),W(!1);return}Ie()},H=X=>{ue.delete(X.key.toLowerCase()),Ie()},ne=()=>{ue.clear(),Q=!1,A!==null&&(clearTimeout(A),A=null),W(!1)};return window.addEventListener("keydown",re,!0),window.addEventListener("keyup",H,!0),window.addEventListener("blur",ne),()=>{window.removeEventListener("keydown",re,!0),window.removeEventListener("keyup",H,!0),window.removeEventListener("blur",ne),A!==null&&clearTimeout(A)}},$=[C],t[6]=C,t[7]=F,t[8]=$):(F=t[7],$=t[8]),l.useEffect(F,$);let K;t[9]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{distance:8}},t[9]=K):K=t[9];let I;t[10]===Symbol.for("react.memo_cache_sentinel")?(I={activationConstraint:{delay:200,tolerance:6}},t[10]=I):I=t[10];const z=hi(In(bi,K),In(gi,I)),k=nl(),M=dc(k0),V=dc(C0),O=d?.tabs??a0;let E;t[11]!==d?.activeTabId||t[12]!==O?(E=O.find(ue=>ue.id===d?.activeTabId)??null,t[11]=d?.activeTabId,t[12]=O,t[13]=E):E=t[13];const R=E,_=d?.isOpen?R?.mode??null:null,U=j?.files.length??0;let me;if(t[14]!==u||t[15]!==c||t[16]!==k||t[17]!==b||t[18]!==x||t[19]!==v||t[20]!==S||t[21]!==h||t[22]!==O){let ue;t[24]!==v?(ue=A=>A.id==="pr"&&v==="gitlab"?{...A,icon:"gitlab"}:A,t[24]=v,t[25]=ue):ue=t[25],me=xb({railOrder:c,hiddenSurfaces:u,planModeEnabled:x,isVSCode:cn(),screenWidth:S,tabs:O,linearConnected:b,sourceControlConnected:h,extras:k}).map(ue),t[14]=u,t[15]=c,t[16]=k,t[17]=b,t[18]=x,t[19]=v,t[20]=S,t[21]=h,t[22]=O,t[23]=me}else me=t[23];const ce=me;let oe,ie;t[26]!==_||t[27]!==m||t[28]!==o||t[29]!==w||t[30]!==b?(ie=()=>{!o||!w||b||_!=="linear"||m(o)},oe=[_,m,o,w,b],t[26]=_,t[27]=m,t[28]=o,t[29]=w,t[30]=b,t[31]=oe,t[32]=ie):(oe=t[31],ie=t[32]),l.useEffect(ie,oe);let xe,G;t[33]!==_||t[34]!==m||t[35]!==o||t[36]!==g||t[37]!==h?(xe=()=>{!o||!g||h||_!=="pr"||m(o)},G=[_,m,o,g,h],t[33]=_,t[34]=m,t[35]=o,t[36]=g,t[37]=h,t[38]=xe,t[39]=G):(xe=t[38],G=t[39]),l.useEffect(xe,G);const[pe,J]=l.useState(!1);let ge;t[40]!==k||t[41]!==f?(ge=ue=>{const{active:A,over:Q}=ue;if(!Q||A.id===Q.id)return;const le=sf(Ce.getState().contextRailOrder,k).map(N0),Ie=le.indexOf(A.id),re=le.indexOf(Q.id);Ie===-1||re===-1||f(Pf(le,Ie,re))},t[40]=k,t[41]=f,t[42]=ge):ge=t[42];const de=ge;if(!o)return null;let Ae;t[43]!==e?(Ae=e("contextRail.aria.rail"),t[43]=e,t[44]=Ae):Ae=t[44];let he;t[45]!==ce?(he=ce.map(A0),t[45]=ce,t[46]=he):he=t[46];let Re;if(t[47]!==_||t[48]!==U||t[49]!==V||t[50]!==o||t[51]!==M||t[52]!==p||t[53]!==v||t[54]!==B||t[55]!==ce||t[56]!==e||t[57]!==a){let ue;t[59]!==_||t[60]!==U||t[61]!==V||t[62]!==o||t[63]!==M||t[64]!==p||t[65]!==v||t[66]!==B||t[67]!==e||t[68]!==a?(ue=(A,Q)=>{const le=A.label??e(zn(A.labelKey,v)),Ie=A.id==="git"&&!a?U:0,re=cr(A.mode)&&_!==A.mode?M[Qo(A.mode)]??0:0,H=Ie>0?Ie:re>0?re:null,ne=H!==null&&Ie===0;return s.jsx(c0,{surface:A,isActive:_===A.mode,showActivityDot:!1,label:le,description:e(zn(A.descriptionKey,v)),badgeCount:H,badgeAriaLabel:H!==null?e(ne?H===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":H===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:le,count:H}):null,badgeDescription:H!==null?e(ne?H===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":H===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:H}):null,orderNumber:Q+1,showOrderNumber:B,onSelect:X=>{cr(X.mode)&&V(Qo(X.mode)),p(o,X.mode)}},A.id)},t[59]=_,t[60]=U,t[61]=V,t[62]=o,t[63]=M,t[64]=p,t[65]=v,t[66]=B,t[67]=e,t[68]=a,t[69]=ue):ue=t[69],Re=ce.map(ue),t[47]=_,t[48]=U,t[49]=V,t[50]=o,t[51]=M,t[52]=p,t[53]=v,t[54]=B,t[55]=ce,t[56]=e,t[57]=a,t[58]=Re}else Re=t[58];let se;t[70]!==he||t[71]!==Re?(se=s.jsx(gl,{items:he,strategy:If,children:Re}),t[70]=he,t[71]=Re,t[72]=se):se=t[72];let Ne;t[73]!==de||t[74]!==z||t[75]!==se?(Ne=s.jsx(xi,{sensors:z,collisionDetection:yi,onDragEnd:de,children:se}),t[73]=de,t[74]=z,t[75]=se,t[76]=Ne):Ne=t[76];let be;t[77]!==e?(be=e("contextRail.configure.open"),t[77]=e,t[78]=be):be=t[78];let we;t[79]===Symbol.for("react.memo_cache_sentinel")?(we=()=>J(!0),t[79]=we):we=t[79];let ye;t[80]===Symbol.for("react.memo_cache_sentinel")?(ye=s.jsx(T,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[80]=ye):ye=t[80];let Pe;t[81]!==be?(Pe=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":be,onClick:we,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:ye})}),t[81]=be,t[82]=Pe):Pe=t[82];let Oe;t[83]!==e?(Oe=e("contextRail.configure.open"),t[83]=e,t[84]=Oe):Oe=t[84];let $e;t[85]!==Oe?($e=s.jsx(jt,{side:"left",sideOffset:8,children:Oe}),t[85]=Oe,t[86]=$e):$e=t[86];let ze;t[87]!==Pe||t[88]!==$e?(ze=s.jsxs(Ct,{delayDuration:gp,children:[Pe,$e]}),t[87]=Pe,t[88]=$e,t[89]=ze):ze=t[89];let Ue;t[90]!==pe?(Ue=s.jsx(t0,{open:pe,onOpenChange:J}),t[90]=pe,t[91]=Ue):Ue=t[91];let q;return t[92]!==Ae||t[93]!==Ne||t[94]!==ze||t[95]!==Ue?(q=s.jsxs("nav",{"aria-label":Ae,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[Ne,ze,Ue]}),t[92]=Ae,t[93]=Ne,t[94]=ze,t[95]=Ue,t[96]=q):q=t[96],q};function u0(t){return t.workStatusPanelVisible}function f0(t){return t.contextRailOrder}function p0(t){return t.contextRailHiddenSurfaces}function m0(t){return t.setContextRailOrder}function h0(t){return t.openContextSurface}function g0(t){return t.closeContextPanel}function b0(t){return t.shortcutOverrides}function x0(t){return t.planModeEnabled}function y0(t){return t.hasChecked}function v0(t){return t.status?.connected===!0}function w0(t){return t.status?.status==="connected"}function S0(t){return Object.values(t.entries).some(w0)}function j0(t){return t.length===1&&t>="0"&&t<="9"}function k0(t){return t.countByGuest}function C0(t){return t.clearBadge}function N0(t){return t.id}function A0(t){return t.id}const P0=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),I0=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Hr(t,e,o=>o.relativePath||o.name,{limit:10,threshold:.4}),od={status:"idle"},D0=({query:t,enabled:e,limit:n,sessionId:r=null,directories:o,role:i=null,includeReasoning:d=!0,order:a="desc"})=>{const[c,u]=l.useState(od),f=(o??[]).join(`
|
|
995
|
-
`),p=`${t}\0${r??""}\0${f}\0${i??""}\0${a}\0${n}\0${d}`,m=l.useRef(p);m.current=p;const y=l.useRef(o);y.current=o,l.useEffect(()=>{if(!e||!t.trim()){u(od);return}if(!yb(t)){u({status:"too-short"});return}const b=new AbortController;return u(g=>({status:"loading",hits:"hits"in g?g.hits:[]})),fc({query:t,sessionId:r,directories:y.current,role:i,includeReasoning:d,order:a,limit:n,signal:b.signal}).then(g=>{b.signal.aborted||(g.status==="ok"?u({status:"ready",hits:g.hits,next:g.next,index:g.index,loadingMore:!1}):g.status==="query-too-short"?u({status:"too-short"}):u({status:"unavailable"}))}).catch(()=>{b.signal.aborted||u({status:"error",hits:[]})}),()=>b.abort()},[e,p]);const x=l.useRef(c);x.current=c;const w=l.useCallback(()=>{const b=x.current;if(b.status!=="ready"||!b.next||b.loadingMore)return;const g=m.current,h=b.next;u({...b,loadingMore:!0}),fc({query:t,sessionId:r,directories:y.current,role:i,includeReasoning:d,order:a,limit:n,before:h}).then(v=>{m.current!==g||v.status!=="ok"||u(S=>S.status==="ready"?{...S,hits:[...S.hits,...v.hits],next:v.next,index:v.index,loadingMore:!1}:S)}).catch(()=>{m.current===g&&u(v=>v.status==="ready"?{...v,loadingMore:!1}:v)})},[t,r,i,d,a,n]);return{state:c,loadMore:w}},E0={user:"user-3",assistant:"chat-ai-3",reasoning:"brain-ai-3"},R0=t=>{const e=He.c(4),{snippet:n}=t;let r;e[0]!==n?(r=vb(n).map(O0),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==r?(o=s.jsx(s.Fragment,{children:r}),e[2]=r,e[3]=o):o=e[3],o},M0=t=>{const e=new Date(t);if(!Number.isFinite(e.getTime()))return"";const n=e.getFullYear()===new Date().getFullYear();return new Intl.DateTimeFormat(tl(),n?{month:"short",day:"numeric"}:{year:"numeric",month:"short",day:"numeric"}).format(e)},id=t=>{const e=He.c(38),{hit:n,projectLabel:r,onSelect:o}=t,{t:i}=vt();let d;e[0]!==n.sessionTitle||e[1]!==i?(d=n.sessionTitle||i("commandPalette.session.untitled"),e[0]=n.sessionTitle,e[1]=i,e[2]=d):d=e[2];const a=d;let c;e[3]!==n.role||e[4]!==i?(c=n.role==="user"?i("commandPalette.messages.byYou"):n.role==="reasoning"?i("commandPalette.messages.inReasoning"):i("commandPalette.messages.byAgent"),e[3]=n.role,e[4]=i,e[5]=c):c=e[5];const u=c,f=`message:${n.role}:${n.id}`;let p;e[6]!==n||e[7]!==o?(p=()=>o(n),e[6]=n,e[7]=o,e[8]=p):p=e[8];const m=E0[n.role];let y;e[9]!==u||e[10]!==m?(y=s.jsx(T,{name:m,className:"mr-2 mt-0.5 h-4 w-4 shrink-0",role:"img","aria-hidden":!1,"aria-label":u}),e[9]=u,e[10]=m,e[11]=y):y=e[11];let x;e[12]!==n.snippet?(x=s.jsx("span",{className:"line-clamp-2 break-words text-foreground",children:s.jsx(R0,{snippet:n.snippet})}),e[12]=n.snippet,e[13]=x):x=e[13];let w;e[14]!==n.role||e[15]!==i?(w=n.role==="reasoning"?s.jsxs("span",{className:"shrink-0",children:[i("commandPalette.messages.inReasoning")," ·"]}):null,e[14]=n.role,e[15]=i,e[16]=w):w=e[16];let b;e[17]!==a?(b=s.jsx("span",{className:"min-w-0 truncate",children:a}),e[17]=a,e[18]=b):b=e[18];let g;e[19]!==r?(g=r?s.jsxs("span",{className:"max-w-[40%] shrink-0 truncate",children:["· ",r]}):null,e[19]=r,e[20]=g):g=e[20];let h;e[21]!==n.createdAt?(h=M0(n.createdAt),e[21]=n.createdAt,e[22]=h):h=e[22];let v;e[23]!==h?(v=s.jsxs("span",{className:"shrink-0",children:["· ",h]}),e[23]=h,e[24]=v):v=e[24];let S;e[25]!==g||e[26]!==v||e[27]!==w||e[28]!==b?(S=s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground typography-micro",children:[w,b,g,v]}),e[25]=g,e[26]=v,e[27]=w,e[28]=b,e[29]=S):S=e[29];let j;e[30]!==S||e[31]!==x?(j=s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[x,S]}),e[30]=S,e[31]=x,e[32]=j):j=e[32];let N;return e[33]!==j||e[34]!==f||e[35]!==p||e[36]!==y?(N=s.jsxs(Fn,{value:f,onSelect:p,className:"items-start",children:[y,j]}),e[33]=j,e[34]=f,e[35]=p,e[36]=y,e[37]=N):N=e[37],N},ad=t=>{const e=He.c(10),{options:n,value:r,onChange:o,label:i}=t;let d;if(e[0]!==o||e[1]!==n||e[2]!==r){let c;e[4]!==o||e[5]!==r?(c=u=>s.jsx(ut,{type:"button",variant:"chip",size:"xs","aria-pressed":r===u.value,onClick:()=>o(u.value),children:u.label},u.value),e[4]=o,e[5]=r,e[6]=c):c=e[6],d=n.map(c),e[0]=o,e[1]=n,e[2]=r,e[3]=d}else d=e[3];let a;return e[7]!==i||e[8]!==d?(a=s.jsx("div",{className:"flex items-center gap-1",role:"group","aria-label":i,children:d}),e[7]=i,e[8]=d,e[9]=a):a=e[9],a},T0=t=>{const e=He.c(42),{scope:n,onScopeChange:r,projectScopeAvailable:o,author:i,onAuthorChange:d,reasoningAvailable:a,onBack:c}=t,{t:u}=vt();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(T,{name:"arrow-left",className:"h-3.5 w-3.5"}),e[0]=f):f=e[0];let p;e[1]!==u?(p=u("commandPalette.messages.back"),e[1]=u,e[2]=p):p=e[2];let m;e[3]!==c||e[4]!==p?(m=s.jsxs(ut,{type:"button",variant:"ghost",size:"xs",onClick:c,children:[f,p]}),e[3]=c,e[4]=p,e[5]=m):m=e[5];let y;e[6]!==r||e[7]!==o||e[8]!==n||e[9]!==u?(y=o?s.jsx(ad,{label:u("commandPalette.messages.filter.scopeLabel"),value:n,onChange:r,options:[{value:"all",label:u("commandPalette.messages.filter.allProjects")},{value:"project",label:u("commandPalette.messages.filter.thisProject")}]}):null,e[6]=r,e[7]=o,e[8]=n,e[9]=u,e[10]=y):y=e[10];let x;e[11]!==u?(x=u("commandPalette.messages.filter.authorLabel"),e[11]=u,e[12]=x):x=e[12];let w;e[13]!==u?(w=u("commandPalette.messages.filter.anyone"),e[13]=u,e[14]=w):w=e[14];let b;e[15]!==w?(b={value:"any",label:w},e[15]=w,e[16]=b):b=e[16];let g;e[17]!==u?(g=u("commandPalette.messages.filter.you"),e[17]=u,e[18]=g):g=e[18];let h;e[19]!==g?(h={value:"user",label:g},e[19]=g,e[20]=h):h=e[20];let v;e[21]!==u?(v=u("commandPalette.messages.filter.agent"),e[21]=u,e[22]=v):v=e[22];let S;e[23]!==v?(S={value:"assistant",label:v},e[23]=v,e[24]=S):S=e[24];let j;e[25]!==a||e[26]!==u?(j=a?[{value:"reasoning",label:u("commandPalette.messages.filter.reasoning")}]:[],e[25]=a,e[26]=u,e[27]=j):j=e[27];let N;e[28]!==S||e[29]!==j||e[30]!==b||e[31]!==h?(N=[b,h,S,...j],e[28]=S,e[29]=j,e[30]=b,e[31]=h,e[32]=N):N=e[32];let C;e[33]!==i||e[34]!==d||e[35]!==N||e[36]!==x?(C=s.jsx(ad,{label:x,value:i,onChange:d,options:N}),e[33]=i,e[34]=d,e[35]=N,e[36]=x,e[37]=C):C=e[37];let B;return e[38]!==C||e[39]!==m||e[40]!==y?(B=s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-border px-2 py-1.5",children:[m,y,C]}),e[38]=C,e[39]=m,e[40]=y,e[41]=B):B=e[41],B};function O0(t,e){return t.match?s.jsx("mark",{className:"rounded-[2px] bg-primary/25 text-foreground",children:t.text},e):s.jsx(l.Fragment,{children:t.text},e)}const B0=new Set,F0=[],L0=3,$0=30,qi=(t,e)=>{const n=t.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return e.toLowerCase().split(/\s+/).filter(Boolean).every(r=>n.some(o=>o.startsWith(r)))},ld=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},cd="",dd=t=>{const e=He.c(7),{text:n,className:r}=t;let o;e[0]!==r?(o=Se("min-w-0 truncate text-muted-foreground",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={direction:"rtl",textAlign:"left"},e[2]=i):i=e[2];const d=`${cd}${n}${cd}`;let a;return e[3]!==o||e[4]!==d||e[5]!==n?(a=s.jsx("span",{className:o,style:i,title:n,children:d}),e[3]=o,e[4]=d,e[5]=n,e[6]=a):a=e[6],a},Cn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const o=r==="/",i=/^[A-Za-z]:\/$/.test(r);return!o&&!i&&(r=r.replace(/\/+$/,"")),r},_0=()=>{const{t}=vt(),e=Ce(P=>P.isCommandPaletteOpen),n=Ce(P=>P.setCommandPaletteOpen),r=Ce(P=>P.setSettingsDialogOpen),o=Ce(P=>P.setSettingsPage),i=Ce(P=>P.setSessionSwitcherOpen),d=Ce(P=>P.toggleSidebar),a=Ce(P=>P.openContextOverview),c=Ce(P=>P.openContextSurface),u=Ce(P=>P.openContextFile),f=Ce(P=>P.shortcutOverrides),p=Ce(P=>P.setArchivePageOpen),m=Ce(P=>P.setProjectContextTab),y=Je(P=>P.openNewSessionDraft),x=Je(P=>P.setCurrentSession),w=Je(P=>P.currentSessionId),b=Tr(P=>P.toggle),g=Ls(l.useCallback(P=>e?P.activeSessions:F0,[e])),h=Tr(l.useCallback(P=>e?P.ids:B0,[e])),v=rl(l.useCallback(P=>e?P.rankById:ol,[e])),S=Fs(P=>P.currentDirectory),j=as(P=>P.getActiveProject()),N=as(P=>P.projects),C=fr(),B=iu(P=>P.searchFiles),{files:W,git:F}=jn(),$=mr(P=>P.ensureStatus),{isMobile:K}=Yn(),I=l.useMemo(()=>C?Cn(C):null,[C]),[z,k]=l.useState(""),V=Xu(z,200).trim(),O=z.trim(),[E,R]=l.useState(!1),[_,U]=l.useState("all"),[me,ce]=l.useState("any");l.useEffect(()=>{e&&(k(""),R(!1))},[e]),l.useEffect(()=>{if(!e||!F)return;const P=setTimeout(()=>{const Z=new Set;for(const Te of g){const Le=vn(Te);!Le||Z.has(Le)||(Z.add(Le),$(Le,F))}},0);return()=>clearTimeout(P)},[e,g,F,$]);const oe=l.useCallback(()=>n(!1),[n]),ie=l.useCallback(P=>()=>{oe(),P()},[oe]),xe=l.useMemo(()=>{const P=[{id:"new-session",title:t("commandPalette.item.newSession"),icon:s.jsx(T,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:t("commandPalette.item.newSession"),onSelect:ie(()=>{i(!1),y()})},{id:"new-worktree",title:t("commandPalette.item.quickWorktree"),icon:s.jsx(T,{name:"flashlight",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:t("commandPalette.item.quickWorktree"),onSelect:ie(()=>{nf()})},{id:"new-worktree-dialog",title:t("commandPalette.item.newWorktreeDialog"),icon:s.jsx(T,{name:"git-branch",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.newWorktreeDialog"),onSelect:ie(()=>{Ce.getState().setNewWorktreeDialogOpen(!0)})},{id:"add-project",title:t("commandPalette.item.addProject"),icon:s.jsx(T,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.addProject"),onSelect:ie(()=>{Rn.requestDirectoryDialog()})},{id:"toggle-sidebar",title:t(K?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(T,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:t(K?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:ie(()=>{if(K){const{isSessionSwitcherOpen:Z}=Ce.getState();i(!Z)}else d()})},{id:"toggle-terminal",title:t("commandPalette.item.toggleTerminal"),icon:s.jsx(T,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:t("commandPalette.item.toggleTerminal"),onSelect:ie(()=>{S&&c(S,"terminal")})},{id:"context-usage",title:t("commandPalette.item.showContextUsage"),icon:s.jsx(T,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.showContextUsage"),onSelect:ie(()=>{S&&a(S)})},{id:"cycle-theme",secondary:!0,title:t("commandPalette.item.cycleTheme"),icon:s.jsx(T,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:t("commandPalette.item.cycleTheme"),onSelect:ie(()=>{wb.invoke("cycle_theme")})},{id:"open-status",secondary:!0,title:t("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(T,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.showOpenCodeStatus"),onSelect:ie(()=>{rf()})},{id:"open-settings",title:t("commandPalette.item.openSettings"),icon:s.jsx(T,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:t("commandPalette.item.openSettings"),onSelect:ie(()=>r(!0))}];return cn()||P.push({id:"reload-ui",secondary:!0,title:t("commandPalette.item.reloadUi"),icon:s.jsx(T,{name:"refresh",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.reloadUi"),onSelect:ie(()=>window.location.reload())}),P.push({id:"pin-session",secondary:!0,title:t("commandPalette.item.pinSession"),icon:s.jsx(T,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.pinSession"),onSelect:ie(()=>{w&&S&&b({directory:S,sessionId:w})})},{id:"copy-session-id",secondary:!0,title:t("commandPalette.item.copySessionId"),icon:s.jsx(T,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.copySessionId"),onSelect:ie(()=>{w&&ur(w).then(Z=>{if(Z.ok){Be.success(t("sessions.sidebar.session.copyId.success"));return}Be.error(t("sessions.sidebar.session.copyId.error"))}).catch(()=>Be.error(t("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:t("commandPalette.item.openMultiRun"),icon:s.jsx(T,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openMultiRun"),onSelect:ie(()=>{i(!1),Sb()})},{id:"open-archive",secondary:!0,title:t("commandPalette.item.openArchive"),icon:s.jsx(T,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openArchive"),onSelect:ie(()=>{i(!1),p(!0)})},{id:"open-notes",secondary:!0,title:t("commandPalette.item.openNotes"),icon:s.jsx(T,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openNotes"),onSelect:ie(()=>{S&&(m("notes"),c(S,"notes"))})},{id:"open-todos",secondary:!0,title:t("commandPalette.item.openTodos"),icon:s.jsx(T,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openTodos"),onSelect:ie(()=>{S&&(m("todos"),c(S,"notes"))})}),cn()||P.push({id:"restart-opencode",secondary:!0,title:t("commandPalette.item.restartOpenCode"),icon:s.jsx(T,{name:"restart",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.restartOpenCode"),onSelect:ie(()=>{vh(t)})}),P.push({id:"toggle-memory-debug",secondary:!0,title:t("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(T,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.toggleMemoryDebug"),onSelect:ie(()=>{window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))})}),eo()&&P.splice(1,0,{id:"new-mini-chat",title:t("commandPalette.item.newMiniChat"),icon:s.jsx(T,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:t("commandPalette.item.newMiniChat"),onSelect:ie(()=>{Un("desktop_open_draft_mini_chat_window",{directory:Cn(S||j?.path||""),projectId:j?.id??null}).catch(Z=>{console.warn("[command-palette] failed to open draft mini chat window",Z)})})}),P},[t,ie,K,i,y,d,c,S,a,r,j?.id,j?.path,w,b,p,m]),G=Ce(P=>P.routingFeatureAvailable),pe=jb(),J=kb(),ge=l.useMemo(()=>{const P=En();return{isVSCode:cn(),isWeb:!P&&qa(),isDesktop:P,isMobile:K,routingAvailable:G,enterpriseMode:pe,jevBlockedByEnterprise:J}},[K,G,pe,J]),de=l.useMemo(()=>wh.filter(P=>P.slug!=="home").filter(P=>P.isAvailable?P.isAvailable(ge):!0).map(P=>{const Z=Sh(P.slug)??"settings-3",Te=(P.keywords??[]).join(" ");return{id:`settings:${P.slug}`,title:P.title,icon:P.slug==="mcp"?s.jsx(Cb,{className:"mr-2 h-4 w-4"}):s.jsx(T,{name:Z,className:"mr-2 h-4 w-4"}),searchText:`${P.title} ${P.group} ${Te}`,onSelect:ie(()=>{o(P.slug),r(!0)})}}),[ge,ie,o,r]),Ae=l.useMemo(()=>{const P=g.filter(Z=>!Nb(Z)&&!Z.parentID);return Ab(P,h,v)},[g,h,v]),he=of(),Re=Je(P=>P.worktreeMetadata),se=l.useCallback((P,Z)=>{const Te=Re.get(P);return Te?.branch?Te.branch.trim()||null:Z&&he.get(Z)?.trim()||null},[Re,he]),[Ne,be]=l.useState([]),[we,ye]=l.useState(""),Pe=P0(I,V),Oe=Je(P=>P.availableWorktrees),$e=l.useMemo(()=>I?Oe.map(P=>Cn(P.path)).filter(P=>P.startsWith(`${I}/`)).map(P=>`${P}/`):[],[Oe,I]),ze=l.useRef($e);ze.current=$e;const q=Ce(P=>P.messageSearchEnabled)&&!cn(),ue=Ce(P=>P.messageSearchReasoningEnabled),A=Ce(P=>P.showReasoningTraces),Q=ue&&A,le=me==="reasoning"&&!Q?"any":me,Ie=l.useMemo(()=>j?.path?[...new Set([Cn(j.path),...Oe.map(P=>Cn(P.path))])]:[],[j?.path,Oe]),re=E&&_==="project"&&Ie.length>0,{state:H,loadMore:ne}=D0({query:V,enabled:e&&q,limit:E?$0:L0,directories:re?Ie:void 0,role:E&&le!=="any"?le:null,includeReasoning:A}),X="hits"in H?H.hits:[];l.useEffect(()=>{if(!e){be([]),ye("");return}if(!Pe){be([]),ye("");return}if(!I){be([]),ye("");return}let P=!1;const Z=ze.current,Te=Z.length>0?100:40;return B(I,V,Te,{type:"file"}).then(Le=>{P||(be(Le.map(We=>({path:Cn(We.path),name:We.name,relativePath:We.relativePath})).filter(We=>!Z.some(Ge=>We.path.startsWith(Ge)))),ye(Pe))}).catch(()=>{P||(be([]),ye(Pe))}),()=>{P=!0}},[e,I,V,Pe,B]);const fe=O.length>0,Fe=l.useMemo(()=>{if(!fe)return xe.filter(Z=>!Z.secondary).map(Z=>({item:Z,score:0}));const P=xe.filter(Z=>qi(Z.searchText,O));return Hr(P,O,Z=>Z.searchText,{limit:7,noFuzzy:!0})},[xe,O,fe]),Me=l.useMemo(()=>{if(!fe)return[];const P=de.filter(Z=>qi(Z.searchText,O));return Hr(P,O,Z=>Z.searchText,{limit:7,noFuzzy:!0})},[de,O,fe]),tt=l.useMemo(()=>fe?Hr(Ae,O,P=>P.title||"",{limit:7,threshold:.2}):Ae.slice(0,5).map(P=>({item:P,score:0})),[Ae,O,fe]),nt=l.useMemo(()=>e?I0(Ne,V,Pe,we):[],[e,Ne,we,Pe,V]),Qe=e&&Pe.length>0&&we!==Pe,_e=l.useMemo(()=>{if(!fe)return[];const Z=N.map(Te=>({...Te,displayName:Te.label||Te.path.split("/").pop()||Te.path,searchText:`${Te.label||""} ${Te.path}`})).filter(Te=>qi(Te.searchText,O));return Hr(Z,O,Te=>Te.searchText,{limit:7,threshold:.4})},[N,O,fe]),wt=Ce(P=>e&&I?P.contextPanelByDirectory[I]?.tabs:void 0),ct=l.useMemo(()=>!I||!wt?[]:wt.filter(P=>P.mode==="file"&&P.targetPath).sort((P,Z)=>Z.touchedAt-P.touchedAt).slice(0,5).flatMap(P=>{const Z=Cn(P.targetPath??"");if(!Z)return[];const Te=Z.startsWith(`${I}/`)?Z.slice(I.length+1):Z;return[{path:Z,name:ld(Te).name,relativePath:Te}]}),[wt,I]),gt=l.useCallback(P=>{if(!P)return null;const Z=Cn(P);let Te=null;for(const Le of N){const We=Cn(Le.path);Z!==We&&!Z.startsWith(`${We}/`)||Te&&Te.length>=We.length||(Te={label:Le.label||We.split("/").pop()||We,length:We.length})}return Te?.label??null},[N]),Kt=Fe.map(P=>P.item),kt=Me.map(P=>P.item),Ht=tt.map(P=>P.item),At=fe?nt.map(P=>P.item):[],Et=fe?_e.map(P=>P.item):[],Bt=fe?[]:ct,Rt=l.useMemo(()=>{if(!fe)return["openFiles","sessions","commands"];const P=Te=>Te.length?Te[0].score:1/0,Z=[{key:"commands",score:P(Fe)},{key:"settings",score:P(Me)},{key:"sessions",score:P(tt)},{key:"files",score:P(nt)},{key:"projects",score:P(_e)}];return Z.sort((Te,Le)=>Te.score-Le.score),[...Z.map(Te=>Te.key),"messages"]},[fe,Fe,Me,tt,nt,_e]),Wt=l.useCallback(P=>{oe(),Pb(P.role==="reasoning"?P.id:null),pa(P.sessionId,P.id)},[oe]),D=l.useCallback(P=>{oe(),x(P.id,vn(P))},[oe,x]),je=l.useCallback(async P=>{if(!I)return;const Z=await Vf(W,P,{directory:I});if(!Z.ok){Be.error(Uf(Z.reason));return}u(I,P),oe()},[I,W,u,oe]),L=l.useCallback((P,Z)=>{oe(),y({selectedProjectId:P,directoryOverride:Z})},[oe,y]),te=l.useCallback(P=>dr(po(P,f)),[f]),ve=(P,Z)=>{const{name:Te,directory:Le}=ld(P.relativePath||P.name);return s.jsxs(Fn,{value:`${Z}:${P.path}`,onSelect:()=>{je(P.path)},children:[s.jsx(sl,{filePath:P.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"shrink-0 truncate","aria-label":P.relativePath,children:Te}),Le?s.jsx(dd,{text:Le,className:"flex-1"}):null]},`${Z}:${P.path}`)};return s.jsxs(en,{open:e,onOpenChange:(P,Z)=>{if(!P&&E&&Z.reason==="escape-key"){Z.cancel(),R(!1);return}n(P)},children:[s.jsxs(pn,{className:"sr-only",children:[s.jsx(mn,{children:t("commandPalette.title")}),s.jsx(hn,{children:t("commandPalette.description")})]}),s.jsx(tn,{className:"gap-0 overflow-hidden p-0 max-w-[min(720px,calc(100vw-2rem))]",layerClassName:"items-start pt-[12vh]",showCloseButton:!1,children:s.jsxs(Ib,{shouldFilter:!1,className:"[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pt-2 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:!text-[11px] [&_[cmdk-group-heading]]:!leading-4 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta",children:[s.jsx(Db,{value:z,onValueChange:k,placeholder:t(E?"commandPalette.messages.placeholder":"commandPalette.input.placeholder"),onKeyDown:P=>{E&&P.key==="Backspace"&&z.length===0&&(P.preventDefault(),R(!1))}}),E?s.jsx(T0,{scope:_,onScopeChange:U,projectScopeAvailable:Ie.length>0,author:le,onAuthorChange:ce,reasoningAvailable:Q,onBack:()=>R(!1)}):null,s.jsx("div",{className:Se("min-h-0",E?"h-[min(403px,calc(60vh-37px))]":"h-[min(440px,60vh)]"),children:s.jsx(Eb,{children:E?s.jsxs(s.Fragment,{children:[X.map(P=>s.jsx(id,{hit:P,projectLabel:gt(P.directory),onSelect:Wt},`${P.role}:${P.id}`)),H.status==="ready"&&H.next?s.jsxs(Fn,{value:"message:load-more",onSelect:ne,disabled:H.loadingMore,children:[s.jsx(T,{name:"more",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate text-muted-foreground",children:t("commandPalette.messages.loadMore")})]}):null,s.jsxs("div",{className:"px-4 py-2 typography-meta text-muted-foreground",role:"status",children:[H.status==="idle"||H.status==="too-short"?t("commandPalette.messages.tooShort"):H.status==="loading"&&X.length===0?t("commandPalette.messages.searching"):H.status==="error"?t("commandPalette.messages.error"):H.status==="unavailable"?t("commandPalette.messages.unavailable"):H.status==="ready"&&X.length===0?t("commandPalette.messages.empty"):null,H.status==="ready"&&H.index?.backfill.state==="running"?` ${t("commandPalette.messages.indexing",{done:H.index.backfill.done,total:H.index.backfill.total})}`:null]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Rb,{children:t("commandPalette.empty.noResults")}),Rt.map(P=>P==="messages"?!fe||X.length===0?null:s.jsxs(sr,{heading:t("commandPalette.group.messages"),children:[X.map(Z=>s.jsx(id,{hit:Z,projectLabel:gt(Z.directory),onSelect:Wt},`${Z.role}:${Z.id}`)),s.jsxs(Fn,{value:"message:show-all",onSelect:()=>R(!0),children:[s.jsx(T,{name:"search",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate text-muted-foreground",children:t("commandPalette.messages.showAll")})]})]},"messages"):P==="openFiles"&&Bt.length>0?s.jsx(sr,{heading:t("commandPalette.group.openFiles"),children:Bt.map(Z=>ve(Z,"open-file"))},"openFiles"):P==="commands"&&Kt.length>0?s.jsx(sr,{heading:t("commandPalette.group.commands"),children:Kt.map(Z=>s.jsxs(Fn,{value:Z.id,onSelect:Z.onSelect,children:[Z.icon,s.jsx("span",{className:"truncate",children:Z.title}),Z.shortcutId?s.jsx(Mb,{children:te(Z.shortcutId)}):null]},Z.id))},"commands"):P==="settings"&&kt.length>0?s.jsx(sr,{heading:t("commandPalette.group.settings"),children:kt.map(Z=>s.jsxs(Fn,{value:Z.id,onSelect:Z.onSelect,children:[Z.icon,s.jsx("span",{className:"truncate",children:Z.title})]},Z.id))},"settings"):P==="sessions"&&Ht.length>0?s.jsx(sr,{heading:t("commandPalette.group.sessions"),children:Ht.map(Z=>{const Te=Z.title||t("commandPalette.session.untitled"),Le=vn(Z),We=se(Z.id,Le),Ge=gt(Le);return s.jsxs(Fn,{value:`session:${Z.id}`,onSelect:()=>D(Z),children:[s.jsx(T,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{dir:"auto",className:"min-w-0 flex-1 truncate text-left",children:Te}),Ge?s.jsx("span",{className:"max-w-[180px] shrink-0 truncate text-muted-foreground typography-meta",children:Ge}):null,We?s.jsxs("span",{className:"inline-flex max-w-[160px] shrink-0 items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(T,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate",children:We})]}):null]},Z.id)})},"sessions"):P==="files"&&At.length>0?s.jsx(sr,{heading:t("commandPalette.group.files"),children:At.map(Z=>ve(Z,"file"))},"files"):P==="projects"&&Et.length>0?s.jsx(sr,{heading:t("commandPalette.group.projects"),children:Et.map(Z=>s.jsxs(Fn,{value:`project:${Z.id}`,onSelect:()=>L(Z.id,Z.path),children:[s.jsx(T,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"shrink-0 truncate",children:Z.displayName}),s.jsx(dd,{text:Z.path,className:"flex-1"})]},`project:${Z.id}`))},"projects"):null),Qe?s.jsx("div",{className:"px-4 py-2 typography-meta text-muted-foreground",children:t("commandPalette.empty.searchingFiles")}):null]})})}),K?null:s.jsxs("div",{className:"flex items-center gap-4 border-t border-border px-3 py-1.5 typography-micro text-muted-foreground","aria-hidden":"true",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"font-sans",children:"↑↓"})," ",t("commandPalette.footer.navigate")]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"font-sans",children:"↵"})," ",t("commandPalette.footer.open")]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"font-sans",children:"esc"})," ",t("commandPalette.footer.close")]})]})]})})]})},ud=(t,e,n)=>dr(po(t,e),n),K0=()=>{const t=He.c(47),{t:e}=vt(),n=Ce(W0),r=Ce(z0),o=Ce(V0);let i,d,a,c,u,f,p,m,y,x,w,b;if(t[0]!==n||t[1]!==r||t[2]!==o||t[3]!==e){const j=[{categoryKey:"helpDialog.section.navigationCommands",column:"left",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:[dr("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",column:"right",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:""},{id:"background_session_work",icon:"arrow-up-double",keys:""}]},{categoryKey:"helpDialog.section.panels",column:"right",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${dr(fa("switch_context_surface",o))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${dr(fa("switch_session_tab",o))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",column:"left",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:""}]}],N=K=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(K.categoryKey)}),s.jsx("div",{className:"space-y-1",children:K.items.map(I=>{const z=I.id?Tb(I.id):void 0,k=I.descriptionKey??(z?.customizable?z.settingsLabelKey:void 0);if(!k||I.id&&!po(I.id,o))return null;const M=I.id?ud(I.id,o,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(I.keys)?I.keys:I.keys.split(" / ");return s.jsxs("div",{className:"flex items-center gap-3 py-1 px-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[I.icon&&s.jsx(T,{name:I.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(k)})]}),s.jsx("div",{"aria-hidden":!0,className:"min-w-4 flex-1 border-b border-dotted border-border"}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:(Array.isArray(M)?M:[M]).map((V,O)=>s.jsxs(l.Fragment,{children:[O>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:V})]},`${V}-${O}`))})]},I.id||k)})})]},K.categoryKey);a=en,w=n,b=r,d=tn,y="max-w-6xl w-[min(72rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let C;t[16]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(T,{name:"command",className:"h-5 w-5"}),t[16]=C):C=t[16];let B;t[17]!==e?(B=e("helpDialog.title"),t[17]=e,t[18]=B):B=t[18];let W;t[19]!==B?(W=s.jsxs(mn,{className:"flex items-center gap-2",children:[C,B]}),t[19]=B,t[20]=W):W=t[20];let F;t[21]!==e?(F=e("helpDialog.description"),t[21]=e,t[22]=F):F=t[22];let $;t[23]!==F?($=s.jsx(hn,{children:F}),t[23]=F,t[24]=$):$=t[24],t[25]!==W||t[26]!==$?(x=s.jsxs(pn,{children:[W,$]}),t[25]=W,t[26]=$,t[27]=x):x=t[27],i=Mn,f="flex-1 min-h-0 mt-3",p="pr-1",m=!0,c="grid grid-cols-1 gap-x-12 gap-y-4 lg:grid-cols-2",u=["left","right"].map(K=>s.jsxs("div",{className:"space-y-4",children:[j.filter(I=>I.column===K).map(N),K==="right"&&s.jsxs("ul",{className:"space-y-0.5 px-2 typography-meta text-muted-foreground",children:[s.jsxs("li",{children:["• ",e("helpDialog.proTips.commandPalette",{shortcut:ud("open_command_palette",o,e("settings.openchamber.keyboardShortcuts.unassigned"))})]}),s.jsxs("li",{children:["• ",e("helpDialog.proTips.recentSessions")]}),s.jsxs("li",{children:["• ",e("helpDialog.proTips.leaderSequences")]})]})]},K)),t[0]=n,t[1]=r,t[2]=o,t[3]=e,t[4]=i,t[5]=d,t[6]=a,t[7]=c,t[8]=u,t[9]=f,t[10]=p,t[11]=m,t[12]=y,t[13]=x,t[14]=w,t[15]=b}else i=t[4],d=t[5],a=t[6],c=t[7],u=t[8],f=t[9],p=t[10],m=t[11],y=t[12],x=t[13],w=t[14],b=t[15];let g;t[28]!==c||t[29]!==u?(g=s.jsx("div",{className:c,children:u}),t[28]=c,t[29]=u,t[30]=g):g=t[30];let h;t[31]!==i||t[32]!==f||t[33]!==p||t[34]!==m||t[35]!==g?(h=s.jsx(i,{outerClassName:f,className:p,disableHorizontal:m,children:g}),t[31]=i,t[32]=f,t[33]=p,t[34]=m,t[35]=g,t[36]=h):h=t[36];let v;t[37]!==d||t[38]!==h||t[39]!==y||t[40]!==x?(v=s.jsxs(d,{className:y,children:[x,h]}),t[37]=d,t[38]=h,t[39]=y,t[40]=x,t[41]=v):v=t[41];let S;return t[42]!==a||t[43]!==v||t[44]!==w||t[45]!==b?(S=s.jsx(a,{open:w,onOpenChange:b,children:v}),t[42]=a,t[43]=v,t[44]=w,t[45]=b,t[46]=S):S=t[46],S};function W0(t){return t.isHelpDialogOpen}function z0(t){return t.setHelpDialogOpen}function V0(t){return t.shortcutOverrides}const U0=()=>{const t=He.c(32),{t:e}=vt(),n=Ce(H0),r=Ce(G0),o=Ce(q0);let i;t[0]!==o||t[1]!==e?(i=async()=>{if(!o)return;if((await ur(o)).ok){Be.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Be.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=o,t[1]=e,t[2]=i):i=t[2];const d=i;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let c;t[5]!==a?(c=s.jsx(mn,{children:a}),t[5]=a,t[6]=c):c=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let f;t[9]!==u?(f=s.jsx(hn,{children:u}),t[9]=u,t[10]=f):f=t[10];let p;t[11]!==c||t[12]!==f?(p=s.jsxs(pn,{children:[c,f]}),t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;t[14]!==e?(m=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=m):m=t[15];let y;t[16]!==d||t[17]!==m?(y=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:d,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-ring",children:m})}),t[16]=d,t[17]=m,t[18]=y):y=t[18];let x;t[19]!==o||t[20]!==e?(x=o||e("openCodeStatusDialog.empty.noData"),t[19]=o,t[20]=e,t[21]=x):x=t[21];let w;t[22]!==x?(w=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:x}),t[22]=x,t[23]=w):w=t[23];let b;t[24]!==p||t[25]!==y||t[26]!==w?(b=s.jsxs(tn,{className:"max-w-2xl",children:[p,y,w]}),t[24]=p,t[25]=y,t[26]=w,t[27]=b):b=t[27];let g;return t[28]!==n||t[29]!==r||t[30]!==b?(g=s.jsx(en,{open:n,onOpenChange:r,children:b}),t[28]=n,t[29]=r,t[30]=b,t[31]=g):g=t[31],g};function H0(t){return t.isOpenCodeStatusDialogOpen}function G0(t){return t.setOpenCodeStatusDialogOpen}function q0(t){return t.openCodeStatusText}const Y0=t=>{const e=He.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:o,sessionSearchInputRef:i,sessionSearchContainerRef:d}=t,a=n===void 0?!0:n;let c,u;e[0]!==a||e[1]!==r||e[2]!==i?(c=()=>{if(!a||!r||typeof window>"u")return;const x=window.requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()});return()=>window.cancelAnimationFrame(x)},u=[a,r,i],e[0]=a,e[1]=r,e[2]=i,e[3]=c,e[4]=u):(c=e[3],u=e[4]),l.useEffect(c,u);let f,p;e[5]!==a||e[6]!==i||e[7]!==o?(f=()=>{if(!a||typeof window>"u")return;const x=()=>{o(!0),i.current?.focus(),i.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",x),()=>window.removeEventListener("openchamber:sidebar-session-search",x)},p=[a,o,i],e[5]=a,e[6]=i,e[7]=o,e[8]=f,e[9]=p):(f=e[8],p=e[9]),l.useEffect(f,p);let m,y;e[10]!==a||e[11]!==r||e[12]!==d||e[13]!==o?(m=()=>{if(!a||!r||typeof document>"u")return;const x=w=>{d.current&&(d.current.contains(w.target)||o(!1))};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},y=[a,r,o,d],e[10]=a,e[11]=r,e[12]=d,e[13]=o,e[14]=m,e[15]=y):(m=e[14],y=e[15]),l.useEffect(m,y)},Q0=t=>{const e=He.c(4);let n;e[0]!==t?(n=(i,d)=>{const a=t.get(i);if(!a||a.length===0)return d;const c=new Map(d.map(X0)),u=[];a.forEach(m=>{const y=c.get(m);y&&(u.push(y),c.delete(m))});const f=[],p=[];return d.forEach(m=>{c.has(m.id)&&(m.isArchivedBucket?p.push(m):f.push(m))}),[...f,...u,...p]},e[0]=t,e[1]=n):n=e[1];const r=n;let o;return e[2]!==r?(o={getOrderedGroups:r},e[2]=r,e[3]=o):o=e[3],o};function X0(t){return[t.id,t]}const Do="oc.sessions.projectCollapse",fd="oc.sessions.groupOrder",pd="oc.sessions.groupCollapse",md=t=>{if(!t)return new Set;try{const e=Si(qn()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},J0=t=>{if(!t)return new Map;try{const e=xl(qn(),Si(qn())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,o]of Object.entries(e.data))n.set(r,o);return n}catch{return new Map}},Z0=t=>{const e=He.c(39),{isVSCode:n,projects:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Xo(),e[0]=o):o=e[0];const i=o;let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>md(i.getItem(Do)),e[1]=d):d=e[1];const[a,c]=l.useState(d);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>md(i.getItem(pd)),e[2]=u):u=e[2];const[f,p]=l.useState(u);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=()=>J0(i.getItem(fd)),e[3]=m):m=e[3];const[y,x]=l.useState(m),w=l.useRef(0),b=l.useRef(!1),g=l.useRef(!1),h=l.useRef(null),v=l.useRef(null);let S;e[4]!==n?(S=()=>{if(n)return;const J=v.current;if(v.current=null,h.current=null,!J)return;const{projects:ge}=as.getState(),de=ge.map(Ae=>({...Ae,sidebarCollapsed:J.has(Ae.id)}));kr({projects:de}).catch(ek)},e[4]=n,e[5]=S):S=e[5];const j=S;let N;e[6]!==j||e[7]!==n?(N=J=>{!globalThis.window||n||(v.current=J,h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{j()},700))},e[6]=j,e[7]=n,e[8]=N):N=e[8];const C=N;let B,W;e[9]===Symbol.for("react.memo_cache_sentinel")?(B=()=>()=>{globalThis.window&&h.current!==null&&window.clearTimeout(h.current),h.current=null,v.current=null},W=[],e[9]=B,e[10]=W):(B=e[9],W=e[10]),l.useEffect(B,W);let F,$;e[11]!==y?($=()=>{if(g.current)try{i.setItem(fd,JSON.stringify(Object.fromEntries(y.entries())))}catch{}},F=[y,i],e[11]=y,e[12]=F,e[13]=$):(F=e[12],$=e[13]),l.useEffect($,F);let K,I;e[14]!==f?(K=()=>{if(b.current)try{i.setItem(pd,JSON.stringify(Array.from(f)))}catch{}},I=[f,i],e[14]=f,e[15]=K,e[16]=I):(K=e[15],I=e[16]),l.useEffect(K,I);let z;e[17]!==r||e[18]!==C?(z=()=>{w.current=Date.now()+150,b.current=!0,p(new Set),c(()=>{const J=new Set(r.map(tk));try{i.setItem(Do,JSON.stringify(Array.from(J)))}catch{}return C(J),J})},e[17]=r,e[18]=C,e[19]=z):z=e[19];const k=z;let M;e[20]!==C?(M=()=>{w.current=Date.now()+150,b.current=!0,p(new Set),c(()=>{const J=new Set;try{i.setItem(Do,JSON.stringify([]))}catch{}return C(J),J})},e[20]=C,e[21]=M):M=e[21];const V=M;let O;e[22]!==C?(O=J=>{w.current=Date.now()+150,c(ge=>{const de=new Set(ge);de.has(J)?de.delete(J):de.add(J);try{i.setItem(Do,JSON.stringify(Array.from(de)))}catch{}return C(de),de})},e[22]=C,e[23]=O):O=e[23];const E=O;let R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=J=>{b.current=!0,p(ge=>{const de=new Set(ge);return de.has(J)?de.delete(J):de.add(J),de})},e[24]=R):R=e[24];const _=R;let U;e[25]===Symbol.for("react.memo_cache_sentinel")?(U=J=>{g.current=!0,x(J)},e[25]=U):U=e[25];const me=U,{getOrderedGroups:ce}=Q0(y);let oe;e[26]!==f||e[27]!==a||e[28]!==y?(oe={collapsedProjects:a,collapsedGroups:f,groupOrderByProject:y},e[26]=f,e[27]=a,e[28]=y,e[29]=oe):oe=e[29];const ie=oe;let xe;e[30]!==k||e[31]!==V||e[32]!==ce||e[33]!==C||e[34]!==E?(xe={setCollapsedProjects:c,toggleProject:E,collapseAllProjects:k,expandAllProjects:V,scheduleCollapsedProjectsPersist:C,setCollapsedGroups:p,toggleGroup:_,setGroupOrderByProject:me,getOrderedGroups:ce},e[30]=k,e[31]=V,e[32]=ce,e[33]=C,e[34]=E,e[35]=xe):xe=e[35];const G=xe;let pe;return e[36]!==G||e[37]!==ie?(pe={state:ie,actions:G},e[36]=G,e[37]=ie,e[38]=pe):pe=e[38],pe};function ek(){}function tk(t){return t.id}const sk=5*6e4,nk=t=>{const e=He.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:o,setProjectRepoStatus:i,setProjectRootBranches:d}=t,a=r===void 0?!0:r,{git:c}=jn(),u=mr(rk);let f,p;e[0]!==a||e[1]!==u||e[2]!==c||e[3]!==n||e[4]!==i?(f=()=>{if(!a||!c||n.length===0){i(new Map);return}n.forEach(N=>{Jo(()=>u(N.normalizedPath,c))})},p=[a,n,c,u,i],e[0]=a,e[1]=u,e[2]=c,e[3]=n,e[4]=i,e[5]=f,e[6]=p):(f=e[5],p=e[6]),l.useEffect(f,p);let m,y;e[7]!==a||e[8]!==o||e[9]!==n||e[10]!==i?(m=()=>{if(!a)return;const N=new Map;n.forEach(C=>{N.set(C.id,o.get(C.normalizedPath)?.isGitRepo??null)}),i(N)},y=[a,n,o,i],e[7]=a,e[8]=o,e[9]=n,e[10]=i,e[11]=m,e[12]=y):(m=e[11],y=e[12]),l.useEffect(m,y);let x;if(e[13]!==o||e[14]!==n){let N;e[16]!==o?(N=C=>{const B=o.get(C.normalizedPath)?.branch??"";return`${C.id}:${B}`},e[16]=o,e[17]=N):N=e[17],x=n.map(N).join("|"),e[13]=o,e[14]=n,e[15]=x}else x=e[15];const w=x;let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=new Map,e[18]=b):b=e[18];const g=l.useRef(b);let h;e[19]===Symbol.for("react.memo_cache_sentinel")?(h=new Map,e[19]=h):h=e[19];const v=l.useRef(h);let S;e[20]!==a||e[21]!==o||e[22]!==n||e[23]!==d?(S=()=>{if(!a)return;let N=!1;const C=setTimeout(()=>{(async()=>{const W=new Set(n.map(ok));for(const k of g.current.keys())W.has(k)||(g.current.delete(k),v.current.delete(k));const F=Date.now(),$=n.filter(k=>{const M=o.get(k.normalizedPath);if(M?.isGitRepo===!1)return g.current.delete(k.id),v.current.delete(k.id),!1;if(M?.isGitRepo!==!0||M.branch===null)return!1;const V=M.branch.trim(),O=`${k.normalizedPath}\0${V}`,E=g.current.get(k.id);if(E===O){const R=v.current.get(k.id);return R&&(R.at=F),!1}return!(E!==void 0&&F-(v.current.get(k.id)?.at??0)<sk)});if($.length===0)return;const K=await Ob($,2,async k=>{const M=o.get(k.normalizedPath)?.branch?.trim()??"",V=`${k.normalizedPath}\0${M}`,O=await Jo(()=>Gu(k.normalizedPath,M?{knownBranch:M}:void 0)).catch(ik);return{id:k.id,inputKey:V,branch:O}});if(N)return;const I=K.filter(ak);if(I.length===0)return;const z=Date.now();d(k=>{const M=new Map(k);return I.forEach(V=>{const{id:O,branch:E}=V;E&&M.set(O,E)}),M}),I.forEach(k=>{const{id:M,inputKey:V,branch:O}=k;g.current.set(M,V),O&&v.current.set(M,{branch:O,at:z})})})()},150);return()=>{N=!0,clearTimeout(C)}},e[20]=a,e[21]=o,e[22]=n,e[23]=d,e[24]=S):S=e[24];let j;e[25]!==a||e[26]!==o||e[27]!==n||e[28]!==w||e[29]!==d?(j=[a,n,w,o,d],e[25]=a,e[26]=o,e[27]=n,e[28]=w,e[29]=d,e[30]=j):j=e[30],l.useEffect(S,j)};function rk(t){return t.ensureStatus}function ok(t){return t.id}function ik(){return null}function ak(t){return t.branch}const lk=t=>{const e=He.c(10),{open:n,onOpenChange:r,project:o,onSave:i}=t;let d;e[0]!==i||e[1]!==n||e[2]!==o?(d=n&&o?s.jsx(jh,{project:o,onIdentitySave:i,showWorktrees:!1}):null,e[0]=i,e[1]=n,e[2]=o,e[3]=d):d=e[3];let a;e[4]!==d?(a=s.jsx(tn,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(Mn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:d})})}),e[4]=d,e[5]=a):a=e[5];let c;return e[6]!==r||e[7]!==n||e[8]!==a?(c=s.jsx(en,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=c):c=e[9],c};function ck(t){const e=He.c(200),{t:n}=vt(),r=af(),{hideDirectoryControls:o,showProjectDisplayControls:i,showRecentControls:d,handleOpenDirectoryDialog:a,onOpenScheduled:c,onOpenArchive:u,headerActionIconClass:f,headerActionButtonClass:p,isSessionSearchOpen:m,setIsSessionSearchOpen:y,sessionSearchInputRef:x,sessionSearchQuery:w,setSessionSearchQuery:b,hasSessionSearchQuery:g,searchMatchCount:h,collapseAllProjects:v,expandAllProjects:S}=t,j=As(jk),N=As(Sk),C=Ds(wk),B=Ds(vk),W=Ds(yk),F=Ds(xk),$=Ds(bk),K=Ds(gk),I=Ds(hk),z=Ds(mk),k=Ds(pk),M=Ds(fk),V=i&&k==="single",O=i&&I==="timeline";if(o){let je;e[0]!==y?(je=()=>y(!1),e[0]=y,e[1]=je):je=e[1];let L;e[2]!==n?(L=n("sessions.sidebar.header.search.placeholder"),e[2]=n,e[3]=L):L=e[3];let te;e[4]!==n?(te=n("sessions.sidebar.header.search.clear"),e[4]=n,e[5]=te):te=e[5];let ve;e[6]!==g||e[7]!==h||e[8]!==n?(ve=g?h===1?n("sessions.sidebar.header.search.matchCountSingle",{count:h}):n("sessions.sidebar.header.search.matchCountPlural",{count:h}):void 0,e[6]=g,e[7]=h,e[8]=n,e[9]=ve):ve=e[9];let P;e[10]!==n?(P=n("sessions.sidebar.header.search.escapeHint"),e[10]=n,e[11]=P):P=e[11];let Z;return e[12]!==x||e[13]!==w||e[14]!==b||e[15]!==je||e[16]!==L||e[17]!==te||e[18]!==ve||e[19]!==P?(Z=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1.5",children:s.jsx(Zl,{inputRef:x,value:w,onSearch:b,onClose:je,placeholder:L,clearLabel:te,leadingHint:ve,trailingHint:P})}),e[12]=x,e[13]=w,e[14]=b,e[15]=je,e[16]=L,e[17]=te,e[18]=ve,e[19]=P,e[20]=Z):Z=e[20],Z}let E;e[21]!==p?(E=Se(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[21]=p,e[22]=E):E=e[22];let R;e[23]!==n?(R=n("sessions.sidebar.header.actions.addProject"),e[23]=n,e[24]=R):R=e[24];let _;e[25]!==f?(_=s.jsx(T,{name:"folder-add",className:f}),e[25]=f,e[26]=_):_=e[26];let U;e[27]!==a||e[28]!==E||e[29]!==R||e[30]!==_?(U=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:E,"aria-label":R,children:_})}),e[27]=a,e[28]=E,e[29]=R,e[30]=_,e[31]=U):U=e[31];let me;e[32]!==n?(me=n("sessions.sidebar.header.actions.addProject"),e[32]=n,e[33]=me):me=e[33];let ce;e[34]!==me?(ce=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:me})}),e[34]=me,e[35]=ce):ce=e[35];let oe;e[36]!==U||e[37]!==ce?(oe=s.jsxs(Ct,{children:[U,ce]}),e[36]=U,e[37]=ce,e[38]=oe):oe=e[38];let ie;e[39]!==p?(ie=Se(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[39]=p,e[40]=ie):ie=e[40];let xe;e[41]!==n?(xe=n("sessions.sidebar.header.actions.scheduledTasks"),e[41]=n,e[42]=xe):xe=e[42];let G;e[43]!==f?(G=s.jsx(T,{name:"calendar-schedule",className:f}),e[43]=f,e[44]=G):G=e[44];let pe;e[45]!==c||e[46]!==ie||e[47]!==xe||e[48]!==G?(pe=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:c,className:ie,"aria-label":xe,children:G})}),e[45]=c,e[46]=ie,e[47]=xe,e[48]=G,e[49]=pe):pe=e[49];let J;e[50]!==n?(J=n("sessions.sidebar.header.actions.scheduledTasks"),e[50]=n,e[51]=J):J=e[51];let ge;e[52]!==J?(ge=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:J})}),e[52]=J,e[53]=ge):ge=e[53];let de;e[54]!==pe||e[55]!==ge?(de=s.jsxs(Ct,{children:[pe,ge]}),e[54]=pe,e[55]=ge,e[56]=de):de=e[56];let Ae;e[57]!==p?(Ae=Se(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[57]=p,e[58]=Ae):Ae=e[58];let he;e[59]!==n?(he=n("sessions.sidebar.nav.archive"),e[59]=n,e[60]=he):he=e[60];let Re;e[61]!==f?(Re=s.jsx(T,{name:"archive",className:f}),e[61]=f,e[62]=Re):Re=e[62];let se;e[63]!==u||e[64]!==Ae||e[65]!==he||e[66]!==Re?(se=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:Ae,"aria-label":he,children:Re})}),e[63]=u,e[64]=Ae,e[65]=he,e[66]=Re,e[67]=se):se=e[67];let Ne;e[68]!==n?(Ne=n("sessions.sidebar.nav.archive"),e[68]=n,e[69]=Ne):Ne=e[69];let be;e[70]!==Ne?(be=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ne})}),e[70]=Ne,e[71]=be):be=e[71];let we;e[72]!==se||e[73]!==be?(we=s.jsxs(Ct,{children:[se,be]}),e[72]=se,e[73]=be,e[74]=we):we=e[74];let ye;e[75]!==r||e[76]!==f||e[77]!==n?(ye=r.length>0&&s.jsxs(Qs,{children:[s.jsx(qs,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(T,{name:"apps",className:f})})}),s.jsxs(Ys,{align:"start",children:[s.jsx(Cr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(uk)]})]}),e[75]=r,e[76]=f,e[77]=n,e[78]=ye):ye=e[78];let Pe;e[79]!==de||e[80]!==we||e[81]!==ye||e[82]!==oe?(Pe=s.jsxs("div",{className:"ml-[3px] flex min-w-0 items-center gap-1.5",children:[oe,de,we,ye]}),e[79]=de,e[80]=we,e[81]=ye,e[82]=oe,e[83]=Pe):Pe=e[83];let Oe;e[84]!==y?(Oe=()=>y(dk),e[84]=y,e[85]=Oe):Oe=e[85];let $e;e[86]!==p?($e=Se(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[86]=p,e[87]=$e):$e=e[87];let ze;e[88]!==n?(ze=n("sessions.sidebar.header.actions.searchSessions"),e[88]=n,e[89]=ze):ze=e[89];let Ue;e[90]!==f?(Ue=s.jsx(T,{name:"search",className:f}),e[90]=f,e[91]=Ue):Ue=e[91];let q;e[92]!==m||e[93]!==Oe||e[94]!==$e||e[95]!==ze||e[96]!==Ue?(q=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Oe,className:$e,"aria-label":ze,"aria-expanded":m,children:Ue})}),e[92]=m,e[93]=Oe,e[94]=$e,e[95]=ze,e[96]=Ue,e[97]=q):q=e[97];let ue;e[98]!==n?(ue=n("sessions.sidebar.header.actions.searchSessions"),e[98]=n,e[99]=ue):ue=e[99];let A;e[100]!==ue?(A=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ue})}),e[100]=ue,e[101]=A):A=e[101];let Q;e[102]!==q||e[103]!==A?(Q=s.jsxs(Ct,{children:[q,A]}),e[102]=q,e[103]=A,e[104]=Q):Q=e[104];const le=j&&"bg-interactive-hover text-primary";let Ie;e[105]!==p||e[106]!==le?(Ie=Se(p,"text-muted-foreground hover:text-foreground hover:bg-transparent",le),e[105]=p,e[106]=le,e[107]=Ie):Ie=e[107];let re;e[108]!==j||e[109]!==n?(re=n(j?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[108]=j,e[109]=n,e[110]=re):re=e[110];let H;e[111]!==f?(H=s.jsx(T,{name:"checkbox-multiple",className:f}),e[111]=f,e[112]=H):H=e[112];let ne;e[113]!==j||e[114]!==Ie||e[115]!==re||e[116]!==H||e[117]!==N?(ne=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:N,className:Ie,"aria-label":re,"aria-pressed":j,children:H})}),e[113]=j,e[114]=Ie,e[115]=re,e[116]=H,e[117]=N,e[118]=ne):ne=e[118];let X;e[119]!==j||e[120]!==n?(X=n(j?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[119]=j,e[120]=n,e[121]=X):X=e[121];let fe;e[122]!==X?(fe=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:X})}),e[122]=X,e[123]=fe):fe=e[123];let Fe;e[124]!==ne||e[125]!==fe?(Fe=s.jsxs(Ct,{children:[ne,fe]}),e[124]=ne,e[125]=fe,e[126]=Fe):Fe=e[126];let Me;e[127]!==p?(Me=Se(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[127]=p,e[128]=Me):Me=e[128];let tt;e[129]!==n?(tt=n("sessions.sidebar.header.displayMode.label"),e[129]=n,e[130]=tt):tt=e[130];let nt;e[131]!==f?(nt=s.jsx(T,{name:"equalizer-2",className:f}),e[131]=f,e[132]=nt):nt=e[132];let Qe;e[133]!==Me||e[134]!==tt||e[135]!==nt?(Qe=s.jsx(Nt,{asChild:!0,children:s.jsx(qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Me,"aria-label":tt,children:nt})})}),e[133]=Me,e[134]=tt,e[135]=nt,e[136]=Qe):Qe=e[136];let _e;e[137]!==n?(_e=n("sessions.sidebar.header.displayMode.label"),e[137]=n,e[138]=_e):_e=e[138];let wt;e[139]!==_e?(wt=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:_e})}),e[139]=_e,e[140]=wt):wt=e[140];let ct;e[141]!==Qe||e[142]!==wt?(ct=s.jsxs(Ct,{children:[Qe,wt]}),e[141]=Qe,e[142]=wt,e[143]=ct):ct=e[143];let gt;e[144]!==z||e[145]!==i||e[146]!==I||e[147]!==n||e[148]!==O?(gt=i?s.jsxs(s.Fragment,{children:[s.jsx(Cr,{children:n("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(je=>{const[L,te]=je;return s.jsxs(ts,{onClick:()=>{z(L),kr({sidebarViewMode:L})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(te)}),I===L?s.jsx(T,{name:"check",className:"h-4 w-4 text-primary"}):null]},L)}),O?null:s.jsx(Vs,{})]}):null,e[144]=z,e[145]=i,e[146]=I,e[147]=n,e[148]=O,e[149]=gt):gt=e[149];let Kt;e[150]!==k||e[151]!==W||e[152]!==M||e[153]!==F||e[154]!==K||e[155]!==i||e[156]!==n||e[157]!==O||e[158]!==$?(Kt=O?null:s.jsxs(s.Fragment,{children:[s.jsx(Cr,{children:n("sessions.sidebar.header.actions.sortProjects")}),[["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(je=>{const[L,te]=je;return s.jsxs(ts,{onClick:()=>{F(L),kr({sidebarProjectSortOrder:L})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(te)}),W===L?s.jsx(T,{name:"check",className:"h-4 w-4 text-primary"}):null]},L)}),s.jsx(Vs,{}),i?s.jsxs(s.Fragment,{children:[s.jsx(Cr,{children:n("sessions.sidebar.header.actions.sortWorktrees")}),[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]].map(je=>{const[L,te]=je;return s.jsxs(ts,{onClick:()=>{K(L),kr({sidebarWorktreeSortOrder:L})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(te)}),$===L?s.jsx(T,{name:"check",className:"h-4 w-4 text-primary"}):null]},L)}),s.jsx(Vs,{})]}):null,i?s.jsxs(s.Fragment,{children:[s.jsx(Cr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(je=>{const[L,te]=je;return s.jsxs(ts,{onClick:()=>{M(L),kr({sidebarProjectDisplayMode:L})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(te)}),k===L?s.jsx(T,{name:"check",className:"h-4 w-4 text-primary"}):null]},L)}),s.jsx(Vs,{})]}):null]}),e[150]=k,e[151]=W,e[152]=M,e[153]=F,e[154]=K,e[155]=i,e[156]=n,e[157]=O,e[158]=$,e[159]=Kt):Kt=e[159];let kt;e[160]!==V||e[161]!==d||e[162]!==C||e[163]!==n||e[164]!==O||e[165]!==B?(kt=!O&&d&&!V?s.jsxs(ts,{onClick:()=>{B(),kr({sidebarShowRecentSection:!C})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),C?s.jsx(T,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[160]=V,e[161]=d,e[162]=C,e[163]=n,e[164]=O,e[165]=B,e[166]=kt):kt=e[166];let Ht;e[167]!==v||e[168]!==S||e[169]!==V||e[170]!==n||e[171]!==O?(Ht=!O&&!V?s.jsxs(s.Fragment,{children:[s.jsx(Vs,{}),s.jsxs(ts,{onClick:v,className:"flex items-center gap-2",children:[s.jsx(T,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(ts,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(T,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[167]=v,e[168]=S,e[169]=V,e[170]=n,e[171]=O,e[172]=Ht):Ht=e[172];let At;e[173]!==gt||e[174]!==Kt||e[175]!==kt||e[176]!==Ht?(At=s.jsxs(Ys,{align:"end",className:"min-w-[180px]",children:[gt,Kt,kt,Ht]}),e[173]=gt,e[174]=Kt,e[175]=kt,e[176]=Ht,e[177]=At):At=e[177];let Et;e[178]!==ct||e[179]!==At?(Et=s.jsxs(Qs,{children:[ct,At]}),e[178]=ct,e[179]=At,e[180]=Et):Et=e[180];let Bt;e[181]!==Q||e[182]!==Fe||e[183]!==Et?(Bt=s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[Q,Fe,Et]}),e[181]=Q,e[182]=Fe,e[183]=Et,e[184]=Bt):Bt=e[184];let Rt;e[185]!==Pe||e[186]!==Bt?(Rt=s.jsxs("div",{className:"flex min-h-8 flex-wrap items-center justify-between gap-2",children:[Pe,Bt]}),e[185]=Pe,e[186]=Bt,e[187]=Rt):Rt=e[187];let Wt;e[188]!==g||e[189]!==m||e[190]!==h||e[191]!==x||e[192]!==w||e[193]!==y||e[194]!==b||e[195]!==n?(Wt=m?s.jsx("div",{className:"pb-1",children:s.jsx(Zl,{inputRef:x,value:w,onSearch:b,onClose:()=>y(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:g?h===1?n("sessions.sidebar.header.search.matchCountSingle",{count:h}):n("sessions.sidebar.header.search.matchCountPlural",{count:h}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[188]=g,e[189]=m,e[190]=h,e[191]=x,e[192]=w,e[193]=y,e[194]=b,e[195]=n,e[196]=Wt):Wt=e[196];let D;return e[197]!==Rt||e[198]!==Wt?(D=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:[Rt,Wt]})}),e[197]=Rt,e[198]=Wt,e[199]=D):D=e[199],D}function dk(t){return!t}function uk(t){return s.jsxs(ts,{onSelect:()=>Ce.getState().setOpenGuestPage(t.id),children:[s.jsx(fo,{icon:Fb(t.icon),iconSrc:Bb(t.id,t.icon,Em().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function fk(t){return t.setProjectDisplayMode}function pk(t){return t.projectDisplayMode}function mk(t){return t.setSidebarViewMode}function hk(t){return t.sidebarViewMode}function gk(t){return t.setWorktreeSortOrder}function bk(t){return t.worktreeSortOrder}function xk(t){return t.setProjectSortOrder}function yk(t){return t.projectSortOrder}function vk(t){return t.toggleRecentSection}function wk(t){return t.showRecentSection}function Sk(t){return t.toggleMode}function jk(t){return t.enabled}const Eo="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-ring";function kk(t){const e=He.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:o,onOpenAbout:i,onOpenUpdate:d,showRuntimeButtons:a,showUpdateButton:c}=t,u=a===void 0?!0:a,f=c===void 0?!0:c,{t:p}=vt();if(!u&&!f)return null;let m;e[0]!==i||e[1]!==n||e[2]!==o||e[3]!==r||e[4]!==u||e[5]!==p?(m=u?s.jsxs(s.Fragment,{children:[s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:Eo,"aria-label":p("sessions.sidebar.footer.actions.settings"),children:s.jsx(T,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:p("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:Eo,"aria-label":p("usageStats.openAction"),children:s.jsx(T,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:p("usageStats.openAction")})})]}),s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:Eo,"aria-label":p("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(T,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:p("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:Eo,"aria-label":p("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(T,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:p("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=i,e[1]=n,e[2]=o,e[3]=r,e[4]=u,e[5]=p,e[6]=m):m=e[6];let y;e[7]!==d||e[8]!==f||e[9]!==p?(y=f?s.jsx(ut,{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:d,children:p("sessions.sidebar.footer.actions.update")}):null,e[7]=d,e[8]=f,e[9]=p,e[10]=y):y=e[10];let x;return e[11]!==m||e[12]!==y?(x=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[m,y]}),e[11]=m,e[12]=y,e[13]=x):x=e[13],x}const Ck=t=>{for(const e of t.sessions.values())if(e.tabs.some(cu))return!0;return!1},Nk=()=>{const t=He.c(4),{terminal:e}=jn(),n=_t(Ck);let r,o;return t[0]!==n||t[1]!==e?(r=()=>{const i=Ak,d=Pk;if(n)return ra(e,"",d,i);let a=Ik;return a=ra(e,"",d,c=>{i(c),a()}),()=>a()},o=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),l.useEffect(r,o),null};function Ak(t){const e=_t.getState(),n=kh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const o of r)e.reconcileServerSessions(o,n.get(o)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function Pk(){return new Map(_t.getState().actionMutationRevisions)}function Ik(){}const Dk=50,Ek=t=>{const e=new Map;for(const n of t){const r=at(n.directory),o=n.branch.trim();if(!(!r||!o||e.has(r))&&(e.set(r,{directory:r,branch:o}),e.size===Dk))break}return[...e.values()]},Rk=t=>{const e=He.c(12),{normalizedProjects:n,enabled:r,ownership:o,isSessionsLoading:i,hasAuthoritativeGlobalSessions:d,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:c,foldersMap:u,createFolder:f,addSessionToFolder:p}=t,m=r===void 0?!0:r;let y,x;e[0]!==p||e[1]!==f||e[2]!==m||e[3]!==u||e[4]!==d||e[5]!==i||e[6]!==a||e[7]!==n||e[8]!==o||e[9]!==c?(y=()=>{!m||i||!d||a||n.forEach(w=>{if(c.has(w.normalizedPath))return;const b=lf(w.normalizedPath),g=o.archivedSessionsByProject.get(w.id)??[],h=u[b]??[],v=new Map(h.map(Mk));g.forEach(S=>{const j=Lb(S,w.normalizedPath),N=j.toLowerCase();let C=v.get(N);C||(C=f(b,j),v.set(N,C)),C.sessionIds.includes(S.id)||p(b,C.id,S.id)})})},x=[n,m,o,i,d,a,c,u,f,p],e[0]=p,e[1]=f,e[2]=m,e[3]=u,e[4]=d,e[5]=i,e[6]=a,e[7]=n,e[8]=o,e[9]=c,e[10]=y,e[11]=x):(y=e[10],x=e[11]),l.useEffect(y,x)};function Mk(t){return[t.name.toLowerCase(),t]}function Tk({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:o,rememberedSessionId:i,fallbackSessionId:d}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(o.entries()).some(([f,p])=>f!==t&&p.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const c=(i&&r.has(i)?i:null)??d;return!c||c===e?{kind:"none"}:{kind:"select-session",sessionId:c}}const Ok=t=>{const e=He.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:o,setActiveSessionByProject:i,currentSessionId:d,currentSessionOwnerProjectId:a,handleSessionSelect:c,newSessionDraftOpen:u,mobileVariant:f,openNewSessionDraft:p,setSessionSwitcherOpen:m}=t;let y,x;if(e[0]!==n){x=new Map,y=new Map;const N=(C,B,W,F)=>{x.has(C)||x.set(C,new Map);const $=x.get(C);F.forEach(K=>{const I=at(K.worktree?.path??K.session.directory??W??B);$.set(K.session.id,{directory:I}),y.has(C)||y.set(C,{id:K.session.id,directory:I}),K.children.length>0&&N(C,B,I,K.children)})};n.forEach(C=>{C.groups.forEach(B=>{N(C.project.id,C.project.normalizedPath,B.directory,B.sessions)})}),e[0]=n,e[1]=y,e[2]=x}else y=e[1],x=e[2];let w;e[3]!==y||e[4]!==x?(w={metaByProject:x,firstSessionByProject:y},e[3]=y,e[4]=x,e[5]=w):w=e[5];const b=w,g=l.useRef(null);let h,v;e[6]!==r||e[7]!==o||e[8]!==d||e[9]!==a||e[10]!==c||e[11]!==f||e[12]!==u||e[13]!==p||e[14]!==n||e[15]!==b||e[16]!==i||e[17]!==m?(h=()=>{if(!r||u||Ce.getState().isNewWorktreeDialogOpen||g.current===r)return;const N=n.find(F=>F.project.id===r);if(!N)return;if(g.current===null){g.current=r;return}const C=b.metaByProject.get(r);if(d&&C&&C.has(d)){g.current=r,i(F=>{if(F.get(r)===d)return F;const $=new Map(F);return $.set(r,d),$});return}const B=Tk({activeProjectId:r,currentSessionId:d,currentSessionOwnerProjectId:a,projectMap:C,metaByProject:b.metaByProject,rememberedSessionId:o.get(r),fallbackSessionId:b.firstSessionByProject.get(r)?.id??null});if(B.kind==="preserve-current"){a===r&&(g.current=r);return}if(g.current=r,B.kind==="open-draft"){f&&m(!1),p({selectedProjectId:N.project.id,directoryOverride:N.project.normalizedPath});return}if(B.kind!=="select-session")return;const W=C?.get(B.sessionId)?.directory??null;c(B.sessionId,W)},v=[r,o,d,a,c,u,f,p,n,b,m,i],e[6]=r,e[7]=o,e[8]=d,e[9]=a,e[10]=c,e[11]=f,e[12]=u,e[13]=p,e[14]=n,e[15]=b,e[16]=i,e[17]=m,e[18]=h,e[19]=v):(h=e[18],v=e[19]),l.useLayoutEffect(h,v);let S,j;e[20]!==r||e[21]!==d||e[22]!==b||e[23]!==i?(S=()=>{if(!r||!d)return;const N=b.metaByProject.get(r);!N||!N.has(d)||i(C=>{if(C.get(r)===d)return C;const B=new Map(C);return B.set(r,d),B})},j=[r,d,b,i],e[20]=r,e[21]=d,e[22]=b,e[23]=i,e[24]=S,e[25]=j):(S=e[24],j=e[25]),l.useEffect(S,j)},Bk=t=>{const e=He.c(20);let n,r,o,i;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:o,sessionOwnerBySessionId:i,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=i):(n=e[1],r=e[2],o=e[3],i=e[4]);const d=Je(Fk),a=Je(Lk);let c;e[5]!==d||e[6]!==i?(c=d?i?.get(d)?.projectId??null:null,e[5]=d,e[6]=i,e[7]=c):c=e[7];const u=c;let f;e[8]!==r?(f=()=>new Map(r),e[8]=r,e[9]=f):f=e[9];const[p,m]=l.useState(f);let y;e[10]!==p||e[11]!==n||e[12]!==d||e[13]!==u||e[14]!==a?(y={...n,activeSessionByProject:p,setActiveSessionByProject:m,currentSessionId:d,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=p,e[11]=n,e[12]=d,e[13]=u,e[14]=a,e[15]=y):y=e[15],Ok(y);let x,w;return e[16]!==p||e[17]!==o?(x=()=>{o(p)},w=[p,o],e[16]=p,e[17]=o,e[18]=x,e[19]=w):(x=e[18],w=e[19]),l.useEffect(x,w),null};function Fk(t){return t.currentSessionId}function Lk(t){return!!t.newSessionDraft?.open}const $k=t=>{const e=He.c(7),{ownership:n}=t;let r;e[0]!==n?(r=c=>n.sessionsByProject.get(c)??[],e[0]=n,e[1]=r):r=e[1];const o=r;let i;e[2]!==n?(i=c=>n.archivedSessionsByProject.get(c)??[],e[2]=n,e[3]=i):i=e[3];const d=i;let a;return e[4]!==d||e[5]!==o?(a={getSessionsForProject:o,getArchivedSessionsForProject:d},e[4]=d,e[5]=o,e[6]=a):a=e[6],a},ar=(t,e)=>`${t}\0${e}`,Wn=(t,e)=>t??il(e)??at(e??null),oo=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??at(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},Al=t=>t.startsWith("__archived__:"),_k=(t,e)=>{const n=t.groups.find(i=>i.isMain&&i.sessions.length>0)??t.groups.find(i=>i.sessions.length>0)??t.groups.find(i=>i.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(i=>i.isArchivedBucket&&i.id!==n.id);return(e.mainWorkspaceOnly?[n,...r?[r]:[]]:[...t.groups.find(i=>i.isMain)?[t.groups.find(i=>i.isMain)]:[],...t.groups.filter(i=>!i.isMain)]).map(i=>({group:i,groupKey:`${t.project.id}:${i.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?i.id===n.id:i.isMain}))},hd=(t,e,n)=>{if(!e)return;const r=o=>{let i=o.session.id===e;for(const d of o.children)i=r(d)||i;return i&&n.add(o.session.id),i};for(const o of t)r(o)},Br=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Br(n,e))return!0;return!1},Kk=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!al(r),Wk=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,Oa=(t,e,n)=>{const r=new Map,o=i=>{const d=vn(i.session)??at(i.worktree?.path)??n;if(d){const a=r.get(d)??[];a.push(i.session.id),r.set(d,a)}if(!(i===t&&e))for(const a of i.children)o(a)};return o(t),[...r].map(([i,d])=>({directory:i,sessionIDs:d}))},Ba=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const o=new Set;let i=r.session.parentID??null;for(;i&&!o.has(i);){if(n.has(i)&&e.has(i))return!1;o.add(i),i=e.get(i)?.session?.parentID??null}return!0})},bp=t=>{const e=new Map(t.map(d=>[d.id,d])),n=new Map;for(const d of t){if(!d.parentId||!e.has(d.parentId))continue;const a=n.get(d.parentId)??[];a.push(d),n.set(d.parentId,a)}const r=new Set,o=[],i=d=>{if(r.has(d.id))return;o.push(d);const a=[d.id];for(;a.length>0;){const c=a.pop();if(!(!c||r.has(c))){r.add(c);for(const u of n.get(c)??[])a.push(u.id)}}};return t.forEach(d=>{(!d.parentId||!e.has(d.parentId))&&i(d)}),t.forEach(i),o},xp=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),o=new Map,i=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){i.add(u.id);continue}if(u.parentId){const m=o.get(u.parentId)??[];m.push(u.id),o.set(u.parentId,m)}const f=new Set;let p=u.id;for(;p;){if(f.has(p)){i.add(u.id);break}f.add(p),p=r.get(p)?.parentId}}const d=new Set,a=new Set,c=u=>{if(d.has(u))return!0;if(a.has(u))return!1;const f=r.get(u);if(!f)return!1;a.add(u);let p=i.has(u);return!p&&e.archivedBucket&&f.nodeCount===0?p=(o.get(u)??[]).some(c):(!p&&!e.searchQuery&&(p=!0),!p&&(f.nodeCount>0||!n&&Zo([f.name],e.searchQuery))&&(p=!0),p||(p=(o.get(u)??[]).some(c))),a.delete(u),p&&d.add(u),p};return t.forEach(u=>c(u.id)),new Set(t.filter(u=>d.has(u.id)).map(u=>u.id))},gd=new WeakMap;let bd=1;const zk=t=>{const e=gd.get(t);if(e!==void 0)return e;const n=bd;return bd+=1,gd.set(t,n),n},io=t=>t.children.length===0?"":t.children.map(n=>{const r=zk(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${io(n)}`}).join("|"),yp=(t,e,n,r,o,i)=>{const d=ss(),a=(c,u)=>{if(c.session.id!==u.session.id||c.children.length!==u.children.length)return!0;const f=c.session.directory??o,p=u.session.directory??i,m=pc(d,f??"",c.session.id),y=pc(d,p??"",u.session.id);return(m?n.has(m):!1)!==(y?r.has(y):!1)?!0:c.children.some((x,w)=>a(x,u.children[w]))};return a(t,e)},Vk=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,Uk=(t,e)=>t?t.branchLabel??null:e??null,Hk=(t,e)=>{if(e)return null;const n=t?.branch?.trim(),r=at(t?.path??null);return n&&r?{directory:r,branch:n}:null},ai=(t,e,n,r)=>{if(!e)return null;const o=r?"archived":"active";let i=null;const d=a=>{if(`${n}:${o}:${a.session.id}`===e)return i=a.session.id,!0;for(const u of a.children)if(d(u))return!0;return!1};return t.forEach(a=>d(a)),i},Ro=t=>"run"in t,Gk=(t,e)=>`${t}:active:run:${e}`,Yi=(t,e,n)=>{if(n||e.runKeyBySessionId.size===0)return[...t];const r=[],o=new Map;for(const i of t){const d=e.runKeyBySessionId.get(i.session.id),a=d?e.runs.get(d):void 0;if(!a){r.push(i);continue}const c=o.get(a.key);if(c){c.lanes.push(i);continue}const u={run:a,lanes:[i]};o.set(a.key,u),r.push(u)}for(const i of o.values()){const d=new Map(i.run.memberIds.map((a,c)=>[a,c]));i.lanes.sort((a,c)=>(d.get(a.session.id)??0)-(d.get(c.session.id)??0))}return r},vp=(t,e)=>{const n=e.trim().toLowerCase(),r=n.startsWith("ses_"),o=i=>i.reduce((d,a)=>d+(!r||a.session.id.toLowerCase()===n?1:0)+o(a.children),0);return o(t)},qk=[],Yk=new Set,xd=32,yd=64,Qk=3,Xk=7,Mo=32,or=28,vd=(t,e,n,r)=>{const o=r.get(t.session.id),i=r.get(e.session.id);if(o!==void 0||i!==void 0){if(o===void 0)return 1;if(i===void 0)return-1;if(o!==i)return o-i}return ll(t.session,e.session,n,ol)},To=t=>{const e=new Map,n=new Map,r=[],o=new WeakMap,i=t.map(d=>({node:d,visited:!1})).reverse();for(;i.length>0;){const d=i.pop();if(!d)continue;if(!d.visited){e.set(d.node.session.id,d.node),n.set(d.node.session.id,d.node.session);const c=r.length;r.push(d.node.session.id),o.set(d.node,[c,c+1]),i.push({node:d.node,visited:!0});for(let u=d.node.children.length-1;u>=0;u-=1){const f=d.node.children[u];f&&i.push({node:f,visited:!1})}continue}const a=o.get(d.node);a&&o.set(d.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:n,preorderIds:Object.freeze(r),subtreeRangeByNode:o}},Jk=(t,e,n)=>`${t}:${e?"archived":"active"}:${n}`,Zk=(t,e)=>{let n=null;for(const r of t){if(r.rowIndex>e)break;n=r}return n},e2=t=>{const e=[],n=[],r=[],o=[],i=[],d=new Map,a=new Map,c=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds),f=t.workSessionIds??Yk;let p=0;const y=[...[...t.authoritativeSections.flatMap(k=>k.groups.flatMap(M=>M.sessions)),...t.chatGroup?.sessions??[]]];for(;y.length>0;){const k=y.pop();k&&(d.set(k.session.id,k.session),y.push(...k.children))}const x=k=>{const M=a.get(k)??0;return a.set(k,M+1),M===0?k:`${k}:${M}`},w=k=>{e.push(Object.freeze(k))},b=t.runIndex??$b,g=(k,M)=>{const V=Gk(M.renderContext,k.run.key),O=M.renderContext!=="timeline"&&(c||t.expandedParents.has(V)),E=k.lanes[0]?.session.id,R=E&&M.getSecondaryMeta?M.getSecondaryMeta(E):M.secondaryMeta,_=Object.freeze([...new Set(k.lanes.flatMap(U=>(M.getBlockingBadgeSessionScopes?.(U.session.id)??[]).flatMap(me=>me.sessionIDs)))]);w({kind:"run",key:x(`${M.containerKey}:run:${k.run.key}`),estimateSize:M.renderContext==="timeline"?yd:xd,run:k.run,depth:M.baseDepth??0,laneNodes:Object.freeze([...k.lanes]),blockingSessionIds:_,projectId:M.projectId,projectLabel:R?.projectLabel??null,groupDirectory:M.groupDirectory,renderContext:M.renderContext,expansionKey:V,expanded:O,forceExpanded:c}),O&&v(k.lanes,(M.baseDepth??0)+1,M)},h=k=>{for(const M of Yi(k.nodes,b,k.archived))Ro(M)?g(M,k):v([M],k.baseDepth??0,k)},v=(k,M,V)=>{const O=[...k].reverse().map(E=>({node:E,depth:M,directory:V.groupDirectory}));for(;O.length>0;){const E=O.pop();if(!E)continue;const R=x(`${V.containerKey}:session:${E.node.session.id}`),_=E.node.session.directory??E.directory;d.set(E.node.session.id,E.node.session),w({kind:"session",key:R,estimateSize:V.renderContext==="timeline"?yd:xd,node:E.node,blockingBadgeSessionScopes:E.depth===M?V.getBlockingBadgeSessionScopes?.(E.node.session.id)??V.blockingBadgeSessionScopes:void 0,depth:E.depth,projectId:V.projectId,groupDirectory:E.directory,ownerKey:V.ownerKey,selectionScopeKey:V.selectionScopeKey,archived:V.archived,renderContext:V.renderContext,secondaryMeta:V.getSecondaryMeta?V.getSecondaryMeta(E.node.session.id):V.secondaryMeta??null});const U=V.indexedNodes?.subtreeRangeByNode.get(E.node),me=U&&U[1]>U[0]+1?Object.freeze([(V.selectionPoolOffset??0)+U[0]+1,(V.selectionPoolOffset??0)+U[1]]):void 0;if(n.push(Object.freeze({id:E.node.session.id,rowKey:R,scopeKey:V.selectionScopeKey,archived:V.archived,descendantRange:me})),!(!c&&!t.expandedParents.has(Jk(V.renderContext,V.archived,E.node.session.id))))for(let ce=E.node.children.length-1;ce>=0;ce-=1){const oe=E.node.children[ce];oe&&O.push({node:oe,depth:E.depth+1,directory:_})}}},S=k=>{const M=t.groupSearchDataByGroup.get(k);if(M?.hasMatch!==!0)return 0;const V=f.size>0?M.filteredNodes.filter(E=>f.has(E.session.id)):[];return Math.max(0,M.matchedSessionCount-vp(V,t.normalizedQuery))+M.folderNameMatchCount+(M.groupMatches?1:0)},j=(k,M,V,O,E)=>{const R=t.groupSearchDataByGroup.get(k);if(c){const re=S(k);if(re===0)return;p+=re}const _=(c?R?.filteredNodes??[]:k.sessions).filter(re=>!f.has(re.session.id)).sort((re,H)=>vd(re,H,u,t.sessionOrderIndex)),U=To(_),me=r.length;r.push(...U.preorderIds);for(const[re,H]of U.sessionsById)d.set(re,H);const ce=Wn(V,k.directory),oe=!c&&t.collapsedGroups.has(M);if(!O){const re=U.preorderIds.flatMap(H=>U.sessionsById.get(H)??[]);w({kind:"group-header",key:`${M}:header`,estimateSize:Mo,group:k,groupKey:M,projectId:V,collapsed:oe,forceExpanded:c,allSessions:Object.freeze(re)})}if(oe)return;const ie=oo(k).flatMap(({scopeKey:re,directory:H})=>(t.foldersMap[re]??qk).map(ne=>({folder:ne,scopeKey:re,scopeDirectory:H,ownerKey:ce,nodes:Ba(ne.sessionIds,U.byId).sort((X,fe)=>vd(X,fe,u,t.sessionOrderIndex))}))),xe=xp(ie.map(re=>({id:re.folder.id,name:re.folder.name,parentId:re.folder.parentId,nodeCount:re.nodes.length})),{archivedBucket:k.isArchivedBucket===!0,searchQuery:c?t.normalizedQuery:""}),G=ie.filter(re=>xe.has(re.folder.id)),pe=new Map(G.map(re=>[ar(re.scopeKey,re.folder.id),re])),J=new Map;for(const re of G){if(!re.folder.parentId)continue;const H=ar(re.scopeKey,re.folder.parentId),ne=J.get(H)??[];ne.push(re),J.set(H,ne)}const ge=bp(G.map(re=>({...re.folder,scopeKey:re.scopeKey}))).map(re=>pe.get(ar(re.scopeKey??"",re.id))).filter(re=>!!re),de=new Set(G.flatMap(re=>re.folder.sessionIds)),Ae=_.filter(re=>!de.has(re.session.id)),he=new Map,Re=ge.map(re=>({folder:re,visited:!1})),se=new Set;for(;Re.length>0;){const re=Re.pop();if(!re)continue;const H=ar(re.folder.scopeKey,re.folder.folder.id);if(!re.visited){if(se.has(H))continue;se.add(H),Re.push({folder:re.folder,visited:!0});for(const X of J.get(H)??[])Re.push({folder:X,visited:!1});continue}const ne=re.folder.nodes.flatMap(X=>{const fe=U.subtreeRangeByNode.get(X);return fe?U.preorderIds.slice(fe[0],fe[1]).flatMap(Fe=>U.sessionsById.get(Fe)??[]):[X.session]});for(const X of J.get(H)??[])ne.push(...he.get(ar(X.scopeKey,X.folder.id))??[]);he.set(H,Object.freeze(ne))}const Ne=new Set,be=(re,H)=>{const ne=ar(re.scopeKey,re.folder.id);if(Ne.has(ne))return;Ne.add(ne);const X=H?`${H} / ${re.folder.name}`:re.folder.name,fe=`${M}:folder:${ne}`,Fe=!c&&t.collapsedFolders.has(re.folder.id),Me=he.get(ne)??[],tt=Fe&&!k.isArchivedBucket?Ba([...new Set(Me.map(_e=>_e.id))],U.byId):[],nt=ce?t.folderAuthorityByOwner.get(ce):void 0,Qe=!!ce&&!k.isArchivedBucket&&!Al(re.scopeKey)&&nt?.complete===!0&&nt.scopeKeys.includes(re.scopeKey);if(w({kind:"folder-header",key:fe,estimateSize:Mo,group:k,folder:re.folder,displayName:X,scopeKey:re.scopeKey,scopeDirectory:re.scopeDirectory,ownerKey:ce,nodes:re.nodes,activityNodes:tt,projectId:V,archived:k.isArchivedBucket===!0,collapsed:Fe,forceExpanded:c,deleteSessions:Me,subFolderCount:J.get(ne)?.length??0,dropEnabled:Qe}),ce&&i.push(Object.freeze({rowKey:fe,scopeKey:re.scopeKey,folderId:re.folder.id,ownerKey:ce,enabled:Qe})),!Fe){h({nodes:re.nodes,containerKey:fe,projectId:V,groupDirectory:re.scopeDirectory??k.directory,ownerKey:ce,selectionScopeKey:ce,archived:k.isArchivedBucket===!0,renderContext:"project",indexedNodes:U,selectionPoolOffset:me,baseDepth:1});for(const _e of J.get(ne)??[])be(_e,X)}};for(const re of ge)be(re,"");const we=V?t.sessionBatchSize:void 0,ye=E?.initial??we??(t.hideDirectoryControls?10:5),Pe=E?.increment??we??7,Oe=Math.max(ye,t.visibleCountByContainer.get(M)??ye),$e=re=>!Ro(re)&&E?.pinnedAlwaysVisible===!0&&cl(u,re.session.directory??k.directory,re.session.id),ze=Yi(Ae,b,k.isArchivedBucket===!0),Ue=ze.filter(re=>!$e(re));let q=Oe;const ue=k.isArchivedBucket||c?ze:ze.filter(re=>$e(re)?!0:q<=0?!1:(q-=1,!0)),A=ue.flatMap(re=>Ro(re)?re.lanes:[re]);h({nodes:A,containerKey:M,projectId:V,groupDirectory:k.directory,ownerKey:ce,selectionScopeKey:ce,archived:k.isArchivedBucket===!0,renderContext:E?.renderContext??"project",indexedNodes:U,selectionPoolOffset:me});const Q=ze.length-ue.length,le=Oe-q;!c&&!k.isArchivedBucket&&Q>0?w({kind:"show-control",key:`${M}:more`,estimateSize:or,control:"more",containerKey:M,currentCount:le,increment:Pe}):!c&&!k.isArchivedBucket&&Ue.length>ye&&Q===0&&w({kind:"show-control",key:`${M}:fewer`,estimateSize:or,control:"fewer",containerKey:M,currentCount:le,increment:Pe});const Ie=t.groupStatusByKey.get(M);_.length===0&&G.length===0?Ie&&Ie.state!=="ready"?w({kind:"status",key:`${M}:status`,estimateSize:or,status:Ie,group:k,groupKey:M}):w({kind:"empty",key:`${M}:empty`,estimateSize:or,emptyKind:k.isArchivedBucket?"archived":"group",group:k,projectId:V}):Ie&&Ie.state!=="ready"&&Ie.state!=="loading"&&w({kind:"status",key:`${M}:status`,estimateSize:or,status:Ie,group:k,groupKey:M})},N=k=>{const M=!c&&t.collapsedActivities.has(k),V=e.length;return w({kind:"activity-header",key:`activity:${k}:header`,estimateSize:Mo,activityKey:k,collapsed:M,forceExpanded:c}),o.push(Object.freeze({rowIndex:V,kind:"activity",id:k})),M},C=t.viewMode==="timeline",B=k=>"run"in k,W=k=>{const M=Yi(k.map(O=>O.node),b,!1),V=new Map(k.map(O=>[O.node,O]));return M.flatMap(O=>{if(!Ro(O)){const E=V.get(O);return E?[E]:[]}return[{run:O.run,items:O.lanes.flatMap(E=>V.get(E)??[])}]})},F=(k,M,V,O)=>{const E=k.items[0];if(!E)return;const R=k.items.map(ie=>ie.node),_=To(R),U=r.length;r.push(..._.preorderIds);const me=Wn(E.projectId,E.groupDirectory),ce=new Map(k.items.map(ie=>[ie.node.session.id,ie.getSecondaryMeta?ie.getSecondaryMeta(ie.node.session.id):ie.secondaryMeta])),oe=new Map(k.items.map(ie=>[ie.node.session.id,ie.blockingBadgeSessionScopes]));g({run:k.run,lanes:R},{nodes:R,containerKey:M,projectId:E.projectId,groupDirectory:E.groupDirectory,ownerKey:me,selectionScopeKey:O?me:null,archived:!1,renderContext:V,getSecondaryMeta:ie=>ce.get(ie)??null,getBlockingBadgeSessionScopes:ie=>oe.get(ie),indexedNodes:_,selectionPoolOffset:U})},$=(k,M,V,O,E=()=>1)=>{for(const R of W(k)){if(B(R)){F(R,M,V,O),c&&(p+=R.items.reduce((oe,ie)=>oe+E(ie),0));continue}const _=R,U=To([_.node]),me=r.length;r.push(...U.preorderIds);const ce=Wn(_.projectId,_.groupDirectory);h({nodes:[_.node],containerKey:M,projectId:_.projectId,groupDirectory:_.groupDirectory,ownerKey:ce,selectionScopeKey:null,archived:!1,renderContext:V,blockingBadgeSessionScopes:_.blockingBadgeSessionScopes,secondaryMeta:_.secondaryMeta,getSecondaryMeta:_.getSecondaryMeta,indexedNodes:U,selectionPoolOffset:me}),c&&(p+=E(_))}};t.chatGroup&&(!c||S(t.chatGroup)>0)&&(N("chats")||j(t.chatGroup,"activity:chats",null,!0,C?{initial:Qk,increment:Xk,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}:void 0));const K=t.workItems??[];if(K.length>0&&(N("work")||$(K,"activity:work",C?"timeline":"recent",!1,M=>Ch(M.node,t.normalizedQuery))),C){const k=(t.timelineItems??[]).filter(M=>!f.has(M.node.session.id));k.length>0&&(N("timeline")||$(k,"activity:timeline","timeline",!1))}if(!C&&t.showRecentSection)for(const k of t.recentSections){const M={...k,items:k.items.filter(ce=>!f.has(ce.node.session.id))};if(M.items.length===0||N("active-now"))continue;const O=`activity:${M.key}`,E=7,R=Math.max(E,t.visibleCountByContainer.get(O)??E),_=W(M.items),U=c?_:_.slice(0,R);for(const ce of U){if(B(ce)){F(ce,O,"recent",!0),c&&(p+=ce.items.length);continue}const oe=ce,ie=To([oe.node]),xe=r.length;r.push(...ie.preorderIds),h({nodes:[oe.node],containerKey:O,projectId:oe.projectId,groupDirectory:oe.groupDirectory,ownerKey:Wn(oe.projectId,oe.groupDirectory),selectionScopeKey:Wn(oe.projectId,oe.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:oe.secondaryMeta,getSecondaryMeta:oe.getSecondaryMeta,indexedNodes:ie,selectionPoolOffset:xe}),c&&(p+=1)}const me=_.length-U.length;!c&&me>0?w({kind:"show-control",key:`${O}:more`,estimateSize:or,control:"more",containerKey:O,currentCount:U.length,increment:7}):!c&&_.length>E&&w({kind:"show-control",key:`${O}:fewer`,estimateSize:or,control:"fewer",containerKey:O,currentCount:U.length,increment:7})}let I=C?[]:t.singleProjectMode?t.sections.filter(k=>k.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const k=I.find(M=>M.project.id===t.activeProjectId)??I[0];I=k?[k]:[]}for(const k of I){const M=_k(k,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(c&&!M.some(O=>S(O.group)>0))continue;const V=!c&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(k.project.id);if(!t.showOnlyMainWorkspace){const O=e.length;w({kind:"project-header",key:`project:${k.project.id}:header`,estimateSize:Mo,section:k,collapsed:V,forceExpanded:c}),o.push(Object.freeze({rowIndex:O,kind:"project",id:k.project.id}))}if(!V)for(const O of M)j(O.group,O.groupKey,O.projectId,O.hideGroupLabel)}e.length===0&&w({kind:"empty",key:c?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:c?"search":"sidebar"});const z=new Map;return e.forEach((k,M)=>z.set(k.key,M)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(n),selectionDescendantIds:Object.freeze(r),rowIndexByKey:z,stickyHeaders:Object.freeze(o),folderDropTargets:Object.freeze(i),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:d,searchMatchCount:c?p:0})},t2=(t,e)=>t.map(n=>{const r=at(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
996
|
-
`),s2=[],n2=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:o,projectRepoStatus:i,projectRootBranches:d,gitBranches:a,lastRepoStatus:c,buildGroupedSessions:u,hasSessionSearchQuery:f,normalizedSessionSearchQuery:p,filterSessionNodesForSearch:m,buildGroupSearchText:y,foldersMap:x,standaloneGroups:w}=t,b=l.useRef(new Map),g=l.useMemo(()=>{const W=b.current,F=new Map;let $=0,K=0;const I=(k,M)=>k.length===M.length&&k.every((V,O)=>V===M[O]),z=e.map(k=>{const M=n(k.id),V=r(k.id),O=o.get(k.normalizedPath)??s2,E=i.has(k.id)?!!i.get(k.id):c,R=d.get(k.id)??null,_=t2(O,a),U=W.get(k.id);if(U&&U.project===k&&I(U.activeSessions,M)&&I(U.archivedSessions,V)&&U.availableWorktrees===O&&U.rootBranch===R&&U.worktreeBranchesKey===_&&U.isRepo===E&&U.buildGroupedSessions===u)return $+=1,F.set(k.id,U),U.section;if(K+=1,U){const ie=U.project!==k?"project":I(U.activeSessions,M)?I(U.archivedSessions,V)?U.availableWorktrees!==O?"worktrees":U.rootBranch!==R?"branch":U.worktreeBranchesKey!==_?"worktreeBranches":U.isRepo!==E?"repo":"builder":"archived":"sessions";Hs(`ui.sidebar.project_section.rebuilt_reason.${ie}`)}const me=cf([...M,...V]),ce=u(me,k.normalizedPath,O,R,E),oe={project:k,groups:ce};return F.set(k.id,{project:k,activeSessions:M,archivedSessions:V,availableWorktrees:O,rootBranch:R,worktreeBranchesKey:_,isRepo:E,buildGroupedSessions:u,section:oe}),oe});return b.current=F,$>0&&Hs("ui.sidebar.project_section.reused",$),K>0&&Hs("ui.sidebar.project_section.rebuilt",K),z},[e,n,r,o,i,c,u,d,a]),h=l.useMemo(()=>g,[g]),v=l.useMemo(()=>{const W=new WeakMap;if(!f)return W;const $=p.trim().toLowerCase().startsWith("ses_"),K=I=>{const z=m(I.sessions,p),k=vp(z,p),M=!$&&Zo([y(I)],p),V=oo(I).flatMap(({scopeKey:E})=>x[E]??[]),O=$?0:V.filter(E=>Zo([E.name],p)).length;W.set(I,{filteredNodes:z,matchedSessionCount:k,folderNameMatchCount:O,groupMatches:M,hasMatch:M||k>0||O>0})};return h.forEach(I=>{I.groups.forEach(K)}),w.forEach(K),W},[f,h,w,m,p,y,x]),S=l.useMemo(()=>f?h.map(W=>({...W,groups:W.groups.filter(F=>v.get(F)?.hasMatch===!0)})).filter(W=>W.groups.length>0):h,[f,h,v]),j=f?S:h,N=l.useRef(new WeakMap),C=l.useMemo(()=>{const W=N.current;return j.map(F=>{const $=W.get(F);if($&&$.query===p)return $.section;const K=F.groups.filter(E=>!E.isArchivedBucket),I=F.groups.filter(E=>E.isArchivedBucket),z=K.flatMap(E=>f?v.get(E)?.filteredNodes??[]:E.sessions),k=K.map(E=>({scopeKey:E.folderScopeKey??at(E.directory??null),directory:E.directory??null})).filter(E=>!!E.scopeKey),M=K.find(E=>E.isMain)??null,V={id:"flat",label:M?.label??"",branch:M?.branch??null,description:M?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:M?.directory??F.project.normalizedPath,folderScopeKey:M?.folderScopeKey??F.project.normalizedPath,folderScopes:k,sessions:z};if(f){const E=K.map(R=>v.get(R)).filter(R=>!!R);v.set(V,{filteredNodes:z,matchedSessionCount:E.reduce((R,_)=>R+_.matchedSessionCount,0),folderNameMatchCount:E.reduce((R,_)=>R+_.folderNameMatchCount,0),groupMatches:E.some(R=>R.groupMatches),hasMatch:E.some(R=>R.hasMatch)})}const O={project:F.project,groups:[V,...I]};return W.set(F,{query:p,section:O}),O})},[v,f,p,j]),B=l.useMemo(()=>{if(!f)return 0;const W=($,K)=>{const I=v.get(K);if(!I)return $;const z=I.folderNameMatchCount+(I.groupMatches?1:0);return $+I.matchedSessionCount+z},F=j.reduce(($,K)=>K.groups.reduce(W,$),0);return w.reduce(W,F)},[f,j,w,v]);return{projectSections:g,visibleProjectSections:h,groupSearchDataByGroup:v,searchableProjectSections:S,sectionsForRender:j,flatSectionsForRender:C,searchMatchCount:B}},r2=180,wd=150,o2=2,i2=8,Sd=[-1,1],Qi=t=>`${t.directory}
|
|
997
|
-
${t.sessionId}`,a2=t=>t?.directory?.trim()||null,l2=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:o})=>{const i=l.useRef(new Map),d=l.useRef([]),a=l.useRef(new Set),c=l.useRef(0),u=l.useMemo(()=>cn(),[]),f=l.useCallback(()=>{c.current+=1,d.current=[],i.current.forEach(y=>window.clearTimeout(y)),i.current.clear()},[]),p=l.useCallback(()=>{if(!(!t||u))for(;a.current.size<o2&&d.current.length>0;){const y=d.current.shift();if(!y)break;if(y.generation!==c.current||Je.getState().currentSessionId===y.sessionId||ma(y.sessionId,y.directory).renderable)continue;const w=Qi(y);a.current.add(w),o({directory:y.directory,sessionID:y.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(w),p()})}},[t,u,o]),m=l.useCallback(y=>{const x=y?.id,w=a2(y);if(!t||u||!x||!w||x===e)return;const b={sessionId:x,directory:w,generation:c.current},g=Qi(b);if(ma(x,w).renderable||a.current.has(g)||d.current.some(S=>Qi(S)===g))return;const h=i.current.get(g);h!==void 0&&window.clearTimeout(h);const v=window.setTimeout(()=>{if(i.current.delete(g),b.generation!==c.current)return;const S=d.current;S.length>=i2&&S.shift(),S.push(b),p()},r2);i.current.set(g,v)},[e,t,u,p]);l.useEffect(()=>{f()},[f,e,t,u]),l.useEffect(()=>{if(!t||u||!e||n.length===0)return;const y=window.setTimeout(()=>{const x=n.findIndex(w=>w.id===e);if(!(x<0))for(const w of Sd)m(n[x+w])},wd);return()=>window.clearTimeout(y)},[e,t,u,m,n]),l.useEffect(()=>{if(!t||u||!e||r.length===0)return;const y=window.setTimeout(()=>{const x=r.findIndex(w=>w.id===e);if(!(x<0))for(const w of Sd)m(r[x+w])},wd);return()=>window.clearTimeout(y)},[e,t,u,r,m]),l.useEffect(()=>f,[f])},c2=t=>{const e=He.c(3),n=Je(d2);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],l2(r),null};function d2(t){return t.currentSessionId}const u2=t=>{const e=He.c(83),{folder:n,displayName:r,sessions:o,subFolderItems:i,isCollapsed:d,collapsedActivityState:a,onToggle:c,onRename:u,onDelete:f,children:p,renderBody:m,mobileVariant:y,alwaysShowActions:x,isRenaming:w,renameDraft:b,onRenameDraftChange:g,onRenameSave:h,onRenameCancel:v,droppableRef:S,isDropTarget:j,onNewSession:N,depth:C,hideActions:B,archivedBucket:W}=t,F=a===void 0?null:a,$=m===void 0?!0:m,I=x===void 0?y===void 0?!1:y:x,z=w===void 0?!1:w,k=b===void 0?"":b,M=j===void 0?!1:j,V=B===void 0?!1:B,O=W===void 0?!1:W,{t:E}=vt(),[R,_]=l.useState(!1),[U,me]=l.useState(""),ce=l.useRef(null),oe=z||R,ie=z?k:U;let xe;e[0]!==n.name?(xe=()=>{me(n.name),_(!0)},e[0]=n.name,e[1]=xe):xe=e[1];const G=xe;let pe;e[2]!==ie||e[3]!==n.name||e[4]!==z||e[5]!==u||e[6]!==h?(pe=()=>{const fe=ie.trim();fe&&fe!==n.name&&u(fe),z&&h&&h(),_(!1),me("")},e[2]=ie,e[3]=n.name,e[4]=z,e[5]=u,e[6]=h,e[7]=pe):pe=e[7];const J=pe;let ge;e[8]!==z||e[9]!==v?(ge=()=>{z&&v&&v(),_(!1),me("")},e[8]=z,e[9]=v,e[10]=ge):ge=e[10];const de=ge;let Ae;e[11]!==z||e[12]!==g?(Ae=fe=>{z&&g?g(fe):me(fe)},e[11]=z,e[12]=g,e[13]=Ae):Ae=e[13];const he=Ae;let Re,se;e[14]!==z?(Re=()=>{if(!z)return;const fe=()=>{const tt=ce.current;tt&&(tt.focus(),tt.select())},Fe=requestAnimationFrame(fe),Me=window.setTimeout(fe,0);return()=>{cancelAnimationFrame(Fe),window.clearTimeout(Me)}},se=[z],e[14]=z,e[15]=Re,e[16]=se):(Re=e[15],se=e[16]),l.useEffect(Re,se);const Ne=d?"folder":"folder-open",be=M&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let we;e[17]!==be?(we=Se("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",be),e[17]=be,e[18]=we):we=e[18];let ye;e[19]!==c||e[20]!==oe?(ye=oe?void 0:fe=>{fe.currentTarget.blur(),c()},e[19]=c,e[20]=oe,e[21]=ye):ye=e[21];const Pe=oe?void 0:"button",Oe=oe?void 0:0;let $e;e[22]!==c||e[23]!==oe?($e=oe?void 0:fe=>{(fe.key==="Enter"||fe.key===" ")&&(fe.preventDefault(),c())},e[22]=c,e[23]=oe,e[24]=$e):$e=e[24];let ze;e[25]!==n.name||e[26]!==d||e[27]!==E?(ze=d?E("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):E("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=d,e[27]=E,e[28]=ze):ze=e[28];const Ue=O?I?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":I?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let q;e[29]!==Ue?(q=Se("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1",Ue),e[29]=Ue,e[30]=q):q=e[30];const ue=M?"text-primary":"text-muted-foreground";let A;e[31]!==ue?(A=Se("h-3.5 w-3.5 flex-shrink-0",ue),e[31]=ue,e[32]=A):A=e[32];let Q;e[33]!==Ne||e[34]!==A?(Q=s.jsx(T,{name:Ne,className:A}),e[33]=Ne,e[34]=A,e[35]=Q):Q=e[35];let le;e[36]!==F||e[37]!==r||e[38]!==ie||e[39]!==n.name||e[40]!==de||e[41]!==he||e[42]!==J||e[43]!==d||e[44]!==M||e[45]!==oe||e[46]!==o||e[47]!==E?(le=oe?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:f2,onMouseDown:p2,onSubmit:fe=>{fe.preventDefault(),J()},children:[s.jsx("input",{ref:ce,value:ie,onChange:fe=>he(fe.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.folderItem.namePlaceholder"),onClick:m2,onPointerDown:h2,onMouseDown:g2,onKeyDown:fe=>{if(fe.key==="Escape"){fe.stopPropagation(),de();return}(fe.key===" "||fe.key==="Enter")&&fe.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:b2,onPointerDown:x2,onMouseDown:y2,children:s.jsx(T,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:fe=>{fe.stopPropagation(),de()},onPointerDown:v2,onMouseDown:w2,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(T,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("span",{className:Se("typography-ui-label font-semibold truncate",M?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(jt,{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:["• ",o.length]}),F?s.jsx(Nh,{state:F}):null,d?s.jsx(T,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(T,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=F,e[37]=r,e[38]=ie,e[39]=n.name,e[40]=de,e[41]=he,e[42]=J,e[43]=d,e[44]=M,e[45]=oe,e[46]=o,e[47]=E,e[48]=le):le=e[48];let Ie;e[49]!==q||e[50]!==Q||e[51]!==le?(Ie=s.jsxs("div",{className:q,children:[Q,le]}),e[49]=q,e[50]=Q,e[51]=le,e[52]=Ie):Ie=e[52];let re;e[53]!==I||e[54]!==O||e[55]!==n.name||e[56]!==G||e[57]!==V||e[58]!==f||e[59]!==N||e[60]!==oe||e[61]!==E?(re=!oe&&(!V||O)?s.jsx("div",{className:Se("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",I?"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:fe=>{fe.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-ring","aria-label":E("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:E("sessions.sidebar.project.actions.newSession"),children:s.jsx(T,{name:"add",className:"h-3.5 w-3.5"})}):null,O?null:s.jsx("button",{type:"button",onClick:fe=>{fe.stopPropagation(),G()},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-ring","aria-label":E("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(T,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:fe=>{fe.stopPropagation(),f()},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-ring","aria-label":O?E("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):E("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(T,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=I,e[54]=O,e[55]=n.name,e[56]=G,e[57]=V,e[58]=f,e[59]=N,e[60]=oe,e[61]=E,e[62]=re):re=e[62];let H;e[63]!==S||e[64]!==we||e[65]!==ye||e[66]!==Pe||e[67]!==Oe||e[68]!==$e||e[69]!==ze||e[70]!==Ie||e[71]!==re?(H=s.jsxs("div",{ref:S,className:we,onClick:ye,role:Pe,tabIndex:Oe,onKeyDown:$e,"aria-label":ze,children:[Ie,re]}),e[63]=S,e[64]=we,e[65]=ye,e[66]=Pe,e[67]=Oe,e[68]=$e,e[69]=ze,e[70]=Ie,e[71]=re,e[72]=H):H=e[72];let ne;e[73]!==p||e[74]!==d||e[75]!==$||e[76]!==o||e[77]!==i||e[78]!==E?(ne=!d&&$?s.jsxs("div",{className:"pb-1",children:[i,o.length>0?p:i?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:E("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=p,e[74]=d,e[75]=$,e[76]=o,e[77]=i,e[78]=E,e[79]=ne):ne=e[79];let X;return e[80]!==H||e[81]!==ne?(X=s.jsxs("div",{className:"oc-folder",children:[H,ne]}),e[80]=H,e[81]=ne,e[82]=X):X=e[82],X},wp=l.memo(u2);function f2(t){return t.stopPropagation()}function p2(t){return t.stopPropagation()}function m2(t){return t.stopPropagation()}function h2(t){return t.stopPropagation()}function g2(t){return t.stopPropagation()}function b2(t){return t.stopPropagation()}function x2(t){return t.stopPropagation()}function y2(t){return t.stopPropagation()}function v2(t){return t.stopPropagation()}function w2(t){return t.stopPropagation()}function S2(t){const e=He.c(11);let n,r,o;e[0]!==t?({notifyOnSubtasks:r,activityNodes:n,...o}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o):(n=e[1],r=e[2],o=e[3]);const i=o.isCollapsed&&!o.archivedBucket;let d;e[4]!==n||e[5]!==r||e[6]!==i?(d={nodes:n,includeUnreadSubtasks:r,enabled:i},e[4]=n,e[5]=r,e[6]=i,e[7]=d):d=e[7];const a=gu(d);let c;return e[8]!==a||e[9]!==o?(c=s.jsx(wp,{...o,collapsedActivityState:a}),e[8]=a,e[9]=o,e[10]=c):c=e[10],c}const ao=t=>{const e=He.c(13),{directory:n,className:r}=t,{t:o}=vt();let i;e[0]!==n?(i=Rm(n),e[0]=n,e[1]=i):i=e[1];const d=i;let a;if(e[2]!==d?(a=w=>w.sessions.get(d),e[2]=d,e[3]=a):a=e[3],!_t(a)?.tabs.some(cu))return null;let f;e[4]!==o?(f=o("sessions.sidebar.projectAction.active"),e[4]=o,e[5]=f):f=e[5];const p=f;let m;e[6]!==r?(m=Se("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=m):m=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(T,{name:"pulse",className:"size-3.5"}),e[8]=y):y=e[8];let x;return e[9]!==d||e[10]!==p||e[11]!==m?(x=s.jsx("span",{className:m,role:"img","aria-label":p,title:p,"data-action-directory":d,children:y}),e[9]=d,e[10]=p,e[11]=m,e[12]=x):x=e[12],x},j2=t=>{const e=He.c(19),{sessionId:n,dragKey:r,ownerKey:o,sessionDirectory:i,sessionTitle:d,archivedBucket:a,children:c}=t,u=o===void 0?null:o,f=a===void 0?!1:a,p=`session-drag:${r??n}`;let m;e[0]!==f||e[1]!==u||e[2]!==i||e[3]!==n||e[4]!==d?(m={type:"session",sessionId:n,ownerKey:u,sessionDirectory:i,sessionTitle:d,archivedBucket:f},e[0]=f,e[1]=u,e[2]=i,e[3]=n,e[4]=d,e[5]=m):m=e[5];let y;e[6]!==f||e[7]!==p||e[8]!==m?(y={id:p,disabled:f,data:m},e[6]=f,e[7]=p,e[8]=m,e[9]=y):y=e[9];const{attributes:x,listeners:w,setNodeRef:b,isDragging:g}=Ny(y);let h;e[10]!==w?(h=N=>{N.stopPropagation(),w?.onPointerDown&&w.onPointerDown(N)},e[10]=w,e[11]=h):h=e[11];const v=h,S=`touch-pan-y select-none${g?" opacity-30":""}`;let j;return e[12]!==x||e[13]!==c||e[14]!==v||e[15]!==w||e[16]!==b||e[17]!==S?(j=s.jsx("div",{ref:b,...x,...w,onPointerDown:v,className:S,children:c}),e[12]=x,e[13]=c,e[14]=v,e[15]=w,e[16]=b,e[17]=S,e[18]=j):j=e[18],j},Sp=t=>{const e=He.c(20),{folderId:n,scopeKey:r,ownerKey:o,disabled:i,children:d}=t,a=i===void 0?!1:i;let c;e[0]!==n||e[1]!==r?(c=ar(r,n),e[0]=n,e[1]=r,e[2]=c):c=e[2];const u=`folder-drop:${c}`;let f;e[3]!==a||e[4]!==r?(f=a||Al(r),e[3]=a,e[4]=r,e[5]=f):f=e[5];let p;e[6]!==n||e[7]!==o||e[8]!==r?(p={type:"folder",folderId:n,scopeKey:r,ownerKey:o},e[6]=n,e[7]=o,e[8]=r,e[9]=p):p=e[9];let m;e[10]!==u||e[11]!==f||e[12]!==p?(m={id:u,disabled:f,data:p},e[10]=u,e[11]=f,e[12]=p,e[13]=m):m=e[13];const{setNodeRef:y,isOver:x}=Ay(m);let w;e[14]!==d||e[15]!==x||e[16]!==y?(w=d(y,x),e[14]=d,e[15]=x,e[16]=y,e[17]=w):w=e[17];let b;return e[18]!==w?(b=s.jsx(s.Fragment,{children:w}),e[18]=w,e[19]=b):b=e[19],b},k2=t=>{const e=He.c(22),{scopeKey:n,ownerKey:r,hasFolders:o,onSessionDroppedOnFolder:i,children:d}=t,a=r===void 0?null:r;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activationConstraint:{distance:8}},e[0]=c):c=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const f=hi(In(bi,c),In(gi,u)),[p,m]=l.useState(null),[y,x]=l.useState("Session"),[w,b]=l.useState(null),[g,h]=l.useState(null);if(!n){let F;return e[2]!==d?(F=s.jsx(s.Fragment,{children:d}),e[2]=d,e[3]=F):F=e[3],F}let v;e[4]!==i||e[5]!==a?(v=F=>{m(null),b(null),h(null);const{active:$,over:K}=F;if(!K)return;const I=$.data.current,z=K.data.current;I?.type!=="session"||!I.sessionId||!I.ownerKey||I.archivedBucket===!0||a&&I.ownerKey!==a||z?.type!=="folder"||!z.folderId||!z.scopeKey||!z.ownerKey||Al(z.scopeKey)||z.ownerKey!==I.ownerKey||i(I.sessionId,{folderId:z.folderId,scopeKey:z.scopeKey,ownerKey:z.ownerKey},I.ownerKey)},e[4]=i,e[5]=a,e[6]=v):v=e[6];const S=v;let j,N;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=F=>{const $=F.active.data.current;if($?.type==="session"&&$.sessionId){m($.sessionId),x($.sessionTitle??"Session");const K=F.active.rect.current.initial?.width,I=F.active.rect.current.initial?.height;b(K??null),h(I??null)}},N=()=>{m(null),b(null),h(null)},e[7]=j,e[8]=N):(j=e[7],N=e[8]);let C;e[9]!==g||e[10]!==p||e[11]!==y||e[12]!==w||e[13]!==o?(C=p&&o?s.jsxs("div",{style:{width:w?`${w}px`:"auto",height:g?`${g}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(T,{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:y})]}):null,e[9]=g,e[10]=p,e[11]=y,e[12]=w,e[13]=o,e[14]=C):C=e[14];let B;e[15]!==C?(B=s.jsx(Py,{children:C}),e[15]=C,e[16]=B):B=e[16];let W;return e[17]!==d||e[18]!==S||e[19]!==f||e[20]!==B?(W=s.jsxs(xi,{sensors:f,collisionDetection:yi,onDragStart:j,onDragCancel:N,onDragEnd:S,children:[d,B]}),e[17]=d,e[18]=S,e[19]=f,e[20]=B,e[21]=W):W=e[21],W},jp=l.createContext(null),C2=({entries:t,descendantIds:e,sessionsById:n,children:r})=>{const o=l.useRef(t),i=l.useRef(e),d=l.useRef(n);o.current=t,i.current=e,d.current=n;const a=l.useRef(null);return a.current===null&&(a.current={getEntries:()=>o.current,getDescendantIds:()=>i.current,getSessionsById:()=>d.current}),s.jsx(jp.Provider,{value:a.current,children:r})},kp=()=>l.useContext(jp),N2=(t,e,n)=>{const r=t[0];if(!r)return null;const o=n??r.scopeKey,i=[],d=new Set;for(const a of t){if(o&&a.scopeKey!==o)continue;const c=a.descendantRange,u=c?[a.id,...e.slice(c[0],c[1])]:[a.id];for(const f of u)d.has(f)||(d.add(f),i.push(f))}return i.length>0?{ids:i,scopeKey:o}:null},Cp=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},A2=t=>{const e=He.c(37),{menuInstanceKey:n,contextMenuInstanceKey:r,openSidebarMenuKey:o,setOpenSidebarMenuKey:i,hasDeferredCloseWork:d,onCloseComplete:a}=t,[c,u]=l.useState(!1),[f,p]=l.useState(!1),m=o===n&&!f,y=r?o===r&&!f:c;let x;e[0]!==d||e[1]!==o||e[2]!==i?(x=$=>{if(o===$){if(d()){p(!0);return}i(null)}},e[0]=d,e[1]=o,e[2]=i,e[3]=x):x=e[3];const w=x;let b;e[4]!==n||e[5]!==w||e[6]!==i?(b=$=>{if($){u(!1),p(!1),i(n);return}w(n)},e[4]=n,e[5]=w,e[6]=i,e[7]=b):b=e[7];const g=b;let h;e[8]!==r||e[9]!==w||e[10]!==i?(h=$=>{if(!r){u($);return}if($){p(!1),i(r);return}w(r)},e[8]=r,e[9]=w,e[10]=i,e[11]=h):h=e[11];const v=h;let S;e[12]!==r||e[13]!==n||e[14]!==a||e[15]!==o||e[16]!==i?(S=$=>{$||(a(),p(!1),(o===n||o===r)&&i(null))},e[12]=r,e[13]=n,e[14]=a,e[15]=o,e[16]=i,e[17]=S):S=e[17];const j=S;let N;e[18]!==m||e[19]!==n||e[20]!==i?(N=()=>{p(!1),i(m?null:n)},e[18]=m,e[19]=n,e[20]=i,e[21]=N):N=e[21];const C=N;let B;e[22]!==v||e[23]!==g||e[24]!==y||e[25]!==m?(B=()=>{if(!m&&!y)return;const $=()=>{y&&v(!1),m&&g(!1)};return window.addEventListener("blur",$),()=>window.removeEventListener("blur",$)},e[22]=v,e[23]=g,e[24]=y,e[25]=m,e[26]=B):B=e[26];let W;e[27]!==y||e[28]!==m?(W=[m,y],e[27]=y,e[28]=m,e[29]=W):W=e[29],l.useEffect(B,W);let F;return e[30]!==v||e[31]!==g||e[32]!==j||e[33]!==y||e[34]!==m||e[35]!==C?(F={isMenuOpen:m,isContextMenuOpen:y,handleMenuOpenChange:g,handleContextMenuOpenChange:v,handleMenuOpenChangeComplete:j,toggleMenu:C},e[30]=v,e[31]=g,e[32]=j,e[33]=y,e[34]=m,e[35]=C,e[36]=F):F=e[36],F},P2=t=>{const e=He.c(10),{project:n,fallback:r}=t,{currentTheme:o}=uo(),i=n.iconImage??null;let d;e[0]!==n.id||e[1]!==i?(d={id:n.id,iconImage:i},e[0]=n.id,e[1]=i,e[2]=d):d=e[2];let a;e[3]!==o.colors.surface.foreground||e[4]!==o.metadata.variant?(a={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[3]=o.colors.surface.foreground,e[4]=o.metadata.variant,e[5]=a):a=e[5];let c;return e[6]!==r||e[7]!==d||e[8]!==a?(c=s.jsx(pf,{project:d,options:a,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=d,e[8]=a,e[9]=c):c=e[9],c},I2=t=>{const e=He.c(13),{project:n}=t,r=n?.icon?uf[n.icon]:null,o=n?.color?ff[n.color]??null:null;let i;e[0]!==o||e[1]!==r?(i=r?s.jsx(T,{name:r,className:Se("h-3.5 w-3.5",!o&&"text-muted-foreground/75"),style:o?{color:o}:void 0}):s.jsx(T,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/75",style:o?{color:o}:void 0}),e[0]=o,e[1]=r,e[2]=i):i=e[2];const d=i;if(!n?.iconImage){let f;return e[3]!==d?(f=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:d}),e[3]=d,e[4]=f):f=e[4],f}let a;e[5]!==n.iconBackground?(a=n.iconBackground?{backgroundColor:n.iconBackground}:void 0,e[5]=n.iconBackground,e[6]=a):a=e[6];let c;e[7]!==d||e[8]!==n?(c=s.jsx(P2,{project:n,fallback:d}),e[7]=d,e[8]=n,e[9]=c):c=e[9];let u;return e[10]!==a||e[11]!==c?(u=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:a,children:c}),e[10]=a,e[11]=c,e[12]=u):u=e[12],u},Fa=t=>{const e=He.c(56),{compact:n,project:r,projectLabel:o,title:i,titleClassName:d,branchLabel:a,thirdLineLead:c,statusDot:u,pinnedMarker:f,timeSlot:p,directoryIndicator:m,prBadge:y,zombieIndicator:x,goal:w,badges:b,doneHint:g,providerId:h,metaPaddingClass:v,hideMetaOnHoverClass:S,actionsReserveClass:j,actionsMaskClass:N}=t,C=n===void 0?!1:n,B=c===void 0?null:c,W=w===void 0?null:w,F=g===void 0?null:g,$=!C&&(!!a||!!B||!!y||!!x||!!W||!!b||!!h);let K;e[0]!==S||e[1]!==v?(K=Se("ml-auto flex flex-shrink-0 items-center gap-1 transition-opacity",v,S),e[0]=S,e[1]=v,e[2]=K):K=e[2];const I=C?W:null,z=C?b:null;let k;e[3]!==p?(k=s.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:p}),e[3]=p,e[4]=k):k=e[4];let M;e[5]!==m||e[6]!==F||e[7]!==f||e[8]!==u||e[9]!==K||e[10]!==I||e[11]!==z||e[12]!==k?(M=s.jsxs("span",{className:K,children:[I,z,m,f,F,u,k]}),e[5]=m,e[6]=F,e[7]=f,e[8]=u,e[9]=K,e[10]=I,e[11]=z,e[12]=k,e[13]=M):M=e[13];const V=M;if(C){let ie;e[14]!==j?(ie=Se("@container relative flex w-full min-w-0 items-center gap-1",j),e[14]=j,e[15]=ie):ie=e[15];let xe;e[16]!==N||e[17]!==d?(xe=Se("min-w-0 flex-1 truncate typography-ui-label font-normal",N,d),e[16]=N,e[17]=d,e[18]=xe):xe=e[18];let G;e[19]!==xe||e[20]!==i?(G=s.jsx("div",{dir:"auto",className:xe,children:i}),e[19]=xe,e[20]=i,e[21]=G):G=e[21];let pe;return e[22]!==V||e[23]!==ie||e[24]!==G?(pe=s.jsxs("div",{className:ie,children:[G,V]}),e[22]=V,e[23]=ie,e[24]=G,e[25]=pe):pe=e[25],pe}let O;e[26]!==j?(O=Se("@container relative flex h-5 w-full min-w-0 items-center gap-1",j),e[26]=j,e[27]=O):O=e[27];let E;e[28]!==r?(E=s.jsx(I2,{project:r}),e[28]=r,e[29]=E):E=e[29];let R;e[30]!==N||e[31]!==o?(R=o?s.jsx("span",{className:Se("min-w-0 truncate typography-micro text-muted-foreground/85 [--oc-actions-inset:18px]",N),children:o}):null,e[30]=N,e[31]=o,e[32]=R):R=e[32];let _;e[33]!==V||e[34]!==O||e[35]!==E||e[36]!==R?(_=s.jsxs("div",{className:O,children:[E,R,V]}),e[33]=V,e[34]=O,e[35]=E,e[36]=R,e[37]=_):_=e[37];let U;e[38]!==d?(U=Se("w-full min-w-0 truncate typography-ui-label font-normal",d),e[38]=d,e[39]=U):U=e[39];let me;e[40]!==U||e[41]!==i?(me=s.jsx("div",{dir:"auto",className:U,children:i}),e[40]=U,e[41]=i,e[42]=me):me=e[42];let ce;e[43]!==b||e[44]!==a||e[45]!==W||e[46]!==$||e[47]!==y||e[48]!==h||e[49]!==B||e[50]!==x?(ce=$?s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[B??(a?s.jsxs(s.Fragment,{children:[s.jsx(T,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:a})]}):null),s.jsxs("span",{className:"ml-auto flex flex-shrink-0 items-center gap-1",children:[W,x??y,b,h?s.jsx(df,{providerId:h,className:"h-4 w-4 flex-shrink-0 opacity-45"}):null]})]}):null,e[43]=b,e[44]=a,e[45]=W,e[46]=$,e[47]=y,e[48]=h,e[49]=B,e[50]=x,e[51]=ce):ce=e[51];let oe;return e[52]!==_||e[53]!==me||e[54]!==ce?(oe=s.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[_,me,ce]}),e[52]=_,e[53]=me,e[54]=ce,e[55]=oe):oe=e[55],oe},La=750,li=t=>{const e=He.c(4),{items:n}=t;let r;e[0]!==n?(r=n.map(M2),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==r?(o=s.jsx("div",{className:"flex min-w-0 flex-col gap-1",children:r}),e[2]=r,e[3]=o):o=e[3],o};function D2(t){return t.stopPropagation()}function E2(t){return t.stopPropagation()}function R2(t){return t.stopPropagation()}function M2(t){return s.jsxs("button",{type:"button",className:Se("group/ref flex min-w-0 flex-col rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default",!t.color&&"text-muted-foreground"),style:t.color?{color:t.color}:void 0,disabled:!t.url,onPointerDown:D2,onMouseDown:E2,onKeyDown:R2,onClick:e=>{e.stopPropagation(),t.url&&Gn(t.url)},children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 group-hover/ref:underline group-disabled/ref:no-underline",children:[s.jsx(T,{name:t.icon,className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:t.text})]}),t.title?s.jsx("span",{className:"min-w-0 truncate pl-[18px] text-muted-foreground",children:t.title}):null]},t.key)}let $a=!1;const _a=new Set;let jd=!1;function T2(){for(const t of _a)t()}function Np(t){$a!==t&&($a=t,T2())}function Oo(t){Np(t.shiftKey)}function O2(){Np(!1)}function B2(){if(jd||typeof window>"u")return;jd=!0;const t={capture:!0,passive:!0};window.addEventListener("keydown",Oo,t),window.addEventListener("keyup",Oo,t),window.addEventListener("pointermove",Oo,t),window.addEventListener("pointerdown",Oo,t),window.addEventListener("blur",O2)}function F2(t){return B2(),_a.add(t),()=>{_a.delete(t)}}function L2(){return $a}function $2(){return!1}function Ap(){return Ms.useSyncExternalStore(F2,L2,$2)}const Pp=async(t,e,n)=>{const r=n.getRuntimeKey(),o=at(t.path);if(!o)throw new Error("Unable to resolve worktree project");const i=await n.listProjectWorktrees(t,{force:!0});if(n.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const d=n.getCurrentProjects(),a=d.find(x=>x.id===t.id)??null;if(!a||at(a.path??null)!==o)throw new Error("Project removed during worktree refresh");const c=Pl({rawWorktreesByProjectRef:n.rawWorktreesByProjectRef,publishedWorktreesByProject:n.getPublishedWorktreesByProject(),runtimeKey:r}),u=i.map(x=>ci(x));u.sort((x,w)=>Ip({metadata:x},{metadata:w}));const f=_b(c.worktreesByProject,o,u,e?.projectDirectory);_2(n.rawWorktreesByProjectRef,r),n.rawWorktreesByProjectRef.current={runtimeKey:r,revision:n.rawWorktreesByProjectRef.current.revision,worktreesByProject:f};const p=n.getPublishedWorktreesByProject(),m=Kb(n.partitionWorktreesByRegisteredProject(d,f),p),y=[...m.values()].flat();return n.recordWorktreesSeen(y.map(x=>x.path),n.now()),n.worktreeMapsEqual(m,p)||n.publishTopology({availableWorktrees:y,availableWorktreesByProject:m}),u},_2=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),K2=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>ci(r))])),Pl=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:K2(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),Ip=(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,o=n.localeCompare(r,void 0,{sensitivity:"base"});return o!==0?o:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},kd=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},ci=t=>({...t,path:at(t.path)??t.path,projectDirectory:at(t.projectDirectory)??t.projectDirectory,worktreeRoot:at(t.worktreeRoot??t.path)??t.worktreeRoot}),Cd=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:o}=t,d=at(e?.path??null)===n,a=d?e?.branch??"":o??"",c={path:n,projectDirectory:r,branch:a,label:d?e?.label||e?.branch||e?.name||kd(n):o||kd(n),name:d?e?.name:void 0,worktreeRoot:d?at(e?.worktreeRoot??n)??n:n,worktreeStatus:d?e?.worktreeStatus??"ready":"ready",worktreeSource:d?e?.worktreeSource??"existing":"existing",headState:d?e?.headState:o?"branch":void 0};return d&&e?{...e,...c}:c},Nd=t=>{const e=at(t.projectPath??null),n=at(t.sourceDirectory??null)??at(t.currentWorktree?.path??null),r=at(t.discoveredWorktrees.find(f=>at(f.projectDirectory??null))?.projectDirectory??null),o=at(t.currentWorktree?.projectDirectory??null),i=r??o??e,d=new Map,a=f=>{const p=at(f.metadata.path??null);!p||d.has(p)||d.set(p,{...f,metadata:ci({...f.metadata,path:p})})};for(const f of t.discoveredWorktrees){const p=at(f.path??null);p&&a({metadata:ci({...f,path:p,projectDirectory:at(f.projectDirectory??null)??i??e??p}),isPrimary:i===p,isCurrent:n===p})}i&&!d.has(i)&&a({metadata:Cd({path:i,projectDirectory:i,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===i}),n&&!d.has(n)&&a({metadata:Cd({path:n,projectDirectory:i??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:i===n,isCurrent:!0});const c=[],u=[];for(const f of d.values()){if(f.isPrimary){c.push(f);continue}u.push(f)}return c.sort((f,p)=>f.metadata.path.localeCompare(p.metadata.path,void 0,{sensitivity:"base"})),u.sort(Ip),[...c,...u]},Dp=(t,e)=>{const n=t.projectId?e.projects.find(i=>i.id===t.projectId)??null:null;if(n)return n;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const o=t.currentWorktree?.projectDirectory??null;return o?e.resolveProject(o):null},W2=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),o=Pl({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),i=Dp(t,e),d=at(i?.path??null);return{cachedTargets:Nd({projectPath:d,discoveredWorktrees:d?o.worktreesByProject.get(d)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!i||!d)throw new Error("Unable to resolve worktree project");const c=await Pp(i,t.currentWorktree,e);return Nd({projectPath:d,discoveredWorktrees:c,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},z2=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},V2=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),U2=(t,e)=>at(t.worktree?.path??null)===at(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,H2=[],G2=[],q2=[],Yr=6,Bo=14,Ad=Yr+14+6,Xi=new WeakMap,Y2=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;Xi.get(n)?.();const r=e.getBoundingClientRect().top;let o=3,i=!1,d=null;const a=()=>{i=!0,d!==null&&window.cancelAnimationFrame(d),d=null,Xi.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},c=()=>{if(i||!e.isConnected||!n.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(n.scrollTop+=u,Hs("ui.sidebar.selection_scroll_anchor_adjustment")),o-=1,o<=0){a();return}d=window.requestAnimationFrame(c)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),Xi.set(n,a),d=window.requestAnimationFrame(c)},Q2=l.memo(function(e){const n=He.c(22),{archiveLabel:r,deleteLabel:o,buttonSizeClass:i,iconSizeClass:d,onPointerDown:a,onMouseDown:c,onArchive:u,onDelete:f}=e,p=Ap(),m=p?o:r;let y;n[0]!==u||n[1]!==f||n[2]!==p?(y=N=>{if(p||N.shiftKey){f(N);return}u(N)},n[0]=u,n[1]=f,n[2]=p,n[3]=y):y=n[3];const x=y,w=p?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let b;n[4]!==i||n[5]!==w?(b=Se("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",w,i),n[4]=i,n[5]=w,n[6]=b):b=n[6];const g=p?"delete-bin":"archive";let h;n[7]!==d||n[8]!==g?(h=s.jsx(T,{name:g,className:d}),n[7]=d,n[8]=g,n[9]=h):h=n[9];let v;n[10]!==x||n[11]!==m||n[12]!==c||n[13]!==a||n[14]!==b||n[15]!==h?(v=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",className:b,"aria-label":m,onPointerDown:a,onMouseDown:c,onClick:x,onKeyDown:oC,children:h})}),n[10]=x,n[11]=m,n[12]=c,n[13]=a,n[14]=b,n[15]=h,n[16]=v):v=n[16];let S;n[17]!==m?(S=s.jsx(jt,{side:"left",sideOffset:8,children:m}),n[17]=m,n[18]=S):S=n[18];let j;return n[19]!==v||n[20]!==S?(j=s.jsxs(Ct,{children:[v,S]}),n[19]=v,n[20]=S,n[21]=j):j=n[21],j});function X2(t){Hs("ui.sidebar_session_node.render");const{t:e}=vt(),{node:n,depth:r=0,groupDirectory:o,projectId:i,folderOwnerKey:d,selectionScopeKey:a,archivedBucket:c=!1,pinnedSessionIds:u,expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:m,notifyOnSubtasks:y,editingId:x,editingRowKey:w,setEditingId:b,setEditingRowKey:g,editTitle:h,setEditTitle:v,handleSaveEdit:S,handleCancelEdit:j,toggleParent:N,handleSessionSelect:C,handleSessionDoubleClick:B,handleCopySessionId:W,openSidebarMenuKey:F,setOpenSidebarMenuKey:$,createFolderAndStartRename:K,handleDeleteSession:I,handleRestoreSession:z,startSessionWorktreeMenuLoad:k,onEditProject:M,mobileVariant:V,alwaysShowActions:O,secondaryMeta:E,renderContext:R="project",blockingBadgeSessionScopes:_,rowKey:U,dragKey:me,children:ce}=t,oe=Tr(ae=>ae.toggle),ie=cs(ae=>ae.getFoldersForScope),xe=cs(ae=>ae.getSessionFolderId),G=cs(ae=>ae.removeSessionFromFolder),pe=cs(ae=>ae.addSessionToFolder),J=Ce(ae=>ae.openContextPanelTab),ge=l.useMemo(()=>cn(),[]),de=l.useMemo(()=>eo(),[]),Ae=l.useContext(Wb),he=ge?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-has-[:focus-visible]:opacity-100 group-has-[:focus-visible]:pointer-events-auto",Re=ge?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",se=ge,Ne=!c&&!V,be=Ce(ae=>ae.sessionWorkEnabled),we=Ce(ae=>ae.sessionRecapEnabled),ye=be&&!c&&!n.session.parentID&&!al(n.session.directory),Pe=ye&&!O,Oe=(Pe?1:0)+(Ne?1:0)+(se?1:0),$e=["group-hover:pr-8","group-hover:pr-14","group-hover:pr-18","group-hover:pr-22"][Oe],ze=Ne?"pr-13":"pr-7",Ue=l.useRef(!1),[q,ue]=l.useState(!1),A=l.useRef(x);A.current=x;const Q=l.useRef(null),le=l.useRef(!1),Ie=l.useRef(S);Ie.current=S;const re=h,H=l.useRef(re);H.current=re;const ne=l.useRef(null),X=l.useRef(!1),fe=l.useRef(null),Fe=l.useRef(null),Me=n.session,tt=Me,nt=as(l.useCallback(ae=>{if(E?.projectLabel||!i)return null;const Dt=ae.projects.find(ns=>ns.id===i);return Dt?Dt.label?.trim()||dl(at(Dt.path)??Dt.path,null)||Dt.path:null},[i,E?.projectLabel])),Qe=R==="timeline"||R==="timeline-chat",_e=R==="timeline-chat",wt=as(l.useCallback(ae=>!Qe||!i?null:ae.projects.find(Dt=>Dt.id===i)??null,[Qe,i])),ct=E?.projectLabel??(nt?mf(nt):null),gt=Uk(E,n.worktree?.branch??null),Kt=l.useMemo(()=>Hk(n.worktree,ge),[ge,n.worktree]),kt=hf(Kt?.directory??null,Kt?.branch??null),Ht=l.useMemo(()=>ge?H2:gf(Me),[ge,Me]),At=l.useMemo(()=>Ht.map(ae=>({item:so("pull",ae),url:ae.url,title:ae.title})),[Ht]),Et=mc(At),Bt=l.useMemo(()=>Et.filter(ae=>ae!==null),[Et]),Rt=l.useMemo(()=>ge?q2:zb(Me),[ge,Me]),Wt=l.useMemo(()=>Rt.flatMap(ae=>ae.gitlab?[{item:no("pull",ae.gitlab),url:ae.url,title:ae.title}]:[]),[Rt]),D=mc(Wt),je=l.useMemo(()=>Vb(kt,[...Bt,...D.filter(ae=>ae!==null)]),[kt,D,Bt]),L=l.useMemo(()=>{let ae=0;return Rt.filter(Dt=>{if(!Dt.gitlab)return!0;const ns=D[ae]!==null;return ae+=1,!ns})},[D,Rt]),te=l.useMemo(()=>Ub(Ht,je),[Ht,je]),ve=kt?`var(--pr-${kt.visualState})`:void 0,P=!!gt&&R==="recent",Z=l.useMemo(()=>ge?G2:ul(Me),[ge,Me]),Te=l.useMemo(()=>Z.flatMap(ae=>ae.source==="github"?[so("issue",ae)]:[]),[Z]),Le=ei(Te),We=l.useMemo(()=>Z.flatMap(ae=>ae.source==="gitlab"?[no("issue",ae.ref)]:[]),[Z]),Ge=ei(We),zt=l.useMemo(()=>Z.flatMap(ae=>ae.source==="linear"?[fl(ae.identifier)]:[]),[Z]),Ye=bf(zt),Ee=l.useMemo(()=>{if(je.length>0||te.length>0||L.length>0){const ae=je.map(Ut=>{const Ns=xf(Ut,e),rs=Za(Ut.provider,Ut.number);return{key:`${Ut.provider??""}:${Ut.repo?.owner??""}/${Ut.repo?.repo??""}#${Ut.number}`,icon:"git-pull-request",label:rs,color:`var(--pr-${Ut.visualState})`,url:Ut.url,title:Ut.title,text:Ns?`${rs} · ${Ns}`:rs}}),Dt=te.map(Ut=>({key:`${Ut.owner}/${Ut.repo}#${Ut.number}`,icon:"git-pull-request",label:`#${Ut.number}`,url:Ut.url,title:Ut.title,text:`#${Ut.number}`})),ns=L.map(Ut=>({key:Ut.key,icon:"git-pull-request",label:Ut.identifier,url:Ut.url,title:Ut.title,text:Ut.identifier}));return[...ae,...Dt,...ns]}return yf(Z,Le,Ye,Ge).map(ae=>({key:ae.key,icon:ae.icon,label:ae.label,color:ae.color??void 0,url:ae.url,title:ae.title,text:ae.statusKey?`${ae.label} · ${e(ae.statusKey)}`:ae.statusText?`${ae.label} · ${ae.statusText}`:ae.label}))},[Ge,Le,Z,Ye,te,je,e,L]),Pt=Ee[0]??null,Lt=Math.max(0,Ee.length-1),os=Ee.map(ae=>ae.text).join(", "),it=Je(ae=>ae.currentSessionId===Me.id),Ve=at(Me.directory??null)??at(o??null),Qt=a!==void 0?a:i??Ve??null,St=Du(),Yt=vf(),ft=ge,Vt=As(ae=>ae.enabled),et=As(l.useCallback(ae=>ae.selectedIds.has(Me.id),[Me.id])),It=As(ae=>ae.toggleSelected),ke=As(ae=>ae.setRange),qe=kp(),Ze=U??Me.id,Mt=x===Me.id&&w===Ze,$t=l.useCallback(ae=>{const Dt=[],ns=Ut=>{Ut.children.forEach(Ns=>{Dt.push(Ns.session.id),ns(Ns)})};return ns(ae),Dt},[]),Gt=l.useCallback(ae=>{const Dt=[],ns=Ut=>{Ut.children.forEach(Ns=>{Dt.push(Ns.session),ns(Ns)})};return ns(ae),Dt},[]),[Ot,xt]=l.useState(!1),[Tt,bs]=l.useState(!0),ht=`${R}:${c?"archived":"active"}:${Me.id}`,xs=U?`session-menu:${U}`:ht,ls=U?`session-context:${U}`:null,ys=wf(l.useCallback(ae=>!!ae.sessionMemoryState.get(Hb(Me.id))?.isZombie,[Me.id])),Es=vu(Me.id),De=Es!==null,ot=Gb(Me.id,De),dt=_f(Me.id),st=Ya(Me.id,Ve),pt=dt||st,Xt=n.worktree??Je.getState().getWorktreeMetadata(Me.id)??null,[us,is]=l.useState([]),[fs,ws]=l.useState(!1),[Xs,Ts]=l.useState(!1),sn=l.useRef(!1),ks=l.useRef(0),$s=qb(tt),_s=ye&&pl(tt),Tn=_s&&!De&&Yb(tt),gr=e(_s?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),gn=async()=>{try{await ax(Me.id,Ve,_s?"done":"open")}catch{Be.error(e("sessions.sidebar.session.work.updateFailed"))}},bn=$s?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(hc[$s.status]),"aria-label":e(hc[$s.status]),children:s.jsx(T,{name:"target",className:"h-3 w-3",style:{color:Qb[$s.status]}})}):null,Ks=tt.title||e("sessions.sidebar.session.untitled"),hs=!Qe&&n.children.length>0,ee=cl(u,Ve,Me.id),Xe=ht,bt=p?!0:f.has(Xe),Jt=l.useMemo(()=>_??Oa(n,bt,Ve),[bt,n,Ve,_]),{permissionCount:gs,formCount:Ps}=Xb(Jt),Cs=!!tt.parentID,Xn=wu(Me.id)>0&&(!Cs||y),ho=tt.time?.updated||tt.time?.created||Date.now(),xr=Jb(ho),Jn=Sf(ho),{isMenuOpen:go,isContextMenuOpen:Zn,handleMenuOpenChange:ki,handleContextMenuOpenChange:Ci,handleMenuOpenChangeComplete:Fr,toggleMenu:bo}=A2({menuInstanceKey:xs,contextMenuInstanceKey:ls,openSidebarMenuKey:F,setOpenSidebarMenuKey:$,hasDeferredCloseWork:()=>Q.current!==null,onCloseComplete:()=>{if(!Q.current)return;const{id:ae,title:Dt}=Q.current;Q.current=null,b(ae),g(Ze),v(Dt)}}),Us=go||Zn,On=l.useMemo(()=>Zb(tt)?.key??null,[tt]),er=l.useMemo(()=>$t(n).length,[$t,n]),yr=l.useCallback(async ae=>{const Dt=[];let ns=0;for(const Ut of ae)try{if(!Ve)throw new Error("Session directory is required for export");const Ns=await St({directory:Ve,sessionID:Ut.session.id});if(!Ns)throw new Error("Session runtime changed during export");const rs=Ut.session.title||e("sessions.sidebar.session.export.untitledSubagent"),nn=Ut.session.agent,ms=await yr(Ut.children);ns+=ms.skipped,Dt.push({title:rs,agent:nn,records:Ns,children:ms.children})}catch{ns+=$t(Ut).length+1}return{children:Dt,skipped:ns}},[$t,St,Ve,e]),Lr=l.useCallback(ae=>{ae<=0||Be.warning(ae===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:ae}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:ae}))},[e]),$r=l.useCallback(async ae=>{if(!Ve){Be.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Dt=await St({directory:Ve,sessionID:Me.id}).catch(()=>null);if(!Dt){Be.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Dt.length===0){Be.error(e("sessions.sidebar.session.export.nothingToExport"));return}let ns,Ut=0;if(ae&&n.children.length>0){const ms=await yr(n.children);ns=ms.children,Ut=ms.skipped}const Ns=Eu(Dt,tt.title??null,ns),rs=Ru(tt.title??null),nn=await Mu(Ns,rs);if(nn){Be.success(e("sessions.sidebar.session.export.success"),{action:{label:e(tx()),onClick:()=>{ex(nn).then(ms=>{ms||Be.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),Lr(Ut);return}Tu(Ns,rs),Be.success(e("sessions.sidebar.session.export.success")),Lr(Ut)},[yr,St,n.children,tt.title,Me.id,Ve,Lr,e]),Ni=Ou(),Il=l.useMemo(()=>Bu(Ni),[Ni]),Dl=l.useCallback(ae=>{Lf({entry:ae,t:e,session:{id:Me.id,title:tt.title,directory:Ve},loadRecords:()=>Ve?St({directory:Ve,sessionID:Me.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>Be.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[St,tt.title,Me.id,Ve,e]),Y=l.useCallback(async()=>{if(n.children.length>0){bs(!0),xt(!0);return}await $r(!1)},[$r,n.children.length]),Ke=l.useCallback(()=>{Ve&&Un("desktop_open_session_mini_chat_window",{sessionId:Me.id,directory:Ve,apiBaseUrl:Yo(),clientToken:ta()}).catch(ae=>{console.warn("[session-sidebar] failed to open mini chat window",ae)})},[Me.id,Ve]);if(l.useEffect(()=>{if(!Mt)return;const ae=Dt=>{const Ut=(Dt.target instanceof HTMLElement?Dt.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Ze)}"]`);Fe.current&&!Ut&&Ie.current(H.current)};return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[Mt,Ze]),l.useLayoutEffect(()=>{if(!Mt){ne.current===Ze&&(ne.current=null);return}ne.current!==Ze&&(ne.current=Ze,X.current=!0)},[h,Mt,Ze]),l.useLayoutEffect(()=>{if(!Mt||!X.current)return;const ae=fe.current;!ae||ae.value!==h||(X.current=!1,ae.focus(),ae.select())},[h,Mt,re]),Mt){const ae=s.jsxs("form",{ref:Fe,"data-session-rename-form":Ze,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:Dt=>{Dt.preventDefault(),S(re)},children:[s.jsx("input",{ref:fe,value:re,onChange:Dt=>v(Dt.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:Dt=>oa(Dt,j)}),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(T,{name:"check",className:"size-3.5"})}),s.jsx("button",{type:"button",onClick:j,"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(T,{name:"close",className:"size-3.5"})})]});return Qe?s.jsx("div",{style:{paddingLeft:Yr+4},className:Se("group relative my-0.5 flex items-center rounded-md pr-2.5",_e?"py-1":"py-1.5",it&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:s.jsx(Fa,{compact:_e,project:wt,projectLabel:ct,title:ae,titleClassName:"text-foreground",branchLabel:gt,statusDot:null,pinnedMarker:null,timeSlot:Jn,directoryIndicator:null,prBadge:Pt?s.jsxs("span",{className:Se("inline-flex flex-shrink-0 items-center gap-1 typography-micro",!Pt.color&&"text-muted-foreground"),style:Pt.color?{color:Pt.color}:void 0,children:[s.jsx(T,{name:Pt.icon,className:"h-3 w-3"}),s.jsx("span",{className:"leading-none tabular-nums",children:Pt.label}),Lt>0?s.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",Lt]}):null]}):null,zombieIndicator:null,goal:bn,badges:null,hideMetaOnHoverClass:""})},Me.id):s.jsx("div",{style:{paddingLeft:Ad+r*Bo},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:ae})},Me.id)}const rt=Ps===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:Ps}),lt=Vk({actionsAlwaysVisible:O&&!ge,menuOpen:Us,hideOnHoverClass:Re}),Ft=!pt&&!De&&Xn&&!it,yt=De||Ft,mt=s.jsx(ku,{state:Es??"unread"}),Zt=(De||Ft)&&ot,es=Qe&&!_e?["[--oc-actions-reserve:14px]","[--oc-actions-reserve:36px]","[--oc-actions-reserve:58px]","[--oc-actions-reserve:80px]"][Oe]:["[--oc-actions-reserve:10px]","[--oc-actions-reserve:28px]","[--oc-actions-reserve:46px]","[--oc-actions-reserve:64px]"][Oe],qt=O?void 0:Us?"oc-actions-mask":ge?"group-hover:oc-actions-mask":"group-hover:oc-actions-mask group-has-[:focus-visible]:oc-actions-mask",ps=Us?"opacity-0":Re,Ws=!O&&hs&&(pt||yt||ee),tr=ee&&!pt&&!yt,Os=s.jsx(T,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),Bn=s.jsx(T,{name:"loader-4",className:"h-3 w-3 flex-shrink-0 animate-spin text-primary","aria-label":e(st?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}),vr=pt||yt||tr?s.jsx("span",{style:{left:Yr+r*Bo},className:Se("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",Ws?"opacity-100 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0":""),children:pt?Bn:yt?mt:tr?Os:null}):null,_r=hs&&!O&&(pt||yt||ee),Up=hs?s.jsx("span",{role:"button",tabIndex:0,onClick:ae=>{ae.stopPropagation(),ae.currentTarget.blur(),N(Xe)},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.stopPropagation(),N(Xe))},style:{minWidth:14,minHeight:14,left:Yr+r*Bo},className:Se("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-ring transition-opacity",_r?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-has-[:focus-visible]:opacity-100 group-has-[:focus-visible]:pointer-events-auto":""),"aria-label":e(bt?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:bt?s.jsx(T,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(T,{name:"arrow-right-s",className:"h-3 w-3"})}):null,Ai=ys?s.jsx(T,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Hp=ae=>{ae.preventDefault(),ae.stopPropagation(),bo()},Gp=ae=>{ae.preventDefault(),ae.stopPropagation()},qp=ae=>{ae.preventDefault(),ae.stopPropagation()},Pi=ae=>{ae.preventDefault(),ae.stopPropagation()},Ii=ae=>{ae.preventDefault(),ae.stopPropagation()},Yp=ae=>{ae.preventDefault(),ae.stopPropagation(),$(null),I(Me,{archivedBucket:c})},Qp=ae=>{ae.preventDefault(),ae.stopPropagation(),$(null),I(Me,{archivedBucket:c,hardDelete:!0,skipConfirm:!0})},Xp=ae=>{ae.preventDefault(),ae.stopPropagation()},Jp=ae=>{ae.preventDefault(),ae.stopPropagation()},Zp=ae=>{ae.preventDefault(),ae.stopPropagation(),Ae?.vscode?.executeCommand("openchamber.openSessionInEditor",Me.id,Ks)},El=ae=>{if(Ue.current){Ue.current=!1;return}if(Vt){if(ae?.preventDefault(),ae?.stopPropagation(),ae?.shiftKey){const Dt=qe?.getEntries(),ns=Dt??Array.from(document.querySelectorAll("[data-session-row]")).map(rs=>rs.getAttribute("data-session-row")).filter(rs=>!!rs).map(rs=>({id:rs,rowKey:rs,scopeKey:Qt,archived:c})),Ut=Dt?As.getState().anchorRowKey:As.getState().anchorId,Ns=new Map;Ns.set(Me.id,$t(n)),ke(Ut,Ze,ns,qe?.getDescendantIds()??[],Qt,Ns);return}It(Me.id,Qt,$t(n),Ze);return}ae?.currentTarget&&Y2(ae.currentTarget),C(Me.id,Ve)},em=ae=>{ae.defaultPrevented||(ae.target instanceof HTMLElement?ae.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||El(ae)},tm=ae=>{(ae.button===2||ae.button===0&&ae.ctrlKey&&!Vt)&&(Ue.current=!0)},sm=ae=>{V&&ae.pointerType==="touch"&&ue(!0),ae.button===0&&!it&&!Vt&&!ft&&Ve&&!ma(Me.id,Ve).renderable&&Yt({directory:Ve,sessionID:Me.id}).catch(()=>{})},Rl=ae=>{V&&ae.pointerType==="touch"&&ue(!1)},nm=ae=>{sn.current=ae,ks.current+=1;const Dt=ks.current;if(!ae){ws(!1),Ts(!1);return}const ns=k({projectId:i??null,sourceDirectory:Ve,currentWorktree:Xt});is(ns.cachedTargets),ws(!0),Ts(!1),ns.refreshTargets.then(Ut=>{!sn.current||ks.current!==Dt||(is(Ut),ws(!1),Ts(!1))}).catch(()=>{!sn.current||ks.current!==Dt||(ws(!1),Ts(!0))})},Ml=({Item:ae,Separator:Dt,Sub:ns,SubTrigger:Ut,SubContent:Ns})=>s.jsxs(s.Fragment,{children:[s.jsx(ds,{hint:e("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(ae,{onClick:()=>{Q.current={id:Me.id,title:Ks}},className:"[&>svg]:mr-1",children:[s.jsx(T,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]})}),s.jsx(wa,{sessionID:Me.id,directory:Ve,open:Us,Item:ae}),s.jsx(ds,{hint:e("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(ae,{onClick:()=>W(Me.id),className:"[&>svg]:mr-1",children:[s.jsx(T,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]})}),s.jsx(ds,{hint:e(ee?"sessions.sidebar.session.menuHint.unpin":"sessions.sidebar.session.menuHint.pin"),children:s.jsxs(ae,{onClick:()=>Ve&&oe({directory:Ve,sessionId:Me.id}),className:"[&>svg]:mr-1",children:[ee?s.jsx(T,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(T,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(ee?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]})}),ye?s.jsx(ds,{hint:e(_s?"sessions.sidebar.session.menuHint.markDone":"sessions.sidebar.session.menuHint.track"),children:s.jsxs(ae,{onClick:()=>{gn()},className:"[&>svg]:mr-1",children:[s.jsx(T,{name:_s?"check":"eye",className:"mr-1 h-4 w-4"}),e(_s?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]})}):null,s.jsx(ds,{hint:e("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(ae,{onClick:()=>{Y()},className:"[&>svg]:mr-1",children:[s.jsx(T,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]})}),Il.map(rs=>s.jsxs(ae,{onClick:()=>Dl(rs),className:"[&>svg]:mr-1",children:[s.jsx(fo,{icon:rs.icon,iconSrc:rs.iconSrc,className:"mr-1 size-4"}),rs.action.label]},`${rs.guest.id}:${rs.action.id}`)),Qe&&i&&M?s.jsxs(ae,{onClick:()=>M(i),className:"[&>svg]:mr-1",children:[s.jsx(T,{name:"pencil-ai",className:"h-4 w-4"}),e("sessions.sidebar.project.actions.edit")]}):null,Kk({isSubtaskSession:Cs,archivedBucket:!!c,isVSCode:ge,sessionDirectory:Ve})?(()=>{const rs=Wk({sessionDirectory:Ve,isStreaming:De,isMovingToWorktree:dt}),nn=V2({targets:us,isRefreshing:fs,loadFailed:Xs});return s.jsxs(ns,{onOpenChange:nm,children:[s.jsx(ds,{hint:e(dt?"sessions.sidebar.session.moveToWorktree.tooltipMoving":De?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets"),children:s.jsxs(Ut,{disabled:rs,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":Me.id,children:[s.jsx(T,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsxs(Ns,{className:"min-w-[220px]","data-session-worktree-submenu":Me.id,children:[us.map(ms=>{const rn=at(ms.metadata.path??null)??ms.metadata.path,Kr=ms.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):ms.metadata.label||ms.metadata.branch||ms.metadata.name||ms.metadata.path,Is=ms.isCurrent||ms.metadata.worktreeStatus!=="ready";return s.jsxs(ae,{disabled:Is,title:ms.metadata.path,"data-session-worktree-target":rn,onClick:()=>{Is||!Ve||ja({kind:"existing",root:tt,descendants:Gt(n),sourceDirectory:Ve,destination:ms.metadata,messages:Sa(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:Kr}),ms.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),ms.isCurrent?s.jsx(T,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},rn)}),nn.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,nn.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(Dt,{}),s.jsxs(ae,{disabled:rs,"data-session-worktree-new-action":"true",onClick:()=>{rs||!Ve||ja({kind:"quick",root:tt,descendants:Gt(n),sourceDirectory:Ve,messages:Sa(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(T,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,On?s.jsx(ds,{hint:e("sessions.sidebar.session.menuHint.openRunOverview"),children:s.jsxs(ae,{onClick:()=>Ce.getState().setRunOverviewKey(On),className:"[&>svg]:mr-1",children:[s.jsx(ha,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]})}):null,Ve&&!c&&!Qe?(()=>{const rs=[],nn=Is=>{const Bs=at(Is??null);Bs&&!rs.includes(Bs)&&rs.push(Bs)};if(i&&!ge){const Is=as.getState().projects.find(wr=>wr.id===i),Bs=at(Is?.path??null);nn(Bs),Bs&&(Je.getState().availableWorktreesByProject.get(Bs)??[]).forEach(wr=>nn(wr.path))}nn(il(Ve)),nn(Ve);const ms=rs.flatMap(Is=>ie(Is).map(Bs=>({scope:Is,folder:Bs}))),rn=ms.find(({scope:Is,folder:Bs})=>xe(Is,Me.id)===Bs.id)??null,Kr=rs[0]??Ve;return s.jsxs(s.Fragment,{children:[s.jsx(Dt,{}),s.jsxs(ns,{children:[s.jsx(ds,{hint:e("sessions.sidebar.session.menuHint.moveToFolder"),children:s.jsxs(Ut,{className:"[&>svg]:mr-1",children:[s.jsx(T,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]})}),s.jsxs(Ns,{className:"min-w-[180px]",children:[ms.length===0?s.jsx(ae,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):ms.map(({scope:Is,folder:Bs})=>{const wr=rn?.folder.id===Bs.id;return s.jsxs(ae,{onClick:()=>{if(wr){G(Is,Me.id);return}rn&&rn.scope!==Is&&G(rn.scope,Me.id),pe(Is,Bs.id,Me.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:Bs.name}),wr?s.jsx(T,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},Bs.id)}),s.jsx(Dt,{}),s.jsxs(ae,{onClick:()=>{const Is=K(Kr);Is&&(le.current=!0,rn&&rn.scope!==Kr&&G(rn.scope,Me.id),pe(Kr,Is.id,Me.id))},children:[s.jsx(T,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),rn?s.jsxs(ae,{onClick:()=>{G(rn.scope,Me.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(T,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,ge?null:s.jsx(ds,{hint:e("sessions.sidebar.session.menuHint.openInSidePanel"),children:s.jsxs(ae,{disabled:!Ve,onClick:()=>{Ve&&J(Ve,{mode:"chat",dedupeKey:`session:${Me.id}`,label:Ks,sessionTitleFallback:Ks})},className:"[&>svg]:mr-1",children:[s.jsx(T,{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")})]})}),de?s.jsx(ds,{hint:e("sessions.sidebar.session.menuHint.openMiniChatWindow"),children:s.jsxs(ae,{disabled:!Ve,onClick:Ke,className:"[&>svg]:mr-1",children:[s.jsx(T,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]})}):null,s.jsx(Dt,{}),c?null:s.jsx(ds,{hint:e("sessions.sidebar.session.menuHint.archive"),children:s.jsxs(ae,{className:"[&>svg]:mr-1",onClick:()=>I(Me,{archivedBucket:c}),children:[s.jsx(T,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]})}),c?s.jsx(ds,{hint:e("sessions.sidebar.session.menuHint.restore"),children:s.jsxs(ae,{className:"[&>svg]:mr-1",onClick:()=>z(Me),children:[s.jsx(T,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]})}):null,s.jsx(ds,{hint:e("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(ae,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>I(Me,{archivedBucket:c,hardDelete:!0}),children:[s.jsx(T,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})})]}),rm=ae=>{ae.preventDefault(),ae.stopPropagation(),gn()},Di=O?"h-6 w-6":Qe&&!_e?"h-5 w-5":"h-4 w-4",xo=O?"h-3.5 w-3.5":Qe&&!_e?"h-3 w-3":"h-2.5 w-2.5",om=O?"h-4 w-4":Qe&&!_e?"h-3.5 w-3.5":"h-3 w-3",Tl=we&&!De&&sx(tt)?.recap||null,Ol=e("sessions.sidebar.session.work.doneSuggested"),Ei=ae=>Tn?s.jsx("span",{className:Se("inline-flex flex-shrink-0 items-center text-muted-foreground/75",ae),title:Ol,"aria-label":Ol,children:s.jsx(T,{name:"check",className:"h-3.5 w-3.5"})}):null,Bl=!Qe&&Tn,im=gs>0||Ps>0||Bl?s.jsxs(s.Fragment,{children:[Bl?Ei():null,gs>0?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(T,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:gs})]}):null,Ps>0?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info",title:rt,"aria-label":rt,children:[s.jsx(T,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Ps})]}):null]}):null,am=Qe&&Pt?s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,closeDelay:La,children:s.jsxs("button",{type:"button",className:Se("inline-flex flex-shrink-0 items-center gap-1 rounded typography-micro hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",!Pt.color&&"text-muted-foreground"),style:Pt.color?{color:Pt.color}:void 0,disabled:!Pt.url,"aria-label":os,onPointerDown:Pi,onMouseDown:Ii,onClick:ae=>{ae.preventDefault(),ae.stopPropagation(),Pt.url&&Gn(Pt.url)},onKeyDown:ae=>ae.stopPropagation(),children:[s.jsx(T,{name:Pt.icon,className:"h-3 w-3"}),s.jsx("span",{className:"leading-none tabular-nums",children:Pt.label}),Lt>0?s.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",Lt]}):null]})}),s.jsx(jt,{side:"top",sideOffset:6,className:"max-w-xs",children:s.jsx(li,{items:Ee})})]}):null,lm=Qe?s.jsx(Fa,{compact:_e,project:wt,projectLabel:ct,title:Jr(Ks,m),titleClassName:it||et?"text-interactive-selection-foreground":Xn?"text-foreground":"text-foreground/80",branchLabel:gt,statusDot:pt?Bn:yt?mt:null,pinnedMarker:ee&&!pt?Os:null,timeSlot:Zt?s.jsx(Fi,{sessionId:Me.id,running:De,className:"typography-micro"}):Jn,directoryIndicator:!c&&Ve?s.jsx(ao,{directory:Ve}):null,prBadge:am,zombieIndicator:Ai,goal:bn,badges:im,doneHint:Ei(),providerId:tt.model?.providerID??null,metaPaddingClass:O?Ne?"pr-13":"pr-7":void 0,hideMetaOnHoverClass:O&&!ge?"":ps,actionsReserveClass:es,actionsMaskClass:qt}):null,cm=s.jsx(Ys,{align:"end",className:"min-w-[180px]",finalFocus:()=>le.current?(le.current=!1,!1):!A.current,children:Ml({Item:ts,Separator:Vs,Sub:rx,SubTrigger:ox,SubContent:ix})}),dm=s.jsx(ba,{children:s.jsx(xa,{className:"app-region-no-drag z-50",children:s.jsx(ya,{"data-slot":"dropdown-menu-content",finalFocus:()=>le.current?(le.current=!1,!1):!A.current,style:{color:"var(--surface-elevated-foreground)"},className:Se(ia,"min-w-[180px]"),children:Ml({Item:({className:ae,...Dt})=>s.jsx(Ef,{className:Se(ju,ae),...Dt}),Separator:({className:ae,...Dt})=>s.jsx(Df,{className:Se(Su,ae),...Dt}),Sub:Ry,SubTrigger:({className:ae,children:Dt,...ns})=>s.jsxs(My,{className:Se(nx,ae),...ns,children:[Dt,s.jsx(T,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:ae,children:Dt,...ns})=>s.jsx(ba,{children:s.jsx(xa,{className:"app-region-no-drag z-50",children:s.jsx(ya,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Se(ia,ae),...ns,children:Dt})})})})})})});return s.jsxs(l.Fragment,{children:[s.jsx(j2,{sessionId:Me.id,dragKey:me??Ze,ownerKey:d??Qt,sessionDirectory:Ve??null,sessionTitle:Ks,archivedBucket:c,children:s.jsxs(Mf,{open:Zn,onOpenChange:Ci,onOpenChangeComplete:Fr,children:[s.jsxs(Rf,{render:s.jsx("div",{"data-session-row":Me.id,"data-session-scope":Qt??"","data-session-archived":c?"1":"0","aria-current":it?"page":void 0,onClick:em,style:{paddingLeft:Qe?Yr+4:Ad+r*Bo},className:Se("group relative my-0.5 flex cursor-pointer items-center rounded-md pr-2.5",Qe&&!_e?"py-1.5":"py-1",Qe&&!(it||et)&&"hover:bg-interactive-hover/60",(it||et)&&"bg-interactive-selection/70 text-interactive-selection-foreground",et&&"ring-1 ring-inset ring-border")}),children:[Qe?null:vr,Qe?null:Up,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,closeDelay:La,disabled:ge||Qe,children:s.jsx("button",{type:"button","aria-pressed":Vt?et:void 0,onPointerDown:sm,onPointerUp:Rl,onPointerCancel:Rl,onMouseDown:tm,onClick:ae=>El(ae),onDoubleClick:ae=>{ae.stopPropagation(),B(Me.id,Ks)},className:Se("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-ring text-foreground select-none",q&&"bg-interactive-hover/70",Qe||!O?void 0:ge?$e:ze),children:Qe?lm:s.jsxs("div",{className:Se("@container flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",es),children:[s.jsx("div",{dir:"auto",className:Se("block min-w-0 flex-1 truncate typography-ui-label font-normal",qt,it||et?"text-interactive-selection-foreground":Xn?"text-foreground":"text-foreground/80"),children:Jr(Ks,m)}),!c&&Ve&&R==="recent"?s.jsx(ao,{directory:Ve,className:O?void 0:Se("transition-opacity",ps)}):null,Ei(Se(lt,O?"ml-2":"ml-1")),O?s.jsx("span",{className:Se("inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",!Tn&&"ml-2"),children:Zt?s.jsx(Fi,{sessionId:Me.id,running:De}):s.jsxs(s.Fragment,{children:[bn,P?s.jsx(T,{name:"git-branch",className:Se("h-3 w-3",!ve&&"text-muted-foreground/60"),style:ve?{color:ve}:void 0}):null,Jn]})}):Zt||bn||P||R==="recent"?s.jsx("div",{className:Se("relative flex h-4 flex-shrink-0 items-center justify-end transition-opacity",!Tn&&"ml-1",ps),children:s.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:Zt?s.jsx(Fi,{sessionId:Me.id,running:De,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[bn,P?s.jsx(T,{name:"git-branch",className:Se("h-3 w-3",!ve&&"text-muted-foreground/60"),style:ve?{color:ve}:void 0}):null,R==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:Jn}):null]})})}):null,gs>0?s.jsxs("span",{className:Se("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",lt),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(T,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:gs})]}):null,Ps>0?s.jsxs("span",{className:Se("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",lt),title:rt,"aria-label":rt,children:[s.jsx(T,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Ps})]}):null]})})}),!ge&&!Qe?s.jsx(jt,{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",{dir:"auto",className:"min-w-0 truncate font-medium text-foreground",children:Ks}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:xr,children:Jn})]}),ct&&!Qe?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(T,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:ct})]}):null,gt?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(T,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:ve?{color:ve}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:gt})]}):null,Ee.length>0?s.jsx(li,{items:Ee}):null,Tl?s.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:Tl}):null]})}):null]})}),Ai&&!V&&!Qe?s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 z-10",children:Ai}):null,s.jsx("div",{className:Se("absolute right-1 z-10 flex items-center gap-0.5 transition-opacity",Qe&&!_e?"top-1.5 h-5":"top-1/2 -translate-y-1/2",Us||O&&!ge?"opacity-100":Se("opacity-0",he)),children:s.jsxs(pi,{delayDuration:400,children:[Pe?s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",className:Se("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",Di,_s?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":gr,onPointerDown:Pi,onMouseDown:Ii,onClick:rm,onKeyDown:ae=>ae.stopPropagation(),children:s.jsx(T,{name:_s?"check":"eye",className:_s?om:xo})})}),s.jsx(jt,{side:"left",sideOffset:8,children:gr})]}):null,Ne?s.jsx(Q2,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:Di,iconSizeClass:xo,onPointerDown:Pi,onMouseDown:Ii,onArchive:Yp,onDelete:Qp}):null,se?s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",className:Se("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-ring transition-opacity",Di),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Xp,onMouseDown:Jp,onClick:Zp,onKeyDown:ae=>ae.stopPropagation(),children:s.jsx(T,{name:"external-link",className:xo})})}),s.jsx(jt,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(Qs,{open:go,onOpenChange:ki,onOpenChangeComplete:Fr,children:[s.jsx(qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Se("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-ring transition-opacity",O?"h-6 w-6 opacity-100":Us?"h-4 w-4 opacity-100":Se("h-4 w-4 opacity-0",he)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Gp,onMouseDown:qp,onClick:Hp,onKeyDown:ae=>ae.stopPropagation(),children:s.jsx(T,{name:"more-2",className:xo})})}),cm]})]})})]}),dm]})}),hs&&bt?ce:null,s.jsx(en,{open:Ot,onOpenChange:xt,children:s.jsxs(tn,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(pn,{children:[s.jsx(mn,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(hn,{children:er===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:er}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:er})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Tt,onChange:ae=>bs(ae.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(pr,{children:[s.jsx(ut,{type:"button",onClick:()=>xt(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{type:"button",onClick:()=>{xt(!1),$r(Tt)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},Me.id)}const Pd=t=>at(t.session.directory??null),J2=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),Z2=t=>{if(!t.openSidebarMenuKey)return null;if(t.rowKey&&(t.openSidebarMenuKey===`session-menu:${t.rowKey}`||t.openSidebarMenuKey===`session-context:${t.rowKey}`))return t.node.session.id;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},Id=t=>t.menuOpenSessionId??Z2(t),Fo=(t,e,n)=>e?n.has(t.node.session.id)?!0:Br(t.node,e):!1,Ka=(t,e,n,r,o)=>{if(t.session.id!==e.session.id)return!0;const i=o(t);if(n.has(i)!==r.has(i)||t.children.length!==e.children.length)return!0;for(let d=0;d<t.children.length;d+=1)if(Ka(t.children[d],e.children[d],n,r,o))return!0;return!1},eC=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return Ka(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${t.renderContext??"project"}:${n}:${o.session.id}`)||Ka(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${e.renderContext??"project"}:${r}:${o.session.id}`)},tC=(t,e)=>t.id===e.id&&t.title===e.title&&t.directory===e.directory&&t.parentID===e.parentID&&t.time?.created===e.time?.created&&t.time?.updated===e.time?.updated&&t.time?.archived===e.time?.archived&&t.time?.idle===e.time?.idle&&t.metadata===e.metadata&&jf(t,e),sC=(t,e)=>{if(t.node.session.id!==e.node.session.id||!tC(t.node.session,e.node.session)||!U2(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(Pd(t.node)!==Pd(e.node))return"nodeDirectory";if(!J2(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&yp(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&eC(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(Fo(t,t.editingId,t.subtreeContainsEditing)||Fo(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editingRowKey!==e.editingRowKey&&(t.editingRowKey===t.rowKey||e.editingRowKey===e.rowKey))return"editingRowKey";if(t.editTitle!==e.editTitle&&(Fo(t,t.editingId,t.subtreeContainsEditing)||Fo(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=Id(t),o=Id(e);if(Br(t.node,r)||Br(e.node,o))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&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.handleCopySessionId===e.handleCopySessionId&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.onEditProject===e.onEditProject&&t.children===e.children?null:"callbacks"},nC=(t,e)=>{const n=sC(t,e);return n===null?!0:(Hs(`ui.sidebar_session_node.props_changed.${n}`),!1)},rC=l.memo(X2,nC);function oC(t){return t.stopPropagation()}const iC=t=>{const{t:e}=vt(),n=l.useRef(null),r=l.useRef(t.editingId),o=l.useRef(t.editTitle),i=l.useRef(t.deleteSessionConfirm);r.current=t.editingId,o.current=t.editTitle,i.current=t.deleteSessionConfirm;const d=Ce(E=>E.setSessionSwitcherOpen),a=Je(E=>E.setCurrentSession),c=Je(E=>E.updateSessionTitle),u=Je(E=>E.deleteSession),f=Je(E=>E.deleteSessions),p=Je(E=>E.archiveSession),m=Je(E=>E.archiveSessions),y=Je(E=>E.unarchiveSession),{mobileVariant:x,allowReselect:w,onSessionSelected:b,resetSessionSearch:g,descendantIds:h,showDeletionDialog:v,setDeleteSessionConfirm:S,setEditingId:j,setEditingRowKey:N,editingSessionId:C,editingOccurrenceKey:B,setEditTitle:W}=t;l.useEffect(()=>()=>{const E=n.current;E&&clearTimeout(E)},[]);const F=l.useCallback((E,R)=>{if(na("navigation.session_select"),Ce.getState().closeMainSurfaces(),x&&d(!1),E===Je.getState().currentSessionId){w&&b?.(E),g();return}na("navigation.session_state_set"),a(E,R??null),b?.(E),g()},[w,x,b,g,a,d]),$=l.useCallback((E,R)=>{j(E),N(B),W(R)},[B,W,j,N]),K=l.useCallback(async E=>{if(!r.current)return;const _=(E??o.current).trim();if(_)try{await c(C,_)}catch(U){console.error("[session-actions] rename failed",U),Be.error(e("sessions.sidebar.session.rename.error",{detail:bu(U instanceof Error?U:new Error(String(U)),e)}))}j(null),N(null),W("")},[C,W,j,N,e,c]),I=l.useCallback(()=>{j(null),N(null),W("")},[W,j,N]),z=l.useCallback(E=>{ur(E).then(R=>{if(R.ok){Be.success(e("sessions.sidebar.session.copyId.success"));return}Be.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Be.error(e("sessions.sidebar.session.copyId.error")))},[e]),k=l.useCallback(async(E,R,_)=>{const U=R?.archivedBucket===!0||R?.hardDelete===!0,me=_?.descendantIds??h;await Ah(U?"delete":"archive",E,me,{archiveSession:p,archiveSessions:m,deleteSession:u,deleteSessions:f},e)},[p,m,u,f,h,e]),M=l.useCallback((E,R)=>{const _=R?.archivedBucket===!0||R?.hardDelete===!0,U=fu(E.id,h,_);if(!v||R?.skipConfirm===!0){k(E,R,{descendantIds:U});return}S({session:E,descendantCount:U.length,descendantIds:U,archivedBucket:_})},[h,k,S,v]),V=l.useCallback(async()=>{const E=i.current;if(!E)return;const{session:R,archivedBucket:_,descendantIds:U}=E;S(null),await k(R,{archivedBucket:_},{descendantIds:U})},[k,S]),O=l.useCallback(async E=>{await y(E.id)?Be.success(e("sessions.sidebar.session.restore.success")):Be.error(e("sessions.sidebar.session.restore.error"))},[e,y]);return l.useMemo(()=>({handleSessionSelect:F,handleSessionDoubleClick:$,handleSaveEdit:K,handleCancelEdit:I,handleCopySessionId:z,handleDeleteSession:M,handleRestoreSession:O,confirmDeleteSession:V}),[I,z,M,O,K,$,F,V])};function aC(t){const e=He.c(71),{t:n}=vt(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:d,onConfirm:a}=t;let c,u,f,p,m,y,x,w,b,g;if(e[0]!==o||e[1]!==n||e[2]!==r){const E=n("sessions.sidebar.session.untitled");p=en,b=!!r,e[13]!==o?(g=_=>{_||o(null)},e[13]=o,e[14]=g):g=e[14],f=tn,x=!1,w="max-w-sm gap-5",u=pn;let R;e[15]!==n||e[16]!==r?.archivedBucket?(R=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=R):R=e[17],e[18]!==R?(y=s.jsx(mn,{children:R}),e[18]=R,e[19]=y):y=e[19],c=hn,m=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||E,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||E,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||E,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||E,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||E}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||E}),e[0]=o,e[1]=n,e[2]=r,e[3]=c,e[4]=u,e[5]=f,e[6]=p,e[7]=m,e[8]=y,e[9]=x,e[10]=w,e[11]=b,e[12]=g}else c=e[3],u=e[4],f=e[5],p=e[6],m=e[7],y=e[8],x=e[9],w=e[10],b=e[11],g=e[12];let h;e[20]!==c||e[21]!==m?(h=s.jsx(c,{children:m}),e[20]=c,e[21]=m,e[22]=h):h=e[22];let v;e[23]!==u||e[24]!==y||e[25]!==h?(v=s.jsxs(u,{children:[y,h]}),e[23]=u,e[24]=y,e[25]=h,e[26]=v):v=e[26];let S;e[27]!==d||e[28]!==i?(S=()=>d(!i),e[27]=d,e[28]=i,e[29]=S):S=e[29];const j=!i;let N;e[30]!==i?(N=i?s.jsx(T,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(T,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=i,e[31]=N):N=e[31];let C;e[32]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=C):C=e[33];let B;e[34]!==N||e[35]!==C||e[36]!==S||e[37]!==j?(B=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-ring","aria-pressed":j,children:[N,C]}),e[34]=N,e[35]=C,e[36]=S,e[37]=j,e[38]=B):B=e[38];let W;e[39]!==o?(W=()=>o(null),e[39]=o,e[40]=W):W=e[40];let F;e[41]!==n?(F=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=F):F=e[42];let $;e[43]!==W||e[44]!==F?($=s.jsx("button",{type:"button",onClick:W,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-ring",children:F}),e[43]=W,e[44]=F,e[45]=$):$=e[45];let K;e[46]!==a?(K=()=>{a()},e[46]=a,e[47]=K):K=e[47];let I;e[48]!==n||e[49]!==r?.archivedBucket?(I=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=I):I=e[50];let z;e[51]!==K||e[52]!==I?(z=s.jsx("button",{type:"button",onClick:K,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:I}),e[51]=K,e[52]=I,e[53]=z):z=e[53];let k;e[54]!==$||e[55]!==z?(k=s.jsxs("div",{className:"flex items-center gap-2",children:[$,z]}),e[54]=$,e[55]=z,e[56]=k):k=e[56];let M;e[57]!==B||e[58]!==k?(M=s.jsxs(pr,{className:"w-full sm:items-center sm:justify-between",children:[B,k]}),e[57]=B,e[58]=k,e[59]=M):M=e[59];let V;e[60]!==f||e[61]!==x||e[62]!==M||e[63]!==w||e[64]!==v?(V=s.jsxs(f,{showCloseButton:x,className:w,children:[v,M]}),e[60]=f,e[61]=x,e[62]=M,e[63]=w,e[64]=v,e[65]=V):V=e[65];let O;return e[66]!==p||e[67]!==V||e[68]!==b||e[69]!==g?(O=s.jsx(p,{open:b,onOpenChange:g,children:V}),e[66]=p,e[67]=V,e[68]=b,e[69]=g,e[70]=O):O=e[70],O}function lC(t){const e=He.c(57),{t:n}=vt(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:d,onConfirm:a}=t,c=r?.archivedBucket===!0,u=r?.sessionCount??0;let f;e[0]!==c||e[1]!==u||e[2]!==n?(f=n(c?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=c,e[1]=u,e[2]=n,e[3]=f):f=e[3];const p=f;let m;e[4]!==c||e[5]!==u||e[6]!==n?(m=c?u===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=c,e[5]=u,e[6]=n,e[7]=m):m=e[7];const y=m,x=!!r;let w;e[8]!==o?(w=O=>{O||o(null)},e[8]=o,e[9]=w):w=e[9];let b;e[10]!==p?(b=s.jsx(mn,{children:p}),e[10]=p,e[11]=b):b=e[11];let g;e[12]!==y?(g=s.jsx(hn,{children:y}),e[12]=y,e[13]=g):g=e[13];let h;e[14]!==b||e[15]!==g?(h=s.jsxs(pn,{children:[b,g]}),e[14]=b,e[15]=g,e[16]=h):h=e[16];let v;e[17]!==d||e[18]!==i?(v=()=>d(!i),e[17]=d,e[18]=i,e[19]=v):v=e[19];const S=!i;let j;e[20]!==i?(j=i?s.jsx(T,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(T,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=i,e[21]=j):j=e[21];let N;e[22]!==n?(N=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=N):N=e[23];let C;e[24]!==N||e[25]!==v||e[26]!==S||e[27]!==j?(C=s.jsxs("button",{type:"button",onClick:v,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-ring","aria-pressed":S,children:[j,N]}),e[24]=N,e[25]=v,e[26]=S,e[27]=j,e[28]=C):C=e[28];let B;e[29]!==o?(B=()=>o(null),e[29]=o,e[30]=B):B=e[30];let W;e[31]!==n?(W=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=W):W=e[32];let F;e[33]!==B||e[34]!==W?(F=s.jsx("button",{type:"button",onClick:B,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-ring",children:W}),e[33]=B,e[34]=W,e[35]=F):F=e[35];let $;e[36]!==a?($=()=>{a()},e[36]=a,e[37]=$):$=e[37];let K;e[38]!==c||e[39]!==n?(K=n(c?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=c,e[39]=n,e[40]=K):K=e[40];let I;e[41]!==$||e[42]!==K?(I=s.jsx("button",{type:"button",onClick:$,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:K}),e[41]=$,e[42]=K,e[43]=I):I=e[43];let z;e[44]!==F||e[45]!==I?(z=s.jsxs("div",{className:"flex items-center gap-2",children:[F,I]}),e[44]=F,e[45]=I,e[46]=z):z=e[46];let k;e[47]!==C||e[48]!==z?(k=s.jsxs(pr,{className:"w-full sm:items-center sm:justify-between",children:[C,z]}),e[47]=C,e[48]=z,e[49]=k):k=e[49];let M;e[50]!==k||e[51]!==h?(M=s.jsxs(tn,{showCloseButton:!1,className:"max-w-sm gap-5",children:[h,k]}),e[50]=k,e[51]=h,e[52]=M):M=e[52];let V;return e[53]!==x||e[54]!==M||e[55]!==w?(V=s.jsx(en,{open:x,onOpenChange:w,children:M}),e[53]=x,e[54]=M,e[55]=w,e[56]=V):V=e[56],V}function Ep(t){const e=He.c(36),{t:n}=vt(),{value:r,setValue:o,onConfirm:i}=t,d=!!r;let a;e[0]!==o?(a=j=>{j||o(null)},e[0]=o,e[1]=a):a=e[1];let c;e[2]!==n?(c=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=c):c=e[3];let u;e[4]!==c?(u=s.jsx(mn,{children:c}),e[4]=c,e[5]=u):u=e[5];let f;e[6]!==n||e[7]!==r?(f=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]=f):f=e[8];let p;e[9]!==f?(p=s.jsx(hn,{children:f}),e[9]=f,e[10]=p):p=e[10];let m;e[11]!==u||e[12]!==p?(m=s.jsxs(pn,{children:[u,p]}),e[11]=u,e[12]=p,e[13]=m):m=e[13];let y;e[14]!==o?(y=()=>o(null),e[14]=o,e[15]=y):y=e[15];let x;e[16]!==n?(x=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=x):x=e[17];let w;e[18]!==y||e[19]!==x?(w=s.jsx("button",{type:"button",onClick:y,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-ring",children:x}),e[18]=y,e[19]=x,e[20]=w):w=e[20];let b;e[21]!==n?(b=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=b):b=e[22];let g;e[23]!==i||e[24]!==b?(g=s.jsx("button",{type:"button",onClick:i,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:b}),e[23]=i,e[24]=b,e[25]=g):g=e[25];let h;e[26]!==g||e[27]!==w?(h=s.jsxs(pr,{children:[w,g]}),e[26]=g,e[27]=w,e[28]=h):h=e[28];let v;e[29]!==h||e[30]!==m?(v=s.jsxs(tn,{showCloseButton:!1,className:"max-w-sm gap-5",children:[m,h]}),e[29]=h,e[30]=m,e[31]=v):v=e[31];let S;return e[32]!==d||e[33]!==a||e[34]!==v?(S=s.jsx(en,{open:d,onOpenChange:a,children:v}),e[32]=d,e[33]=a,e[34]=v,e[35]=S):S=e[35],S}const cC=new Set;function dC(t){const e=He.c(114),{node:n,depth:r,groupDirectory:o,projectId:i,folderOwnerKey:d,selectionScopeKey:a,archivedBucket:c,secondaryMeta:u,renderContext:f,rowKey:p,dragKey:m,renderExtras:y,pinnedSessionIds:x,expandedParents:w,hasSessionSearchQuery:b,normalizedSessionSearchQuery:g,notifyOnSubtasks:h,editingId:v,editingRowKey:S,setEditingId:j,setEditingRowKey:N,editTitle:C,setEditTitle:B,toggleParent:W,openSidebarMenuKey:F,setOpenSidebarMenuKey:$,allowReselect:K,onSessionSelected:I,resetSessionSearch:z,deleteSessionConfirm:k,setDeleteSessionConfirm:M,startFolderRename:V,startSessionWorktreeMenuLoad:O,onEditProject:E,mobileVariant:R,alwaysShowActions:_,renderChildren:U}=t,me=r===void 0?0:r,ce=c===void 0?!1:c,oe=f===void 0?"project":f,ie=U===void 0?!0:U;Hs("ui.sidebar_tree_item.render");const xe=p??`${oe}:${ce?"archived":"active"}:${n.session.id}`,G=cs(mC),pe=cs(pC),J=Ce(fC),ge=Ce(uC);let de;if(e[0]!==n){de=[];const ne=X=>X.children.forEach(fe=>{de.push(fe.session.id),ne(fe)});ne(n),e[0]=n,e[1]=de}else de=e[1];const Ae=de.join(`
|
|
998
|
-
`);let he;e[2]!==Ae?(he=Ae?Ae.split(`
|
|
999
|
-
`):[],e[2]=Ae,e[3]=he):he=e[3];const Re=he;let se;e[4]!==G||e[5]!==V||e[6]!==pe?(se=(ne,X)=>{if(!ne)return null;X&&cs.getState().collapsedFolderIds.has(X)&&pe(X);const fe=G(ne,"New folder",X);return V(ne,fe),fe},e[4]=G,e[5]=V,e[6]=pe,e[7]=se):se=e[7];const Ne=se;let be;e[8]!==K||e[9]!==k||e[10]!==Re||e[11]!==C||e[12]!==v||e[13]!==xe||e[14]!==R||e[15]!==n.session.id||e[16]!==I||e[17]!==z||e[18]!==M||e[19]!==B||e[20]!==j||e[21]!==N||e[22]!==J?(be={mobileVariant:R,allowReselect:K,onSessionSelected:I,resetSessionSearch:z,descendantIds:Re,showDeletionDialog:J,setDeleteSessionConfirm:M,deleteSessionConfirm:k,editingId:v,setEditingId:j,setEditingRowKey:N,editingSessionId:n.session.id,editingOccurrenceKey:xe,editTitle:C,setEditTitle:B},e[8]=K,e[9]=k,e[10]=Re,e[11]=C,e[12]=v,e[13]=xe,e[14]=R,e[15]=n.session.id,e[16]=I,e[17]=z,e[18]=M,e[19]=B,e[20]=j,e[21]=N,e[22]=J,e[23]=be):be=e[23];const we=iC(be),ye=y?.childRenderExtrasFor,Pe=n.session.directory??o;let Oe;e[24]!==ce||e[25]!==i||e[26]!==oe||e[27]!==Pe?(Oe={groupDirectory:Pe,projectId:i,archivedBucket:ce,renderContext:oe},e[24]=ce,e[25]=i,e[26]=oe,e[27]=Pe,e[28]=Oe):Oe=e[28];const $e=Oe,ze=m??p??n.session.id,Ue=y?.subtreeContainsEditing??cC,q=y?.menuOpenSessionId??null,ue=y?.nodeStructureKey??"",A=y?.blockingBadgeSessionScopes,Q=y?.relativeTimeTick;let le;e[29]!==K||e[30]!==_||e[31]!==$e||e[32]!==ye||e[33]!==k||e[34]!==me||e[35]!==C||e[36]!==v||e[37]!==S||e[38]!==w||e[39]!==d||e[40]!==b||e[41]!==R||e[42]!==n.children||e[43]!==g||e[44]!==h||e[45]!==I||e[46]!==F||e[47]!==x||e[48]!==ie||e[49]!==z||e[50]!==a||e[51]!==M||e[52]!==B||e[53]!==j||e[54]!==N||e[55]!==$||e[56]!==V||e[57]!==O||e[58]!==W?(le=ie?n.children.map(ne=>s.jsx(di,{node:ne,pinnedSessionIds:x,expandedParents:w,hasSessionSearchQuery:b,normalizedSessionSearchQuery:g,notifyOnSubtasks:h,editingId:v,editingRowKey:S,setEditingId:j,setEditingRowKey:N,editTitle:C,setEditTitle:B,toggleParent:W,openSidebarMenuKey:F,setOpenSidebarMenuKey:$,allowReselect:K,onSessionSelected:I,resetSessionSearch:z,deleteSessionConfirm:k,setDeleteSessionConfirm:M,startFolderRename:V,startSessionWorktreeMenuLoad:O,mobileVariant:R,alwaysShowActions:_,depth:me+1,folderOwnerKey:d,selectionScopeKey:a,...$e,renderExtras:ye?.(ne)},ne.session.id)):null,e[29]=K,e[30]=_,e[31]=$e,e[32]=ye,e[33]=k,e[34]=me,e[35]=C,e[36]=v,e[37]=S,e[38]=w,e[39]=d,e[40]=b,e[41]=R,e[42]=n.children,e[43]=g,e[44]=h,e[45]=I,e[46]=F,e[47]=x,e[48]=ie,e[49]=z,e[50]=a,e[51]=M,e[52]=B,e[53]=j,e[54]=N,e[55]=$,e[56]=V,e[57]=O,e[58]=W,e[59]=le):le=e[59];let Ie;e[60]!==_||e[61]!==ce||e[62]!==Ne||e[63]!==me||e[64]!==C||e[65]!==v||e[66]!==S||e[67]!==xe||e[68]!==w||e[69]!==d||e[70]!==o||e[71]!==b||e[72]!==R||e[73]!==n||e[74]!==g||e[75]!==h||e[76]!==E||e[77]!==F||e[78]!==x||e[79]!==i||e[80]!==oe||e[81]!==u||e[82]!==a||e[83]!==we.handleCancelEdit||e[84]!==we.handleCopySessionId||e[85]!==we.handleDeleteSession||e[86]!==we.handleRestoreSession||e[87]!==we.handleSaveEdit||e[88]!==we.handleSessionDoubleClick||e[89]!==we.handleSessionSelect||e[90]!==B||e[91]!==j||e[92]!==N||e[93]!==$||e[94]!==O||e[95]!==ze||e[96]!==Ue||e[97]!==q||e[98]!==ue||e[99]!==A||e[100]!==Q||e[101]!==le||e[102]!==W?(Ie=s.jsx(rC,{expandedParents:w,hasSessionSearchQuery:b,normalizedSessionSearchQuery:g,notifyOnSubtasks:h,editingId:v,editingRowKey:S,setEditingId:j,setEditingRowKey:N,editTitle:C,setEditTitle:B,handleSaveEdit:we.handleSaveEdit,handleCancelEdit:we.handleCancelEdit,toggleParent:W,handleSessionSelect:we.handleSessionSelect,handleSessionDoubleClick:we.handleSessionDoubleClick,handleCopySessionId:we.handleCopySessionId,openSidebarMenuKey:F,setOpenSidebarMenuKey:$,createFolderAndStartRename:Ne,handleDeleteSession:we.handleDeleteSession,handleRestoreSession:we.handleRestoreSession,startSessionWorktreeMenuLoad:O,onEditProject:E,mobileVariant:R,alwaysShowActions:_,pinnedSessionIds:x,node:n,depth:me,groupDirectory:o,projectId:i,folderOwnerKey:d,selectionScopeKey:a,archivedBucket:ce,secondaryMeta:u,renderContext:oe,rowKey:xe,dragKey:ze,subtreeContainsEditing:Ue,menuOpenSessionId:q,nodeStructureKey:ue,blockingBadgeSessionScopes:A,relativeTimeTick:Q,children:le}),e[60]=_,e[61]=ce,e[62]=Ne,e[63]=me,e[64]=C,e[65]=v,e[66]=S,e[67]=xe,e[68]=w,e[69]=d,e[70]=o,e[71]=b,e[72]=R,e[73]=n,e[74]=g,e[75]=h,e[76]=E,e[77]=F,e[78]=x,e[79]=i,e[80]=oe,e[81]=u,e[82]=a,e[83]=we.handleCancelEdit,e[84]=we.handleCopySessionId,e[85]=we.handleDeleteSession,e[86]=we.handleRestoreSession,e[87]=we.handleSaveEdit,e[88]=we.handleSessionDoubleClick,e[89]=we.handleSessionSelect,e[90]=B,e[91]=j,e[92]=N,e[93]=$,e[94]=O,e[95]=ze,e[96]=Ue,e[97]=q,e[98]=ue,e[99]=A,e[100]=Q,e[101]=le,e[102]=W,e[103]=Ie):Ie=e[103];let re;e[104]!==k||e[105]!==n.session.id||e[106]!==we.confirmDeleteSession||e[107]!==M||e[108]!==ge||e[109]!==J?(re=k?.session.id===n.session.id?s.jsx(aC,{value:k,setValue:M,showDeletionDialog:J,setShowDeletionDialog:ge,onConfirm:we.confirmDeleteSession}):null,e[104]=k,e[105]=n.session.id,e[106]=we.confirmDeleteSession,e[107]=M,e[108]=ge,e[109]=J,e[110]=re):re=e[110];let H;return e[111]!==Ie||e[112]!==re?(H=s.jsxs(s.Fragment,{children:[Ie,re]}),e[111]=Ie,e[112]=re,e[113]=H):H=e[113],H}function uC(t){return t.setShowDeletionDialog}function fC(t){return t.showDeletionDialog}function pC(t){return t.toggleFolderCollapse}function mC(t){return t.createFolder}const hC=(t,e)=>t.session.id===e.session.id&&t.session.title===e.session.title&&t.session.directory===e.session.directory&&t.session.parentID===e.session.parentID&&t.session.time?.created===e.session.time?.created&&t.session.time?.updated===e.session.time?.updated&&t.session.time?.archived===e.session.time?.archived&&jf(t.session,e.session)&&at(t.worktree?.path??null)===at(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,gC=(t,e)=>{if(t.node!==e.node&&!hC(t.node,e.node)||(t.renderExtras?.nodeStructureKey??"")!==(e.renderExtras?.nodeStructureKey??"")||(t.renderExtras?.menuOpenSessionId??null)!==(e.renderExtras?.menuOpenSessionId??null)||t.renderExtras?.relativeTimeTick!==e.renderExtras?.relativeTimeTick)return!1;const n=e.node.session.id;if((t.renderExtras?.subtreeContainsEditing?.has(n)??!1)!==(e.renderExtras?.subtreeContainsEditing?.has(n)??!1)||(t.secondaryMeta?.projectLabel??null)!==(e.secondaryMeta?.projectLabel??null)||(t.secondaryMeta?.branchLabel??null)!==(e.secondaryMeta?.branchLabel??null))return!1;const r=["depth","groupDirectory","projectId","folderOwnerKey","selectionScopeKey","archivedBucket","renderContext","rowKey","dragKey","renderChildren","hasSessionSearchQuery","normalizedSessionSearchQuery","notifyOnSubtasks","editingId","editingRowKey","editTitle","openSidebarMenuKey","mobileVariant","alwaysShowActions","allowReselect","pinnedSessionIds","expandedParents","deleteSessionConfirm","setEditingId","setEditingRowKey","setEditTitle","toggleParent","setOpenSidebarMenuKey","startSessionWorktreeMenuLoad","onEditProject","onSessionSelected","resetSessionSearch","setDeleteSessionConfirm","startFolderRename"];for(const o of r)if(t[o]!==e[o])return!1;return!0},di=l.memo(dC,gC),Wa=6,Dd=14,bC=Wa+14+6,xC=4;function Ed(t){const e=He.c(7),{providerIDs:n,ringClass:r}=t;let o;if(e[0]!==n||e[1]!==r){let d;e[3]!==r?(d=a=>s.jsx("span",{className:Se("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:s.jsx(df,{providerId:a,className:"h-3 w-3"})},a),e[3]=r,e[4]=d):d=e[4],o=n.slice(0,xC).map(d),e[0]=n,e[1]=r,e[2]=o}else o=e[2];let i;return e[5]!==o?(i=s.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:o}),e[5]=o,e[6]=i):i=e[6],i}function yC(t){const e=He.c(96),{run:n,depth:r,laneNodes:o,blockingSessionIds:i,renderContext:d,projectId:a,projectLabel:c,expansionKey:u,expanded:f,forceExpanded:p,notifyOnSubtasks:m,toggleParent:y}=t,{t:x}=vt();let w;e[0]!==n.key?(w=Ne=>Ne.runOverviewKey===n.key,e[0]=n.key,e[1]=w):w=e[1];const b=Ce(w),g=d==="timeline";let h;e[2]!==g||e[3]!==a?(h=Ne=>g&&a?Ne.projects.find(be=>be.id===a)??null:null,e[2]=g,e[3]=a,e[4]=h):h=e[4];const v=as(h),S=n.lanes.length;let j;e[5]!==S||e[6]!==x?(j=S===1?x("sessions.sidebar.run.laneCountSingle",{count:S}):x("sessions.sidebar.run.laneCountPlural",{count:S}),e[5]=S,e[6]=x,e[7]=j):j=e[7];const N=j;let C;e[8]!==o?(C=[...o],e[8]=o,e[9]=C):C=e[9];const B=C;let W;e[10]!==B||e[11]!==i||e[12]!==m?(W=s.jsx(xu,{nodes:B,blockingSessionIds:i,includeUnreadSubtasks:m}),e[10]=B,e[11]=i,e[12]=m,e[13]=W):W=e[13];const F=W,$=b?"text-interactive-selection-foreground":"text-foreground/80";let K;e[14]!==n.key?(K=()=>Ce.getState().setRunOverviewKey(n.key),e[14]=n.key,e[15]=K):K=e[15];const I=K;if(g){const Ne=n.key,be=b?"page":void 0;let we;e[16]!==n.title||e[17]!==x?(we=x("sessions.sidebar.run.openOverviewAria",{title:n.title}),e[16]=n.title,e[17]=x,e[18]=we):we=e[18];let ye;e[19]===Symbol.for("react.memo_cache_sentinel")?(ye={paddingLeft:Wa+4},e[19]=ye):ye=e[19];const Pe=b?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let Oe;e[20]!==Pe?(Oe=Se("group relative my-0.5 flex w-full cursor-pointer items-center rounded-md py-1.5 pr-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Pe),e[20]=Pe,e[21]=Oe):Oe=e[21];const $e=n.title;let ze;e[22]===Symbol.for("react.memo_cache_sentinel")?(ze=s.jsx(ha,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[22]=ze):ze=e[22];let Ue;e[23]!==N?(Ue=s.jsxs(s.Fragment,{children:[ze,s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:N})]}),e[23]=N,e[24]=Ue):Ue=e[24];let q;e[25]!==n.lastActivity?(q=Sf(n.lastActivity),e[25]=n.lastActivity,e[26]=q):q=e[26];let ue;e[27]!==n.providerIDs?(ue=s.jsx(Ed,{providerIDs:n.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[27]=n.providerIDs,e[28]=ue):ue=e[28];let A;e[29]!==F||e[30]!==c||e[31]!==n.title||e[32]!==Ue||e[33]!==q||e[34]!==ue||e[35]!==v||e[36]!==$?(A=s.jsx(Fa,{project:v,projectLabel:c,title:$e,titleClassName:$,branchLabel:null,thirdLineLead:Ue,statusDot:F,pinnedMarker:null,timeSlot:q,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:ue,hideMetaOnHoverClass:""}),e[29]=F,e[30]=c,e[31]=n.title,e[32]=Ue,e[33]=q,e[34]=ue,e[35]=v,e[36]=$,e[37]=A):A=e[37];let Q;return e[38]!==I||e[39]!==n.key||e[40]!==Oe||e[41]!==A||e[42]!==be||e[43]!==we?(Q=s.jsx("button",{type:"button","data-run-row":Ne,"aria-current":be,"aria-label":we,onClick:I,style:ye,className:Oe,children:A}),e[38]=I,e[39]=n.key,e[40]=Oe,e[41]=A,e[42]=be,e[43]=we,e[44]=Q):Q=e[44],Q}let z;e[45]!==u||e[46]!==p||e[47]!==y?(z=Ne=>{Ne.stopPropagation(),p||y(u)},e[45]=u,e[46]=p,e[47]=y,e[48]=z):z=e[48];const k=z,M=n.key,V=b?"page":void 0,O=bC+r*Dd;let E;e[49]!==O?(E={paddingLeft:O},e[49]=O,e[50]=E):E=e[50];const R=b?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let _;e[51]!==R?(_=Se("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-2.5",R),e[51]=R,e[52]=_):_=e[52];let U;e[53]!==k?(U=Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),k(Ne))},e[53]=k,e[54]=U):U=e[54];const me=Wa+r*Dd;let ce;e[55]!==me?(ce={left:me},e[55]=me,e[56]=ce):ce=e[56];let oe;e[57]!==f||e[58]!==x?(oe=x(f?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[57]=f,e[58]=x,e[59]=oe):oe=e[59];const ie=f?"arrow-down-s":"arrow-right-s";let xe;e[60]!==ie?(xe=s.jsx(T,{name:ie,className:"h-3 w-3"}),e[60]=ie,e[61]=xe):xe=e[61];let G;e[62]!==f||e[63]!==U||e[64]!==ce||e[65]!==oe||e[66]!==xe||e[67]!==k?(G=s.jsx("button",{type:"button",onClick:k,onKeyDown:U,style:ce,className:"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-ring","aria-expanded":f,"aria-label":oe,children:xe}),e[62]=f,e[63]=U,e[64]=ce,e[65]=oe,e[66]=xe,e[67]=k,e[68]=G):G=e[68];let pe;e[69]!==I?(pe=Ne=>{Ne.stopPropagation(),I()},e[69]=I,e[70]=pe):pe=e[70];let J;e[71]!==n.title||e[72]!==x?(J=x("sessions.sidebar.run.openOverviewAria",{title:n.title}),e[71]=n.title,e[72]=x,e[73]=J):J=e[73];let ge;e[74]===Symbol.for("react.memo_cache_sentinel")?(ge=s.jsx(ha,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[74]=ge):ge=e[74];let de;e[75]!==$?(de=Se("block min-w-0 flex-1 truncate typography-ui-label font-normal",$),e[75]=$,e[76]=de):de=e[76];let Ae;e[77]!==n.title||e[78]!==de?(Ae=s.jsx("span",{dir:"auto",className:de,children:n.title}),e[77]=n.title,e[78]=de,e[79]=Ae):Ae=e[79];let he;e[80]!==n.providerIDs?(he=s.jsx(Ed,{providerIDs:n.providerIDs,ringClass:"ring-sidebar"}),e[80]=n.providerIDs,e[81]=he):he=e[81];let Re;e[82]!==F||e[83]!==pe||e[84]!==J||e[85]!==Ae||e[86]!==he?(Re=s.jsxs("button",{type:"button",onClick:pe,className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":J,children:[ge,Ae,he,F]}),e[82]=F,e[83]=pe,e[84]=J,e[85]=Ae,e[86]=he,e[87]=Re):Re=e[87];let se;return e[88]!==I||e[89]!==n.key||e[90]!==E||e[91]!==_||e[92]!==G||e[93]!==Re||e[94]!==V?(se=s.jsxs("div",{"data-run-row":M,"aria-current":V,onClick:I,style:E,className:_,children:[G,Re]}),e[88]=I,e[89]=n.key,e[90]=E,e[91]=_,e[92]=G,e[93]=Re,e[94]=V,e[95]=se):se=e[95],se}const vC=l.memo(yC),wC=24,SC=t=>Array.from({length:Math.min(t,wC)},(e,n)=>n),jC=(t,e,n)=>{const r=new Set(t);for(const o of e)o>=0&&o<n&&r.add(o);return[...r].sort((o,i)=>o-i)},kC=(t,e)=>t.find(n=>n.end>e)?.index??0,Rd=(t,e)=>t.key.startsWith("activity:")&&e!==void 0&&!e.key.startsWith("activity:")&&(e.kind==="project-header"||e.kind==="group-header")?"pb-6":e?.kind==="activity-header"||e?.kind==="project-header"||e?.kind==="group-header"&&t.kind!=="project-header"?"pb-2":void 0;function CC({model:t,scrollElement:e,pinnedRowIndexes:n,renderRow:r,onFirstVisibleIndexChange:o}){const i=t.rows,d=l.useCallback(()=>e,[e]),a=l.useCallback(b=>i[b]?.estimateSize??32,[i]),c=l.useCallback(b=>i[b]?.key??b,[i]),u=l.useCallback(b=>jC(Ly(b),n,i.length),[n,i.length]),f=Fy({count:i.length,enabled:e!==null,getScrollElement:d,estimateSize:a,getItemKey:c,overscan:8,rangeExtractor:u}),p=f.getVirtualItems(),m=e?f.getTotalSize():0,y=e?Math.max(m-e.clientHeight,0):0,x=e?Math.min(e.scrollTop,y):0,w=kC(p,x);if(l.useLayoutEffect(()=>{o(w)},[w,o]),!e){const b=SC(i.length),g=b.reduce((v,S)=>v+(i[S]?.estimateSize??0),0),h=i.reduce((v,S)=>v+S.estimateSize,0);return s.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[b.map(v=>{const S=i[v];return S?s.jsx("div",{className:Rd(S,i[v+1]),children:r(S,v)},S.key):null}),h>g?s.jsx("div",{"aria-hidden":"true",style:{height:h-g}}):null]})}return s.jsx("div",{"data-sidebar-virtual-ready":"true",style:{height:m,position:"relative"},children:p.map(b=>{const g=i[b.index];return g?s.jsx("div",{className:`[&_[data-session-row]]:my-px ${Rd(g,i[b.index+1])??""}`,"data-index":b.index,"data-sidebar-virtual-start":b.start,ref:f.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${b.start}px)`},children:r(g,b.index)},g.key):null})})}const NC={work:"eye",chats:"chat-4","active-now":"history",timeline:"folder"},Md={work:"sessions.sidebar.work.title",chats:"sessions.sidebar.activity.chatsTitle","active-now":"sessions.sidebar.activity.recentTitle",timeline:"sessions.sidebar.activity.timelineTitle"},AC=t=>{const e=He.c(48),{activityKey:n,collapsed:r,forceExpanded:o,alwaysShowActions:i,onToggle:d,onNewChat:a,timelineView:c}=t,u=c===void 0?!1:c,{t:f}=vt(),p=n==="chats";if(u){const K=o?void 0:d;let I;e[0]===Symbol.for("react.memo_cache_sentinel")?(I=Se("group flex w-full items-center gap-1 py-2 pl-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","pr-3.5"),e[0]=I):I=e[0];const z=!r,k=Md[n];let M;e[1]!==f||e[2]!==k?(M=f(k),e[1]=f,e[2]=k,e[3]=M):M=e[3];let V;e[4]!==M?(V=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:M}),e[4]=M,e[5]=V):V=e[5];let O;e[6]!==r||e[7]!==o?(O=o?null:s.jsx(T,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5 text-muted-foreground"}),e[6]=r,e[7]=o,e[8]=O):O=e[8];let E;return e[9]!==o||e[10]!==K||e[11]!==z||e[12]!==V||e[13]!==O?(E=s.jsx("div",{className:"relative group/chats -mr-2",children:s.jsxs("button",{type:"button",onClick:K,disabled:o,className:I,"aria-expanded":z,children:[V,O]})}),e[9]=o,e[10]=K,e[11]=z,e[12]=V,e[13]=O,e[14]=E):E=e[14],E}const m=o?void 0:d,y=p?"pr-10":"pr-3.5";let x;e[15]!==y?(x=Se("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),e[15]=y,e[16]=x):x=e[16];const w=!r,b=NC[n],g=!o&&"group-hover:hidden";let h;e[17]!==g?(h=Se("h-3.5 w-3.5 text-muted-foreground/80",g),e[17]=g,e[18]=h):h=e[18];let v;e[19]!==b||e[20]!==h?(v=s.jsx(T,{name:b,className:h}),e[19]=b,e[20]=h,e[21]=v):v=e[21];let S;e[22]!==r||e[23]!==o?(S=o?null:s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:s.jsx(T,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[22]=r,e[23]=o,e[24]=S):S=e[24];let j;e[25]!==S||e[26]!==v?(j=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[v,S]}),e[25]=S,e[26]=v,e[27]=j):j=e[27];const N=Md[n];let C;e[28]!==f||e[29]!==N?(C=f(N),e[28]=f,e[29]=N,e[30]=C):C=e[30];let B;e[31]!==C?(B=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:C}),e[31]=C,e[32]=B):B=e[32];let W;e[33]!==o||e[34]!==j||e[35]!==B||e[36]!==m||e[37]!==x||e[38]!==w?(W=s.jsxs("button",{type:"button",onClick:m,disabled:o,className:x,"aria-expanded":w,children:[j,B]}),e[33]=o,e[34]=j,e[35]=B,e[36]=m,e[37]=x,e[38]=w,e[39]=W):W=e[39];let F;e[40]!==i||e[41]!==p||e[42]!==a||e[43]!==f?(F=p?s.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),a()},className:Se("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",i?"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":f("sessions.sidebar.header.actions.newSession"),children:s.jsx(T,{name:"add",className:"h-4 w-4"})}):null,e[40]=i,e[41]=p,e[42]=a,e[43]=f,e[44]=F):F=e[44];let $;return e[45]!==W||e[46]!==F?($=s.jsxs("div",{className:"relative group/chats -ml-2.5 -mr-2",children:[W,F]}),e[45]=W,e[46]=F,e[47]=$):$=e[47],$},Rp=l.createContext(null);function Td(t){let e=0,n=t;for(;n;){e+=n.offsetTop;const i=n.offsetParent;n=i instanceof HTMLElement?i:null}const r=t.closest("[data-sidebar-virtual-start]"),o=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(o)?o:0)}function PC(t){const e=He.c(14),{enabled:n,suspended:r,layoutKey:o,scrollRef:i,children:d}=t,a=r===void 0?!1:r,c=o===void 0?"":o;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[0]=u):u=e[0];const f=l.useRef(u),p=l.useRef(null);let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=h=>(f.current.add(h),p.current?.(),()=>{f.current.delete(h),p.current?.()}),e[1]=m):m=e[1];const y=m;let x;e[2]!==n||e[3]!==i||e[4]!==a?(x=()=>{const h=i.current;if(!n||a||!h)return;const v=document.createElement("div");v.dataset.sidebarCrossfadeLayer="true",v.className="pointer-events-none sticky top-0 z-30 h-0",v.style.marginBlock="0px",h.prepend(v);let S=null,j=null,N=null,C=0;const B=new Set;let W=[];const F=window.matchMedia("(prefers-reduced-motion: reduce)"),$=DC,K=()=>{N?.cancel(),N=null,j?.remove(),j=null},I=()=>{let O=null,E=-1/0;for(const{entry:R,top:_}of W)_<=h.scrollTop&&_>=E&&(E=_,O=R);if(S!==O){if(K(),S&&O&&!F.matches){const R=S.host.cloneNode(!0);R instanceof HTMLElement&&(R.inert=!0,R.setAttribute("aria-hidden","true"),R.querySelectorAll("[id]").forEach(IC),R.className="pointer-events-none absolute inset-x-0 top-0 z-30",j=R)}S&&($(S,S.slot),S.slot.style.removeProperty("height")),S=O,v.hidden=!O,O&&(O.slot.style.height=`${O.host.getBoundingClientRect().height}px`,$(O,v),j&&(v.append(j),N=j.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),N.onfinish=K))}},z=()=>{S&&(S.slot.style.height=`${S.host.getBoundingClientRect().height}px`);const O=Td(h)+h.clientTop;W=Array.from(f.current,E=>({entry:E,top:Td(E.slot)-O})),I()},k=new ResizeObserver(z),M=new MutationObserver(()=>{cancelAnimationFrame(C),C=requestAnimationFrame(z)});k.observe(h);const V=()=>{M.disconnect();for(const O of B)f.current.has(O)||(k.unobserve(O.host),O.slot.parentElement&&k.unobserve(O.slot.parentElement),B.delete(O));for(const O of f.current){const E=O.slot.closest("[data-sidebar-virtual-start]");E&&M.observe(E,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),B.has(O)||(k.observe(O.host),O.slot.parentElement&&k.observe(O.slot.parentElement),B.add(O))}cancelAnimationFrame(C),C=requestAnimationFrame(z)};return p.current=V,h.addEventListener("scroll",I,{passive:!0}),V(),z(),()=>{p.current=null,cancelAnimationFrame(C),h.removeEventListener("scroll",I),k.disconnect(),M.disconnect(),K(),v.hidden=!0,S&&($(S,S.slot),S.slot.style.removeProperty("height")),v.remove()}},e[2]=n,e[3]=i,e[4]=a,e[5]=x):x=e[5];let w;e[6]!==n||e[7]!==c||e[8]!==i||e[9]!==a?(w=[n,a,c,i],e[6]=n,e[7]=c,e[8]=i,e[9]=a,e[10]=w):w=e[10],l.useLayoutEffect(x,w);const b=n?y:null;let g;return e[11]!==d||e[12]!==b?(g=s.jsx(Rp.Provider,{value:b,children:d}),e[11]=d,e[12]=b,e[13]=g):g=e[13],g}function IC(t){return t.removeAttribute("id")}function DC(t,e){const n=document.activeElement,r=n instanceof HTMLElement&&t.host.contains(n);e.moveBefore&&e.isConnected&&t.host.isConnected?e.moveBefore(t.host,null):e.append(t.host),r&&n.focus({preventScroll:!0})}function EC(t){const e=He.c(15);let n,r;e[0]!==t?({register:r,...n}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const o=l.useRef(null),[i]=l.useState(RC);let d,a;e[3]!==i||e[4]!==r?(d=()=>{const m=o.current;if(!m)return;m.append(i);const y=r({slot:m,host:i});return()=>{y(),i.remove()}},a=[i,r],e[3]=i,e[4]=r,e[5]=d,e[6]=a):(d=e[5],a=e[6]),l.useLayoutEffect(d,a);let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx("div",{ref:o}),e[7]=c):c=e[7];let u;e[8]!==n?(u=s.jsx("div",{...n}),e[8]=n,e[9]=u):u=e[9];let f;e[10]!==i||e[11]!==u?(f=um.createPortal(u,i),e[10]=i,e[11]=u,e[12]=f):f=e[12];let p;return e[13]!==f?(p=s.jsxs(s.Fragment,{children:[c,f]}),e[13]=f,e[14]=p):p=e[14],p}function RC(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function Mp(t){const e=He.c(3),n=l.useContext(Rp);let r;return e[0]!==t||e[1]!==n?(r=n?s.jsx(EC,{...t,register:n}):s.jsx("div",{...t}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r}const MC=t=>{const e=He.c(3),[n,r]=l.useState(!1);let o,i;return e[0]!==t?(o=()=>{if(!t){r(!1);return}let d=!0;const a=()=>{to.getDirectoryAvailability(t).then(c=>{d&&c!=="unknown"&&r(c==="missing")})};return a(),window.addEventListener("focus",a),()=>{d=!1,window.removeEventListener("focus",a)}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),l.useEffect(o,i),n},Ji=t=>{const e=He.c(25),{id:n,projectLabel:r,projectIcon:o,projectColor:i,projectIconImage:d,projectIconBackground:a,isCollapsed:c,alwaysShowActions:u,labelClassName:f}=t,p=u===void 0?!1:u,{currentTheme:m}=uo(),y=o?uf[o]:null,x=i?ff[i]??null:null,w=c!==void 0,b=w?p?"hidden":"transition-opacity group-hover/project:opacity-0 group-focus-within/project:opacity-0":void 0;let g;e[0]!==p||e[1]!==w||e[2]!==c?(g=w?s.jsx("span",{className:Se("h-3.5 w-3.5 items-center justify-center text-muted-foreground",p?"inline-flex":"absolute inset-0 inline-flex opacity-0 transition-opacity group-hover/project:opacity-100 group-focus-within/project:opacity-100"),children:s.jsx(T,{name:c?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=p,e[1]=w,e[2]=c,e[3]=g):g=e[3];let h;e[4]!==p||e[5]!==m||e[6]!==w||e[7]!==x||e[8]!==b||e[9]!==n||e[10]!==a||e[11]!==d||e[12]!==y?(h=d?s.jsx("span",{className:Se("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",w&&p?"hidden":"inline-flex",b),style:a?{backgroundColor:a}:void 0,children:s.jsx(pf,{project:{id:n,iconImage:d},options:{themeVariant:m.metadata.variant,iconColor:m.colors.surface.foreground},className:"h-full w-full object-contain",fallback:y?s.jsx(T,{name:y,className:"h-3.5 w-3.5",style:x?{color:x}:void 0}):s.jsx(T,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:x?{color:x}:void 0})})}):y?s.jsx(T,{name:y,className:Se("h-3.5 w-3.5",b),style:x?{color:x}:void 0}):s.jsx(T,{name:"folder",className:Se("h-3.5 w-3.5 text-muted-foreground/80",b),style:x?{color:x}:void 0}),e[4]=p,e[5]=m,e[6]=w,e[7]=x,e[8]=b,e[9]=n,e[10]=a,e[11]=d,e[12]=y,e[13]=h):h=e[13];let v;e[14]!==g||e[15]!==h?(v=s.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[g,h]}),e[14]=g,e[15]=h,e[16]=v):v=e[16];let S;e[17]!==f?(S=Se("truncate typography-ui-label font-semibold lowercase text-foreground",f),e[17]=f,e[18]=S):S=e[18];let j;e[19]!==r||e[20]!==S?(j=s.jsx("span",{className:S,children:r}),e[19]=r,e[20]=S,e[21]=j):j=e[21];let N;return e[22]!==v||e[23]!==j?(N=s.jsxs(s.Fragment,{children:[v,j]}),e[22]=v,e[23]=j,e[24]=N):N=e[24],N},TC=t=>{const e=He.c(66),{id:n,disabled:r,projectLabel:o,projectDescription:i,projectDirectory:d,projectIcon:a,projectColor:c,projectIconImage:u,projectIconBackground:f,isCollapsed:p,isRepo:m,hideDirectoryControls:y,alwaysShowActions:x,onToggle:w,onNewSession:b,onNewWorktreeSession:g,onManageWorktrees:h,onManageSpaces:v,onRenameStart:S,onArchiveAll:j,onClose:N,children:C,showCreateButtons:B,hideHeader:W,statusIndicator:F,openSidebarMenuKey:$,setOpenSidebarMenuKey:K,projectPickerOptions:I,onProjectSelect:z}=t,k=r===void 0?!1:r,M=B===void 0?!0:B,V=W===void 0?!1:W,O=F===void 0?null:F,{t:E}=vt(),R=MC(d);let _;e[0]!==k||e[1]!==n?(_={id:n,disabled:k},e[0]=k,e[1]=n,e[2]=_):_=e[2];const{attributes:U,listeners:me,setNodeRef:ce,transform:oe,transition:ie,isDragging:xe}=vi(_),G=l.useRef(!1),pe=`project:${n}`,J=$===pe,[ge,de]=l.useState(!1),Ae=!!(I&&z);let he;e[3]!==pe||e[4]!==K?(he=fe=>{fe&&de(!1),K(fe?pe:null)},e[3]=pe,e[4]=K,e[5]=he):he=e[5];const Re=he;let se;e[6]!==y||e[7]!==m||e[8]!==j||e[9]!==N||e[10]!==v||e[11]!==h||e[12]!==b||e[13]!==S||e[14]!==M||e[15]!==E?(se=fe=>s.jsxs(s.Fragment,{children:[M&&!m&&!y&&b&&s.jsxs(fe,{onClick:b,children:[s.jsx(T,{name:"add",className:"mr-1.5 h-4 w-4"}),E("sessions.sidebar.project.actions.newSession")]}),m&&!y&&h&&s.jsxs(fe,{onClick:h,children:[s.jsx(T,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),E("sessions.sidebar.project.actions.manageWorktrees")]}),m&&!y&&v&&s.jsxs(fe,{onClick:v,children:[s.jsx(T,{name:"box-3",className:"mr-1.5 h-4 w-4"}),E("spaces.page.menuItem")]}),s.jsxs(fe,{onClick:S,children:[s.jsx(T,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),E("sessions.sidebar.project.actions.edit")]}),j&&s.jsxs(fe,{onClick:j,children:[s.jsx(T,{name:"archive",className:"mr-1.5 h-4 w-4"}),E("sessions.sidebar.project.actions.archiveAll")]}),s.jsxs(fe,{onClick:N,className:"text-destructive focus:text-destructive",children:[s.jsx(T,{name:"close",className:"mr-1.5 h-4 w-4"}),E("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=y,e[7]=m,e[8]=j,e[9]=N,e[10]=v,e[11]=h,e[12]=b,e[13]=S,e[14]=M,e[15]=E,e[16]=se):se=e[16];const Ne=se,be=FC,we=LC,ye=$C;let Pe;e[17]===Symbol.for("react.memo_cache_sentinel")?(Pe=fe=>{(fe.button===2||fe.button===0&&fe.ctrlKey)&&(G.current=!0)},e[17]=Pe):Pe=e[17];const Oe=Pe;let $e;e[18]!==w?($e=fe=>{if(fe.currentTarget.blur(),G.current){G.current=!1;return}w()},e[18]=w,e[19]=$e):$e=e[19];const ze=$e,q=(M&&m&&!y&&!!g?1:0)+(y?0:1),ue=q===2?"[--oc-actions-reserve:66px]":q===1&&M?"[--oc-actions-reserve:38px]":M||q===1?"[--oc-actions-reserve:12px]":void 0,A=x?void 0:J?"oc-actions-mask":"group-hover/project:oc-actions-mask group-focus-within/project:oc-actions-mask",Q=x?void 0:J?"opacity-0":"transition-opacity group-hover/project:opacity-0 group-focus-within/project:opacity-0";let le;e[20]!==oe?(le=wi.Transform.toString(oe),e[20]=oe,e[21]=le):le=e[21];let Ie;e[22]!==le||e[23]!==ie?(Ie={transform:le,transition:ie},e[22]=le,e[23]=ie,e[24]=Ie):Ie=e[24];const re=xe&&"opacity-30";let H;e[25]!==re?(H=Se("relative",re),e[25]=re,e[26]=H):H=e[26];let ne;e[27]!==x||e[28]!==U||e[29]!==R||e[30]!==Re||e[31]!==ze||e[32]!==ue||e[33]!==Q||e[34]!==A||e[35]!==y||e[36]!==V||e[37]!==n||e[38]!==p||e[39]!==ge||e[40]!==J||e[41]!==Ae||e[42]!==m||e[43]!==me||e[44]!==b||e[45]!==g||e[46]!==z||e[47]!==c||e[48]!==i||e[49]!==d||e[50]!==a||e[51]!==f||e[52]!==u||e[53]!==o||e[54]!==I||e[55]!==Ne||e[56]!==M||e[57]!==O||e[58]!==E?(ne=V?null:s.jsx(s.Fragment,{children:s.jsxs(Qu,{open:ge,onOpenChange:de,children:[s.jsx(Yu,{render:s.jsx(Mp,{className:Se("-ml-2.5 -mr-2 text-left group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:fe=>{y||(fe.preventDefault(),de(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...U,children:[Ae?s.jsxs(Qs,{children:[s.jsx(qs,{asChild:!0,children:s.jsxs("button",{type:"button",className:Se("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-ring",m&&!y?x||J?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":x||J?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":E("sessions.sidebar.project.selectAria",{project:o}),children:[s.jsx(Ji,{id:n,projectLabel:o,projectIcon:a,projectColor:c,projectIconImage:u,projectIconBackground:f}),s.jsx(T,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),d?s.jsx(ao,{directory:d,className:"ml-auto"}):null]})}),s.jsx(Ys,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:I?.map(fe=>s.jsxs(ts,{onClick:()=>z?.(fe.id),className:"flex items-center justify-between gap-3",title:fe.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(Ji,{...fe})}),fe.id===n?s.jsx(T,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},fe.id))})]}):s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:Oe,onClick:ze,...me,className:Se("@container flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing",x?m&&!y?"pr-20":"pr-14":ue),children:[s.jsx(Ji,{id:n,projectLabel:o,projectIcon:a,projectColor:c,projectIconImage:u,projectIconBackground:f,isCollapsed:p,alwaysShowActions:x,labelClassName:Se("[--oc-actions-inset:20px]",A)}),R?s.jsx("span",{className:Se("inline-flex flex-shrink-0 items-center text-status-warning",Q),title:E("sessions.sidebar.project.folderMissing"),"aria-label":E("sessions.sidebar.project.folderMissing"),children:s.jsx(T,{name:"alert",className:"h-3 w-3"})}):null,O?s.jsx("span",{className:Se("ml-1 inline-flex flex-shrink-0 items-center",Q),children:O}):null,d?s.jsx(ao,{directory:d,className:Se("ml-auto",Q)}):null]})}),s.jsx(jt,{side:"right",sideOffset:8,children:i})]}),s.jsxs("div",{className:Se("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",M?"right-7":"right-0.5"),children:[M&&m&&!y&&g?s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:fe=>{fe.stopPropagation(),g()},className:Se("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-ring hover:text-foreground transition-opacity",x?"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":E("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(T,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:E("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,y?null:s.jsxs(Qs,{open:J,onOpenChange:Re,children:[s.jsx(qs,{asChild:!0,children:s.jsx("button",{type:"button",className:Se("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-ring hover:text-foreground",J?"opacity-100 pointer-events-auto":x?"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":E("sessions.sidebar.project.actions.projectMenu"),onPointerDown:we,onMouseDown:ye,onClick:be,children:s.jsx(T,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Ys,{align:"end",className:"min-w-[180px]",children:Ne(ts)})]})]}),M&&b?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:fe=>{fe.stopPropagation(),b()},className:Se("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-ring transition-opacity",x?"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":E(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(T,{name:"add",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:E(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(qu,{className:"min-w-[180px]",children:Ne(lr)})]})}),e[27]=x,e[28]=U,e[29]=R,e[30]=Re,e[31]=ze,e[32]=ue,e[33]=Q,e[34]=A,e[35]=y,e[36]=V,e[37]=n,e[38]=p,e[39]=ge,e[40]=J,e[41]=Ae,e[42]=m,e[43]=me,e[44]=b,e[45]=g,e[46]=z,e[47]=c,e[48]=i,e[49]=d,e[50]=a,e[51]=f,e[52]=u,e[53]=o,e[54]=I,e[55]=Ne,e[56]=M,e[57]=O,e[58]=E,e[59]=ne):ne=e[59];let X;return e[60]!==C||e[61]!==ce||e[62]!==Ie||e[63]!==H||e[64]!==ne?(X=s.jsxs("div",{ref:ce,style:Ie,className:H,children:[ne,C]}),e[60]=C,e[61]=ce,e[62]=Ie,e[63]=H,e[64]=ne,e[65]=X):X=e[65],X},OC=t=>{const e=He.c(21),{id:n,disabled:r,children:o}=t,i=r===void 0?!1:r;let d;e[0]!==i||e[1]!==n?(d={id:n,disabled:i},e[0]=i,e[1]=n,e[2]=d):d=e[2];const{listeners:a,setNodeRef:c,setActivatorNodeRef:u,transform:f,transition:p,isDragging:m}=vi(d);let y;e[3]!==a||e[4]!==u?(y={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=y):y=e[5];const x=y;let w;e[6]!==f?(w=wi.Transform.toString(f),e[6]=f,e[7]=w):w=e[7];let b;e[8]!==w||e[9]!==p?(b={transform:w,transition:p},e[8]=w,e[9]=p,e[10]=b):b=e[10];const g=m&&"opacity-50";let h;e[11]!==g?(h=Se("space-y-0.5 rounded-md",g),e[11]=g,e[12]=h):h=e[12];let v;e[13]!==o||e[14]!==x?(v=o(x),e[13]=o,e[14]=x,e[15]=v):v=e[15];let S;return e[16]!==c||e[17]!==b||e[18]!==h||e[19]!==v?(S=s.jsx("div",{ref:c,style:b,className:h,children:v}),e[16]=c,e[17]=b,e[18]=h,e[19]=v,e[20]=S):S=e[20],S},BC=l.memo(OC);function FC(t){t.stopPropagation()}function LC(t){t.stopPropagation()}function $C(t){t.stopPropagation()}const Od=[],_C=t=>{const e=He.c(6),{nodes:n,includeUnreadSubtasks:r,children:o}=t;let i;e[0]!==r||e[1]!==n?(i={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=i):i=e[2];const d=gu(i);let a;return e[3]!==o||e[4]!==d?(a=o(d),e[3]=o,e[4]=d,e[5]=a):a=e[5],a},Zi=(t,e)=>e?t.sessions.some(n=>Br(n,e)):!1,KC=(t,e,n)=>t.sessions.some(r=>yp(r,r,e,n,t.directory,t.directory)),WC=(t,e,n)=>{const r=o=>{const i=o.session.id;return e.get(i)!==n.get(i)?!0:o.children.some(r)};return t.sessions.some(r)},zC=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",o=i=>{const d=`project:${r}:${i.session.id}`;return e.has(d)!==n.has(d)?!0:i.children.some(o)};return t.sessions.some(o)},VC=(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&&KC(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&WC(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&zC(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Zi(e.group,t.editingId)||Zi(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Zi(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=ai(e.group.sessions,t.openSidebarMenuKey,"project",n),o=ai(e.group.sessions,e.openSidebarMenuKey,"project",n);if(r||o)return!1}if(t.folderRename!==e.folderRename){const n=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??at(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.renderBody===e.renderBody&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.resetSessionSearch===e.resetSessionSearch&&t.deleteSessionConfirm===e.deleteSessionConfirm&&t.setDeleteSessionConfirm===e.setDeleteSessionConfirm&&t.startFolderRename===e.startFolderRename&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename},UC=l.memo(function(e){const n=He.c(23),{label:r,sessions:o,worktree:i}=e,{t:d}=vt(),a=Ap();let c;n[0]!==o||n[1]!==a||n[2]!==i?(c=g=>{g.stopPropagation(),Rn.requestDelete({sessions:o,mode:"worktree",worktree:i,skipDialogIfSafe:a||g.shiftKey})},n[0]=o,n[1]=a,n[2]=i,n[3]=c):c=n[3];const u=a?"text-destructive":"text-muted-foreground";let f;n[4]!==u?(f=Se("inline-flex h-6 w-6 items-center justify-center rounded-md hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u),n[4]=u,n[5]=f):f=n[5];let p;n[6]!==r||n[7]!==a||n[8]!==d?(p=a?d("sessions.sidebar.group.actions.deleteGroupAndBranchAria",{label:r}):d("sessions.sidebar.group.actions.deleteGroupAria",{label:r}),n[6]=r,n[7]=a,n[8]=d,n[9]=p):p=n[9];let m;n[10]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(T,{name:"delete-bin",className:"h-4 w-4"}),n[10]=m):m=n[10];let y;n[11]!==c||n[12]!==f||n[13]!==p?(y=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:c,className:f,"aria-label":p,children:m})}),n[11]=c,n[12]=f,n[13]=p,n[14]=y):y=n[14];let x;n[15]!==a||n[16]!==d?(x=d(a?"sessions.sidebar.group.actions.deleteWorktreeAndBranch":"sessions.sidebar.group.actions.deleteWorktree"),n[15]=a,n[16]=d,n[17]=x):x=n[17];let w;n[18]!==x?(w=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:x})}),n[18]=x,n[19]=w):w=n[19];let b;return n[20]!==y||n[21]!==w?(b=s.jsxs(Ct,{children:[y,w]}),n[20]=y,n[21]=w,n[22]=b):b=n[22],b}),Bd=[];function HC(t){const{t:e}=vt(),{group:n,groupKey:r,projectId:o,hideGroupLabel:i,renderBody:d=!0,hasSessionSearchQuery:a,normalizedSessionSearchQuery:c,groupSearchDataByGroup:u,visibleSessionCount:f,sessionBatchSize:p,collapsedGroups:m,hideDirectoryControls:y,showMoreGroupSessions:x,resetGroupSessionLimit:w,mobileVariant:b,alwaysShowActions:g,activeProjectId:h,setActiveProjectIdOnly:v,setSessionSwitcherOpen:S,openNewSessionDraft:j,pinnedSessionIds:N,sessionOrderIndex:C,notifyOnSubtasks:B,onToggleCollapsedGroup:W,dragHandleProps:F,compactBodyPadding:$=!1,expandedParents:K,editingId:I,editingRowKey:z,openSidebarMenuKey:k,editTitle:M,folderRename:V,setFolderRenameDraft:O,clearFolderRename:E}=t,R=cs(De=>De.toggleFolderCollapse),_=cs(De=>De.renameFolder),U=cs(De=>De.deleteFolder),me=cs(De=>De.addSessionToFolder),ce=Ce(De=>De.showDeletionDialog),[oe,ie]=l.useState(null),xe=l.useCallback((De,ot)=>{const dt=C.get(De.session.id),st=C.get(ot.session.id);if(dt!==void 0||st!==void 0){if(dt===void 0)return 1;if(st===void 0)return-1;if(dt!==st)return dt-st}return ll(De.session,ot.session,N,ol)},[N,C]),G=a?u.get(n):null,pe=a?!1:m.has(r),J=lx(!n.isMain&&n.worktree?n.worktree.path:null),ge=n.isMain||n.isArchivedBucket||i?null:at(n.directory??null),de=n.isMain||n.isArchivedBucket||i?null:n.branch?.trim()||null,Ae=hf(ge,de),he=Ae?`var(--pr-${Ae.visualState})`:void 0,Re=xf(Ae,e),se=Ae?Za(Ae.provider,Ae.number):"",Ne=Ae?Re?`${se} · ${Re}`:se:void 0,be=mi(),we=l.useMemo(()=>{const De=n.folderScopes?.map(ot=>at(ot.directory))??[at(n.directory??null)];return[...new Set(De.filter(ot=>!!ot))]},[n.directory,n.folderScopes]);l.useSyncExternalStore(l.useCallback(De=>we.length>0?be.subscribeBootstrap(De):()=>{},[we.length,be]),l.useCallback(()=>we.map(De=>`${De}\0${be.getBootstrapState(De)??""}\0${be.getBootstrapFailure(De)??""}\0${be.getInitializationState(De)??""}\0${be.getInitializationFailure(De)??""}`).join(""),[we,be]),l.useCallback(()=>"",[]));const ye=we.some(De=>{const ot=be.getBootstrapState(De);return ot==="queued"||ot==="running"}),Pe=we.find(De=>be.getBootstrapState(De)==="failed"||be.getInitializationState(De)==="failed")??null,Oe=Pe!==null&&be.getBootstrapState(Pe)==="failed",$e=Pe?Oe?be.getBootstrapFailure(Pe):be.getInitializationFailure(Pe):void 0,ze=$e==="os-permission"&&du(),[Ue,q]=l.useState(!1),ue=l.useCallback(()=>{Pe&&be.requestBootstrap({directory:Pe,priority:pe?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[be,Pe,n.isMain,pe]),A=l.useCallback(async()=>{if(!(!Pe||!ze||Ue)){q(!0);try{(await uu(Pe)).success&&ue()}finally{q(!1)}}},[ze,Pe,Ue,ue]),Q=p??(y?10:5),le=Math.max(Q,f??Q),Ie=a?G?.groupMatches===!0:!1,re=a,H=l.useMemo(()=>[...re?G?.filteredNodes??[]:n.sessions].sort(xe),[xe,n.sessions,G?.filteredNodes,re]),ne=n.folderScopeKey??at(n.directory??null),X=Wn(o,n.directory),fe=l.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:ne?[{scopeKey:ne,directory:n.directory??null}]:[],[ne,n.directory,n.folderScopes]),Fe=cs(Or(l.useCallback(De=>fe.map(({scopeKey:ot})=>De.foldersMap[ot]??Od),[fe]))),Me=l.useMemo(()=>fe.flatMap(({scopeKey:De,directory:ot},dt)=>(Fe[dt]??Od).map(pt=>({folder:pt,scopeKey:De,scopeDirectory:ot}))),[Fe,fe]),tt=cs(Or(l.useCallback(De=>new Set(Fe.flatMap(ot=>ot.filter(dt=>De.collapsedFolderIds.has(dt.id)).map(dt=>dt.id))),[Fe]))),nt=l.useMemo(()=>{const De=new Map,ot=dt=>{dt.forEach(st=>{De.set(st.session.id,st),st.children.length>0&&ot(st.children)})};return ot(H),De},[H]),Qe=l.useMemo(()=>Me.map(({folder:De,scopeKey:ot,scopeDirectory:dt})=>{const st=Ba(De.sessionIds,nt).sort(xe);return{folder:De,scopeKey:ot,scopeDirectory:dt,nodes:st}}),[Me,nt,xe]),_e=l.useMemo(()=>{const De=xp(Qe.map(({folder:ot,nodes:dt})=>({id:ot.id,name:ot.name,parentId:ot.parentId,nodeCount:dt.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:a?c:""});return Qe.filter(({folder:ot})=>De.has(ot.id))},[Qe,n.isArchivedBucket,a,c]),wt=I,ct=k,gt=l.useMemo(()=>new Set(_e.flatMap(De=>De.folder.sessionIds)),[_e]),Kt=l.useMemo(()=>H.filter(De=>!gt.has(De.session.id)),[H,gt]),kt=l.useMemo(()=>{const De=new Map(_e.map(ot=>[ot.folder.id,ot]));return bp(_e.map(ot=>ot.folder)).map(ot=>De.get(ot.id)).filter(ot=>!!ot)},[_e]),Ht=l.useMemo(()=>{const De=new Map;return _e.forEach(ot=>{if(!ot.folder.parentId)return;const dt=De.get(ot.folder.parentId)??[];dt.push(ot),De.set(ot.folder.parentId,dt)}),De},[_e]),At=l.useMemo(()=>{const De=new Map(_e.map(st=>[st.folder.id,st])),ot=new Map,dt=(st,pt)=>{const Xt=ot.get(st);if(Xt!==void 0)return Xt;if(pt.has(st))return[];pt.add(st);const us=De.get(st),is=us?[...us.nodes]:[];for(const fs of Ht.get(st)??[])is.push(...dt(fs.folder.id,pt));return ot.set(st,is),is};return _e.forEach(({folder:st})=>dt(st.id,new Set)),ot},[_e,Ht]),Et="project",Bt=l.useMemo(()=>{const De=new Set;return hd(H,wt,De),_e.forEach(({nodes:ot})=>{hd(ot,wt,De)}),De},[H,_e,wt]),Rt=l.useMemo(()=>{if(!ct)return null;const De=ai(H,ct,Et,!!n.isArchivedBucket);if(De)return De;for(const{nodes:ot}of _e){const dt=ai(ot,ct,Et,!!n.isArchivedBucket);if(dt)return dt}return null},[ct,H,_e,n.isArchivedBucket]),Wt=l.useCallback(De=>{const ot=new WeakMap,dt=st=>{ot.set(st,io(st));for(const pt of st.children)dt(pt)};return De.forEach(dt),ot},[]),D=l.useMemo(()=>Wt(H),[Wt,H]),je=l.useMemo(()=>{const De=new WeakMap;return _e.forEach(({nodes:ot})=>{ot.forEach(dt=>De.set(dt,io(dt)))}),De},[_e]),L=l.useCallback(De=>D.get(De)??je.get(De)??"",[D,je]),te=l.useCallback(De=>({subtreeContainsEditing:Bt,menuOpenSessionId:Rt,nodeStructureKey:L(De)}),[Bt,Rt,L]),ve=Kt.length,P=n.isArchivedBucket||a?Kt:Kt.slice(0,le),Z=ve-P.length,Te=!n.isArchivedBucket&&!a&&ve>Q&&Z===0,Le=l.useCallback(De=>{const ot=[],dt=st=>{st.forEach(pt=>{ot.push(pt.session),pt.children.length>0&&dt(pt.children)})};return dt(De),ot},[]),We=l.useMemo(()=>Le(H),[Le,H]),Ge=l.useMemo(()=>{if(Ae||n.isMain||n.isArchivedBucket||i)return Bd;const De=new Map;for(const ot of We)for(const dt of ul(ot))De.has(dt.key)||De.set(dt.key,dt);return De.size>0?[...De.values()]:Bd},[We,n.isArchivedBucket,n.isMain,Ae,i]),zt=l.useMemo(()=>Ge.flatMap(De=>De.source==="github"?[so("issue",De)]:[]),[Ge]),Ye=ei(zt),Ee=l.useMemo(()=>Ge.flatMap(De=>De.source==="linear"?[fl(De.identifier)]:[]),[Ge]),Pt=bf(Ee),Lt=l.useMemo(()=>Ge.flatMap(De=>De.source==="gitlab"?[no("issue",De.ref)]:[]),[Ge]),os=ei(Lt),it=l.useMemo(()=>yf(Ge,Ye,Pt,os).map(De=>({...De,text:De.statusKey?`${De.label} · ${e(De.statusKey)}`:De.statusText?`${De.label} · ${De.statusText}`:De.label})),[os,Ye,Ge,Pt,e]),Ve=it[0]??null,Qt=l.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const De=new Map,ot=new Map;for(const{folder:st}of _e){if(!st.parentId)continue;const pt=ot.get(st.parentId)??[];pt.push(st.id),ot.set(st.parentId,pt)}const dt=(st,pt)=>{if(pt.has(st))return[];pt.add(st);const Xt=_e.find(({folder:fs})=>fs.id===st),us=Xt?Le(Xt.nodes):[],is=ot.get(st)??[];for(const fs of is)us.push(...dt(fs,pt));return us};for(const{folder:st}of _e)De.set(st.id,dt(st.id,new Set));return De},[_e,Le,n.isArchivedBucket]);if(a&&!Ie&&kt.length===0&&Kt.length===0)return null;const St=!n.isMain&&!!n.branch,Yt=n.branch&&cx(n.branch,n.label)?{label:n.branch}:null,ft=pe?s.jsx(xu,{nodes:H,includeUnreadSubtasks:B}):null,Vt=(De,ot)=>{const{folder:dt,scopeKey:st,scopeDirectory:pt,nodes:Xt}=De,us=Qt.get(dt.id)??[],is=V?.folderId===dt.id&&V?.scopeKey===st,fs=a?!1:tt.has(dt.id),ws=Xs=>s.jsx(Sp,{folderId:dt.id,scopeKey:st,ownerKey:X,children:(Ts,sn)=>s.jsx(wp,{folder:dt,displayName:ot,sessions:Xt,isCollapsed:fs,collapsedActivityState:Xs,onToggle:()=>R(dt.id),onRename:ks=>{_(st,dt.id,ks)},onDelete:()=>{if(n.isArchivedBucket){Rn.requestDelete({sessions:us,mode:"session"});return}if(!ce){U(st,dt.id);return}const ks=_e.filter(({folder:_s})=>_s.parentId===dt.id).length,$s=Xt.length;ie({scopeKey:st,folderId:dt.id,folderName:dt.name,subFolderCount:ks,sessionCount:$s})},groupDirectory:pt??n.directory,projectId:o,mobileVariant:b,alwaysShowActions:g,isRenaming:is,renameDraft:is?V?.draft:void 0,onRenameDraftChange:O,onRenameSave:()=>{const ks=V?.draft.trim()??"";ks&&_(st,dt.id,ks),E()},onRenameCancel:E,droppableRef:Ts,isDropTarget:sn,depth:0,onNewSession:()=>{o&&o!==h&&v(o),b&&S(!1),j({selectedProjectId:o,directoryOverride:pt??n.directory,targetFolderId:dt.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:Xt.map(ks=>s.jsx(di,{node:ks,pinnedSessionIds:N,expandedParents:K,hasSessionSearchQuery:a,normalizedSessionSearchQuery:c,notifyOnSubtasks:B,editingId:I,editingRowKey:z,editTitle:M,openSidebarMenuKey:k,mobileVariant:b,alwaysShowActions:g,groupDirectory:pt??n.directory,projectId:o,folderOwnerKey:X,selectionScopeKey:X,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:Bt,menuOpenSessionId:Rt,nodeStructureKey:L(ks),childRenderExtrasFor:te},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},ks.session.id))})},dt.id);return fs?s.jsx(_C,{nodes:At.get(dt.id)??Xt,includeUnreadSubtasks:B,children:ws},dt.id):ws(null)},et=()=>{const De=new Map;for(const pt of _e){const Xt=pt.folder.parentId;if(!Xt)continue;const us=De.get(Xt);us?us.push(pt):De.set(Xt,[pt])}const ot=[],dt=new Set,st=(pt,Xt)=>{if(dt.has(pt.folder.id))return;dt.add(pt.folder.id);const us=Xt?`${Xt} / ${pt.folder.name}`:pt.folder.name;ot.push(Vt(pt,us)),!(!a&&tt.has(pt.folder.id))&&(De.get(pt.folder.id)??[]).forEach(fs=>st(fs,us))};return kt.forEach(pt=>st(pt,"")),ot},It=!!(!n.isMain&&n.worktree&&!J),ke=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(T,{name:"alert",className:"h-3 w-3"})}):null,qe=n.space&&n.space.state!=="complete"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.spaceStale"),"aria-label":e("sessions.sidebar.group.spaceStale"),children:s.jsx(T,{name:"alert",className:"h-3 w-3"})}):null,Ze=It||!!n.space,Mt=!!n.space,$t=g?Mt?"pr-20":Ze?"pr-14":"pr-7":Se("pr-2",Mt?"[--oc-actions-reserve:68px]":Ze?"[--oc-actions-reserve:44px]":"[--oc-actions-reserve:18px]"),Gt=g?void 0:"group-hover/gh:oc-actions-mask group-focus-within/gh:oc-actions-mask",Ot=g?void 0:"transition-opacity group-hover/gh:opacity-0 group-focus-within/gh:opacity-0",xt=g?"hidden":"transition-opacity group-hover/gh:opacity-0",Tt=g?"inline-flex":"absolute inset-0 inline-flex opacity-0 transition-opacity group-hover/gh:opacity-100",bs=Ae&&Re?[{key:`pr:${Ae.number}`,icon:"git-pull-request",text:`${se} · ${Re}`,title:Ae.title,color:he,url:Ae.url}]:[],ht=Pe?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e($e==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":Oe?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),ze?s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:Ue,onClick:()=>{A()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:ue,children:e("sessions.sidebar.group.empty.retry")})]}):null,xs=De=>s.jsx(di,{node:De,pinnedSessionIds:N,expandedParents:K,hasSessionSearchQuery:a,normalizedSessionSearchQuery:c,notifyOnSubtasks:B,editingId:I,editingRowKey:z,editTitle:M,openSidebarMenuKey:k,mobileVariant:b,alwaysShowActions:g,groupDirectory:n.directory,projectId:o,folderOwnerKey:X,selectionScopeKey:X,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:Bt,menuOpenSessionId:Rt,nodeStructureKey:L(De),childRenderExtrasFor:te},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},De.session.id),ls=s.jsxs(k2,{scopeKey:fe[0]?.scopeKey??ne,ownerKey:X,hasFolders:_e.length>0,onSessionDroppedOnFolder:(De,ot)=>{const dt=_e.find(({folder:pt,scopeKey:Xt})=>pt.id===ot.folderId&&Xt===ot.scopeKey);if(!dt)return;const st=cs.getState();for(const{scopeKey:pt}of fe)pt!==dt.scopeKey&&st.getSessionFolderId(pt,De)&&st.removeSessionFromFolder(pt,De);me(dt.scopeKey,ot.folderId,De)},children:[et(),P.map(xs),ve===0&&_e.length===0?!n.isArchivedBucket&&!ye&&!ht&&n.directory&&!n.emptyMessage?s.jsx(ut,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{o&&o!==h&&v(o),b&&S(!1),j({selectedProjectId:o,directoryOverride:n.directory,target:n.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):ye?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(T,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):ht||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,ve>0&&ht?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:ht}):null,Z>0?s.jsx("button",{type:"button",onClick:()=>x(r,P.length,p??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,Te?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]}),ys="pb-2",Es=s.jsx(Ep,{value:oe,setValue:ie,onConfirm:()=>{const De=oe;De&&(U(De.scopeKey,De.folderId),ie(null))}});return i?d?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Se("oc-group-body",ys),children:ls})}),Es]}):null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:Se("oc-group",J&&"opacity-60"),"aria-busy":J||void 0,children:[s.jsxs("div",{className:Se("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),children:[s.jsxs(Ct,{disabled:Ae?!Re:!Ve,children:[s.jsx(Nt,{asChild:!0,closeDelay:La,children:s.jsx("div",{className:"min-w-0 flex-1",onClick:()=>W(r),role:"button",tabIndex:0,onKeyDown:De=>{(De.key==="Enter"||De.key===" ")&&(De.preventDefault(),W(r))},"aria-label":pe?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!pe,children:s.jsxs("div",{ref:F?.setActivatorNodeRef,className:Se("@container min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5",$t),...F?.listeners??{},children:[s.jsxs("div",{className:Se("min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",Gt),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:"relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(T,{name:"archive",className:Se("h-3.5 w-3.5 shrink-0 text-muted-foreground",xt)}),s.jsx("span",{className:Se("text-muted-foreground h-3.5 w-3.5 items-center justify-center",Tt),children:pe?s.jsx(T,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(T,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Jr(n.label,c)}),ke,ft]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[J?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-muted-foreground",title:e("sessions.sidebar.group.worktreeRemoving"),role:"status","aria-label":e("sessions.sidebar.group.worktreeRemoving"),children:s.jsx(T,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"})}):s.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(T,{name:n.space?"box-3":"git-branch",className:Se("h-3.5 w-3.5 shrink-0",!he&&"text-muted-foreground",xt),style:he?{color:he}:void 0,"aria-label":n.space?e("sessions.sidebar.group.space"):void 0}),s.jsx("span",{className:Se("text-muted-foreground h-3.5 w-3.5 items-center justify-center",Tt),children:pe?s.jsx(T,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(T,{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:Jr(n.label,c)}),ke,qe,ft,Ae?s.jsx("button",{type:"button",className:Se("ml-auto flex-shrink-0 rounded text-[0.72rem] font-medium leading-none hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",Ot),style:he?{color:he}:void 0,disabled:!Ae.url,"aria-label":Ne,onPointerDown:De=>De.stopPropagation(),onKeyDown:De=>De.stopPropagation(),onClick:De=>{De.stopPropagation(),Ae.url&&Gn(Ae.url)},children:se}):Ve?s.jsxs("button",{type:"button",className:Se("ml-auto inline-flex flex-shrink-0 items-center gap-1 rounded text-[0.72rem] font-medium leading-none hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",!Ve.color&&"text-muted-foreground",Ot),style:Ve.color?{color:Ve.color}:void 0,"aria-label":it.map(De=>De.text).join(", "),onPointerDown:De=>De.stopPropagation(),onKeyDown:De=>De.stopPropagation(),onClick:De=>{De.stopPropagation(),Gn(Ve.url)},children:[s.jsx(T,{name:Ve.icon,className:"h-3 w-3"}),Ve.label,it.length>1?s.jsxs("span",{className:"text-muted-foreground",children:["+",it.length-1]}):null]}):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:Jr(n.label,c)}),ft]})}),St&&Yt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(T,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(T,{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:Yt.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(ao,{directory:n.directory,className:Se("self-center",Ot)}):null]})})}),bs.length>0?s.jsx(jt,{side:"right",sideOffset:8,className:"max-w-xs",children:s.jsx(li,{items:bs})}):!Ae&&Ve?s.jsx(jt,{side:"right",sideOffset:8,className:"max-w-xs",children:s.jsx(li,{items:it})}):null]}),s.jsxs(pi,{delayDuration:400,children:[n.isArchivedBucket&&We.length>0?s.jsx("div",{className:Se("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",g?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:De=>{De.stopPropagation(),Rn.requestDelete({sessions:We,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-ring","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(T,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree&&!J?s.jsx("div",{className:Se("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",g?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsx(UC,{label:n.label,sessions:We,worktree:n.worktree})}):null,n.space?s.jsx("div",{className:Se("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",g?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:De=>{De.stopPropagation(),n.space&&_o.getState().openAccessDialog(n.space.id)},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-ring","aria-label":e("spaces.group.access.giveAria",{label:n.label}),children:s.jsx(T,{name:"key",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,n.space?s.jsx("div",{className:Se("absolute right-[3.25rem] top-1/2 -translate-y-1/2 z-10 transition-opacity",g?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100 has-[[data-popup-open]]:opacity-100"),children:s.jsx(Ph,{spaceId:n.space.id,label:n.label})}):null,n.directory?s.jsx("div",{className:Se("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",g?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:De=>{De.stopPropagation(),o&&o!==h&&v(o),b&&S(!1),j({selectedProjectId:o,directoryOverride:n.directory,preserveDirectoryOverride:!!n.space})},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-ring","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(T,{name:"add",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]})]}),n.space?s.jsx(Ih,{spaceId:n.space.id,className:"pb-1 pl-5"}):null,!pe&&d?s.jsx("div",{className:Se("oc-group-body",ys),children:ls}):null]}),Es]})}const GC=l.memo(HC,VC),Lo=({projectId:t,mobileVariant:e,closeMobileSwitcher:n,setActiveProjectIdOnly:r,setSessionSwitcherOpen:o})=>{t&&r(t),e&&n&&o(!1)},qC=(t,e)=>{const n=new Set;for(const r of t)if(!r.isArchivedBucket)for(const o of r.sessions){const{session:i}=o;i.time?.archived||e(i)||n.add(i.id)}return[...n]},Fd=(t,e)=>mf(t.label?.trim()||dl(t.normalizedPath,e)||t.normalizedPath);function YC(t){const e=He.c(110),{model:n,view:r,actions:o}=t;Hs("ui.sidebar_projects_list.render");const{t:i}=vt(),d=mi(),a=cs(a3),c=cs(i3),u=cs(o3),f=cs(r3),p=Ce(n3),m=Ce(s3)&&!cn(),[y,x]=l.useState(null),[w,b]=l.useState(null),[g,h]=l.useState(null),[v,S]=l.useState(null),[j,N]=l.useState(!1),C=l.useRef(null);let B;e[0]===Symbol.for("react.memo_cache_sentinel")?(B={activationConstraint:{distance:8}},e[0]=B):B=e[0];let W;e[1]===Symbol.for("react.memo_cache_sentinel")?(W={activationConstraint:{delay:200,tolerance:6}},e[1]=W):W=e[1];let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={coordinateGetter:Ey},e[2]=F):F=e[2];const $=hi(In(bi,B),In(gi,W),In(Iy,F));let K;e[3]===Symbol.for("react.memo_cache_sentinel")?(K=A=>{C.current=A,S(A)},e[3]=K):K=e[3];const I=K;let z;if(e[4]!==n.projectSections||e[5]!==r.homeDirectory){let A;e[7]!==r.homeDirectory?(A=Q=>({id:Q.project.id,projectLabel:Fd(Q.project,r.homeDirectory),projectDescription:ro(Q.project.normalizedPath,r.homeDirectory),projectIcon:Q.project.icon,projectColor:Q.project.color,projectIconImage:Q.project.iconImage,projectIconBackground:Q.project.iconBackground}),e[7]=r.homeDirectory,e[8]=A):A=e[8],z=n.projectSections.map(A),e[4]=n.projectSections,e[5]=r.homeDirectory,e[6]=z}else z=e[6];const k=z,M=dx(),{confirm:V}=M;let O;e[9]!==V||e[10]!==i?(O=async(A,Q)=>{const le=Tr.getState().ids,Ie=qC(Q,X=>cl(le,X.directory,X.id)||Nu(X.id)||pl(X));if(Ie.length===0){Be.info(i("sessions.sidebar.project.archiveAll.nothing"));return}if(!await V({title:i("sessions.sidebar.project.archiveAll.title",{project:A}),message:Ie.length===1?i("sessions.sidebar.project.archiveAll.descriptionSingle",{count:Ie.length}):i("sessions.sidebar.project.archiveAll.descriptionPlural",{count:Ie.length}),action:i("sessions.sidebar.bulkActions.archive")}))return;const{archivedIds:H,failedIds:ne}=await Je.getState().archiveSessions(Ie);H.length>0&&Be.success(H.length===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:H.length}):i("sessions.sidebar.bulkActions.archivedPlural",{count:H.length})),ne.length>0&&Be.error(ne.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:ne.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:ne.length}))},e[9]=V,e[10]=i,e[11]=O):O=e[11];const E=O;let R;e:{if(!r.stickyZoneHeaders){R=-1;break e}let A;if(e[12]!==n.rowModel.stickyHeaders||e[13]!==w){let Q;e[15]!==w?(Q=le=>`${le.kind}:${le.id}`===w,e[15]=w,e[16]=Q):Q=e[16],A=n.rowModel.stickyHeaders.findIndex(Q),e[12]=n.rowModel.stickyHeaders,e[13]=w,e[14]=A}else A=e[14];R=A}const _=R;let U;if(e[17]!==g||e[18]!==n.groupProps.editingRowKey||e[19]!==n.rowModel.rowIndexByKey||e[20]!==n.rowModel.rows||e[21]!==n.rowModel.stickyHeaders||e[22]!==n.state.openSidebarMenuKey||e[23]!==_){if(U=new Set,g){let A;e[25]!==g||e[26]!==n.rowModel.rowIndexByKey?(A=n.rowModel.rowIndexByKey.get(g),e[25]=g,e[26]=n.rowModel.rowIndexByKey,e[27]=A):A=e[27];const Q=A;Q!==void 0&&U.add(Q)}for(let A=0;A<n.rowModel.rows.length;A=A+1,A){const Q=n.rowModel.rows[A];Q?.kind==="session"&&(n.groupProps.editingRowKey===Q.key||n.state.openSidebarMenuKey===`session-menu:${Q.key}`||n.state.openSidebarMenuKey===`session-context:${Q.key}`)&&U.add(A)}if(_>=0){const A=Math.max(0,_-1),Q=Math.min(n.rowModel.stickyHeaders.length-1,_+1);for(let le=A;le<=Q;le=le+1,le){const Ie=n.rowModel.stickyHeaders[le];Ie&&U.add(Ie.rowIndex)}}e[17]=g,e[18]=n.groupProps.editingRowKey,e[19]=n.rowModel.rowIndexByKey,e[20]=n.rowModel.rows,e[21]=n.rowModel.stickyHeaders,e[22]=n.state.openSidebarMenuKey,e[23]=_,e[24]=U}else U=e[24];const me=U;let ce;e[28]!==n.rowModel.stickyHeaders||e[29]!==r.stickyZoneHeaders?(ce=A=>{const Q=r.stickyZoneHeaders?Zk(n.rowModel.stickyHeaders,A):null,le=Q?`${Q.kind}:${Q.id}`:null;b(Ie=>Ie===le?Ie:le)},e[28]=n.rowModel.stickyHeaders,e[29]=r.stickyZoneHeaders,e[30]=ce):ce=e[30];const oe=ce;let ie;e[31]!==d||e[32]!==i?(ie=A=>{const Q=()=>{if(!A.status.directory){ml();return}d.requestBootstrap({directory:A.status.directory,priority:"expanded",reason:A.group.isMain?"project-expanded":"worktree-expanded",force:!0})},le=async()=>{if(!A.status.directory)return;(await uu(A.status.directory)).success&&Q()};let Ie;e:switch(A.status.state){case"permission-denied":{Ie=i("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Ie=i("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Ie=i("sessions.sidebar.group.empty.initializationFailed");break e}default:Ie=i("sessions.sidebar.group.empty.loadingSessions")}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[A.status.state==="loading"?s.jsx(T,{name:"loader-4",className:"size-3 animate-spin"}):null,Ie,A.status.canGrantAccess?s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{le()},children:i("sessions.sidebar.group.empty.grantAccess")}):null,A.status.state!=="loading"?s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:Q,children:i("sessions.sidebar.group.empty.retry")}):null]})})},e[31]=d,e[32]=i,e[33]=ie):ie=e[33];const xe=ie;let G;e[34]!==o||e[35]!==u||e[36]!==n.emptyState||e[37]!==n.groupProps||e[38]!==n.projectRepoStatus||e[39]!==n.searchEmptyState||e[40]!==n.singleProjectMode||e[41]!==n.state||e[42]!==k||e[43]!==c||e[44]!==xe||e[45]!==E||e[46]!==p||e[47]!==m||e[48]!==i||e[49]!==a||e[50]!==r.alwaysShowActions||e[51]!==r.hideDirectoryControls||e[52]!==r.homeDirectory||e[53]!==r.mobileVariant||e[54]!==r.projectSortOrder||e[55]!==r.stickyZoneHeaders||e[56]!==r.timelineView||e[57]!==r.worktreeSortOrder?(G=A=>{if(A.kind==="activity-header")return s.jsx(Mp,{className:r.stickyZoneHeaders?"sticky top-0 z-20 bg-sidebar":void 0,"data-sidebar-sticky-header":r.stickyZoneHeaders?"true":void 0,children:s.jsx(AC,{activityKey:A.activityKey,collapsed:A.collapsed,forceExpanded:A.forceExpanded,alwaysShowActions:r.alwaysShowActions,timelineView:r.timelineView,onToggle:()=>{if(!A.collapsed){const Q=`activity:${A.activityKey}`;o.group.resetGroupSessionLimit(Q),n.state.setVisibleActivityCountByKey(le=>{if(!le.has(Q))return le;const Ie=new Map(le);return Ie.delete(Q),Ie})}n.state.setCollapsedActivityKeys(Q=>{const le=new Set(Q);return le.has(A.activityKey)?le.delete(A.activityKey):le.add(A.activityKey),le})},onNewChat:()=>{Ce.getState().closeMainSurfaces(),r.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:ux,directoryOverride:null})}})});if(A.kind==="project-header"){const Q=A.section.project,le=Fd(Q,r.homeDirectory);return s.jsx(TC,{id:Q.id,disabled:n.singleProjectMode||A.forceExpanded||n.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:le,projectDescription:ro(Q.normalizedPath,r.homeDirectory),projectDirectory:Q.normalizedPath,projectIcon:Q.icon,projectColor:Q.color,projectIconImage:Q.iconImage,projectIconBackground:Q.iconBackground,isCollapsed:A.collapsed,isRepo:!!n.projectRepoStatus.get(Q.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:A.collapsed?o.renderProjectStatusIndicator?.(Q.id,A.section.groups):null,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,projectPickerOptions:n.singleProjectMode?k:void 0,onProjectSelect:n.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{!A.forceExpanded&&!n.singleProjectMode&&o.toggleProject(Q.id)},onNewSession:()=>{Lo({projectId:Q.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:Q.id,directoryOverride:Q.normalizedPath})},onNewWorktreeSession:()=>{Lo({projectId:Q.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(Q.id),onManageSpaces:m?()=>Ce.getState().setSpacesPageProjectId(Q.id):void 0,onRenameStart:()=>o.openProjectEditDialog(Q.id),onArchiveAll:()=>{E(le,A.section.groups)},onClose:()=>o.removeProject(Q.id),showCreateButtons:!0})}if(A.kind==="group-header")return s.jsx(BC,{id:A.groupKey,disabled:A.forceExpanded||n.state.editingId!==null||r.worktreeSortOrder!=="manual",children:Q=>s.jsx(GC,{...n.groupProps,...o.group,group:A.group,groupKey:A.groupKey,projectId:A.projectId,visibleSessionCount:n.state.visibleSessionCountByGroup.get(A.groupKey),editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,dragHandleProps:Q,renderBody:!1})});if(A.kind==="folder-header"){const Q=n.groupProps.folderRename?.folderId===A.folder.id&&n.groupProps.folderRename.scopeKey===A.scopeKey;return s.jsx(Sp,{folderId:A.folder.id,scopeKey:A.scopeKey,ownerKey:A.ownerKey,disabled:!A.dropEnabled,children:(le,Ie)=>s.jsx(S2,{notifyOnSubtasks:n.groupProps.notifyOnSubtasks,activityNodes:A.activityNodes,folder:A.folder,displayName:A.displayName,sessions:A.nodes,isCollapsed:A.collapsed,onToggle:A.forceExpanded?t3:()=>a(A.folder.id),onRename:re=>c(A.scopeKey,A.folder.id,re),onDelete:()=>{A.archived?Rn.requestDelete({sessions:[...A.deleteSessions],mode:"session"}):p?x({scopeKey:A.scopeKey,folderId:A.folder.id,folderName:A.folder.name,subFolderCount:A.subFolderCount,sessionCount:A.nodes.length}):u(A.scopeKey,A.folder.id)},renderBody:!1,groupDirectory:A.scopeDirectory??A.group.directory,projectId:A.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:Q,renameDraft:Q?n.groupProps.folderRename?.draft:void 0,onRenameDraftChange:n.groupProps.setFolderRenameDraft,onRenameSave:()=>{const re=n.groupProps.folderRename?.draft.trim();re&&c(A.scopeKey,A.folder.id,re),n.groupProps.clearFolderRename()},onRenameCancel:n.groupProps.clearFolderRename,droppableRef:le,isDropTarget:Ie,onNewSession:()=>{Lo({projectId:A.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:A.projectId,directoryOverride:A.scopeDirectory??A.group.directory,targetFolderId:A.folder.id,target:A.group.draftTarget})},archivedBucket:A.archived})})}if(A.kind==="session"){const Q=new Set;return Br(A.node,n.state.editingId)&&Q.add(A.node.session.id),s.jsx("div",{onFocusCapture:()=>h(A.key),onBlurCapture:()=>h(le=>le===A.key?null:le),children:s.jsx(di,{...n.groupProps,node:A.node,depth:A.depth,groupDirectory:A.groupDirectory,projectId:A.projectId,folderOwnerKey:A.ownerKey,selectionScopeKey:A.selectionScopeKey,archivedBucket:A.archived,renderContext:A.renderContext,rowKey:A.key,dragKey:A.key,secondaryMeta:A.secondaryMeta,renderChildren:!1,editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:Q,menuOpenSessionId:n.state.openSidebarMenuKey===`session-menu:${A.key}`||n.state.openSidebarMenuKey===`session-context:${A.key}`?A.node.session.id:null,nodeStructureKey:A.blockingBadgeSessionScopes?`${io(A.node)}:${JSON.stringify(A.blockingBadgeSessionScopes)}`:io(A.node),blockingBadgeSessionScopes:A.blockingBadgeSessionScopes}})})}if(A.kind==="run")return s.jsx(vC,{run:A.run,depth:A.depth,laneNodes:A.laneNodes,blockingSessionIds:A.blockingSessionIds,renderContext:A.renderContext,projectId:A.projectId,projectLabel:A.projectLabel,expansionKey:A.expansionKey,expanded:A.expanded,forceExpanded:A.forceExpanded,notifyOnSubtasks:n.groupProps.notifyOnSubtasks,toggleParent:n.groupProps.toggleParent});if(A.kind==="show-control")return s.jsx("button",{type:"button",className:Se("mt-0.5 flex items-center justify-start rounded-md pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",r.timelineView?"pl-[10px]":"pl-[26px]"),onClick:()=>{A.containerKey.startsWith("activity:")?n.state.setVisibleActivityCountByKey(Q=>{const le=new Map(Q);return A.control==="more"?le.set(A.containerKey,A.currentCount+A.increment):le.delete(A.containerKey),le}):A.control==="more"?o.group.showMoreGroupSessions(A.containerKey,A.currentCount,A.increment):o.group.resetGroupSessionLimit(A.containerKey)},children:i(A.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")});if(A.kind==="status")return xe(A);if(A.emptyKind==="sidebar")return n.emptyState;if(A.emptyKind==="search")return n.searchEmptyState;if(A.emptyKind==="group"&&A.group?.directory&&!A.group.emptyMessage){const Q=A.group;return s.jsx(ut,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{Lo({projectId:A.projectId??null,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:A.projectId,directoryOverride:Q.directory,target:Q.draftTarget})},children:i("sessions.sidebar.group.empty.startSession")})}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:A.emptyKind==="archived"?i("sessions.sidebar.group.empty.noArchivedSessions"):A.group?.emptyMessage??i("sessions.sidebar.group.empty.noSessionsInWorkspace")})},e[34]=o,e[35]=u,e[36]=n.emptyState,e[37]=n.groupProps,e[38]=n.projectRepoStatus,e[39]=n.searchEmptyState,e[40]=n.singleProjectMode,e[41]=n.state,e[42]=k,e[43]=c,e[44]=xe,e[45]=E,e[46]=p,e[47]=m,e[48]=i,e[49]=a,e[50]=r.alwaysShowActions,e[51]=r.hideDirectoryControls,e[52]=r.homeDirectory,e[53]=r.mobileVariant,e[54]=r.projectSortOrder,e[55]=r.stickyZoneHeaders,e[56]=r.timelineView,e[57]=r.worktreeSortOrder,e[58]=G):G=e[58];const pe=G;let J;e[59]!==n.rowModel.rows?(J=n.rowModel.rows.flatMap(e3),e[59]=n.rowModel.rows,e[60]=J):J=e[60];const ge=J;let de;e[61]!==n.sectionsForRender?(de=new Set(n.sectionsForRender.map(ZC)),e[61]=n.sectionsForRender,e[62]=de):de=e[62];const Ae=de;let he;e[63]!==n.rowModel.stickyHeaders?(he=n.rowModel.stickyHeaders.map(JC).join(""),e[63]=n.rowModel.stickyHeaders,e[64]=he):he=e[64];const Re=he,se=!r.timelineView;let Ne;e[65]!==Ae?(Ne=A=>{N(Ae.has(String(A.active.id)))},e[65]=Ae,e[66]=Ne):Ne=e[66];let be;e[67]===Symbol.for("react.memo_cache_sentinel")?(be=()=>N(!1),e[67]=be):be=e[67];let we;e[68]!==o||e[69]!==f||e[70]!==n.rowModel.folderAuthorityByOwner||e[71]!==n.rowModel.folderDropTargets||e[72]!==n.rowModel.rows||e[73]!==n.sectionsForRender||e[74]!==n.state||e[75]!==r.hasSessionSearchQuery||e[76]!==r.projectSortOrder?(we=A=>{if(N(!1),!A.over)return;const Q=A.active.data.current,le=A.over.data.current;if(Q?.type==="session"&&Q.sessionId&&Q.ownerKey&&Q.archivedBucket!==!0&&le?.type==="folder"&&le.folderId&&le.scopeKey&&le.ownerKey===Q.ownerKey){const _e=n.rowModel.folderDropTargets.find(gt=>gt.folderId===le.folderId&>.scopeKey===le.scopeKey&>.ownerKey===Q.ownerKey),wt=n.rowModel.folderAuthorityByOwner.get(Q.ownerKey);if(!_e?.enabled||wt?.complete!==!0)return;const ct=cs.getState();for(const gt of wt.scopeKeys)gt!==le.scopeKey&&ct.removeSessionFromFolder(gt,Q.sessionId);f(le.scopeKey,le.folderId,Q.sessionId);return}if(r.hasSessionSearchQuery||n.state.editingId!==null||A.active.id===A.over.id)return;const Ie=String(A.active.id),re=String(A.over.id),H=n.sectionsForRender.map(XC),ne=H.indexOf(Ie),X=H.indexOf(re);if(ne>=0&&X>=0&&r.projectSortOrder==="manual"){o.reorderProjects(ne,X);return}const fe=n.rowModel.rows.find(_e=>_e.kind==="group-header"&&_e.groupKey===Ie),Fe=n.rowModel.rows.find(_e=>_e.kind==="group-header"&&_e.groupKey===re);if(!fe||!Fe||fe.projectId!==Fe.projectId||!fe.projectId)return;const Me=fe.projectId,tt=n.sectionsForRender.find(_e=>_e.project.id===Me);if(!tt)return;const nt=tt.groups.findIndex(_e=>_e.id===fe.group.id),Qe=tt.groups.findIndex(_e=>_e.id===Fe.group.id);nt<0||Qe<0||o.setGroupOrderByProject(_e=>new Map(_e).set(Me,Pf(tt.groups,nt,Qe).map(QC)))},e[68]=o,e[69]=f,e[70]=n.rowModel.folderAuthorityByOwner,e[71]=n.rowModel.folderDropTargets,e[72]=n.rowModel.rows,e[73]=n.sectionsForRender,e[74]=n.state,e[75]=r.hasSessionSearchQuery,e[76]=r.projectSortOrder,e[77]=we):we=e[77];let ye;e[78]!==oe||e[79]!==n.rowModel||e[80]!==me||e[81]!==pe||e[82]!==v?(ye=s.jsx(CC,{model:n.rowModel,scrollElement:v,pinnedRowIndexes:me,renderRow:pe,onFirstVisibleIndexChange:oe}),e[78]=oe,e[79]=n.rowModel,e[80]=me,e[81]=pe,e[82]=v,e[83]=ye):ye=e[83];let Pe;e[84]!==ge||e[85]!==ye?(Pe=s.jsx(gl,{items:ge,strategy:If,children:ye}),e[84]=ge,e[85]=ye,e[86]=Pe):Pe=e[86];let Oe;e[87]!==$||e[88]!==Ne||e[89]!==we||e[90]!==Pe?(Oe=s.jsx(xi,{sensors:$,collisionDetection:yi,onDragStart:Ne,onDragCancel:be,onDragEnd:we,children:Pe}),e[87]=$,e[88]=Ne,e[89]=we,e[90]=Pe,e[91]=Oe):Oe=e[91];let $e;e[92]!==se||e[93]!==Oe?($e=s.jsx(Mn,{ref:I,useScrollShadow:!0,hideTopScrollShadow:se,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 pl-2.5 pr-2 [overflow-anchor:none]",children:Oe}),e[92]=se,e[93]=Oe,e[94]=$e):$e=e[94];let ze;e[95]!==j||e[96]!==$e||e[97]!==r.stickyZoneHeaders||e[98]!==Re?(ze=s.jsx(PC,{enabled:r.stickyZoneHeaders,suspended:j,layoutKey:Re,scrollRef:C,children:$e}),e[95]=j,e[96]=$e,e[97]=r.stickyZoneHeaders,e[98]=Re,e[99]=ze):ze=e[99];let Ue;e[100]!==u||e[101]!==y?(Ue=()=>{y&&(u(y.scopeKey,y.folderId),x(null))},e[100]=u,e[101]=y,e[102]=Ue):Ue=e[102];let q;e[103]!==y||e[104]!==Ue?(q=s.jsx(Ep,{value:y,setValue:x,onConfirm:Ue}),e[103]=y,e[104]=Ue,e[105]=q):q=e[105];let ue;return e[106]!==M.dialog||e[107]!==ze||e[108]!==q?(ue=s.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[ze,q,M.dialog]}),e[106]=M.dialog,e[107]=ze,e[108]=q,e[109]=ue):ue=e[109],ue}function QC(t){return t.id}function XC(t){return t.project.id}function JC(t){const{kind:e,id:n,rowIndex:r}=t;return`${e}:${n}:${r}`}function ZC(t){return t.project.id}function e3(t){return t.kind==="project-header"?[t.section.project.id]:t.kind==="group-header"?[t.groupKey]:[]}function t3(){}function s3(t){return t.isolatedSpacesEnabled}function n3(t){return t.showDeletionDialog}function r3(t){return t.addSessionToFolder}function o3(t){return t.deleteFolder}function i3(t){return t.renameFolder}function a3(t){return t.toggleFolderCollapse}const l3=l.memo(YC),za=new Map,Ld=(t,e)=>{for(const n of t){const r=at(n??null);r&&!za.has(r)&&za.set(r,e)}},$d=t=>{const e=at(t??null);return e?za.get(e)??0:0},zr=t=>!!t.time?.archived,c3=t=>{const{t:e}=vt(),n=l.useRef(t.gitBranches);n.current=t.gitBranches;const r=l.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),o=l.useCallback(a=>{const c=at(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${c}`.toLowerCase()},[e]),i=l.useCallback((a,c)=>{if(!c)return a;const u=c.trim().toLowerCase(),f=u.startsWith("ses_");return a.flatMap(p=>{if(f&&zr(p.session))return[];if(f?p.session.id.toLowerCase()===u:Zo([o(p.session)],c))return[p];const y=i(p.children,c);return y.length===0?[]:[{...p,children:y}]})},[o]),d=l.useCallback((a,c,u,f,p)=>{const m=at(c??null),y=cf(a),x=new Map(y.map(R=>[R.id,R])),w=new Map;y.forEach(R=>{const _=R.parentID;if(!_)return;const U=x.get(_);if(!U||zr(U)||zr(R))return;const me=w.get(_)??[];me.push(R),w.set(_,me)});const b=fx(u,m),g=(m&&!t.isVSCode?t.spacesByProject?.get(m):void 0)??[],h=new Map;for(const R of g){const _=at(R.directory);_&&h.set(_,R)}const v=R=>{const _=at(R.directory??null),U=t.worktreeMetadata.get(R.id)??null;if(U)return U;if(_){const me=b.get(_)??null;if(me&&_!==m)return me}return null},S=new Set,j=R=>{S.add(R.id);const _=w.get(R.id)??[],U=[];for(const me of _)S.has(me.id)||U.push(j(me));return{session:R,children:U,worktree:v(R)}},N=R=>{const _=R.parentID;if(!_)return!1;if(zr(R))return!0;const U=x.get(_);return!!(U&&zr(U))},C=y.filter(R=>{const _=R.parentID;return _?!x.has(_)&&!N(R):!0}),B=[],W=R=>{S.has(R.id)||B.push(j(R))};C.forEach(W),y.forEach(R=>{N(R)||W(R)});const F=new Map,$="__archived__",K=R=>{if(R.time?.archived)return $;if(t.isVSCode||t.runKeyBySessionId?.has(R.id))return m??"__project_root__";const _=t.sessionOwners?.get(R.id)?.scopeDirectory;if(_){if(_===m)return m??"__project_root__";if(b.has(_)||h.has(_))return _}const me=at(t.worktreeMetadata.get(R.id)?.path??null)??vn(R);return me&&me!==m&&b.has(me)?me:m??"__project_root__"};B.forEach(R=>{const _=K(R.session);F.has(_)||F.set(_,[]),F.get(_)?.push(R)});const I=m??"__project_root__",z=[{id:"root",label:p&&f&&f!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:f}):e("sessions.sidebar.grouping.projectRoot"),branch:f??null,description:m?ro(m,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:m,folderScopeKey:m,sessions:F.get(I)??[]}],k=new Map;u.forEach(R=>{const _=at(R.path)??R.path,U=F.get(_)??[],me=U.length>0,ce=U.reduce((oe,ie)=>{const xe=px(ie.session,t.sessionOrderRanks);return Number.isFinite(xe)?Math.max(oe,xe):oe},0);k.set(_,{hasActiveSession:me,lastUpdatedAt:ce})});const M=(R,_)=>{const U=(R.label||R.branch||R.name||R.path||"").toLowerCase(),me=(_.label||_.branch||_.name||_.path||"").toLowerCase();return U.localeCompare(me)},V=t.worktreeSortOrder!=="recent"?[...u].sort(M):[...u].sort((R,_)=>{const U=at(R.path)??R.path,me=at(_.path)??_.path,ce=k.get(U)??{hasActiveSession:!1,lastUpdatedAt:0},oe=k.get(me)??{hasActiveSession:!1,lastUpdatedAt:0};if(ce.hasActiveSession!==oe.hasActiveSession)return ce.hasActiveSession?-1:1;if(ce.hasActiveSession&&oe.hasActiveSession)return oe.lastUpdatedAt-ce.lastUpdatedAt;const ie=$d(R.path),xe=$d(_.path);return ie!==xe?xe-ie:M(R,_)});(t.isVSCode?[]:V).forEach(R=>{const _=at(R.path)??R.path,U=n.current.get(_)?.trim()||null,me=R.branch?.trim()||null,oe=!!(U&&me&&R.label&&gc(R.label)===gc(me))?U:R.label||R.name||dl(_,t.homeDirectory)||_;z.push({id:`worktree:${_}`,label:oe,branch:U||me,description:ro(_,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:R,directory:_,folderScopeKey:_,sessions:F.get(_)??[]})});for(const[R,_]of h)z.push({id:`space:${_.id}`,label:_.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:_,directory:R,folderScopeKey:R,sessions:F.get(R)??[]});const E=F.get($)??[];return E.length>0&&z.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&&m?lf(m):null,sessions:E}),z},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,t.worktreeSortOrder,t.sessionOwners,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:r,buildSessionSearchText:o,filterSessionNodesForSearch:i,buildGroupedSessions:d}},d3=t=>{const e=He.c(60),{selectedCount:n,scopeKey:r,scopeFolders:o,archivedBucket:i,onMoveToFolder:d,onCreateFolderAndMove:a,onRemoveFromFolder:c,canRemoveFromFolder:u,onRestore:f,onArchive:p,onDelete:m,onDone:y}=t,{t:x}=vt(),w=n>0,b=w&&!!r&&!i;let g;e[0]!==n||e[1]!==x?(g=x("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[0]=n,e[1]=x,e[2]=g):g=e[2];let h;e[3]!==g?(h=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:g}),e[3]=g,e[4]=h):h=e[4];let v;e[5]!==b||e[6]!==u||e[7]!==a||e[8]!==d||e[9]!==c||e[10]!==o||e[11]!==x?(v=b?s.jsxs(Qs,{children:[s.jsxs(Ct,{children:[s.jsx(Nt,{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-ring disabled:pointer-events-none disabled:opacity-40","aria-label":x("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(T,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:x("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(Ys,{align:"end",className:"min-w-[180px]",children:[o.length===0?s.jsx(ts,{disabled:!0,className:"text-muted-foreground",children:x("sessions.sidebar.folders.none")}):o.map(U=>s.jsx(ts,{onClick:()=>d(U.id),children:s.jsx("span",{className:"flex-1 truncate",children:U.name})},U.id)),s.jsx(Vs,{}),s.jsxs(ts,{onClick:a,children:[s.jsx(T,{name:"add",className:"mr-1 h-4 w-4"}),x("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(ts,{onClick:c,className:"text-destructive focus:text-destructive",children:[s.jsx(T,{name:"close",className:"mr-1 h-4 w-4"}),x("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=b,e[6]=u,e[7]=a,e[8]=d,e[9]=c,e[10]=o,e[11]=x,e[12]=v):v=e[12];let S;e[13]!==i||e[14]!==w||e[15]!==f||e[16]!==x?(S=i?s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,disabled:!w,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-ring disabled:pointer-events-none disabled:opacity-40","aria-label":x("sessions.sidebar.bulkActions.restore"),children:s.jsx(T,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:x("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=i,e[14]=w,e[15]=f,e[16]=x,e[17]=S):S=e[17];let j;e[18]!==i||e[19]!==w||e[20]!==p||e[21]!==x?(j=i?null:s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:p,disabled:!w,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-ring disabled:pointer-events-none disabled:opacity-40","aria-label":x("sessions.sidebar.bulkActions.archive"),children:s.jsx(T,{name:"archive",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:x("sessions.sidebar.bulkActions.archive")})})]}),e[18]=i,e[19]=w,e[20]=p,e[21]=x,e[22]=j):j=e[22];const N=!w;let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=Se("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 disabled:pointer-events-none disabled:opacity-40"),e[23]=C):C=e[23];let B;e[24]!==x?(B=x("sessions.sidebar.bulkActions.delete"),e[24]=x,e[25]=B):B=e[25];let W;e[26]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(T,{name:"delete-bin",className:"h-4 w-4"}),e[26]=W):W=e[26];let F;e[27]!==m||e[28]!==N||e[29]!==B?(F=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,disabled:N,className:C,"aria-label":B,children:W})}),e[27]=m,e[28]=N,e[29]=B,e[30]=F):F=e[30];let $;e[31]!==x?($=x("sessions.sidebar.bulkActions.delete"),e[31]=x,e[32]=$):$=e[32];let K;e[33]!==$?(K=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:$})}),e[33]=$,e[34]=K):K=e[34];let I;e[35]!==F||e[36]!==K?(I=s.jsxs(Ct,{children:[F,K]}),e[35]=F,e[36]=K,e[37]=I):I=e[37];let z;e[38]!==x?(z=x("sessions.sidebar.header.actions.exitSelection"),e[38]=x,e[39]=z):z=e[39];let k;e[40]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(T,{name:"close",className:"h-4 w-4"}),e[40]=k):k=e[40];let M;e[41]!==y||e[42]!==z?(M=s.jsx(Nt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:y,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-ring disabled:pointer-events-none disabled:opacity-40","aria-label":z,children:k})}),e[41]=y,e[42]=z,e[43]=M):M=e[43];let V;e[44]!==x?(V=x("sessions.sidebar.header.actions.exitSelection"),e[44]=x,e[45]=V):V=e[45];let O;e[46]!==V?(O=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:V})}),e[46]=V,e[47]=O):O=e[47];let E;e[48]!==M||e[49]!==O?(E=s.jsxs(Ct,{children:[M,O]}),e[48]=M,e[49]=O,e[50]=E):E=e[50];let R;e[51]!==I||e[52]!==E||e[53]!==v||e[54]!==S||e[55]!==j?(R=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[v,S,j,I,E]}),e[51]=I,e[52]=E,e[53]=v,e[54]=S,e[55]=j,e[56]=R):R=e[56];let _;return e[57]!==h||e[58]!==R?(_=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[h,R]}),e[57]=h,e[58]=R,e[59]=_):_=e[59],_},_d=new Map,u3=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},f3=(t,e)=>{const n=t.sessionIds.filter(i=>e.has(i));if(n.length===0)return{ready:!1,value:null};const r=t.archivedBucket||Cp(new Set(n),e),o={sessionIds:n,sessionCount:n.length,archivedBucket:r};return{ready:n.length===t.sessionIds.length&&r===t.archivedBucket,value:o}},p3=t=>{const e=He.c(89),{t:n}=vt();let r;e[0]!==n?(r=q=>{const ue=mx(q);return ue?{description:bu(ue,n)}:void 0},e[0]=n,e[1]=r):r=e[1];const o=r,{isInlineEditing:i,showDeletionDialog:d,foldersMap:a,getFolderScopesForProject:c,addSessionsToFolder:u,removeSessionsFromFolders:f,createFolderAndStartRename:p,archiveSessions:m,unarchiveSessions:y,deleteSessions:x,bulkDeleteConfirm:w,setBulkDeleteConfirm:b}=t,g=As(m3),h=As(h3),v=h>0,S=As(g3),j=As(b3),N=kp(),C=x3,B=y3;let W;e[2]!==v||e[3]!==N||e[4]!==S?(W=v&&Cp(S,N?.getSessionsById()??_d),e[2]=v,e[3]=N,e[4]=S,e[5]=W):W=e[5];const F=W;let $;e:{if(j){$=j;break e}$=null}const K=$;let I;e[6]!==K||e[7]!==c?(I=u3(K,c),e[6]=K,e[7]=c,e[8]=I):I=e[8];const z=I;let k;if(e[9]!==a||e[10]!==z){let q;e[12]!==a?(q=ue=>a[ue]??[],e[12]=a,e[13]=q):q=e[13],k=z.flatMap(q),e[9]=a,e[10]=z,e[11]=k}else k=e[11];const M=k;let V;e[14]!==a||e[15]!==z?(V=q=>{for(const ue of z)if((a[ue]??[]).some(A=>A.id===q))return ue;return null},e[14]=a,e[15]=z,e[16]=V):V=e[16];const O=V;let E;e:{if(!v){E=!1;break e}for(const q of z)for(const ue of a[q]??[])for(const A of ue.sessionIds)if(S.has(A)){E=!0;break e}E=!1}const R=E;let _;e[17]!==u||e[18]!==f||e[19]!==S||e[20]!==z?(_=(q,ue)=>{const A=Array.from(S);for(const Q of z)Q!==q&&f(Q,A);u(q,ue,A)},e[17]=u,e[18]=f,e[19]=S,e[20]=z,e[21]=_):_=e[21];const U=_;let me;e[22]!==v||e[23]!==U||e[24]!==O?(me=q=>{if(!v)return;const ue=O(q);ue&&U(ue,q)},e[22]=v,e[23]=U,e[24]=O,e[25]=me):me=e[25];const ce=me;let oe;e[26]!==p||e[27]!==v||e[28]!==U||e[29]!==z?(oe=()=>{const q=z[0];if(!q||!v)return;const ue=p(q);ue&&U(q,ue.id)},e[26]=p,e[27]=v,e[28]=U,e[29]=z,e[30]=oe):oe=e[30];const ie=oe;let xe;e[31]!==v||e[32]!==f||e[33]!==S||e[34]!==z?(xe=()=>{if(!v)return;const q=Array.from(S);for(const ue of z)f(ue,q)},e[31]=v,e[32]=f,e[33]=S,e[34]=z,e[35]=xe):xe=e[35];const G=xe;let pe;e[36]!==m||e[37]!==x||e[38]!==o||e[39]!==n?(pe=async(q,ue)=>{if(q.length!==0)if(ue){const{deletedIds:A,failedIds:Q}=await x(q);A.length>0&&Be.success(A.length===1?n("sessions.sidebar.bulkActions.deletedSingle",{count:A.length}):n("sessions.sidebar.bulkActions.deletedPlural",{count:A.length})),Q.length>0&&Be.error(Q.length===1?n("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Q.length}):n("sessions.sidebar.bulkActions.failedDeletePlural",{count:Q.length}),o(Q)),As.getState().removeMany(A)}else{const{archivedIds:A,failedIds:Q}=await m(q);A.length>0&&Be.success(A.length===1?n("sessions.sidebar.bulkActions.archivedSingle",{count:A.length}):n("sessions.sidebar.bulkActions.archivedPlural",{count:A.length})),Q.length>0&&Be.error(Q.length===1?n("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Q.length}):n("sessions.sidebar.bulkActions.failedArchivePlural",{count:Q.length}),o(Q)),As.getState().removeMany(A)}},e[36]=m,e[37]=x,e[38]=o,e[39]=n,e[40]=pe):pe=e[40];const J=pe;let ge;e[41]!==J||e[42]!==v||e[43]!==S||e[44]!==b||e[45]!==d?(ge=q=>{if(!v)return;const ue=Array.from(S);if(!d){J(ue,q);return}b({sessionIds:ue,sessionCount:ue.length,archivedBucket:q})},e[41]=J,e[42]=v,e[43]=S,e[44]=b,e[45]=d,e[46]=ge):ge=e[46];const de=ge;let Ae;e[47]!==F||e[48]!==de?(Ae=()=>de(F),e[47]=F,e[48]=de,e[49]=Ae):Ae=e[49];const he=Ae;let Re;e[50]!==de?(Re=()=>de(!1),e[50]=de,e[51]=Re):Re=e[51];const se=Re;let Ne;e[52]!==de?(Ne=()=>de(!0),e[52]=de,e[53]=Ne):Ne=e[53];const be=Ne;let we;e[54]!==F||e[55]!==o||e[56]!==v||e[57]!==S||e[58]!==n||e[59]!==y?(we=async()=>{if(!v||!F)return;const q=Array.from(S),{restoredIds:ue,failedIds:A}=await y(q);ue.length>0&&Be.success(ue.length===1?n("sessions.sidebar.bulkActions.restoredSingle",{count:ue.length}):n("sessions.sidebar.bulkActions.restoredPlural",{count:ue.length})),A.length>0&&Be.error(A.length===1?n("sessions.sidebar.bulkActions.failedRestoreSingle",{count:A.length}):n("sessions.sidebar.bulkActions.failedRestorePlural",{count:A.length}),o(A)),As.getState().removeMany(ue)},e[54]=F,e[55]=o,e[56]=v,e[57]=S,e[58]=n,e[59]=y,e[60]=we):we=e[60];const ye=we;let Pe;e[61]!==w||e[62]!==J||e[63]!==N||e[64]!==b?(Pe=async()=>{if(!w)return;const q=N?.getSessionsById()??_d,ue=f3(w,q);if(!ue.ready){b(ue.value);return}b(null),await J(ue.value.sessionIds,ue.value.archivedBucket)},e[61]=w,e[62]=J,e[63]=N,e[64]=b,e[65]=Pe):Pe=e[65];const Oe=Pe;let $e,ze;e[66]!==w||e[67]!==he||e[68]!==i||e[69]!==N||e[70]!==g?($e=()=>{if(!g)return;const q=/Macintosh|Mac OS X/.test(navigator.userAgent||""),ue=A=>{if(w||i)return;const Q=A.target instanceof HTMLElement?A.target:null;if(Q&&(Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q.isContentEditable))return;const le=q?A.metaKey:A.ctrlKey;if(A.key==="Escape"){A.preventDefault(),As.getState().disable();return}if(le&&A.key==="Backspace"){A.preventDefault(),he();return}if(le&&(A.key==="a"||A.key==="A")){const Ie=N2(N?.getEntries()??[],N?.getDescendantIds()??[],As.getState().scopeKey);if(!Ie)return;A.preventDefault(),As.getState().replaceAll(Ie.ids,Ie.scopeKey)}};return window.addEventListener("keydown",ue),()=>window.removeEventListener("keydown",ue)},ze=[w,he,i,N,g],e[66]=w,e[67]=he,e[68]=i,e[69]=N,e[70]=g,e[71]=$e,e[72]=ze):($e=e[71],ze=e[72]),l.useEffect($e,ze);let Ue;return e[73]!==R||e[74]!==M||e[75]!==F||e[76]!==Oe||e[77]!==K||e[78]!==se||e[79]!==ie||e[80]!==he||e[81]!==be||e[82]!==ce||e[83]!==G||e[84]!==ye||e[85]!==v||e[86]!==h||e[87]!==g?(Ue={selectionModeEnabled:g,hasSelection:v,selectedIdsSize:h,bulkScopeIsArchived:F,derivedSelectionScope:K,bulkScopeFolders:M,bulkCanRemoveFromFolder:R,handleToggleSelectionMode:C,handleExitSelectionMode:B,handleBulkMoveToFolder:ce,handleBulkCreateFolderAndMove:ie,handleBulkRemoveFromFolder:G,handleBulkDelete:he,handleBulkArchive:se,handleBulkHardDelete:be,handleBulkRestore:ye,confirmBulkDelete:Oe},e[73]=R,e[74]=M,e[75]=F,e[76]=Oe,e[77]=K,e[78]=se,e[79]=ie,e[80]=he,e[81]=be,e[82]=ce,e[83]=G,e[84]=ye,e[85]=v,e[86]=h,e[87]=g,e[88]=Ue):Ue=e[88],Ue};function m3(t){return t.enabled}function h3(t){return t.selectedIds.size}function g3(t){return t.selectedIds}function b3(t){return t.scopeKey}function x3(){As.getState().toggleMode()}function y3(){As.getState().disable()}function v3(t){const e=He.c(37),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:o}=t,[i,d]=l.useState(null),a=Ce(I3),c=Ce(P3),u=cs(A3),f=cs(N3),p=cs(C3),m=cs(k3),y=Je(j3),x=Je(S3),w=Je(w3);let b;e[0]!==f||e[1]!==o?(b=N=>{const C=f(N,"New folder");return o(N,C),C},e[0]=f,e[1]=o,e[2]=b):b=e[2];let g;e[3]!==p||e[4]!==y||e[5]!==i||e[6]!==w||e[7]!==u||e[8]!==n||e[9]!==r||e[10]!==m||e[11]!==a||e[12]!==b||e[13]!==x?(g={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:n,addSessionsToFolder:p,removeSessionsFromFolders:m,createFolderAndStartRename:b,archiveSessions:y,unarchiveSessions:x,deleteSessions:w,bulkDeleteConfirm:i,setBulkDeleteConfirm:d},e[3]=p,e[4]=y,e[5]=i,e[6]=w,e[7]=u,e[8]=n,e[9]=r,e[10]=m,e[11]=a,e[12]=b,e[13]=x,e[14]=g):g=e[14];const h=p3(g);let v;e[15]!==h.bulkCanRemoveFromFolder||e[16]!==h.bulkScopeFolders||e[17]!==h.bulkScopeIsArchived||e[18]!==h.derivedSelectionScope||e[19]!==h.handleBulkArchive||e[20]!==h.handleBulkCreateFolderAndMove||e[21]!==h.handleBulkHardDelete||e[22]!==h.handleBulkMoveToFolder||e[23]!==h.handleBulkRemoveFromFolder||e[24]!==h.handleBulkRestore||e[25]!==h.handleExitSelectionMode||e[26]!==h.selectedIdsSize||e[27]!==h.selectionModeEnabled?(v=h.selectionModeEnabled?s.jsx(d3,{selectedCount:h.selectedIdsSize,scopeKey:h.derivedSelectionScope,scopeFolders:h.bulkScopeFolders,archivedBucket:h.bulkScopeIsArchived,onMoveToFolder:h.handleBulkMoveToFolder,onCreateFolderAndMove:h.handleBulkCreateFolderAndMove,onRemoveFromFolder:h.handleBulkRemoveFromFolder,canRemoveFromFolder:h.bulkCanRemoveFromFolder,onRestore:h.handleBulkRestore,onArchive:h.handleBulkArchive,onDelete:h.handleBulkHardDelete,onDone:h.handleExitSelectionMode}):null,e[15]=h.bulkCanRemoveFromFolder,e[16]=h.bulkScopeFolders,e[17]=h.bulkScopeIsArchived,e[18]=h.derivedSelectionScope,e[19]=h.handleBulkArchive,e[20]=h.handleBulkCreateFolderAndMove,e[21]=h.handleBulkHardDelete,e[22]=h.handleBulkMoveToFolder,e[23]=h.handleBulkRemoveFromFolder,e[24]=h.handleBulkRestore,e[25]=h.handleExitSelectionMode,e[26]=h.selectedIdsSize,e[27]=h.selectionModeEnabled,e[28]=v):v=e[28];let S;e[29]!==h.confirmBulkDelete||e[30]!==i||e[31]!==c||e[32]!==a?(S=s.jsx(lC,{value:i,setValue:d,showDeletionDialog:a,setShowDeletionDialog:c,onConfirm:h.confirmBulkDelete}),e[29]=h.confirmBulkDelete,e[30]=i,e[31]=c,e[32]=a,e[33]=S):S=e[33];let j;return e[34]!==v||e[35]!==S?(j=s.jsxs(s.Fragment,{children:[v,S]}),e[34]=v,e[35]=S,e[36]=j):j=e[36],j}function w3(t){return t.deleteSessions}function S3(t){return t.unarchiveSessions}function j3(t){return t.archiveSessions}function k3(t){return t.removeSessionsFromFolders}function C3(t){return t.addSessionsToFolder}function N3(t){return t.createFolder}function A3(t){return t.foldersMap}function P3(t){return t.setShowDeletionDialog}function I3(t){return t.showDeletionDialog}const Tp="oc.sessions.expandedParents.v3",D3=Si(qn()),E3=()=>{try{const t=globalThis.localStorage.getItem(Tp);if(t===null)return new Set;const e=D3.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},R3=()=>{const[t,e]=l.useState(E3),n=l.useRef(t);n.current=t;const r=l.useCallback(o=>{const i=hx(n.current,o);n.current=i,e(i);try{globalThis.localStorage.setItem(Tp,JSON.stringify([...i]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},M3=t=>{const e=He.c(22),{childStores:n,sections:r,chatGroup:o,canGrantAccess:i}=t,d=Ls(T3),a=Ls(O3);let c;e[0]!==o||e[1]!==r?(c=[...r.flatMap(B3),...o?[{key:"activity:chats",group:o}]:[]].map($3),e[0]=o,e[1]=r,e[2]=c):c=e[2];const u=c;let f;e[3]!==u?(f=new Set(u.flatMap(_3)),e[3]=u,e[4]=f):f=e[4];let p;e[5]!==f?(p=[...f],e[5]=f,e[6]=p):p=e[6];const m=p;let y;e[7]!==n||e[8]!==m.length?(y=v=>m.length>0?n.subscribeBootstrap(v):K3,e[7]=n,e[8]=m.length,e[9]=y):y=e[9];let x;e[10]!==n||e[11]!==m?(x=()=>m.map(v=>`${v}\0${n.getBootstrapState(v)??""}\0${n.getBootstrapFailure(v)??""}\0${n.getInitializationState(v)??""}\0${n.getInitializationFailure(v)??""}`).join(""),e[10]=n,e[11]=m,e[12]=x):x=e[12];const w=l.useSyncExternalStore(y,x,W3);let b;if(e[13]!==i||e[14]!==n||e[15]!==d||e[16]!==u||e[17]!==a){b=new Map;for(const{key:v,archived:S,directories:j}of u){const N=j.find(C=>n.getBootstrapState(C)==="failed"||n.getInitializationState(C)==="failed");if(N){const C=n.getBootstrapState(N)==="failed",B=C?n.getBootstrapFailure(N):n.getInitializationFailure(N);b.set(v,{state:B==="os-permission"?"permission-denied":C?"load-failed":"initialization-failed",directory:N,canGrantAccess:B==="os-permission"&&i})}else{const C=a||!S&&j.length>0&&j.every(B=>n.getBootstrapState(B)==="complete");b.set(v,{state:C?"ready":d==="error"?"load-failed":"loading",directory:C?j[0]??null:null,canGrantAccess:!1})}}e[13]=i,e[14]=n,e[15]=d,e[16]=u,e[17]=a,e[18]=b}else b=e[18];const g=b;let h;return e[19]!==w||e[20]!==g?(h={groupStatusByKey:g,bootstrapSnapshot:w},e[19]=w,e[20]=g,e[21]=h):h=e[21],h};function T3(t){return t.status}function O3(t){return t.hasLoaded}function B3(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function F3(t){return at(t.directory)}function L3(t){return!!t}function $3(t){const{key:e,group:n}=t;return{key:e,archived:n.isArchivedBucket===!0,directories:oo(n).map(F3).filter(L3)}}function _3(t){return t.directories}function K3(){}function W3(){return""}const z3=6e4,V3=[],Kd=[],Wd=[],U3=t=>!t.parentID,H3=({topology:t,view:e,actions:n})=>{const{alwaysShowActions:r,notifyOnSubtasks:o,projectViewActions:i,rowActions:d,...a}=n,c=cs(ke=>ke.foldersMap),u=cs(ke=>ke.collapsedFolderIds),f=cs(ke=>ke.createFolder),p=cs(ke=>ke.addSessionToFolder),m=e.projectView,{getOrderedGroups:y,setGroupOrderByProject:x,toggleGroup:w,toggleProject:b}=i,g=Dh({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),h=gx(ke=>ke.projects),v=Mm(),S=l.useMemo(()=>new Map(v.map(ke=>[ke.id,ke.name])),[v]),j=l.useMemo(()=>{const ke=new Map;for(const qe of v){const Ze=at(qe.projectDirectory);if(!Ze)continue;const Mt=ke.get(Ze);Mt?Mt.push(qe):ke.set(Ze,[qe])}return ke},[v]),N=l.useMemo(()=>By(g.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,g.archivedSessions,h,v),[h,g.archivedSessions,g.sessions,v,t.availableWorktreesByProject,t.isVSCode,t.projects]),[C,B]=l.useState(new Map),[W,F]=l.useState(new Set),[$,K]=l.useState(new Map),I=l.useCallback((ke,qe,Ze=7)=>{B(Mt=>new Map(Mt).set(ke,qe+Ze))},[]),z=l.useCallback(ke=>{B(qe=>{if(!qe.has(ke))return qe;const Ze=new Map(qe);return Ze.delete(ke),Ze})},[]),k=Ds(ke=>ke.showRecentSection),M=Ds(ke=>ke.projectDisplayMode),V=Ds(ke=>ke.singleProjectId),O=Ds(ke=>ke.setSingleProjectId),R=!t.isVSCode&&!Tm()&&M==="single",_=e.sidebarViewMode==="timeline"&&!t.isVSCode,U=Eh({enabled:k&&!R&&!_,isVSCode:t.isVSCode,pinnedSessionIds:g.pinnedSessionIds,sessionOrderRanks:g.sessionOrderRanks,sessions:g.rootSessions}),me=l.useMemo(()=>bx(g.rootSessions,ke=>at(t.worktreeMetadata.get(ke.id)?.projectDirectory??ke.directory??null)),[g.rootSessions,t.worktreeMetadata]),ce=l.useRef(null),oe=l.useMemo(()=>{const ke=Array.from(me.runKeyBySessionId,([qe,Ze])=>`${qe}\0${Ze}`).sort().join("");return ce.current?.signature!==ke&&(ce.current={signature:ke,map:me.runKeyBySessionId}),ce.current.map},[me]),[ie,xe]=l.useState(null),[G,pe]=l.useState(null),[J,ge]=l.useState(""),[de,Ae]=l.useState(null),[he,Re]=l.useState(null),[se,Ne]=l.useState(null),be=l.useCallback((ke,qe)=>{Ne({scopeKey:ke,folderId:qe.id,draft:qe.name})},[]),we=l.useCallback(ke=>{Ne(qe=>qe?{...qe,draft:ke}:null)},[]),ye=l.useCallback(()=>Ne(null),[]),{expandedParents:Pe,toggleParent:Oe}=R3(),$e=Je(ke=>ke.setCurrentSession),ze=l.useCallback((ke,qe)=>{ke!==Je.getState().currentSessionId&&$e(ke,qe)},[$e]),Ue=vf(),q=Ds(ke=>ke.worktreeSortOrder),{buildGroupedSessions:ue,filterSessionNodesForSearch:A,buildGroupSearchText:Q}=c3({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:g.pinnedSessionIds,sessionOrderRanks:g.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:q,sessionOwners:N.bySessionId,spacesByProject:j,runKeyBySessionId:oe}),{getSessionsForProject:le,getArchivedSessionsForProject:Ie}=$k({ownership:N}),re=l.useMemo(()=>{if(t.isVSCode)return null;const ke=xx(e.homeDirectory)??g.chatSessions.map(Ze=>il(Ze.directory)).find(Boolean)??null;if(!ke)return null;const qe=Array.from(new Set([ke,...g.chatSessions.map(Ze=>at(Ze.directory??null)).filter(Boolean)])).filter(Ze=>!!Ze).map(Ze=>({scopeKey:Ze,directory:Ze}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:ke,folderScopeKey:ke,folderScopes:qe,draftTarget:"chat",sessions:g.chatSessions.filter(Ze=>!Ze.time?.archived&&U3(Ze)).map(Ze=>jr(g.childrenMap,Ze))}},[g.chatSessions,g.childrenMap,t.isVSCode,e.homeDirectory]),H=l.useMemo(()=>re?[re]:V3,[re]),{projectSections:ne,groupSearchDataByGroup:X,sectionsForRender:fe,flatSectionsForRender:Fe}=n2({normalizedProjects:t.projects,getSessionsForProject:le,getArchivedSessionsForProject:Ie,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:ue,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:A,buildGroupSearchText:Q,foldersMap:c,standaloneGroups:H}),Me=e.onSearchMatchCountChange;l.useEffect(()=>()=>Me(0),[Me]);const tt=mi(),nt=e.useGroupedSections?fe:Fe,Qe=l.useMemo(()=>e.showInlineArchived?nt:nt.map(ke=>ke.groups.some(qe=>qe.isArchivedBucket)?{...ke,groups:ke.groups.filter(qe=>!qe.isArchivedBucket)}:ke),[nt,e.showInlineArchived]),_e=l.useCallback(ke=>Fe.find(Ze=>Ze.project.id===ke)?.groups.find(Ze=>!Ze.isArchivedBucket)?.folderScopes??[],[Fe]);Rk({enabled:!0,normalizedProjects:t.projects,ownership:N,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:g.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:c,createFolder:f,addSessionToFolder:p});const{sourceControl:wt}=jn(),ct=vs(ke=>ke.ensureEntry),gt=vs(ke=>ke.setParams),Kt=vs(ke=>ke.refreshTargets),kt=vs(ke=>ke.clearDirectoryStatus),Ht=vs(ke=>ke.beginActiveContextsLoad),At=vs(ke=>ke.commitActiveContexts),Et=vs(ke=>ke.releaseActiveContexts),Bt=vs(ke=>ke.activeContextRegistrations),Rt=l.useId(),Wt=l.useRef(new Set),D=l.useMemo(()=>new Map(g.orderedSessions.map((ke,qe)=>[ke.id,qe])),[g.orderedSessions]),je=l.useMemo(()=>q!=="manual"?Qe:Qe.map(ke=>{const qe=y(ke.project.id,ke.groups);return qe===ke.groups?ke:{...ke,groups:qe}}),[y,Qe,q]),L=l.useMemo(()=>{const ke=new Map(U.map($t=>[$t.id,jr(g.childrenMap,$t)])),qe=[...ke.values()],Ze=[];for(;qe.length>0;){const $t=qe.pop();if(!$t)break;Ze.push($t.session),qe.push(...$t.children)}const Mt=Oi({sessions:Ze,projects:t.projects,ownerBySessionId:N.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,hideBranchMatchingProjectLabel:!0});return Rh({sessions:U,getSessionLocation:$t=>Mt.get($t)??null,getSessionNode:$t=>ke.get($t.id)??jr(g.childrenMap,$t),query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""})},[g.childrenMap,N.bySessionId,U,S,t.availableWorktreesByProject,t.gitBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),te=l.useMemo(()=>{if(!_)return Kd;const ke=new Set(g.rootSessions.map(Gt=>Gt.id)),qe=g.orderedSessions.filter(Gt=>ke.has(Gt.id)&&!Gt.time?.archived),Ze=new Map,Mt=Oi({sessions:qe,projects:t.projects,ownerBySessionId:N.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return ec({sessions:qe,getSessionLocation:Gt=>Mt.get(Gt)??null,getSessionNode:Gt=>{const Ot=jr(g.childrenMap,Gt),xt=Mt.get(Gt.id);return Ze.set(Gt.id,Oa(Ot,!1,xt?.groupDirectory??Gt.directory??null)),{...Ot,children:[],worktree:xt?.worktree??null}},query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""}).map(Gt=>({...Gt,blockingBadgeSessionScopes:Ze.get(Gt.node.session.id)}))},[g.childrenMap,g.orderedSessions,g.rootSessions,N.bySessionId,S,_,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),ve=Ce(ke=>ke.sessionWorkEnabled),P=l.useMemo(()=>{if(!ve)return Wd;const ke=g.orderedSessions.filter(qe=>!qe.parentID&&!qe.time?.archived&&!al(qe.directory)&&pl(qe));return ke.length>0?ke:Wd},[g.orderedSessions,ve]),Z=l.useMemo(()=>new Set(P.map(ke=>ke.id)),[P]),Te=l.useMemo(()=>{if(P.length===0)return Kd;const ke=Oi({sessions:[...P],projects:t.projects,ownerBySessionId:N.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!_}),qe=new Map,Ze=new Map(P.map(Ot=>{const xt=jr(g.childrenMap,Ot);_&&qe.set(Ot.id,Oa(xt,!1,ke.get(Ot.id)?.groupDirectory??Ot.directory??null));const Tt={...xt,children:_?[]:xt.children,worktree:ke.get(Ot.id)?.worktree??null};return[Ot.id,Tt]})),Mt=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",$t=Mt?P.filter(Ot=>{const xt=Ze.get(Ot.id);return xt?Mh(xt,Mt):!1}):[...P],Gt=ec({sessions:$t,getSessionLocation:Ot=>ke.get(Ot)??null,getSessionNode:Ot=>Ze.get(Ot.id)??jr(g.childrenMap,Ot),query:""});return _?Gt.map(Ot=>({...Ot,blockingBadgeSessionScopes:qe.get(Ot.node.session.id)})):Gt},[g.childrenMap,N.bySessionId,S,_,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery,P]),Le=l.useMemo(()=>{const ke=new Map,qe=new Map,Ze=new Map,Mt=new Map,$t=new Set,Gt=(xt,Tt)=>{const bs=Tt?.trim();xt&&bs&&ke.set(wx(xt,bs),{directory:xt,branch:bs})},Ot=xt=>{if(Gt(at(xt.worktree?.path??null),xt.worktree?.branch),!t.isVSCode){for(const Tt of gf(xt.session))qe.set(`${Tt.owner.toLowerCase()}/${Tt.repo.toLowerCase()}#${Tt.number}`,{owner:Tt.owner,repo:Tt.repo,number:Tt.number});for(const Tt of ul(xt.session))Tt.source==="github"?Ze.set(`${Tt.owner.toLowerCase()}/${Tt.repo.toLowerCase()}#${Tt.number}`,{owner:Tt.owner,repo:Tt.repo,number:Tt.number}):Tt.source==="linear"&&$t.add(Tt.identifier.toUpperCase());for(const Tt of vx(xt.session))Mt.set(Tt.key,Tt)}xt.children.forEach(Ot)};return Te.forEach(xt=>Ot(xt.node)),_?(te.forEach(xt=>Ot(xt.node)),{targets:ke,linkedRefs:[...qe.values()],linkedIssueRefs:[...Ze.values()],linearIdentifiers:[...$t],gitlabRefs:[...Mt.values()]}):(L.forEach(xt=>xt.items.forEach(Tt=>Ot(Tt.node))),ne.forEach(xt=>{m.collapsedProjects.has(xt.project.id)||xt.groups.forEach(Tt=>{if(Tt.isArchivedBucket||(Tt.sessions.forEach(Ot),Tt.isMain))return;const bs=at(Tt.directory??null);Gt(bs,Tt.branch?.trim()||t.gitBranches.get(bs||""))})}),{targets:ke,linkedRefs:[...qe.values()],linkedIssueRefs:[...Ze.values()],linearIdentifiers:[...$t],gitlabRefs:[...Mt.values()]})},[ne,m.collapsedProjects,L,te,_,t.gitBranches,t.isVSCode,Te]),We=Le.targets,Ge=l.useRef(null),zt=l.useMemo(()=>{const ke=Ek(We.values()),qe=JSON.stringify(ke);return Ge.current?.signature!==qe&&(Ge.current={signature:qe,candidates:ke}),Ge.current.candidates},[We]);l.useEffect(()=>{const ke=zt;if(ke.length===0)return;let qe=!1;const Ze=ss(),Mt=async(ht,xs=z3)=>{const ls=Date.now(),ys=new Map,Es=st=>{const pt=ys.get(st);if(pt)return pt;const Xt=Ht(Ze,st,Rt),us=nr.scope(st),is=Jo(()=>nr.read(us,wt)).then(fs=>{if(qe||Ze!==ss())return null;const ws=fs.contexts[0],Xs=ws&&la(Hn.getState().entries[Ar(ws)],ws).connected?[ws]:[];return At(Ze,st,Rt,Xt,Xs)?(Xs.length===0&&kt(st),Xs):null});return ys.set(st,is),is},De=await Promise.all(ke.filter(st=>!ht||st.directory===ht).map(async st=>(await Es(st.directory)??[]).map(Xt=>({...st,context:Xt}))));if(qe||Ze!==ss())return;const ot=new Map,dt=new Map;for(const st of De.flat()){const pt=Ku(st.context,st.branch);dt.set(pt,{context:st.context,branch:st.branch});const Xt=vs.getState().entries[pt],us=Xt?.status?.changeRequest??Xt?.status?.pr,is=us?.state,ws=!!us&&!(is==="closed"||is==="merged"),Xs=Math.max(Xt?.lastRefreshAt??0,Xt?.lastDiscoveryPollAt??0),Ts=!!(Xt?.isInitialStatusResolved&&!ws&&(!Wt.current.has(pt)||ls-Xs>=xs));(!Xt||!Xt.isInitialStatusResolved||Ts)&&(Ts&&Wt.current.add(pt),ot.has(pt)||ot.set(pt,{context:st.context,branch:st.branch}))}dt.forEach((st,pt)=>{ct(pt),gt(pt,{directory:st.context.directory,branch:st.branch,remoteName:st.context.primaryRemote,canShow:!0,identity:st.context,readContext:st.context,sourceControl:wt,authChecked:!0,connected:!0})}),ot.size!==0&&await Kt([...ot.values()],{silent:!0,markInitialResolved:!0})},$t=[...new Set(ke.map(ht=>ht.directory))].map(ht=>nr.scope(ht)),Gt=$t.map(ht=>{let xs=nr.snapshot(ht);return nr.subscribe(ht,()=>{const ls=nr.snapshot(ht),ys=xs.read!==null&&xs!==ls;xs=ls,ys&&!qe&&Mt(ht.directory)})}),Ot=Hn.subscribe((ht,xs)=>{if(!(qe||Ze!==ss()||ht.entries===xs.entries))for(const ls of $t){const ys=nr.snapshot(ls).contexts[0];if(!ys)continue;const Es=Ar(ys);ht.entries[Es]!==xs.entries[Es]&&Mt(ls.directory)}});Mt();const xt=new Set(ke.map(ht=>ht.directory)),Tt=Qn(ht=>{!qe&&ht.type==="source-control-activity"&&xt.has(ht.directory)&&Mt(ht.directory,0)}),bs=()=>{!qe&&document.visibilityState==="visible"&&Mt()};return document.addEventListener("visibilitychange",bs),()=>{qe=!0,Ot(),Gt.forEach(ht=>ht()),Tt(),document.removeEventListener("visibilitychange",bs);for(const ht of ke)Et(Ze,ht.directory,Rt)}},[Ht,kt,At,zt,ct,Kt,Et,gt,wt,Rt]);const Ye=l.useMemo(()=>yx(Bt,We.values()),[Bt,We]),Ee=zu(Ye),Pt=l.useMemo(()=>[...Ee,...Le.linkedRefs.map(ke=>so("pull",ke)),...Le.linkedIssueRefs.map(ke=>so("issue",ke)),...Le.gitlabRefs.map(ke=>ke.thread==="pull"?no("pull",ke):no("issue",ke)),...Le.linearIdentifiers.map(fl)],[Ee,Le]);Wu(Pt);const{groupStatusByKey:Lt,bootstrapSnapshot:os}=M3({childStores:tt,sections:je,chatGroup:re,canGrantAccess:du()});let it=null;R&&(ne.some(ke=>ke.project.id===V)?it=V:ne.some(ke=>ke.project.id===e.activeProjectId)?it=e.activeProjectId:it=ne[0]?.project.id??null);const Ve=l.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:X,collapsedGroups:m.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:o,pinnedSessionIds:g.pinnedSessionIds,sessionOrderIndex:D,expandedParents:Pe,editingId:ie,editingRowKey:G,editTitle:J,sessionBatchSize:R&&!e.useGroupedSections?20:void 0,setEditingId:xe,setEditingRowKey:pe,setEditTitle:ge,toggleParent:Oe,allowReselect:d.allowReselect,onSessionSelected:d.onSessionSelected,resetSessionSearch:d.resetSessionSearch,deleteSessionConfirm:he,setDeleteSessionConfirm:Re,startFolderRename:be,startSessionWorktreeMenuLoad:n.startSessionWorktreeMenuLoad,onEditProject:_?a.openProjectEditDialog:void 0,folderRename:se,setFolderRenameDraft:we,clearFolderRename:ye}),[g.pinnedSessionIds,r,o,m.collapsedGroups,X,D,J,ie,G,Pe,se,we,ye,be,he,n.startSessionWorktreeMenuLoad,a.openProjectEditDialog,_,d,Oe,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,R]),Qt=l.useMemo(()=>({showMoreGroupSessions:I,resetGroupSessionLimit:z,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,onToggleCollapsedGroup:w}),[z,I,w,a.openNewSessionDraft,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen]),St=l.useMemo(()=>{const ke=new Map;for(const qe of je)for(const Ze of qe.groups){const Mt=Wn(qe.project.id,Ze.directory);if(!Mt)continue;const $t=oo(Ze),Gt=ke.get(Mt),Ot=[...new Set([...Gt?.scopeKeys??[],...$t.map(Tt=>Tt.scopeKey)])],xt=g.hasAuthoritativeGlobalSessions&&$t.every(Tt=>{const bs=at(Tt.directory);return!bs||tt.getBootstrapState(bs)==="complete"});ke.set(Mt,{scopeKeys:Ot,complete:(Gt?.complete??!0)&&xt})}if(re){const qe=Wn(null,re.directory);qe&&ke.set(qe,{scopeKeys:oo(re).map(Ze=>Ze.scopeKey),complete:g.hasAuthoritativeGlobalSessions})}return ke},[os,re,tt,g.hasAuthoritativeGlobalSessions,je]),Yt=l.useMemo(()=>new Map([...C,...$]),[$,C]),ft=l.useMemo(()=>e2({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:_?"timeline":"projects",sections:je,authoritativeSections:ne,chatGroup:re,recentSections:L,timelineItems:te,workItems:Te,workSessionIds:Z,showRecentSection:k&&!R&&!_,foldersMap:c,groupSearchDataByGroup:X,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:m.collapsedProjects,collapsedGroups:m.collapsedGroups,collapsedFolders:u,collapsedActivities:W,expandedParents:Pe,visibleCountByContainer:Yt,pinnedSessionIds:g.pinnedSessionIds,sessionOrderIndex:D,groupStatusByKey:Lt,folderAuthorityByOwner:St,activeProjectId:e.activeProjectId,singleProjectMode:R&&!_,singleProjectId:it,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:R&&!e.useGroupedSections?20:void 0,runIndex:me}),[me,re,W,te,_,Te,Z,u,g.pinnedSessionIds,Pe,St,c,X,Lt,je,ne,m.collapsedGroups,m.collapsedProjects,L,it,D,k,R,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,Yt]);l.useEffect(()=>{Me(ft.searchMatchCount)},[Me,ft.searchMatchCount]);const Vt=l.useMemo(()=>({rowModel:ft,sectionsForRender:je,projectSections:ne,singleProjectMode:R,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:ie,openSidebarMenuKey:de,setOpenSidebarMenuKey:Ae,visibleSessionCountByGroup:C,collapsedActivityKeys:W,setCollapsedActivityKeys:F,visibleActivityCountByKey:$,setVisibleActivityCountByKey:K},groupProps:Ve}),[Ve,ie,de,ne,je,ft,t.projectRepoStatus,e.emptyState,e.searchEmptyState,C,$,W,R]),et=l.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,stickyZoneHeaders:e.stickyZoneHeaders,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:q,timelineView:_}),[_,q,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder,e.stickyZoneHeaders]),It=l.useMemo(()=>({group:Qt,toggleProject:b,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,openNewWorktreeDialog:a.openNewWorktreeDialog,openWorktreesPage:a.openWorktreesPage,openProjectEditDialog:a.openProjectEditDialog,removeProject:a.removeProject,reorderProjects:a.reorderProjects,setGroupOrderByProject:x,renderProjectStatusIndicator:a.renderProjectStatusIndicator,setSingleProjectId:O}),[Qt,a.openNewSessionDraft,a.openNewWorktreeDialog,a.openProjectEditDialog,a.openWorktreesPage,a.removeProject,a.reorderProjects,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen,x,b,a.renderProjectStatusIndicator,O]);return s.jsxs(s.Fragment,{children:[s.jsx(Nk,{}),s.jsx(Bk,{projectSections:ne,activeProjectId:e.activeProjectId,initialActiveSessionByProject:n.initialActiveSessionByProject,persistActiveSessionByProject:n.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:n.openNewSessionDraft,setSessionSwitcherOpen:n.setSessionSwitcherOpen,sessionOwnerBySessionId:N.bySessionId,handleSessionSelect:ze}),s.jsx(c2,{sortedSessions:g.orderedSessions,recentSessions:U,prefetchSession:Ue}),s.jsxs(C2,{entries:ft.selectionEntries,descendantIds:ft.selectionDescendantIds,sessionsById:ft.sessionById,children:[s.jsx(v3,{getFolderScopesForProject:_e,isInlineEditing:ie!==null,startFolderRename:be}),s.jsx(l3,{model:Vt,view:et,actions:It})]})]})},G3=t=>{const e=He.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(H3,{...t}):null,e[0]=t,e[1]=n):n=e[1],n},Op=(t,e,n)=>{const r=new Set;for(const o of t){const i=at(o.path);i&&r.add(i)}if(n?.includeWorktrees===!1)return r;for(const o of e.values())for(const i of o){const d=at(i.path);d&&r.add(d)}return r},zd="oc.sessions.activeSessionByProject",q3=[],Y3=xl(qn(),qn().min(1).catch("")),Q3=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:o=!1,showOnlyMainWorkspace:i=!1})=>{na("react.session_sidebar_render"),Hs("ui.session_sidebar.render"),Hs(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Hs(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:d}=vt(),[a,c]=l.useState(!1),[u,f]=l.useState(""),p=l.useCallback(()=>{f(""),c(!1)},[]),[m,y]=l.useState(0),x=l.useRef(null),w=l.useRef(null),[b,g]=l.useState(null),h=l.useMemo(()=>Xo(),[]),[v,S]=l.useState(new Map),j=Ce(Ee=>Ee.isNewWorktreeDialogOpen),N=Ce(Ee=>Ee.setNewWorktreeDialogOpen),[C,B]=l.useState(!1),W=l.useMemo(()=>{try{const Ee=h.getItem(zd);if(!Ee)return new Map;const Pt=Y3.safeParse(JSON.parse(Ee));if(!Pt.success)return new Map;const Lt=new Map;return Object.entries(Pt.data).forEach(([os,it])=>{it&&Lt.set(os,it)}),Lt}catch{return new Map}},[h]),F=l.useCallback(Ee=>{try{h.setItem(zd,JSON.stringify(Object.fromEntries(Ee.entries())))}catch{}},[h]),[$,K]=l.useState(new Map),I=Fs(Ee=>Ee.homeDirectory),z=as(Ee=>Ee.projects),k=as(Ee=>Ee.activeProjectId),M=as(Ee=>Ee.removeProject),V=as(Ee=>Ee.setActiveProjectIdOnly),O=as(Ee=>Ee.updateProjectMeta),E=as(Ee=>Ee.reorderProjects),R=Ce(Ee=>Ee.setSettingsDialogOpen),_=Ce(Ee=>Ee.toggleHelpDialog),U=Ce(Ee=>Ee.setAboutDialogOpen),me=Ce(Ee=>Ee.setSessionSwitcherOpen),ce=Ce(Ee=>Ee.setScheduledTasksDialogOpen),oe=Ce(Ee=>Ee.setArchivePageOpen),ie=Ce(Ee=>Ee.setUsageStatsPageOpen),xe=Ce(Ee=>Ee.setWorktreesPageProjectId),G=Ce(Ee=>Ee.notifyOnSubtasks),pe=l.useMemo(()=>u.trim().toLowerCase(),[u]),J=pe.length>0;Y0({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:c,sessionSearchInputRef:w,sessionSearchContainerRef:x});const ge=of(t),de=l.useMemo(()=>cn(),[]),Ae=Je(Ee=>Ee.worktreeMetadata),he=Je(Ee=>Ee.availableWorktreesByProject),Re=Je(Ee=>Ee.openNewSessionDraft),se=l.useMemo(()=>Op(z,he,{includeWorktrees:!de}),[he,de,z]),Ne=l.useCallback(Ee=>{Ce.getState().closeMainSurfaces(),Re(Ee),de&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[de,Re]),be=Qr(Or(Ee=>({checkForUpdates:Ee.checkForUpdates,available:Ee.available,runtimeType:Ee.runtimeType,info:Ee.info,downloading:Ee.downloading,downloaded:Ee.downloaded,installing:Ee.installing,progress:Ee.progress,error:Ee.error,downloadUpdate:Ee.downloadUpdate,restartToUpdate:Ee.restartToUpdate}))),we=ss(),ye=l.useMemo(()=>`${we}|${z.map(Ee=>`${Ee.id}:${at(Ee.path)??""}`).join("|")}`,[z,we]),[Pe,Oe]=l.useState(de?ye:null),[$e,ze]=l.useReducer(Ee=>Ee+1,0),Ue=!de&&Pe!==ye,[q,ue]=l.useState(new Set),A=l.useRef(q);A.current=q;const Q=js(Ee=>Ee.isConnected),le=l.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});l.useEffect(()=>{let Ee=!1;return(async()=>{const Lt=we,os=js.getState().isConnected,it=as.getState().projects;if(Je.setState({worktreeDiscoveryByProject:new Map(it.map(Ze=>[at(Ze.path)??Ze.path,"loading"]))}),it.length===0||de){Ee||(le.current={runtimeKey:null,revision:0,worktreesByProject:new Map},ue(new Set),Oe(ye));return}const Ve=Je.getState().availableWorktreesByProject,Qt=Pl({rawWorktreesByProjectRef:le,publishedWorktreesByProject:Ve,runtimeKey:Lt}),St=Qt.revision,Yt=new Map(Qt.worktreesByProject),ft=new Set,Vt=3;let et=0;const It=Array.from({length:Vt},async()=>{for(;;){const Ze=et;if(et+=1,Ze>=it.length)return;const Mt=it[Ze],$t=at(Mt.path);if($t)try{const Gt=await Jo(async()=>mr.getState().directories.get($t)?.isGitRepo??await Au($t)?yc({id:Mt.id,path:$t}):null);if(Gt===null){Yt.delete($t);continue}if(Ee)return;Gt.length===0?Yt.delete($t):Yt.set($t,Gt)}catch{ft.add($t)}}});if(await Promise.all(It),Ee||ss()!==Lt)return;const ke=new Set(it.map(Ze=>at(Ze.path)).filter(Boolean));for(const Ze of Yt.keys())ke.has(Ze)||Yt.delete(Ze);z2({rawWorktreesByProjectRef:le,runtimeKey:Lt,capturedRevision:St,nextRawWorktreesByProject:Yt,publishedWorktreesByProject:Ve,partitionWorktreesByRegisteredProject:xc,projects:it,worktreeMapsEqual:bc,recordWorktreesSeen:Ld,publishTopology:Ze=>{Je.setState(Ze)},requestRediscovery:()=>{ze()},now:()=>Date.now()})&&(ue(ft),Je.setState({worktreeDiscoveryByProject:new Map(it.map(Ze=>{const Mt=at(Ze.path)??Ze.path;return[Mt,ft.has(Mt)?"error":"ready"]}))}),Oe(ye),ft.size>0&&!os&&js.getState().isConnected&&ze())})(),()=>{Ee=!0}},[de,ye,we,$e]),l.useEffect(()=>{Q&&A.current.size>0&&ze()},[Q]);const Ie=l.useMemo(()=>En(),[]),{isTablet:re}=Yn(),H=e||re,ne=l.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:d("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:d("sessions.sidebar.empty.noSessions.description")})]}),[d]),X=l.useMemo(()=>z.find(Ee=>Ee.id===b)??null,[z,b]),fe=l.useCallback(Ee=>{b&&O(b,{label:Ee.label,icon:Ee.icon,color:Ee.color,iconBackground:Ee.iconBackground,defaultAgent:Ee.defaultAgent??null,defaultModel:Ee.defaultModel??null,defaultVariant:Ee.defaultVariant??null})},[b,O]),Fe=l.useCallback(()=>{N(!0)},[N]),Me=l.useCallback(()=>{const Ee=Qr.getState();if(Ee.available&&Ee.info){B(!0);return}be.checkForUpdates().then(()=>{const{available:Pt,error:Lt}=Qr.getState();if(Lt){Be.error(d("sessions.sidebar.updateCheck.errorTitle"),{description:Lt});return}if(!Pt){Be.success(d("sessions.sidebar.updateCheck.latestVersion"));return}B(!0)})},[d,be]),tt=l.useCallback(()=>{e&&me(!1),R(!0)},[e,me,R]),nt=be.available&&(be.runtimeType==="desktop"||be.runtimeType==="web"),Qe=l.useCallback(()=>{Rn.requestDirectoryDialog()},[]),_e=l.useMemo(()=>z.flatMap(Ee=>{const Pt=at(Ee.path);return Pt?[{id:Ee.id,path:Ee.path,label:Ee.label,normalizedPath:Pt,icon:Ee.icon??void 0,color:Ee.color??void 0,iconImage:Ee.iconImage??void 0,iconBackground:Ee.iconBackground??void 0,addedAt:Ee.addedAt,lastOpenedAt:Ee.lastOpenedAt,sidebarCollapsed:Ee.sidebarCollapsed}]:[]}),[z]),wt=l.useMemo(()=>_e.map(Ee=>Ee.normalizedPath),[_e]),ct=Sx(t?wt:q3);nk({enabled:t,normalizedProjects:_e,gitRepoStatus:ct,setProjectRepoStatus:S,setProjectRootBranches:K});const gt=Je(Ee=>Ee.isLoading),Kt=l.useRef(!1);k&&v.has(k)&&(Kt.current=!!v.get(k));const kt=Ds(Ee=>Ee.showArchivedSessions),Ht=Ds(Ee=>Ee.projectSortOrder),At=Ds(Ee=>Ee.sidebarViewMode),Et=as(Ee=>Ee.manualProjectOrder),Bt={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:o,showOnlyMainWorkspace:i,t:d,isTablet:re,projects:z,activeProjectId:k,manualProjectOrder:Et,worktreeMetadata:Ae,availableWorktreesByProject:he,gitBranches:ge,gitRepoStatus:ct,updateStore:be,showArchivedSessions:kt,projectSortOrder:Ht,projectRepoStatus:v,projectRootBranches:$,resolvedWorktreeTopologyKey:Pe,unresolvedWorktreeProjectPaths:q,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:b,updateDialogOpen:C},Rt=l.useRef(null),Wt=Rt.current;if(Wt){let Ee=!1;for(const Pt of Object.keys(Bt))Object.is(Wt[Pt],Bt[Pt])||(Hs(`ui.session_sidebar.source.${Pt}`),Ee=!0);Ee||Hs("ui.session_sidebar.source.parent_or_context")}Rt.current=Bt;const D=l.useMemo(()=>Th(_e,Ht,Et),[_e,Ht,Et]),je=Z0({isVSCode:de,projects:D}),L=l.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:d("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:d("sessions.sidebar.empty.noMatches.description")})]}),[d]),te=de&&kt,ve=!de,P=de?"projects":At,Z=P==="projects",We=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-ring 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-ring disabled:cursor-not-allowed",Ge="h-4.5 w-4.5",zt=l.useMemo(()=>({projects:z,getCurrentProjects:()=>as.getState().projects,rawWorktreesByProjectRef:le,getPublishedWorktreesByProject:()=>Je.getState().availableWorktreesByProject,resolveProject:Ee=>aa(Ee),listProjectWorktrees:yc,partitionWorktreesByRegisteredProject:xc,worktreeMapsEqual:bc,recordWorktreesSeen:Ld,publishTopology:Ee=>{Je.setState(Ee)},getRuntimeKey:ss,now:()=>Date.now()}),[z]),Ye=l.useCallback(Ee=>{const Pt=Dp(Ee,{projects:z,resolveProject:aa});return W2(Ee,{...zt,projectRootBranch:Pt?$.get(Pt.id)??null:null})},[$,z,zt]);return l.useEffect(()=>{if(!de)return Qn(Ee=>{if(Ee.type==="session-created"){ze();return}if(Ee.type==="worktree-changed")for(const Pt of jx(Ee.directories)){const Lt=at(Pt.path),os=ss(),it=Ve=>{!Lt||ss()!==os||Je.setState(Qt=>({worktreeDiscoveryByProject:new Map(Qt.worktreeDiscoveryByProject).set(Lt,Ve)}))};it("loading"),Pp(Pt,null,zt).then(()=>{!Lt||ss()!==os||(it("ready"),ue(Ve=>{if(!Ve.has(Lt))return Ve;const Qt=new Set(Ve);return Qt.delete(Lt),Qt}))}).catch(()=>{!Lt||ss()!==os||(it("error"),ue(Ve=>new Set(Ve).add(Lt)))})}})},[de,zt]),s.jsx(pi,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:x,className:Se("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[s.jsx(ck,{hideDirectoryControls:o,showProjectDisplayControls:!de,showRecentControls:!de,handleOpenDirectoryDialog:Qe,onOpenScheduled:()=>{e&&me(!1),ce(!0)},onOpenArchive:()=>{e&&me(!1),oe(!0)},headerActionIconClass:Ge,headerActionButtonClass:We,isSessionSearchOpen:a,setIsSessionSearchOpen:c,sessionSearchInputRef:w,sessionSearchQuery:u,setSessionSearchQuery:f,hasSessionSearchQuery:J,searchMatchCount:m,collapseAllProjects:je.actions.collapseAllProjects,expandAllProjects:je.actions.expandAllProjects}),s.jsx(G3,{topology:{projects:D,availableWorktreesByProject:he,knownDirectories:se,isVSCode:de,worktreeMetadata:Ae,gitBranches:ge,projectRepoStatus:v,projectRootBranches:$,lastRepoStatus:Kt.current},view:{isVisible:t,hasSessionSearchQuery:J,normalizedSessionSearchQuery:pe,activeProjectId:k,showInlineArchived:te,useGroupedSections:ve,homeDirectory:I,mobileVariant:e,hideDirectoryControls:o,showOnlyMainWorkspace:i,isDesktopShellRuntime:Ie,stickyZoneHeaders:Z,projectSortOrder:Ht,sidebarViewMode:P,emptyState:ne,searchEmptyState:L,isSessionsLoading:gt,isWorktreeTopologyLoading:Ue,unresolvedWorktreeProjectPaths:q,projectView:je.state,onSearchMatchCountChange:y},actions:{rowActions:{allowReselect:r,onSessionSelected:n,resetSessionSearch:p},alwaysShowActions:H,notifyOnSubtasks:G,setActiveProjectIdOnly:V,setSessionSwitcherOpen:me,openNewSessionDraft:Ne,openNewWorktreeDialog:Fe,openWorktreesPage:Ee=>{e&&me(!1),xe(Ee)},openProjectEditDialog:g,removeProject:M,reorderProjects:E,startSessionWorktreeMenuLoad:Ye,initialActiveSessionByProject:W,persistActiveSessionByProject:F,projectViewActions:je.actions}}),s.jsx(kk,{onOpenSettings:tt,onOpenUsage:()=>ie(!Ce.getState().isUsageStatsPageOpen),onOpenShortcuts:_,onOpenAbout:()=>U(!0),onOpenUpdate:Me,showRuntimeButtons:!de,showUpdateButton:nt}),s.jsx(pu,{open:C,onOpenChange:B,info:be.info,downloading:be.downloading,downloaded:be.downloaded,installing:be.installing,progress:be.progress,error:be.error,onDownload:be.downloadUpdate,onRestart:be.restartToUpdate,runtimeType:be.runtimeType}),s.jsx(lk,{open:!!X,onOpenChange:Ee=>{Ee||g(null)},project:X,onSave:fe}),s.jsx(kx,{open:j,onOpenChange:N,onWorktreeCreated:Ee=>{Ce.getState().closeMainSurfaces(),e&&me(!1),Re({directoryOverride:Ee,preserveDirectoryOverride:!0})}})]})})},X3=l.memo(Q3),Nn=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,ln=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},J3=()=>{const{t}=vt(),{git:e,sourceControl:n}=jn(),[r,o]=l.useState(!1),[i,d]=l.useState(!1),[a,c]=l.useState(null),[u,f]=l.useState([]),[p,m]=l.useState(!1),[y,x]=l.useState(!1),[w,b]=l.useState(!1),[g,h]=l.useState(!1),[v,S]=l.useState(new Set),j=Je(q=>q.getWorktreeMetadata),N=Je(q=>q.newSessionDraft),C=Je(q=>q.setNewSessionDraftTarget),B=Je(q=>q.setDraftBootstrapPendingDirectory),W=Cx,F=Ax,$=Je(q=>q.deleteSessions),K=Je(q=>q.archiveSessions),I=Ce(q=>q.showDeletionDialog),z=Ce(q=>q.setShowDeletionDialog),k=Fs(q=>q.currentDirectory),M=Fs(q=>q.homeDirectory),V=Fs(q=>q.isHomeReady),O=as(q=>q.projects),E=as(q=>q.activeProjectId),{isMobile:R,isTablet:_,hasTouchInput:U}=Yn(),me=R||_||U,ce=l.useMemo(()=>{const ue=(E?O.find(A=>A.id===E)??null:null)?.path??k;return ln(ue)},[E,k,O]),oe=l.useCallback(q=>{const A=ln(q.projectDirectory)||ce;return{id:(O.find(le=>ln(le.path)===A)??null)?.id??`path:${A}`,path:A}},[ce,O]),ie=g&&v.size>0,xe=l.useMemo(()=>{const q=a?.worktree;return q&&typeof q.branch=="string"&&q.branch.trim().length>0?!!q.status?.upstream?.split("/")[0]?.trim():u.length>0&&u.every(({metadata:ue})=>typeof ue.branch=="string"&&ue.branch.trim().length>0&&!!ue.status?.upstream?.split("/")[0]?.trim())},[a?.worktree,u]),G=a?.mode==="worktree",pe=w||!G||!xe,J=w||!G;l.useEffect(()=>{i||!V||O.length>0||(d(!0),o(!0))},[i,V,O.length]);const ge=l.useCallback(q=>{c({sessions:q.sessions,dateLabel:q.dateLabel,mode:q.mode??"session",worktree:q.worktree??null})},[]),de=l.useCallback(()=>{c(null),f([]),m(!1),x(!1),b(!1),h(!1),S(new Set)},[]),Ae=l.useCallback(async q=>{if(q.sessions.length===0)return;if(q.sessions.length===1){const le=q.sessions[0];await W(le.id)?Be.success(t("sessions.sidebar.session.delete.success")):Be.error(t("sessions.sidebar.session.delete.error"));return}const ue=q.sessions.map(le=>le.id),{deletedIds:A,failedIds:Q}=await $(ue);if(A.length>0){const le=Q.length>0?Q.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Q.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Q.length}):q.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:q.dateLabel}):void 0;Be.success(A.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:A.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:A.length}),{description:Nn(le)})}Q.length>0&&Be.error(Q.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Q.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Q.length}),{description:Nn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[W,$,t]);l.useEffect(()=>Rn.onDirectoryRequest(()=>{o(!0)}),[]),l.useEffect(()=>{if(!a){f([]),m(!1),x(!1),h(!1),S(new Set);return}const q=a.sessions.map(Q=>{const le=j(Q.id);return le?{session:Q,metadata:le}:null}).filter(Q=>!!Q);f(q),m(!1),h(!1),S(new Set);const ue=new Map;if(a.worktree?.path&&ue.set(ln(a.worktree.path),a.worktree),q.forEach(({metadata:Q})=>{Q.path&&ue.set(ln(Q.path),Q)}),ue.size===0){h(!0);return}let A=!1;return(async()=>{const Q=new Map,le=new Set;await Promise.all(Array.from(ue.entries()).map(async([Ie,re])=>{try{const H=await vc(re.path);Q.set(Ie,H),H?.isDirty&&le.add(Ie)}catch{re.status&&(Q.set(Ie,re.status),re.status.isDirty&&le.add(Ie))}})).catch(Ie=>{console.warn("Failed to inspect worktree status before deletion:",Ie)}),!A&&(S(le),h(!0),c(Ie=>{if(!Ie?.worktree?.path)return Ie;const re=ln(Ie.worktree.path),H=Q.get(re);if(!H)return Ie;const ne=Ie.worktree.status;return ne?.isDirty===H.isDirty&&ne?.ahead===H.ahead&&ne?.behind===H.behind&&ne?.upstream===H.upstream?Ie:{...Ie,worktree:{...Ie.worktree,status:H}}}),f(Ie=>Ie.map(re=>{const H=ln(re.metadata.path),ne=Q.get(H);return ne?{session:re.session,metadata:{...re.metadata,status:ne}}:re})))})(),()=>{A=!0}},[a,j]),l.useEffect(()=>{xe||m(!1)},[xe]);const he=l.useCallback(async(q,ue,A)=>{const Q=p&&xe,le=oe(q),Ie=ln(q.path),re=ln(le.path);try{await Pu(le,q,{deleteRemoteBranch:Q,deleteLocalBranch:ue,remoteName:q.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:n}});const H=ln(N?.directoryOverride);return N?.open&&Ie&&H===Ie&&re&&(B(null),C({projectId:le.id,directoryOverride:re},{force:!0})),ln(k)===Ie&&re&&Fs.getState().setDirectory(re,{showOverlay:!1}),!0}catch(H){return Be.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:Li(q)}),{id:A,description:Nn(H instanceof Error?H.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[xe,k,p,oe,e,N?.directoryOverride,N?.open,B,C,n,t]),Re=l.useCallback((q,ue,A)=>{const Q=p&&xe,le=Be.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Li(q)}));return Nx(q.path),(async()=>{try{const Ie=await Oh({sessionIds:ue,removeWorktree:()=>he(q,A,le),archiveSessions:async ne=>ne.length===1?await F(ne[0])?{archivedIds:ne,failedIds:[]}:{archivedIds:[],failedIds:ne}:K(ne)});if(!Ie.removed)return;const re=t(Q?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Be.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:Li(q)}),{id:le,description:Nn(re)});const{failedIds:H}=Ie.archive;H.length>0&&Be.error(H.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:H.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:H.length}),{description:Nn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(Ie){Be.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:le,description:Nn(Ie instanceof Error?Ie.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{Px(q.path)}})()},[F,K,xe,p,he,t]),se=l.useRef(new Set),Ne=l.useCallback(async(q,ue)=>{const A=ln(q.path);if(!se.current.has(A)){se.current.add(A);try{const Q=await vc(q.path).catch(()=>{});if(!Ix(Q)){ge({sessions:ue,mode:"worktree",worktree:q});return}await Re(q,ue.map(le=>le.id),!0)}finally{se.current.delete(A)}}},[ge,Re]);l.useEffect(()=>Rn.onDeleteRequest(q=>{if(!I&&(q.mode??"session")==="session"){Ae(q);return}if(q.mode==="worktree"&&q.skipDialogIfSafe&&q.worktree){Ne(q.worktree,q.sessions);return}ge(q)}),[ge,I,Ae,Ne]);const be=l.useCallback(async()=>{if(a){b(!0);try{if(G){const q=a.worktree??u[0]?.metadata;if(!q){Be.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Nn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),b(!1);return}Re(q,a.sessions.map(ue=>ue.id),y),de();return}if(a.sessions.length===1){const q=a.sessions[0];if(!await W(q.id)){Be.error(t("sessions.sidebar.session.delete.error")),b(!1);return}Be.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const q=a.sessions.map(Q=>Q.id),{deletedIds:ue,failedIds:A}=await $(q);if(ue.length>0){const Q=A.length>0?A.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:A.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:A.length}):a.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:a.dateLabel}):void 0;Be.success(ue.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ue.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ue.length}),{description:Nn(Q),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(A.length>0&&(Be.error(A.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:A.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:A.length}),{description:Nn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ue.length===0)){b(!1);return}}de()}finally{b(!1)}}},[a,u,y,W,$,de,G,Re,t]),we=a?.worktree??u[0]?.metadata??null;let ye="";if(a?.mode==="worktree"){const q=a.sessions.length;q===0?ye=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):q===1?ye=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:q}):ye=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:q})}else if(a){const q=a.sessions.length;q===1?ye=a.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:a.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):ye=a.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:q,dateLabel:a.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:q})}const Pe=a?s.jsxs("div",{className:Se(G?"space-y-3":"space-y-2"),children:[a.sessions.length>0&&s.jsxs("div",{className:Se(G?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[G&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:a.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:a.sessions.length})]}),s.jsxs("ul",{className:Se(G?"mt-2 space-y-1":"space-y-0.5"),children:[a.sessions.slice(0,5).map(q=>s.jsxs("li",{className:Se(G?"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:Se(!G&&"hidden"),children:"•"}),s.jsx("span",{dir:"auto",className:"truncate",children:q.title||t("sessions.sidebar.session.untitled")})]},q.id)),a.sessions.length>5&&s.jsx("li",{className:Se(G?"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:a.sessions.length-5})})]})]}),G?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(T,{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")}),we?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:we.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:we?ro(we.path,M):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),ie&&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,Oe=G?xe?s.jsxs("button",{type:"button",onClick:()=>{pe||m(q=>!q)},disabled:pe,"aria-pressed":p,className:Se("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",pe?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?s.jsx(T,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(T,{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,$e=G?s.jsxs("button",{type:"button",onClick:()=>{J||x(q=>!q)},disabled:J,"aria-pressed":y,className:Se("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",J?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[y?s.jsx(T,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(T,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,ze=G?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:[$e,Oe]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ut,{variant:"ghost",onClick:de,disabled:w,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",onClick:be,disabled:w,children:t(w?"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:()=>z(!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-ring","aria-pressed":!I,children:[I?s.jsx(T,{name:"checkbox-blank",className:"size-4"}):s.jsx(T,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ut,{variant:"ghost",onClick:de,disabled:w,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",onClick:be,disabled:w,children:w?t("sessions.sidebar.sessionDialogs.actions.deleting"):a?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),Ue=G?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):a?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[me?s.jsx(Hu,{open:!!a,onClose:()=>{w||de()},title:Ue,footer:s.jsx("div",{className:"flex justify-end gap-2",children:ze}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[ye&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:ye}),Pe]})}):s.jsx(en,{open:!!a,onOpenChange:q=>{if(!q){if(w)return;de()}},children:s.jsxs(tn,{className:Se(G?"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(pn,{children:[s.jsxs(mn,{className:Se(G&&"flex items-center gap-2"),children:[G&&s.jsx(T,{name:"delete-bin",className:"h-5 w-5"}),Ue]}),ye&&s.jsx(hn,{children:ye})]}),s.jsx("div",{className:Se(G&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:Pe}),s.jsx(pr,{className:"mt-2 gap-2 pt-1 pb-1",children:ze})]})}),s.jsx(Bh,{open:r,onOpenChange:o})]})};function Z3(){const t=He.c(18),{t:e}=vt(),n=Ce(s4),r=Ce(t4),o=as(e4);let i;t[0]!==n?(i=y=>y.projects.find(x=>x.id===n)??null,t[0]=n,t[1]=i):i=t[1];const d=as(i);if(!n||!d)return null;let a;t[2]!==d.id||t[3]!==o||t[4]!==r?(a=()=>{o(d.id),r(!0)},t[2]=d.id,t[3]=o,t[4]=r,t[5]=a):a=t[5];let c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(T,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=c):c=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let f;t[9]!==a||t[10]!==u?(f=s.jsx("div",{className:"flex items-center",children:s.jsxs(ut,{size:"sm",onClick:a,children:[c,u]})}),t[9]=a,t[10]=u,t[11]=f):f=t[11];let p;t[12]!==d.id||t[13]!==d.path?(p=s.jsx(Fh,{projectRef:{id:d.id,path:d.path},sections:"list-only"}),t[12]=d.id,t[13]=d.path,t[14]=p):p=t[14];let m;return t[15]!==f||t[16]!==p?(m=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:[f,p]})})}),t[15]=f,t[16]=p,t[17]=m):m=t[17],m}function e4(t){return t.setActiveProjectIdOnly}function t4(t){return t.setNewWorktreeDialogOpen}function s4(t){return t.worktreesPageProjectId}function n4(){const t=He.c(52),{t:e}=vt(),n=Ce(o4);let r;t[0]!==n?(r=B=>B.projects.find(W=>W.id===n)??null,t[0]=n,t[1]=r):r=t[1];const o=as(r),{journey:i,error:d}=Om(),[a,c]=l.useState(!1);if(!o)return null;let u,f,p,m,y,x,w,b,g,h;if(t[2]!==d||t[3]!==i||t[4]!==o||t[5]!==e){const B=i?Bm(i,o.path):[];h="absolute inset-0 z-10 flex flex-col bg-background",g="flex-1 overflow-y-auto px-6 py-4",w="mx-auto w-full max-w-4xl space-y-4";let W,F;t[16]===Symbol.for("react.memo_cache_sentinel")?(W=()=>c(!0),F=s.jsx(T,{name:"box-3",className:"mr-1 h-3.5 w-3.5"}),t[16]=W,t[17]=F):(W=t[16],F=t[17]);let $;t[18]!==e?($=e("spaces.page.new"),t[18]=e,t[19]=$):$=t[19],t[20]!==$?(b=s.jsx("div",{className:"flex items-center",children:s.jsxs(ut,{size:"sm",onClick:W,children:[F,$]})}),t[20]=$,t[21]=b):b=t[21],u=Mx,t[22]!==e?(f=e("spaces.page.listTitle"),t[22]=e,t[23]=f):f=t[23],t[24]!==d||t[25]!==e?(p=d?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("spaces.page.loadFailed",{reason:Dx(e,Ex(d))})}):null,t[24]=d,t[25]=e,t[26]=p):p=t[26],t[27]!==d||t[28]!==i||t[29]!==e?(m=i===null&&!d?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("spaces.page.loading")}):null,t[27]=d,t[28]=i,t[29]=e,t[30]=m):m=t[30],y=i!==null&&!d&&B.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:e("spaces.page.empty")}):null,x=B.length>0?s.jsx("div",{className:"space-y-1",children:B.map(r4)}):null,t[2]=d,t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=f,t[8]=p,t[9]=m,t[10]=y,t[11]=x,t[12]=w,t[13]=b,t[14]=g,t[15]=h}else u=t[6],f=t[7],p=t[8],m=t[9],y=t[10],x=t[11],w=t[12],b=t[13],g=t[14],h=t[15];let v;t[31]!==u||t[32]!==f||t[33]!==p||t[34]!==m||t[35]!==y||t[36]!==x?(v=s.jsxs(u,{title:f,children:[p,m,y,x]}),t[31]=u,t[32]=f,t[33]=p,t[34]=m,t[35]=y,t[36]=x,t[37]=v):v=t[37];let S;t[38]!==v||t[39]!==w||t[40]!==b?(S=s.jsxs("div",{className:w,children:[b,v]}),t[38]=v,t[39]=w,t[40]=b,t[41]=S):S=t[41];let j;t[42]!==S||t[43]!==g?(j=s.jsx("div",{className:g,children:S}),t[42]=S,t[43]=g,t[44]=j):j=t[44];let N;t[45]!==a||t[46]!==o?(N=a?s.jsx(Rx,{open:!0,onOpenChange:B=>{B||c(!1)},project:{id:o.id,path:o.path}}):null,t[45]=a,t[46]=o,t[47]=N):N=t[47];let C;return t[48]!==j||t[49]!==N||t[50]!==h?(C=s.jsxs("div",{className:h,children:[j,N]}),t[48]=j,t[49]=N,t[50]=h,t[51]=C):C=t[51],C}function r4(t){return s.jsx(Lh,{entry:t,actions:"menu"},t.id)}function o4(t){return t.spacesPageProjectId}function i4(t,e,n){const[r,o]=l.useState(null),i=l.useRef(n);return i.current=n,l.useEffect(()=>{if(!t||r)return;let d=!1;return Tx(e).then(a=>{d||o(()=>a)},a=>{console.error("[on-demand] failed to load component",a),d||i.current()}),()=>{d=!0}},[r,e,t]),r}function a4(t){const e=[],n=(r,o)=>{const i=at(r);!i||e.some(d=>d.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const l4=new Map,c4=t=>{const e=He.c(23),{isVSCode:n}=t,r=mi(),o=as(d4),i=Fs(u4),d=Je(f4);let a;e[0]!==n?(a=W=>n?l4:W.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const c=Je(a),u=!n;let f;e[2]!==c||e[3]!==o||e[4]!==u?(f=Op(o,c,{includeWorktrees:u}),e[2]=c,e[3]=o,e[4]=u,e[5]=f):f=e[5];const p=f,m=Ls(p4),y=Ls(m4),x=Ls(h4),w=`session-list-sync:${l.useId()}`;let b,g;e[6]!==w||e[7]!==r||e[8]!==i||e[9]!==d?(b=()=>(r.setBootstrapDemand(w,a4({currentDirectory:i,currentSessionDirectory:d})),()=>r.clearBootstrapDemand(w)),g=[w,r,i,d],e[6]=w,e[7]=r,e[8]=i,e[9]=d,e[10]=b,e[11]=g):(b=e[10],g=e[11]),l.useEffect(b,g);const h=l.useRef(null);let v,S;e[12]!==n||e[13]!==p?(v=()=>{const W=new Set(p),F=h.current;h.current=W;const $=F?[...W].filter(K=>!F.has(K)):n?[...W]:[];$.length&&Qa($,ti())},S=[n,p],e[12]=n,e[13]=p,e[14]=v,e[15]=S):(v=e[14],S=e[15]),l.useEffect(v,S);let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[16]=j):j=e[16],l.useEffect(g4,j);let N;e[17]!==y||e[18]!==m?(N=[...m,...y],e[17]=y,e[18]=m,e[19]=N):N=e[19];const C=N;let B;e[20]!==C||e[21]!==x?(B={enabled:!0,hasAuthoritativeGlobalSessions:x,sessions:C},e[20]=C,e[21]=x,e[22]=B):B=e[22],$h(B)};function d4(t){return t.projects}function u4(t){return t.currentDirectory}function f4(t){return t.currentSessionDirectory}function p4(t){return t.activeSessions}function m4(t){return t.archivedSessions}function h4(t){return t.status==="ready"}function g4(){let t=null,e=!1;const n=new Set,r=Qn(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")n.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),ml(ti());return}const i=[...n];n.clear(),i.length&&Qa(i,ti())},500)});return()=>{t&&clearTimeout(t),r()}}const b4=()=>Sn(()=>import("./SettingsWindow-CM5fL8Ot.js"),__vite__mapDeps([145,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,146,82,83,84,85,147,131,132,133,134,120,121,105,106,90,91,92,93,94,95,96,97,98,99,100,101,102,103,148,149,150])).then(t=>t.SettingsWindow),x4=()=>{const t=He.c(74);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],c4(e),_h();const n=Ce(y4),r=Ce(v4),o=Ce(w4),i=Ce(S4),d=Ce(j4);let a;t[1]!==d?(a=()=>d(!1),t[1]=d,t[2]=a):a=t[2];const c=i4(i,b4,a),u=Ce(k4),f=Ce(C4),p=Ce(N4),m=Ce(A4),y=Ce(P4),x=Ce(I4),w=Ce(D4),b=af();let g;if(t[3]!==b||t[4]!==w){let $e;t[6]!==w?($e=ze=>ze.id===w,t[6]=w,t[7]=$e):$e=t[7],g=b.find($e),t[3]=b,t[4]=w,t[5]=g}else g=t[5];const h=g;let v,S;t[8]!==h||t[9]!==w?(v=()=>{w&&!h&&Ce.getState().setOpenGuestPage(null)},S=[w,h],t[8]=h,t[9]=w,t[10]=v,t[11]=S):(v=t[10],S=t[11]),l.useEffect(v,S);let j;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=[],t[12]=j):j=t[12],l.useEffect(R4,j);const N=f||p||m||!!y||x||u||!!h;let C;t[13]===Symbol.for("react.memo_cache_sentinel")?(C=[],t[13]=C):C=t[13],l.useEffect(T4,C);const{isMobile:B}=Yn();Kh();let W,F;t[14]!==B||t[15]!==o?(W=()=>{Ce.getState().isMobile!==B&&o(B)},F=[B,o],t[14]=B,t[15]=o,t[16]=W,t[17]=F):(W=t[16],F=t[17]),l.useEffect(W,F);let $,K,I,z,k;t[18]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(_0,{}),$=s.jsx(K0,{}),K=s.jsx(U0,{}),I=s.jsx(Wh,{}),z=s.jsx(J3,{}),t[18]=$,t[19]=K,t[20]=I,t[21]=z,t[22]=k):($=t[18],K=t[19],I=t[20],z=t[21],k=t[22]);let M;t[23]!==r?(M=r?s.jsxs(s.Fragment,{children:[s.jsx(zh,{}),s.jsx(Vh,{}),s.jsx(Uh,{}),s.jsx(Hh,{}),s.jsx(Gh,{})]}):null,t[23]=r,t[24]=M):M=t[24];let V;t[25]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(iw,{}),t[25]=V):V=t[25];let O;t[26]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(ow,{}),t[26]=O):O=t[26];let E;t[27]!==n?(E=s.jsx(X3,{isVisible:n}),t[27]=n,t[28]=E):E=t[28];let R;t[29]!==B||t[30]!==n||t[31]!==E?(R=s.jsx(rw,{isOpen:n,isMobile:B,className:"border-border",topBar:O,children:E}),t[29]=B,t[30]=n,t[31]=E,t[32]=R):R=t[32];let _;t[33]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(sw,{}),t[33]=_):_=t[33];const U=N&&"invisible";let me;t[34]!==U?(me=Se("absolute inset-0",U),t[34]=U,t[35]=me):me=t[35];const ce=!i&&!N;let oe;t[36]!==ce?(oe=s.jsx(zs,{children:s.jsx(hu,{active:ce})}),t[36]=ce,t[37]=oe):oe=t[37];let ie;t[38]!==me||t[39]!==oe?(ie=s.jsx("div",{className:me,children:oe}),t[38]=me,t[39]=oe,t[40]=ie):ie=t[40];let xe;t[41]===Symbol.for("react.memo_cache_sentinel")?(xe=s.jsx(zs,{children:s.jsx(qh,{})}),t[41]=xe):xe=t[41];let G;t[42]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx(zs,{children:s.jsx(Yh,{})}),t[42]=G):G=t[42];let pe;t[43]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(zs,{children:s.jsx(Qh,{})}),t[43]=pe):pe=t[43];let J;t[44]!==m?(J=m&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(zs,{children:s.jsx(Xh,{})})}),t[44]=m,t[45]=J):J=t[45];let ge;t[46]===Symbol.for("react.memo_cache_sentinel")?(ge=s.jsx(zs,{children:s.jsx(Z3,{})}),t[46]=ge):ge=t[46];let de;t[47]!==x?(de=x?s.jsx(zs,{children:s.jsx(n4,{})}):null,t[47]=x,t[48]=de):de=t[48];let Ae;t[49]!==h?(Ae=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(zs,{children:s.jsx(Ox,{mode:`plugin:${h.id}`,surface:"page",item:null,onDismiss:O4})})}),t[49]=h,t[50]=Ae):Ae=t[50];let he;t[51]!==ie||t[52]!==J||t[53]!==de||t[54]!==Ae?(he=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[ie,xe,G,pe,J,ge,de,Ae]}),t[51]=ie,t[52]=J,t[53]=de,t[54]=Ae,t[55]=he):he=t[55];let Re;t[56]===Symbol.for("react.memo_cache_sentinel")?(Re=s.jsx(e0,{}),t[56]=Re):Re=t[56];let se;t[57]!==he?(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:[he,Re]})})}),t[57]=he,t[58]=se):se=t[58];let Ne;t[59]===Symbol.for("react.memo_cache_sentinel")?(Ne=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(zs,{children:s.jsx(d0,{})})}),t[59]=Ne):Ne=t[59];let be;t[60]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(zs,{children:s.jsx(yy,{})}),t[60]=be):be=t[60];let we;t[61]!==se?(we=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[_,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[se,Ne,be]})]}),t[61]=se,t[62]=we):we=t[62];let ye;t[63]!==R||t[64]!==we?(ye=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[R,we]}),t[63]=R,t[64]=we,t[65]=ye):ye=t[65];let Pe;t[66]!==c||t[67]!==i||t[68]!==d?(Pe=c?s.jsx(c,{open:i,onOpenChange:d}):null,t[66]=c,t[67]=i,t[68]=d,t[69]=Pe):Pe=t[69];let Oe;return t[70]!==M||t[71]!==ye||t[72]!==Pe?(Oe=s.jsx(Jh,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[k,$,K,I,z,M,V,ye,Pe]})}),t[70]=M,t[71]=ye,t[72]=Pe,t[73]=Oe):Oe=t[73],Oe};function y4(t){return t.isSidebarOpen}function v4(t){return t.isolatedSpacesEnabled}function w4(t){return t.setIsMobile}function S4(t){return t.isSettingsDialogOpen}function j4(t){return t.setSettingsDialogOpen}function k4(t){return t.runOverviewKey!==null}function C4(t){return t.isScheduledTasksDialogOpen}function N4(t){return t.isArchivePageOpen}function A4(t){return t.isUsageStatsPageOpen}function P4(t){return t.worktreesPageProjectId}function I4(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function D4(t){return t.openGuestPageId}function E4(){return Ce.getState().setOpenGuestPage(null)}function R4(){return co(E4)}function M4(){return Ce.getState().closeMainSurfaces()}function T4(){const t=M4,e=Je.subscribe((n,r)=>{const o=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,i=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function O4(){return Ce.getState().setOpenGuestPage(null)}const Bp=12,B4=[{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"}],F4=t=>{const e=He.c(18),{isActive:n,burstKey:r,className:o,durationMs:i,bursts:d,onComplete:a}=t,c=r===void 0?0:r,u=i===void 0?900:i,f=d===void 0?B4:d,p=Ms.useRef(!1);let m,y;e[0]!==n||e[1]!==a?(m=()=>{!n&&p.current&&a?.(),n&&(p.current=!0)},y=[n,a],e[0]=n,e[1]=a,e[2]=m,e[3]=y):(m=e[2],y=e[3]),Ms.useEffect(m,y);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=Array.from({length:Bp},L4),e[4]=x):x=e[4];const w=x;if(!n)return null;let b;e[5]!==o?(b=Se("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=b):b=e[6];let g;if(e[7]!==c||e[8]!==f||e[9]!==u){let v;e[11]!==c||e[12]!==u?(v=S=>{const j={"--burst-delay":`${S.delay}ms`,"--burst-x":`${S.x}%`,"--burst-y":`${S.y}%`,"--firework-color":`var(${S.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:j,children:w.map((N,C)=>{const B=N.x*S.radius,W=N.y*S.radius,F={"--translate-x":`${B}px`,"--translate-y":`${W}px`,"--particle-delay":`${N.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:F},`${S.id}-${C}-${c}`)})},`${S.id}-${c}`)},e[11]=c,e[12]=u,e[13]=v):v=e[13],g=f.map(v),e[7]=c,e[8]=f,e[9]=u,e[10]=g}else g=e[10];let h;return e[14]!==c||e[15]!==b||e[16]!==g?(h=s.jsx("div",{className:b,"aria-hidden":"true","data-burst-key":c,children:g}),e[14]=c,e[15]=b,e[16]=g,e[17]=h):h=e[17],h};function L4(t,e){const n=Math.PI*2*e/Bp;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const $4=t=>{const e=He.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,o=r===void 0?3400:r;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={isActive:!1,cycle:0},e[2]=i):i=e[2];const[d,a]=Ms.useState(i),c=Ms.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{c.current&&(window.clearTimeout(c.current),c.current=null)},e[3]=u):u=e[3];const f=u;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{f(),a(_4)},e[4]=p):p=e[4];const m=p;let y;e[5]!==o?(y=()=>{f(),a(K4),c.current=window.setTimeout(()=>{a(W4),c.current=null},o)},e[5]=o,e[6]=y):y=e[6];const x=y;let w,b;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>f(),b=[f],e[7]=w,e[8]=b):(w=e[7],b=e[8]),Ms.useEffect(w,b);let g;return e[9]!==d.cycle||e[10]!==d.isActive||e[11]!==x?(g={isActive:d.isActive,burstKey:d.cycle,triggerFireworks:x,dismissFireworks:m},e[9]=d.cycle,e[10]=d.isActive,e[11]=x,e[12]=g):g=e[12],g};function _4(t){return t.isActive?{...t,isActive:!1}:t}function K4(t){return{isActive:!0,cycle:t.cycle+1}}function W4(t){return t.isActive?{...t,isActive:!1}:t}const Fp=l.createContext(void 0),z4=t=>{const e=He.c(10),{children:n}=t,{isActive:r,burstKey:o,triggerFireworks:i,dismissFireworks:d}=$4();let a;e[0]!==d||e[1]!==i?(a={triggerFireworks:i,dismissFireworks:d},e[0]=d,e[1]=i,e[2]=a):a=e[2];const c=a;let u;e[3]!==o||e[4]!==r?(u=s.jsx(F4,{isActive:r,burstKey:o}),e[3]=o,e[4]=r,e[5]=u):u=e[5];let f;return e[6]!==n||e[7]!==u||e[8]!==c?(f=s.jsxs(Fp.Provider,{value:c,children:[n,u]}),e[6]=n,e[7]=u,e[8]=c,e[9]=f):f=e[9],f},L5=()=>{const t=l.useContext(Fp);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Va="openchamber_requests_in_flight",Lp=1e3,V4=300*1e3,ui=Math.ceil(V4/Lp),U4=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Va)==="1"}catch{return!1}},$p=()=>({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 H4=1;const G4=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},q4=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},_p=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,o)=>r-o),n},Mr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},Y4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,o)=>{const i=H4++;G4(i,Date.now());try{return await e(r,o)}finally{q4(i)}};window.fetch=n},Vd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Vr=t=>{t.length>ui&&t.splice(0,t.length-ui)},Q4=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=_p(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(Mr(e,50)),t.p90Samples.push(Mr(e,90)),t.p99Samples.push(Mr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Vr(t.samples),Vr(t.p50Samples),Vr(t.p90Samples),Vr(t.p99Samples),Vr(t.maxSamples),t.lastSampleAt=Date.now()},X4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(Q4,Lp))},Ud=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Hd=t=>{if(!(typeof window>"u"))try{if(t){Ud(),Vd(),window.localStorage.setItem(Va,"1"),window.__openchamberRequestsInFlight__=$p(),Y4(),X4();return}window.localStorage.removeItem(Va),Ud(),Vd(),delete window.__openchamberRequestsInFlight__}catch{}},J4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=$p();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},Ua=()=>{if(typeof window>"u")return Gd();const t=window.__openchamberRequestsInFlight__;if(!U4()||!t)return Gd();const e=_p(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:Mr(e,50),ageP90:Mr(e,90),ageP99:Mr(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:ui}},Gd=()=>({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:ui});function Z4(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const Kp=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`},Ha=t=>`${(t/1e3).toFixed(2)} s`,Rs=t=>{const e=He.c(8),{label:n,value:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=o):o=e[0];let i;e[1]!==n?(i=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=i):i=e[2];let d;e[3]!==r?(d=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=d):d=e[4];let a;return e[5]!==i||e[6]!==d?(a=s.jsxs("div",{className:"rounded-md p-2",style:o,children:[i,d]}),e[5]=i,e[6]=d,e[7]=a):a=e[7],a},qd=t=>{const e=He.c(43),{title:n,snapshot:r,emptyLabel:o}=t,{t:i}=vt();let d;if(e[0]!==o||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==i||e[6]!==n){const a=r.entries.slice(0,12);let c;e[8]!==r.entries?(c=r.entries.reduce(sN,0),e[8]=r.entries,e[9]=c):c=e[9];const u=c;let f;e[10]!==n?(f=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=f):f=e[11];let p;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==i?(p=r.startedAt?Kp(r.durationMs):i("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=i,e[15]=p):p=e[15];let m;e[16]!==p?(m=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:p}),e[16]=p,e[17]=m):m=e[17];let y;e[18]!==f||e[19]!==m?(y=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f,m]}),e[18]=f,e[19]=m,e[20]=y):y=e[20];let x;e[21]!==i?(x=i("memoryDebugPanel.metric.metrics"),e[21]=i,e[22]=x):x=e[22];let w;e[23]!==r.entries.length||e[24]!==x?(w=s.jsx(Rs,{label:x,value:r.entries.length}),e[23]=r.entries.length,e[24]=x,e[25]=w):w=e[25];let b;e[26]!==i?(b=i("memoryDebugPanel.metric.samples"),e[26]=i,e[27]=b):b=e[27];let g;e[28]!==b||e[29]!==u?(g=s.jsx(Rs,{label:b,value:u}),e[28]=b,e[29]=u,e[30]=g):g=e[30];let h;e[31]!==i?(h=i("memoryDebugPanel.metric.lastUpdate"),e[31]=i,e[32]=h):h=e[32];let v;e[33]!==r.lastUpdatedAt||e[34]!==i?(v=r.lastUpdatedAt?i("memoryDebugPanel.common.live"):i("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=i,e[35]=v):v=e[35];let S;e[36]!==h||e[37]!==v?(S=s.jsx(Rs,{label:h,value:v}),e[36]=h,e[37]=v,e[38]=S):S=e[38];let j;e[39]!==g||e[40]!==S||e[41]!==w?(j=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[w,g,S]}),e[39]=g,e[40]=S,e[41]=w,e[42]=j):j=e[42],d=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[y,j,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:o}):s.jsx(Mn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(N=>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:N.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:i("memoryDebugPanel.metric.countValue",{value:N.count})}),s.jsx("span",{children:i("memoryDebugPanel.metric.avgValue",{value:N.avg})}),s.jsx("span",{children:i("memoryDebugPanel.metric.maxValue",{value:N.max})}),s.jsx("span",{children:i("memoryDebugPanel.metric.totalValue",{value:N.total})})]})]},N.metric))})})]}),e[0]=o,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=i,e[6]=n,e[7]=d}else d=e[7];return d},Yd=t=>{const e=He.c(24),{series:n,peak:r,windowSeconds:o,ariaLabel:i,maxLabel:d}=t,a=o,c=n.reduce(nN,0),u=r>0?52/r:0;let f;e[0]!==c||e[1]!==a?(f=S=>a-c+S,e[0]=c,e[1]=a,e[2]=f):f=e[2];const p=f;let m;e[3]!==u?(m=S=>56-S*u,e[3]=u,e[4]=m):m=e[4];const y=m;let x;e[5]!==d?(x=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:d}),e[5]=d,e[6]=x):x=e[6];const w=`0 0 ${a} 56`;let b;e[7]!==a?(b=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]=b):b=e[8];let g;if(e[9]!==n||e[10]!==p||e[11]!==y){let S;e[13]!==p||e[14]!==y?(S=(j,N)=>{const C=j.samples.length;if(C===0)return null;const B=j.samples.map((F,$)=>`${p($)},${y(F).toFixed(2)}`),W=`M ${B.join(" L ")}`;return s.jsxs(l.Fragment,{children:[j.filled?s.jsx("path",{d:`M ${p(0)},56 L ${B.join(" L ")} L ${p(C-1)},56 Z`,fill:`color-mix(in srgb, ${j.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:W,fill:"none",stroke:j.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},N)},e[13]=p,e[14]=y,e[15]=S):S=e[15],g=n.map(S),e[9]=n,e[10]=p,e[11]=y,e[12]=g}else g=e[12];let h;e[16]!==i||e[17]!==w||e[18]!==b||e[19]!==g?(h=s.jsxs("svg",{viewBox:w,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":i,children:[b,g]}),e[16]=i,e[17]=w,e[18]=b,e[19]=g,e[20]=h):h=e[20];let v;return e[21]!==x||e[22]!==h?(v=s.jsxs("div",{className:"relative w-full",children:[x,h]}),e[21]=x,e[22]=h,e[23]=v):v=e[23],v},eN=t=>{const e=He.c(100),{onClose:n}=t,{t:r}=vt(),[o,i]=l.useState("memory"),[d,a]=l.useState("idle"),c=Je(rN),u=wf(oN),f=Ju(),p=Bx(iN),m=vs(aN),[y,x]=l.useState(lN),[w,b]=l.useState(cN),[g,h]=l.useState(dN),v=[{label:"p50",current:g.ageP50,samples:g.p50Samples,color:"var(--status-success)"},{label:"p90",current:g.ageP90,samples:g.p90Samples,color:"var(--status-info)"},{label:"p99",current:g.ageP99,samples:g.p99Samples,color:"var(--status-warning)"},{label:"max",current:g.ageMax,samples:g.maxSamples,color:"var(--status-error)"}];let S;e[0]!==g.samples?(S=g.samples.reduce(uN,0),e[0]=g.samples,e[1]=S):S=e[1];const j=S,N=v.reduce(pN,0);let C;e[2]!==y.entries?(C=new Map,y.entries.forEach(nt=>{C.set(nt.metric,nt.count)}),e[2]=y.entries,e[3]=C):C=e[3];let B;e[4]!==C?(B=C.get("ui.message_list.render")??0,e[4]=C,e[5]=B):B=e[5];let W;e[6]!==C?(W=C.get("ui.message_list.render.streaming")??0,e[6]=C,e[7]=W):W=e[7];let F;e[8]!==C?(F=C.get("ui.chat_message.render")??0,e[8]=C,e[9]=F):F=e[9];let $;e[10]!==C?($=C.get("ui.chat_message.render.streaming")??0,e[10]=C,e[11]=$):$=e[11];let K;e[12]!==C?(K=C.get("ui.chat_message.render.static_during_stream")??0,e[12]=C,e[13]=K):K=e[13];let I;e[14]!==C?(I=C.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=C,e[15]=I):I=e[15];let z;e[16]!==B||e[17]!==W||e[18]!==F||e[19]!==$||e[20]!==K||e[21]!==I?(z={messageListRender:B,messageListRenderStreaming:W,chatMessageRender:F,chatMessageRenderStreaming:$,chatMessageRenderStaticDuringStream:K,chatMessageRenderStaticOutsideActiveTurnDuringStream:I},e[16]=B,e[17]=W,e[18]=F,e[19]=$,e[20]=K,e[21]=I,e[22]=z):z=e[22];const k=z;let M,V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{const nt=()=>{x(Ko()),b(Wo()),h(Ua())};nt();const Qe=window.setInterval(nt,500);return()=>window.clearInterval(Qe)},M=[],e[23]=M,e[24]=V):(M=e[23],V=e[24]),l.useEffect(V,M);let O,E;e[25]!==d?(O=()=>{if(d==="idle")return;const nt=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(nt)},E=[d],e[25]=d,e[26]=O,e[27]=E):(O=e[26],E=e[27]),l.useEffect(O,E);let R=0,_=0,U=0;for(const nt of Object.keys(p)){const Qe=p[nt]??[];_=_+Qe.length;for(const _e of Qe)_e.role==="user"?U=U+1:_e.role==="assistant"&&(R=R+1)}let me;e[28]!==R||e[29]!==_||e[30]!==U?(me={assistant:R,total:_,user:U},e[28]=R,e[29]=_,e[30]=U,e[31]=me):me=e[31];const ce=me;let oe;if(e[32]!==c||e[33]!==p||e[34]!==u||e[35]!==f||e[36]!==r){let nt;e[38]!==c||e[39]!==p||e[40]!==u||e[41]!==r?(nt=Qe=>{const _e=p[Qe.id]??[];let wt=0,ct=0;for(const Kt of _e)Kt.role==="user"?ct=ct+1:Kt.role==="assistant"&&(wt=wt+1);const gt=u.get(Qe.id);return{id:Qe.id,title:Qe.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:wt,messageCount:_e.length,userMessageCount:ct,isStreaming:gt?.isStreaming||!1,isZombie:gt?.isZombie||!1,backgroundCount:gt?.backgroundMessageCount||0,lastAccessed:gt?.lastAccessedAt||0,isCurrent:Qe.id===c}},e[38]=c,e[39]=p,e[40]=u,e[41]=r,e[42]=nt):nt=e[42],oe=f.map(nt).sort(mN),e[32]=c,e[33]=p,e[34]=u,e[35]=f,e[36]=r,e[37]=oe}else oe=e[37];const ie=oe;let xe;e[43]!==p?(xe=Object.keys(p),e[43]=p,e[44]=xe):xe=e[44];const G=xe.length;let pe;e[45]===Symbol.for("react.memo_cache_sentinel")?(pe=async()=>{try{const nt={generatedAt:new Date().toISOString(),ui:Ko(),vscode:Wo()};await navigator.clipboard.writeText(JSON.stringify(nt,null,2)),a("copied")}catch{a("error")}},e[45]=pe):pe=e[45];const J=pe,ge=Lx,de="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let Ae;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ae={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=Ae):Ae=e[46];let he;e[47]!==o?(he=Z4(o),e[47]=o,e[48]=he):he=e[48];let Re;e[49]!==he?(Re=s.jsx(T,{name:he,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=he,e[50]=Re):Re=e[50];let se;e[51]!==r?(se=r("memoryDebugPanel.title"),e[51]=r,e[52]=se):se=e[52];let Ne;e[53]!==se?(Ne=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:se}),e[53]=se,e[54]=Ne):Ne=e[54];let be;e[55]!==Re||e[56]!==Ne?(be=s.jsxs("div",{className:"flex items-center gap-2",children:[Re,Ne]}),e[55]=Re,e[56]=Ne,e[57]=be):be=e[57];let we;e[58]!==o?(we=o==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(ut,{size:"xs",variant:"ghost",onClick:J,children:s.jsx(T,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(ut,{size:"xs",variant:"ghost",onClick:()=>{Fm(),x(Ko()),b(Wo())},children:s.jsx(T,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=o,e[59]=we):we=e[59];let ye;e[60]!==o?(ye=o==="requests"?s.jsx(ut,{size:"xs",variant:"ghost",onClick:()=>{J4(),h(Ua())},children:s.jsx(T,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=o,e[61]=ye):ye=e[61];let Pe;e[62]!==n?(Pe=n?s.jsx(ut,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(T,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=Pe):Pe=e[63];let Oe;e[64]!==we||e[65]!==ye||e[66]!==Pe?(Oe=s.jsxs("div",{className:"flex items-center gap-1",children:[we,ye,Pe]}),e[64]=we,e[65]=ye,e[66]=Pe,e[67]=Oe):Oe=e[67];let $e;e[68]!==be||e[69]!==Oe?($e=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[be,Oe]}),e[68]=be,e[69]=Oe,e[70]=$e):$e=e[70];let ze;e[71]===Symbol.for("react.memo_cache_sentinel")?(ze={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=ze):ze=e[71];const Ue=o==="memory"?"secondary":"ghost";let q;e[72]===Symbol.for("react.memo_cache_sentinel")?(q=()=>i("memory"),e[72]=q):q=e[72];let ue;e[73]!==r?(ue=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=ue):ue=e[74];let A;e[75]!==Ue||e[76]!==ue?(A=s.jsx(ut,{size:"sm",variant:Ue,className:"flex-1",onClick:q,children:ue}),e[75]=Ue,e[76]=ue,e[77]=A):A=e[77];const Q=o==="streaming"?"secondary":"ghost";let le;e[78]===Symbol.for("react.memo_cache_sentinel")?(le=()=>i("streaming"),e[78]=le):le=e[78];let Ie;e[79]!==r?(Ie=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=Ie):Ie=e[80];let re;e[81]!==Q||e[82]!==Ie?(re=s.jsx(ut,{size:"sm",variant:Q,className:"flex-1",onClick:le,children:Ie}),e[81]=Q,e[82]=Ie,e[83]=re):re=e[83];const H=o==="requests"?"secondary":"ghost";let ne;e[84]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>i("requests"),e[84]=ne):ne=e[84];let X;e[85]!==r?(X=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=X):X=e[86];let fe;e[87]!==H||e[88]!==X?(fe=s.jsx(ut,{size:"sm",variant:H,className:"flex-1",onClick:ne,children:X}),e[87]=H,e[88]=X,e[89]=fe):fe=e[89];let Fe;e[90]!==A||e[91]!==re||e[92]!==fe?(Fe=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ze,children:[A,re,fe]}),e[90]=A,e[91]=re,e[92]=fe,e[93]=Fe):Fe=e[93];const Me=o==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(Rs,{label:r("memoryDebugPanel.metric.totalMessages"),value:ce.total}),s.jsx(Rs,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${G} / ${wc.MAX_SESSIONS}`}),s.jsx(Rs,{label:r("memoryDebugPanel.metric.userMessages"),value:ce.user}),s.jsx(Rs,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ce.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:Fx()})})]}),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:wc.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:m})]})]}),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(Mn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:ie.map(nt=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:nt.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:nt.title}),nt.isStreaming?s.jsx(T,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,nt.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:nt.assistantMessageCount,user:nt.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:nt.messageCount})}),nt.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",nt.backgroundCount]}):null]})]},nt.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Ct,{children:[s.jsx(Nt,{asChild:!0,children:s.jsx(ut,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:f.map(hN),currentSessionId:c,cachedSessions:Object.keys(p),messageRoleCounts:ce,sessionMessageRoleCounts:ie.map(gN),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(jt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):o==="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(d==="copied"?"memoryDebugPanel.streaming.copy.copied":d==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(ut,{size:"xs",variant:"outline",onClick:J,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Rs,{label:r("memoryDebugPanel.metric.uiMetrics"),value:y.entries.length}),s.jsx(Rs,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:w.entries.length}),s.jsx(Rs,{label:r("memoryDebugPanel.metric.messageListRenders"),value:k.messageListRender}),s.jsx(Rs,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:k.messageListRenderStreaming}),s.jsx(Rs,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:k.chatMessageRender}),s.jsx(Rs,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:k.chatMessageRenderStreaming}),s.jsx(Rs,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:k.chatMessageRenderStaticDuringStream}),s.jsx(Rs,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:k.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(qd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:y,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),w.entries.length>0?s.jsx(qd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:w,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(Rs,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${g.totalSettled} / ${g.totalStarted}`}),s.jsx(Rs,{label:r("memoryDebugPanel.requests.tracking"),value:g.startedAt?Kp(g.durationMs):r("memoryDebugPanel.common.idle")})]}),g.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:g.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:g.peak})]})]}),s.jsx(Yd,{series:[{samples:g.samples,color:"var(--status-info)",filled:!0}],peak:j,windowSeconds:g.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:g.peak}),maxLabel:`${j}`}),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:Ha(g.peakAgeMs)})]}),s.jsx(Yd,{series:v.map(bN),peak:N,windowSeconds:g.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Ha(N)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:v.map(xN)}),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:g.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let tt;return e[94]!==ge||e[95]!==Ae||e[96]!==$e||e[97]!==Fe||e[98]!==Me?(tt=s.jsxs(ge,{className:de,style:Ae,children:[$e,Fe,Me]}),e[94]=ge,e[95]=Ae,e[96]=$e,e[97]=Fe,e[98]=Me,e[99]=tt):tt=e[99],tt},tN=eN;function sN(t,e){return t+e.count}function nN(t,e){return Math.max(t,e.samples.length)}function rN(t){return t.currentSessionId}function oN(t){return t.sessionMemoryState}function iN(t){return t.message}function aN(t){return t.totalRequestCount}function lN(){return Ko()}function cN(){return Wo()}function dN(){return Ua()}function uN(t,e){return Math.max(t,e)}function fN(t,e){return Math.max(t,e)}function pN(t,e){return e.samples.reduce(fN,t)}function mN(t,e){return e.lastAccessed-t.lastAccessed}function hN(t){return{id:t.id,title:t.title}}function gN(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function bN(t){return{samples:t.samples,color:t.color}}function xN(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:Ha(t.current)})]},t.label)}const yN=()=>{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()??"":""},vN=async()=>{const t=yN()||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")},Qd="openchamber:menu-action",ea="openchamber:check-for-updates",wN=t=>{const e=Je(g=>g.openNewSessionDraft),n=Ce(g=>g.toggleCommandPalette),r=Ce(g=>g.setCommandPaletteOpen),o=Ce(g=>g.toggleHelpDialog),i=Ce(g=>g.toggleSidebar),d=Ce(g=>g.setSessionSwitcherOpen),a=Ce(g=>g.setSettingsDialogOpen),c=Ce(g=>g.setAboutDialogOpen),u=Qr(g=>g.checkForUpdates),{setThemeMode:f}=uo(),p=l.useRef(!1),m=l.useCallback(()=>{p.current||(p.current=!0,u().then(()=>{const{available:g,error:h}=Qr.getState();if(h){Be.error("Failed to check for updates",{description:h});return}g||Be.success("You are on the latest version")}).finally(()=>{p.current=!1}))},[u]),y=l.useCallback(()=>{Rn.requestDirectoryDialog()},[]),x=l.useCallback(g=>{const h=$x();if(h.length===0)return;const v=Je.getState().currentSessionId,S=h.findIndex(C=>C.id===v);let j=g>0?0:h.length-1;S>=0&&(j=(S+g+h.length)%h.length);const N=h[j];N&&(d(!1),Je.getState().setCurrentSession(N.id))},[d]),w=l.useCallback(g=>{const{activeProjectId:h,projects:v,setActiveProject:S}=as.getState();if(v.length===0)return;const j=v.findIndex(B=>B.id===h);let N=g>0?0:v.length-1;j>=0&&(N=(j+g+v.length)%v.length);const C=v[N];C&&S(C.id)},[]),b=l.useCallback(g=>{switch(g){case"about":c(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":d(!1);{const h=Je.getState(),v=Fs.getState().currentDirectory;e(h.currentSessionId&&v?{directoryOverride:v}:void 0)}break;case"new-worktree-session":d(!1),nf();break;case"change-workspace":y();break;case"toggle-right-sidebar":{const h=Fs.getState().currentDirectory;if(!h)break;const v=Ce.getState(),S=Kn(h),j=v.contextPanelByDirectory[S];j?.isOpen?v.closeContextPanel(S):j?.activeTabId?v.setActiveContextPanelTab(S,j.activeTabId):v.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const h=Fs.getState().currentDirectory;if(!h)break;Ce.getState().openContextSurface(Kn(h),"git");break}case"open-right-sidebar-files":{const h=Fs.getState().currentDirectory;if(!h)break;Ce.getState().openContextSurface(Kn(h),"file");break}case"toggle-terminal":{const h=Fs.getState().currentDirectory;if(!h)break;Ce.getState().openContextSurface(Kn(h),"terminal");break}case"toggle-terminal-expanded":{const h=Fs.getState().currentDirectory;if(!h)break;const v=Kn(h),S=Ce.getState(),j=S.contextPanelByDirectory[v];(j?.isOpen?j.tabs.find(C=>C.id===j.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(v,"terminal"),S.toggleContextPanelExpanded(v);break}case"copy":{const h=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(h)||vN();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":_x();break;case"toggle-sidebar":i();break;case"toggle-memory-debug":t?.();break;case"go-back":Sc(-1);break;case"go-forward":Sc(1);break;case"previous-session":x(-1);break;case"next-session":x(1);break;case"previous-project":w(-1);break;case"next-project":w(1);break;case"help-dialog":o();break;case"download-logs":{rf().catch(()=>{Be.error("Failed to collect OpenCode status")});break}}},[y,w,x,t,e,c,d,r,a,f,n,o,i]);l.useEffect(()=>{const g=v=>{const S=v.detail;S&&b(S)},h=()=>{m()};return window.addEventListener(Qd,g),window.addEventListener(ea,h),()=>{window.removeEventListener(Qd,g),window.removeEventListener(ea,h)}},[b,m]),l.useEffect(()=>{if(typeof window>"u")return;const h=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof h!="function")return;let v=null,S=null;return h("openchamber:menu-action",j=>{const N=j?.payload;typeof N=="string"&&b(N)}).then(j=>{v=j}).catch(()=>{}),h("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(ea))}).then(j=>{S=j}).catch(()=>{}),()=>{(async()=>{try{const N=v?.();N instanceof Promise&&await N}catch{}try{const N=S?.();N instanceof Promise&&await N}catch{}})()}},[b])},SN="openchamber:tray-action",jN=5e3,kN=500,CN=20,Xd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Jd=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,Wp=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},zp=t=>t.title.trim()||"Question",NN=(t,e)=>ll(t,e,Tr.getState().ids,rl.getState().rankById),AN=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},PN=(t,e,n,r,o)=>{if(!t)return"";const i=yu(n,r,t),d=e.project?.name,a=i?.label?.trim()||d?.trim()||AN(t),c=Vo(t);let u=c&&o.get(c)||"";if(!u){for(const[f,p]of mr.getState().directories)if(Vo(f)===c){u=p.status?.current??"";break}}if(!u)for(const f of r.values()){const p=f.find(m=>Vo(m.path)===c);if(p?.branch){u=p.branch;break}}return u?`${a} · ${u}`:a},IN=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=Nr.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(d=>[d.providerId,d])),i=[];for(const d of Wx){if(!e.includes(d.id))continue;const a=o.get(d.id);if(!a||a.configured!==!0)continue;const c=[];for(const[f,p]of Object.entries(a.usage?.windows??{})){const m=r==="remaining"?p.remainingPercent:p.usedPercent;c.push({label:Vx(f),value:zx(p.valueLabel,m)})}const u=!a.ok&&a.error?a.error:c.length===0?"No rate limits reported":null;i.push({provider:d.name,rows:c,status:u})}return{mode:r,groups:i}},DN=async()=>{try{if(lo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Yo();if(e&&Ll(e,t))return"Local OpenChamber";const r=(await ru()).hosts.find(o=>e?Ll(e,Lm(o)):!1);return r?.label?.trim()?ou(r.label.trim()):"Instance"}catch{return""}},EN=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=ga()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[i,d]of o.children.entries()){const a=d.getState();a.vcs?.branch&&e.set(Vo(i)??i,a.vcs.branch);for(const c of a.session)c?.id&&r.set(c.id,c.title);for(const[c,u]of Object.entries(a.session_status??{})){const f=u?.type,p=f==="busy"?"busy":f==="retry"?"retry":"idle",m=t.get(c);(!m||m==="idle")&&t.set(c,p)}for(const[c,u]of Object.entries(a.permission??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||c;n.push({kind:"permission",id:f.id,sessionId:p,sessionTitle:"",label:Wp(f),directory:i})}for(const[c,u]of Object.entries(a.form??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||c;n.push({kind:"form",id:f.id,sessionId:p,sessionTitle:"",label:zp(f),directory:i})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},RN=(t,e)=>{const n=kf.getState().index.session,r=Ls.getState().activeSessions,o=new Map;for(const h of r)if(h?.id&&h.parentID){const v=o.get(h.parentID)??[];v.push(h.id),o.set(h.parentID,v)}const i=h=>{const v=[],S=[...o.get(h)??[]],j=new Set;for(;S.length;){const N=S.pop();j.has(N)||(j.add(N),v.push(N),S.push(...o.get(N)??[]))}return v},d=Ce.getState();let a=0;if(d.dockBadgeEnabled)for(const h of r){if(!h?.id||h.parentID)continue;let v=n.unseenCount[h.id]??0;v===0&&d.notifyOnSubtasks&&(v=i(h.id).reduce((S,j)=>S+(n.unseenCount[j]??0),0)),v>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const c=EN(),u=new Map(c.titleById);for(const h of r)h?.id&&h.title&&u.set(h.id,h.title);const f=hl.getState().statusById,p=h=>{const v=c.statusById.get(h);return v&&v!=="idle"?v:f.get(h)?.status.type??v??"idle"},m=h=>{const v=h.map(S=>p(S));return v.includes("busy")?"busy":v.includes("retry")?"retry":"idle"},y=as.getState().projects,x=Je.getState().availableWorktreesByProject,w=r.filter(h=>h?.id&&!h.parentID).slice().sort(NN).slice(0,CN).map(h=>{const v=[h.id,...i(h.id)],S=vn(h)??"";return{id:h.id,title:h.title||"Untitled session",status:m(v),branch:S?c.branchByDirectory.get(S)??"":"",unseen:v.reduce((j,N)=>j+(n.unseenCount[N]??0),0),hasError:v.some(j=>n.unseenHasError[j]??!1),directory:S,subtitle:PN(S,h,y,x,c.branchByDirectory)}}),b=c.approvals.map(h=>({...h,sessionTitle:u.get(h.sessionId)||""})),g=new Set(b.map(h=>h.id));for(const[h,v]of Cf.getState().bySession){const S=u.get(h)||"";for(const j of v.permissions)g.has(j.id)||(g.add(j.id),b.push({kind:"permission",id:j.id,sessionId:h,sessionTitle:S,label:Wp(j),directory:v.directory}));for(const j of v.forms)g.has(j.id)||(g.add(j.id),b.push({kind:"form",id:j.id,sessionId:h,sessionTitle:S,label:zp(j),directory:v.directory}))}return{sessions:w,approvals:b,instanceName:t,usage:IN(),dockBadgeCount:a}},MN=()=>{l.useEffect(()=>{if(!Xd()||!eo())return;const t=Jd();let e=!1,n="",r=null,o="";const i=()=>{if(e)return;const C=RN(o,t),B=JSON.stringify(C);B!==n&&(n=B,Un("desktop_tray_update",C))},d=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},kN))},a=kf.subscribe(()=>d()),c=Ls.subscribe(()=>d()),u=Ce.subscribe((C,B)=>{(C.dockBadgeEnabled!==B.dockBadgeEnabled||C.notifyOnSubtasks!==B.notifyOnSubtasks)&&d()}),f=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),c(),u()};if(!t)return i(),f;DN().then(C=>{e||(o=C,i())});const p=new Map,m=()=>{if(e)return;let C;try{C=ga()}catch{return}const B=new Set;for(const[W,F]of C.children.entries())B.add(W),p.has(W)||p.set(W,F.subscribe(()=>d()));for(const[W,F]of p)B.has(W)||(F(),p.delete(W))};let y=null;try{y=ga().subscribeRegistry(()=>{m(),d()})}catch{}m();const x=as.subscribe(()=>d()),w=Je.subscribe(()=>d()),b=mr.subscribe(()=>d()),g=hl.subscribe(()=>d()),h=Cf.subscribe(()=>d()),v=rl.subscribe(()=>d()),S=Tr.subscribe(()=>d()),j=Nr.subscribe(()=>d());Nr.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:C,results:B}=Nr.getState();C.length>0&&C.some(F=>!B.some($=>$.providerId===F))&&Nr.getState().fetchQuotas(C)});const N=window.setInterval(()=>{m(),i()},jN);return i(),()=>{f(),window.clearInterval(N),x(),w(),b(),g(),h(),v(),S(),j(),y?.();for(const C of p.values())C();p.clear()}},[]),l.useEffect(()=>{if(!Xd()||!Jd()||!eo())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=o=>{o.type==="respond-permission"&&Kx(o.sessionId,o.id,o.response).catch(()=>{Be.error("Failed to respond to permission request")})};let r=null;return e(SN,o=>{const i=o?.payload;!i||typeof i!="object"||typeof i.type!="string"||n(i)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},TN=30*6e4,ON=(t,e,n=TN)=>{const r=new Map;for(const[o,i]of Object.entries(t.sessions)){if(i.status!=="busy"&&i.status!=="retry"||t.serverTime-i.lastUpdateAt>n||e.isKnown(o))continue;const d=e.resolveDirectory(o);if(!d)continue;const a=r.get(d)??[];a.push({type:"session.status",properties:{sessionID:o,status:{type:"busy"}}}),r.set(d,a)}return r};let Ur=null;const BN=()=>{if(Ur)return Ur;const t=ss();return Ur=(async()=>{const e=await to.getHostSessionStatusSnapshot();if(!e||ss()!==t)return;const n=hl.getState(),r=Ls.getState().entityById,o=ON(e,{isKnown:d=>n.statusById.has(d)||n.observedById.has(d),resolveDirectory:d=>{const a=r.get(d);return a?vn(a):null}});for(const[d,a]of o)Ux(d,a);const i=[];for(const[d,a]of Object.entries(e.pending??{})){const c=r.get(d),u=c?vn(c):null;u&&i.push({sessionId:d,directory:u,permissions:a.permissions,forms:a.forms})}Hx(i)})().finally(()=>{Ur=null}),Ur},FN=45e3,LN=[1e3,2e3,4e3],$N=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let o=!1,i,d=0,a=!1;const c=async u=>{const f=await u().catch(()=>!1);if(o)return;a||=f;const p=a?void 0:LN[d];p!==void 0&&(d+=1),i=n(()=>{i=void 0,c(e)},p??FN)};return c(t),()=>{o=!0,i!==void 0&&r(i)}},_N=t=>{const e=He.c(3);let n,r;e[0]!==t?(n=()=>{const o=KN;let i=o();const d=co(()=>{i(),i=o()});return()=>{d(),i()}},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),l.useEffect(n,r)};function KN(){const t=ss();let e=!0;const n=async o=>(o?await Gx(ti()):await ml(),!e||ss()!==t?!1:(BN(),Ls.getState().status==="ready")),r=$N(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const WN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,zN=(t,e,n,r)=>r||[t,e,n].filter(Boolean).join("|")||void 0,VN=t=>{t.kind!=="plugin"||!t.title||Be.info(t.title,{id:zN(t.kind,t.title,t.body,t.tag),description:t.body})},UN=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,HN=t=>{const e=He.c(3),n=!0;let r,o;e[0]!==n?(r=()=>{if(!(En()||!qa()||!globalThis.window))return Qn(GN)},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),l.useEffect(r,o)};function GN(t){if(t.type!=="notification")return;const e=Ce.getState();if(!e.nativeNotificationsEnabled)return;const n=WN();if(UN(t.payload,n)){VN(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&n)return;nu()?.notifications?.notifyAgentCompletion(t.payload)}const qN=6e4,YN=t=>{const e=He.c(10),n=Ce(QN),r=qx(XN),i=Zh(t)?.path??null;let d,a;e[0]!==n||e[1]!==r||e[2]!==i?(d=()=>{n&&r(i,{maxAgeMs:qN})},a=[n,r,i],e[0]=n,e[1]=r,e[2]=i,e[3]=d,e[4]=a):(d=e[3],a=e[4]),l.useEffect(d,a);let c,u;e[5]!==n||e[6]!==r||e[7]!==i?(c=()=>{if(n)return Qn(f=>{f.type==="agent-memory-changed"&&r(i)})},u=[n,r,i],e[5]=n,e[6]=r,e[7]=i,e[8]=c,e[9]=u):(c=e[8],u=e[9]),l.useEffect(c,u)};function QN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function XN(t){return t.load}const JN=()=>{const t=He.c(4),{t:e}=vt(),n=Ce(ZN);let r,o;t[0]!==n||t[1]!==e?(r=()=>Qn(i=>{i.type==="browser-provider-reset"&&(n("builtin"),Be.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),l.useEffect(r,o)};function ZN(t){return t.setBrowserProvider}const Zd="pwa-install-toast-shown",eu="pwa-install-toast-dismissed",e5=()=>{const t=He.c(6),{browserTab:e}=eg(),{t:n}=vt(),r=l.useRef(n);let o,i;t[0]!==n?(o=()=>{r.current=n},i=[n],t[0]=n,t[1]=o,t[2]=i):(o=t[1],i=t[2]),l.useEffect(o,i);let d,a;t[3]!==e?(d=()=>{if(typeof window>"u"||!qa()||!e)return;let c=null,u=null;const f=()=>{u!==null&&(Be.dismiss(u),u=null)},p=async()=>{if(!c)return;const x=c;c=null,f(),await x.prompt();const{outcome:w}=await x.userChoice;w==="accepted"&&Be.success(r.current("pwa.installPrompt.started"))},m=x=>{const w=x;if(typeof w.prompt!="function")return;w.preventDefault(),c=w;const b=Xo(),g=$m();tg({dismissed:b.getItem(eu),sessionShown:g.getItem(Zd),hasActiveToast:u!==null})&&(g.setItem(Zd,"true"),u=Be.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{p()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Xo().setItem(eu,"true"),f()}}}))},y=()=>{c=null,f(),Be.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",m),window.addEventListener("appinstalled",y),()=>{f(),window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",y)}},a=[e],t[3]=e,t[4]=d,t[5]=a):(d=t[4],a=t[5]),l.useEffect(d,a)},t5=({open:t,onOpenChange:e})=>{const{t:n}=vt(),r=!1,[o,i]=l.useState(null),[d,a]=l.useState(null),[c,u]=l.useState(!1),[f,p]=l.useState(!1),[m,y]=l.useState(null),[x,w]=l.useState(!1);l.useCallback(async()=>{},[m,c,r,n]),l.useEffect(()=>{if(!t)return;(async()=>{try{const h=await Zs("/api/system/info");if(h.ok){const v=await h.json();if(typeof v.openchamberVersion=="string"&&v.openchamberVersion.trim()){i(v.openchamberVersion);return}}}catch{}i(await Yx())})()},[t]),l.useEffect(()=>{if(!t)return;let g=!1;return(async()=>{try{const v=await Zs("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!v.ok)return;const S=await v.json().catch(()=>null),j=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!g&&j&&a(j)}catch{}})(),()=>{g=!0}},[t]),l.useEffect(()=>{{y(null),w(!1);return}},[t,r]);const b=o;return s.jsx(en,{open:t,onOpenChange:e,children:s.jsx(tn,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Zu,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[b&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:b})}),d&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:d})})]})]}),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://github.com/openchamber/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(T,{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(T,{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(T,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Ga="project-config-invalid",s5=()=>{const t=He.c(9),{t:e}=vt(),n=js(n5);let r;t[0]!==n?(r=m=>m.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const o=js(r),[i,d]=Ms.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const m=js.getState(),y=m.activeDirectoryKey;d(!0),Promise.all([m.loadProviders({directory:y,source:"projectConfigError:retry"}),m.loadAgents({directory:y,source:"projectConfigError:retry"})]).finally(()=>d(!1))},t[2]=a):a=t[2];const c=a;let u,f;t[3]!==o||t[4]!==i||t[5]!==e?(u=()=>{if(!o){Be.dismiss(Ga);return}Be.error(e("projectConfigError.toast.title"),{id:Ga,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&s.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:o.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:m=>{m.preventDefault(),i||c()}}})},f=[o,i,c,e],t[3]=o,t[4]=i,t[5]=e,t[6]=u,t[7]=f):(u=t[6],f=t[7]),Ms.useEffect(u,f);let p;return t[8]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[8]=p):p=t[8],Ms.useEffect(o5,p),null};function n5(t){return t.activeDirectoryKey}function r5(){Be.dismiss(Ga)}function o5(){return r5}const i5="\x1B",a5=new RegExp(`${i5}\\[[0-9;?]*[ -/]*[@-~]`,"g"),$o=qn().transform(t=>t.replace(a5,"").trim()).nullish(),l5=Nc({isOpenCodeReady:Ac().optional(),openCodeRunning:Ac().optional(),lastOpenCodeError:$o,opencodeBinaryResolved:$o,lastOpenCodeLaunchDiagnostics:Nc({sourceBinary:$o,binary:$o}).nullish()}),c5=async(t,e=Zs)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=l5.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},d5=(t,e)=>{if(t)return"startup.initRecovery.openCodeUnavailable";switch(e?.step){case"serverUnreachable":return"startup.initRecovery.serverUnreachable";case"openCodeUnavailable":return"startup.initRecovery.openCodeUnavailable";case"loadAgents":return"startup.initRecovery.loadAgentsFailed";default:return"startup.initRecovery.unexpected"}},tu=hr(()=>Sn(()=>import("./OnboardingScreen-Bgp5A3WB.js"),__vite__mapDeps([151,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])).then(t=>({default:t.OnboardingScreen}))),u5=()=>{const t=He.c(3),e=Ce(h5),n=Ce(g5);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(t5,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},f5=t=>{const e=He.c(33),{onRetry:n,isRetrying:r}=t,{t:o}=vt(),[i,d]=l.useState(null);let a,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const j=new AbortController,N=ss(),C=setTimeout(()=>j.abort(),5e3);return c5(j.signal).then(B=>{!j.signal.aborted&&ss()===N&&d(B)}).catch(b5).finally(()=>clearTimeout(C)),()=>{j.abort(),clearTimeout(C)}},c=[],e[0]=a,e[1]=c):(a=e[0],c=e[1]),l.useEffect(a,c);const u=js(x5),f=i?null:u?.message??null;let p;e[2]!==o?(p=o("startup.initRecovery.title"),e[2]=o,e[3]=p):p=e[3];let m;e[4]!==p?(m=s.jsx("h1",{className:"typography-title text-foreground",children:p}),e[4]=p,e[5]=m):m=e[5];let y;e[6]!==i||e[7]!==u||e[8]!==o?(y=o(d5(i,u)),e[6]=i,e[7]=u,e[8]=o,e[9]=y):y=e[9];let x;e[10]!==y?(x=s.jsx("p",{className:"typography-body text-muted-foreground",children:y}),e[10]=y,e[11]=x):x=e[11];let w;e[12]!==m||e[13]!==x?(w=s.jsxs("div",{className:"flex flex-col gap-2",children:[m,x]}),e[12]=m,e[13]=x,e[14]=w):w=e[14];let b;e[15]!==f||e[16]!==o?(b=f&&s.jsxs("dl",{className:"w-full min-w-0 text-left","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:f})]}),e[15]=f,e[16]=o,e[17]=b):b=e[17];let g;e[18]!==i||e[19]!==o?(g=i&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[i.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:i.error})]})]}),e[18]=i,e[19]=o,e[20]=g):g=e[20];let h;e[21]!==r||e[22]!==o?(h=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[21]=r,e[22]=o,e[23]=h):h=e[23];let v;e[24]!==r||e[25]!==n||e[26]!==h?(v=s.jsx(ut,{type:"button",onClick:n,disabled:r,children:h}),e[24]=r,e[25]=n,e[26]=h,e[27]=v):v=e[27];let S;return e[28]!==v||e[29]!==w||e[30]!==b||e[31]!==g?(S=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[w,b,g,v]})}),e[28]=v,e[29]=w,e[30]=b,e[31]=g,e[32]=S):S=e[32],S};function p5({apis:t}){l.useEffect(()=>{_m("App:mounted"),Km()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=js(G=>G.initializeApp),n=js(G=>G.isInitialized),r=js(G=>G.isConnected),o=js(G=>G.providers.length),i=js(G=>G.agents.length),d=js(G=>G.loadProviders),a=js(G=>G.loadAgents),c=Je(G=>G.error),u=Je(G=>G.clearError),f=Fs(G=>G.currentDirectory),p=Fs(G=>G.isSwitchingDirectory),[m,y]=l.useState(!1),x=Hn(G=>G.refreshAll),w=ua(G=>G.refreshStatus),[b,g]=l.useState(()=>t.runtime.isVSCode),[h,v]=l.useState(!1),[S,j]=l.useState(0),[N,C]=l.useState(0),[B,W]=l.useState(!1),F=Ce(G=>G.wideChatLayoutEnabled),$=Ce(G=>G.mobileKeyboardMode),K=l.useMemo(()=>En(),[]),I=Ja(G=>G.setPlanModeEnabled),[z,k]=l.useState(()=>$l()),[M,V]=l.useState(()=>{const G=_l();return G!==null?Kl({isDesktopShell:!0,bootOutcome:G}):null}),O=l.useRef(!1);l.useEffect(()=>(Wl(m),Hd(m),()=>{Wl(!1),Hd(!1)}),[m]),l.useEffect(()=>{Wm($)},[$]),l.useEffect(()=>{g(t.runtime.isVSCode)},[t.runtime.isVSCode]),l.useEffect(()=>co(G=>{ng(G)&&rg(G),C(pe=>pe+1),v(!1),j(pe=>pe+1)}),[]);const E=jc(G=>{const pe=ss();return Object.values(G.runsByOriginalSessionID).filter(J=>J.status==="running"&&J.runtimeKey===pe).map(J=>`${J.originalSessionID}:${J.phase}:${J.lastForwardedMessageID??""}:${J.expectedAssistantParentID??""}`).sort().join("|")});l.useEffect(()=>{const G=ss(),pe=Object.values(jc.getState().runsByOriginalSessionID).filter(J=>J.status==="running"&&J.runtimeKey===G);for(const J of pe)Qx(J.originalSessionID)},[E,N]),l.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",F),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[F]),l.useEffect(()=>(zl(t),()=>zl(null)),[t]),l.useEffect(()=>{r&&(x(t.sourceControl,{force:!0}),w(t.linear,{force:!0}))},[t.sourceControl,t.linear,r,x,w,N]),Xx();const R=z==="valid",_=M?.screen==="main";l.useEffect(()=>{if(!zm({isDesktopShell:K,isInitialized:n,bootOutcomeKnown:R,bootViewIsMain:_}))return;const G=setTimeout(()=>{const pe=document.getElementById("initial-loading");pe&&(pe.classList.add("fade-out"),setTimeout(()=>{pe.remove()},300))},150);return()=>clearTimeout(G)},[K,n,R,_]),l.useEffect(()=>{if(!K||z!=="malformed")return;const G=document.getElementById("initial-loading");G&&(G.textContent="Desktop startup failed — please restart the app.")},[K,z]),l.useEffect(()=>{if(K)return;const G=setTimeout(()=>{const pe=document.getElementById("initial-loading");pe&&!n&&(pe.classList.add("fade-out"),setTimeout(()=>{pe.remove()},300))},5e3);return()=>clearTimeout(G)},[K,n]),l.useEffect(()=>{let G=!1;return(async()=>{const J=await Zs("/health",{method:"GET"}).catch(()=>null);if(!J||!J.ok||G)return;const ge=await J.json().catch(()=>null);if(!ge||G)return;const de=ge.planModeExperimentalEnabled;I(de===!0||de===1||de==="1"||de==="true")})(),()=>{G=!0}},[I]),l.useEffect(()=>{b||e()},[e,b]),l.useEffect(()=>{if(b||n)return;let G=!0,pe,J=0;const ge=10,de=1e3,Ae=async()=>{if(!G)return;if(J>=ge){v(!0);return}const he=js.getState();if(he.isInitialized){v(!1);return}J+=1,await he.initializeApp();const Re=js.getState();if(!G)return;if(Re.isInitialized){v(!1);return}if(J>=ge){v(!0);return}const se=Math.min(de*Math.pow(2,J-1),16e3);pe=setTimeout(Ae,se)};return pe=setTimeout(Ae,de),()=>{G=!1,pe&&clearTimeout(pe)}},[S,n,b]),l.useEffect(()=>{n&&v(!1)},[n]),l.useEffect(()=>{if(!h)return;const G=document.getElementById("initial-loading");G&&(G.classList.add("fade-out"),setTimeout(()=>{G.remove()},300))},[h]),l.useEffect(()=>{if(b||!r||o>0&&i>0)return;let G=!0,pe=0;const J=15,ge=async()=>{const Ae=js.getState();if(!(Ae.providers.length>0&&Ae.agents.length>0))try{Ae.providers.length===0&&await d({source:"startupRecovery"}),js.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};ge();const de=setInterval(()=>{if(G){if(++pe>=J){clearInterval(de);return}ge()}},2e3);return()=>{G=!1,clearInterval(de)}},[r,b,a,d,o,i]),l.useEffect(()=>{p||b||r&&to.setDirectory(f)},[f,p,r,b]),l.useEffect(()=>{if(typeof window>"u")return;const G=pe=>{const J=pe.detail,ge=typeof J?.sessionId=="string"?J.sessionId.trim():"";if(!ge)return;const de=typeof J?.directory=="string"&&J.directory.trim().length>0?J.directory.trim():null;if(!de){pa(ge,typeof J?.messageId=="string"?J.messageId.trim():null);return}Je.getState().setCurrentSession(ge,de)};return window.addEventListener("openchamber:open-session",G),Vm().then(pe=>{for(const J of pe)pa(J.sessionId,J.messageId)}),()=>window.removeEventListener("openchamber:open-session",G)},[]);const U=l.useRef(!1);l.useEffect(()=>{!n||U.current||(U.current=!0,og({refresh:!1}))},[n]),l.useEffect(()=>{if(typeof window>"u")return;const G=()=>{Un("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",G),()=>window.removeEventListener("openchamber:open-mini-chat",G)},[]),l.useEffect(()=>{if(typeof window>"u")return;const G=()=>{const pe=Je.getState().currentSessionId;pe&&tf(pe)};return window.addEventListener("focus",G),()=>window.removeEventListener("focus",G)},[]),l.useEffect(()=>{if(typeof window>"u")return;const G=pe=>{const J=pe.detail,ge=typeof J?.directory=="string"&&J.directory.trim().length>0?J.directory.trim():null,de=typeof J?.projectId=="string"&&J.projectId.trim().length>0?J.projectId.trim():null,Ae=!!(ge||de);Ce.getState().setSessionSwitcherOpen(!1),Je.getState().openNewSessionDraft({target:Ae?"project":"chat",selectedProjectId:Ae?de:null,directoryOverride:Ae?ge:null,preserveDirectoryOverride:!!ge})};return window.addEventListener("openchamber:open-draft-session",G),()=>window.removeEventListener("openchamber:open-draft-session",G)},[]),l.useEffect(()=>{typeof window>"u"||!n||p||O.current||(O.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),Jx(),HN(),YN(f||null),JN(),Zx(),ig(),e5(),ey(),vy(),ag();const me=l.useCallback(()=>{y(G=>!G)},[]);wN(me),MN(),_N(!0),l.useEffect(()=>{const G=()=>y(pe=>!pe);return window.addEventListener("openchamber:memory-debug-toggle",G),()=>window.removeEventListener("openchamber:memory-debug-toggle",G)},[]),l.useEffect(()=>{c&&setTimeout(()=>u(),5e3)},[u,c]),l.useEffect(()=>{if(!K||z!=="not-injected")return;let G=!1,pe=0;const J=200,ge=2e3,de=50,Ae=()=>{if(G)return;pe++;const he=$l();if(he!=="not-injected"){if(G=!0,k(he),he==="valid"){const se=_l();se&&V(Kl({isDesktopShell:!0,bootOutcome:se}))}return}const Re=Math.min(J*Math.pow(1.1,pe),ge);if(pe>=de){const se=document.getElementById("initial-loading");se&&!se.textContent?.includes("taking longer")&&(se.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Ae,Re)};return window.setTimeout(Ae,J),()=>{G=!0}},[K,z]);const ce=l.useCallback(async()=>{if(Um({isDesktopShell:En(),isDesktopLocalOriginActive:lo()})){await Hm();return}window.location.reload()},[]),oe=l.useCallback(async()=>{if(!B){v(!1),W(!0);try{await js.getState().initializeApp()}finally{W(!1)}js.getState().isInitialized||j(G=>G+1)}},[B]),ie=G=>{if(G.screen==="recovery")return G.variant};if(K&&M&&M.screen!=="main"){if(M.screen==="chooser")return s.jsx(zs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(tu,{mode:"first-launch",localAvailable:M.localAvailable!==!1,onCliAvailable:ce,onChooseRemote:()=>{}})})})});const G=ie(M),pe=M.screen==="recovery"&&"url"in M?M.url:void 0;return s.jsx(zs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(tu,{mode:"recovery",recoveryVariant:G,recoveryHostUrl:pe,recoveryHostLabel:void 0,localAvailable:M.localAvailable!==!1,onCliAvailable:ce})})})})}if(h&&!n&&!b)return s.jsx(zs,{children:s.jsx(f5,{onRetry:()=>{oe()},isRetrying:B},N)});const xe=!n&&!K;return s.jsx(zs,{children:s.jsx(ty,{sdk:to.getSdkClient(),directory:f||"",children:s.jsx(sy,{apis:t,children:s.jsx(z4,{children:s.jsx(pi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:K?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(ny,{backgroundWorkEnabled:!0}),s.jsx(lg,{}),s.jsx(s5,{}),s.jsx(x4,{}),s.jsx(cg,{ready:n&&(!K||R&&_)}),s.jsx(ry,{}),s.jsx(oy,{}),s.jsx(iy,{}),!xe&&s.jsxs(s.Fragment,{children:[s.jsx(dg,{}),s.jsx(u5,{}),m&&s.jsx(tN,{onClose:()=>y(!1)})]})]})})})})},N)})}function m5(t){const e=He.c(2);let n;return e[0]!==t?(n=s.jsx(sg,{children:s.jsx(p5,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function h5(t){return t.isAboutDialogOpen}function g5(t){return t.setAboutDialogOpen}function b5(){}function x5(t){return t.lastInitFailure}const y5=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Gm();ug();qm().then(()=>{Promise.all([Ym(),ay()]).catch(t=>{console.error("[main] settings init failed:",t)}),ly(),cy(),dy()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Vp=document.getElementById("root");if(!Vp)throw new Error("Root element not found");uy();fm.createRoot(Vp).render(s.jsx(Ms.StrictMode,{children:s.jsx(fy,{children:s.jsx(py,{children:s.jsx(my,{children:s.jsx(hy,{children:s.jsx(m5,{apis:y5})})})})})}));const $5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{bw as W,L5 as a,Uf as g,$5 as m,fw as u,Vf as v};
|