@openchamber/web 2.0.4 → 2.1.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/dist/assets/{CodeMirrorCommentWidgets-C_zL-eri.js → CodeMirrorCommentWidgets-qlshRzAf.js} +1 -1
- package/dist/assets/{DiffView-BeN2_YYF.js → DiffView-BI_YgdKl.js} +3 -3
- package/dist/assets/FilesView-B_NJFLBH.js +17 -0
- package/dist/assets/{GitView-DLDazOo1.js → GitView-BWKg6TNS.js} +4 -4
- package/dist/assets/{GuestAttachDialog-C0xe_Lyy.js → GuestAttachDialog-DO4x4vIR.js} +1 -1
- package/dist/assets/{GuestSurfacePane-BdaurnDr.js → GuestSurfacePane-4PY11vEP.js} +1 -1
- package/dist/assets/JsonTreeView-u4yx65zn.js +1 -0
- package/dist/assets/{LinearIssuesView-BryoAHow.js → LinearIssuesView-C4gGBhU8.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-DfuEoaGq.js → MarkdownImageGallery-fqVRCTdC.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-Cfb5fTnq.js +39 -0
- package/dist/assets/OnboardingScreen-CiTV2_OT.js +1 -0
- package/dist/assets/PatchDiff-BrjhzXDM.js +1 -0
- package/dist/assets/{PierreDiffViewer-BC950e3F.js → PierreDiffViewer-CVx2e1cx.js} +5 -5
- package/dist/assets/{PlanView-B7Xgihqk.js → PlanView-DP9DOnI-.js} +4 -4
- package/dist/assets/{PluginPane-2C71F8uF.js → PluginPane-rZvoMQSi.js} +3 -3
- package/dist/assets/SettingsView-Dp9jubRs.js +30 -0
- package/dist/assets/SettingsWindow-Dst0yiV7.js +1 -0
- package/dist/assets/{SubmoduleDiffSummary-BSA9gnIO.js → SubmoduleDiffSummary-CixkM4fI.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DprkVKcj.js → ToolOutputDialog-f0cS2DIf.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-CFFIAFFY.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-Kp8hKJdT.js → VirtualizedFileDiff-B-U_aQwV.js} +4 -4
- package/dist/assets/{WalkthroughView-DGnTzqIU.js → WalkthroughView-C1uB3Pl3.js} +2 -2
- package/dist/assets/{appThemeRegistry-BdEHBA4s.js → appThemeRegistry-DU-UKEHq.js} +1 -1
- package/dist/assets/{commitAndPush-LwtVa2Oc.js → commitAndPush-CtWGqrtW.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-6V1xNpO9.js → computeVirtualFileMetrics-BmhViPMt.js} +1 -1
- package/dist/assets/de-D4hpTCNY.js +10 -0
- package/dist/assets/es-Bw9m3H62.js +16 -0
- package/dist/assets/fileTreeStatus-CvPnAWSi.js +1 -0
- package/dist/assets/fr-Bhll42P0.js +14 -0
- package/dist/assets/index-Btd2mmYT.js +42 -0
- package/dist/assets/index-C-7hQnEc.css +1 -0
- package/dist/assets/{index-CmNPYddV.js → index-DwtCnbiK.js} +1 -1
- package/dist/assets/{isDiffPlainText-1bXcWCrw.js → isDiffPlainText-CPDhzF1K.js} +1 -1
- package/dist/assets/{isFilePlainText-CBAppvy1.js → isFilePlainText-n8k0lMTZ.js} +1 -1
- package/dist/assets/ja-CsHoT43d.js +16 -0
- package/dist/assets/ko-BBNdtFa4.js +16 -0
- package/dist/assets/{main-CzjTMTfW.js → main-D6rlXjug.js} +2 -2
- package/dist/assets/main-kYkr_urz.js +1000 -0
- package/dist/assets/markdownCore-CHm8ycaW.js +7 -0
- package/dist/assets/{miniChat-CP68IL8Q.js → miniChat-2JY8K3Qw.js} +2 -2
- package/dist/assets/mobile-CviaXnnU.js +2 -0
- package/dist/assets/nl-DszyktfH.js +16 -0
- package/dist/assets/openSessionFromRoute-BIlcJIf3.js +1 -0
- package/dist/assets/{web-components-ngpHPEDU.js → parseDiffFromFile-DeZzEah8.js} +5 -5
- package/dist/assets/{patchFileDiff-pqRSHLHI.js → patchFileDiff-BnEHIdM2.js} +2 -2
- package/dist/assets/pl-Bk9_mUXc.js +16 -0
- package/dist/assets/pt-BR-BIXmm3Gw.js +16 -0
- package/dist/assets/{renderElectronMiniChatApp-DKIilR7N.js → renderElectronMiniChatApp-DvUphkjj.js} +2 -2
- package/dist/assets/renderMobileApp-Cdc49X8Y.js +25 -0
- package/dist/assets/runtimeEndpointReset-Cu6RUve4.js +56 -0
- package/dist/assets/shikiHighlight-CcVzlYit.js +1 -0
- package/dist/assets/space-apply-CgJ5JYPK.js +1 -0
- package/dist/assets/space-close-C1tL-_0t.js +1 -0
- package/dist/assets/{textMateThemeFromAppTheme-BSUFChBY.js → textMateThemeFromAppTheme-CAOCeVjl.js} +1 -1
- package/dist/assets/tr-C_13w7CX.js +7 -0
- package/dist/assets/uk-BZTsG-q_.js +16 -0
- package/dist/assets/{useAppFontEffects-Dsl_sLrj.js → useAppFontEffects-CeMgbeVa.js} +185 -177
- package/dist/assets/{useInlineCommentController-d5vntsQ_.js → useInlineCommentController-U97JJifS.js} +2 -2
- package/dist/assets/useRootScrollLock-DMBY2aTT.js +2 -0
- package/dist/assets/{vendor-base-ui-DnNniUWp.js → vendor-base-ui-DWgyZK2k.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-DetzHhtC.js +1 -0
- package/dist/assets/{vendor-codemirror-commands-B7H_j0iU.js → vendor-codemirror-commands-ConqfjLn.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-DEPs2M5t.js → vendor-codemirror-lang-angular-Dbpx8qe-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-DhkseaMo.js → vendor-codemirror-lang-cpp-TRtQWrpl.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-O0cZX78y.js → vendor-codemirror-lang-css-DY4CGDG2.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-fMdQYcON.js → vendor-codemirror-lang-go-CLKXh6B8.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-CfgK872x.js → vendor-codemirror-lang-html-CQnNjmg9.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CQj4S3zl.js → vendor-codemirror-lang-java-CokZKqls.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-Cc2ZYbgX.js → vendor-codemirror-lang-javascript-Kgp6fZRE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-BmZZv8g-.js → vendor-codemirror-lang-jinja-DZchyrN1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-CMBS2tG9.js → vendor-codemirror-lang-json-CkdBRvqj.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-C6Eo8hVS.js → vendor-codemirror-lang-less-_k-GKz0A.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-DSTR47-H.js → vendor-codemirror-lang-liquid-DuHUMKoh.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-BPGOH9ye.js → vendor-codemirror-lang-markdown-CdG1RXm1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-DD9udfPH.js → vendor-codemirror-lang-php-Ca15KQSA.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-HahnQaAS.js → vendor-codemirror-lang-python-B4MRHRva.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-nLTovbjv.js → vendor-codemirror-lang-rust-8fLJdxQA.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-pL2Yc72v.js → vendor-codemirror-lang-sass-CASr_yQ1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-BVBnan19.js → vendor-codemirror-lang-sql-Dc4ER-re.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-BqGzJVm1.js → vendor-codemirror-lang-vue-fu2BqdK2.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-B0_m5DqU.js → vendor-codemirror-lang-wast-BkCOgSpV.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-Dj3voadT.js → vendor-codemirror-lang-xml-7e-kPepH.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-yu-9Z5u7.js → vendor-codemirror-lang-yaml-Cq3p_9DI.js} +1 -1
- package/dist/assets/vendor-codemirror-language-CZcLdzDM.js +3 -0
- package/dist/assets/{vendor-codemirror-language-data-B1EetJur.js → vendor-codemirror-language-data-B8HKnqZy.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BZNojiZO.js +2 -0
- package/dist/assets/{vendor-codemirror-state-C9awkmn-.js → vendor-codemirror-state--21VQleR.js} +1 -1
- package/dist/assets/vendor-codemirror-view-8PpN-8l4.js +4 -0
- package/dist/assets/vendor-opencode-client-Byb4ZSqI.js +12 -0
- package/dist/assets/vendor-remend-DcBOpbSu.js +24 -0
- package/dist/assets/{vendor-replit-codemirror-vim-B2DJlAhT.js → vendor-replit-codemirror-vim-EX7OnecQ.js} +1 -1
- package/dist/assets/zh-CN-C62wm2Tg.js +16 -0
- package/dist/assets/zh-TW-BgGTiQA6.js +16 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +4 -4
- package/server/index.js +58 -1
- package/server/lib/browser-control/DOCUMENTATION.md +8 -1
- package/server/lib/dev-tunnel/DOCUMENTATION.md +6 -0
- package/server/lib/dev-tunnel/runtime.js +94 -38
- package/server/lib/dev-tunnel/tunnel.test.js +16 -2
- package/server/lib/dictation/DOCUMENTATION.md +23 -10
- package/server/lib/dictation/audio.js +28 -0
- package/server/lib/dictation/local/sherpa-recognizer.js +33 -7
- package/server/lib/dictation/local/sherpa-recognizer.test.js +94 -0
- package/server/lib/dictation/local/worker-client.js +28 -10
- package/server/lib/dictation/local/worker-process.js +25 -1
- package/server/lib/dictation/stream-manager.js +160 -53
- package/server/lib/dictation/stream-manager.test.js +108 -7
- package/server/lib/enterprise-mode.d.ts +2 -0
- package/server/lib/enterprise-mode.js +84 -9
- package/server/lib/enterprise-mode.test.js +115 -0
- package/server/lib/fs/DOCUMENTATION.md +3 -2
- package/server/lib/fs/routes.js +28 -1
- package/server/lib/fs/routes.test.js +31 -5
- package/server/lib/git/DOCUMENTATION.md +1 -1
- package/server/lib/git/service.js +61 -2
- package/server/lib/git/service.test.js +141 -0
- package/server/lib/github/DOCUMENTATION.md +18 -0
- package/server/lib/github/checks-summary.js +76 -0
- package/server/lib/github/pr-summaries.js +282 -0
- package/server/lib/github/pr-summaries.test.js +209 -0
- package/server/lib/github/routes.js +42 -77
- package/server/lib/github/routes.test.js +77 -0
- package/server/lib/inherited-env.js +51 -0
- package/server/lib/inherited-env.test.js +59 -0
- package/server/lib/message-search/DOCUMENTATION.md +83 -0
- package/server/lib/message-search/indexer.js +336 -0
- package/server/lib/message-search/indexer.test.js +341 -0
- package/server/lib/message-search/routes.js +92 -0
- package/server/lib/message-search/runtime.js +234 -0
- package/server/lib/message-search/runtime.test.js +108 -0
- package/server/lib/message-search/sqlite.js +74 -0
- package/server/lib/message-search/store.js +289 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
- package/server/lib/openchamber-control/actions.js +1 -1
- package/server/lib/openchamber-control/service.js +21 -2
- package/server/lib/openchamber-control/service.test.js +50 -0
- package/server/lib/openchamber-sessions/routes.js +15 -0
- package/server/lib/openchamber-sessions/routes.test.js +31 -0
- package/server/lib/opencode/DOCUMENTATION.md +43 -38
- package/server/lib/opencode/auth.d.ts +24 -0
- package/server/lib/opencode/auth.js +130 -66
- package/server/lib/opencode/auth.test.js +114 -70
- package/server/lib/opencode/compatibility.js +4 -3
- package/server/lib/opencode/compatibility.test.js +10 -10
- package/server/lib/opencode/feature-routes-runtime.js +3 -0
- package/server/lib/opencode/lifecycle.js +21 -12
- package/server/lib/opencode/lifecycle.test.js +38 -5
- package/server/lib/opencode/provider-source-route.test.js +55 -2
- package/server/lib/opencode/routes.js +17 -4
- package/server/lib/opencode/settings-helpers.js +6 -0
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +16 -0
- package/server/lib/opencode/settings-runtime.js +9 -0
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/v1-migration-topup.js +13 -3
- package/server/lib/opencode/v2-install.test.js +13 -13
- package/server/lib/quota/DOCUMENTATION.md +11 -5
- package/server/lib/quota/providers/claude/auth.js +19 -6
- package/server/lib/quota/providers/claude/auth.test.js +22 -9
- package/server/lib/quota/providers/claude/index.js +3 -3
- package/server/lib/quota/providers/claude/index.test.js +3 -2
- package/server/lib/quota/providers/cline-pass.js +4 -4
- package/server/lib/quota/providers/codex.js +3 -4
- package/server/lib/quota/providers/codex.test.js +1 -1
- package/server/lib/quota/providers/copilot.js +4 -5
- package/server/lib/quota/providers/copilot.test.js +1 -1
- package/server/lib/quota/providers/deepseek.js +3 -4
- package/server/lib/quota/providers/deepseek.test.js +1 -1
- package/server/lib/quota/providers/google/auth.js +1 -3
- package/server/lib/quota/providers/google/index.js +3 -2
- package/server/lib/quota/providers/hyper.js +4 -4
- package/server/lib/quota/providers/index.js +9 -2
- package/server/lib/quota/providers/index.test.js +5 -3
- package/server/lib/quota/providers/kimi.js +16 -11
- package/server/lib/quota/providers/kimi.test.js +81 -38
- package/server/lib/quota/providers/minimax-shared.js +3 -4
- package/server/lib/quota/providers/nanogpt.js +3 -4
- package/server/lib/quota/providers/neuralwatt.js +3 -4
- package/server/lib/quota/providers/neuralwatt.test.js +1 -1
- package/server/lib/quota/providers/openai.js +2 -8
- package/server/lib/quota/providers/opencode-go.js +5 -5
- package/server/lib/quota/providers/opencode-go.test.js +1 -1
- package/server/lib/quota/providers/openrouter.js +30 -6
- package/server/lib/quota/providers/openrouter.test.js +122 -1
- package/server/lib/quota/providers/wafer.js +3 -4
- package/server/lib/quota/providers/xai.js +12 -12
- package/server/lib/quota/providers/zai.js +3 -4
- package/server/lib/quota/providers/zai.test.js +1 -1
- package/server/lib/quota/providers/zhipuai-coding-plan.js +5 -6
- package/server/lib/quota/providers/zhipuai-coding-plan.test.js +1 -1
- package/server/lib/quota/routes.js +1 -1
- package/server/lib/routing/DOCUMENTATION.md +4 -0
- package/server/lib/routing/runtime.js +45 -4
- package/server/lib/routing/runtime.test.js +35 -6
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +27 -0
- package/server/lib/scheduled-tasks/chats-scope.js +50 -0
- package/server/lib/scheduled-tasks/runtime.js +57 -23
- package/server/lib/scheduled-tasks/runtime.test.js +103 -1
- package/server/lib/scheduled-tasks/service.js +37 -29
- package/server/lib/scheduled-tasks/service.test.js +39 -0
- package/server/lib/spaces/DOCUMENTATION.md +54 -9
- package/server/lib/spaces/host.js +24 -3
- package/server/lib/spaces/journey.js +111 -11
- package/server/lib/spaces/journey.test.js +189 -8
- package/server/lib/spaces/places/docker-disk.js +151 -0
- package/server/lib/spaces/places/docker-disk.test.js +167 -0
- package/server/lib/spaces/places/docker-tools.js +11 -1
- package/server/lib/spaces/places/docker.js +4 -2
- package/server/lib/spaces/places/fake-docker.js +36 -2
- package/server/lib/spaces/routes.js +21 -4
- package/server/lib/spaces/routes.test.js +6 -2
- package/server/lib/spaces/space-archive.js +275 -0
- package/server/lib/spaces/space-archive.test.js +194 -0
- package/server/lib/spaces/space-opencode.js +139 -6
- package/server/lib/spaces/space-opencode.test.js +82 -1
- package/server/lib/spaces/space-records.js +3 -0
- package/server/lib/spaces/space-setup.js +10 -5
- package/server/lib/spaces/space-setup.test.js +8 -2
- package/server/lib/terminal/DOCUMENTATION.md +1 -0
- package/server/lib/terminal/runtime.js +6 -1
- package/server/lib/terminal/runtime.test.js +19 -0
- package/server/lib/tts/routes.js +2 -2
- package/server/lib/tts/service.js +8 -8
- package/dist/assets/FilesView-CN34wm_N.js +0 -17
- package/dist/assets/JsonTreeView-B1Xq-k2t.js +0 -1
- package/dist/assets/MarkdownRendererImpl-B_ZcWOvX.js +0 -12
- package/dist/assets/OnboardingScreen-C22bGmnP.js +0 -1
- package/dist/assets/PatchDiff-0xd6UeFB.js +0 -1
- package/dist/assets/SettingsView-m_zoFiaT.js +0 -30
- package/dist/assets/SettingsWindow-CofS020b.js +0 -1
- package/dist/assets/ToolPartDiffPreview-Dq0go_fX.js +0 -8
- package/dist/assets/de-DlgBHUAI.js +0 -10
- package/dist/assets/es-BC8G41U8.js +0 -16
- package/dist/assets/fr-I0z3vVjy.js +0 -14
- package/dist/assets/index-CgR5rJq_.js +0 -41
- package/dist/assets/index-adyy_sEk.css +0 -1
- package/dist/assets/ja-BIElEsY8.js +0 -16
- package/dist/assets/ko-DRnnHetA.js +0 -16
- package/dist/assets/main-DVX34beR.js +0 -886
- package/dist/assets/markdownCore-Cxbkn5NR.js +0 -7
- package/dist/assets/mobile-BrlBrNfZ.js +0 -2
- package/dist/assets/nl-DzUV-kwp.js +0 -16
- package/dist/assets/pl-Bb-cb7k7.js +0 -16
- package/dist/assets/pt-BR-CyIWrTcE.js +0 -16
- package/dist/assets/renderMobileApp-B0z6-x58.js +0 -25
- package/dist/assets/runtimeEndpointReset-uu1DBwLL.js +0 -52
- package/dist/assets/scheduledTasksApi-BuzWT445.js +0 -1
- package/dist/assets/shikiHighlight-BWGrY5YU.js +0 -1
- package/dist/assets/tr-DXEDSoYO.js +0 -7
- package/dist/assets/uk-C8hN--q_.js +0 -16
- package/dist/assets/useRootScrollLock-2rd5Y6gR.js +0 -2
- package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +0 -1
- package/dist/assets/vendor-codemirror-language-BgPj_McA.js +0 -3
- package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +0 -2
- package/dist/assets/vendor-codemirror-view-CiLROUVV.js +0 -4
- package/dist/assets/vendor-opencode-client-DSZl7jSi.js +0 -12
- package/dist/assets/vendor-remend-BWYYytN3.js +0 -22
- package/dist/assets/zh-CN-CtzXdjMZ.js +0 -16
- package/dist/assets/zh-TW-Ds0CADSz.js +0 -16
- package/server/lib/opencode/credential-db.js +0 -144
- package/server/lib/opencode/credential-db.test.js +0 -104
|
@@ -0,0 +1,1000 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-C1uB3Pl3.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-CeMgbeVa.js","assets/index-Btd2mmYT.js","assets/vendor-zod-CxRSdNoV.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-Byb4ZSqI.js","assets/index-C-7hQnEc.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-base-ui-DWgyZK2k.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--0sBrLRh.js","assets/vendor-tanstack-virtual-core-BoA4iGMw.js","assets/vendor-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/contextPanelEmbeddedChat-CirXEPJq.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-CZcLdzDM.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state--21VQleR.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-8PpN-8l4.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-Kgp6fZRE.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DetzHhtC.js","assets/vendor-codemirror-lang-json-CkdBRvqj.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-DY4CGDG2.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CQnNjmg9.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CdG1RXm1.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-B8HKnqZy.js","assets/vendor-codemirror-lang-python-B4MRHRva.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-ConqfjLn.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-BnEHIdM2.js","assets/runtimeEndpointReset-Cu6RUve4.js","assets/space-apply-CgJ5JYPK.js","assets/openSessionFromRoute-BIlcJIf3.js","assets/GuestAttachDialog-DO4x4vIR.js","assets/PluginPane-rZvoMQSi.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/parseDiffFromFile-DeZzEah8.js","assets/computeVirtualFileMetrics-BmhViPMt.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-CVx2e1cx.js","assets/VirtualizedFileDiff-B-U_aQwV.js","assets/isDiffPlainText-CPDhzF1K.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-U97JJifS.js","assets/appThemeRegistry-DU-UKEHq.js","assets/textMateThemeFromAppTheme-CAOCeVjl.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-DMBY2aTT.js","assets/fileTreeStatus-CvPnAWSi.js","assets/DiffView-BI_YgdKl.js","assets/SubmoduleDiffSummary-CixkM4fI.js","assets/changesTree-CePHbFcj.js","assets/FilesView-B_NJFLBH.js","assets/shikiHighlight-CcVzlYit.js","assets/vendor-codemirror-search-BZNojiZO.js","assets/vendor-replit-codemirror-vim-EX7OnecQ.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-u4yx65zn.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-n8k0lMTZ.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-qlshRzAf.js","assets/GitView-BWKg6TNS.js","assets/commitAndPush-CtWGqrtW.js","assets/LinearIssuesView-C4gGBhU8.js","assets/PlanView-DP9DOnI-.js","assets/GuestSurfacePane-4PY11vEP.js","assets/SettingsWindow-Dst0yiV7.js","assets/SettingsView-Dp9jubRs.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-CiTV2_OT.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as Ye,R as c,j as n,r as ps,c as Zp,h as em}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{J as pn,K as Lo,L as tm,N as sm,h as ds,B as Ld,u as ve,O as Ot,P as cl,Q as nm,y as po,R as _s,a as Qt,C as Or,o as ut,S as vs,T as Dr,U as _d,V as rm,W as om,X as im,Y as am,Z as $d,n as is,_ as Rn,$ as jo,e as fr,a0 as lm,a1 as cm,a2 as dm,a3 as um,a4 as Wd,A as ln,F as ar,a5 as lr,a6 as fm,a7 as wa,a8 as Kd,a9 as Pn,aa as In,ab as pm,ac as zd,ad as mm,ae as hm,af as gm,ag as Kn,ah as ko,ai as Ei,aj as bm,ak as xm,al as va,d as Co,z as sr,v as cs,am as ym,an as Vd,ao as wm,ap as Ri,aq as Ud,ar as Hd,x as vm,i as Sm,q as jm,t as km,as as mo,at as ho,au as Cm,av as dl,aw as Nm,ax as Am,ay as Pm,az as Im,aA as ul,aB as fl,aC as pl,aD as ml,aE as Dm,E as hl,aF as Em,aG as Rm,aH as Mm,aI as Tm,H as Om,I as Bm}from"./index-Btd2mmYT.js";import{_ as sn}from"./vendor-vite-runtime-DD1OZmLC.js";import{_ as gl,$ as li,a0 as Vs,a1 as Mi,a2 as bl,a3 as Fm,a4 as Lm,a5 as _m,a6 as $m,a7 as Wm,a8 as Km,a9 as zm,aa as xl,ab as Vm,ac as Um,ad as Hm,ae as Sa,d as Gm,m as Gd,af as qm,a as Ym,b as Qm,ag as qd,h as Ti,ah as yl,ai as wl,w as Yd,aj as Xm,ak as Jm,t as Zm,q as eh,al as Qd,am as Oi,an as Wn,ao as Xd,ap as Jd,v as th,aq as er,ar as vl,as as Sl,at as jl,P as sh,T as nh,au as rh,av as oh,aw as ih,ax as ah,ay as lh,az as ch,j as Zd,aA as dh,aB as uh,C as fh,c as eu,S as ci,aC as tu,l as ph,aD as su,aE as mh,k as hh,aF as gh,f as bh,i as xh,aG as tr,r as di,aH as yh,aI as kl,aJ as wh,u as Nr,s as vh,N as Sh,D as jh,aK as kh,e as Ch,x as Nh,U as Ah,E as Ph,aL as Ih,J as Dh,K as Eh,L as Rh,M as Mh,Q as Th,V as nu,W as Oh,aM as Bh,X as Fh,Z as Lh,aN as _h,aO as $h,aP as Wh,O as Kh,aQ as zh,z as Vh,A as Uh,F as Hh,G as Gh,I as ru,H as qh,R as Yh,aR as Qh}from"./runtimeEndpointReset-Cu6RUve4.js";import{f as jt,h as De,bs as Wt,I as F,g as Hn,t as We,aD as js,bt as ws,aF as ks,aC as Cs,T as mr,a4 as hn,as as Gn,bu as Tn,o as Mn,bv as Cl,bw as Xh,bx as Jh,ao as vt,ap as St,aq as wt,b as Vt,z as Je,H as Zh,by as ou,bz as Vr,u as gs,r as Is,D as iu,C as au,bA as Bi,bB as eg,bC as lu,bD as cu,S as du,bE as tg,bF as sg,bG as Nl,bH as Al,bI as uu,bJ as ng,bK as Pl,bL as rg,bM as og,bN as ja,bO as Fi,bP as fu,bQ as ig,bR as ag,bS as lg,Q as pu,bT as cg,bU as dg,bV as ug,n as rr,bW as fg,bX as pg,bY as mg,p as hg,bZ as mu,b_ as gg,b$ as bg,c0 as xg,c1 as hu,c2 as gu,c3 as bu,c4 as xu,c5 as yu,c6 as wu,c7 as vu,c8 as Br,c9 as ka,aV as Ca,ca as zn,cb as Fr,cc as yg,cd as Ds,ce as Es,cf as Gs,cg as qs,ch as Ys,ci as qn,B as ht,cj as gn,aL as hs,ck as wg,cl as vg,aT as mn,cm as nr,cn as ys,co as _o,cp as Su,cq as Li,cr as Sg,cs as Il,ct as Dl,cu as El,cv as Rl,cw as Ur,a1 as Ar,cx as Hr,cy as Ml,cz as jg,R as ju,cA as kg,cB as Cg,at as Ng,au as Na,av as Ag,J as Pg,K as Yn,cC as ku,ah as Ig,cD as Dg,cE as Eg,aJ as Rg,cF as Mg,cG as Aa,cH as Tg,cI as Og,aK as Pa,cJ as Bg,cK as Cu,cL as go,cM as Nu,cN as Fg,l as es,s as Lg,cO as _g,cP as $g,aY as Qn,O as Au,cQ as Wg,cR as Kg,cS as Xn,cT as zg,cU as Vg,cV as Ug,cW as ui,cX as Hg,cY as Gg,cZ as qg,c_ as Pu,c$ as Yg,d0 as Ia,d1 as Qg,d2 as Iu,d3 as Xg,aU as _i,d4 as $i,d5 as Tl,d6 as Jg,d7 as Ol,d8 as jr,d9 as Zg,da as Bl,db as eb,dc as Cn,c as Er,d as Da,a5 as Ea,dd as Du,de as Hs,df as tb,dg as Eu,dh as sb,aM as nb,di as rb,ac as ob,a7 as Ru,dj as ib,dk as ab,dl as lb,dm as cb,dn as db,dp as Bn,dq as ub,dr as fb,ag as Wi,ds as pb,dt as Mu,du as ts,dv as mb,dw as hb,dx as Tu,dy as gb,dz as Ra,a9 as Ma,dA as Fl,ae as No,e as Ta,dB as bb,ad as Ou,dC as Bu,dD as Ki,P as Fu,U as Lu,V as _u,W as $u,dE as xb,dF as yb,dG as qt,dH as wb,dI as $o,dJ as Wu,dK as Ku,dL as zu,dM as vb,dN as Oa,dO as Vu,dP as Uu,dQ as Hu,dR as Sb,E as jb,dS as kb,X as Cb,$ as Gu,ak as Nb,Z as Ab,Y as Ll,dT as Pb,dU as qu,F as Yu,dV as Ib,dW as Db,dX as Eb,dY as Rb,dZ as Pr,a0 as zi,d_ as Mb,d$ as Tb,e0 as Ob,e1 as Bb,al as Fb,e2 as Qu,e3 as Wo,e4 as Lb,e5 as Rr,ab as _b,G as Ba,e6 as $b,e7 as Wb,e8 as _l,e9 as Kb,ea as zb,a6 as Vb,aa as Ub,eb as Hb,ec as Gb,b9 as $l,aj as Wl,ai as Kl,ed as qb,b4 as Vi,ee as Yb,M as zl,N as fi,ef as Qb,eg as Xb,af as Jb,eh as Zb,ei as ex,ej as tx,ek as sx,el as nx,em as rx,en as Ao,eo as ox,ep as Vl,eq as ix,er as ax,es as lx,et as Ul,eu as cx,a as Xu,ev as Ui,ew as Fa,_ as Ju,ex as dx,ey as bo,ez as ux,i as fx,eA as px,eB as mx,eC as hx,eD as gx,eE as bx,eF as xx,eG as Hl,eH as yx,aZ as wx,a_ as vx,b0 as Sx,a$ as jx,b2 as Gl,b3 as ql,b6 as Yl,b7 as Ql,b5 as Zu,b8 as ef,eI as kx,bn as Cx,bo as Nx,bp as Ax,bq as Px,br as Ix,bh as Dx,bj as Ex,bk as Rx,bl as Mx,bm as Tx}from"./useAppFontEffects-CeMgbeVa.js";import{u as tf,S as Xl,C as Ox,t as Bx,W as sf,f as Fx,G as Lx,a as _x}from"./useRootScrollLock-DMBY2aTT.js";import{u as Fn,O as Jl,D as $x,a as Wx,b as Kx,G as zx}from"./fileTreeStatus-CvPnAWSi.js";import{i as Vx}from"./space-apply-CgJ5JYPK.js";import{f as Ko,h as un,T as zo,M as Vo,D as Uo,j as Ho,d as Ux,b as Hx,k as Gx,i as qx}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Go,S as La,h as Yx,a as nf,v as rf,s as Qx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as qo}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as of,M as af,C as lf,a as Hi,b as Gi,c as qi,d as cf,e as Xx,f as Jx}from"./vendor-base-ui-DWgyZK2k.js";import{c as Lr,u as Vn,d as Zx,p as ey}from"./vendor-zustand-BAGL70zf.js";import{g as ty,a as sy,E as df,b as ny,c as ry,d as oy,e as iy,i as ay}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as ly}from"./PluginPane-rZvoMQSi.js";import{o as Yi}from"./openSessionFromRoute-BIlcJIf3.js";import{a as _a,s as Un,r as uf,o as Zl,b as ec}from"./vendor-zod-CxRSdNoV.js";import{u as cy}from"./vendor-tanstack-react-virtual--0sBrLRh.js";import{d as dy}from"./vendor-tanstack-virtual-core-BoA4iGMw.js";const uy="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",fy="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",pi=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?uy:t.id==="terminal"?fy:void 0}),tc=t=>{const e=Ye.c(8),{label:s,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==s?(a=s.trim().slice(0,1).toUpperCase()||"?",e[0]=s,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>l(!0),e[2]=m):m=e[2];let b;return e[3]!==u?(b=n.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:m}),e[3]=u,e[4]=b):b=e[4],b}let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=De("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]!==d?(p=n.jsx("span",{className:f,children:d}),e[6]=d,e[7]=p):p=e[7],p},py=t=>{const e=Ye.c(75),{directory:s,className:r}=t,{t:i}=jt(),o=Fn(my),l=Fn(hy),a=Fn(gy),d=Fn(by),u=Fn(xy),f=Fn(yy),p=Fn(wy);let m,b;e[0]!==u?(m=()=>{u()},b=[u],e[0]=u,e[1]=m,e[2]=b):(m=e[1],b=e[2]),c.useEffect(m,b);const x=pn()&&Lo();let v;e:{let le;e[3]!==l||e[4]!==o?(le=l.find(he=>he.id===o)??l.find(vy)??l[0]??Jl[0],e[3]=l,e[4]=o,e[5]=le):le=e[5];const pe=le;if(pe){let he;e[6]!==pe?(he=pi(pe),e[6]=pe,e[7]=he):he=e[7],v=he;break e}let je;e[8]===Symbol.for("react.memo_cache_sentinel")?(je=pi(Jl[0]),e[8]=je):je=e[8],v=je}const y=v;if(!x||!s||l.length===0)return null;let g;e[9]!==s?(g=async le=>{await tm(s,le.id,le.appName)||await sm(s,le.appName)},e[9]=s,e[10]=g):g=e[10];const h=g;let w;e[11]!==h||e[12]!==p?(w=async le=>{await p(le.id),await h(le)},e[11]=h,e[12]=p,e[13]=w):w=e[13];const S=w;let j;e[14]!==s||e[15]!==i?(j=async()=>{(await Hn(s)).ok&&We.success(i("openInApp.toast.pathCopied"))},e[14]=s,e[15]=i,e[16]=j):j=e[16];const N=j;let C;e[17]!==r?(C=De("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 R;e[19]!==h||e[20]!==y?(R=()=>{h(y)},e[19]=h,e[20]=y,e[21]=R):R=e[21];const T=d&&"animate-pulse";let O;e[22]!==T?(O=De("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",T),e[22]=T,e[23]=O):O=e[23];let _;e[24]!==y.label||e[25]!==i?(_=i("openInApp.actions.openInAria",{app:y.label}),e[24]=y.label,e[25]=i,e[26]=_):_=e[26];let W;e[27]!==y.fallbackIconDataUrl||e[28]!==y.iconDataUrl||e[29]!==y.label?(W=n.jsx(tc,{label:y.label,iconDataUrl:y.iconDataUrl,fallbackIconDataUrl:y.fallbackIconDataUrl}),e[27]=y.fallbackIconDataUrl,e[28]=y.iconDataUrl,e[29]=y.label,e[30]=W):W=e[30];let L;e[31]!==O||e[32]!==_||e[33]!==W||e[34]!==R?(L=n.jsx("button",{type:"button",onClick:R,className:O,"aria-label":_,children:W}),e[31]=O,e[32]=_,e[33]=W,e[34]=R,e[35]=L):L=e[35];let K;e[36]===Symbol.for("react.memo_cache_sentinel")?(K=De("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]=K):K=e[36];let A;e[37]!==i?(A=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=A):A=e[38];let D;e[39]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(F,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=D):D=e[39];let E;e[40]!==A?(E=n.jsx(js,{asChild:!0,children:n.jsx("button",{type:"button",className:K,"aria-label":A,children:D})}),e[40]=A,e[41]=E):E=e[41];let M;e[42]!==N?(M=()=>{N()},e[42]=N,e[43]=M):M=e[43];let k;e[44]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(F,{name:"file-copy",className:"h-4 w-4"}),e[44]=k):k=e[44];let I;e[45]!==i?(I=i("openInApp.actions.copyPath"),e[45]=i,e[46]=I):I=e[46];let U;e[47]!==I?(U=n.jsx("span",{className:"typography-ui-label text-foreground",children:I}),e[47]=I,e[48]=U):U=e[48];let z;e[49]!==M||e[50]!==U?(z=n.jsxs(Wt,{className:"flex items-center gap-2",onClick:M,children:[k,U]}),e[49]=M,e[50]=U,e[51]=z):z=e[51];let ce;e[52]===Symbol.for("react.memo_cache_sentinel")?(ce=n.jsx(ws,{}),e[52]=ce):ce=e[52];let re;if(e[53]!==l||e[54]!==S||e[55]!==y.id){let le;e[57]!==S||e[58]!==y.id?(le=pe=>{const je=pi(pe);return n.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{S(pe)},children:[n.jsx(tc,{label:pe.label,iconDataUrl:pe.iconDataUrl,fallbackIconDataUrl:je.fallbackIconDataUrl}),n.jsx("span",{className:"typography-ui-label text-foreground",children:pe.label}),y.id===pe.id?n.jsx(F,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},pe.id)},e[57]=S,e[58]=y.id,e[59]=le):le=e[59],re=l.map(le),e[53]=l,e[54]=S,e[55]=y.id,e[56]=re}else re=e[56];let Y;e[60]!==a||e[61]!==f||e[62]!==i?(Y=a?n.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{f(!0)},children:[n.jsx(F,{name:"refresh",className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=f,e[62]=i,e[63]=Y):Y=e[63];let me;e[64]!==z||e[65]!==re||e[66]!==Y?(me=n.jsxs(ks,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[z,ce,re,Y]}),e[64]=z,e[65]=re,e[66]=Y,e[67]=me):me=e[67];let be;e[68]!==E||e[69]!==me?(be=n.jsxs(Cs,{children:[E,me]}),e[68]=E,e[69]=me,e[70]=be):be=e[70];let Pe;return e[71]!==L||e[72]!==be||e[73]!==C?(Pe=n.jsxs("div",{className:C,children:[L,be]}),e[71]=L,e[72]=be,e[73]=C,e[74]=Pe):Pe=e[74],Pe};function my(t){return t.selectedAppId}function hy(t){return t.availableApps}function gy(t){return t.isCacheStale}function by(t){return t.isScanning}function xy(t){return t.initialize}function yy(t){return t.loadInstalledApps}function wy(t){return t.selectApp}function vy(t){return t.id===$x}const Po=new Map,Qi=new Set,ff=()=>{for(const t of Qi)t()},mi=(t,e)=>{const s=t.trim();s&&(e.length===0?Po.delete(s):Po.set(s,[...e]),ff())},Sy=t=>{Po.delete(t.trim())&&ff()},pf=[],jy=t=>Po.get(t.trim())??pf,ky=t=>(Qi.add(t),()=>{Qi.delete(t)}),Cy=t=>{const e=Ye.c(2);let s;return e[0]!==t?(s=()=>jy(t),e[0]=t,e[1]=s):s=e[1],c.useSyncExternalStore(ky,s,Ny)};function Ny(){return pf}const Ay=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Py=["dev","start","preview","serve"];async function Iy(t,e,s){if(!t)return null;const r=Ry(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(s){const i=My(s);if(i){const o=await Ty(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await Dy(t)){const i=await Ey(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function Dy(t){const e=`${t}/index.html`,s=await Io(e,t);return typeof s=="string"&&s.trim().length>0}async function Ey(){try{const t=await ds("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),s=typeof e?.port=="number"?e.port:null;return s&&Number.isFinite(s)?s:null}catch{return null}}function Ry(t){for(const e of t){const s=`${e.name} ${e.command}`.toLowerCase();if(Py.some(i=>s.includes(i)))return e}return null}function My(t){for(const{pattern:e}of Ay)for(const s of Object.keys(t))if(e.test(s))return s;return null}async function Ty(t){const e=await Io(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const s=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of s){const o=await Io(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Io(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ds(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const s=Ld()?.files;if(s?.readFile)try{const r=await s.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ds(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Oy(t){try{const e=await Io(`${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 By=/\{(worktree|branch)\}/g,hi=63,Fy=new Set(["main","master"]),mf=t=>/\{(worktree|branch)\}/.test(t??""),Ly=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const s=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(s).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},hf=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=hi)return e;const s=await Ly(e);return s?`${e.slice(0,hi-7).replace(/-+$/,"")}-${s}`:e.slice(0,hi).replace(/-+$/,"")},_y=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},$y=async(t,e,s)=>{const r=s.includes("{branch}"),i=s.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!i)return{branch:null,linkedWorktree:i};const o=await t.getGitStatus(e,{mode:"light"});return{branch:_y(o.current),linkedWorktree:i}},Wy=async t=>!t.linkedWorktree||!t.branch||Fy.has(t.branch)?"":hf(t.branch.split("/").pop()??""),Ky=t=>{const e=t.lastIndexOf("@"),s=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const i=r.lastIndexOf(":"),o=i>=0?r.slice(0,i):r,l=i>=0?r.slice(i):"",a=o.split(".").map(d=>d.replace(/^-+|-+$/g,"")).filter(Boolean);return`${s}${a.join(".")}${l}`},zy=async(t,e)=>{const s={worktree:await Wy(e),branch:e.branch?await hf(e.branch):""},r=t.replace(By,(d,u)=>s[u]),i=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!i)return r;const[,o="",l="",a=""]=i;return`${o}${Ky(l)}${a}`},Vy=async(t,e,s)=>mf(e)?zy(e,await $y(t,s,e)):e,Us="__openchamber_auto_discover_preview__",Uy=15e3,Hy=3e3,gi=t=>t.id===Us?"scan-2":Um.find(s=>s.key===t.icon)?.Icon??"play",Gy=t=>{const e=(t||"").trim();if(!e)return null;const s=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(s);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},qy=({projectRef:t,directory:e,className:s,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=jt(),{currentTheme:l}=mr(),{terminal:a,runtime:d,git:u}=hn(),f=Gn(),{isMobile:p}=Tn(),m=c.useMemo(()=>pn(),[]),b=gl(B=>B.instances),x=gl(B=>B.load),v=ve(B=>B.terminalShell),y=ve(B=>B.terminalLoginShells.includes(B.terminalShell)),g=ve(B=>B.setSettingsPage),h=ve(B=>B.setSettingsDialogOpen),w=ve(B=>B.setSettingsProjectsSelectedId),S=ve(B=>B.openContextPreview),j=Ot(B=>B.ensureDirectory),N=Ot(B=>B.reconcileServerSessions),C=Ot(B=>B.setTabLabel),R=Ot(B=>B.setTabIconKey),T=Ot(B=>B.setActiveTab),O=Ot(B=>B.setConnecting),_=Ot(B=>B.setTabSessionId),W=Ot(B=>B.setTabPurpose),L=Ot(B=>B.allocateActionExecution),K=Ot(B=>B.setTabLifecycle),A=Ot(B=>B.setTabPreviewUrl),D=Ot(B=>B.matchesActionExecution),E=Ot(B=>B.captureStartedActionMutationRevisions),[M,k]=c.useState([]),I=c.useRef(null),[U,z]=c.useState(null),[ce,re]=c.useState(!1),Y=c.useRef({}),me=c.useRef({}),be=c.useRef({}),Pe=c.useRef(new Set),le=c.useRef(0),[pe,je]=c.useState({}),he=t?.id??null,X=t?.path??"",de=c.useMemo(()=>he?{id:he,path:X}:null,[he,X]);c.useEffect(()=>{m&&x().catch(()=>{})},[m,x]);const fe=c.useCallback(async B=>{await Mn(B)},[]),H=c.useCallback(async()=>{if(!de)return;const B=le.current+1;le.current=B,re(!0);try{const Se=await Cl(de);if(le.current!==B)return;I.current=Se;const Fe=Se.projectActions;k(Fe),z($=>$===Us||$&&Fe.some(se=>se.id===$)?$:null)}catch{if(le.current!==B)return}finally{le.current===B&&re(!1)}},[de]),ge=c.useMemo(()=>li(e||de?.path||""),[e,de?.path]),Me=c.useMemo(()=>li(de?.path||""),[de?.path]),Ne=c.useMemo(()=>li(f||"")||ge,[f,ge]),Ie=c.useRef(Ne);c.useEffect(()=>{Ie.current=Ne},[Ne]);const Te=Ot(B=>ge?B.getDirectoryState(ge):void 0),Le=Ot(B=>Me&&Me!==ge?B.getDirectoryState(Me):void 0),_e=c.useMemo(()=>{const B=ge?[{directory:ge,state:Te}]:[];return Me&&Me!==ge&&B.push({directory:Me,state:Le}),B},[Te,ge,Me,Le]),P=c.useMemo(()=>{const B=ge?[ge]:[];return Me&&Me!==ge&&B.push(Me),B},[ge,Me]),oe=c.useCallback(B=>B.id!==Us&&B.runIn==="parent"&&Me||ge,[ge,Me]),V=c.useCallback((B,Se,Fe)=>`${B}::${Se}::${Fe}`,[]),Q=c.useCallback((B,Se,Fe=Ot.getState())=>B?Fe.getDirectoryState(B)?.tabs.find($=>$.purpose.type==="project-action"&&$.purpose.actionId===Se)??null:null,[]),ue=c.useMemo(()=>{const B={};for(const{directory:Se,state:Fe}of _e)for(const $ of Fe?.tabs??[]){if($.purpose.type!=="project-action"||!$.purpose.executionId||!$.terminalSessionId||$.lifecycle==="idle"||$.lifecycle==="exited")continue;const se=Vs(Se,$.purpose.actionId),we=V(Se,$.purpose.actionId,$.purpose.executionId);B[se]={directory:Se,actionId:$.purpose.actionId,tabId:$.id,sessionId:$.terminalSessionId,executionId:$.purpose.executionId,status:$.lifecycle==="stopping"?"stopping":pe[we]?"waiting-for-preview":"running"}}return B},[V,pe,_e]),Z=c.useCallback((B,Se,Fe)=>{const $=Vs(B,Se),se=V(B,Se,Fe),tt=Y.current[$]?.executionId===Fe,rt=globalThis.window,Xe=G=>{rt?.clearTimeout(be.current[G]),delete be.current[G]};tt&&(delete Y.current[$],Xe($)),me.current[se]?.(),delete me.current[se],Xe(se),je(G=>{if(!G[se])return G;const Ce={...G};return delete Ce[se],Ce})},[V]),ee=c.useCallback(B=>{me.current[B]?.(),delete me.current[B]},[]),ke=c.useCallback(B=>{window.clearTimeout(be.current[B]),delete be.current[B]},[]);c.useEffect(()=>{const B=me.current,Se=be.current;return()=>{for(const Fe of Object.keys(B))ee(Fe);for(const Fe of Object.keys(Se))ke(Fe)}},[ke,ee]),c.useEffect(()=>{const B=new Set(P);for(const Se of Object.values(Y.current))B.has(Se.directory)||Z(Se.directory,Se.actionId,Se.executionId);for(const Se of Object.keys(me.current)){const Fe=Se.split("::",1)[0]??"";B.has(Fe)||ee(Se)}},[Z,ee,P]);const ne=c.useCallback((B,Se)=>{ve.getState().openContextPanelTab(B,{mode:"terminal",targetDirectory:Se===B?null:Se})},[]),q=c.useMemo(()=>U?M.find(B=>B.id===U)??null:null,[M,U]),ie=c.useMemo(()=>({id:Us,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),Ee=!p,Ae=c.useMemo(()=>Ee?[ie,...M]:M,[M,ie,Ee]);c.useEffect(()=>{H()},[H]),c.useEffect(()=>{const B=P.map(Se=>Mi(a,Se,E,Fe=>N(Se,Fe.sessions,{startedActionMutationRevisions:Fe.startedActionMutationRevisions})));return()=>{for(const Se of B)Se()}},[E,N,a,P]),c.useEffect(()=>{for(const{directory:B,state:Se}of _e)if(B)for(const Fe of Se?.tabs??[]){if(Fe.purpose.type!=="project-action")continue;const $=Fe.purpose.actionId,se=Ae.find(rt=>rt.id===$),we=se?.name??$,tt=se?.icon||"play";Fe.label!==we&&C(B,Fe.id,we),Fe.iconKey!==tt&&R(B,Fe.id,tt)}},[Ae,R,C,_e]),c.useEffect(()=>{const B=globalThis.window;if(!B)return;const Se=Fe=>{const $=Fe.detail;he&&($?.projectId&&$.projectId!==he||H())};return B.addEventListener(bl,Se),()=>{B.removeEventListener(bl,Se)}},[H,he]),c.useEffect(()=>{U&&(U===Us&&Ee||M.some(B=>B.id===U)||z(null))},[M,Ee,U]),c.useEffect(()=>{const B=Fe=>{delete be.current[Fe];const $=Y.current[Fe];if(!$||$.openedUrl)return;const se=V($.directory,$.actionId,$.executionId),we=$.announced;if(we.length!==0){if(window.clearTimeout(be.current[se]),delete be.current[se],$.openedUrl=!0,je(tt=>{if(!tt[se])return tt;const rt={...tt};return delete rt[se],rt}),we.length===1){mi($.directory,[]),A($.directory,$.tabId,we[0],{locked:!1,autoOpened:!0}),S($.directory,we[0]);return}$.offering=!0,mi($.directory,we),ve.getState().openContextSurface($.directory,"browser"),We.info(o("projectActions.toast.multipleServers"))}},Se=()=>{const Fe=Ot.getState(),$=Fe.sessions,se=ue;for(const[we,tt]of Object.entries(se)){const Xe=$.get(tt.directory)?.tabs.find(Ue=>Ue.id===tt.tabId);if(!Xe||Xe.terminalSessionId!==tt.sessionId){Z(tt.directory,tt.actionId,tt.executionId);continue}const G=Y.current[we],Ce=G?.executionId===tt.executionId?G:{hostDirectory:Ie.current||tt.directory,directory:tt.directory,tabId:tt.tabId,actionId:tt.actionId,executionId:tt.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};Y.current[we]=Ce;const bt=Ae.find(Ue=>Ue.id===tt.actionId),xe=Fe.getBuffer(tt.directory,tt.tabId).chunks;if(!bt||xe.length===0)continue;const xt=xe.filter(Ue=>Ce.lastSeenChunkId===null||Ue.id>Ce.lastSeenChunkId);if(xt.length===0)continue;const Mt=xt.map(Ue=>Ue.data).join(""),pt=`${Ce.tail}${Mt}`;for(const Ue of Km(pt))Ce.proxiedPorts.includes(Ue)||Ce.proxiedPorts.push(Ue);if(Ce.openInPreview&&(!Ce.openedUrl||Ce.offering)){const Ue=zm(pt,{proxiedPorts:Ce.proxiedPorts,namedAddressesReachable:!xl()}),lt=Ce.announced.length;for(const ft of Ue)Ce.announced.includes(ft)||Ce.announced.push(ft);const et=Ce.announced.length-lt;Ce.offering&&et>0?mi(tt.directory,Ce.announced):!Ce.openedUrl&<===0&&Ce.announced.length>0&&(window.clearTimeout(be.current[we]),be.current[we]=window.setTimeout(()=>B(we),Hy))}const at=!Ce.openedUrl&&bt.autoOpenUrl===!0&&!Ce.openInPreview?Vm(pt,{proxiedPorts:Ce.proxiedPorts,namedAddressesReachable:!xl()}):null,Be=xt[xt.length-1]?.id??Ce.lastSeenChunkId;if(Ce.lastSeenChunkId=Be,Ce.tail=pt.slice(-512),at)if(Ce.openedUrl=!0,Ce.openInPreview){const Ue=se[we];Ue&&(A(Ue.directory,Ue.tabId,at,{locked:!1,autoOpened:!1,expectedExecutionId:Ue.executionId}),Ue.status==="waiting-for-preview"&&je(lt=>{const et=V(Ue.directory,Ue.actionId,Ue.executionId);if(!lt[et])return lt;const ft={...lt};return delete ft[et],ft}),window.clearTimeout(be.current[we]),delete be.current[we],S(Ue.directory,at))}else fe(at),We.success(o("projectActions.toast.openedUrlFromOutput"));Y.current[we]=Ce}for(const we of Object.keys(Y.current))if(!se[we]){const tt=Y.current[we],rt=tt?$.get(tt.directory)?.tabs.find(G=>G.id===tt.tabId):void 0;if(rt?.purpose.type==="project-action"&&rt.purpose.executionId===tt?.executionId&&!!rt.terminalSessionId&&rt.lifecycle!=="idle"&&rt.lifecycle!=="exited")continue;delete Y.current[we],window.clearTimeout(be.current[we]),delete be.current[we]}};return Se(),Ot.subscribe((Fe,$)=>{(Fe.sessions!==$.sessions||Fe.buffers!==$.buffers)&&Se()})},[Z,Ie,Ae,V,S,fe,ue,A,o]),c.useEffect(()=>{for(const{directory:B,state:Se}of _e)for(const Fe of Se?.tabs??[]){if(Fe.purpose.type!=="project-action"||!Fe.purpose.executionId||!Fe.terminalSessionId||Fe.lifecycle!=="running")continue;const $=Fe.purpose.actionId,se=Fe.purpose.executionId,we=V(B,$,se);if(me.current[we])continue;const tt=a.connect(Fe.terminalSessionId,{onEvent:rt=>{if(!D(B,Fe.id,se))return;rt.type==="snapshot"&&(Ot.getState().replaceBuffer(B,Fe.id,rt.data??"",rt.sequence??0,cl(rt)),rt.status==="running"&&Ot.getState().setTabLifecycle(B,Fe.id,"running",{expectedExecutionId:se}),rt.status==="exited"&&(Ot.getState().setTabLifecycle(B,Fe.id,"exited",{expectedExecutionId:se}),Ot.getState().setTabPurpose(B,Fe.id,{type:"project-action",actionId:$,executionId:null}),Z(B,$,se)));const Xe=rt.type==="data"?rt.data??"":"";Xe&&Ot.getState().appendToBuffer(B,Fe.id,Xe,rt.sequence,rt.replayData),rt.type==="exit"&&(Ot.getState().setTabLifecycle(B,Fe.id,"exited",{expectedExecutionId:se}),Ot.getState().setTabPurpose(B,Fe.id,{type:"project-action",actionId:$,executionId:null}),Z(B,$,se))},onError:(rt,Xe)=>{!Xe||!D(B,Fe.id,se)||(Ot.getState().setTabLifecycle(B,Fe.id,"exited",{expectedExecutionId:se}),Ot.getState().setTabSessionId(B,Fe.id,null,{expectedExecutionId:se}),Ot.getState().setTabPurpose(B,Fe.id,{type:"project-action",actionId:$,executionId:null}),Z(B,$,se))}},B);me.current[we]=tt.close}},[Z,V,D,a,_e]);const $e=c.useCallback(async B=>{const Se=oe(B);if(!Se)throw new Error(o("projectActions.error.noActiveDirectory"));const Fe=Vs(Se,B.id);j(Se);const $=Ot.getState(),se=Q(Se,B.id,$),we=se?.id??$.createTab(Se);C(Se,we,B.name),R(Se,we,B.icon||"play"),se||W(Se,we,{type:"project-action",actionId:B.id,executionId:null}),T(Se,we);const rt=Ot.getState().getDirectoryState(Se)?.tabs.find(Xe=>Xe.id===we);return{executionDirectory:Se,key:Fe,tabId:we,sessionId:rt?.terminalSessionId??null,executionId:rt?.purpose.type==="project-action"?rt.purpose.executionId:null}},[j,oe,Q,T,R,C,W,o]),Oe=c.useCallback(async B=>{if(d.isVSCode||!i&&p)return;if(!ge){We.error(o("projectActions.error.noActiveDirectoryForAction"));return}const Se=Vs(oe(B),B.id),Fe=ue[Se];if(Fe&&Fe.status==="running"||Pe.current.has(Se))return;Pe.current.add(Se);let $=null;try{const se=B.id===Us?await(async()=>{const[it,Tt]=await Promise.all([Xh({id:de?.id??"",path:ge}),Oy(ge)]),$t=await Iy(ge,it.actions,Tt);if(!$t)throw new Error(o("contextPanel.preview.noDevServer"));return{id:Us,name:o("projectActions.actions.autoDiscover"),command:$t.command,icon:"scan-2",autoOpenUrl:!0,openUrl:$t.previewUrlHint||""}})():B,we=se.autoOpenUrl===!0&&(se.openUrl||"").trim().length>0,tt=!we&&B.id!==Us,rt=Ie.current||ge,{executionDirectory:Xe,key:G,tabId:Ce}=await $e(se),bt=Fm(se.command);if(!bt)throw new Error(o("projectActions.error.failedToRunAction"));const xe=se.autoOpenUrl===!0&&m&&(se.desktopOpenSshForward||"").trim().length>0,xt=se.autoOpenUrl&&se.openUrl||"";let Mt=!1;const pt=mf(xt)?await Vy(u,xt,Xe).catch(()=>(Mt=!0,"")):xt,at=se.autoOpenUrl?Gy(pt):null,Be=se.autoOpenUrl&&m?Lm(se.desktopOpenSshForward,b):null;if(a.listSessions){const it=Q(Xe,se.id);if(it?.purpose.type==="project-action"&&it.purpose.executionId===null){const Tt=await _m(a,Xe,{captureStartedActionMutationRevisions:E});Tt&&N(Xe,Tt.sessions,{startedActionMutationRevisions:Tt.startedActionMutationRevisions})}}const Ue=Q(Xe,se.id);let lt,et;if(Ue?.lifecycle==="running"&&Ue.terminalSessionId&&Ue.purpose.type==="project-action"&&Ue.purpose.executionId)lt=Ue.terminalSessionId,et=Ue.purpose.executionId;else{const it=Ue?.purpose.type==="project-action"?Ue.purpose.executionId:null;it&&Z(Xe,se.id,it);const Tt=L(Xe,Ce,se.id);if(!Tt)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));$={directory:Xe,tabId:Ce,id:Tt},O(Xe,Ce,!0,{expectedExecutionId:Tt});const $t=await $m({terminal:a,createOptions:{cwd:Xe,shell:v,loginShell:y,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:bt,isRunStillExpected:()=>D(Xe,Ce,Tt),purpose:{type:"project-action",actionId:se.id,executionId:Tt}});if(!D(Xe,Ce,Tt)){$t.sessionId===Tt&&await a.close($t.sessionId).catch(()=>{});return}et=$t.purpose?.type==="project-action"?$t.purpose.executionId:Tt,lt=$t.sessionId,W(Xe,Ce,{type:"project-action",actionId:se.id,executionId:et}),_(Xe,Ce,lt,{expectedExecutionId:et}),O(Xe,Ce,!1,{expectedExecutionId:et})}tt&&rt&&ne(rt,Xe),Y.current[G]={hostDirectory:rt,directory:Xe,tabId:Ce,actionId:se.id,executionId:et,lastSeenChunkId:null,openedUrl:!!Be||!!at||we,tail:"",openInPreview:se.id===Us,announced:[],offering:!1,proxiedPorts:[]};const ft=V(Xe,se.id,et);O(Xe,Ce,!0,{expectedExecutionId:et});const Ct=a.connect(lt,{onEvent:it=>{if(!D(Xe,Ce,et)||it.purpose?.type==="project-action"&&it.purpose.executionId!==et)return;it.type==="snapshot"&&(Ot.getState().replaceBuffer(Xe,Ce,it.data??"",it.sequence??0,cl(it)),Ot.getState().setConnecting(Xe,Ce,!1,{expectedExecutionId:et}),it.purpose?.type==="project-action"&&Ot.getState().setTabPurpose(Xe,Ce,{type:"project-action",actionId:it.purpose.actionId,executionId:it.purpose.executionId}),it.status==="running"&&Ot.getState().setTabLifecycle(Xe,Ce,"running",{expectedExecutionId:et}),it.status==="exited"&&(Ot.getState().setTabLifecycle(Xe,Ce,"exited",{expectedExecutionId:et}),Ot.getState().setTabPurpose(Xe,Ce,{type:"project-action",actionId:se.id,executionId:null}),Z(Xe,se.id,et)));const Tt=it.type==="data"?it.data??"":"";Tt&&Ot.getState().appendToBuffer(Xe,Ce,Tt,it.sequence,it.replayData),it.type==="exit"&&(Ot.getState().setTabLifecycle(Xe,Ce,"exited",{expectedExecutionId:et}),Ot.getState().setConnecting(Xe,Ce,!1,{expectedExecutionId:et}),Ot.getState().setTabPurpose(Xe,Ce,{type:"project-action",actionId:se.id,executionId:null}),Z(Xe,se.id,et))},onError:(it,Tt)=>{D(Xe,Ce,et)&&(Ot.getState().setConnecting(Xe,Ce,!1,{expectedExecutionId:et}),Tt&&(Ot.getState().setTabLifecycle(Xe,Ce,"exited",{expectedExecutionId:et}),Ot.getState().setTabSessionId(Xe,Ce,null,{expectedExecutionId:et}),Ot.getState().setTabPurpose(Xe,Ce,{type:"project-action",actionId:se.id,executionId:null}),Z(Xe,se.id,et)))}},Xe);if(!D(Xe,Ce,et)){Ct.close();return}me.current[ft]?.(),me.current[ft]=Ct.close,window.clearTimeout(be.current[ft]),delete be.current[ft],se.id===Us&&!at&&(je(it=>({...it,[ft]:!0})),be.current[ft]=window.setTimeout(()=>{delete be.current[ft];const it=Y.current[G];!it||it.executionId!==et||it.openedUrl||it.offering||D(Xe,Ce,et)&&(je(Tt=>{if(!Tt[ft])return Tt;const $t={...Tt};return delete $t[ft],$t}),Ot.getState().setActiveTab(Xe,Ce),ne(it.hostDirectory,Xe))},Uy)),Be?(A(Xe,Ce,null,{locked:!0,expectedExecutionId:et}),fe(Be),We.success(o("projectActions.toast.openedForwardedUrl"))):at?(A(Xe,Ce,at,{locked:!0,autoOpened:!0,expectedExecutionId:et}),S(rt,at),We.success(o("projectActions.toast.openedActionUrl"))):Mt?(A(Xe,Ce,null,{locked:!0,expectedExecutionId:et}),We.error(o("projectActions.error.openUrlTemplateUnresolved"))):we?(A(Xe,Ce,null,{locked:!0,expectedExecutionId:et}),We.error(o("projectActions.error.invalidCustomUrlFormat"))):xe?(A(Xe,Ce,null,{locked:!0,expectedExecutionId:et}),We.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):A(Xe,Ce,null,{locked:!1,autoOpened:!1,expectedExecutionId:et})}catch(se){if($&&D($.directory,$.tabId,$.id)){const{directory:we,tabId:tt,id:rt}=$;Z(we,B.id,rt),K(we,tt,"exited",{expectedExecutionId:rt}),W(we,tt,{type:"project-action",actionId:B.id,executionId:null})}if(se instanceof Error&&se.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(se instanceof Error&&(se.message==="COMMAND_MODE_UNSUPPORTED"||se.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){We.error(o("projectActions.error.failedToCreateTerminalSession"));return}We.error(se instanceof Error?se.message:o("projectActions.error.failedToRunAction"))}finally{Pe.current.delete(Se)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,Ie,b,$e,u,i,p,m,ge,y,v,fe,S,ue,ne,d.isVSCode,oe,D,Z,V,Q,N,L,E,O,K,W,A,_,de?.id,o,a]),qe=c.useCallback(async B=>{const Se=Vs(oe(B),B.id),Fe=ue[Se];Fe&&await Wm({terminal:a,sessionId:Fe.sessionId,isExecutionStillCurrent:()=>D(Fe.directory,Fe.tabId,Fe.executionId),markStopping:()=>{K(Fe.directory,Fe.tabId,"stopping",{expectedExecutionId:Fe.executionId})},restoreRunning:()=>{K(Fe.directory,Fe.tabId,"running",{expectedExecutionId:Fe.executionId})},clearSession:()=>{_(Fe.directory,Fe.tabId,null,{expectedExecutionId:Fe.executionId})},finalizeExit:()=>{K(Fe.directory,Fe.tabId,"exited",{expectedExecutionId:Fe.executionId}),W(Fe.directory,Fe.tabId,{type:"project-action",actionId:Fe.actionId,executionId:null}),Z(Fe.directory,Fe.actionId,Fe.executionId)}})},[Z,oe,D,ue,K,W,_,a]),ct=c.useCallback(()=>{const B=q??Ae[0];if(!B)return;const Se=Vs(oe(B),B.id),Fe=ue[Se];if(Fe?.status!=="stopping"){if(Fe){qe(B);return}Oe(B)}},[Ae,oe,Oe,ue,q,qe]),Ve=c.useCallback(async B=>{if(B.source==="shared"&&de){const Se=I.current?.trust.trusted?I.current:await Cl(de);if(I.current=Se,!await Jh(de,Se))return;I.current={...Se,trust:{...Se.trust,trusted:!0}}}await Oe(B)},[Oe,de]),nt=c.useCallback((B,Se=!1)=>{if(z(B.id),!Se){Ve(B);return}const Fe=Vs(oe(B),B.id),$=ue[Fe];if($?.status!=="stopping"){if($){qe(B);return}Ve(B)}},[oe,Ve,ue,qe]),kt=c.useCallback(()=>{de?.id&&(w(de.id),g("projects"),h(!0))},[h,g,w,de?.id]),dt=q??Ae[0]??null,yt=dt?ue[Vs(oe(dt),dt.id)]:null,_t=Ot(B=>yt?B.getDirectoryState(yt.directory)?.tabs.find(Se=>Se.id===yt.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&p||!de||!ge)return null;const Bt=q??Ae[0]??null;if(!Bt)return null;const Lt=gi(Bt),Rt=Vs(oe(Bt),Bt.id),Et=ue[Rt],Nt=Et?.status==="stopping",ye=Et?.status==="waiting-for-preview",He=!!(Et&&_t),mt=()=>{!Et||!_t||S(Et.directory,_t)},Ke=Bt.id===Us;return r?n.jsxs("div",{className:"inline-flex items-center",children:[n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",disabled:ce||Nt,className:De("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",s),onClick:ct,"aria-label":Et?o("projectActions.actions.stopNamedAria",{name:Bt.name}):o("projectActions.actions.runNamedAria",{name:Bt.name}),children:Nt||ye?n.jsx(F,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):Et?n.jsx(F,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):n.jsx(F,{name:Lt,className:"h-5 w-5"})})}),Ke?n.jsx(wt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),He?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.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":o("projectActions.actions.openPreview"),onClick:mt,children:n.jsx(F,{name:"global",className:"h-4 w-4"})})}),n.jsx(wt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,n.jsxs(Cs,{children:[n.jsx(js,{asChild:!0,children:n.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":o("projectActions.actions.chooseActionAria"),children:n.jsx(F,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),n.jsxs(ks,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[n.jsxs(Wt,{className:"flex items-center gap-2",onClick:kt,children:[n.jsx(F,{name:"add",className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),n.jsx(ws,{}),Ae.map(B=>{const Se=gi(B),Fe=Vs(oe(B),B.id),$=ue[Fe],se=!!$,we=$?.status==="stopping";return n.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{nt(B,!0)},children:[n.jsx(F,{name:Se,className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground truncate",children:B.name}),B.source==="shared"?n.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,we||$?.status==="waiting-for-preview"?n.jsx(F,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):se?n.jsx(F,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},B.id)})]})]})]}):n.jsxs("div",{className:De("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",s),children:[n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:ct,disabled:ce||Nt,className:De("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?o("projectActions.actions.stopNamedAria",{name:Bt.name}):o("projectActions.actions.runNamedAria",{name:Bt.name}),children:n.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:Nt||ye?n.jsx(F,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):Et?n.jsx(F,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):n.jsx(F,{name:Lt,className:"h-4 w-4"})})})}),Ke?n.jsx(wt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),He?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:mt,className:De(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":o("projectActions.actions.openPreview"),children:n.jsx(F,{name:"global",className:"h-4 w-4"})})}),n.jsx(wt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,n.jsxs(Cs,{children:[n.jsx(js,{asChild:!0,children:n.jsx("button",{type:"button",className:De(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":o("projectActions.actions.chooseActionAria"),children:n.jsx(F,{name:"arrow-down-s",className:"h-4 w-4"})})}),n.jsxs(ks,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[n.jsxs(Wt,{className:"flex items-center gap-2",onClick:kt,children:[n.jsx(F,{name:"add",className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),n.jsx(ws,{}),Ae.map(B=>{const Se=gi(B),Fe=Vs(oe(B),B.id),$=ue[Fe],se=!!$,we=$?.status==="stopping";return n.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{nt(B,!0)},children:[n.jsx(F,{name:Se,className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground truncate",children:B.name}),B.source==="shared"?n.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,we||$?.status==="waiting-for-preview"?n.jsx(F,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):se?n.jsx(F,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},B.id)})]})]})]})},Yy=t=>{const e=Ye.c(23),{directory:s,className:r,iconClassName:i}=t,{t:o}=jt(),l=ve(Qy);let a;e[0]!==s?(a=nm(s),e[0]=s,e[1]=a):a=e[1];const d=a;let u;e[2]!==d?(u=S=>Vx(d?S.journey?.get(d):void 0),e[2]=d,e[3]=u):u=e[3];const f=po(u);let p;e[4]!==d?(p=S=>d?S.actions.get(d)?.kind==="running":!1,e[4]=d,e[5]=p):p=e[5];const m=po(p);if(!l||!d||!f||_s())return null;let b;e[6]!==o?(b=o("spaces.header.apply"),e[6]=o,e[7]=b):b=e[7];const x=b;let v;e[8]!==d?(v=()=>po.getState().openApplyDialog(d),e[8]=d,e[9]=v):v=e[9];let y;e[10]!==i?(y=n.jsx(F,{name:"git-merge",className:i}),e[10]=i,e[11]=y):y=e[11];let g;e[12]!==m||e[13]!==r||e[14]!==x||e[15]!==v||e[16]!==y?(g=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":x,disabled:m,onClick:v,className:r,children:y})}),e[12]=m,e[13]=r,e[14]=x,e[15]=v,e[16]=y,e[17]=g):g=e[17];let h;e[18]!==x?(h=n.jsx(wt,{side:"bottom",children:x}),e[18]=x,e[19]=h):h=e[19];let w;return e[20]!==g||e[21]!==h?(w=n.jsxs(vt,{children:[g,h]}),e[20]=g,e[21]=h,e[22]=w):w=e[22],w};function Qy(t){return t.isolatedSpacesEnabled}const kr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Xy=({projects:t,worktreesByProject:e,directory:s,activeProjectId:r})=>{const i=kr(s??"");if(i){const o=ou(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function Jy(){const t=Vt(x=>x.projects),e=Vt(x=>x.activeProjectId),s=Je(x=>x.availableWorktreesByProject),r=Je(x=>x.currentSessionId),i=Zh(r??null),o=Je(x=>r?x.worktreeMetadata.get(r)?.path??"":""),l=Je(x=>x.newSessionDraft?.open?kr(x.newSessionDraft.bootstrapPendingDirectory??x.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>kr(o||""),[o]),d=c.useMemo(()=>{const x=typeof i?.directory=="string"?i.directory:"";return kr(x||"")},[i?.directory]),u=a||d||l,f=c.useMemo(()=>Xy({projects:t,worktreesByProject:s,directory:u,activeProjectId:e}),[e,u,t,s]),p=c.useMemo(()=>kr(u||f?.path||""),[u,f?.path]),m=c.useMemo(()=>f?{id:f.id,path:f.path}:null,[f]),b=c.useRef(null);return c.useEffect(()=>{m&&p&&(b.current={projectRef:m,directory:p})},[p,m]),c.useMemo(()=>m&&p?{projectRef:m,directory:p}:b.current,[m,p])}const Zy=({transform:t})=>({...t,y:0}),ew={Item:Wt,Separator:ws},tw={Item:({className:t,...e})=>n.jsx(af,{className:De(cu,t),...e}),Separator:({className:t,...e})=>n.jsx(of,{className:De(lu,t),...e})},sw=t=>{const e=Ye.c(63),{tab:s,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:f}=t,{t:p}=jt(),[m,b]=c.useState(!1),[x,v]=c.useState(!1),[y,g]=c.useState(!1);let h;e[0]!==s.id?(h={id:s.id},e[0]=s.id,e[1]=h):h=e[1];const{attributes:w,listeners:S,setNodeRef:j,transform:N,transition:C,isDragging:R}=Go(h);let T;e[2]!==p||e[3]!==s.session.title?(T=s.session.title?.trim()||p("sessions.sidebar.session.untitled"),e[2]=p,e[3]=s.session.title,e[4]=T):T=e[4];const O=T,_=!i&&(m||x),W=s.id;let L;e[5]!==s.session?(L=Is(s.session),e[5]=s.session,e[6]=L):L=e[6];const K=Sa(W,L),A=iu(s.id),D=A!==null,M=au(s.id)>0&&!r&&!D,k=D||M;let I;e[7]!==d||e[8]!==y||e[9]!==r||e[10]!==m||e[11]!==o||e[12]!==s?(I=H=>({session:s.session,open:m||y,isActive:r,select:()=>o(s),closeOtherTabs:()=>d(s.id),components:H}),e[7]=d,e[8]=y,e[9]=r,e[10]=m,e[11]=o,e[12]=s,e[13]=I):I=e[13];const U=I;let z;e[14]!==N?(z=qo.Translate.toString(N),e[14]=N,e[15]=z):z=e[15];let ce;e[16]!==z||e[17]!==C?(ce={transform:z,transition:C},e[16]=z,e[17]=C,e[18]=ce):ce=e[18];const re=R&&"z-10 opacity-60";let Y;e[19]!==re?(Y=De("session-tab-slot flex h-7 w-44 shrink-0 touch-none",re),e[19]=re,e[20]=Y):Y=e[20];const me=r?"true":"false";let be;e[21]!==r?(be=r?{"data-active-session-tab":!0}:{},e[21]=r,e[22]=be):be=e[22];let Pe;e[23]!==u?(Pe=H=>u?.(H),e[23]=u,e[24]=Pe):Pe=e[24];let le;e[25]!==f||e[26]!==r||e[27]!==K||e[28]!==U||e[29]!==m||e[30]!==l||e[31]!==u||e[32]!==o||e[33]!==_||e[34]!==a||e[35]!==k||e[36]!==i||e[37]!==p||e[38]!==s||e[39]!==O||e[40]!==A?(le=n.jsx(lf,{render:H=>n.jsxs("div",{...H,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(s),onKeyDown:r?void 0:ge=>{(ge.key==="Enter"||ge.key===" ")&&(ge.preventDefault(),o(s))},onAuxClick:ge=>{ge.button===1&&(ge.preventDefault(),l(s.id))},"data-controls-open":_?"true":"false",className:De("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":De("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",_&&"bg-interactive-hover text-foreground")),children:[n.jsxs("div",{className:De("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",_&&"pr-10"),children:[n.jsx("div",{className:De("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?f:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:n.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:O})})}),K?n.jsx(F,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":p("sessions.aiRename.generating")}):k?n.jsx(du,{state:A??"unread",className:De("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",_&&"opacity-0")}):null]}),i?null:n.jsxs("div",{onClick:rw,onPointerDown:ow,className:De("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:[n.jsxs(Cs,{open:m,onOpenChange:ge=>{b(ge),ge&&v(!0)},onOpenChangeComplete:ge=>{ge||v(!1),u?.(ge)},children:[n.jsx(js,{asChild:!0,children:n.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:n.jsx(F,{name:"more",className:"size-4"})})}),n.jsx(ks,{align:"start",className:"min-w-[190px]",children:a(U(ew))})]}),n.jsx("button",{type:"button","aria-label":p("header.sessionTabs.closeTab"),onClick:()=>l(s.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(F,{name:"close",className:"size-4"})})]})]})}),e[25]=f,e[26]=r,e[27]=K,e[28]=U,e[29]=m,e[30]=l,e[31]=u,e[32]=o,e[33]=_,e[34]=a,e[35]=k,e[36]=i,e[37]=p,e[38]=s,e[39]=O,e[40]=A,e[41]=le):le=e[41];let pe,je;e[42]===Symbol.for("react.memo_cache_sentinel")?(pe={color:"var(--surface-elevated-foreground)"},je=De(Bi,"min-w-[190px]"),e[42]=pe,e[43]=je):(pe=e[42],je=e[43]);let he;e[44]!==U||e[45]!==a?(he=a(U(tw)),e[44]=U,e[45]=a,e[46]=he):he=e[46];let X;e[47]!==he?(X=n.jsx(Hi,{children:n.jsx(Gi,{className:"app-region-no-drag z-50",children:n.jsx(qi,{"data-slot":"dropdown-menu-content",style:pe,className:je,children:he})})}),e[47]=he,e[48]=X):X=e[48];let de;e[49]!==y||e[50]!==Pe||e[51]!==le||e[52]!==X?(de=n.jsxs(cf,{open:y,onOpenChange:g,onOpenChangeComplete:Pe,children:[le,X]}),e[49]=y,e[50]=Pe,e[51]=le,e[52]=X,e[53]=de):de=e[53];let fe;return e[54]!==w||e[55]!==S||e[56]!==j||e[57]!==me||e[58]!==be||e[59]!==de||e[60]!==ce||e[61]!==Y?(fe=n.jsx("div",{ref:j,style:ce,className:Y,"data-active":me,...be,...w,...S,children:de}),e[54]=w,e[55]=S,e[56]=j,e[57]=me,e[58]=be,e[59]=de,e[60]=ce,e[61]=Y,e[62]=fe):fe=e[62],fe},nw=t=>{const e=Ye.c(65),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=jt(),d=Vr(iw),u=Vr(aw),f=Vr(lw),p=Vr(cw),m=Je(dw),b=Je(uw),x=gs(fw),v=Hm(m);let y,g;e[0]!==v||e[1]!==m||e[2]!==u?(y=()=>{m&&u(m,v)},g=[m,v,u],e[0]=v,e[1]=m,e[2]=u,e[3]=y,e[4]=g):(y=e[3],g=e[4]),c.useEffect(y,g);let h;if(e[5]!==x){h=new Map;for(const Ie of x)h.set(Ie.id,Ie);e[5]=x,e[6]=h}else h=e[6];const w=h;let S;if(e[7]!==w||e[8]!==d){S=[];for(const Ie of d){const Te=w.get(Ie);Te&&S.push({id:Ie,session:Te})}e[7]=w,e[8]=d,e[9]=S}else S=e[9];const j=S;let N;e[10]!==b?(N=Ie=>{b(Ie.id,Is(Ie.session))},e[10]=b,e[11]=N):N=e[11];const C=N,R=pw;let T;e[12]!==f||e[13]!==m||e[14]!==C||e[15]!==j?(T=Ie=>{if(f(Ie),m&&m!==Ie){const Te=j.find(Le=>Le.id===Ie);Te&&C(Te)}},e[12]=f,e[13]=m,e[14]=C,e[15]=j,e[16]=T):T=e[16];const O=T;let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_={activationConstraint:{distance:8}},e[17]=_):_=e[17];let W;e[18]===Symbol.for("react.memo_cache_sentinel")?(W={activationConstraint:{delay:200,tolerance:6}},e[18]=W):W=e[18];const L=Ko(un(Vo,_),un(zo,W));let K;e[19]!==p?(K=Ie=>{const{active:Te,over:Le}=Ie;Le&&Te.id!==Le.id&&p(String(Te.id),String(Le.id))},e[19]=p,e[20]=K):K=e[20];const A=K,D=c.useRef(null);let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E={left:!1,right:!1},e[21]=E):E=e[21];const[M,k]=c.useState(E);let I;e[22]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{const Ie=D.current;if(!Ie)return;const Te=Ie.scrollLeft>2,Le=Ie.scrollLeft+Ie.clientWidth<Ie.scrollWidth-2;k(_e=>_e.left===Te&&_e.right===Le?_e:{left:Te,right:Le})},e[22]=I):I=e[22];const U=I;let z;e[23]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{U();const Ie=D.current;if(!Ie||!globalThis.ResizeObserver)return;const Te=new ResizeObserver(U);return Te.observe(Ie),()=>Te.disconnect()},e[23]=z):z=e[23];let ce;e[24]!==j.length?(ce=[U,j.length],e[24]=j.length,e[25]=ce):ce=e[25],c.useEffect(z,ce);let re;e[26]===Symbol.for("react.memo_cache_sentinel")?(re=()=>{D.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[26]=re):re=e[26];let Y;e[27]!==m?(Y=[m],e[27]=m,e[28]=Y):Y=e[28],c.useEffect(re,Y);const me=M.left&&M.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":M.left?"linear-gradient(to right, transparent, black 24px)":M.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let be;e[29]!==j?(be=j.map(mw),e[29]=j,e[30]=be):be=e[30];const Pe=be;let le;e[31]!==m||e[32]!==j?(le=!m||!j.some(Ie=>Ie.id===m),e[31]=m,e[32]=j,e[33]=le):le=e[33];const pe=le;let je;e[34]!==a?(je=a("header.sessionTabs.stripAria"),e[34]=a,e[35]=je):je=e[35];let he;e[36]!==me?(he=me?{maskImage:me,WebkitMaskImage:me}:void 0,e[36]=me,e[37]=he):he=e[37];let X;e[38]===Symbol.for("react.memo_cache_sentinel")?(X=[Zy],e[38]=X):X=e[38];let de;e[39]!==o||e[40]!==m||e[41]!==O||e[42]!==C||e[43]!==r||e[44]!==s||e[45]!==l||e[46]!==j?(de=j.map(Ie=>n.jsx(sw,{tab:Ie,isActive:Ie.id===m,suppressControls:Ie.id===m&&l,onSelect:C,onClose:R,renderMenu:s,closeOtherTabs:O,onMenuOpenChangeComplete:r,children:Ie.id===m?o:null},Ie.id)),e[39]=o,e[40]=m,e[41]=O,e[42]=C,e[43]=r,e[44]=s,e[45]=l,e[46]=j,e[47]=de):de=e[47];let fe;e[48]!==de||e[49]!==Pe?(fe=n.jsx(La,{items:Pe,strategy:Yx,children:de}),e[48]=de,e[49]=Pe,e[50]=fe):fe=e[50];let H;e[51]!==A||e[52]!==L||e[53]!==fe?(H=n.jsx(Uo,{sensors:L,collisionDetection:Ho,modifiers:X,onDragEnd:A,children:fe}),e[51]=A,e[52]=L,e[53]=fe,e[54]=H):H=e[54];let ge;e[55]!==o||e[56]!==pe?(ge=pe?n.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:n.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[55]=o,e[56]=pe,e[57]=ge):ge=e[57];let Me;e[58]!==he||e[59]!==H||e[60]!==ge?(Me=n.jsxs("div",{ref:D,onScroll:U,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:he,children:[H,ge]}),e[58]=he,e[59]=H,e[60]=ge,e[61]=Me):Me=e[61];let Ne;return e[62]!==je||e[63]!==Me?(Ne=n.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":je,children:Me}),e[62]=je,e[63]=Me,e[64]=Ne):Ne=e[64],Ne};function rw(t){return t.stopPropagation()}function ow(t){return t.stopPropagation()}function iw(t){return t.tabIds}function aw(t){return t.ensureTab}function lw(t){return t.closeOtherTabs}function cw(t){return t.reorderTabs}function dw(t){return t.currentSessionId}function uw(t){return t.setCurrentSession}function fw(t){return t.activeSessions}function pw(t){eg(t)}function mw(t){return t.id}function sc(t){const e=Ye.c(20),{sessionId:s,onArchive:r,Item:i}=t,{t:o}=jt();let l;e[0]!==s?(l=g=>!!g.entityById.get(s)?.time.archived,e[0]=s,e[1]=l):l=e[1];const a=gs(l),d=Je(hw);let u;e[2]!==s||e[3]!==o||e[4]!==d?(u=async()=>{await d(s)?We.success(o("sessions.sidebar.session.restore.success")):We.error(o("sessions.sidebar.session.restore.error"))},e[2]=s,e[3]=o,e[4]=d,e[5]=u):u=e[5];const f=u;let p;e[6]!==a||e[7]!==r||e[8]!==f?(p=a?()=>{f()}:r,e[6]=a,e[7]=r,e[8]=f,e[9]=p):p=e[9];const m=a?"inbox-unarchive":"inbox-archive";let b;e[10]!==m?(b=n.jsx(F,{name:m,className:"mr-1 size-4"}),e[10]=m,e[11]=b):b=e[11];const x=a?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let v;e[12]!==o||e[13]!==x?(v=o(x),e[12]=o,e[13]=x,e[14]=v):v=e[14];let y;return e[15]!==i||e[16]!==p||e[17]!==b||e[18]!==v?(y=n.jsxs(i,{onClick:p,children:[b,v]}),e[15]=i,e[16]=p,e[17]=b,e[18]=v,e[19]=y):y=e[19],y}function hw(t){return t.unarchiveSession}const gf=async t=>{const{entry:e,session:s}=t,r=Qt(),i={sessionId:s.id,sessionTitle:s.title,directory:s.directory};if(!(tg(e.action)&&sg(e.guest,"conversation"))){await Nl(e,Al(e.action.id,i),t.t,r);return}let l=!1;const a=Or(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Nl(e,Al(e.action.id,i,d),t.t,r)}};function Xi(t){const e=Ye.c(16),{sessionID:s,directory:r,open:i,Item:o}=t,{t:l}=jt(),{pending:a,disabled:d,hint:u,run:f}=Gm(s,r,i),p=a?"loader-4":"ai-generate-2",m=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let b;e[0]!==p||e[1]!==m?(b=n.jsx(F,{name:p,className:m}),e[0]=p,e[1]=m,e[2]=b):b=e[2];let x;e[3]!==l?(x=l("sessions.aiRename.action"),e[3]=l,e[4]=x):x=e[4];let v;e[5]!==o||e[6]!==d||e[7]!==f||e[8]!==b||e[9]!==x?(v=n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"block",children:n.jsxs(o,{disabled:d,onClick:f,className:"w-full",children:[b,x]})})}),e[5]=o,e[6]=d,e[7]=f,e[8]=b,e[9]=x,e[10]=v):v=e[10];let y;e[11]!==u?(y=n.jsx(wt,{side:"right",children:u}),e[11]=u,e[12]=y):y=e[12];let g;return e[13]!==v||e[14]!==y?(g=n.jsxs(vt,{children:[v,y]}),e[13]=v,e[14]=y,e[15]=g):g=e[15],g}const Ji=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class bf extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const Yo=Lr(()=>({pendingSessionIds:new Set})),xf=t=>{const e=Ye.c(2);let s;return e[0]!==t?(s=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=s):s=e[1],Yo(s)},nc=(t,e)=>{Yo.setState(s=>{if(s.pendingSessionIds.has(t)===e)return s;const r=new Set(s.pendingSessionIds);return e?r.add(t):r.delete(t),{...s,pendingSessionIds:r}})},gw=async(t,e)=>{try{const d=(await lg(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const s=ut(t),r=ut(e)??e,i=Je.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>ut(a.path)===s)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},rc=t=>{for(const e of t){const s=rg(e.id);if(s==="unknown")throw new Error("Session status is unavailable");if(s==="active")throw new Error("Session is not idle")}};class bw extends Error{constructor(e,s){super(e,{cause:s}),this.name="IncompleteRollbackError"}}const xw=(t,e)=>{const s=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new bw(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${s}`,{moveError:t,rollbackFailures:e})},yw=async(t,e,s,r)=>{const i=[];for(const o of[...t].reverse()){if(og(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await uu(o,s,e),Je.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i},oc=async(t,e,s)=>{try{await pu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${s.message}`)}throw s},ic=async(t,e)=>{const s=e?[t,e]:[t];try{await ja(s)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},yf=async(t,e)=>{if(Yo.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");nc(t.root.id,!0);try{const s=[...t.descendants,t.root],r=new Map(s.map(a=>[a.id,Je.getState().getWorktreeMetadata(a.id)]));rc(s);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of s.entries()){rc(s.slice(a));try{await uu(d,t.sourceDirectory,i.directory)}catch(u){throw ng(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&Je.getState().setWorktreeMetadata(d.id,Pl(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await yw(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await ic(t.sourceDirectory,i?.directory),u.length>0)throw xw(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new bf(d):d}return Je.getState().setWorktreeMetadata(t.root.id,Pl(i.metadata)),await ic(t.sourceDirectory,i.directory),i.directory}finally{nc(t.root.id,!1)}},ww=async t=>{const e=ut(t.sourceDirectory)??t.sourceDirectory,s=ut(t.destination.path)??t.destination.path;if(e===s)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return yf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},vw=async t=>yf(t,async()=>{const e=Fi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const s=await fu(t.sourceDirectory)?await gw(t.sourceDirectory,e.path):null,r=await ig(e,s?{startRef:s}:{});try{await ag(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return oc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>oc(e,r,i)}}),Sw=t=>{(t.kind==="existing"?ww({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):vw({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>We.success(t.messages.success)).catch(s=>{const r=s instanceof Error?s:new Error(String(s));We.error(t.messages.failure,{description:r instanceof bf?t.messages.outcomeUnknown:r.message})})},Zi=t=>{Yo.getState().pendingSessionIds.has(t.root.id)||Sw(t)},or="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",jw=c.memo(function(e){const s=Ye.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:f}=e,p=r===void 0?!0:r,m=f===void 0?!1:f;if(!p)return null;const b=a??or,x=m&&"bg-interactive-selection text-interactive-selection-foreground";let v;s[0]!==b||s[1]!==x?(v=De(b,x),s[0]=b,s[1]=x,s[2]=v):v=s[2];const y=u??"h-[18px] w-[18px]";let g;s[3]!==d||s[4]!==y?(g=n.jsx(F,{name:d,className:y}),s[3]=d,s[4]=y,s[5]=g):g=s[5];let h;s[6]!==o||s[7]!==l||s[8]!==m||s[9]!==v||s[10]!==g?(h=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":m,className:v,children:g})}),s[6]=o,s[7]=l,s[8]=m,s[9]=v,s[10]=g,s[11]=h):h=s[11];let w;s[12]!==i?(w=n.jsx(wt,{children:n.jsx("p",{children:i})}),s[12]=i,s[13]=w):w=s[13];let S;return s[14]!==h||s[15]!==w?(S=n.jsxs(vt,{children:[h,w]}),s[14]=h,s[15]=w,s[16]=S):S=s[16],S}),kw=c.memo(function(e){const s=Ye.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:f,remoteUpdateChecking:p,remoteUpdateError:m,onOpenRemoteUpdate:b}=e,{t:x}=jt();let v;s[0]!==d||s[1]!==a?(v=W=>{a(W),W&&d()},s[0]=d,s[1]=a,s[2]=v):v=s[2];let y;s[3]!==i||s[4]!==r||s[5]!==x?(y=r?x("header.services.openWithCurrent",{current:i}):x("header.services.open"),s[3]=i,s[4]=r,s[5]=x,s[6]=y):y=s[6];const g=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let h;s[7]!==g?(h=De(or,g),s[7]=g,s[8]=h):h=s[8];let w;s[9]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(F,{name:"server",className:"h-[18px] w-[18px]"}),s[9]=w):w=s[9];let S;s[10]!==i||s[11]!==r?(S=r?n.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,s[10]=i,s[11]=r,s[12]=S):S=s[12];let j;s[13]!==y||s[14]!==h||s[15]!==S?(j=n.jsx(St,{asChild:!0,children:n.jsx(js,{asChild:!0,children:n.jsxs("button",{type:"button","aria-label":y,className:h,children:[w,S]})})}),s[13]=y,s[14]=h,s[15]=S,s[16]=j):j=s[16];let N;s[17]!==i||s[18]!==u||s[19]!==x?(N=x("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),s[17]=i,s[18]=u,s[19]=x,s[20]=N):N=s[20];let C;s[21]!==N?(C=n.jsx(wt,{children:n.jsx("p",{children:N})}),s[21]=N,s[22]=C):C=s[22];let R;s[23]!==j||s[24]!==C?(R=n.jsxs(vt,{children:[j,C]}),s[23]=j,s[24]=C,s[25]=R):R=s[25];let T;s[26]!==o||s[27]!==r||s[28]!==l||s[29]!==b||s[30]!==p||s[31]!==m||s[32]!==f||s[33]!==a||s[34]!==x?(T=r?n.jsxs("div",{children:[o?null:n.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:x("header.services.remoteUpdate.title")}),n.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?n.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:b,children:x("header.services.remoteUpdate.actions.open")}):null]})}),n.jsx(cg,{embedded:!0,open:l,onOpenChange:Nw,onHostSwitched:()=>a(!1)})]}):null,s[26]=o,s[27]=r,s[28]=l,s[29]=b,s[30]=p,s[31]=m,s[32]=f,s[33]=a,s[34]=x,s[35]=T):T=s[35];let O;s[36]!==T?(O=n.jsx(ks,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:T}),s[36]=T,s[37]=O):O=s[37];let _;return s[38]!==l||s[39]!==v||s[40]!==R||s[41]!==O?(_=n.jsxs(Cs,{open:l,onOpenChange:v,children:[R,O]}),s[38]=l,s[39]=v,s[40]=R,s[41]=O,s[42]=_):_=s[42],_}),rn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ac=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(s=>s.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,Cw=()=>{vs("ui.header.render");const{t}=jt(),e=ve(J=>J.isSidebarOpen),s=ve(J=>J.openContextOverview),r=ve(J=>J.closeContextPanel),i=ve(J=>J.shortcutOverrides),o=ve(J=>J.sessionTabsEnabled),l=Je(J=>J.getContextUsage),a=Je(J=>!!J.newSessionDraft?.open),d=Je(J=>J.currentSessionId),u=dg(d??""),f=ug(d??""),p=xf(d??""),m=gs(Vn(c.useCallback(J=>{if(!d)return null;const ze=[...J.activeSessions,...J.archivedSessions].find(Ft=>Ft.id===d);if(!ze)return null;const Qe=ze;return{title:ze.title??null,directory:Qe.directory??null,created:ze.time?.created??null,slug:Qe.slug??null,parentId:ze.parentID??null}},[d]))),b=Vt(Vn(J=>{if(!J.activeProjectId)return null;const ze=J.projects.find(Qe=>Qe.id===J.activeProjectId);return ze?{id:ze.id,path:ze.path,label:ze.label}:null})),x=c.useMemo(()=>{if(!b)return null;const J=b.label?.trim();if(J)return J;const ze=b.path.split(/[\\/]/).filter(Boolean);return ze[ze.length-1]??null},[b]),v=rr(J=>J.loadSettings),{isMobile:y}=Tn(),g=c.useRef(null),[h,w]=c.useState(()=>typeof window>"u"?!1:pn()),S=c.useMemo(()=>Dr(),[]),j=fg(),[N,C]=c.useState(!1),R=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:T,side:O}=tf(),_=c.useMemo(()=>{if(typeof window>"u")return null;const J=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof J=="number"&&Number.isFinite(J)&&J>0)return J;if(typeof navigator>"u")return null;const ze=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ze)return null;const Qe=Number.parseInt(ze[1],10),Ft=Number.parseInt(ze[2],10);return Number.isNaN(Qe)?null:Qe===10?Ft:Qe},[]);ps.useEffect(()=>{typeof window>"u"||w(pn())},[]);const{context:W,output:L}=pg(d),K=l(W,L),[A,D]=c.useState(null),E=!d||u;ps.useEffect(()=>{if(!d){D(J=>J===null?J:null);return}if(K){D(J=>mg(J,K)?J:K);return}E&&D(J=>J===null?J:null)},[K,d,E]);const[M,k]=c.useState(!1),[I,U]=c.useState("Local"),[z,ce]=c.useState(!0),[re,Y]=c.useState(!1),[me,be]=c.useState(null),[Pe,le]=c.useState(!1),[pe,je]=c.useState(null),he=c.useMemo(()=>_s(),[]),X=ve(J=>J.workStatusPanelVisible),de=ve(J=>J.workStatusPanelEnabled),fe=ve(J=>J.setWorkStatusPanelEnabled),H=ve(J=>J.workStatusPanelFits),ge=ve(J=>J.workStatusOverlayOpen),Me=ve(J=>J.setWorkStatusOverlayOpen),Ie=de&&H||ge,Te=c.useCallback(()=>{if(de&&!H){Me(!ge);return}fe(!de)},[Me,fe,ge,de,H]),Le=!he&&!X&&!!A,_e=c.useCallback(async()=>{if(!(typeof window>"u"||!h))try{if(Lo()){U("Local"),ce(!0);return}ce(!1);const J=await _d(),ze=rm(),Qe=om([im(ze),...J.hosts]);if(Qe.id===am){U("Local"),ce(!0);return}U($d(Qe.label.trim()||"Instance"))}catch{U("Local"),ce(!0)}},[h]);ps.useEffect(()=>(_e(),Or(()=>{_e()})),[_e]);const P=c.useCallback(async()=>{if(z){be(null),je(null);return}le(!0),je(null);try{const J=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),ze=await ds(`/api/openchamber/update-check?${J.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!ze.ok)throw new Error(`Server responded with ${ze.status}`);const Qe=await ze.json();be({available:Qe.available??!1,version:Qe.version,currentVersion:Qe.currentVersion??"unknown",body:Qe.body,nextSuggestedCheckInSec:typeof Qe.nextSuggestedCheckInSec=="number"?Qe.nextSuggestedCheckInSec:void 0,packageManager:Qe.packageManager,updateCommand:Qe.updateCommand})}catch(J){be(null),je(J instanceof Error?J.message:t("header.services.remoteUpdate.error"))}finally{le(!1)}},[z,t]);c.useEffect(()=>{be(null),je(null),Y(!1)},[z,I]),c.useEffect(()=>{if(!h||z)return;const J=3e3,ze=3600*1e3;let Qe=!1,Ft=null;const zt=Kt=>{Ft=window.setTimeout(()=>{if(Qe||typeof document<"u"&&document.visibilityState!=="visible"){zt(ze);return}P().finally(()=>{Qe||zt(ze)})},Kt)};return zt(J),()=>{Qe=!0,Ft!==null&&window.clearTimeout(Ft)}},[P,z,I,h]);const oe=c.useCallback(()=>{if(me?.available){Y(!0);return}P()},[P,me?.available]);hg(),c.useEffect(()=>{v()},[v]);const V=d?m??null:null,Q=c.useRef(null),[ue,Z]=c.useState(0);c.useEffect(()=>{if(!d){Q.current&&(Q.current=null,Z(Ft=>Ft+1));return}if(V){Q.current={sessionId:d,session:V,expiresAt:Date.now()+2e3};return}const J=Q.current;if(!J||J.sessionId!==d)return;const ze=J.expiresAt-Date.now();if(ze<=0){Q.current=null,Z(Ft=>Ft+1);return}const Qe=window.setTimeout(()=>{Q.current?.sessionId===d&&(Q.current=null),Z(Ft=>Ft+1)},ze);return()=>{window.clearTimeout(Qe)}},[d,V]);const ee=(()=>{if(V)return V;if(!d)return null;const J=Q.current;return J&&J.sessionId===d&&J.expiresAt>Date.now()?J.session:null})(),ke=Je(J=>d?J.worktreeMetadata.get(d)?.path??"":""),ne=Je(J=>d?J.worktreeMetadata.get(d)?.branch?.trim()??null:null),q=mu(J=>d?J.getAttachment(d):void 0),ie=c.useMemo(()=>q?gg(q,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,q]),Ee=c.useMemo(()=>q?q.legacy?"legacy":q.degraded?"degraded":q.worktreeStatus==="pending"?"pending":q.worktreeStatus==="missing"?"missing":q.worktreeStatus==="invalid"?"invalid":q.attentionReason?"attention":null:null,[q]),Ae=c.useMemo(()=>rn(ke||""),[ke]),$e=c.useMemo(()=>{const J=typeof ee?.directory=="string"?ee.directory:"";return rn(J||"")},[ee?.directory]),Oe=Sa(d??"",$e),qe=Je(J=>J.newSessionDraft?.open?rn(J.newSessionDraft.bootstrapPendingDirectory??J.newSessionDraft.directoryOverride??""):""),ct=Je(J=>J.newSessionDraft.target),Ve=Je(J=>J.newSessionDraft.selectedProjectId),nt=Je(J=>J.currentSessionDirectory),kt=is(J=>J.homeDirectory),dt=c.useMemo(()=>Ae||$e||qe,[qe,$e,Ae]),yt=ve(c.useCallback(J=>{const ze=rn(dt||"");return ze?ac(J.contextPanelByDirectory[ze]):null},[dt])),_t=Je(J=>{const ze=rn(Ae||$e||"");if(!ze)return null;for(const Qe of J.availableWorktreesByProject.values()){const zt=Qe.find(Kt=>rn(Kt.path)===ze)?.branch?.trim();if(zt)return zt}return null}),Lt=bg(dt||null)||ne||_t,Rt=a?ct==="chat":xg($e||nt,kt),Et=!Rt&&!X&&!!(x||Lt||!a&&Ee),Nt=c.useMemo(()=>{if(!d)return x??"OpenChamber";const J=ee?.title?.trim();return J&&J.length>0?J:"Untitled Session"},[x,ee?.title,d]),ye=hu(),He=Je(J=>J.updateSessionTitle),mt=Je(J=>J.archiveSessions),Ke=Je(J=>J.deleteSessions),[B,Se]=c.useState(!1),[Fe,$]=c.useState(!1),se=c.useRef(null),[we,tt]=c.useState(""),[rt,Xe]=c.useState(null),G=c.useRef(null),Ce=c.useCallback(()=>{d&&(tt(ee?.title?.trim()||Nt),Se(!0))},[ee?.title,d,Nt]),bt=c.useRef(Ce);bt.current=Ce;const xe=c.useCallback(J=>{J&&(J.focus(),J.select())},[]);c.useEffect(()=>{if($(!1),Xe(null),d&&se.current===d){se.current=null,bt.current();return}Se(!1),tt("")},[d]);const xt=c.useCallback(async()=>{if(!d)return;const J=we.trim();J&&J!==ee?.title?.trim()&&await He(d,J),Se(!1)},[ee?.title,d,we,He]);c.useEffect(()=>{if(!B)return;const J=ze=>{const Qe=ze.target;(!Qe||!G.current?.contains(Qe))&&xt()};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[B,xt]);const Mt=c.useCallback(J=>{J&&Hn(J).then(ze=>{We[ze.ok?"success":"error"](t(ze.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>We.error(t("sessions.sidebar.session.copyId.error")))},[t]),pt=c.useCallback(async()=>{if(!d||!dt){We.error(t("sessions.sidebar.session.export.nothingToExport"));return}const J=await ye({sessionID:d,directory:dt}).catch(()=>null);if(!J){We.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(J.length===0){We.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ze=gu(J,ee?.title??null),Qe=bu(ee?.title??null);await xu(ze,Qe)||yu(ze,Qe),We.success(t("sessions.sidebar.session.export.success"))},[ee?.title,d,ye,dt,t]),at=wu(),Be=c.useMemo(()=>vu(at),[at]),Ue=c.useCallback(J=>{d&&gf({entry:J,t,session:{id:d,title:ee?.title,directory:$e??dt},loadRecords:async()=>{if(!dt)return null;try{return await ye({sessionID:d,directory:dt})}catch{return null}},onLoadFailed:()=>We.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[ee?.title,d,ye,dt,$e,t]),lt=c.useCallback(J=>Be.map(ze=>n.jsxs(J,{onClick:()=>Ue(ze),children:[n.jsx(Br,{icon:ze.icon,iconSrc:ze.iconSrc,className:"mr-1 size-4"}),ze.action.label]},`${ze.guest.id}:${ze.action.id}`)),[Be,Ue]),et=f?.type==="busy"||f?.type==="retry",ft=c.useCallback(()=>{if(!d||!$e||et||p)return;const J=gs.getState().activeSessions,ze=J.find(zt=>zt.id===d);if(!ze)return;const Qe=[],Ft=[d];for(let zt=0;zt<Ft.length;zt+=1){const Kt=Ft[zt];for(const Ut of J)Ut.parentID===Kt&&(Qe.push(Ut),Ft.push(Ut.id))}Zi({kind:"quick",root:ze,descendants:Qe,sourceDirectory:$e,messages:Ji(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,et,p,$e,t]),Ct=c.useCallback(async(J,ze)=>{const Qe=[ze,...Gd(ze,[],J==="delete")],Ft=Je.getState().currentSessionId===ze?ze:null;if(J==="delete"){const{failedIds:Ut}=await Ke(Qe);Ut.length>0?We.error(t("sessions.sidebar.session.delete.error")):We.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:zt,failedIds:Kt}=await mt(Qe);if(Kt.length>0){We.error(t("sessions.sidebar.session.archive.error"));return}We.success(t("sessions.sidebar.session.archive.success"),qm(zt,Ft,t))},[mt,Ke,t]),it=c.useCallback(async()=>{if(!rt)return;const{action:J,sessionId:ze}=rt;Xe(null),await Ct(J,ze)},[rt,Ct]),Tt=ve(J=>J.openGuestPageId),$t=ka(J=>J.guests.find(ze=>ze.id===Tt)),ss=ve(J=>J.isScheduledTasksDialogOpen),Re=ve(J=>J.isArchivePageOpen),Ze=ve(J=>J.isUsageStatsPageOpen),ot=ve(J=>J.worktreesPageProjectId),gt=ve(J=>J.isolatedSpacesEnabled?J.spacesPageProjectId:null),Dt=ve(J=>J.runOverviewKey),At=Ym(Dt),Xt=ot??gt,ns=Vt(J=>{if(!Xt)return null;const ze=J.projects.find(Qe=>Qe.id===Xt);return ze?.label?.trim()||ze?.path?.split("/").pop()||null}),Jt=c.useMemo(()=>$t?{title:$t.pageTitle??$t.name,subtitle:null}:ss?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Re?{title:t("sessions.archivePage.title"),subtitle:null}:Ze?{title:t("usageStats.title"),subtitle:null}:ot?{title:t("sessions.worktreesPage.title",{project:ns??""}),subtitle:null}:gt?{title:t("spaces.page.title",{project:ns??""}),subtitle:null}:Dt?{title:At??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[$t,Re,At,Dt,ss,Ze,gt,ns,t,ot]),bn=c.useMemo(()=>rn(dt||b?.path||""),[b?.path,dt]),rs=Jy(),nn=Ca(J=>J.planModeEnabled),Qs=Je(J=>J.isSessionPlanAvailable),as=nn&&d?Qs(d):!1,Ws=c.useRef("");c.useEffect(()=>{if(!nn||!d)return;const J=`${d||"none"}:${$e||"none"}:${ee?.created||0}:${ee?.slug||"none"}`;Ws.current!==J&&(Ws.current=J)},[nn,as,ee?.slug,ee?.created,d,$e]);const xn=c.useCallback(()=>{Rn("desktop_open_draft_mini_chat_window",{directory:Rt?"":qe,projectId:Rt?null:Ve,apiBaseUrl:fr(),clientToken:jo()}).catch(J=>{console.warn("[header] failed to open draft mini chat window",J)})},[qe,Ve,Rt]),yn=c.useCallback(()=>{if(a){xn();return}d&&Rn("desktop_open_session_mini_chat_window",{sessionId:d,directory:$e||rn(nt||"")||Ae,apiBaseUrl:fr(),clientToken:jo()}).catch(J=>{console.warn("[header] failed to open session mini chat window",J)})},[d,xn,a,nt,$e,Ae]),bs=c.useCallback(()=>{const J=rn(dt||"");if(!J)return;const ze=ve.getState().contextPanelByDirectory[J];if(ac(ze)==="context"){r(J);return}s(J)},[r,s,dt]),Ks=yt==="context",wn=or,vn=c.useMemo(()=>h&&R&&!N?"88px":j?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!h||T)&&!he?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[h,N,R,j,he,T]);ps.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",vn)},[vn]);const Ns=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",xs=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ps.useEffect(()=>{if(!h||!R){C(!1);return}let J=!1;const ze=async()=>{try{const Ft=await Rn("desktop_is_window_fullscreen");J||C(Ft===!0)}catch{J||C(!1)}},Qe=()=>{ze()};return ze(),window.addEventListener("openchamber:window-resized",Qe),()=>{J=!0,window.removeEventListener("openchamber:window-resized",Qe)}},[h,R]);const Xs=c.useMemo(()=>!h||!R||_===null?"":_>=26?"h-12":_<=15?"h-14":"",[h,R,_]),Js=c.useMemo(()=>{if(!(h&&!T||he)&&!(T&&O==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[h,he,T,O]),zs=c.useCallback(()=>{if(typeof document>"u")return;const J=g.current?.getBoundingClientRect().height;J&&document.documentElement.style.setProperty("--oc-header-height",`${J}px`)},[]);ps.useEffect(()=>{if(typeof window>"u")return;zs();const J=g.current;if(!J||typeof ResizeObserver>"u")return()=>{};let ze=0;const Qe=()=>{ze||(ze=requestAnimationFrame(()=>{ze=0,zs()}))},Ft=new ResizeObserver(Qe);return Ft.observe(J),window.addEventListener("resize",Qe),window.addEventListener("orientationchange",Qe),()=>{ze&&cancelAnimationFrame(ze),Ft.disconnect(),window.removeEventListener("resize",Qe),window.removeEventListener("orientationchange",Qe)}},[zs]),ps.useEffect(()=>{zs()},[zs,y,Xs]);const Sn=c.useCallback(async J=>{const ze=J.target;ze.closest(".app-region-no-drag")||ze.closest("button, a, input, select, textarea")||J.button===0&&h&&await lm()},[h]),$r=c.useCallback(J=>zn(Fr(J,i)),[i]);yg({rename_current_session:()=>{if(!d||y)return!1;Ce()},archive_current_session:()=>{if(!d||y||gs.getState().entityById.get(d)?.time.archived)return!1;if(ve.getState().showDeletionDialog){Xe({action:"archive",sessionId:d});return}Ct("archive",d)},toggle_services_menu:()=>{if(M){k(!1);return}k(!0),_e()}});const Zs=n.jsxs(n.Fragment,{children:[rs?n.jsx(qy,{projectRef:rs.projectRef,directory:rs.directory,className:"mr-2"}):null,n.jsx(Yy,{directory:dt,className:De(or,"mr-1 text-muted-foreground hover:text-foreground"),iconClassName:"h-[18px] w-[18px]"}),n.jsx(Qm,{directory:dt,className:De(or,"mr-1 text-muted-foreground hover:text-foreground"),iconClassName:"h-[18px] w-[18px]"}),n.jsx(py,{directory:bn,className:"mr-1"}),h?n.jsx(kw,{isDesktopApp:h,currentInstanceLabel:I,currentInstanceIsLocal:z,isDesktopServicesOpen:M,setIsDesktopServicesOpen:k,refreshCurrentInstanceLabel:_e,shortcutLabel:$r,remoteUpdateInfo:me,remoteUpdateChecking:Pe,remoteUpdateError:pe,onOpenRemoteUpdate:oe}):null]}),te=S&&(a||!!d),Ge=c.useCallback(({session:J,open:ze,isActive:Qe,select:Ft,closeOtherTabs:zt,components:Kt})=>{const{Item:Ut,Separator:As}=Kt,Rs=Qe&&!he&&!Rt&&ee&&!ee.parentId;return n.jsxs(n.Fragment,{children:[n.jsxs(Ut,{onClick:()=>{Qe||Ft(),se.current=J.id},children:[n.jsx(F,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),n.jsx(Xi,{sessionID:J.id,directory:J.directory,open:ze,Item:Ut}),n.jsxs(Ut,{onClick:()=>Mt(J.id),children:[n.jsx(F,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),n.jsx(As,{}),Qe?n.jsxs(Ut,{onClick:()=>{pt()},children:[n.jsx(F,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,Qe?lt(Ut):null,Rs?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"block",children:n.jsxs(Ut,{disabled:!$e||et||p,onClick:ft,className:"w-full",children:[n.jsx(F,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),n.jsx(wt,{side:"right",className:"max-w-72",children:t(p?"sessions.sidebar.session.moveToWorktree.tooltipMoving":et?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,n.jsx(As,{}),n.jsxs(Ut,{onClick:zt,children:[n.jsx(F,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),n.jsx(As,{}),n.jsx(sc,{sessionId:J.id,Item:Ut,onArchive:()=>Xe({action:"archive",sessionId:J.id})}),n.jsxs(Ut,{className:"text-destructive focus:text-destructive",onClick:()=>Xe({action:"delete",sessionId:J.id}),children:[n.jsx(F,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Mt,ee,pt,Rt,et,p,he,ft,lt,$e,t]),st=()=>n.jsxs("div",{onMouseDown:Sn,className:De("app-region-drag relative flex h-12 select-none items-center",T&&O==="right"?"pr-0":"pr-3",Xs),style:Js,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.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:Ns}}),n.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}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Jt?n.jsxs(n.Fragment,{children:[n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ht,{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:()=>ve.getState().closeMainSurfaces(),children:n.jsx(F,{name:"arrow-left",className:"size-[18px]"})})}),n.jsx(wt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),n.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[n.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Jt.title}),Jt.subtitle?n.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Jt.subtitle}):null]})]}):he||!o?n.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:[Oe?n.jsx(F,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:n.jsx(Xl,{align:"start",children:n.jsx("button",{type:"button",className:wn,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(F,{name:"history",className:"h-[18px] w-[18px]"})})}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[B?n.jsxs("form",{ref:G,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:J=>J.stopPropagation(),onSubmit:J=>{J.preventDefault(),xt()},children:[n.jsx("input",{ref:xe,value:we,onChange:J=>tt(J.target.value),onKeyDown:J=>Ti(J,()=>Se(!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"}),n.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:n.jsx(F,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Se(!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:n.jsx(F,{name:"close",className:"size-4"})})]}):a?null:n.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Nt}),Et?n.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[x?n.jsx("span",{className:"truncate",children:x}):null,Lt?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(F,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),n.jsx("span",{className:"truncate",children:Lt})]}):null,!a&&Ee?n.jsxs("span",{className:De("inline-flex min-w-0 items-center gap-0.5",Ee==="attention"||Ee==="invalid"||Ee==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[n.jsx(F,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:ie})]}):null]}):null]}),n.jsx("div",{className:De("flex h-[18px] shrink-0 items-center justify-center",Et?"self-start":"self-center"),children:d&&!a&&!B?n.jsxs(Cs,{open:Fe,onOpenChange:$,onOpenChangeComplete:J=>{!J&&se.current&&se.current===d&&(se.current=null,Ce())},children:[n.jsx(js,{asChild:!0,children:n.jsx(ht,{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:n.jsx(F,{name:"more",className:"size-4"})})}),n.jsxs(ks,{align:"end",className:"min-w-[190px]",children:[n.jsxs(Wt,{onClick:()=>{se.current=d},children:[n.jsx(F,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),n.jsx(Xi,{sessionID:d,directory:$e,open:Fe,Item:Wt}),n.jsxs(Wt,{onClick:()=>d&&Mt(d),children:[n.jsx(F,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),n.jsx(ws,{}),n.jsxs(Wt,{onClick:()=>{pt()},children:[n.jsx(F,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),lt(Wt),!he&&!Rt&&ee&&!ee.parentId?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"block",children:n.jsxs(Wt,{disabled:!$e||et||p,onClick:ft,className:"w-full",children:[n.jsx(F,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),n.jsx(wt,{side:"right",className:"max-w-72",children:t(p?"sessions.sidebar.session.moveToWorktree.tooltipMoving":et?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,n.jsx(ws,{}),n.jsx(sc,{sessionId:d,Item:Wt,onArchive:()=>Xe({action:"archive",sessionId:d})}),n.jsxs(Wt,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&Xe({action:"delete",sessionId:d})},children:[n.jsx(F,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):n.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:n.jsx(Xl,{align:"start",children:n.jsx("button",{type:"button",className:wn,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(F,{name:"history",className:"h-[18px] w-[18px]"})})}),n.jsx(nw,{renderMenu:Ge,suppressActiveTabControls:B,onMenuOpenChangeComplete:J=>{!J&&se.current&&se.current===d&&(se.current=null,Ce())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:B?n.jsxs("form",{ref:G,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:J=>J.stopPropagation(),onSubmit:J=>{J.preventDefault(),xt()},children:[n.jsx("input",{ref:xe,value:we,onChange:J=>tt(J.target.value),onKeyDown:J=>Ti(J,()=>Se(!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"}),n.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:n.jsx(F,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Se(!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:n.jsx(F,{name:"close",className:"size-4"})})]}):n.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):Nt})})})]}),Jt||he||!o?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Le&&A?n.jsx(Ox,{reading:Bx(A),contextLimit:A.contextLimit,outputLimit:A.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:bs,pressed:Ks,className:te?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,n.jsx(jw,{visible:te,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:yn,className:De(wn,"mr-1"),Icon:"picture-in-picture-2"}),he?null:n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":Ie,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:Te,className:De(or,"mr-1",Ie?"text-foreground":"text-muted-foreground/50"),children:n.jsx(F,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),n.jsx(wt,{side:"bottom",children:t(de&&!H?ge?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":de?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),Zs,n.jsx(sf,{visible:T&&O==="right",position:"right"})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:g,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:st()}),n.jsx(Ds,{open:rt!==null,onOpenChange:J=>{J||Xe(null)},children:n.jsxs(Es,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(Gs,{children:[n.jsx(qs,{children:rt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),n.jsx(Ys,{children:rt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Nt}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Nt})})]}),n.jsxs(qn,{children:[n.jsx(ht,{variant:"outline",size:"sm",onClick:()=>Xe(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ht,{variant:"destructive",size:"sm",onClick:()=>{it()},children:rt?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),n.jsx(qd,{open:re,onOpenChange:Y,info:me,downloading:!1,downloaded:!1,progress:null,error:pe,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function Nw(){}const lc=280,cc=264,dc=500,Aw=({isOpen:t,isMobile:e,children:s,className:r,topBar:i})=>{const{t:o}=jt(),l=ve(C=>C.sidebarWidth),a=ve(C=>C.setSidebarWidth),[d,u]=c.useState(!1),f=c.useRef(0),p=c.useRef(l||lc),m=c.useRef(null),b=c.useRef(null),x=c.useRef(null),v=c.useCallback(C=>Math.min(dc,Math.max(cc,C)),[]),y=c.useCallback(C=>{const R=x.current;R&&(R.style.width=`${C}px`,R.style.minWidth=`${C}px`,R.style.maxWidth=`${C}px`,R.style.setProperty("--oc-left-sidebar-width",`${C}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(m.current=null,b.current=null)},[d]),e)return null;const g=Math.min(dc,Math.max(cc,l||lc)),h=t?g:0,w=C=>{if(t){try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}b.current=C.pointerId,u(!0),f.current=C.clientX,p.current=h,m.current=h,y(h),C.preventDefault()}},S=C=>{if(e||!d||b.current!==C.pointerId)return;const R=C.clientX-f.current,T=v(p.current+R);m.current!==T&&(m.current=T,y(T))},j=C=>{if(b.current!==C.pointerId||e)return;try{C.currentTarget.releasePointerCapture(C.pointerId)}catch{}const R=v(m.current??h);b.current=null,m.current=null,u(!1),a(R)},N=d?m.current??h:h;return n.jsxs("aside",{ref:x,className:De("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":`${d?N:g}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||h===0,children:[t&&n.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&&n.jsx("div",{className:De("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:S,onPointerUp:j,onPointerCancel:j,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),n.jsxs("div",{className:De("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",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,n.jsx(gn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:n.jsx(hs,{children:s})})]})]})},Pw=()=>{const t=Ye.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 s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=s):s=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[s,n.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),n.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},Gr="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=Ye.c(37),{t:e}=jt(),s=ve(Dw),r=ve(Ew),i=ve(Rw),o=c.useRef(null),l=zn(Fr("toggle_sidebar",i)),a=Mw,{usesFramelessChrome:d,side:u}=tf(),f=Ow;let p,m;t[0]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{if(typeof document>"u")return;const A=o.current;if(!A)return;const D=()=>{const M=Math.max(A.getBoundingClientRect().width,A.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(M)}px`)};if(D(),typeof ResizeObserver>"u")return;const E=new ResizeObserver(D);return E.observe(A),()=>{E.disconnect()}},m=[],t[0]=p,t[1]=m):(p=t[0],m=t[1]),c.useEffect(p,m);const b="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let x;t[2]===Symbol.for("react.memo_cache_sentinel")?(x={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=x):x=t[2];const v="flex items-center gap-2";let y;t[3]!==d||t[4]!==u?(y=d&&u==="left"?n.jsx(sf,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=y):y=t[5];let g;t[6]!==e||t[7]!==d?(g=d?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:f,"aria-label":e("header.actions.openAppMenuAria"),className:De(Gr,"shrink-0"),children:n.jsx(F,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),n.jsx(wt,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=g):g=t[8];const h=vt;let w;t[9]!==e?(w=e("header.actions.openSessionsAria"),t[9]=e,t[10]=w):w=t[10];let S,j;t[11]===Symbol.for("react.memo_cache_sentinel")?(S=De(Gr,"shrink-0"),j=n.jsx(F,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=S,t[12]=j):(S=t[11],j=t[12]);let N;t[13]!==w||t[14]!==s?(N=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:s,"aria-label":w,className:S,children:j})}),t[13]=w,t[14]=s,t[15]=N):N=t[15];const C=wt,R=e("header.actions.openSessionsWithShortcut",{shortcut:l});let T;t[16]!==R?(T=n.jsx("p",{children:R}),t[16]=R,t[17]=T):T=t[17];let O;t[18]!==C||t[19]!==T?(O=n.jsx(C,{children:T}),t[18]=C,t[19]=T,t[20]=O):O=t[20];let _;t[21]!==h||t[22]!==N||t[23]!==O?(_=n.jsxs(h,{children:[N,O]}),t[21]=h,t[22]=N,t[23]=O,t[24]=_):_=t[24];let W;t[25]!==a||t[26]!==r||t[27]!==e?(W=r?n.jsxs("button",{type:"button",onClick:a,className:De(Gr,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[n.jsx(F,{name:"chat-new",className:"h-[18px] w-[18px]"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:De(Gr,"-ml-1 shrink-0"),children:n.jsx(F,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),n.jsx(wt,{children:n.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=W):W=t[28];let L;t[29]!==_||t[30]!==W||t[31]!==y||t[32]!==g?(L=n.jsxs("div",{ref:o,className:v,children:[y,g,_,W]}),t[29]=_,t[30]=W,t[31]=y,t[32]=g,t[33]=L):L=t[33];let K;return t[34]!==L||t[35]!==x?(K=n.jsx("div",{className:b,style:x,children:L}),t[34]=L,t[35]=x,t[36]=K):K=t[36],K};function Dw(t){return t.toggleSidebar}function Ew(t){return t.isSidebarOpen}function Rw(t){return t.shortcutOverrides}function Mw(){ve.getState().closeMainSurfaces(),Je.getState().openNewSessionDraft()}function Tw(t){console.warn("[titlebar] failed to open app menu",t)}function Ow(t){const e=t.currentTarget.getBoundingClientRect();Rn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(Tw)}function wf(t){const e=Ye.c(5),{className:s}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${s===void 0?"h-5 w-5":s}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=n.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=n.jsx(F,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=n.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const uc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Bw(t,e,s){const r=Ye.c(5),[i,o]=c.useState();let l,a;return r[0]!==s||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,f]=await Promise.all([wg(t),vg(t)]).catch(Fw);if(d)return;const p=uc(u),m=uc(f);if(!p||!m||m===p)return;const b=s||"",x=m.split("/").filter(Boolean).pop()||m;o({source:"sdk",path:m,projectDirectory:p,branch:b,label:b||x,name:x,worktreeRoot:m,worktreeStatus:"ready",headState:b?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function Fw(){return["",""]}const fc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Lw=async(t,e)=>{if(t)return t.authActivate(e);const s=await ds("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await s.json().catch(()=>null);if(!s.ok||!r)throw new Error(r?.error||s.statusText);return r},pc=({className:t})=>{const{t:e}=jt(),{github:s}=hn(),r=mn(b=>b.status),i=mn(b=>b.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async b=>{if(!(!b||o)){l(!0);try{i(await Lw(s,b))}catch(x){console.error("Failed to switch GitHub account:",x)}finally{l(!1)}}},[s,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,f=r.accounts??[],p=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),m=u?n.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(F,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return f.length<=1?n.jsx("div",{className:De(fc,t),title:p,children:m}):n.jsxs(Cs,{children:[n.jsx(js,{asChild:!0,children:n.jsx("button",{type:"button",className:De(fc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:p,disabled:o,children:m})}),n.jsxs(ks,{align:"end",className:"w-64",children:[n.jsx(nr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),n.jsx(ws,{}),f.map(b=>{const x=b.user,v=!!b.current,y=b.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return n.jsxs(Wt,{className:"gap-2",disabled:o,onSelect:()=>{v||a(b.id)},children:[x?.avatarUrl?n.jsx("img",{src:x.avatarUrl,alt:x.login?e("header.github.avatarWithLogin",{login:x.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:n.jsx(F,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:x?.name?.trim()||x?.login||"GitHub"}),x?.login?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:x.login}),n.jsx("span",{className:"mx-1 opacity-50",children:"·"}),n.jsx("span",{children:y})]}):null]}),v?n.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]},b.id)})]})]})};class Qo extends Error{code;model;requiredChars;availableChars;constructor(e,s={}){super(e),this.name="WalkthroughError",this.code=s.code,this.model=s.model,this.requiredChars=s.requiredChars,this.availableChars=s.availableChars}}const Xo="/api/walkthrough",vf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),Sf=()=>new Qo("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),_w=t=>!vf(t)&&(t.ok||t.status===404),$a=async(t,e)=>{if(_w(t))throw Sf();const s=await t.json().catch(()=>null);throw new Qo(typeof s?.error=="string"?s.error:e,{code:typeof s?.code=="string"?s.code:void 0,model:s?.model??void 0,requiredChars:typeof s?.requiredChars=="number"?s.requiredChars:void 0,availableChars:typeof s?.availableChars=="number"?s.availableChars:void 0})},jf=async t=>{if(!vf(t))throw Sf();try{return await t.json()}catch{throw new Qo("The server returned a malformed walkthrough response")}};async function $w(t,e,s={}){const r=await ds(Xo,{query:{directory:t,source:JSON.stringify(e),...s.model?{model:s.model}:{},...s.providerID?{providerID:s.providerID}:{},...s.language?{language:s.language}:{}},signal:s.signal});return r.ok?jf(r):$a(r,"Failed to load walkthrough")}async function Ww(t,e,s={}){const r=await ds(`${Xo}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:s.force===!0,...s.model?{model:s.model}:{},...s.providerID?{providerID:s.providerID}:{},...s.language?{language:s.language}:{}}),signal:s.signal});return r.ok?jf(r):$a(r,"Failed to generate walkthrough")}async function Kw(t,e){const s=await ds(`${Xo}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});s.ok||await $a(s,"Failed to cancel walkthrough generation")}async function zw(t,e,s){const r=await ds(`${Xo}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:s});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const br={status:"idle",stage:null,result:null,readiness:null,error:null},Vw=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,jn=(t,e)=>`${Qt()}\0${t}\0${Vw(e)}`,mc=t=>t instanceof Qo?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Os=new Map,xr=new Map,Uw=1e3,Hw=Lr()(Zx((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(s,r,i)=>{const o=jn(s,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(s,r)=>e().selectedLanguage[jn(s,r)],selectModel:(s,r,i)=>{const o=jn(s,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(s,r)=>e().selectedModel[jn(s,r)],requestSource:(s,r)=>{t(i=>({requestedSource:{...i.requestedSource,[s]:r}}))},clearRequestedSource:s=>{t(r=>{if(!r.requestedSource[s])return r;const i={...r.requestedSource};return delete i[s],{requestedSource:i}})},getEntry:(s,r)=>e().entries[jn(s,r)]??br,load:async(s,r,i={})=>{if(!s)return;const o=jn(s,r);if(e().entries[o]?.status==="generating")return;Os.get(o)?.abort();const a=new AbortController;Os.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??br,status:"loading",error:null}}}));try{const d=await $w(s,r,{model:e().selectedModel[o],providerID:i.providerID,language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(s,r,{language:i.language,providerID:i.providerID})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??br,status:"error",stage:null,error:mc(d)}}}))}finally{Os.get(o)===a&&Os.delete(o)}},generate:async(s,r,i={})=>{if(!s)return;const o=jn(s,r);Os.get(o)?.abort();const l=new AbortController;Os.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??br,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=xr.get(o);d!==void 0&&(clearInterval(d),xr.delete(o))};a(),xr.set(o,setInterval(()=>{zw(s,r).then(d=>{!d||l.signal.aborted||t(u=>{const f=u.entries[o];return!f||f.status!=="generating"||f.stage===d?u:{entries:{...u.entries,[o]:{...f,stage:d}}}})}).catch(()=>{})},Uw));try{const d=await Ww(s,r,{force:i.force,model:e().selectedModel[o],providerID:i.providerID,language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??br,status:"error",stage:null,error:mc(d)}}}))}finally{a(),Os.get(o)===l&&Os.delete(o)}},cancel:(s,r)=>{const i=jn(s,r);Kw(s,r).catch(()=>{}),Os.get(i)?.abort(),Os.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const s of Os.values())s.abort();Os.clear();for(const s of xr.values())clearInterval(s);xr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),Gw="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)]",qw=3e4,hc=20,kf=(t,e)=>JSON.stringify([Qt(),t,e]),Yw=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[s,r,i]=e;return typeof s!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:s,directory:r,number:i}}catch{return null}},gc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),qr=new Map,Qw=t=>{const e=Object.entries(t);return e.length<=hc?t:Object.fromEntries(e.sort(([,s],[,r])=>r.fetchedAt-s.fetchedAt).slice(0,hc))},bc=Lr()((t,e)=>({entries:{},ensure:async(s,r,i,o)=>{const l=kf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<qw&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const f=`${l}::${a?"details":"plain"}`,m=qr.get(`${l}::details`)??(a?null:qr.get(f));if(m&&!o?.force)return m;const b=(async()=>{t(x=>({entries:{...x.entries,[l]:{...x.entries[l]??gc(),isLoading:!0,error:null}}}));try{const x=await s.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(v=>({entries:Qw({...v.entries,[l]:{result:x,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),x}catch(x){const v=x instanceof Error?x.message:"Failed to load pull request context";return t(y=>({entries:{...y.entries,[l]:{...y.entries[l]??gc(),isLoading:!1,error:v}}})),null}finally{qr.delete(f)}})();return qr.set(f,b),b},invalidate:(s,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=Yw(l);d&&d.directory===s&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),Xw=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let s;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!s||o.startedAt<s)&&(s=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...s?{startedAt:s}:{}}},Jw=35e3,bi=(t,e,s)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):s??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},xi=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},xc=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"}},Zw=(t,e)=>{const{currentSessionId:s,getDirectoryForSession:r}=Je.getState(),i=s?r(s):null;!s||!i||ut(i)!==ut(t)||kg(s,i,Cg({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},ev=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const s=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="dirty";return s||i?"blocked":"open"},tv=[2e3,5e3],sv=600,yc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Nn=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):""},nv=(t,e)=>{const s=Nn(t);if(!s||s.includes("->"))return"";if(e){const i=`${e}/`;return s.startsWith(i)?s.slice(i.length).trim():""}const r=s.indexOf("/");return r>0?s.slice(r+1).trim():s},rv=(t,e)=>`${t}::${e}`,Wa=t=>{const e=String(t||"").trim();if(!e)return"";const s=e.indexOf("/");return s<=0?"":e.slice(0,s).trim()},yi=(t,e)=>{if(t.length===0)return null;const s=String(e.selectedRemoteName||"").trim();if(s){const o=t.find(l=>l.name===s);if(o)return o}const r=Wa(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},ov=t=>t.startsWith("pr-"),iv=(t,e)=>{const s=Wa(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return s&&o(r.get(s)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!ov(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},yr=new Map,Yr=Mn;function av(t,e){const[s,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:s,upstreamBranches:i}}const lv=({directory:t,branch:e,baseBranch:s,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=jt(),d=ve(te=>te.timeFormatPreference),{github:u}=hn(),f=mn(te=>te.status),p=mn(te=>te.hasChecked),m=ve(te=>te.setSettingsDialogOpen),b=ve(te=>te.setSettingsPage),x=Je(te=>te.currentSessionId),v=Je(te=>!!te.newSessionDraft?.open),{isMobile:y,hasTouchInput:g,screenWidth:h}=Tn(),w=ve(te=>te.openContextSurface),S=Hw(te=>te.requestSource),j=!y&&h>=768&&!_s(),N=c.useCallback(()=>{b("integrations"),m(!0)},[m,b]),C=c.useMemo(()=>rv(t,e),[t,e]),R=c.useMemo(()=>yr.get(C)??null,[C]),T=ys(te=>te.ensureEntry),O=ys(te=>te.setParams),_=ys(te=>te.startWatching),W=ys(te=>te.stopWatching),L=ys(te=>te.refresh),K=ys(te=>te.updateStatus),[A,D]=c.useState(()=>R?.title??yc(e)),[E,M]=c.useState(()=>R?.body??""),[k,I]=c.useState(()=>R?.draft??!1),[U,z]=c.useState(()=>R?.additionalContext??""),[ce,re]=c.useState(()=>{const te=typeof R?.targetBaseBranch=="string"?Nn(R.targetBaseBranch):"";return te||Nn(s)}),[Y,me]=c.useState("squash"),[be,Pe]=c.useState(!1),[le,pe]=c.useState(!1),[je,he]=c.useState(!1),[X,de]=c.useState(!1),[fe,H]=c.useState(!1),[ge,Me]=c.useState(!1),[Ne,Ie]=c.useState(null),[Te,Le]=c.useState(""),[_e,P]=c.useState(""),[oe,V]=c.useState(!1),[Q,ue]=c.useState(!1),[Z,ee]=c.useState(()=>yi(i,{selectedRemoteName:R?.selectedRemoteName,trackingBranch:r})),[ke,ne]=c.useState(!1),{detectedUpstream:q,upstreamBranches:ie}=av(t,u);c.useEffect(()=>{ne(!1)},[t]);const Ee=i.some(te=>te.name==="upstream"),$e=!!(t&&e&&s&&(e!==s||(Ee||q!==null))),Oe=c.useMemo(()=>_o(t,e,Z?.name??null),[t,e,Z?.name]),qe=ys(te=>te.entries[Oe]),ct=qe?.isLoading??!1,Ve=qe?.status??null,nt=qe?.error??null,kt=qe?.isInitialStatusResolved??!1,dt=c.useMemo(()=>{const te=ke?null:Z?.name?.trim()||null,Ge=new Set;for(const J of o){const ze=nv(J,te);!ze||ze==="HEAD"||Ge.add(ze)}if(ke)for(const J of ie)J&&J!=="HEAD"&&Ge.add(J);const st=Nn(s);st&&st!=="HEAD"&&Ge.add(st);const Pt=Nn(ce);return Pt&&Pt!=="HEAD"&&Ge.add(Pt),Array.from(Ge).sort((J,ze)=>J.localeCompare(ze))},[s,o,Z?.name,ce,ie,ke]);c.useEffect(()=>{if(i.length===0){Z&&ee(null);return}(!Z||!i.some(te=>te.name===Z.name))&&ee(yi(i,{selectedRemoteName:R?.selectedRemoteName,trackingBranch:r}))},[R?.selectedRemoteName,i,Z,r]),c.useEffect(()=>{const te=Nn(s);if(!ce&&te){re(te);return}if(dt.length!==0&&!dt.includes(ce)){const Ge=dt.includes(te)?te:dt[0];Ge&&re(Ge)}},[dt,s,ce]);const[yt,_t]=c.useState(()=>R?.activeSegment??"overview"),[Bt,Lt]=c.useState(new Set),[Rt,Et]=c.useState(new Set),Nt=c.useRef(new Set),ye=c.useRef(null),He=c.useRef(!1),mt=c.useRef(new Set),Ke=c.useRef([]);c.useEffect(()=>{q&&!Ee&&ne(!0)},[q,Ee]),c.useEffect(()=>{ke&&q?.defaultBranch&&re(q.defaultBranch)},[ke,q?.defaultBranch]);const B=Ve?.pr??null,Se=B?.state==="merged"||B?.state==="closed",Fe=Se?null:B,$=Fe?kf(t,Fe.number):null,se=bc(te=>$?te.entries[$]:void 0),we=bc(te=>te.ensure),tt=se?.result??null,rt=se?.isLoading??!1,Xe=c.useCallback(te=>{_t(te);const Ge=yr.get(C);Ge&&yr.set(C,{...Ge,activeSegment:te})},[C]);c.useEffect(()=>{!Fe||!u?.prContext||yt==="overview"||we(u,t,Fe.number,{includeCheckDetails:yt==="checks",sourceRepo:Ve?.repo??null})},[yt,t,we,u,Fe,Ve?.repo]);const G=Ve?.checks??null,Ce=(G?.pending??0)>0,bt=tt?.checkRuns??null,xe=tt?.fetchedAt;c.useEffect(()=>{if(!bt||bt.length===0)return;const te=Xw(bt);K(Oe,Ge=>{if(!Ge?.pr||typeof xe=="number"&&typeof Ge.fetchedAt=="number"&&xe<Ge.fetchedAt)return Ge;const st=Ge.checks;return st&&st.state===te.state&&st.total===te.total&&st.success===te.success&&st.failure===te.failure&&st.pending===te.pending&&st.inProgress===te.inProgress&&st.queued===te.queued&&st.startedAt===te.startedAt?Ge:{...Ge,checks:te,...typeof xe=="number"?{fetchedAt:xe}:{}}})},[bt,xe,Oe,K]),c.useEffect(()=>{if(yt!=="checks"||!Ce||!B||!u?.prContext)return;const te=window.setInterval(()=>{we(u,t,B.number,{includeCheckDetails:!0,sourceRepo:Ve?.repo??null,force:!0})},Jw);return()=>window.clearInterval(te)},[yt,Ce,t,we,u,B,Ve?.repo]);const[xt,Mt]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Ce)return;Mt(Date.now());const te=window.setInterval(()=>Mt(Date.now()),3e4);return()=>window.clearInterval(te)},[Ce]);const pt=B?`${t}#${B.number}`:null,at=!!(pt&&Ne===pt);c.useEffect(()=>{if(!u?.prContext||!B||typeof B.body=="string"&&B.body.length>0)return;const te=`${t}#${B.number}`;if(Nt.current.has(te))return;Nt.current.add(te),Ie(te);let Ge=!1;return we(u,t,B.number,{sourceRepo:Ve?.repo??null}).then(st=>{if(Ge)return;const Pt=st?.pr;Pt&&K(Oe,J=>!J?.pr||J.pr.number!==B.number?J:{...J,pr:{...J.pr,body:Pt.body||""}})}).catch(()=>{}).finally(()=>{Ge||Ie(st=>st===te?null:st)}),()=>{Ge=!0}},[t,we,u,B,Oe,Ve?.repo,K]),c.useEffect(()=>{if(!B){Me(!1),Le(""),P(""),ye.current=null;return}const te=ye.current!==null&&ye.current!==B.number;te&&Me(!1),(!ge||te)&&(Le(B.title||""),P(B.body||"")),ye.current=B.number},[ge,B]);const Be=c.useCallback(te=>{if(!te)return"";const Ge=Date.parse(te);return Number.isFinite(Ge)?Su(Ge,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):te},[d]),Ue=c.useMemo(()=>{const te=f?.user?.login;return typeof te=="string"?te.trim():""},[f]),lt=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),et=c.useCallback(te=>{const Ge=Ue.toLowerCase(),st=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return te.replace(st,(Pt,J,ze)=>{const Qe=`@${ze}`,Ft=ze.toLowerCase();return`${J}[${Qe}](https://github.com/${Ft}${Ge&&Ft===Ge?"?oc-self-mention=1":""})`})},[Ue]),ft=c.useMemo(()=>{const te=(tt?.issueComments??[]).map(Pt=>({id:`issue-${Pt.id}`,body:Pt.body||"",authorName:Pt.author?.name||Pt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:Pt.author?.login||null,avatarUrl:Pt.author?.avatarUrl||null,createdAt:Pt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),Ge=(tt?.reviewComments??[]).map(Pt=>({id:`review-${Pt.id}`,body:Pt.body||"",authorName:Pt.author?.name||Pt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:Pt.author?.login||null,avatarUrl:Pt.author?.avatarUrl||null,createdAt:Pt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:Pt.path||null,line:Pt.line??null})),st=[...te,...Ge];return st.sort((Pt,J)=>{const ze=Pt.createdAt?Date.parse(Pt.createdAt):0,Qe=J.createdAt?Date.parse(J.createdAt):0,Ft=Number.isFinite(ze)?ze:0,zt=Number.isFinite(Qe)?Qe:0;return Ft-zt}),st},[tt,a]),Ct=c.useCallback(()=>{const te=x??(v?"draft":null);return te?{directory:t,sessionKey:te}:(We.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[x,t,v,a]),it=c.useCallback((te,Ge)=>{const st=Ge.authorLogin?`@${Ge.authorLogin}`:Ge.authorName,Pt=Ge.path?` · ${Ge.path}${Ge.line?`:${Ge.line}`:""}`:"";Li.getState().addDraft(te,{source:"pr-comment",fileLabel:`PR #${B?.number??""} ${st}${Pt}`,startLine:Ge.line??0,endLine:Ge.line??0,code:Ge.body,language:"markdown",text:""})},[B?.number]),Tt=c.useCallback((te,Ge)=>{const st=te.status||"unknown",Pt=te.conclusion??void 0,J=Pt?`${st} / ${Pt}`:st,ze=te.app?.name||te.app?.slug;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:Ge?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[Ge?.hideHeader?null:n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"typography-ui-label text-foreground truncate",children:te.name}),n.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:ze?`${ze} · ${J}`:J})]}),te.detailsUrl?n.jsx(ht,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:n.jsxs("a",{href:te.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(F,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),te.output?.title?n.jsx("div",{className:"typography-micro text-foreground",children:te.output.title}):null,te.output?.summary?n.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:te.output.summary}):null,te.output?.text?n.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:te.output.text}):null,Array.isArray(te.annotations)&&te.annotations.length>0?n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",te.annotations.length>20?` (showing 20/${te.annotations.length})`:""]}),n.jsx("div",{className:"space-y-1",children:te.annotations.slice(0,20).map((Qe,Ft)=>n.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[n.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[Qe.title||Qe.level||"Issue",Qe.path?` · ${Qe.path}`:"",typeof Qe.startLine=="number"?`:${Qe.startLine}`:"",typeof Qe.endLine=="number"&&Qe.endLine!==Qe.startLine?`-${Qe.endLine}`:""]}),n.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:Qe.message}),Qe.rawDetails?n.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:Qe.rawDetails}):null]},`${Qe.path||"file"}:${Qe.startLine||Ft}:${Ft}`))})]}):null,te.job?.steps&&te.job.steps.length>0?n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),n.jsx("div",{className:"space-y-1",children:te.job.steps.map((Qe,Ft)=>{const zt=(Qe.conclusion||"").toLowerCase(),Kt=zt&&!["success","neutral","skipped"].includes(zt),Ut=`${te.id??"run"}:${te.job?.jobId??"job"}:${Qe.number??Ft}:${Qe.name}`,As=Bt.has(Ut);return Kt?n.jsxs(yl,{open:As,children:[n.jsxs("button",{type:"button",onClick:()=>{Lt(Rs=>{const On=new Set(Rs);return On.has(Ut)?On.delete(Ut):On.add(Ut),On})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Kt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[As?n.jsx(F,{name:"arrow-down-s",className:"size-4"}):n.jsx(F,{name:"arrow-right-s",className:"size-4"}),n.jsx("span",{className:"truncate",children:Qe.name}),Qe.conclusion?n.jsx("span",{className:"ml-auto flex-shrink-0",children:Qe.conclusion}):null]}),n.jsx(wl,{children:n.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 Qe.number=="number"?n.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",Qe.number]}):null,Qe.status?n.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",Qe.status]}):null,Qe.conclusion?n.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",Qe.conclusion]}):null,Qe.startedAt?n.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",Be(Qe.startedAt)]}):null,Qe.completedAt?n.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",Be(Qe.completedAt)]}):null]})})]},Ut):n.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[n.jsx("span",{className:"truncate",children:Qe.name}),Qe.conclusion?n.jsx("span",{className:"ml-auto flex-shrink-0",children:Qe.conclusion}):null]},Ut)})})]}):null]})},[Bt,Be,a]),[$t,ss]=c.useState(!1),[Re,Ze]=c.useState(!1),ot=c.useCallback(async()=>{if(!u?.prContext){We.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!B)return;const te=Ct();if(te){ss(!0);try{const Ge=await we(u,t,B.number,{includeCheckDetails:!0,sourceRepo:Ve?.repo??null});if(!Ge){We.error(a("gitView.pr.toast.loadChecksFailed"));return}const Pt=(Ge.checkRuns??[]).filter(ze=>xi(ze.conclusion));if(Pt.length===0){We.message(a("gitView.pr.toast.noFailedChecks"));return}const J=Li.getState();for(const ze of Pt){const Qe=(ze.annotations??[]).map(Kt=>[[Kt.level,Kt.title].filter(Boolean).join(" "),Kt.path?`${Kt.path}${typeof Kt.startLine=="number"?`:${Kt.startLine}`:""}`:null,Kt.message,Kt.rawDetails].filter(Boolean).join(`
|
|
3
|
+
`)),Ft=(ze.job?.steps??[]).filter(Kt=>xi(Kt.conclusion)).map(Kt=>`step ${Kt.number??"?"}: ${Kt.name} → ${Kt.conclusion}`),zt=[`check: ${ze.job?.workflowName?`${ze.job.workflowName} / ${ze.name}`:ze.name}`,`status: ${ze.status??"unknown"} / ${ze.conclusion??"unknown"}`,ze.detailsUrl?`url: ${ze.detailsUrl}`:null,ze.output?.title?`title: ${ze.output.title}`:null,ze.output?.summary?`summary:
|
|
4
|
+
${ze.output.summary}`:null,Ft.length>0?`failed steps:
|
|
5
|
+
${Ft.join(`
|
|
6
|
+
`)}`:null,Qe.length>0?`annotations:
|
|
7
|
+
${Qe.join(`
|
|
8
|
+
---
|
|
9
|
+
`)}`:null].filter(Boolean).join(`
|
|
10
|
+
|
|
11
|
+
`);J.addDraft(te,{source:"pr-check",fileLabel:`PR #${B.number} · ${ze.name}`,startLine:0,endLine:0,code:zt,language:"text",text:""})}}catch(Ge){const st=Ge instanceof Error?Ge.message:String(Ge);We.error(a("gitView.pr.toast.loadChecksFailed"),{description:st})}finally{ss(!1)}}},[t,we,u,B,Ct,Ve?.repo,a]),gt=c.useCallback(async()=>{if(!u?.prContext){We.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!B)return;const te=Ct();if(te){Ze(!0);try{if(!await we(u,t,B.number,{sourceRepo:Ve?.repo??null})){We.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(ft.length===0){We.message(a("gitView.pr.toast.noPrComments"));return}for(const st of ft)it(te,st)}catch(Ge){const st=Ge instanceof Error?Ge.message:String(Ge);We.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:st})}finally{Ze(!1)}}},[it,t,we,u,B,Ct,Ve?.repo,a,ft]),Dt=c.useCallback(async te=>{const Ge=Ct();Ge&&it(Ge,te)},[it,Ct]),At=c.useCallback(async te=>{await L(Oe,te)},[Oe,L]),[Xt,ns]=c.useState(!1),Jt=c.useRef(!0);c.useEffect(()=>(Jt.current=!0,()=>{Jt.current=!1}),[]);const bn=c.useCallback(async()=>{if(Xt)return;ns(!0);const te=Date.now();try{await At({force:!0})}finally{const Ge=sv-(Date.now()-te);Ge>0&&await new Promise(st=>window.setTimeout(st,Ge)),Jt.current&&ns(!1)}},[Xt,At]),rs=c.useCallback(()=>{Ke.current.forEach(te=>{window.clearTimeout(te)}),Ke.current=tv.map(te=>window.setTimeout(()=>{At({force:!0,silent:!0,markInitialResolved:!0})},te))},[At]);c.useEffect(()=>{if(!u?.prStatus||!$e||i.length<=1||He.current||Ve?.pr)return;const te=`${C}::${Z?.name??""}`;if(mt.current.has(te))return;mt.current.add(te);const Ge=iv(i,r).filter(J=>J.name!==Z?.name);if(Ge.length===0)return;let st=!1;return(async()=>{for(const J of Ge){if(st)return;try{if(!(await u.prStatus(t,e,J.name))?.pr)continue;if(st)return;ee(Qe=>Qe?.name===J.name?Qe:J);return}catch{}}})(),()=>{st=!0}},[e,$e,t,u,i,Z?.name,C,Ve?.pr,r]),c.useEffect(()=>{T(Oe),O(Oe,{directory:t,branch:e,remoteName:Z?.name??null,canShow:$e,github:u,githubAuthChecked:p,githubConnected:f?.connected??null})},[e,$e,t,T,u,p,f?.connected,Oe,Z?.name,O]),c.useEffect(()=>(_(Oe),()=>{W(Oe)}),[Oe,_,W]),c.useEffect(()=>{const te=yr.get(C)??null;D(te?.title??yc(e)),M(te?.body??""),I(te?.draft??!1),re(te?.targetBaseBranch?Nn(te.targetBaseBranch):Nn(s));const Ge=yi(i,{selectedRemoteName:te?.selectedRemoteName,trackingBranch:r});ee(st=>st?.name===Ge?.name?st:Ge)},[s,e,i,C,r]),c.useEffect(()=>{At({markInitialResolved:!0})},[Oe,At]),c.useEffect(()=>{!$e||!Z?.name||At({force:!0,silent:!0,markInitialResolved:!0})},[$e,At,Z?.name]),c.useEffect(()=>{const te=Ve?.resolvedRemoteName?.trim();if(!te||He.current)return;const Ge=i.find(st=>st.name===te);Ge&&ee(st=>st?.name===Ge.name?st:Ge)},[i,Ve?.resolvedRemoteName]),c.useEffect(()=>{const te=()=>{const st=ys.getState().entries[Oe]?.lastRefreshAt??0;Date.now()-st>6e4&&At({force:!0,silent:!0})},Ge=()=>{document.visibilityState==="visible"&&te()};return window.addEventListener("focus",te),document.addEventListener("visibilitychange",Ge),()=>{window.removeEventListener("focus",te),document.removeEventListener("visibilitychange",Ge)}},[Oe,At]),c.useEffect(()=>{p&&f?.connected===!1&&At({force:!0,silent:!0,markInitialResolved:!0})},[p,f,At]),c.useEffect(()=>{!t||!e||yr.set(C,{title:A,body:E,draft:k,additionalContext:U,targetBaseBranch:ce,selectedRemoteName:Z?.name,activeSegment:yt})},[C,A,E,k,U,ce,Z?.name,t,e,yt]),c.useEffect(()=>{const te=Ke.current;return()=>{te.forEach(Ge=>{window.clearTimeout(Ge)}),Ke.current=[]}},[]);const nn=c.useCallback(async()=>{if(!be&&t){Pe(!0);try{const Ge={base:ke&&q?.defaultBranchSha?q.defaultBranchSha:ce,head:e};U&&(Ge.context=U);const st=await Sg(t,Ge);st.title?.trim()&&D(st.title.trim()),st.body?.trim()&&M(st.body.trim()),l?.()}catch(te){const Ge=te instanceof Error?te.message:String(te);We.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:Ge})}finally{Pe(!1)}}},[U,e,q?.defaultBranchSha,t,be,l,ce,a,ke]),Qs=c.useCallback(async()=>{if(!u?.prCreate){We.error(a("gitView.pr.toast.githubApiUnavailable"));return}const te=A.trim();if(!te){We.error(a("gitView.pr.toast.titleRequired"));return}const Ge=ce.trim();if(!Ge){We.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!ke&&Ge===e){We.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}pe(!0);try{const st=Wa(r),Pt=ke&&q,J=await u.prCreate({directory:t,title:te,head:e,base:Ge,...E.trim()?{body:E}:{},draft:k,...Pt?{targetRepo:{owner:q.owner,repo:q.repo},headRemote:"origin"}:{...Z?{remote:Z.name}:{},...st&&st!==Z?.name?{headRemote:st}:{}}});We.success(a("gitView.pr.toast.prCreated")),Zw(t,J),K(Oe,ze=>ze&&{...ze,pr:J}),await At({force:!0}),rs()}catch(st){const Pt=st instanceof Error?st.message:String(st);We.error(a("gitView.pr.toast.createPrFailed"),{description:Pt})}finally{pe(!1)}},[E,e,q,t,k,u,Oe,At,rs,Z,ce,A,r,K,ke,a]),as=c.useCallback(async te=>{if(!u?.prMerge){We.error(a("gitView.pr.toast.githubApiUnavailable"));return}de(!0);try{const Ge=await u.prMerge({directory:t,number:te.number,method:Y});Ge.merged?We.success(a("gitView.pr.toast.prMerged")):We.message(a("gitView.pr.toast.prNotMerged"),{description:Ge.message||a("gitView.pr.notMergeable")}),await At({force:!0}),rs()}catch(Ge){const st=Ge instanceof Error?Ge.message:String(Ge);We.error(a("gitView.pr.toast.mergeFailed"),{description:st}),te.url&&Yr(te.url)}finally{de(!1)}},[t,u,Y,At,rs,a]),Ws=c.useCallback(async te=>{if(!u?.prReady){We.error(a("gitView.pr.toast.githubApiUnavailable"));return}H(!0);try{await u.prReady({directory:t,number:te.number}),We.success(a("gitView.pr.toast.markedReady")),await At({force:!0}),rs()}catch(Ge){const st=Ge instanceof Error?Ge.message:String(Ge);We.error(a("gitView.pr.toast.markReadyFailed"),{description:st}),te.url&&Yr(te.url)}finally{H(!1)}},[t,u,At,rs,a]),xn=c.useCallback(async te=>{if(!u?.prUpdate){We.error(a("gitView.pr.toast.githubApiUnavailable"));return}const Ge=Te.trim();if(!Ge){We.error(a("gitView.pr.toast.titleRequired"));return}he(!0);try{const st=await u.prUpdate({directory:t,number:te.number,title:Ge,body:_e});K(Oe,Pt=>Pt&&{...Pt,pr:{...Pt.pr??te,...st}}),Me(!1),We.success(a("gitView.pr.toast.prUpdated")),await At({force:!0}),rs()}catch(st){const Pt=st instanceof Error?st.message:String(st);We.error(a("gitView.pr.toast.updatePrFailed"),{description:Pt})}finally{he(!1)}},[t,_e,Te,u,Oe,At,rs,K,a]);if(!$e)return n.jsx("section",{className:"border-0 bg-transparent rounded-none",children:n.jsxs("div",{className:"space-y-1 pt-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("gitView.pullRequest.title")}),n.jsx(pc,{})]}),n.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const yn=Ve?.repo?.url||null,bs=ke&&q?.url?q.url:yn,Ks=!!Ve?.canMerge,wn=!!Ve?.connected,vn=p&&Ve?.connected===!1,Ns=ev(Ve),xs=Ns?`var(--pr-${Ns})`:"var(--status-info)",Xs=Ns==="draft"?"git-pr-draft":Ns==="merged"?"git-merge":Ns==="closed"?"git-close-pull-request":"git-pull-request",Js=B?[`${B.state}${B.draft?" (draft)":""}`,B.mergeable===!1?a("gitView.pr.notMergeable"):null,B.state==="open"&&typeof B.mergeableState=="string"&&B.mergeableState&&B.mergeableState!=="unknown"?B.mergeableState:null].filter(Boolean).join(" · "):"",zs=G?G.total>0?`${G.success}/${G.total} ${a("gitView.pr.checks.label")}`:`${G.state} ${a("gitView.pr.checks.label")}`:"";return n.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[n.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex flex-col gap-1",children:[n.jsxs("div",{className:"@container/pr-actions flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[B?n.jsxs(ht,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Yr(B.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[n.jsx(F,{name:Xs,className:"size-4 shrink-0",style:{color:xs}}),a("gitView.pr.actions.openOnGitHub")]}):n.jsx(F,{name:Xs,className:"size-4 shrink-0",style:{color:"var(--surface-muted-foreground)"}}),n.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:a("gitView.pullRequest.title")}),B?n.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",B.number]}):null]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[B&&j?n.jsxs(ht,{variant:"outline",size:"sm",className:De("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Gw),onClick:()=>{S(t,{kind:"pr",number:B.number,sourceRepo:Ve?.repo?{owner:Ve.repo.owner,repo:Ve.repo.repo}:void 0}),w(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[n.jsx(F,{name:"route",className:"size-4"}),n.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ht,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:ct||Xt,onClick:()=>{bn()},"aria-label":a("gitView.pr.actions.refreshAria"),children:ct||Xt?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):n.jsx(F,{name:"refresh",className:"size-4 text-muted-foreground"})})}),n.jsx(wt,{children:n.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),n.jsx(pc,{className:"h-7 w-7"})]})]}),B?n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[n.jsx("span",{style:{color:xs},children:Js}),G?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${xc(G.state)}`}),zs]}):null,r&&Z&&r.split("/")[0]!==Z.name?n.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",Z.name]}):null]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[Ks&&B.draft&&B.state==="open"?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ht,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Ws(B),disabled:fe||X||je||ge,"aria-label":a("gitView.pr.actions.markReadyAria"),children:fe?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(F,{name:"checkbox-circle",className:"size-4"})})}),n.jsx(wt,{children:n.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,Ks?n.jsxs(n.Fragment,{children:[n.jsxs(Il,{value:Y,onValueChange:te=>me(te),disabled:X||B.state!=="open",children:[n.jsx(Dl,{size:"sm",className:"h-7 w-auto min-w-0",children:n.jsx(El,{})}),n.jsxs(Rl,{children:[n.jsx(Ur,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),n.jsx(Ur,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),n.jsx(Ur,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ht,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>as(B),disabled:X||fe||B.state!=="open"||B.draft||je||ge,"aria-label":a("gitView.pr.actions.mergePrAria"),children:X?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(F,{name:"git-merge",className:"size-4"})})}),n.jsx(wt,{children:n.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),n.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[vn?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),n.jsx(ht,{variant:"outline",size:"sm",onClick:N,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,nt?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.statusUnavailable")}),n.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:nt}),bs?n.jsx(ht,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:n.jsxs("a",{href:bs,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(F,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!B&&!kt&&!nt&&!vn?n.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):B&&!Se?n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"h-8 min-w-0",children:n.jsx(Yd,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:G&&G.total>0?`${a("gitView.pr.segment.checks")} ${G.success}/${G.total}`:a("gitView.pr.segment.checks"),icon:G?n.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${xc(G.state)}`}):void 0},{id:"comments",label:tt?`${a("gitView.pr.segment.comments")} ${(tt.issueComments?.length??0)+(tt.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:yt,onSelect:te=>Xe(te),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),yt==="overview"?n.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Ks&&B.draft?n.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,Ks?null:n.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.noMergePermission")}),n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsx("div",{className:"min-w-0 flex-1",children:ge?n.jsx(Ar,{value:Te,onChange:te=>Le(te.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:g?"on":"off",autoCapitalize:g?"sentences":"off",spellCheck:g}):n.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:B.title})}),B.state==="open"?n.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:ge?n.jsxs(n.Fragment,{children:[n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ht,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Me(!1),Le(B.title||""),P(B.body||"")},disabled:je,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:n.jsx(F,{name:"close",className:"size-4"})})}),n.jsx(wt,{children:n.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ht,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>xn(B),disabled:je||!Te.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:je?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(F,{name:"check",className:"size-4"})})}),n.jsx(wt,{children:n.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ht,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Me(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:n.jsx(F,{name:"edit",className:"size-4"})})}),n.jsx(wt,{children:n.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),ge?n.jsx(Hr,{value:_e,onChange:te=>P(te.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:g?"on":"off",autoCapitalize:g?"sentences":"off",spellCheck:g}):null,ge?null:B.body?.trim()?n.jsx(Ml,{content:B.body,className:"typography-markdown-body min-w-0 text-muted-foreground break-words",enableFileReferences:!1}):n.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:a(at?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,yt==="checks"?n.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[G&&G.total>0?n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted/40",children:[G.success>0?n.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${G.success/G.total*100}%`}}):null,G.failure>0?n.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${G.failure/G.total*100}%`}}):null,G.pending>0?n.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${G.pending/G.total*100}%`}}):null]}),n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[G.success,"/",G.total," ",a("gitView.pr.checks.label")]}),(G.inProgress??0)>0?n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[n.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),bi(G.startedAt,void 0,xt)]}):null]}):null,G?.failure?n.jsxs(ht,{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:ot,disabled:$t,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[$t?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(F,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(tt?.checkRuns?.length??0)>0?n.jsx("div",{className:"flex flex-col gap-1.5",children:(tt?.checkRuns??[]).map((te,Ge)=>{const st=`${te.id??"run"}:${te.name}:${Ge}`,Pt=te.status==="in_progress",J=te.status==="queued",ze=xi(te.conclusion),Qe=Rt.has(st),Ft=!!(te.output?.title||te.output?.summary||te.output?.text||(te.annotations?.length??0)>0||(te.job?.steps?.length??0)>0||te.detailsUrl),zt=te.job?.workflowName,Kt=Pt?bi(te.startedAt,void 0,xt):bi(te.startedAt,te.completedAt);return n.jsxs("div",{className:De("rounded-md border border-border/40",ze&&"border-[var(--status-error-border)]"),children:[n.jsxs("button",{type:"button",disabled:!Ft,onClick:()=>{Et(Ut=>{const As=new Set(Ut);return As.has(st)?As.delete(st):As.add(st),As})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[Pt?n.jsx(F,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):J?n.jsx(F,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):ze?n.jsx(F,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):n.jsx(F,{name:"checkbox-circle",className:"size-4 shrink-0 text-[var(--status-success)]"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:zt&&zt!==te.name?`${zt} / ${te.name}`:te.name}),Kt?n.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:Kt}):null,Ft?n.jsx(F,{name:"arrow-down-s",className:De("size-4 shrink-0 text-muted-foreground transition-transform",Qe&&"rotate-180")}):null]}),Qe&&Ft?n.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:Tt(te,{hideHeader:!0})}):null]},st)})}):rt?n.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):n.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.checkDetails.empty")})]}):null,yt==="comments"?n.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[ft.length>0?n.jsx("div",{className:"flex items-center justify-end",children:n.jsxs(ht,{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:gt,disabled:Re,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Re?n.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(F,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,ft.length>0?n.jsx("div",{className:"relative pl-3",children:n.jsx("div",{children:ft.map((te,Ge)=>{const st=(te.authorName||"?").charAt(0).toUpperCase(),Pt=Ge===ft.length-1;return n.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[Pt?null:n.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),n.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:te.avatarUrl?n.jsx("img",{src:te.avatarUrl,alt:te.authorName,className:"h-full w-full object-cover"}):n.jsx("span",{children:st})}),n.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[n.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:[n.jsxs("span",{className:"text-foreground whitespace-nowrap",children:[te.authorName,te.authorLogin&&te.authorLogin!==te.authorName?` · @${te.authorLogin}`:""]}),te.createdAt?n.jsx("span",{className:"whitespace-nowrap",children:Be(te.createdAt)}):null,n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ht,{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:()=>{Dt(te)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[n.jsx(F,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),n.jsx(wt,{children:n.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),n.jsxs("div",{className:"typography-micro text-muted-foreground",children:[te.context,te.path?` · ${te.path}`:"",te.line?`:${te.line}`:""]}),n.jsx(Ml,{content:et(te.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",lt].filter(Boolean).join(" "),enableFileReferences:!1})]})]},te.id)})})}):rt&&!tt?n.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):n.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.comments.empty")})]}):null]}):n.jsxs("div",{className:"flex flex-col gap-3",children:[B&&Se?n.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:[n.jsx(F,{name:B.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:xs}}),n.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:B.state==="merged"?a("gitView.pr.history.merged",{number:B.number,base:B.base||ce}):a("gitView.pr.history.closed",{number:B.number})}),n.jsx(ht,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Yr(B.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:n.jsx(F,{name:"external-link",className:"size-3.5"})})]}):null,n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),n.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",n.jsx("span",{className:"opacity-60",children:"(local)"})," → ",ce," ",n.jsxs("span",{className:"opacity-60",children:["(",ke&&q?"upstream":"remote",")"]})]})]}),bs?n.jsx(ht,{variant:"outline",size:"sm",asChild:!0,children:n.jsxs("a",{href:bs,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(F,{name:"external-link",className:"size-4"}),a("gitView.pr.actions.repo")]})}):null]}),n.jsxs("label",{className:"space-y-1",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.title")}),n.jsx(Ar,{value:A,onChange:te=>D(te.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:g?"on":"off",autoCapitalize:g?"sentences":"off",spellCheck:g})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),dt.length>0?n.jsxs(Il,{value:ce,onValueChange:re,children:[n.jsx(Dl,{size:"lg","aria-label":a("gitView.pr.field.baseBranch"),children:n.jsx(El,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),n.jsx(Rl,{children:dt.map(te=>n.jsx(Ur,{value:te,children:te},te))})]}):n.jsx(Ar,{value:ce,onChange:te=>re(te.target.value),placeholder:a("gitView.pr.placeholder.main"),"aria-label":a("gitView.pr.field.baseBranch")})]}),n.jsxs("label",{className:"space-y-1",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.description")}),n.jsx(Hr,{value:E,onChange:te=>M(te.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:g?"on":"off",autoCapitalize:g?"sentences":"off",spellCheck:g})]}),n.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":k,onClick:()=>I(te=>!te),onKeyDown:te=>{(te.key===" "||te.key==="Enter")&&(te.preventDefault(),I(Ge=>!Ge))},children:[n.jsx(jg,{size:"sm",checked:k,onChange:te=>I(te),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),n.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),y?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),n.jsx(ht,{variant:"outline",size:"sm",onClick:()=>ue(!0),children:U.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),U.trim()&&n.jsx("div",{className:"flex items-center gap-2",children:n.jsx("span",{className:"inline-flex items-center rounded-full bg-[var(--interactive-selection)] px-2 py-0.5 text-xs text-[var(--interactive-selection-foreground)]",children:a("gitView.pr.additionalContext.added")})})]}):n.jsxs(yl,{open:oe,onOpenChange:V,children:[n.jsxs(Xm,{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:[n.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),n.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:oe?a("gitView.pr.actions.hide"):U.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),n.jsx(wl,{children:n.jsxs("div",{className:"mt-2 space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[n.jsx(Hr,{value:U,onChange:te=>z(te.target.value),className:"min-h-[100px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext")}),n.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})})]}),n.jsx(ju,{open:Q,onClose:()=>ue(!1),title:a("gitView.pr.additionalContext.title"),footer:n.jsx(ht,{size:"sm",onClick:()=>ue(!1),className:"w-full",children:a("gitView.common.done")}),children:n.jsxs("div",{className:"space-y-3",children:[n.jsx(Hr,{value:U,onChange:te=>z(te.target.value),className:"min-h-[200px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext"),autoFocus:!0}),n.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(ht,{variant:"outline",size:"sm",onClick:nn,disabled:be||le,children:[be?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(F,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),n.jsx("div",{className:"flex-1"}),n.jsxs(ht,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:Qs,disabled:le||!wn||!ce.trim()||!ke&&ce.trim()===e,children:[n.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:le?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(F,{name:"git-pull-request",className:"size-4"})}),n.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},wi=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),Qr=new Map,Xr=new Map,kn=t=>`${Qt()}::${t}`,cv=()=>{const t=Ye.c(115),{t:e}=jt(),{git:s}=hn(),r=Gn(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=Ng(r??null),a=Na(o??null),d=Ag(o??null),u=Pg(o??null),{ensureAll:f,ensureNestedRepos:p,selectNestedRepo:m}=Yn(Vn(dv)),b=Je(uv),x=Je(fv),v=Je(pv),y=Je(mv);let g;t[0]!==r?(g=wi(r),t[0]=r,t[1]=g):g=t[1];const h=g;let w;if(t[2]!==y||t[3]!==h||t[4]!==v){e:{if(!h){w=void 0;break e}let Z;if(t[6]!==y||t[7]!==h){let ke;t[9]!==h?(ke=ne=>wi(ne.path)===h,t[9]=h,t[10]=ke):ke=t[10],Z=y.find(ke),t[6]=y,t[7]=h,t[8]=Z}else Z=t[8];const ee=Z;if(ee){w=ee;break e}for(const ke of v.values())if(wi(ke.path)===h){w=ke;break e}w=void 0}t[2]=y,t[3]=h,t[4]=v,t[5]=w}else w=t[5];const S=w;let j;t[11]!==b||t[12]!==S||t[13]!==x?.open||t[14]!==v?(j=()=>{if(b)return v.get(b)??S;if(x?.open)return S},t[11]=b,t[12]=S,t[13]=x?.open,t[14]=v,t[15]=j):j=t[15],x?.open;let N;t[16]!==j?(N=j(),t[16]=j,t[17]=N):N=t[17];const C=N;let R;t[18]!==b?(R=Z=>b?Z.getAttachment(b):void 0,t[18]=b,t[19]=R):R=t[19];const T=mu(R),O=T&&!T.degraded&&!T.legacy?T.worktreeRoot??void 0:void 0,_=Bw(r,C,a?.current??void 0);let W,L;t[20]!==f||t[21]!==s||t[22]!==o?(W=()=>{!o||!s||f(o,s)},L=[o,f,s],t[20]=f,t[21]=s,t[22]=o,t[23]=W,t[24]=L):(W=t[23],L=t[24]),c.useEffect(W,L);const[K,A]=c.useState(null);let D;t[25]!==O||t[26]!==_?.projectDirectory?(D=()=>{const Z=O||_?.projectDirectory;if(!Z){A(null);return}let ee=!1;return ku(Z).then(ke=>{if(ee)return;const ne=ke.trim();A(ne&&ne!=="HEAD"?ne:null)}).catch(()=>{ee||A(null)}),()=>{ee=!0}},t[25]=O,t[26]=_?.projectDirectory,t[27]=D):D=t[27];const E=_?.projectDirectory;let M;t[28]!==O||t[29]!==E?(M=[O,E],t[28]=O,t[29]=E,t[30]=M):M=t[30],c.useEffect(D,M);let k;t[31]!==o?(k=()=>(o?Qr.get(kn(o)):void 0)??[],t[31]=o,t[32]=k):k=t[32];const[I,U]=c.useState(k);let z;t[33]!==o?(z=()=>(o?Xr.get(kn(o)):void 0)??null,t[33]=o,t[34]=z):z=t[34];const[ce,re]=c.useState(z);let Y,me;t[35]!==s||t[36]!==o?(Y=()=>{if(!o||!s?.getRemotes){U([]);return}U(Qr.get(kn(o))??[]);let Z=!1;return s.getRemotes(o).then(ee=>{Z||(Qr.set(kn(o),ee??[]),U(ee??[]))}).catch(()=>{Z||U(Qr.get(kn(o))??[])}),()=>{Z=!0}},me=[o,s],t[35]=s,t[36]=o,t[37]=Y,t[38]=me):(Y=t[37],me=t[38]),c.useEffect(Y,me);let be,Pe;t[39]!==s||t[40]!==o?(be=()=>{if(!o||!s?.getRemoteUrl){re(null);return}re(Xr.get(kn(o))??null);let Z=!1;return s.getRemoteUrl(o).then(ee=>{Z||(Xr.set(kn(o),ee),re(ee))}).catch(()=>{Z||re(Xr.get(kn(o))??null)}),()=>{Z=!0}},Pe=[o,s],t[39]=s,t[40]=o,t[41]=be,t[42]=Pe):(be=t[41],Pe=t[42]),c.useEffect(be,Pe);let le;e:{if(!d?.all){let ee;t[43]===Symbol.for("react.memo_cache_sentinel")?(ee=[],t[43]=ee):ee=t[43],le=ee;break e}let Z;t[44]!==d.all?(Z=d.all.filter(hv).sort(),t[44]=d.all,t[45]=Z):Z=t[45],le=Z}const pe=le;let je;e:{if(!d?.all){let ee;t[46]===Symbol.for("react.memo_cache_sentinel")?(ee=[],t[46]=ee):ee=t[46],je=ee;break e}let Z;t[47]!==d.all?(Z=d.all.filter(gv).map(bv).sort(),t[47]=d.all,t[48]=Z):Z=t[48],je=Z}const he=je;let X;t[49]!==he||t[50]!==ce||t[51]!==I||t[52]!==a?.tracking?(X=()=>{if(I.length>0)return I;const Z=new Set,ee=a?.tracking?.trim();ee&&ee.includes("/")&&Z.add(ee.split("/")[0]);for(const ke of he){const ne=ke.indexOf("/");ne>0&&Z.add(ke.slice(0,ne))}return Z.size===0&&ce&&Z.add("origin"),Array.from(Z).map(ke=>({name:ke,fetchUrl:ce??"",pushUrl:ce??""}))},t[49]=he,t[50]=ce,t[51]=I,t[52]=a?.tracking,t[53]=X):X=t[53],a?.tracking;let de;t[54]!==X?(de=X(),t[54]=X,t[55]=de):de=t[55];const fe=de,H=a?.current??null;a?.tracking;let ge;t[56]!==a?.tracking?(ge=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=ge):ge=t[57];const Me=ge,Ne=(Me&&d?.defaultBranches?.[Me])??d?.defaultBranches?.origin;let Ie;t[58]!==H||t[59]!==Ne||t[60]!==fe||t[61]!==pe||t[62]!==K||t[63]!==_?.createdFromBranch?(Ie=()=>Jm({remoteNames:new Set(fe.map(xv)),localBranches:pe,worktreeCreatedFromBranch:_?.createdFromBranch,rootBranchHint:K,defaultBranch:Ne,headBranch:H}),t[58]=H,t[59]=Ne,t[60]=fe,t[61]=pe,t[62]=K,t[63]=_?.createdFromBranch,t[64]=Ie):Ie=t[64],_?.createdFromBranch;let Te;t[65]!==Ie?(Te=Ie(),t[65]=Ie,t[66]=Te):Te=t[66];const Le=Te;if(!r){let Z;t[67]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx(F,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=Z):Z=t[67];let ee;t[68]!==e?(ee=e("gitView.pullRequest.title"),t[68]=e,t[69]=ee):ee=t[69];let ke;t[70]!==ee?(ke=n.jsx("div",{className:"typography-ui-header text-foreground",children:ee}),t[70]=ee,t[71]=ke):ke=t[71];let ne;t[72]!==e?(ne=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=ne):ne=t[73];let q;t[74]!==ne?(q=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ne}),t[74]=ne,t[75]=q):q=t[75];let ie;return t[76]!==ke||t[77]!==q?(ie=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[Z,ke,q]}),t[76]=ke,t[77]=q,t[78]=ie):ie=t[78],ie}if(i===!1&&u!==!0){let Z;t[79]!==r||t[80]!==p?(Z=()=>{p(r,{force:!0})},t[79]=r,t[80]=p,t[81]=Z):Z=t[81];let ee;return t[82]!==u||t[83]!==l||t[84]!==i||t[85]!==Z?(ee=n.jsx(Zm,{rootIsGitRepo:i,resolvedIsGitRepo:u,nestedRepos:l,onRetryDiscovery:Z}),t[82]=u,t[83]=l,t[84]=i,t[85]=Z,t[86]=ee):ee=t[86],ee}if(!H){let Z;t[87]===Symbol.for("react.memo_cache_sentinel")?(Z=n.jsx(F,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=Z):Z=t[87];let ee;t[88]!==e?(ee=e("gitView.pullRequest.title"),t[88]=e,t[89]=ee):ee=t[89];let ke;t[90]!==ee?(ke=n.jsx("div",{className:"typography-ui-header text-foreground",children:ee}),t[90]=ee,t[91]=ke):ke=t[91];let ne;t[92]!==e?(ne=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=ne):ne=t[93];let q;t[94]!==ne?(q=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ne}),t[94]=ne,t[95]=q):q=t[95];let ie;return t[96]!==ke||t[97]!==q?(ie=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[Z,ke,q]}),t[96]=ke,t[97]=q,t[98]=ie):ie=t[98],ie}const _e=i===!1&&Array.isArray(l)&&l.length>0;let P;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==m||t[103]!==_e?(P=_e?n.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:n.jsx(eh,{repositories:l,selectedRepository:o??null,onSelectRepository:Z=>{r&&m(r,Z)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=m,t[103]=_e,t[104]=P):P=t[104];const oe=o??r,V=a?.tracking??void 0;let Q;t[105]!==Le||t[106]!==H||t[107]!==he||t[108]!==I||t[109]!==oe||t[110]!==V?(Q=n.jsx(gn,{as:Ig,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:n.jsx(lv,{directory:oe,branch:H,baseBranch:Le,trackingBranch:V,remotes:I,remoteBranches:he})}),t[105]=Le,t[106]=H,t[107]=he,t[108]=I,t[109]=oe,t[110]=V,t[111]=Q):Q=t[111];let ue;return t[112]!==P||t[113]!==Q?(ue=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[P,Q]}),t[112]=P,t[113]=Q,t[114]=ue):ue=t[114],ue};function dv(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function uv(t){return t.currentSessionId}function fv(t){return t.newSessionDraft}function pv(t){return t.worktreeMetadata}function mv(t){return t.availableWorktrees}function hv(t){return!t.startsWith("remotes/")}function gv(t){return t.startsWith("remotes/")}function bv(t){return t.replace(/^remotes\//,"")}function xv(t){return t.name}const ea=2e4,yv=(t,e)=>{if(!t)return 1;let s=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(s+=1,s>e))return s;return s},Jr=(t,e)=>Tg(Og.getState().dictionary,t,e),wv=t=>{const s=(t instanceof Error?t.message:String(t??"")).toLowerCase();return s.includes("file not found")||s.includes("not found")||s.includes("enoent")||s.includes("no such file")||s.includes("does not exist")?"missing":"unreadable"},vv=async(t,e,s)=>{if(t.readFile)return(await t.readFile(e,{optional:!0,directory:s?.directory})).content??"";const r=new URLSearchParams({path:e,optional:"true"});s?.directory&&r.set("directory",s.directory);const i=await ds(`/api/fs/read?${r.toString()}`,{cache:"no-store",headers:s?.directory?{"x-opencode-directory":s.directory}:void 0});if(!i.ok){const o=await i.json().catch(()=>({error:i.statusText}));throw new Error(o.error||"Failed to read file")}return i.text()},Cf=async(t,e,s)=>{if(Dg(e)||Eg(e)||Rg(e))return{ok:!0};try{const r=await vv(t,e,s);return Mg(r)?{ok:!1,reason:"binary"}:yv(r,ea)>ea?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:wv(r)}}},Nf=t=>{if(t==="too-large"){const e=ea.toLocaleString(Aa());return Jr("contextFileOpen.failure.tooLarge",{count:e})}return Jr(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},wc=8;let ta=null;const Af=t=>{ta={x:t.clientX,y:t.clientY}},Pf=t=>{const e=ta;return ta=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=wc&&Math.abs(t.clientY-e.y)<=wc},cr=t=>Array.from(t.types).includes("Files"),Sv=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(s=>{if(s.kind!=="file"||s.webkitGetAsEntry()?.isDirectory)return[];const r=s.getAsFile();return r?[r]:[]})},jv=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),os=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Ka=(t,e)=>{const s=os(e),r=os(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},kv=(t,e)=>{const s=Ka(t,e);if(s!==".")return s;const r=os(t);return r.split("/").filter(Boolean).pop()??r},Cv=t=>{const e=os(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},Nv=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),Av=new Set(["node_modules"]),Pv=t=>Av.has(t),Iv=t=>{const e=os(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Dv=8,en=new Map,za=t=>JSON.stringify([Qt(),t]),Ev=t=>{const e=za(t),s=en.get(e);return s?(s.touchedAt=Date.now(),en.delete(e),en.set(e,s),s):null},vi=t=>{const e=za(t),s=en.get(e);if(s)return s.touchedAt=Date.now(),s;if(en.size>=Dv){const i=en.keys().next().value;i!==void 0&&en.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return en.set(e,r),r},If=(t,e)=>n.jsx(Pa,{filePath:t,extension:e}),Rv=t=>{const e=Ye.c(3),{status:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=r):r=e[0];const i=r[s];let o;return e[1]!==i?(o=n.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i}}),e[1]=i,e[2]=o):o=e[2],o},Mv=t=>{const e=Ye.c(95),{node:s,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:d,isDropTarget:u,canUpload:f,permissions:p,downloadFile:m,onSelect:b,onToggle:x,onRevealPath:v,onOpenDialog:y,onSetDropTarget:g,onDropFiles:h,onPickFiles:w}=t,{t:S}=jt(),j=s.type==="directory";let N;e[0]!==j||e[1]!==s.path?(N=j?s.path:Cv(s.path),e[0]=j,e[1]=s.path,e[2]=N):N=e[2];const C=N,{canRename:R,canCreateFile:T,canCreateFolder:O,canDelete:_,canReveal:W}=p,L=!j&&!!m,K=W&&!l,A=j&&f,D=R||T||O||A||_||L||K,[E,M]=c.useState(!1),[k,I]=c.useState(!1);let U;e[3]!==D?(U=ie=>{D&&(ie?.preventDefault(),I(!0))},e[3]=D,e[4]=U):U=e[4];const z=U;let ce;e[5]!==j||e[6]!==s||e[7]!==b||e[8]!==x?(ce=()=>{j?x(s.path):b(s)},e[5]=j,e[6]=s,e[7]=b,e[8]=x,e[9]=ce):ce=e[9];const re=ce;let Y;e[10]!==j||e[11]!==s||e[12]!==b?(Y=()=>{j||b(s,{pin:!0})},e[10]=j,e[11]=s,e[12]=b,e[13]=Y):Y=e[13];const me=Y;let be;e[14]===Symbol.for("react.memo_cache_sentinel")?(be=ie=>{ie.stopPropagation(),I(!1),M(!0)},e[14]=be):be=e[14];const Pe=be;let le;e[15]!==T||e[16]!==O||e[17]!==_||e[18]!==R||e[19]!==K||e[20]!==A||e[21]!==m||e[22]!==l||e[23]!==j||e[24]!==s||e[25]!==y||e[26]!==w||e[27]!==v||e[28]!==S?(le=ie=>{const{Item:Ee,Separator:Ae}=ie;return n.jsxs(n.Fragment,{children:[R&&n.jsxs(Ee,{onClick:$e=>{$e.stopPropagation(),y("rename",s)},children:[n.jsx(F,{name:"edit",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.rename")]}),n.jsxs(Ee,{onClick:$e=>{$e.stopPropagation(),Hn(s.path).then(Oe=>{if(Oe.ok){We.success(S("sidebarFilesTree.toast.pathCopied"));return}We.error(S("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(F,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.copyPath")]}),!j&&m&&n.jsxs(Ee,{onClick:$e=>{$e.stopPropagation(),m(s.path).catch(Oe=>{console.error("Download failed:",Oe),We.error(S("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 h-4 w-4"})," ",S(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),K&&n.jsxs(Ee,{onClick:$e=>{$e.stopPropagation(),v(s.path)},children:[n.jsx(F,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",S(Bg())]}),j&&(T||O||A)&&n.jsxs(n.Fragment,{children:[n.jsx(Ae,{}),T&&n.jsxs(Ee,{onClick:$e=>{$e.stopPropagation(),y("createFile",s)},children:[n.jsx(F,{name:"file-add",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.newFile")]}),O&&n.jsxs(Ee,{onClick:$e=>{$e.stopPropagation(),y("createFolder",s)},children:[n.jsx(F,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.newFolder")]}),A&&n.jsxs(Ee,{onClick:$e=>{$e.stopPropagation(),w(s.path)},children:[n.jsx(F,{name:"upload-2",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.uploadFiles")]})]}),_&&n.jsxs(n.Fragment,{children:[n.jsx(Ae,{}),n.jsxs(Ee,{onClick:$e=>{$e.stopPropagation(),y("delete",s)},className:"text-destructive focus:text-destructive",children:[n.jsx(F,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.delete")]})]})]})},e[15]=T,e[16]=O,e[17]=_,e[18]=R,e[19]=K,e[20]=A,e[21]=m,e[22]=l,e[23]=j,e[24]=s,e[25]=y,e[26]=w,e[27]=v,e[28]=S,e[29]=le):le=e[29];const pe=le;let je;e[30]!==s.path||e[31]!==r?(je=ie=>{Af(ie);const Ee=Ka(r,s.path);!Ee||Ee==="."||(ie.dataTransfer.setData("application/x-openchamber-file-path",Ee),ie.dataTransfer.effectAllowed="copy")},e[30]=s.path,e[31]=r,e[32]=je):je=e[32];const he=je;let X;e[33]!==re?(X=ie=>{Pf(ie)&&re()},e[33]=re,e[34]=X):X=e[34];const de=X;let fe;e[35]!==f||e[36]!==g||e[37]!==C?(fe=ie=>{!f||!C||!cr(ie.dataTransfer)||(ie.preventDefault(),ie.stopPropagation(),ie.dataTransfer.dropEffect="copy",g(C))},e[35]=f,e[36]=g,e[37]=C,e[38]=fe):fe=e[38];const H=fe;let ge;e[39]!==f||e[40]!==g||e[41]!==C?(ge=ie=>{!f||!C||!cr(ie.dataTransfer)||ie.relatedTarget instanceof Node&&ie.currentTarget.contains(ie.relatedTarget)||(ie.stopPropagation(),g(null))},e[39]=f,e[40]=g,e[41]=C,e[42]=ge):ge=e[42];const Me=ge;let Ne;e[43]!==f||e[44]!==h||e[45]!==C?(Ne=ie=>{!f||!C||!cr(ie.dataTransfer)||(ie.preventDefault(),ie.stopPropagation(),h(C,ie.dataTransfer))},e[43]=f,e[44]=h,e[45]=C,e[46]=Ne):Ne=e[46];const Ie=Ne;let Te;e[47]===Symbol.for("react.memo_cache_sentinel")?(Te={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[47]=Te):Te=e[47];let Le;e[48]!==z||e[49]!==Me||e[50]!==H||e[51]!==Ie?(Le=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Te,onContextMenu:z,onDragEnter:H,onDragOver:H,onDragLeave:Me,onDrop:Ie}),e[48]=z,e[49]=Me,e[50]=H,e[51]=Ie,e[52]=Le):Le=e[52];const _e=u?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let P;e[53]!==_e?(P=De("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]=P):P=e[54];let oe;e[55]!==j||e[56]!==i||e[57]!==s.extension||e[58]!==s.path?(oe=j?i?n.jsx(F,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):n.jsx(F,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):If(s.path,s.extension),e[55]=j,e[56]=i,e[57]=s.extension,e[58]=s.path,e[59]=oe):oe=e[59];let V;e[60]!==s.name||e[61]!==s.path?(V=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:s.path,children:s.name}),e[60]=s.name,e[61]=s.path,e[62]=V):V=e[62];let Q;e[63]!==j||e[64]!==a?(Q=!j&&a&&n.jsx(Rv,{status:a}),e[63]=j,e[64]=a,e[65]=Q):Q=e[65];let ue;e[66]!==d||e[67]!==j?(ue=j&&d&&n.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[d.modified>0&&n.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",d.modified]}),d.added>0&&n.jsxs("span",{className:"text-[var(--status-success)]",children:["+",d.added]})]}),e[66]=d,e[67]=j,e[68]=ue):ue=e[68];let Z;e[69]!==z||e[70]!==me||e[71]!==de||e[72]!==he||e[73]!==re||e[74]!==P||e[75]!==oe||e[76]!==V||e[77]!==Q||e[78]!==ue?(Z=n.jsxs("button",{type:"button",onClick:re,onDoubleClick:me,onContextMenu:z,draggable:!0,onDragStart:he,onDragEnd:de,className:P,children:[oe,V,Q,ue]}),e[69]=z,e[70]=me,e[71]=de,e[72]=he,e[73]=re,e[74]=P,e[75]=oe,e[76]=V,e[77]=Q,e[78]=ue,e[79]=Z):Z=e[79];let ee;e[80]!==E||e[81]!==D||e[82]!==pe||e[83]!==S?(ee=D&&n.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:n.jsxs(Cs,{open:E,onOpenChange:M,children:[n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(js,{asChild:!0,children:n.jsx(ht,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:Pe,title:S("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":S("sidebarFilesTree.actions.fileMenuTitle"),children:n.jsx(F,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(wt,{side:"bottom",sideOffset:6,children:S("sidebarFilesTree.actions.fileMenuTitle")})]}),n.jsx(ks,{align:"end",side:"bottom",onCloseAutoFocus:()=>M(!1),children:pe({Item:Wt,Separator:ws})})]})}),e[80]=E,e[81]=D,e[82]=pe,e[83]=S,e[84]=ee):ee=e[84];let ke;e[85]!==Le||e[86]!==Z||e[87]!==ee?(ke=n.jsxs(Xd,{render:Le,children:[Z,ee]}),e[85]=Le,e[86]=Z,e[87]=ee,e[88]=ke):ke=e[88];let ne;e[89]!==pe?(ne=n.jsx(Qd,{className:"min-w-[180px]",children:pe({Item:Wn,Separator:Oi})}),e[89]=pe,e[90]=ne):ne=e[90];let q;return e[91]!==k||e[92]!==ke||e[93]!==ne?(q=n.jsxs(Jd,{open:k,onOpenChange:I,children:[ke,ne]}),e[91]=k,e[92]=ke,e[93]=ne,e[94]=q):q=e[94],q},Tv=(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,Ov=c.memo(Mv,Tv),Bv=t=>{const e=Ye.c(6),{visible:s}=t,r=s===void 0?!0:s,i=Yn(Lv),o=Gn();let l;e[0]!==o||e[1]!==i?(l=JSON.stringify([i,o]),e[0]=o,e[1]=i,e[2]=l):l=e[2];let a;return e[3]!==l||e[4]!==r?(a=n.jsx(Fv,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},Fv=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:s}=jt(),{files:r,runtime:i}=hn(),o=cm(i.platform),l=Gn()??"",a=os(l.trim()),d=za(a),u=dm(),f=um(),p=Wd(ye=>ye.searchFiles),m=ve(ye=>ye.openContextFile),b=Na(t?l:null),[x,v]=c.useState(""),y=Cu(x,200),g=c.useRef(null),[h,w]=c.useState([]),[S,j]=c.useState(!1),[N,C]=c.useState(null),[R,T]=c.useState({}),[O,_]=c.useState({}),W=c.useRef(new Set),L=c.useMemo(()=>new Wx,[]);c.useEffect(()=>()=>L.clear(),[L]);const K=c.useRef(null);c.useEffect(()=>{if(C(null),!a){T({}),_({}),W.current=new Set;return}const ye=Ev(a);ye?(T({...ye.childrenByDir}),_({...ye.loadErrorsByDir}),W.current=new Set(ye.loadedDirs)):(T({}),_({}),W.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const ye=vi(a);ye.childrenByDir=R},[a,R]),c.useEffect(()=>{if(!a)return;const ye=vi(a);ye.loadErrorsByDir=O},[a,O]),c.useEffect(()=>{if(!a)return;const ye=vi(a);ye.loadedDirs=new Set(W.current)},[a,R,O]),c.useEffect(()=>()=>{if(!a)return;const ye=en.get(d);ye&&ye.loadedDirs.size===0&&Object.keys(ye.childrenByDir).length===0&&en.delete(d)},[d,a]);const A=c.useMemo(()=>[],[]),D=c.useMemo(()=>[],[]),E=ln(ye=>a?ye.byRoot[a]?.expandedPaths??A:A),M=c.useMemo(()=>new Set(E),[E]),k=ln(ye=>a?ye.byRoot[a]?.selectedPath??null:null),I=ln(ye=>ye.setSelectedPath),U=c.useRef(null),z=c.useRef(null);c.useEffect(()=>{z.current=k},[k]);const ce=ln(ye=>ye.addOpenPath),re=ln(ye=>ye.removeOpenPathsByPrefix),Y=ln(ye=>ye.toggleExpandedPath),me=ln(ye=>ye.collapseAllExpandedPaths),be=ve(ye=>a?ye.contextPanelByDirectory[a]?.tabs??D:D),Pe=c.useMemo(()=>new Set(be.map(ye=>ye.mode==="file"?ye.targetPath:null).filter(ye=>typeof ye=="string"&&ye.length>0).map(ye=>os(ye))),[be]),[le,pe]=c.useState(null),[je,he]=c.useState(null),[X,de]=c.useState(""),[fe,H]=c.useState(!1),ge=!!r.writeFile,Me=!!r.createDirectory,Ne=!!r.rename,Ie=!!r.delete,Te=!!r.revealPath,Le=c.useMemo(()=>({canRename:Ne,canCreateFile:ge,canCreateFolder:Me,canDelete:Ie,canReveal:Te}),[Ne,ge,Me,Ie,Te]),_e=c.useCallback(ye=>{r.revealPath&&r.revealPath(ye).catch(()=>{We.error(s("sidebarFilesTree.toast.revealFailed"))})},[r,s]),P=c.useCallback((ye,He)=>{pe(ye),he(He),de(ye==="rename"&&He.name||""),H(!1)},[]),oe=c.useCallback((ye,He)=>{const mt=He.filter(Ke=>Ke&&typeof Ke.name=="string"&&Ke.name.length>0).filter(Ke=>u||!Ke.name.startsWith(".")).filter(Ke=>f||!Pv(Ke.name)).map(Ke=>{const B=Ke.name,Se=os(Ke.path||""),Fe=Se?Nv(Se)?Se:os(`${ye}/${Se}`):os(`${ye}/${B}`),$=Ke.isDirectory?"directory":"file",se=$==="file"&&B.includes(".")?B.split(".").pop()?.toLowerCase():void 0;return{name:B,path:Fe,type:$,extension:se}});return jv(mt)},[f,u]),V=c.useCallback(async(ye,He,mt=!1)=>{if(!e.current||He?.())return;const Ke=os(ye.trim());if(!Ke||!mt&&W.current.has(Ke))return;const B=Qt();return L.run(Ke,async Se=>{const Fe=()=>!Se()||Qt()!==B;try{const $=r.listDirectory?(await r.listDirectory(Ke)).entries:await ar.listLocalDirectory(Ke);if(Fe())return;const se=oe(Ke,$);W.current=new Set(W.current),W.current.add(Ke),_(we=>{if(!we[Ke])return we;const tt={...we};return delete tt[Ke],tt}),T(we=>we[Ke]&&Kx(we[Ke],se)?we:{...we,[Ke]:se})}catch($){if(Fe())return;const se=$ instanceof Error?$.message:String($??"");console.error("Failed to load sidebar directory:",$),_(we=>({...we,[Ke]:se}))}},mt)},[L,r,oe]),Q=c.useCallback(async()=>{if(!a)return;K.current?.abort();const ye=new AbortController;K.current=ye,L.clear();try{const mt=(ln.getState().byRoot[a]?.expandedPaths??[]).map(Se=>os(Se)).filter(Se=>!!Se&&Se!==a&&Se.startsWith(`${a}/`)),Ke=[a,...mt];W.current=new Set(W.current);for(const Se of Ke)W.current.delete(Se);_(Se=>{if(Object.keys(Se).length===0)return Se;const Fe={...Se};let $=!1;for(const se of Ke)se in Fe&&(delete Fe[se],$=!0);return $?Fe:Se});const B=()=>ye.signal.aborted;await V(a,B);for(let Se=0;Se<mt.length&&!ye.signal.aborted;Se+=3){const Fe=mt.slice(Se,Se+3);await Promise.all(Fe.map($=>V($,B)))}}catch(He){if(ye.signal.aborted)return;console.error("Failed to refresh sidebar tree:",He)}finally{K.current===ye&&(K.current=null)}},[L,V,a]),ue=c.useCallback(async ye=>{if(!ye){await Q();return}const He=os(ye);W.current=new Set(W.current),W.current.delete(He),await V(He,void 0,!0)},[V,Q]);c.useEffect(()=>{a&&(K.current?.abort(),W.current=new Set,L.clear(),_({}),T(ye=>Object.keys(ye).length===0?ye:{}),V(a))},[L,V,a,u,f]),c.useEffect(()=>{if(!t||!a||E.length===0)return;const ye=E.map(Ke=>os(Ke)).filter(Ke=>!!Ke&&Ke!==a&&Ke.startsWith(`${a}/`)&&!W.current.has(Ke)&&!L.has(Ke)).sort((Ke,B)=>Ke.split("/").length-B.split("/").length);if(ye.length===0)return;let He=!1;const mt=()=>He;return(async()=>{for(let Ke=0;Ke<ye.length&&!He;Ke+=3){const B=ye.slice(Ke,Ke+3);await Promise.all(B.map(Se=>V(Se,mt)))}})(),()=>{He=!0}},[L,E,V,a,t]);const Z=c.useRef(t);c.useEffect(()=>{const ye=t&&!Z.current;Z.current=t,ye&&Q()},[Q,t]),c.useEffect(()=>{if(!t)return;if(!l){w([]),j(!1);return}const ye=y.trim();if(!ye){w([]),j(!1);return}let He=!1;return j(!0),p(l,ye,150,{includeHidden:u,respectGitignore:!f,type:"file"}).then(mt=>{if(He)return;const B=mt.filter(Se=>f||!Iv(Se.path)).map(Se=>({name:Se.name,path:os(Se.path),type:"file",extension:Se.extension,relativePath:Se.relativePath}));w(B)}).catch(()=>{He||w([])}).finally(()=>{He||j(!1)}),()=>{He=!0}},[l,y,p,u,f,t]);const ee=c.useMemo(()=>{const ye=new Map;if(!b?.files)return ye;for(const He of b.files)He.index==="A"||He.working_dir==="?"?ye.set(He.path,"git-added"):He.index==="D"?ye.set(He.path,"git-deleted"):(He.index==="M"||He.working_dir==="M")&&ye.set(He.path,"git-modified");return ye},[b]),ke=c.useMemo(()=>{const ye=new Map;if(!b?.files||!a)return ye;for(const He of b.files){const mt=He.index==="M"||He.working_dir==="M",Ke=He.index==="A"||He.working_dir==="?";if(!mt&&!Ke)continue;const B=He.path.split("/");if(B.length<=1)continue;let Se=a;for(let Fe=0;Fe<B.length-1;Fe++){Se=`${Se}/${B[Fe]}`;let $=ye.get(Se);$||($={modified:0,added:0},ye.set(Se,$)),mt&&$.modified++,Ke&&$.added++}}return ye},[b,a]),ne=c.useCallback(ye=>{if(Pe.has(ye))return"open";if(ee.size===0)return null;const He=ye.startsWith(a+"/")?ye.slice(a.length+1):ye;return ee.get(He)??null},[Pe,ee,a]),q=c.useCallback(ye=>{if(ke.size===0)return null;const He=ke.get(ye);return He&&He.modified+He.added>0?He:null},[ke]),ie=c.useCallback(async(ye,He)=>{if(!a)return;const mt=await Cf(r,ye.path,{directory:a});if(!mt.ok){We.error(Nf(mt.reason));return}I(a,ye.path),ce(a,ye.path),m(a,ye.path,{preview:!He?.pin&&!ve.getState().isMobile})},[ce,r,m,a,I]),Ee=c.useCallback(async ye=>{const He=os(ye);a&&(Y(a,He),W.current.has(He)||await V(He))},[V,a,Y]),{canUpload:Ae,uploadingDirectory:$e,uploadFiles:Oe,pickFiles:qe,uploadElements:ct}=th({root:a,refreshDirectory:ue}),Ve=$e!==null,nt=$e??N,kt=c.useCallback((ye,He)=>{const mt=Sv(He);mt.length!==0&&(C(null),Oe(ye,mt))},[Oe]),dt=c.useCallback(ye=>{!Ae||Ve||!a||!cr(ye.dataTransfer)||(ye.preventDefault(),ye.dataTransfer.dropEffect="copy",C(a))},[Ae,Ve,a]),yt=c.useCallback(ye=>{cr(ye.dataTransfer)&&(ye.relatedTarget instanceof Node&&ye.currentTarget.contains(ye.relatedTarget)||C(null))},[]),_t=c.useCallback(ye=>{!Ae||Ve||!a||!cr(ye.dataTransfer)||(ye.preventDefault(),kt(a,ye.dataTransfer))},[Ae,kt,Ve,a]),Bt=c.useCallback(async ye=>{if(ye?.preventDefault(),!je||!le)return;H(!0);const He=()=>H(!1),mt=()=>pe(null);if(le==="createFile"){if(!X.trim()){We.error(s("sidebarFilesTree.toast.filenameRequired")),He();return}if(!r.writeFile){We.error(s("sidebarFilesTree.toast.writeNotSupported")),He();return}const Ke=je.path,B=Ke?`${Ke}/`:"",Se=os(`${B}${X.trim()}`);await r.writeFile(Se,"").then(async Fe=>{Fe.success&&(We.success(s("sidebarFilesTree.toast.fileCreated")),await ue(Ke)),mt()}).catch(()=>We.error(s("sidebarFilesTree.toast.operationFailed"))).finally(He);return}if(le==="createFolder"){if(!X.trim()){We.error(s("sidebarFilesTree.toast.folderNameRequired")),He();return}const Ke=je.path,B=Ke?`${Ke}/`:"",Se=os(`${B}${X.trim()}`);await r.createDirectory(Se).then(async Fe=>{Fe.success&&(We.success(s("sidebarFilesTree.toast.folderCreated")),await ue(Ke)),mt()}).catch(()=>We.error(s("sidebarFilesTree.toast.operationFailed"))).finally(He);return}if(le==="rename"){if(!X.trim()){We.error(s("sidebarFilesTree.toast.nameRequired")),He();return}if(!r.rename){We.error(s("sidebarFilesTree.toast.renameNotSupported")),He();return}const Ke=je.path,B=Ke.split("/").slice(0,-1).join("/"),Se=B?`${B}/`:"",Fe=os(`${Se}${X.trim()}`);await r.rename(Ke,Fe).then(async $=>{$.success&&(We.success(s("sidebarFilesTree.toast.renamedSuccessfully")),await ue(B),a&&re(a,Ke),(k===Ke||k&&k.startsWith(`${Ke}/`))&&I(a,null)),mt()}).catch(()=>We.error(s("sidebarFilesTree.toast.operationFailed"))).finally(He);return}if(le==="delete"){if(!r.delete){We.error(s("sidebarFilesTree.toast.deleteNotSupported")),He();return}const Ke=je.path,B=Ke.split("/").slice(0,-1).join("/");await r.delete(Ke).then(async Se=>{Se.success&&(We.success(s("sidebarFilesTree.toast.deletedSuccessfully")),await ue(B),a&&re(a,Ke),(k===Ke||k&&k.startsWith(Ke+"/"))&&I(a,null)),mt()}).catch(()=>We.error(s("sidebarFilesTree.toast.operationFailed"))).finally(He);return}He()},[le,je,X,r,ue,re,a,k,I,s]);function Lt(ye,He){const mt=R[ye]??[];return mt.map((Ke,B)=>{const Se=Ke.type==="directory",Fe=Se&&M.has(Ke.path),$=k===Ke.path,se=B===mt.length-1;return n.jsxs("li",{className:"relative","data-file-tree-path":Se?void 0:Ke.path,children:[He>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),se&&n.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),n.jsx(Ov,{node:Ke,root:a,isExpanded:Fe,isActive:$,isBrowserClient:o,status:Se?void 0:ne(Ke.path),badge:Se?q(Ke.path):void 0,isDropTarget:Se&&nt===Ke.path,canUpload:Ae&&!Ve,permissions:Le,downloadFile:r.downloadFile,onSelect:ie,onToggle:Ee,onRevealPath:_e,onOpenDialog:P,onSetDropTarget:C,onDropFiles:kt,onPickFiles:qe}),Se&&Fe&&n.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[O[Ke.path]?n.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:O[Ke.path],children:O[Ke.path]}),n.jsxs(ht,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{ue(Ke.path)},children:[n.jsx(F,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):null,Lt(Ke.path,He+1)]})]},Ke.path)})}c.useEffect(()=>{const ye=z.current,He=U.current;if(!ye||!He)return;const mt=He.querySelector(`[data-file-tree-path="${CSS.escape(ye)}"]`);!mt||mt.offsetParent===null||(z.current=null,mt.scrollIntoView({block:"nearest"}))});const Rt=!!(a&&R[a]),Et=a?O[a]:null,Nt=nt?kv(a,nt):"";return n.jsxs("section",{ref:U,className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[n.jsxs("div",{className:"flex items-center justify-end gap-2",children:[ge&&n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(ht,{variant:"ghost",size:"sm",onClick:()=>P("createFile",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.newFileTitle"),"aria-label":s("sidebarFilesTree.actions.newFileTitle"),children:n.jsx(F,{name:"file-add",className:"h-4 w-4"})})})}),n.jsx(wt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.newFileTitle")})]}),Me&&n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(ht,{variant:"ghost",size:"sm",onClick:()=>P("createFolder",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.newFolderTitle"),"aria-label":s("sidebarFilesTree.actions.newFolderTitle"),children:n.jsx(F,{name:"folder-add",className:"h-4 w-4"})})})}),n.jsx(wt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.newFolderTitle")})]}),Ae&&n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(ht,{variant:"ghost",size:"sm",onClick:()=>qe(a),disabled:!a||Ve,className:"h-8 w-8 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":s("sidebarFilesTree.actions.uploadFilesTitle"),children:n.jsx(F,{name:"upload-2",className:"h-4 w-4"})})})}),n.jsx(wt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.uploadFilesTitle")})]}),n.jsx(zx,{className:"h-8 w-8"}),n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(ht,{variant:"ghost",size:"sm",onClick:()=>{Q()},className:"h-8 w-8 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.refreshTitle"),"aria-label":s("sidebarFilesTree.actions.refreshTitle"),children:n.jsx(F,{name:"refresh",className:"h-4 w-4"})})})}),n.jsx(wt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.refreshTitle")})]}),n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(ht,{variant:"ghost",size:"sm",onClick:()=>{a&&me(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":s("sidebarFilesTree.actions.collapseAllTitle"),children:n.jsx(F,{name:"collapse-vertical",className:"h-4 w-4"})})})}),n.jsx(wt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.collapseAllTitle")})]})]}),n.jsxs("div",{className:"relative min-w-0",children:[n.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),n.jsx(Ar,{ref:g,value:x,onChange:ye=>v(ye.target.value),placeholder:s("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),x.trim().length>0?n.jsx("button",{type:"button","aria-label":s("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:()=>{v(""),g.current?.focus()},children:n.jsx(F,{name:"close",className:"h-4 w-4"})}):null]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsx(gn,{outerClassName:"h-full min-h-0",className:De("p-2",nt===a&&"bg-interactive-selection/10"),onDragEnter:dt,onDragOver:dt,onDragLeave:yt,onDrop:_t,children:n.jsx("ul",{className:"flex flex-col",children:S?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"h-4 w-4 animate-spin"}),s("sidebarFilesTree.state.searching")]}):h.length>0?h.map(ye=>{const He=k===ye.path;return n.jsx("li",{"data-file-tree-path":ye.path,children:n.jsxs("button",{type:"button",onClick:()=>ie(ye),onDoubleClick:()=>ie(ye,{pin:!0}),draggable:!0,onDragStart:mt=>{Af(mt);const Ke=ye.relativePath||Ka(a??"",ye.path);!Ke||Ke==="."||(mt.dataTransfer.setData("application/x-openchamber-file-path",Ke),mt.dataTransfer.effectAllowed="copy")},onDragEnd:mt=>{Pf(mt)&&ie(ye)},className:De("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",He?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:ye.path,children:[If(ye.path,ye.extension),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:`${ye.relativePath??ye.path}`})]})},ye.path)}):Et?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:Et}),n.jsxs(ht,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Q()},children:[n.jsx(F,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):Rt&&a?Lt(a,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:s("sidebarFilesTree.state.loading")})})}),nt?n.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:[n.jsx(F,{name:Ve?"loader-4":"folder-received",className:De("size-4 flex-shrink-0",Ve&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Nt,children:s(Ve?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Nt})})]}):null]}),ct,n.jsx(Ds,{open:!!le,onOpenChange:ye=>!ye&&pe(null),children:n.jsxs(Es,{children:[n.jsxs(Gs,{children:[n.jsxs(qs,{children:[le==="createFile"&&s("sidebarFilesTree.dialog.createFile.title"),le==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.title"),le==="rename"&&s("sidebarFilesTree.dialog.rename.title"),le==="delete"&&s("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(Ys,{children:[le==="createFile"&&s("sidebarFilesTree.dialog.createFile.description",{path:je?.path??s("sidebarFilesTree.dialog.rootFallback")}),le==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.description",{path:je?.path??s("sidebarFilesTree.dialog.rootFallback")}),le==="rename"&&s("sidebarFilesTree.dialog.rename.description",{name:je?.name??""}),le==="delete"&&s("sidebarFilesTree.dialog.delete.description",{name:je?.name??""})]})]}),le!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(Ar,{value:X,onChange:ye=>de(ye.target.value),placeholder:s(le==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:ye=>{ye.key==="Enter"&&Bt()},autoFocus:!0})}),n.jsxs(qn,{children:[n.jsx(ht,{variant:"outline",onClick:()=>pe(null),disabled:fe,children:s("sidebarFilesTree.dialog.cancel")}),n.jsx(ht,{variant:le==="delete"?"destructive":"default",onClick:()=>{Bt()},disabled:fe||le!=="delete"&&!X.trim(),children:fe?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):s(le==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function Lv(t){return t.runtimeKey}const vc=60,_v=t=>{try{return new URL(t).origin}catch{return""}},Si=new Set,Df=Lr()((t,e)=>({byOrigin:{},resolve:(s,r)=>{const i=_v(s);!i||!r||e().byOrigin[i]||Si.has(i)||(Si.add(i),go("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const d={...a.byOrigin,[i]:l},u=Object.keys(d);if(u.length<=vc)return{byOrigin:d};for(const f of u.slice(0,u.length-vc))delete d[f];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{Si.delete(i)}))}})),Va=t=>t,sa=t=>{const e=Va(t).type;return typeof e=="string"?e:""},$v=t=>{const e=Va(t).tool;return typeof e=="string"?e:""},Wv=t=>{const e=Va(t).text;return typeof e=="string"?e:""},Kv=t=>{const e=sa(t);return e==="tool"?$v(t).trim().toLowerCase()||"tool":e||"unknown"},zv=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=Kv(s);e.includes(r)||e.push(r)}return e.join(" + ")},Vv=t=>t.replace(/\s+/g," ").trim(),Uv=t=>{for(const s of t)if(sa(s)==="text"){const r=Vv(Wv(s));if(r.length===0)continue;return r}const e=t.filter(s=>sa(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Hv=(t,e,s)=>`${s(t)} / ${s(e)}`,Gv=t=>{if(t==="12h")return!0;if(t==="24h")return!1},qv=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=Gv(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:s===!1?"2-digit":"numeric",minute:"2-digit",...s===void 0?{}:{hour12:s}})},na={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},xo={user:0,assistant:0,tool:0,other:0},An=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Sc=t=>{const e=t.info.tokens,s=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof s=="number")return{...na,total:An(s)};if(!s||typeof s!="object")return na;const r=s,i=An(r.input),o=An(r.output),l=An(r.reasoning),a=An(r.cache?.read),d=An(r.cache?.write),u=An(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:d,total:u>0?u:i+o+l+a+d}},Yv=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Ps=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+Ps(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+Ps(s),0):0,Qv=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...xo,assistant:Ps(s.text)+Ps(s.content)};const i=Yv(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Ps(s.input)+Ps(s.output)+Ps(s.error)+Ps(s.call?.input)+Ps(s.call?.output)+Ps(s.call?.error)+Ps(s.raw)+Math.round(Ps(s.metadata)*.25)+Math.round(Ps(s.state)*.1),other:0}:e==="user"?{user:i.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},jc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),Xv=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",Jv=(t,e)=>{if(t.length===0)return{...xo};const s=t.reduce((r,i)=>{const o=Xv(i);let l={...xo};for(const a of i.parts)l=jc(l,Qv(a,o));return jc(r,l)},{...xo});return s.user+=e.length,{user:Math.ceil(s.user/4),assistant:Math.ceil(s.assistant/4),tool:Math.ceil(s.tool/4),other:Math.ceil(s.other/4)}},_n=t=>t.toLocaleString(Aa()),Zv=(t,e)=>!t||!Number.isFinite(t)?"-":Su(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),e1=(t,e,s)=>{const r=t.find(o=>o.id===e),i=r?.models?.find(o=>o.id===s);return{providerName:r?.name||e||"-",modelName:i?.name||s||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},t1=()=>{const t=Ye.c(209),{t:e}=jt(),s=ve(s1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[i,o]=c.useState(r),[l,a]=c.useState(null),d=c.useRef(null),u=Je(n1),f=Je(r1),p=Nu(f??void 0),m=Fg(u??"",f??void 0),b=es(o1);let x;t[1]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),o(i1),a(null)},t[1]=x):x=t[1];let v;t[2]!==f||t[3]!==u?(v=[f,u],t[2]=f,t[3]=u,t[4]=v):v=t[4],c.useEffect(x,v);let y,g;t[5]===Symbol.for("react.memo_cache_sentinel")?(y=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},g=[],t[5]=y,t[6]=g):(y=t[5],g=t[6]),c.useEffect(y,g);let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=async(pt,at)=>{(await Hn(at)).ok?(a(pt),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{a(Ue=>Ue===pt?null:Ue),d.current=null},2e3)):a(null)},t[7]=h):h=t[7];const w=h;let S;t[8]!==u||t[9]!==p?(S=u?p.find(pt=>pt.id===u)??null:null,t[8]=u,t[9]=p,t[10]=S):S=t[10];const j=S;let N,C,R,T,O,_,W;if(t[11]!==m){N=m.filter(a1),W=m.filter(l1);const pt=Lg(m.map(c1));R=pt?m[pt.index]??null:null,T=pt?.state==="compacted";let at;t[19]!==R?(_=R?Sc(R):na,at=_g({input:_.input,cache:{read:_.cacheRead,write:_.cacheWrite}}),t[19]=R,t[20]=at,t[21]=_):(at=t[20],_=t[21]),C=at,O=N.reduce(d1,0),t[11]=m,t[12]=N,t[13]=C,t[14]=R,t[15]=T,t[16]=O,t[17]=_,t[18]=W}else N=t[12],C=t[13],R=t[14],T=t[15],O=t[16],_=t[17],W=t[18];const L=O,K=R?.info??null,A=b,D=K?.providerID||"",E=K?.modelID||"";let M;t[22]!==E||t[23]!==A||t[24]!==D?(M=e1(A,D,E),t[22]=E,t[23]=A,t[24]=D,t[25]=M):M=t[25];const k=M,I=k.contextLimit,U=T?null:I&&I>0?Math.min(999,_.total/I*100):0;let z;if(t[26]!==m){const pt=[...m].reverse().find(u1),at=pt?.info.role==="system"?pt.info.text:"";z=Jv(m,at),t[26]=m,t[27]=z}else z=t[27];const ce=z,re=ce.user,Y=ce.assistant,me=ce.tool,be=Math.max(0,_.input-re-Y-me),Pe=re+Y+me+be,le=m[0]?.info?.time?.created,pe=m.length>0?m[m.length-1]?.info?.time?.created:null;let je;t[28]!==j?.title||t[29]!==e?(je=j?.title||e("contextSidebar.session.untitled"),t[28]=j?.title,t[29]=e,t[30]=je):je=t[30];const he=j?.time?.created??le??null,X=pe??j?.time?.created??null;let de;t[31]!==Y||t[32]!==be||t[33]!==me||t[34]!==re?(de={user:re,assistant:Y,tool:me,other:be},t[31]=Y,t[32]=be,t[33]=me,t[34]=re,t[35]=de):de=t[35];let fe;t[36]!==N.length||t[37]!==Pe||t[38]!==C||t[39]!==I||t[40]!==k||t[41]!==m.length||t[42]!==je||t[43]!==he||t[44]!==X||t[45]!==de||t[46]!==_||t[47]!==L||t[48]!==U||t[49]!==W.length?(fe={sessionTitle:je,messagesCount:m.length,userMessagesCount:W.length,assistantMessagesCount:N.length,createdAt:he,lastActivityAt:X,providerModel:k,tokenBreakdown:_,usagePercent:U,cacheHitRate:C,totalAssistantCost:L,contextLimit:I,breakdown:de,breakdownTotal:Pe},t[36]=N.length,t[37]=Pe,t[38]=C,t[39]=I,t[40]=k,t[41]=m.length,t[42]=je,t[43]=he,t[44]=X,t[45]=de,t[46]=_,t[47]=L,t[48]=U,t[49]=W.length,t[50]=fe):fe=t[50];const H=fe;if(!u){let pt;t[51]!==e?(pt=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=pt):pt=t[52];let at;return t[53]!==pt?(at=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:pt}),t[53]=pt,t[54]=at):at=t[54],at}let ge;t[55]!==e?(ge=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=ge):ge=t[56];let Me;t[57]!==ge||t[58]!==H.breakdown.user?(Me={key:"user",label:ge,value:H.breakdown.user,color:"var(--status-success)"},t[57]=ge,t[58]=H.breakdown.user,t[59]=Me):Me=t[59];let Ne;t[60]!==e?(Ne=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=Ne):Ne=t[61];let Ie;t[62]!==Ne||t[63]!==H.breakdown.assistant?(Ie={key:"assistant",label:Ne,value:H.breakdown.assistant,color:"var(--primary-base)"},t[62]=Ne,t[63]=H.breakdown.assistant,t[64]=Ie):Ie=t[64];let Te;t[65]!==e?(Te=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=Te):Te=t[66];let Le;t[67]!==Te||t[68]!==H.breakdown.tool?(Le={key:"tool",label:Te,value:H.breakdown.tool,color:"var(--status-warning)"},t[67]=Te,t[68]=H.breakdown.tool,t[69]=Le):Le=t[69];let _e;t[70]!==e?(_e=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=_e):_e=t[71];let P;t[72]!==_e||t[73]!==H.breakdown.other?(P={key:"other",label:_e,value:H.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=_e,t[73]=H.breakdown.other,t[74]=P):P=t[74];let oe;t[75]!==Me||t[76]!==Ie||t[77]!==Le||t[78]!==P?(oe=[Me,Ie,Le,P],t[75]=Me,t[76]=Ie,t[77]=Le,t[78]=P,t[79]=oe):oe=t[79];const V=oe;let Q;t[80]!==H.sessionTitle?(Q=n.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:H.sessionTitle}),t[80]=H.sessionTitle,t[81]=Q):Q=t[81];let ue;t[82]!==H.providerModel.modelName||t[83]!==H.providerModel.providerName?(ue=n.jsxs("span",{children:[H.providerModel.providerName," / ",H.providerModel.modelName]}),t[82]=H.providerModel.modelName,t[83]=H.providerModel.providerName,t[84]=ue):ue=t[84];let Z;t[85]!==s||t[86]!==H.createdAt?(Z=H.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:Zv(H.createdAt,s)})]}),t[85]=s,t[86]=H.createdAt,t[87]=Z):Z=t[87];let ee;t[88]!==ue||t[89]!==Z?(ee=n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[ue,Z]}),t[88]=ue,t[89]=Z,t[90]=ee):ee=t[90];let ke;t[91]!==Q||t[92]!==ee?(ke=n.jsxs("div",{className:"mb-6",children:[Q,ee]}),t[91]=Q,t[92]=ee,t[93]=ke):ke=t[93];let ne;t[94]!==e?(ne=e("contextSidebar.section.context"),t[94]=e,t[95]=ne):ne=t[95];let q;t[96]!==ne?(q=n.jsx("span",{className:"typography-micro text-muted-foreground",children:ne}),t[96]=ne,t[97]=q):q=t[97];let ie;t[98]!==H.tokenBreakdown.total||t[99]!==H.usagePercent?(ie=H.usagePercent===null?"—":_n(H.tokenBreakdown.total),t[98]=H.tokenBreakdown.total,t[99]=H.usagePercent,t[100]=ie):ie=t[100];let Ee;t[101]!==H.contextLimit?(Ee=H.contextLimit?` / ${_n(H.contextLimit)}`:"",t[101]=H.contextLimit,t[102]=Ee):Ee=t[102];let Ae;t[103]!==ie||t[104]!==Ee?(Ae=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[ie,Ee]}),t[103]=ie,t[104]=Ee,t[105]=Ae):Ae=t[105];let $e;t[106]!==q||t[107]!==Ae?($e=n.jsxs("div",{className:"flex items-baseline justify-between",children:[q,Ae]}),t[106]=q,t[107]=Ae,t[108]=$e):$e=t[108];let Oe;t[109]!==H.usagePercent?(Oe=H.usagePercent!==null&&H.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,H.usagePercent)}%`,backgroundColor:H.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[109]=H.usagePercent,t[110]=Oe):Oe=t[110];let qe;t[111]!==Oe?(qe=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Oe}),t[111]=Oe,t[112]=qe):qe=t[112];let ct;t[113]!==e||t[114]!==H.usagePercent?(ct=H.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:H.usagePercent.toFixed(1)}),t[113]=e,t[114]=H.usagePercent,t[115]=ct):ct=t[115];let Ve;t[116]!==ct?(Ve=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:ct}),t[116]=ct,t[117]=Ve):Ve=t[117];let nt;t[118]!==$e||t[119]!==qe||t[120]!==Ve?(nt=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[$e,qe,Ve]}),t[118]=$e,t[119]=qe,t[120]=Ve,t[121]=nt):nt=t[121];let kt;t[122]!==e?(kt=e("contextSidebar.stats.messages"),t[122]=e,t[123]=kt):kt=t[123];let dt;t[124]!==H.messagesCount?(dt=_n(H.messagesCount),t[124]=H.messagesCount,t[125]=dt):dt=t[125];let yt;t[126]!==kt||t[127]!==dt?(yt={label:kt,value:dt},t[126]=kt,t[127]=dt,t[128]=yt):yt=t[128];let _t;t[129]!==e?(_t=e("contextSidebar.stats.user"),t[129]=e,t[130]=_t):_t=t[130];let Bt;t[131]!==H.userMessagesCount?(Bt=_n(H.userMessagesCount),t[131]=H.userMessagesCount,t[132]=Bt):Bt=t[132];let Lt;t[133]!==_t||t[134]!==Bt?(Lt={label:_t,value:Bt},t[133]=_t,t[134]=Bt,t[135]=Lt):Lt=t[135];let Rt;t[136]!==e?(Rt=e("contextSidebar.stats.assistant"),t[136]=e,t[137]=Rt):Rt=t[137];let Et;t[138]!==H.assistantMessagesCount?(Et=_n(H.assistantMessagesCount),t[138]=H.assistantMessagesCount,t[139]=Et):Et=t[139];let Nt;t[140]!==Rt||t[141]!==Et?(Nt={label:Rt,value:Et},t[140]=Rt,t[141]=Et,t[142]=Nt):Nt=t[142];let ye;t[143]!==e?(ye=e("contextSidebar.stats.cost"),t[143]=e,t[144]=ye):ye=t[144];let He;t[145]!==H.totalAssistantCost?(He=Fx(H.totalAssistantCost),t[145]=H.totalAssistantCost,t[146]=He):He=t[146];let mt;t[147]!==ye||t[148]!==He?(mt={label:ye,value:He},t[147]=ye,t[148]=He,t[149]=mt):mt=t[149];let Ke;t[150]!==yt||t[151]!==Lt||t[152]!==Nt||t[153]!==mt?(Ke=[yt,Lt,Nt,mt],t[150]=yt,t[151]=Lt,t[152]=Nt,t[153]=mt,t[154]=Ke):Ke=t[154];const B=Ke;let Se;t[155]!==B?(Se=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:B.map(f1)}),t[155]=B,t[156]=Se):Se=t[156];let Fe;t[157]!==e?(Fe=e("contextSidebar.section.lastAssistantMessage"),t[157]=e,t[158]=Fe):Fe=t[158];let $;t[159]!==Fe?($=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:Fe}),t[159]=Fe,t[160]=$):$=t[160];let se;t[161]!==e||t[162]!==H.cacheHitRate.hasInput||t[163]!==H.cacheHitRate.percent||t[164]!==H.tokenBreakdown.cacheRead||t[165]!==H.tokenBreakdown.cacheWrite||t[166]!==H.tokenBreakdown.input||t[167]!==H.tokenBreakdown.output||t[168]!==H.tokenBreakdown.reasoning?(se=n.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:H.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:H.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:H.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:H.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:H.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:H.cacheHitRate.hasInput?H.cacheHitRate.percent:null,format:"percent"}].map(p1)}),t[161]=e,t[162]=H.cacheHitRate.hasInput,t[163]=H.cacheHitRate.percent,t[164]=H.tokenBreakdown.cacheRead,t[165]=H.tokenBreakdown.cacheWrite,t[166]=H.tokenBreakdown.input,t[167]=H.tokenBreakdown.output,t[168]=H.tokenBreakdown.reasoning,t[169]=se):se=t[169];let we;t[170]!==$||t[171]!==se?(we=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[$,se]}),t[170]=$,t[171]=se,t[172]=we):we=t[172];let tt;t[173]!==V||t[174]!==H.breakdownTotal?(tt=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:V.map(pt=>pt.value<=0||H.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${pt.value/H.breakdownTotal*100}%`,backgroundColor:pt.color}},pt.key))}),t[173]=V,t[174]=H.breakdownTotal,t[175]=tt):tt=t[175];let rt;t[176]!==V||t[177]!==H.breakdownTotal?(rt=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:V.map(pt=>{const at=H.breakdownTotal>0?pt.value/H.breakdownTotal*100:0;return n.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:pt.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[pt.label," ",n.jsxs("span",{className:"tabular-nums",children:[at.toFixed(0),"%"]})]})]},pt.key)})}),t[176]=V,t[177]=H.breakdownTotal,t[178]=rt):rt=t[178];let Xe;t[179]!==tt||t[180]!==rt?(Xe=n.jsxs("div",{className:"mb-6",children:[tt,rt]}),t[179]=tt,t[180]=rt,t[181]=Xe):Xe=t[181];let G;t[182]!==e?(G=e("contextSidebar.section.rawMessages"),t[182]=e,t[183]=G):G=t[183];let Ce;t[184]!==G?(Ce=n.jsx("div",{className:"typography-micro text-muted-foreground",children:G}),t[184]=G,t[185]=Ce):Ce=t[185];let bt;if(t[186]!==l||t[187]!==i||t[188]!==m||t[189]!==e||t[190]!==s){let pt;t[192]!==l||t[193]!==i||t[194]!==e||t[195]!==s?(pt=at=>{const Be=at.info.role,Ue=Be==="assistant",lt=Be==="user",et=i[at.info.id]===!0,ft=l===at.info.id,Ct=at.info.time?.created??null,it=zv(at.parts),Tt=Ue?Sc({info:at.info,parts:at.parts}):null,$t=lt?Uv(at.parts):"",ss=qv(Ct,s),Re=it||"—",Ze=Tt?Hv(Tt.input,Tt.output,_n):"",ot=Be||"unknown",gt=it?`${ot}: ${it}`:ot,Dt=et?JSON.stringify({info:at.info,parts:at.parts},null,2):"";return n.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[n.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":et,onClick:()=>{o(At=>({...At,[at.info.id]:At[at.info.id]!==!0}))},children:n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:Ue?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[lt?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",$t]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:Ue?Re:gt}),Ue&&n.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Ze})]}),n.jsx("span",{className:"text-right text-muted-foreground",children:ss})]})}),et&&n.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:n.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[n.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:At=>{At.stopPropagation(),w(at.info.id,Dt)},"aria-label":e(ft?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(ft?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:ft?n.jsx(F,{name:"check",className:"size-3.5"}):n.jsx(F,{name:"file-copy",className:"size-3.5"})})}),n.jsx($g,{language:"json",code:Dt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},at.info.id)},t[192]=l,t[193]=i,t[194]=e,t[195]=s,t[196]=pt):pt=t[196],bt=[...m].reverse().map(pt),t[186]=l,t[187]=i,t[188]=m,t[189]=e,t[190]=s,t[191]=bt}else bt=t[191];let xe;t[197]!==bt?(xe=n.jsx("div",{className:"mt-2.5 space-y-1",children:bt}),t[197]=bt,t[198]=xe):xe=t[198];let xt;t[199]!==Ce||t[200]!==xe?(xt=n.jsxs("div",{children:[Ce,xe]}),t[199]=Ce,t[200]=xe,t[201]=xt):xt=t[201];let Mt;return t[202]!==ke||t[203]!==nt||t[204]!==Se||t[205]!==we||t[206]!==Xe||t[207]!==xt?(Mt=n.jsx(gn,{outerClassName:"h-full",className:"bg-background",children:n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ke,nt,Se,we,Xe,xt]})}),t[202]=ke,t[203]=nt,t[204]=Se,t[205]=we,t[206]=Xe,t[207]=xt,t[208]=Mt):Mt=t[208],Mt};function s1(t){return t.timeFormatPreference}function n1(t){return t.currentSessionId}function r1(t){return t.currentSessionDirectory}function o1(t){return t.providers}function i1(t){return Object.keys(t).length>0?{}:t}function a1(t){return t.info.role==="assistant"}function l1(t){return t.info.role==="user"}function c1(t){return t.info}function d1(t,e){const s=An(e.info.cost);return t+s}function u1(t){return t.info.role==="system"}function f1(t){return n.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[n.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function p1(t){return n.jsxs("div",{children:[n.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),n.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)}%`:_n(t.value):"—"})]},t.label)}const m1=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"},h1=async t=>{try{const e=await ds("/api/dev-servers",{signal:t});if(!e.ok)return{kind:"unavailable"};const s=await e.json();if(!s||typeof s!="object")return{kind:"unavailable"};const r=s.servers;return Array.isArray(r)?{kind:"ready",servers:r.filter(m1)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},g1=async t=>{try{const e=await ds("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const s=await e.json();if(!s||typeof s!="object")return null;const r=s.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},b1=t=>{try{const e=new URL(t),s=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(s)&&s>0?s:null}catch{return null}},x1=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const i=b1(r);i!==null&&!s.has(i)&&s.set(i,r)}return e?e.map(r=>{const i=s.get(r.port);return{url:i??r.url,port:r.port,announced:i!==void 0}}).sort((r,i)=>r.announced!==i.announced?r.announced?-1:1:r.port-i.port):[...s.entries()].map(([r,i])=>({url:i,port:r,announced:!0})).sort((r,i)=>r.port-i.port)},ra="__openchamberBrowserAnnotationActive",y1=`(() => {
|
|
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['${ra}']; } catch (error) { /* non-configurable */ }
|
|
21
|
+
})();`,w1=(t,e)=>{const s=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
|
|
22
|
+
var CONFIG = ${s};
|
|
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['${ra}'] = 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['${ra}']; } 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
|
+
});`},v1={kind:"idle"},tn=t=>typeof t=="object"&&t!==null,dn=t=>typeof t=="number"&&Number.isFinite(t),kc=t=>tn(t)&&Object.values(t).every(e=>typeof e=="string"),Ua=t=>tn(t)&&dn(t.x)&&dn(t.y)&&dn(t.width)&&dn(t.height),Ef=t=>tn(t)&&dn(t.x)&&dn(t.y),S1=t=>tn(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"),j1=t=>tn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&Ua(t.bounds)&&Ef(t.center)&&kc(t.attributes)&&kc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(S1),k1=t=>tn(t)&&typeof t.id=="string"&&j1(t.element),C1=t=>tn(t)&&typeof t.id=="string"&&Ua(t.rect),N1=t=>tn(t)&&typeof t.id=="string"&&Ua(t.bounds)&&Array.isArray(t.points)&&t.points.every(Ef),A1=t=>tn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&tn(t.viewport)&&dn(t.viewport.width)&&dn(t.viewport.height)&&dn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(k1)&&Array.isArray(t.regions)&&t.regions.every(C1)&&Array.isArray(t.strokes)&&t.strokes.every(N1),P1=1600,I1=t=>new Promise((e,s)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>s(new Error("Failed to decode browser page capture")),r.src=t}),D1=async({base64:t,mime:e,captureWidth:s,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:d})=>{if(!t)return null;try{const u=await I1(`data:${e};base64,${t}`),f=Math.max(1,u.naturalWidth||s),p=Math.max(1,u.naturalHeight||r),m=f/Math.max(1,i||f),b=p/Math.max(1,o||p),x=Math.min(1,P1/f),v=document.createElement("canvas");v.width=Math.max(1,Math.floor(f*x)),v.height=Math.max(1,Math.floor(p*x));const y=v.getContext("2d");if(!y)return null;y.scale(x,x),y.drawImage(u,0,0,f,p);const g=j=>({x:j.x*m,y:j.y*b,width:j.width*m,height:j.height*b}),h=Math.max(2,2.5*m/Math.max(x,.2));y.strokeStyle=a,y.fillStyle=d;const w=j=>{const N=g(j);y.lineWidth=h,y.fillRect(N.x,N.y,N.width,N.height),y.strokeRect(N.x,N.y,N.width,N.height)};for(const j of l.elements)w(j.element.bounds);for(const j of l.regions)w(j.rect);for(const j of l.strokes)j.points.length<2||(y.beginPath(),j.points.forEach((N,C)=>{const R=N.x*m,T=N.y*b;C===0?y.moveTo(R,T):y.lineTo(R,T)}),y.lineCap="round",y.lineJoin="round",y.lineWidth=h*1.4,y.stroke());const S=await new Promise(j=>v.toBlob(j,"image/jpeg",.85));return S?new File([S],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},E1="({ width: window.innerWidth, height: window.innerHeight })",R1=async t=>{try{const e=await t.executeJavaScript(E1,!0);if(!e||typeof e!="object")return null;const s=e;return typeof s.width!="number"||typeof s.height!="number"||!Number.isFinite(s.width)||!Number.isFinite(s.height)?null:{width:s.width,height:s.height}}catch{return null}},yo=async t=>{try{await t.executeJavaScript(y1,!1)}catch{}},M1=async({host:t,theme:e,labels:s})=>{const r=w1(e,s),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!A1(i))return await yo(t),null;const o=i;try{const l=await R1(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const d=await D1({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:l.width,cssHeight:l.height,payload:o,accentColor:e.primary,accentFill:e.primarySoft});return{payload:o,screenshot:d}}catch{return{payload:o,screenshot:null}}},Bs={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)"},T1=()=>{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 s=window.getComputedStyle(t).backgroundColor;return s&&s!=="rgba(0, 0, 0, 0)"?s:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},O1=t=>{const e=T1();if(!e)return{...Bs,colorScheme:t};try{const s=(a,d)=>e.read(`var(${a})`)||d,r=(a,d,u)=>e.read(`color-mix(in srgb, var(${a}) ${d}%, transparent)`)||u,i=e.readVariable("--oc-glass-tooltip-opacity")||"62%",o=e.readVariable("--oc-glass-blur")||"26px",l=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${i}, transparent)`)||Bs.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:s("--primary",Bs.primary),primarySoft:r("--primary",16,Bs.primarySoft),primaryFaint:r("--primary",10,Bs.primaryFaint),primaryContrast:s("--primary-foreground",Bs.primaryContrast),surface:s("--surface-background",Bs.surface),surfaceElevated:s("--surface-elevated",Bs.surfaceElevated),border:s("--border",Bs.border),text:s("--foreground",Bs.text),mutedText:s("--muted-foreground",Bs.mutedText)}}catch{return{...Bs,colorScheme:t}}finally{e.dispose()}},B1=2e3,F1=50,L1=400,$s=new Map,fn=new Map;let wo=null,En=null,Ir=null;const oa=async t=>{try{const e=await ds("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===!0:!1}catch{return!1}},cn=async(t,e)=>{try{const s=await ds("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});s.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${s.status}); the agent will see this action time out`)}catch(s){console.warn(`[browser-control] could not deliver the result for ${t}:`,s)}},Rf=async(t,e=B1)=>{const s=Date.now()+e;for(;!$s.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,F1));return $s.get(t)??null},ia=t=>$s.has(t)||fn.has(t),Cc=t=>{let e=null;for(const s of t.keys())e=s;return e},Mf=()=>wo&&ia(wo)?wo:Cc($s)??Cc(fn),Tf=async t=>{const e=$s.get(t);if(e)return e;const s=fn.get(t);return s?(s.wake(),Rf(t)):null},_1=()=>{const t=Mf();return[...$s.values(),...[...fn.values()].filter(s=>!$s.has(s.tabId))].map(s=>{let r={title:"",url:""};try{r=s.describe()}catch{}return{id:s.tabId,title:r.title,url:r.url,active:s.tabId===t}})},Of=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,$1=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.`,W1=async t=>{const e=t.action==="browser.open",{tabId:s,...r}=t.parameters,i=s===void 0?null:String(s);if(i!==null){if(!ia(i)){if($s.size===0&&fn.size===0&&!En)return;if(await new Promise(l=>setTimeout(l,L1)),ia(i)){await Nc(t,i,r);return}if(!await oa(t.requestId))return;await cn(t.requestId,{ok:!1,error:$1(i)});return}await Nc(t,i,r);return}const o=Mf();if(!(!o&&!(e&&En))&&await oa(t.requestId))try{const l=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!l){await cn(t.requestId,{ok:!1,error:"url is required"});return}const a=e&&En?En(l):null;if(e&&!a&&!o){await cn(t.requestId,{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 cn(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a}});return}const f=await Rf(a);if(!f){await cn(t.requestId,{ok:!0,data:{url:l,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 cn(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a,viewportApplied:!0,viewport:m}});return}const d=await Tf(o);await cn(t.requestId,d?await Bf(d,t.action,r):{ok:!1,error:Of(o)})}catch(l){await cn(t.requestId,{ok:!1,error:l instanceof Error?l.message:String(l)})}},Nc=async(t,e,s)=>{if(!await oa(t.requestId))return;const r=await Tf(e);await cn(t.requestId,r?await Bf(r,t.action,s):{ok:!1,error:Of(e)})},Bf=async(t,e,s)=>{try{const r=await t.run(e,s);return e==="browser.snapshot"&&Object(r)===r?{ok:!0,data:{...Object(r),tabs:_1()}}:{ok:!0,data:r}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},Ha=()=>{Ir||(Ir=Qn(t=>{t.type==="browser-control-request"&&W1({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Ga=()=>{$s.size>0||fn.size>0||En||!Ir||(Ir(),Ir=null)},K1=t=>($s.set(t.tabId,t),Ha(),()=>{$s.get(t.tabId)===t&&$s.delete(t.tabId),Ga()}),z1=t=>(fn.set(t.tabId,t),Ha(),()=>{fn.get(t.tabId)===t&&fn.delete(t.tabId),Ga()}),V1=t=>{wo=t},U1=t=>(En=t,Ha(),()=>{En===t&&(En=null),Ga()}),H1=50,G1=6,q1=2048,Y1=200,Ff=t=>{const e=lr(String(t??"").trim());if(!e||e.length>q1)return"";try{const s=new URL(e);return s.protocol!=="http:"&&s.protocol!=="https:"?"":s.toString()}catch{return""}},Q1=(t,e)=>{const s=Ff(e.url);if(!s)return t;const r=t.find(l=>l.url===s),i=String(e.title??"").trim().slice(0,Y1)||r?.title||"";return[{url:s,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==s)].slice(0,H1)},X1=(t,e)=>{const s=Ff(e);return t.filter(r=>r.url!==s)},J1=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Lf=(t,e,s=G1)=>{const r=String(e??"").trim().toLowerCase(),i=[...t].sort((l,a)=>a.lastVisitedAt-l.lastVisitedAt);if(!r)return i.slice(0,s);const o=r.replace(/^https?:\/\//,"");return i.filter(l=>{const a=J1(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,s)},Ac=20,vo=t=>{const e=ut((t||"").trim());return e?JSON.stringify([Qt(),e]):""},Z1=t=>{const e=Object.keys(t);if(e.length<=Ac)return t;const s=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,Ac);return Object.fromEntries(s.map(([r])=>[r,t[r]??[]]))},dr=Lr()(ey(t=>({byProject:{},recordVisit:(e,s)=>{const r=vo(e);r&&t(i=>{const o=i.byProject[r]??[],l=Q1(o,{...s,at:Date.now()});return l===o?i:{byProject:Z1({...i.byProject,[r]:l})}})},forget:(e,s)=>{const r=vo(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:X1(o,s)}}:i})},clear:e=>{const s=vo(e);s&&t(r=>{if(!(s in r.byProject))return r;const i={...r.byProject};return delete i[s],{byProject:i}})}}),{name:"openchamber-browser-history",version:1,storage:fm(),partialize:t=>({byProject:t.byProject})})),eS=[],_f=t=>e=>{const s=vo(t);return(s?e.byProject[s]:void 0)??eS},Pc=6e3,tS=120,sS=80,nS=`
|
|
690
|
+
var MAX_ELEMENTS = ${tS};
|
|
691
|
+
var MAX_LABEL_CHARS = ${sS};
|
|
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
|
+
`,_r=t=>`(() => {
|
|
805
|
+
${nS}
|
|
806
|
+
${t}
|
|
807
|
+
})()`,rS=({selector:t}={})=>_r(`
|
|
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, ${Pc}),
|
|
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 > ${Pc}) {
|
|
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
|
+
`),oS=({selector:t,text:e})=>_r(`
|
|
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
|
+
`),iS=({selector:t,value:e,submit:s})=>_r(`
|
|
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 (${s?"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
|
+
`),aS=({selector:t,direction:e})=>_r(`
|
|
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
|
+
`),lS=["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"],cS=({selector:t})=>_r(`
|
|
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(lS)};
|
|
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
|
+
`),dS=t=>{const e=Ye.c(18),{entries:s,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=jt();if(s.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==s||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let p;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(p=(m,b)=>n.jsxs("div",{role:"option","aria-selected":b===r,className:De("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",b===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:x=>{x.preventDefault(),i(m.url)},onPointerEnter:()=>l(b),children:[n.jsx(F,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-micro text-foreground",children:m.title||wa(m.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.url})]}),n.jsx("button",{type:"button",className:De("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(),o(m.url)},children:n.jsx(F,{name:"close",className:"size-3","aria-hidden":"true"})})]},m.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=p):p=e[14],u=s.map(p),e[2]=r,e[3]=s,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let f;return e[15]!==d||e[16]!==u?(f=n.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":d,children:u}),e[15]=d,e[16]=u,e[17]=f):f=e[17],f},Fs=t=>{const e=Ye.c(17),{icon:s,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=De("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let f;e[2]!==s?(f=n.jsx(F,{name:s,className:"size-3.5","aria-hidden":"true"}),e[2]=s,e[3]=f):f=e[3];let p;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==f?(p=n.jsx(St,{asChild:!0,children:n.jsx(ht,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:f})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=f,e[11]=p):p=e[11];let m;e[12]!==r?(m=n.jsx(wt,{sideOffset:6,children:r}),e[12]=r,e[13]=m):m=e[13];let b;return e[14]!==p||e[15]!==m?(b=n.jsxs(vt,{children:[p,m]}),e[14]=p,e[15]=m,e[16]=b):b=e[16],b},$f=t=>{const e=Ye.c(104),{address:s,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:f,canGoBack:p,canGoForward:m,isLoading:b,onAnnotate:x,onOpenDevTools:v,isAnnotating:y,onHardReload:g,onZoomIn:h,onZoomOut:w,onZoomReset:S,zoomPercent:j,onClearCookies:N,onClearCache:C,onToggleDeviceBar:R,isDeviceBarOpen:T}=t;let O;e[0]!==r?(O=r===void 0?[]:r,e[0]=r,e[1]=O):O=e[1];const _=O,W=j===void 0?100:j,{t:L}=jt(),[K,A]=c.useState(!1),[D,E]=c.useState(-1);let M;e[2]!==K||e[3]!==_?(M=K?_:[],e[2]=K,e[3]=_,e[4]=M):M=e[4];const k=M;let I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{E(-1)},e[5]=I):I=e[5];let U;e[6]!==s||e[7]!==K?(U=[s,K],e[6]=s,e[7]=K,e[8]=U):U=e[8],c.useEffect(I,U);let z;e[9]!==l?(z=Ee=>{A(!1),E(-1),l(Ee)},e[9]=l,e[10]=z):z=e[10];const ce=z;let re;e[11]!==D||e[12]!==ce||e[13]!==k?(re=Ee=>{if(k.length!==0){if(Ee.key==="ArrowDown"||Ee.key==="ArrowUp"){Ee.preventDefault();const Ae=Ee.key==="ArrowDown"?1:-1,$e=k.length;E(Oe=>{const qe=Oe+Ae;return qe<-1?$e-1:qe>=$e?-1:qe});return}if(Ee.key==="Escape"&&D>=0){Ee.preventDefault(),E(-1);return}if(Ee.key==="Enter"&&D>=0){Ee.preventDefault();const Ae=k[D];Ae&&ce(Ae.url)}}},e[11]=D,e[12]=ce,e[13]=k,e[14]=re):re=e[14];const Y=re;let me;e[15]!==L?(me=L("contextPanel.browser.back"),e[15]=L,e[16]=me):me=e[16];const be=!p;let Pe;e[17]!==a||e[18]!==be||e[19]!==me?(Pe=n.jsx(Fs,{icon:"arrow-left",label:me,onClick:a,disabled:be}),e[17]=a,e[18]=be,e[19]=me,e[20]=Pe):Pe=e[20];let le;e[21]!==L?(le=L("contextPanel.browser.forward"),e[21]=L,e[22]=le):le=e[22];const pe=!m;let je;e[23]!==d||e[24]!==le||e[25]!==pe?(je=n.jsx(Fs,{icon:"arrow-right",label:le,onClick:d,disabled:pe}),e[23]=d,e[24]=le,e[25]=pe,e[26]=je):je=e[26];let he;e[27]!==b||e[28]!==L?(he=L(b?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=b,e[28]=L,e[29]=he):he=e[29];let X;e[30]!==u||e[31]!==he?(X=n.jsx(Fs,{icon:"refresh",label:he,onClick:u}),e[30]=u,e[31]=he,e[32]=X):X=e[32];let de;e[33]!==g||e[34]!==L?(de=g?n.jsx(Fs,{icon:"restart",label:L("contextPanel.browser.hardReload"),onClick:g}):null,e[33]=g,e[34]=L,e[35]=de):de=e[35];let fe;e[36]!==s||e[37]!==ce?(fe=Ee=>{Ee.preventDefault(),ce(s)},e[36]=s,e[37]=ce,e[38]=fe):fe=e[38];let H;e[39]!==o?(H=Ee=>o(Ee.target.value),e[39]=o,e[40]=H):H=e[40];let ge,Me;e[41]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>A(!0),Me=()=>A(!1),e[41]=ge,e[42]=Me):(ge=e[41],Me=e[42]);const Ne=k.length>0;let Ie;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ie=De("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]=Ie):Ie=e[43];let Te;e[44]!==L?(Te=L("contextPanel.browser.addressAria"),e[44]=L,e[45]=Te):Te=e[45];let Le;e[46]!==s||e[47]!==Y||e[48]!==H||e[49]!==Ne||e[50]!==Te?(Le=n.jsx("input",{value:s,onChange:H,onFocus:ge,onBlur:Me,onKeyDown:Y,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Ne,"aria-controls":"openchamber-browser-address-suggestions",className:Ie,"aria-label":Te}),e[46]=s,e[47]=Y,e[48]=H,e[49]=Ne,e[50]=Te,e[51]=Le):Le=e[51];let _e;e[52]!==i?(_e=Ee=>i?.(Ee),e[52]=i,e[53]=_e):_e=e[53];let P;e[54]!==D||e[55]!==ce||e[56]!==_e||e[57]!==k?(P=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(dS,{entries:k,activeIndex:D,onSelect:ce,onForget:_e,onHighlight:E})}),e[54]=D,e[55]=ce,e[56]=_e,e[57]=k,e[58]=P):P=e[58];let oe;e[59]!==fe||e[60]!==Le||e[61]!==P?(oe=n.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:fe,children:[Le,P]}),e[59]=fe,e[60]=Le,e[61]=P,e[62]=oe):oe=e[62];let V;e[63]!==h||e[64]!==w||e[65]!==S||e[66]!==L||e[67]!==W?(V=w&&h?n.jsxs("div",{className:"flex shrink-0 items-center",children:[n.jsx(Fs,{icon:"subtract",label:L("contextPanel.browser.zoomOut"),onClick:w}),W!==100&&S?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ht,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:S,"aria-label":L("contextPanel.browser.zoomReset"),children:[W,"%"]})}),n.jsx(wt,{sideOffset:6,children:L("contextPanel.browser.zoomReset")})]}):null,n.jsx(Fs,{icon:"add",label:L("contextPanel.browser.zoomIn"),onClick:h})]}):null,e[63]=h,e[64]=w,e[65]=S,e[66]=L,e[67]=W,e[68]=V):V=e[68];let Q;e[69]!==N||e[70]!==L?(Q=N?n.jsx(Fs,{icon:"delete-bin",label:L("contextPanel.browser.clearCookies"),onClick:N}):null,e[69]=N,e[70]=L,e[71]=Q):Q=e[71];let ue;e[72]!==C||e[73]!==L?(ue=C?n.jsx(Fs,{icon:"database-2",label:L("contextPanel.browser.clearCache"),onClick:C}):null,e[72]=C,e[73]=L,e[74]=ue):ue=e[74];let Z;e[75]!==T||e[76]!==R||e[77]!==L?(Z=R?n.jsx(Fs,{icon:"smartphone",label:L("contextPanel.browser.deviceToolbar"),onClick:R,pressed:T}):null,e[75]=T,e[76]=R,e[77]=L,e[78]=Z):Z=e[78];let ee;e[79]!==y||e[80]!==x||e[81]!==L?(ee=x?n.jsx(Fs,{icon:"markup",label:L("contextPanel.browser.annotate.toggle"),onClick:x,pressed:y}):null,e[79]=y,e[80]=x,e[81]=L,e[82]=ee):ee=e[82];let ke;e[83]!==v||e[84]!==L?(ke=v?n.jsx(Fs,{icon:"terminal-box",label:L("contextPanel.browser.devTools"),onClick:v}):null,e[83]=v,e[84]=L,e[85]=ke):ke=e[85];let ne;e[86]!==L?(ne=L("contextPanel.browser.openExternal"),e[86]=L,e[87]=ne):ne=e[87];let q;e[88]!==f||e[89]!==ne?(q=n.jsx(Fs,{icon:"external-link",label:ne,onClick:f}),e[88]=f,e[89]=ne,e[90]=q):q=e[90];let ie;return e[91]!==Pe||e[92]!==je||e[93]!==X||e[94]!==de||e[95]!==oe||e[96]!==V||e[97]!==Q||e[98]!==ue||e[99]!==Z||e[100]!==ee||e[101]!==ke||e[102]!==q?(ie=n.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Pe,je,X,de,oe,V,Q,ue,Z,ee,ke,q]}),e[91]=Pe,e[92]=je,e[93]=X,e[94]=de,e[95]=oe,e[96]=V,e[97]=Q,e[98]=ue,e[99]=Z,e[100]=ee,e[101]=ke,e[102]=q,e[103]=ie):ie=e[103],ie},Do={kind:"fill"},Ic=240,uS=3840,Wf=[{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}],Dc=t=>Number.isFinite(t)?Math.round(Math.min(uS,Math.max(Ic,t))):Ic,Eo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Kf=t=>{const e=Wf.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},fS=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},pS=(t,e)=>{const s=Eo(t);if(!s)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/s.width,i/s.height);return{width:s.width,height:s.height,scale:o}},mS=["mobile","tablet","desktop","fill"],hS={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Ec=t=>typeof t=="string"&&mS.includes(t),aa=t=>t==="fill"?Do:Kf(hS[t])??Do,Zr=t=>{const e=Eo(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=aa(s),i=Eo(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:s,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},gS=t=>{const e=Ye.c(70),{viewport:s,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=jt();let d;e[0]!==s?(d=Eo(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=s.kind==="preset"?s.id:"";let p;e[2]!==r||e[3]!==u?(p=(be,Pe)=>{const le=Number.parseInt(Pe,10);if(!Number.isFinite(le))return;const pe=u??{width:1280,height:800};r({kind:"custom",width:Dc(be==="width"?le:pe.width),height:Dc(be==="height"?le:pe.height)})},e[2]=r,e[3]=u,e[4]=p):p=e[4];const m=p;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=De("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]=b):b=e[5];const x=b;let v;e[6]!==r?(v=be=>{const Pe=Kf(be.target.value);r(Pe??Do)},e[6]=r,e[7]=v):v=e[7];let y;e[8]!==a?(y=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=y):y=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=De("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 w;e[13]!==h?(w=n.jsx("option",{value:"",children:h}),e[13]=h,e[14]=w):w=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=Wf.map(bS),e[15]=S):S=e[15];let j;e[16]!==f||e[17]!==v||e[18]!==y||e[19]!==w?(j=n.jsxs("select",{value:f,onChange:v,"aria-label":y,className:g,children:[w,S]}),e[16]=f,e[17]=v,e[18]=y,e[19]=w,e[20]=j):j=e[20];const N=u?String(u.width):"";let C;e[21]!==m?(C=be=>m("width",be.target.value),e[21]=m,e[22]=C):C=e[22];let R;e[23]!==a?(R=a("contextPanel.browser.device.width"),e[23]=a,e[24]=R):R=e[24];let T;e[25]!==N||e[26]!==C||e[27]!==R?(T=n.jsx("input",{value:N,onChange:C,placeholder:"—",inputMode:"numeric","aria-label":R,className:x}),e[25]=N,e[26]=C,e[27]=R,e[28]=T):T=e[28];let O;e[29]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=O):O=e[29];const _=u?String(u.height):"";let W;e[30]!==m?(W=be=>m("height",be.target.value),e[30]=m,e[31]=W):W=e[31];let L;e[32]!==a?(L=a("contextPanel.browser.device.height"),e[32]=a,e[33]=L):L=e[33];let K;e[34]!==_||e[35]!==W||e[36]!==L?(K=n.jsx("input",{value:_,onChange:W,placeholder:"—",inputMode:"numeric","aria-label":L,className:x}),e[34]=_,e[35]=W,e[36]=L,e[37]=K):K=e[37];let A;e[38]!==r||e[39]!==s?(A=()=>r(fS(s)),e[38]=r,e[39]=s,e[40]=A):A=e[40];const D=!u;let E;e[41]!==a?(E=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=E):E=e[42];let M;e[43]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(F,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=M):M=e[43];let k;e[44]!==A||e[45]!==D||e[46]!==E?(k=n.jsx(St,{asChild:!0,children:n.jsx(ht,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:A,disabled:D,"aria-label":E,children:M})}),e[44]=A,e[45]=D,e[46]=E,e[47]=k):k=e[47];let I;e[48]!==a?(I=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=I):I=e[49];let U;e[50]!==I?(U=n.jsx(wt,{sideOffset:6,children:I}),e[50]=I,e[51]=U):U=e[51];let z;e[52]!==k||e[53]!==U?(z=n.jsxs(vt,{children:[k,U]}),e[52]=k,e[53]=U,e[54]=z):z=e[54];let ce;e[55]!==l||e[56]!==u?(ce=u&&l<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=ce):ce=e[57];let re;e[58]===Symbol.for("react.memo_cache_sentinel")?(re=["system","light","dark"],e[58]=re):re=e[58];let Y;e[59]!==i||e[60]!==o||e[61]!==a?(Y=n.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:re.map(be=>n.jsx(ht,{type:"button",variant:i===be?"secondary":"ghost",size:"xs",className:De("shrink-0 rounded-full px-2.5 typography-micro",i===be?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(be),"aria-pressed":i===be,children:a(be==="system"?"contextPanel.browser.device.schemeSystem":be==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},be))}),e[59]=i,e[60]=o,e[61]=a,e[62]=Y):Y=e[62];let me;return e[63]!==j||e[64]!==T||e[65]!==K||e[66]!==z||e[67]!==ce||e[68]!==Y?(me=n.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[j,T,O,K,z,ce,Y]}),e[63]=j,e[64]=T,e[65]=K,e[66]=z,e[67]=ce,e[68]=Y,e[69]=me):me=e[69],me};function bS(t){return n.jsx("option",{value:t.id,children:t.label},t.id)}const xS=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},yS=2e3,wS=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=fr();if(!t)return!1;try{return!Kd(new URL(t,window.location.href).toString())}catch{return!1}},zf=t=>{const e=Ye.c(33),{onOpen:s,directory:r}=t,i=r===void 0?"":r,{t:o}=jt();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,d]=c.useState(l),u=Cy(i),[f]=c.useState(wS);let p,m;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{let T=!0,O=null;const _=new AbortController,W=()=>{h1(_.signal).then(L=>{T&&(d(L),O=setTimeout(W,yS))})};return W(),()=>{T=!1,O&&clearTimeout(O),_.abort()}},m=[],e[1]=p,e[2]=m):(p=e[1],m=e[2]),c.useEffect(p,m);const b=a.kind==="ready"?a.servers:null;let x;e[3]!==u||e[4]!==b?(x=x1({announced:u,discovered:b}),e[3]=u,e[4]=b,e[5]=x):x=e[5];const v=x;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Au,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=y):y=e[6];let g;e[7]!==o?(g=o("contextPanel.browser.empty"),e[7]=o,e[8]=g):g=e[8];let h;e[9]!==g?(h=n.jsx("span",{className:"typography-ui-header text-foreground",children:g}),e[9]=g,e[10]=h):h=e[10];let w;e[11]!==o?(w=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=w):w=e[12];let S;e[13]!==w?(S=n.jsx("span",{className:"typography-micro text-muted-foreground",children:w}),e[13]=w,e[14]=S):S=e[14];let j;e[15]!==S||e[16]!==h?(j=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[h,S]}),e[15]=S,e[16]=h,e[17]=j):j=e[17];let N;e[18]!==u||e[19]!==v||e[20]!==i||e[21]!==s||e[22]!==f||e[23]!==o?(N=v.length>0?n.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[n.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),f?n.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,n.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:v.map(T=>n.jsxs(ht,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{Sy(i),s(T.url)},children:[n.jsx(F,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",children:wa(T.url)||T.url}),n.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:xS(T.url)})]},T.port))})]}):null,e[18]=u,e[19]=v,e[20]=i,e[21]=s,e[22]=f,e[23]=o,e[24]=N):N=e[24];let C;e[25]!==v.length||e[26]!==a.kind||e[27]!==o?(C=v.length===0&&a.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=v.length,e[26]=a.kind,e[27]=o,e[28]=C):C=e[28];let R;return e[29]!==j||e[30]!==N||e[31]!==C?(R=n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[y,j,N,C]}),e[29]=j,e[30]=N,e[31]=C,e[32]=R):R=e[32],R},Ss=t=>Math.round(t),vS=(t,e)=>{const s=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,s?`- Text: ${s}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Ss(l.x)}, y=${Ss(l.y)}, width=${Ss(l.width)}, height=${Ss(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},SS=(t,e)=>{const s=t.rect;return`Region ${e+1}: x=${Ss(s.x)}, y=${Ss(s.y)}, width=${Ss(s.width)}, height=${Ss(s.height)}`},jS=(t,e)=>{const s=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Ss(s.x)}, y=${Ss(s.y)}, width=${Ss(s.width)}, height=${Ss(s.height)}`},kS=({payload:t,screenshotAttached:e,intro:s})=>{const r=s.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Ss(t.viewport.width)}x${Ss(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...vS(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(SS(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(jS(l,a)))),o.filter(l=>typeof l=="string").join(`
|
|
994
|
+
`)},CS=t=>{const e=Ye.c(7),{t:s}=jt(),r=Je(AS),i=Je(PS),o=Li(IS),l=Wg(DS);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==s?(a=async d=>{const u=r??(i?"draft":null);if(!u){We.error(s("contextPanel.browser.annotate.noSession"));return}let f=!1;if(d.screenshot)try{await l(d.screenshot),f=!0}catch{f=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:kS({payload:d.payload,screenshotAttached:f,intro:s("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),We.success(s("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=s,e[6]=a):a=e[6],a},NS=()=>{const t=Ye.c(16),{t:e}=jt();let s;t[0]!==e?(s=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=s):s=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==s||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:s,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=s,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function AS(t){return t.currentSessionId}function PS(t){return t.newSessionDraft?.open}function IS(t){return t.addDraft}function DS(t){return t.addAttachedFile}const ES=3e4,RS=3,MS=250,TS={attempts:0,windowStartedAt:null},OS=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=ES,r=s?0:t.attempts;return r>=RS?null:{delayMs:MS*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},BS=-3,eo=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},FS=(t,{initialUrl:e,onUrlChange:s})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:v1),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,f]=c.useState(!1),[p,m]=c.useState(!1),b=c.useRef(s);b.current=s;const x=c.useRef(TS);return c.useEffect(()=>{if(!t)return;const v=()=>{try{const O=t.getURL();return eo(O)?O:""}catch{return""}},y=()=>{try{f(t.canGoBack()),m(t.canGoForward())}catch{}},g=O=>{eo(O)&&(l(O),b.current(O))},h=()=>{const O=v();i({kind:"loading",url:O})},w=()=>{const O=v();let _="";try{_=t.getTitle()||""}catch{_=""}d(_),g(O),y(),i(W=>W.kind==="failed"?W:{kind:"ready",url:O,title:_})},S=O=>{const _=ir(O);eo(_.url)&&(g(_.url),y())},j=O=>{const _=ir(O),W=Array.isArray(_.favicons)?_.favicons.find(Boolean):"",L=v();W&&L&&Df.getState().resolve(L,W)},N=O=>{const _=ir(O);typeof _.title=="string"&&d(_.title)},C=O=>{const _=ir(O);if(_.isMainFrame===!1)return;const W=typeof _.errorCode=="number"?_.errorCode:0;W!==BS&&i({kind:"failed",url:eo(_.validatedURL)?_.validatedURL:v(),code:W,description:typeof _.errorDescription=="string"?_.errorDescription:""})};let R=null;const T=()=>{const O=v(),_=OS(x.current,Date.now());if(!_){i({kind:"failed",url:O,code:0,description:"",crashed:!0});return}x.current=_.state,i({kind:"loading",url:O}),R=setTimeout(()=>{R=null;try{t.reload()}catch{i({kind:"failed",url:O,code:0,description:"",crashed:!0})}},_.delayMs)};t.addEventListener("did-start-loading",h),t.addEventListener("did-stop-loading",w),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",T),t.addEventListener("crashed",T);try{!t.isLoading()&&v()&&w()}catch{}return()=>{R!==null&&clearTimeout(R),t.removeEventListener("render-process-gone",T),t.removeEventListener("crashed",T),t.removeEventListener("did-start-loading",h),t.removeEventListener("did-stop-loading",w),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:o,title:a,canGoBack:u,canGoForward:p}},LS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,to=.5,_S=-3,$S=4,WS="persist:openchamber-browser",Rc=20,KS=600,zS=2e4,VS=15e3,US=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}},HS=({initialUrl:t,directory:e,tabID:s})=>{const{t:r}=jt(),{currentTheme:i}=mr(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(q=>{o.current=q,a(q)},[]),u=ve(q=>q.setContextPanelTabTargetPath),f=c.useRef(lr(t)),p=f.current!==Pn?f.current:"",[m,b]=c.useState(p?null:Pn),[x,v]=c.useState(p),[y,g]=c.useState(!1),[h,w]=c.useState(!1),[S,j]=c.useState(0),N=c.useRef(0),[C,R]=c.useState(!1),[T,O]=c.useState(Do),_=c.useRef(T);_.current=T;const W=c.useRef([]),[L,K]=c.useState("system"),[A,D]=c.useState({width:0,height:0}),E=c.useRef(null),M=c.useRef(null),k=In(e),I=c.useRef(!!p&&!pm(k,s));c.useEffect(()=>{zd(k,s)},[k,s]);const U=c.useRef(!1),z=c.useRef(Date.now()),ce=c.useCallback(q=>{!q||q===Pn||!e||!s||u(e,s,q)},[e,s,u]),re=FS(l,{initialUrl:p,onUrlChange:c.useCallback(q=>{const ie=er(q);v(ie),ce(ie)},[ce])}),[Y,me]=c.useState(null),be=CS(e),Pe=NS(),le=re.status.kind==="loading",pe=dr(_f(e)),je=dr(q=>q.recordVisit),he=dr(q=>q.forget);c.useEffect(()=>{re.status.kind==="ready"&&je(e,{url:er(re.status.url),title:re.status.title})},[e,re.status,je]);const X=c.useMemo(()=>Lf(pe,x),[pe,x]),de=c.useCallback(q=>{const ie=lr(q);ie!==Pn&&(I.current=!1,v(ie),me(null),vl(ie).then(Ee=>{const Ae=o.current;if(!Ae){b(Ee);return}try{Ae.loadURL(Ee)}catch{b(Ee)}}).catch(Ee=>{Ee instanceof Sl&&me(ie)}))},[]);c.useEffect(()=>{if(!p)return;let q=!0;return vl(p).then(ie=>{q&&b(ie)}).catch(ie=>{if(q){if(ie instanceof Sl){me(p),I.current=!1,b(Pn);return}b(p)}}),()=>{q=!1}},[]);const fe=c.useMemo(()=>({executeJavaScript:async(q,ie)=>{const Ee=o.current;if(!Ee)throw new Error("Browser view is not available");return Ee.executeJavaScript(q,ie)},capturePage:async()=>{const q=o.current;if(!q)return null;const ie=q.getWebContentsId();return Number.isFinite(ie)?await go("desktop_browser_capture_page",{webContentsId:ie}):null}}),[]),H=c.useCallback(()=>{if(y){g(!1),yo(fe);return}if(!re.url){We.error(r("contextPanel.browser.annotate.noPage"));return}const q=O1(i.metadata.variant==="light"?"light":"dark");g(!0),M1({host:fe,theme:q,labels:Pe}).then(async ie=>{g(!1),ie&&await be(ie)}).catch(()=>{g(!1),We.error(r("contextPanel.browser.annotate.failed"))})},[fe,be,i,y,re.url,Pe,r]);c.useEffect(()=>{if(!y)return;const q=ie=>{Kg(ie)||ie.key!=="Escape"||(ie.preventDefault(),ie.stopImmediatePropagation(),g(!1),yo(fe))};return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[fe,y]);const ge=c.useRef(!1);c.useEffect(()=>{if(!l)return;const q=()=>{ge.current=!0};return l.addEventListener("dom-ready",q),l.addEventListener("did-fail-load",q),()=>{l.removeEventListener("dom-ready",q),l.removeEventListener("did-fail-load",q)}},[l]);const Me=c.useCallback(async()=>{const q=Date.now()+VS;for(;!(o.current&&ge.current)&&Date.now()<q;)await new Promise(ie=>setTimeout(ie,100));return o.current},[]),Ne=c.useCallback(async(q=8e3)=>{const ie=Date.now();for(;;){const Ee=o.current;if(!Ee)return!1;let Ae=!1;try{Ae=Ee.isLoading()}catch{return!1}if(!Ae)return!0;if(Date.now()-ie>q)return!1;await new Promise($e=>setTimeout($e,120))}},[]),Ie=c.useCallback(async(q,ie)=>{const Ee=await Me();if(!Ee)throw new Error("The browser panel is not ready");const Ae=()=>{Ec(ie.viewport)&&(O(aa(ie.viewport)),R(!0))};if(q==="browser.back"||q==="browser.forward"){const nt=q==="browser.back";if(!(nt?Ee.canGoBack():Ee.canGoForward()))throw new Error(nt?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");nt?Ee.goBack():Ee.goForward(),await new Promise(yt=>setTimeout(yt,150)),await Ne();let dt="";try{dt=Ee.getTitle()||""}catch{dt=""}return{url:er(Ee.getURL()),title:dt}}if(q==="browser.capture"){const nt=US(E.current);try{await new Promise(yt=>{requestAnimationFrame(()=>requestAnimationFrame(()=>yt()))}),await Ne();const kt=await fe.capturePage();if(!kt)throw new Error("The page could not be captured");let dt="";try{dt=Ee.getTitle()||""}catch{dt=""}return{...kt,url:er(Ee.getURL()),title:dt,viewport:Zr(_.current)}}finally{nt()}}if(q==="browser.resize"){if(!Ec(ie.viewport))throw new Error("viewport is required");return Ae(),await new Promise(nt=>setTimeout(nt,200)),await Ne(),{viewport:Zr(aa(ie.viewport))}}if(q==="browser.open"){const nt=typeof ie.url=="string"?ie.url:"";if(!nt)throw new Error("url is required");Ae(),de(nt),await new Promise(yt=>setTimeout(yt,150));const kt=await Ne(25e3);let dt="";try{dt=Ee.getTitle()||""}catch{dt=""}return{url:lr(nt),title:dt,opened:!0,settled:kt,viewport:Zr(_.current)}}await Ne();const $e=nt=>typeof nt=="string"&&nt?nt:void 0,qe=(()=>{switch(q){case"browser.snapshot":return rS({selector:$e(ie.selector)});case"browser.click":return oS({selector:$e(ie.selector),text:$e(ie.text)});case"browser.type":return iS({selector:String(ie.selector??""),value:String(ie.value??""),submit:ie.submit===!0});case"browser.inspect":return cS({selector:String(ie.selector??"")});case"browser.scroll":return aS({selector:$e(ie.selector),direction:$e(ie.direction)});default:return null}})();if(!qe)throw new Error(`Unsupported browser action: ${q}`);const ct=await Ee.executeJavaScript(qe,!0);if(!ct||typeof ct!="object")throw new Error("The page returned no result");const Ve=ct;if(Ve.ok!==!0)throw new Error(typeof Ve.error=="string"&&Ve.error?Ve.error:"Browser action failed");if(q==="browser.snapshot"){const nt=W.current;return{...Ve,viewport:Zr(_.current),...nt.length>0?{consoleProblems:[...nt]}:{}}}return(q==="browser.click"||q==="browser.type"&&ie.submit===!0)&&(await new Promise(nt=>setTimeout(nt,150)),await Ne()),ct},[fe,de,Ne,Me]),Te=c.useCallback(()=>{const q=o.current;if(!q)return{title:"",url:""};let ie="",Ee="";try{ie=q.getTitle()||""}catch{ie=""}try{Ee=er(q.getURL())}catch{Ee=""}return{title:ie,url:Ee}},[]);c.useEffect(()=>K1({tabId:s,describe:Te,run:Ie}),[Te,Ie,s]),c.useEffect(()=>{const q=fe;return()=>{yo(q)}},[fe]),c.useEffect(()=>{if(!l)return;const q=Ee=>{const Ae=Ee;if(typeof Ae.level!="number"||Ae.level<2)return;const $e=Ae.sourceId?`${Ae.sourceId}${Ae.line?`:${Ae.line}`:""}`:"";W.current.push({level:Ae.level>=3?"error":"warning",message:String(Ae.message??"").slice(0,400),source:$e}),W.current.length>Rc&&W.current.splice(0,W.current.length-Rc)},ie=()=>{W.current=[]};return l.addEventListener("console-message",q),l.addEventListener("did-start-loading",ie),()=>{l.removeEventListener("console-message",q),l.removeEventListener("did-start-loading",ie)}},[l]);const Le=c.useRef(new Set),_e=c.useCallback(q=>{Le.current.clear(),de(q)},[de]),P=c.useRef(re.status);P.current=re.status;const oe=c.useRef(!1);re.status.kind==="ready"&&re.status.url&&(oe.current=!0),c.useEffect(()=>mm(k,s,q=>{gm(P.current,oe.current)&&_e(q)}),[_e,k,s]),c.useEffect(()=>{if(!l)return;const q=Ee=>{const Ae=ir(Ee),$e=typeof Ae.url=="string"?Ae.url:"";!$e||!jl($e)||(Ee.preventDefault(),de($e))},ie=Ee=>{const Ae=ir(Ee);if(Ae.isMainFrame===!1||Ae.errorCode===-3)return;const $e=typeof Ae.validatedURL=="string"?Ae.validatedURL:"";!$e||!jl($e)||Le.current.has($e)||(Le.current.add($e),de($e))};return l.addEventListener("will-navigate",q),l.addEventListener("did-fail-load",ie),()=>{l.removeEventListener("will-navigate",q),l.removeEventListener("did-fail-load",ie)}},[de,l]),c.useEffect(()=>{if(!l)return;const q=ie=>{const Ee=ie.detail;ie.preventDefault(),Ee?.url&&de(Ee.url)};return l.addEventListener("new-window",q),()=>l.removeEventListener("new-window",q)},[de,l]);const V=c.useCallback(q=>{const ie=Math.min($S,Math.max(_S,q));N.current=ie,j(ie);try{o.current?.setZoomLevel(ie)}catch{}},[]);c.useEffect(()=>{const q=ie=>{if(!(ie instanceof CustomEvent))return;const Ee=ie.detail,Ae=o.current;!Ae||document.activeElement!==Ae||(Ee==="zoom-in"?V(N.current+to):Ee==="zoom-out"?V(N.current-to):Ee==="zoom-reset"&&V(0))};return window.addEventListener("openchamber:zoom",q),()=>window.removeEventListener("openchamber:zoom",q)},[V]);const Q=c.useCallback(q=>{go("desktop_browser_clear_data",{partition:WS,cookies:q==="cookies",cache:q==="cache"}).then(()=>{We.success(r(q==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>We.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const q=E.current;if(!q||typeof ResizeObserver>"u")return;const ie=new ResizeObserver(Ee=>{const Ae=Ee[0]?.contentRect;Ae&&D({width:Ae.width,height:Ae.height})});return ie.observe(q),()=>ie.disconnect()},[]);const ue=c.useCallback(q=>{K(q);const ie=o.current;if(!ie)return;let Ee=-1;try{Ee=ie.getWebContentsId()}catch{return}go("desktop_browser_set_color_scheme",{webContentsId:Ee,scheme:q}).catch(Ae=>{K("system"),We.error(Ae instanceof Error?Ae.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),Z=c.useCallback(()=>{try{le?o.current?.stop():o.current?.reload()}catch{}},[le]),ee=re.status;c.useEffect(()=>{const q=()=>{w(!0);const $e=setTimeout(()=>{try{o.current?.reload()}catch{}},KS);return()=>clearTimeout($e)};if(ee.kind==="loading")return;const ie=I.current;if((ee.kind==="failed"||ee.kind==="ready"&&ee.url)&&(I.current=!1),ee.kind==="failed"){const $e=hm(ee,{run:M.current,restored:ie,now:Date.now()});if(M.current=$e.run,!$e.retry){w(!1);return}return q()}if(M.current=null,ee.kind!=="ready"||!ee.url||!Kd(ee.url)){U.current=!0,w(!1);return}if(ie||U.current||Date.now()-z.current>zS){U.current=!0,w(!1);return}let Ee=!1,Ae=null;return g1(er(ee.url)).then($e=>{if(!Ee){if($e===null||$e<500){U.current=!0,w(!1);return}Ae=q()}}),()=>{Ee=!0,Ae?.()}},[ee]);const ke=re.status.kind==="failed"&&!h?re.status:null,ne=pS(T,A);return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[n.jsx($f,{address:x,onAddressChange:v,onSubmit:_e,suggestions:X,onForgetSuggestion:q=>he(e,q),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:Z,onOpenExternal:()=>{Mn(re.url||x)},canGoBack:re.canGoBack,canGoForward:re.canGoForward,isLoading:le,onAnnotate:H,isAnnotating:y,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>V(S+to),onZoomOut:()=>V(S-to),onZoomReset:()=>V(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>Q("cookies"),onClearCache:()=>Q("cache"),onToggleDeviceBar:()=>R(q=>!q),isDeviceBarOpen:C}),C?n.jsx(gS,{viewport:T,onViewportChange:O,colorScheme:L,onColorSchemeChange:ue,scale:ne?.scale??1}):null,n.jsxs("div",{ref:E,className:De("relative min-h-0 flex-1 bg-background",ne&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[m!==null?n.jsx("webview",{ref:d,src:m,partition:"persist:openchamber-browser",allowpopups:!0,style:ne?{width:`${ne.width}px`,height:`${ne.height}px`,transform:`scale(${ne.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,m!==null&&!p&&!re.url&&!le?n.jsx(zf,{onOpen:_e,directory:e}):null,h?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,Y?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:Y})})]}):null,ke&&!Y?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:ke.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:ke.crashed?r("contextPanel.browser.crashedHint"):ke.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,le?n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:n.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},GS=t=>{const e=Ye.c(53),{initialUrl:s,directory:r,tabID:i}=t,{t:o}=jt(),l=ve(YS);let a;e[0]!==s?(a=lr(s),e[0]=s,e[1]=a):a=e[1];const d=a,u=d!==Pn?d:"",[f,p]=c.useState(u),[m,b]=c.useState(u);let x;e[2]!==u?(x=u?[u]:[],e[2]=u,e[3]=x):x=e[3];const[v,y]=c.useState(x),[g,h]=c.useState(u?0:-1),[w,S]=c.useReducer(QS,0);let j,N;e[4]!==r||e[5]!==i?(j=()=>{zd(In(r),i)},N=[r,i],e[4]=r,e[5]=i,e[6]=j,e[7]=N):(j=e[6],N=e[7]),c.useEffect(j,N);let C;e[8]!==r||e[9]!==l||e[10]!==i?(C=Pe=>{!Pe||Pe===Pn||!r||!i||l(r,i,Pe)},e[8]=r,e[9]=l,e[10]=i,e[11]=C):C=e[11];const R=C;let T;e[12]!==r?(T=_f(r),e[12]=r,e[13]=T):T=e[13];const O=dr(T),_=dr(XS),W=dr(JS);let L;e[14]!==f||e[15]!==O?(L=Lf(O,f),e[14]=f,e[15]=O,e[16]=L):L=e[16];const K=L;let A;e[17]!==r||e[18]!==g||e[19]!==R||e[20]!==_?(A=Pe=>{const le=lr(Pe);le!==Pn&&(p(le),b(le),R(le),_(r,{url:le}),y(pe=>{const je=g>=0?pe.slice(0,g+1):[];return je[je.length-1]===le?(h(je.length-1),je):(h(je.length),[...je,le])}))},e[17]=r,e[18]=g,e[19]=R,e[20]=_,e[21]=A):A=e[21];const D=A;let E;e[22]!==v||e[23]!==R?(E=Pe=>{const le=v[Pe];le&&(h(Pe),p(le),b(le),R(le))},e[22]=v,e[23]=R,e[24]=E):E=e[24];const M=E;let k;e[25]!==r||e[26]!==W?(k=Pe=>W(r,Pe),e[25]=r,e[26]=W,e[27]=k):k=e[27];let I,U;e[28]!==M||e[29]!==g?(I=()=>M(g-1),U=()=>M(g+1),e[28]=M,e[29]=g,e[30]=I,e[31]=U):(I=e[30],U=e[31]);let z;e[32]!==f||e[33]!==m?(z=()=>{Mn(m||f)},e[32]=f,e[33]=m,e[34]=z):z=e[34];const ce=g>0,re=g>=0&&g<v.length-1;let Y;e[35]!==f||e[36]!==D||e[37]!==K||e[38]!==k||e[39]!==I||e[40]!==U||e[41]!==z||e[42]!==ce||e[43]!==re?(Y=n.jsx($f,{address:f,onAddressChange:p,onSubmit:D,suggestions:K,onForgetSuggestion:k,onBack:I,onForward:U,onReload:S,onOpenExternal:z,canGoBack:ce,canGoForward:re,isLoading:!1}),e[35]=f,e[36]=D,e[37]=K,e[38]=k,e[39]=I,e[40]=U,e[41]=z,e[42]=ce,e[43]=re,e[44]=Y):Y=e[44];let me;e[45]!==m||e[46]!==D||e[47]!==w||e[48]!==o?(me=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:m?n.jsx("iframe",{src:m,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${m}|${w}`):n.jsx(zf,{onOpen:D})}),e[45]=m,e[46]=D,e[47]=w,e[48]=o,e[49]=me):me=e[49];let be;return e[50]!==Y||e[51]!==me?(be=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Y,me]}),e[50]=Y,e[51]=me,e[52]=be):be=e[52],be},qS=t=>{const e=Ye.c(3),[s]=c.useState(LS);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(HS,{...t}):n.jsx(GS,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function YS(t){return t.setContextPanelTabTargetPath}function QS(t){return t+1}function XS(t){return t.recordVisit}function JS(t){return t.forget}const ZS=Xn(()=>sn(()=>import("./WalkthroughView-C1uB3Pl3.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,127,128,129])).then(t=>({default:t.WalkthroughView}))),ej=Xn(()=>sn(()=>import("./DiffView-BI_YgdKl.js"),__vite__mapDeps([130,1,2,4,5,6,7,8,9,83,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,131,119,120,121,122,123,124,125,132,126,127,128,129])).then(t=>({default:t.DiffView}))),tj=Xn(()=>sn(()=>import("./FilesView-B_NJFLBH.js"),__vite__mapDeps([133,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,134,135,136,137,129,138,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,139,140,124,125,122,141,123,142])).then(t=>({default:t.FilesView}))),sj=Xn(()=>sn(()=>import("./GitView-BWKg6TNS.js"),__vite__mapDeps([143,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,144,132,119,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,120,121,122,123,124,125,126,127,128,129])).then(t=>({default:t.GitView}))),nj=Xn(()=>sn(()=>import("./LinearIssuesView-C4gGBhU8.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,82])).then(t=>({default:t.LinearIssuesView}))),rj=Xn(()=>sn(()=>import("./PlanView-DP9DOnI-.js"),__vite__mapDeps([146,1,2,4,5,6,7,8,9,134,57,58,59,60,61,62,79,55,56,63,135,136,137,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,123,84,85,86,87,88,89,90,142,124,125,109,110,94,95,96,97,98,99,100,101,102,103,104,105,106,107])).then(t=>({default:t.PlanView}))),Vf=c.lazy(()=>sn(()=>import("./PluginPane-rZvoMQSi.js").then(t=>t.q),__vite__mapDeps([88,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.PluginPane}))),Uf={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}},oj=t=>{const e=Ye.c(12),{mode:s,docking:r}=t,[i,o]=c.useState(null),l=Uf[r.dock],a=Math.max(Yg,i??r.size),d=l.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==l.page||e[1]!==d?(u=De("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,l.page),e[0]=l.page,e[1]=d,e[2]=u):u=e[2];let f;e[3]!==l.vertical||e[4]!==a?(f=l.vertical?{height:a}:{width:a},e[3]=l.vertical,e[4]=a,e[5]=f):f=e[5];let p;e[6]!==s?(p=n.jsx(Vf,{mode:s,onResize:o}),e[6]=s,e[7]=p):p=e[7];let m;return e[8]!==u||e[9]!==f||e[10]!==p?(m=n.jsx("div",{className:u,style:f,children:p}),e[8]=u,e[9]=f,e[10]=p,e[11]=m):m=e[11],m},Mc=c.lazy(()=>sn(()=>import("./GuestSurfacePane-4PY11vEP.js"),__vite__mapDeps([147,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,88])).then(t=>({default:t.GuestSurfacePane}))),Hf=320,qa=600,ij=400,aj=100,lj=24,Ro=new Map,cj=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Tc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Hf,Math.round(t))):qa,Oc=t=>{const e=t??(typeof window<"u"?window.innerWidth:qa*2);return Math.max(Hf,e-ij)},dj=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},uj=(t,e)=>{if(!t)return"";const s=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&s.startsWith(r+"/")?s.slice(r.length+1):s},Gf=(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"):Kn(t)?ka.getState().guests.find(r=>r.id===ko(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),fj=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const s=e.split("/").filter(Boolean);return s.length===0?e:s[s.length-1]||null},pj=(t,e,s)=>{if(t.mode==="chat"){const r=la(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||s("contextPanel.mode.chat")}return t.mode==="browser"?wa(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?fj(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):Gf(t.mode,s)},mj=t=>{const e=Ye.c(8),{mode:s}=t,r=Ia();let i;if(e[0]!==s||e[1]!==r){let u;e[3]!==s?(u=f=>f.mode===s,e[3]=s,e[4]=u):u=e[4],i=r.find(u),e[0]=s,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??Qg,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=n.jsx(Br,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Bc=(t,e={})=>{if(t.mode==="file")return t.targetPath?n.jsx(Pa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(wf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx(F,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx(F,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx(F,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return n.jsx(F,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return n.jsx(F,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx(F,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return n.jsx(F,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx(F,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return n.jsx(F,{name:"chat-4",className:"h-3.5 w-3.5"});if(Kn(t.mode))return n.jsx(mj,{mode:t.mode});if(t.mode==="browser"){const s=hj(t.targetPath??"",e);return s?n.jsx("img",{src:s,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):n.jsx(F,{name:"global",className:"h-3.5 w-3.5"})}},hj=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},gj=({visible:t,active:e,fill:s=!1})=>{const{t:r}=jt(),i=ve(h=>h.contextEditorTreeWidth),o=ve(h=>h.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),f=c.useRef(null),p=c.useRef(null),m=c.useRef(null),b=c.useCallback(h=>{const w=m.current;w&&(w.style.width=`${h}px`,w.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),d.current=h.clientX,u.current=i,f.current=i,h.preventDefault()}},v=h=>{if(!l||p.current!==h.pointerId)return;const w=d.current-h.clientX,S=Ei(u.current+w);f.current!==S&&(f.current=S,b(S))},y=h=>{if(p.current!==h.pointerId)return;try{h.currentTarget.releasePointerCapture(h.pointerId)}catch{}const w=Ei(f.current??i);p.current=null,f.current=null,a(!1),o(w)},g=t?i:0;return n.jsxs("div",{ref:m,className:De("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",s&&"ml-auto"),style:{width:`${l?f.current??g:g}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${l?f.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!s&&n.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!s&&n.jsx("div",{className:De("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:x,onPointerMove:v,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:De("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:s?"100%":void 0},"aria-hidden":!t,children:n.jsx(Bv,{visible:t&&e})})]})},la=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,bj=(t,e)=>{if(t.size!==e.size)return!1;for(const[s,r]of t)if(e.get(s)!==r)return!1;return!0},xj=(t,e)=>{if(e.length===0)return Ro;const s=new Set(e),r=new Map;for(const i of t){if(!s.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Ro:r},yj=(t,e)=>{const s=qg(t),r=c.useRef(Ro),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(s.subscribe,c.useCallback(()=>{const o=xj(s.getState().session,i.current);return bj(r.current,o)?r.current:(r.current=o,o)},[s]),()=>Ro)},wj=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,vj=()=>{const{t}=jt(),e=Gn()??"",s=c.useMemo(()=>cj(e),[e]),r=ve(G=>s?G.contextPanelByDirectory[s]:void 0),i=ve(G=>G.closeContextPanel),o=ve(G=>G.closeContextPanelTab),l=ve(G=>G.pinContextPanelTab),a=ve(G=>G.openContextPanelTab),d=ve(G=>G.toggleContextPanelExpanded),u=ve(G=>G.setContextPanelWidth),f=ve(G=>G.setActiveContextPanelTab),p=ve(G=>G.openAgentBrowserTab),[m,b]=c.useState(()=>new Set),x=c.useCallback(G=>{b(Ce=>Ce.has(G)?Ce:new Set(Ce).add(G))},[]);c.useEffect(()=>{if(e)return U1(G=>{const Ce=p(e,G);return Ce&&x(Ce),Ce})},[e,p,x]);const v=ve(G=>G.openContextFile);c.useEffect(()=>Qn(G=>{if(G.type!=="file-open-request")return;const Ce=G.directory??e;Ce&&v(Ce,G.path)}),[e,v]);const y=ve(G=>G.reorderContextPanelTabs),g=ln(G=>G.setSelectedPath),h=ve(G=>G.contextEditorTreeVisible),w=ve(G=>G.contextEditorTreeWidth),S=ve(G=>G.setContextEditorTreeWidth),j=ve(G=>G.toggleContextEditorTree),N=ve(G=>G.contextEditorVisible),C=ve(G=>G.toggleContextEditor),R=ve(G=>G.openNewContextBrowserTab),T=Df(G=>G.byOrigin),O=ve(G=>G.allowPromptingSubagentSessions),{themeMode:_,setThemeMode:W,lightThemeId:L,darkThemeId:K,currentTheme:A}=mr(),D=c.useMemo(()=>r?.tabs??[],[r?.tabs]),E=D.find(G=>G.id===r?.activeTabId)??D[D.length-1]??null,M=E?.mode==="browser"?E.id:null;c.useEffect(()=>{M&&V1(M)},[M]);const k=!!(r?.isOpen&&E),[I,U]=c.useState(null),z=c.useMemo(()=>D.some(G=>G.mode==="file"&&G.targetPath),[D]),ce=z&&(N||!h),re=E?.mode??null,Y=re==="file"&&!ce,me=!!(k&&r?.expanded&&!Y),be=re?r?.widthByMode?.[re]:void 0,Pe=re?r?.widthFractionByMode?.[re]:void 0,le=re?zg(re):.5,pe=I??(typeof window<"u"?window.innerWidth:qa*2),je=Pe!=null&&I!=null?Math.round(Pe*I):be,he=Y?w:Tc(je??Math.round(le*pe),Oc(I??pe));c.useEffect(()=>{!s||!re||Y||Pe!=null||be==null||I==null||u(s,re,be,I)},[re,I,s,Y,be,Pe,u]);const X=c.useMemo(()=>{const G=[];for(const Ce of D){if(Ce.mode!=="chat")continue;const bt=la(Ce.dedupeKey);bt&&!G.includes(bt)&&G.push(bt)}return G},[D]),de=yj(s||void 0,X),[fe,H]=c.useState(!1),ge=c.useRef(0),Me=c.useRef(he),Ne=c.useRef(null),Ie=c.useRef(null),Te=c.useRef(null),Le=c.useRef(new Map),_e=c.useRef(new Map),P=c.useRef(!1);c.useLayoutEffect(()=>{const G=Te.current?.parentElement;if(!G||typeof ResizeObserver>"u")return;const Ce=new ResizeObserver(()=>{U(G.clientWidth||null)});return Ce.observe(G),U(G.clientWidth||null),()=>Ce.disconnect()},[]),c.useEffect(()=>{if(!k||P.current){P.current=k;return}const G=window.requestAnimationFrame(()=>{Te.current?.focus({preventScroll:!0})});return P.current=!0,()=>window.cancelAnimationFrame(G)},[k]);const oe=c.useRef(null),V=c.useRef(null),Q=c.useCallback(()=>{V.current=null;const G=Te.current,Ce=Ne.current;!G||Ce===null||G.style.setProperty("--oc-context-panel-width",`${Ce}px`)},[]);c.useEffect(()=>()=>{V.current!==null&&clearTimeout(V.current)},[]);const ue=c.useCallback(G=>{const Ce=oe.current,bt=Y?Ei(G):Tc(G,Oc(Ce));return Ce===null?bt:Math.min(bt,Math.max(1,Ce))},[Y]),Z=c.useCallback(G=>{!k||me||!s||(Ie.current=G.pointerId,H(!0),ge.current=G.clientX,Me.current=he,Ne.current=he,oe.current=dj(Te.current),document.documentElement.style.cursor="col-resize",G.preventDefault())},[s,me,k,he]),ee=c.useCallback(()=>{const G=ue(Ne.current??he),Ce=oe.current;Ne.current=null,oe.current=null,V.current!==null&&(clearTimeout(V.current),V.current=null),document.documentElement.style.cursor="",Y?S(G):s&&re&&u(s,re,G,Ce??void 0),H(!1),Ie.current=null},[re,ue,s,Y,S,u,he]);c.useEffect(()=>{if(!fe)return;const G=xe=>{if(Ie.current!==xe.pointerId)return;const xt=ge.current-xe.clientX,Mt=ue(Me.current+xt);Ne.current!==Mt&&(Ne.current=Mt,V.current===null&&(V.current=setTimeout(Q,aj)))},Ce=xe=>{Ie.current===xe.pointerId&&ee()},bt=()=>{ee()};return window.addEventListener("pointermove",G),window.addEventListener("pointerup",Ce),window.addEventListener("pointercancel",Ce),window.addEventListener("blur",bt),()=>{window.removeEventListener("pointermove",G),window.removeEventListener("pointerup",Ce),window.removeEventListener("pointercancel",Ce),window.removeEventListener("blur",bt)}},[Q,ue,ee,fe]),c.useEffect(()=>{fe||(Ne.current=null,document.documentElement.style.cursor="")},[fe]);const ke=c.useCallback(()=>{s&&i(s)},[i,s]),ne=c.useCallback(()=>{s&&d(s)},[s,d]),q=c.useCallback(G=>{G.key==="Escape"&&(G.target instanceof Node&&!G.currentTarget.contains(G.target)||Vg(G.target)||Ug(G.target)||G.defaultPrevented||(G.preventDefault(),G.stopPropagation(),ke()))},[ke]);c.useEffect(()=>{if(!(!s||!E)&&E.mode==="file"&&E.targetPath){g(s,E.targetPath,{allowOutsideRoot:!0});return}},[E,s,g]);const ie=c.useMemo(()=>D.filter(G=>G.mode==="chat"),[D]),Ee=k&&E?.mode==="chat"?E.id:null,Ae=k&&E?.mode==="chat"?la(E.dedupeKey):null,$e=ty(ie,Ee);c.useEffect(()=>{if(!k||!s||!Ae||typeof window>"u")return;const G=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ui(s,Ae,!1);return}Pu(Ae),ui(s,Ae,!0)};G();const Ce=window.setInterval(G,1e4);return window.addEventListener("focus",G),window.addEventListener("blur",G),document.addEventListener("visibilitychange",G),()=>{window.clearInterval(Ce),window.removeEventListener("focus",G),window.removeEventListener("blur",G),document.removeEventListener("visibilitychange",G),ui(s,Ae,!1)}},[Ae,s,k]);const Oe=c.useCallback((G,Ce,bt)=>sy(_e.current,G,Ce,s||null,bt,{mode:_,lightThemeId:L,darkThemeId:K,currentTheme:A},{allowPromptingSubagentSessions:O}),[O,A,K,s,L,_]),qe=$e&&Ae?Oe($e.id,Ae,$e.readOnly):null;c.useEffect(()=>{const G=new Set(D.map(Ce=>Ce.id));for(const Ce of _e.current.keys())G.has(Ce)||_e.current.delete(Ce)},[D]);const ct=c.useCallback(G=>{!s||E?.mode!=="diff"||a(s,{mode:"diff",targetPath:E.targetPath,stagedDiff:G==="staged",diffScope:G})},[E,s,a]),Ve=c.useCallback(()=>{if(typeof window>"u")return;const G={themeMode:_,lightThemeId:L,darkThemeId:K,currentTheme:A};for(const Ce of Le.current.values()){const bt=Ce.contentWindow;bt&&bt.postMessage({type:"openchamber:theme-sync",payload:G},window.location.origin)}},[A,K,L,_]),nt=c.useCallback(()=>{if(typeof window>"u")return;const G={allowPromptingSubagentSessions:O};for(const Ce of Le.current.values()){const bt=Ce.contentWindow;bt&&bt.postMessage({type:"openchamber:chat-settings-sync",payload:G},window.location.origin)}},[O]),kt=c.useCallback((G,Ce,bt)=>{const xe=Ce.contentWindow;xe&&xe.postMessage({type:df,payload:{visible:Ee===G}},bt)},[Ee]),dt=c.useCallback(()=>{if(!(typeof window>"u"))for(const[G,Ce]of Le.current.entries())kt(G,Ce,window.location.origin)},[kt]);c.useEffect(()=>{if(typeof window>"u")return;const G=Ce=>{if(Ce.origin!==window.location.origin)return;const bt=Array.from(Le.current.entries()).find(([,at])=>at.contentWindow===Ce.source);if(!bt)return;const xe=Ce.data;if(xe?.type===ny){const[at,Be]=bt;kt(at,Be,Ce.origin);return}if(xe?.type===ry){if(typeof xe.requestId!="string"||!xe.requestId)return;const at=Qt(),Be={apiBaseUrl:fr(),clientToken:jo(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:xm(),relayHostId:at.startsWith("host:")?at.slice(5):"",relay:bm()??void 0};Ce.source?.postMessage({type:oy,requestId:xe.requestId,payload:Be},Ce.origin);return}if(xe?.type==="openchamber:theme-sync-request"){Ve();return}if(xe?.type==="openchamber:chat-settings-request"){nt();return}if(xe?.type!=="openchamber:cycle-theme-request")return;const xt=["light","dark","system"],pt=(xt.indexOf(_)+1)%xt.length;W(xt[pt])};return window.addEventListener("message",G),()=>window.removeEventListener("message",G)},[nt,kt,Ve,W,_]),c.useLayoutEffect(()=>{D.some(Ce=>Ce.mode==="chat")&&(Ve(),nt(),dt())},[K,L,nt,dt,Ve,D,_]);const yt=E?.mode==="file"||E?.mode==="chat"||E?.mode==="browser",_t=c.useMemo(()=>E?D.filter(G=>G.mode===E.mode):[],[E,D]),Bt=c.useMemo(()=>_t.map(G=>{const Ce=pj(G,de,t),bt=wj(Ce,lj),xe=uj(G.targetPath,e);return{id:G.id,label:bt,icon:Bc(G,T),title:xe?`${Ce}: ${xe}`:Ce,closeLabel:t("contextPanel.tab.closeTabAria",{label:bt}),preview:G.preview}}),[_t,e,T,de,t]),Lt=E?.mode==="context"?n.jsx(t1,{}):E?.mode==="git"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(sj,{isActive:k})}):E?.mode==="pr"?n.jsx(cv,{}):E?.mode==="linear"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(nj,{})}):E?.mode==="notes"?n.jsx(sh,{}):E?.mode==="plan"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(rj,{targetPath:E.targetPath,savedProjectPlan:E.projectPlanId&&E.projectPlanRef?{projectRef:E.projectPlanRef,planId:E.projectPlanId}:null})}):null,Rt=c.useMemo(()=>D.filter(G=>G.mode==="browser"),[D]),Et=k&&E?.mode==="browser"?E.id:null;c.useEffect(()=>{Et&&x(Et)},[Et,x]);const Nt=c.useMemo(()=>Rt.filter(G=>G.id===Et||m.has(G.id)),[Rt,Et,m]);c.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const G=Rt.filter(Ce=>!Nt.includes(Ce)).map(Ce=>z1({tabId:Ce.id,describe:()=>({title:"",url:Ce.targetPath??""}),wake:()=>x(Ce.id)}));return()=>G.forEach(Ce=>Ce())},[Rt,Nt,x]);const ye=c.useMemo(()=>D.filter(G=>G.mode==="diff"),[D]),He=c.useMemo(()=>D.find(G=>G.mode==="terminal")??null,[D]),mt=c.useMemo(()=>D.some(G=>G.mode==="walkthrough"),[D]),Ke=c.useMemo(()=>D.filter(G=>Kn(G.mode)),[D]),B=ka(G=>G.guests),Se=c.useMemo(()=>new Set(B.filter(Hg).map(G=>G.id)),[B]),Fe=c.useMemo(()=>{const G=new Map;for(const Ce of B){const bt=Gg(Ce);bt&&G.set(Ce.id,bt)}return G},[B]),$=c.useMemo(()=>D.some(G=>G.mode==="file"),[D]),se=E?.mode==="file",we=ve(G=>G.closeContextPanelTabs),tt=c.useCallback(G=>{if(!s)return null;const{id:Ce,index:bt,allIds:xe,close:xt}=G,Mt=()=>we(s,xe.filter(ft=>ft!==Ce)),pt=()=>we(s,xe.slice(0,bt)),at=()=>we(s,xe.slice(bt+1)),Be=()=>we(s,xe),Ue=xe.length>1,lt=bt===0,et=bt===xe.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs(Wn,{onClick:xt,children:[n.jsx(F,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),n.jsx(Oi,{}),n.jsxs(Wn,{onClick:Mt,disabled:!Ue,children:[n.jsx(F,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),n.jsxs(Wn,{onClick:pt,disabled:lt,children:[n.jsx(F,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),n.jsxs(Wn,{onClick:at,disabled:et,children:[n.jsx(F,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),n.jsx(Oi,{}),n.jsxs(Wn,{onClick:Be,disabled:!Ue,children:[n.jsx(F,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[we,s,t]),rt=n.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[yt?n.jsx(Yd,{items:Bt,activeId:E?.id??null,onSelect:G=>{s&&f(s,G)},onClose:G=>{s&&o(s,G)},onReorder:(G,Ce)=>{s&&y(s,G,Ce)},onDoubleClickTab:G=>{s&&l(s,G)},layoutMode:"scrollable",variant:"default",tabContextMenu:tt}):n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[E?Bc(E,T):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:E?Gf(E.mode,t):null})]}),n.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[E?.mode==="browser"?n.jsx(ht,{type:"button",variant:"ghost",size:"sm",onClick:()=>{s&&R(s)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:n.jsx(F,{name:"add",className:"h-3.5 w-3.5"})}):null,se&&z?n.jsx(ht,{type:"button",variant:"ghost",size:"sm",onClick:C,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":ce,children:n.jsx(F,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,se?n.jsx(ht,{type:"button",variant:"ghost",size:"sm",onClick:j,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":h,children:n.jsx(F,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,Y?null:n.jsx(ht,{type:"button",variant:"ghost",size:"sm",onClick:ne,className:"h-7 w-7 p-0",title:t(me?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(me?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:me?n.jsx(F,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx(F,{name:"fullscreen",className:"h-3.5 w-3.5"})}),n.jsx(ht,{type:"button",variant:"ghost",size:"sm",onClick:ke,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:n.jsx(F,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Xe=k?me?{"--oc-context-panel-width":I!==null?`${I}px`:"100%",width:I!==null?`${I}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${he}px`}:{"--oc-context-panel-width":`${he}px`,width:0,maxWidth:"100%",overflowX:"clip"};return n.jsxs("aside",{ref:Te,"data-context-panel":"true",tabIndex:-1,inert:!k||void 0,className:De("flex min-h-0 flex-col overflow-hidden bg-background",me?"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:q,style:Xe,children:[k&&!me&&n.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),k&&n.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!me&&n.jsx("div",{className:De("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",fe&&"bg-[var(--interactive-border)]"),onPointerDown:Z,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),n.jsxs("div",{className:De("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:me?I!==null?`${I}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!k,children:[rt,n.jsxs("div",{className:De("relative min-h-0 flex-1 overflow-hidden",fe&&"pointer-events-none"),children:[$?n.jsxs("div",{className:De("absolute inset-0 flex",se?"flex":"hidden"),children:[z||!h?n.jsx("div",{className:De("h-full min-w-0 flex-1",z&&!ce&&"hidden"),children:z?n.jsx(c.Suspense,{fallback:null,children:n.jsx(tj,{mode:"editor-only",visible:k&&se&&ce})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx(F,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),n.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,n.jsx(gj,{visible:h,active:k&&se,fill:!ce})]}):null,$e&&Ae&&qe?n.jsx("iframe",{ref:G=>{if(!G){Le.current.delete($e.id);return}Le.current.set($e.id,G)},src:qe,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:Ae}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Ve(),nt(),dt()}},$e.id):null,Nt.map(G=>n.jsx("div",{className:De("absolute inset-0",E?.id!==G.id&&"invisible pointer-events-none"),"aria-hidden":E?.id!==G.id||void 0,children:n.jsx(qS,{initialUrl:G.targetPath??"",directory:s,tabID:G.id})},G.id)),ye.map(G=>n.jsx("div",{className:De("absolute inset-0",E?.id!==G.id&&"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(ej,{visible:k&&E?.id===G.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:G.diffScope??(G.stagedDiff?"staged":"working"),onDiffScopeChange:ct,targetFilePath:G.targetPath,flushContent:!0})})},G.id)),He?n.jsx("div",{className:De("absolute inset-0",E?.mode==="terminal"?"block":"hidden"),children:n.jsx(nh,{visible:k&&E?.mode==="terminal",directory:He.targetDirectory,onLastTabClosed:()=>{s&&o(s,He.id)}})}):null,mt?n.jsx("div",{className:De("absolute inset-0",E?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(ZS,{directory:e,visible:k&&E?.mode==="walkthrough"})})}):null,Ke.map(G=>{if(!Kn(G.mode))return null;const Ce=ko(G.mode),bt=Se.has(Ce),xe=Fe.get(Ce),xt=E?.id===G.id,Mt=xt&&k;return bt&&!xe&&!Mt?null:n.jsx("div",{className:De("absolute inset-0",xt?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:bt?xe?n.jsxs("div",{className:De("flex h-full",Uf[xe.dock].container),children:[n.jsx(oj,{mode:G.mode,docking:xe}),n.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Mt?n.jsx(Mc,{mode:G.mode}):null})]}):n.jsx(Mc,{mode:G.mode}):n.jsx(Vf,{mode:G.mode})})},G.id)}),E?.mode!=="chat"&&!se&&E?.mode!=="browser"&&E?.mode!=="diff"&&E?.mode!=="terminal"&&E?.mode!=="walkthrough"&&!(E&&Kn(E.mode))?Lt:null]})]})]})},Sj=t=>{const e=Ye.c(43),{open:s,onOpenChange:r}=t,{t:i}=jt(),o=ve(jj),l=ve(kj),a=ve(Cj),d=ve(Nj),u=Ia();let f;e[0]!==o||e[1]!==u?(f=Iu(o,u),e[0]=o,e[1]=u,e[2]=f):f=e[2];const p=f,m=l.length===0;let b;if(e[3]!==l||e[4]!==p){let T;e[6]!==l?(T=O=>l.includes(O.id),e[6]=l,e[7]=T):T=e[7],b=p.every(T),e[3]=l,e[4]=p,e[5]=b}else b=e[5];const x=b;let v;e[8]!==i?(v=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=v):v=e[9];let y;e[10]!==v?(y=n.jsx(qs,{children:v}),e[10]=v,e[11]=y):y=e[11];let g;e[12]!==i?(g=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=g):g=e[13];let h;e[14]!==g?(h=n.jsx(Ys,{children:g}),e[14]=g,e[15]=h):h=e[15];let w;e[16]!==y||e[17]!==h?(w=n.jsxs(Gs,{children:[y,h]}),e[16]=y,e[17]=h,e[18]=w):w=e[18];let S;if(e[19]!==l||e[20]!==a||e[21]!==p||e[22]!==i){let T;e[24]!==l||e[25]!==a||e[26]!==i?(T=O=>n.jsx(Xg,{settingsItem:`layout.context-rail.surface.${O.id}`,checked:!l.includes(O.id),onChange:_=>a(O.id,_),label:O.label??i(O.labelKey),ariaLabel:O.label??i(O.labelKey)},O.id),e[24]=l,e[25]=a,e[26]=i,e[27]=T):T=e[27],S=p.map(T),e[19]=l,e[20]=a,e[21]=p,e[22]=i,e[23]=S}else S=e[23];let j;e[28]!==S?(j=n.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]!==d||e[33]!==i?(N=m?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[x?n.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(ht,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=m,e[31]=x,e[32]=d,e[33]=i,e[34]=N):N=e[34];let C;e[35]!==N||e[36]!==w||e[37]!==j?(C=n.jsxs(Es,{className:"max-w-md",children:[w,j,N]}),e[35]=N,e[36]=w,e[37]=j,e[38]=C):C=e[38];let R;return e[39]!==r||e[40]!==s||e[41]!==C?(R=n.jsx(Ds,{open:s,onOpenChange:r,children:C}),e[39]=r,e[40]=s,e[41]=C,e[42]=R):R=e[42],R};function jj(t){return t.contextRailOrder}function kj(t){return t.contextRailHiddenSurfaces}function Cj(t){return t.setContextRailSurfaceVisible}function Nj(t){return t.setContextRailHiddenSurfaces}const qf=150,Aj=500,Pj=[],Ij=t=>t>99?"99+":String(t),Dj=t=>{const e=Ye.c(52),{surface:s,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:f,showOrderNumber:p,onSelect:m}=t;let b;e[0]!==s.id?(b={id:s.id},e[0]=s.id,e[1]=b):b=e[1];const{attributes:x,listeners:v,setNodeRef:y,transform:g,transition:h,isDragging:w}=Go(b);let S;e[2]!==a?(S=a!=null&&a>0?Ij(a):null,e[2]=a,e[3]=S):S=e[3];const j=S;let N;e[4]!==g?(N=qo.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 R=w&&"z-10 opacity-70";let T;e[9]!==R?(T=De("relative",R),e[9]=R,e[10]=T):T=e[10];let O;e[11]!==m||e[12]!==s?(O=()=>m(s),e[11]=m,e[12]=s,e[13]=O):O=e[13];const _=d??o,W=r?"text-primary":"text-muted-foreground hover:text-foreground";let L;e[14]!==W?(L=De("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",W),e[14]=W,e[15]=L):L=e[15];let K;e[16]!==s.icon||e[17]!==s.iconSrc||e[18]!==s.id?(K=s.id==="diff"?n.jsx(wf,{className:"h-[18px] w-[18px]"}):n.jsx(Br,{icon:s.icon,iconSrc:s.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=s.icon,e[17]=s.iconSrc,e[18]=s.id,e[19]=K):K=e[19];let A;e[20]!==j||e[21]!==f||e[22]!==i||e[23]!==p?(A=p&&f!=null?n.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?n.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}):i?n.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]=i,e[23]=p,e[24]=A):A=e[24];let D;e[25]!==x||e[26]!==r||e[27]!==v||e[28]!==L||e[29]!==K||e[30]!==A||e[31]!==O||e[32]!==_?(D=n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",...x,...v,onClick:O,"aria-label":_,"aria-pressed":r,className:L,children:[K,A]})}),e[25]=x,e[26]=r,e[27]=v,e[28]=L,e[29]=K,e[30]=A,e[31]=O,e[32]=_,e[33]=D):D=e[33];let E;e[34]!==o?(E=n.jsx("span",{children:o}),e[34]=o,e[35]=E):E=e[35];let M;e[36]!==l?(M=n.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=M):M=e[37];let k;e[38]!==u?(k=u?n.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=k):k=e[39];let I;e[40]!==E||e[41]!==M||e[42]!==k?(I=n.jsx(wt,{side:"left",sideOffset:8,children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[E,M,k]})}),e[40]=E,e[41]=M,e[42]=k,e[43]=I):I=e[43];let U;e[44]!==D||e[45]!==I?(U=n.jsxs(vt,{delayDuration:qf,children:[D,I]}),e[44]=D,e[45]=I,e[46]=U):U=e[46];let z;return e[47]!==y||e[48]!==U||e[49]!==C||e[50]!==T?(z=n.jsx("div",{ref:y,style:C,className:T,children:U}),e[47]=y,e[48]=U,e[49]=C,e[50]=T,e[51]=z):z=e[51],z},Ej=()=>{const t=Ye.c(92),{t:e}=jt(),s=Gn();let r;t[0]!==s?(r=s?In(s):"",t[0]=s,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=V=>i?V.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=ve(o),a=ve(Rj),d=ve(Mj),u=ve(Tj),f=ve(Oj),p=ve(Bj),m=ve(Fj),b=ve(Lj),x=Ca(_j),v=_i($j),y=_i(Wj),g=mn(Kj),h=mn(zj),{screenWidth:w}=Tn(),S=Na(i||null);let j;t[4]!==b?(j=$i("switch_context_surface",b),t[4]=b,t[5]=j):j=t[5];const N=j,[C,R]=c.useState(!1);let T,O;t[6]!==N?(T=()=>{const V=new Set;let Q=null,ue=!1;const Z=Vj,ee=()=>{Ol(N,V)?!ue&&Q===null&&(Q=setTimeout(()=>R(!0),Aj)):(ue=!1,Q!==null&&(clearTimeout(Q),Q=null),R(!1))},ke=ie=>{if(V.add(ie.key.toLowerCase()),Z(ie.key)&&Ol(N,V)){ue=!0,Q!==null&&(clearTimeout(Q),Q=null),R(!1);return}ee()},ne=ie=>{V.delete(ie.key.toLowerCase()),ee()},q=()=>{V.clear(),ue=!1,Q!==null&&(clearTimeout(Q),Q=null),R(!1)};return window.addEventListener("keydown",ke,!0),window.addEventListener("keyup",ne,!0),window.addEventListener("blur",q),()=>{window.removeEventListener("keydown",ke,!0),window.removeEventListener("keyup",ne,!0),window.removeEventListener("blur",q),Q!==null&&clearTimeout(Q)}},O=[N],t[6]=N,t[7]=T,t[8]=O):(T=t[7],O=t[8]),c.useEffect(T,O);let _;t[9]===Symbol.for("react.memo_cache_sentinel")?(_={activationConstraint:{distance:8}},t[9]=_):_=t[9];let W;t[10]===Symbol.for("react.memo_cache_sentinel")?(W={activationConstraint:{delay:200,tolerance:6}},t[10]=W):W=t[10];const L=Ko(un(Vo,_),un(zo,W)),K=Ia(),A=Tl(Uj),D=Tl(Hj),E=l?.tabs??Pj;let M;t[11]!==l?.activeTabId||t[12]!==E?(M=E.find(V=>V.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=E,t[13]=M):M=t[13];const k=M,I=l?.isOpen?k?.mode??null:null,U=S?.files.length??0;let z;t[14]!==u||t[15]!==d||t[16]!==h||t[17]!==K||t[18]!==y||t[19]!==x||t[20]!==w||t[21]!==E?(z=Jg({railOrder:d,hiddenSurfaces:u,planModeEnabled:x,isVSCode:_s(),screenWidth:w,tabs:E,linearConnected:y,githubConnected:h,extras:K}),t[14]=u,t[15]=d,t[16]=h,t[17]=K,t[18]=y,t[19]=x,t[20]=w,t[21]=E,t[22]=z):z=t[22];const ce=z;let re,Y;t[23]!==I||t[24]!==m||t[25]!==i||t[26]!==v||t[27]!==y?(Y=()=>{!i||!v||y||I!=="linear"||m(i)},re=[I,m,i,v,y],t[23]=I,t[24]=m,t[25]=i,t[26]=v,t[27]=y,t[28]=re,t[29]=Y):(re=t[28],Y=t[29]),c.useEffect(Y,re);let me,be;t[30]!==I||t[31]!==m||t[32]!==i||t[33]!==g||t[34]!==h?(me=()=>{!i||!g||h||I!=="pr"||m(i)},be=[I,m,i,g,h],t[30]=I,t[31]=m,t[32]=i,t[33]=g,t[34]=h,t[35]=me,t[36]=be):(me=t[35],be=t[36]),c.useEffect(me,be);const[Pe,le]=c.useState(!1);let pe;t[37]!==K||t[38]!==f?(pe=V=>{const{active:Q,over:ue}=V;if(!ue||Q.id===ue.id)return;const Z=Iu(ve.getState().contextRailOrder,K).map(Gj),ee=Z.indexOf(Q.id),ke=Z.indexOf(ue.id);ee===-1||ke===-1||f(nf(Z,ee,ke))},t[37]=K,t[38]=f,t[39]=pe):pe=t[39];const je=pe;if(!i)return null;let he;t[40]!==e?(he=e("contextRail.aria.rail"),t[40]=e,t[41]=he):he=t[41];let X;t[42]!==ce?(X=ce.map(qj),t[42]=ce,t[43]=X):X=t[43];let de;if(t[44]!==I||t[45]!==U||t[46]!==D||t[47]!==i||t[48]!==A||t[49]!==p||t[50]!==C||t[51]!==ce||t[52]!==e||t[53]!==a){let V;t[55]!==I||t[56]!==U||t[57]!==D||t[58]!==i||t[59]!==A||t[60]!==p||t[61]!==C||t[62]!==e||t[63]!==a?(V=(Q,ue)=>{const Z=Q.label??e(Q.labelKey),ee=Q.id==="git"&&!a?U:0,ke=Kn(Q.mode)&&I!==Q.mode?A[ko(Q.mode)]??0:0,ne=ee>0?ee:ke>0?ke:null,q=ne!==null&&ee===0;return n.jsx(Dj,{surface:Q,isActive:I===Q.mode,showActivityDot:!1,label:Z,description:e(Q.descriptionKey),badgeCount:ne,badgeAriaLabel:ne!==null?e(q?ne===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":ne===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:Z,count:ne}):null,badgeDescription:ne!==null?e(q?ne===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":ne===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:ne}):null,orderNumber:ue+1,showOrderNumber:C,onSelect:ie=>{Kn(ie.mode)&&D(ko(ie.mode)),p(i,ie.mode)}},Q.id)},t[55]=I,t[56]=U,t[57]=D,t[58]=i,t[59]=A,t[60]=p,t[61]=C,t[62]=e,t[63]=a,t[64]=V):V=t[64],de=ce.map(V),t[44]=I,t[45]=U,t[46]=D,t[47]=i,t[48]=A,t[49]=p,t[50]=C,t[51]=ce,t[52]=e,t[53]=a,t[54]=de}else de=t[54];let fe;t[65]!==X||t[66]!==de?(fe=n.jsx(La,{items:X,strategy:rf,children:de}),t[65]=X,t[66]=de,t[67]=fe):fe=t[67];let H;t[68]!==je||t[69]!==L||t[70]!==fe?(H=n.jsx(Uo,{sensors:L,collisionDetection:Ho,onDragEnd:je,children:fe}),t[68]=je,t[69]=L,t[70]=fe,t[71]=H):H=t[71];let ge;t[72]!==e?(ge=e("contextRail.configure.open"),t[72]=e,t[73]=ge):ge=t[73];let Me;t[74]===Symbol.for("react.memo_cache_sentinel")?(Me=()=>le(!0),t[74]=Me):Me=t[74];let Ne;t[75]===Symbol.for("react.memo_cache_sentinel")?(Ne=n.jsx(F,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=Ne):Ne=t[75];let Ie;t[76]!==ge?(Ie=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":ge,onClick:Me,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:Ne})}),t[76]=ge,t[77]=Ie):Ie=t[77];let Te;t[78]!==e?(Te=e("contextRail.configure.open"),t[78]=e,t[79]=Te):Te=t[79];let Le;t[80]!==Te?(Le=n.jsx(wt,{side:"left",sideOffset:8,children:Te}),t[80]=Te,t[81]=Le):Le=t[81];let _e;t[82]!==Ie||t[83]!==Le?(_e=n.jsxs(vt,{delayDuration:qf,children:[Ie,Le]}),t[82]=Ie,t[83]=Le,t[84]=_e):_e=t[84];let P;t[85]!==Pe?(P=n.jsx(Sj,{open:Pe,onOpenChange:le}),t[85]=Pe,t[86]=P):P=t[86];let oe;return t[87]!==he||t[88]!==H||t[89]!==_e||t[90]!==P?(oe=n.jsxs("nav",{"aria-label":he,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[H,_e,P]}),t[87]=he,t[88]=H,t[89]=_e,t[90]=P,t[91]=oe):oe=t[91],oe};function Rj(t){return t.workStatusPanelVisible}function Mj(t){return t.contextRailOrder}function Tj(t){return t.contextRailHiddenSurfaces}function Oj(t){return t.setContextRailOrder}function Bj(t){return t.openContextSurface}function Fj(t){return t.closeContextPanel}function Lj(t){return t.shortcutOverrides}function _j(t){return t.planModeEnabled}function $j(t){return t.hasChecked}function Wj(t){return t.status?.connected===!0}function Kj(t){return t.hasChecked}function zj(t){return t.status?.connected===!0}function Vj(t){return t.length===1&&t>="0"&&t<="9"}function Uj(t){return t.countByGuest}function Hj(t){return t.clearBadge}function Gj(t){return t.id}function qj(t){return t.id}const Yj=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),Qj=(t,e,s,r)=>!s||r!==s||t.length===0?[]:jr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),Fc={status:"idle"},Xj=({query:t,enabled:e,limit:s,sessionId:r=null,directories:i,role:o=null,includeReasoning:l=!0,order:a="desc"})=>{const[d,u]=c.useState(Fc),f=(i??[]).join(`
|
|
995
|
+
`),p=`${t}\0${r??""}\0${f}\0${o??""}\0${a}\0${s}\0${l}`,m=c.useRef(p);m.current=p;const b=c.useRef(i);b.current=i,c.useEffect(()=>{if(!e||!t.trim()){u(Fc);return}if(!Zg(t)){u({status:"too-short"});return}const y=new AbortController;return u(g=>({status:"loading",hits:"hits"in g?g.hits:[]})),Bl({query:t,sessionId:r,directories:b.current,role:o,includeReasoning:l,order:a,limit:s,signal:y.signal}).then(g=>{y.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(()=>{y.signal.aborted||u({status:"error",hits:[]})}),()=>y.abort()},[e,p]);const x=c.useRef(d);x.current=d;const v=c.useCallback(()=>{const y=x.current;if(y.status!=="ready"||!y.next||y.loadingMore)return;const g=m.current,h=y.next;u({...y,loadingMore:!0}),Bl({query:t,sessionId:r,directories:b.current,role:o,includeReasoning:l,order:a,limit:s,before:h}).then(w=>{m.current!==g||w.status!=="ok"||u(S=>S.status==="ready"?{...S,hits:[...S.hits,...w.hits],next:w.next,index:w.index,loadingMore:!1}:S)}).catch(()=>{m.current===g&&u(w=>w.status==="ready"?{...w,loadingMore:!1}:w)})},[t,r,o,l,a,s]);return{state:d,loadMore:v}},Jj={user:"user-3",assistant:"chat-ai-3",reasoning:"brain-ai-3"},Zj=t=>{const e=Ye.c(4),{snippet:s}=t;let r;e[0]!==s?(r=eb(s).map(s0),e[0]=s,e[1]=r):r=e[1];let i;return e[2]!==r?(i=n.jsx(n.Fragment,{children:r}),e[2]=r,e[3]=i):i=e[3],i},e0=t=>{const e=new Date(t);if(!Number.isFinite(e.getTime()))return"";const s=e.getFullYear()===new Date().getFullYear();return new Intl.DateTimeFormat(Aa(),s?{month:"short",day:"numeric"}:{year:"numeric",month:"short",day:"numeric"}).format(e)},Lc=t=>{const e=Ye.c(38),{hit:s,projectLabel:r,onSelect:i}=t,{t:o}=jt();let l;e[0]!==s.sessionTitle||e[1]!==o?(l=s.sessionTitle||o("commandPalette.session.untitled"),e[0]=s.sessionTitle,e[1]=o,e[2]=l):l=e[2];const a=l;let d;e[3]!==s.role||e[4]!==o?(d=s.role==="user"?o("commandPalette.messages.byYou"):s.role==="reasoning"?o("commandPalette.messages.inReasoning"):o("commandPalette.messages.byAgent"),e[3]=s.role,e[4]=o,e[5]=d):d=e[5];const u=d,f=`message:${s.role}:${s.id}`;let p;e[6]!==s||e[7]!==i?(p=()=>i(s),e[6]=s,e[7]=i,e[8]=p):p=e[8];const m=Jj[s.role];let b;e[9]!==u||e[10]!==m?(b=n.jsx(F,{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]=b):b=e[11];let x;e[12]!==s.snippet?(x=n.jsx("span",{className:"line-clamp-2 break-words text-foreground",children:n.jsx(Zj,{snippet:s.snippet})}),e[12]=s.snippet,e[13]=x):x=e[13];let v;e[14]!==s.role||e[15]!==o?(v=s.role==="reasoning"?n.jsxs("span",{className:"shrink-0",children:[o("commandPalette.messages.inReasoning")," ·"]}):null,e[14]=s.role,e[15]=o,e[16]=v):v=e[16];let y;e[17]!==a?(y=n.jsx("span",{className:"min-w-0 truncate",children:a}),e[17]=a,e[18]=y):y=e[18];let g;e[19]!==r?(g=r?n.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]!==s.createdAt?(h=e0(s.createdAt),e[21]=s.createdAt,e[22]=h):h=e[22];let w;e[23]!==h?(w=n.jsxs("span",{className:"shrink-0",children:["· ",h]}),e[23]=h,e[24]=w):w=e[24];let S;e[25]!==g||e[26]!==w||e[27]!==v||e[28]!==y?(S=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground typography-micro",children:[v,y,g,w]}),e[25]=g,e[26]=w,e[27]=v,e[28]=y,e[29]=S):S=e[29];let j;e[30]!==S||e[31]!==x?(j=n.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]!==b?(N=n.jsxs(Cn,{value:f,onSelect:p,className:"items-start",children:[b,j]}),e[33]=j,e[34]=f,e[35]=p,e[36]=b,e[37]=N):N=e[37],N},_c=t=>{const e=Ye.c(10),{options:s,value:r,onChange:i,label:o}=t;let l;if(e[0]!==i||e[1]!==s||e[2]!==r){let d;e[4]!==i||e[5]!==r?(d=u=>n.jsx(ht,{type:"button",variant:"chip",size:"xs","aria-pressed":r===u.value,onClick:()=>i(u.value),children:u.label},u.value),e[4]=i,e[5]=r,e[6]=d):d=e[6],l=s.map(d),e[0]=i,e[1]=s,e[2]=r,e[3]=l}else l=e[3];let a;return e[7]!==o||e[8]!==l?(a=n.jsx("div",{className:"flex items-center gap-1",role:"group","aria-label":o,children:l}),e[7]=o,e[8]=l,e[9]=a):a=e[9],a},t0=t=>{const e=Ye.c(42),{scope:s,onScopeChange:r,projectScopeAvailable:i,author:o,onAuthorChange:l,reasoningAvailable:a,onBack:d}=t,{t:u}=jt();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(F,{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]!==d||e[4]!==p?(m=n.jsxs(ht,{type:"button",variant:"ghost",size:"xs",onClick:d,children:[f,p]}),e[3]=d,e[4]=p,e[5]=m):m=e[5];let b;e[6]!==r||e[7]!==i||e[8]!==s||e[9]!==u?(b=i?n.jsx(_c,{label:u("commandPalette.messages.filter.scopeLabel"),value:s,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]=i,e[8]=s,e[9]=u,e[10]=b):b=e[10];let x;e[11]!==u?(x=u("commandPalette.messages.filter.authorLabel"),e[11]=u,e[12]=x):x=e[12];let v;e[13]!==u?(v=u("commandPalette.messages.filter.anyone"),e[13]=u,e[14]=v):v=e[14];let y;e[15]!==v?(y={value:"any",label:v},e[15]=v,e[16]=y):y=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 w;e[21]!==u?(w=u("commandPalette.messages.filter.agent"),e[21]=u,e[22]=w):w=e[22];let S;e[23]!==w?(S={value:"assistant",label:w},e[23]=w,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]!==y||e[31]!==h?(N=[y,h,S,...j],e[28]=S,e[29]=j,e[30]=y,e[31]=h,e[32]=N):N=e[32];let C;e[33]!==o||e[34]!==l||e[35]!==N||e[36]!==x?(C=n.jsx(_c,{label:x,value:o,onChange:l,options:N}),e[33]=o,e[34]=l,e[35]=N,e[36]=x,e[37]=C):C=e[37];let R;return e[38]!==C||e[39]!==m||e[40]!==b?(R=n.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,b,C]}),e[38]=C,e[39]=m,e[40]=b,e[41]=R):R=e[41],R};function s0(t,e){return t.match?n.jsx("mark",{className:"rounded-[2px] bg-primary/25 text-foreground",children:t.text},e):n.jsx(c.Fragment,{children:t.text},e)}const n0=new Set,r0=[],o0=3,i0=30,ji=(t,e)=>{const s=t.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return e.toLowerCase().split(/\s+/).filter(Boolean).every(r=>s.some(i=>i.startsWith(r)))},$c=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},Wc="",Kc=t=>{const e=Ye.c(7),{text:s,className:r}=t;let i;e[0]!==r?(i=De("min-w-0 truncate text-muted-foreground",r),e[0]=r,e[1]=i):i=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={direction:"rtl",textAlign:"left"},e[2]=o):o=e[2];const l=`${Wc}${s}${Wc}`;let a;return e[3]!==i||e[4]!==l||e[5]!==s?(a=n.jsx("span",{className:i,style:o,title:s,children:l}),e[3]=i,e[4]=l,e[5]=s,e[6]=a):a=e[6],a},on=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+/g,"/");s&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},a0=()=>{const{t}=jt(),e=ve($=>$.isCommandPaletteOpen),s=ve($=>$.setCommandPaletteOpen),r=ve($=>$.setSettingsDialogOpen),i=ve($=>$.setSettingsPage),o=ve($=>$.setSessionSwitcherOpen),l=ve($=>$.toggleSidebar),a=ve($=>$.openContextOverview),d=ve($=>$.openContextSurface),u=ve($=>$.openContextFile),f=ve($=>$.shortcutOverrides),p=ve($=>$.setArchivePageOpen),m=ve($=>$.setProjectContextTab),b=Je($=>$.openNewSessionDraft),x=Je($=>$.setCurrentSession),v=Je($=>$.currentSessionId),y=Er($=>$.toggle),g=gs(c.useCallback($=>e?$.activeSessions:r0,[e])),h=Er(c.useCallback($=>e?$.ids:n0,[e])),w=Da(c.useCallback($=>e?$.rankById:Ea,[e])),S=is($=>$.currentDirectory),j=Vt($=>$.getActiveProject()),N=Vt($=>$.projects),C=Gn(),R=Wd($=>$.searchFiles),{files:T,git:O}=hn(),_=Yn($=>$.ensureStatus),{isMobile:W}=Tn(),L=c.useMemo(()=>C?on(C):null,[C]),[K,A]=c.useState(""),E=Cu(K,200).trim(),M=K.trim(),[k,I]=c.useState(!1),[U,z]=c.useState("all"),[ce,re]=c.useState("any");c.useEffect(()=>{e&&(A(""),I(!1))},[e]),c.useEffect(()=>{if(!e||!O)return;const $=setTimeout(()=>{const se=new Set;for(const we of g){const tt=Is(we);!tt||se.has(tt)||(se.add(tt),_(tt,O))}},0);return()=>clearTimeout($)},[e,g,O,_]);const Y=c.useCallback(()=>s(!1),[s]),me=c.useCallback($=>()=>{Y(),$()},[Y]),be=c.useMemo(()=>{const $=[{id:"new-session",title:t("commandPalette.item.newSession"),icon:n.jsx(F,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:t("commandPalette.item.newSession"),onSelect:me(()=>{o(!1),b()})},{id:"new-worktree",title:t("commandPalette.item.newWorktreeDraft"),icon:n.jsx(F,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:t("commandPalette.item.newWorktreeDraft"),onSelect:me(()=>{Du()})},{id:"add-project",title:t("commandPalette.item.addProject"),icon:n.jsx(F,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.addProject"),onSelect:me(()=>{Hs.requestDirectoryDialog()})},{id:"toggle-sidebar",title:t(W?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:n.jsx(F,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:t(W?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:me(()=>{if(W){const{isSessionSwitcherOpen:se}=ve.getState();o(!se)}else l()})},{id:"toggle-terminal",title:t("commandPalette.item.toggleTerminal"),icon:n.jsx(F,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:t("commandPalette.item.toggleTerminal"),onSelect:me(()=>{S&&d(S,"terminal")})},{id:"context-usage",title:t("commandPalette.item.showContextUsage"),icon:n.jsx(F,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.showContextUsage"),onSelect:me(()=>{S&&a(S)})},{id:"cycle-theme",secondary:!0,title:t("commandPalette.item.cycleTheme"),icon:n.jsx(F,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:t("commandPalette.item.cycleTheme"),onSelect:me(()=>{tb.invoke("cycle_theme")})},{id:"open-status",secondary:!0,title:t("commandPalette.item.showOpenCodeStatus"),icon:n.jsx(F,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.showOpenCodeStatus"),onSelect:me(()=>{Eu()})},{id:"open-settings",title:t("commandPalette.item.openSettings"),icon:n.jsx(F,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:t("commandPalette.item.openSettings"),onSelect:me(()=>r(!0))}];return _s()||$.push({id:"reload-ui",secondary:!0,title:t("commandPalette.item.reloadUi"),icon:n.jsx(F,{name:"refresh",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.reloadUi"),onSelect:me(()=>window.location.reload())}),$.push({id:"pin-session",secondary:!0,title:t("commandPalette.item.pinSession"),icon:n.jsx(F,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.pinSession"),onSelect:me(()=>{v&&S&&y({directory:S,sessionId:v})})},{id:"copy-session-id",secondary:!0,title:t("commandPalette.item.copySessionId"),icon:n.jsx(F,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.copySessionId"),onSelect:me(()=>{v&&Hn(v).then(se=>{if(se.ok){We.success(t("sessions.sidebar.session.copyId.success"));return}We.error(t("sessions.sidebar.session.copyId.error"))}).catch(()=>We.error(t("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:t("commandPalette.item.openMultiRun"),icon:n.jsx(F,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openMultiRun"),onSelect:me(()=>{o(!1),sb()})},{id:"open-archive",secondary:!0,title:t("commandPalette.item.openArchive"),icon:n.jsx(F,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openArchive"),onSelect:me(()=>{o(!1),p(!0)})},{id:"open-notes",secondary:!0,title:t("commandPalette.item.openNotes"),icon:n.jsx(F,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openNotes"),onSelect:me(()=>{S&&(m("notes"),d(S,"notes"))})},{id:"open-todos",secondary:!0,title:t("commandPalette.item.openTodos"),icon:n.jsx(F,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openTodos"),onSelect:me(()=>{S&&(m("todos"),d(S,"notes"))})}),_s()||$.push({id:"restart-opencode",secondary:!0,title:t("commandPalette.item.restartOpenCode"),icon:n.jsx(F,{name:"restart",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.restartOpenCode"),onSelect:me(()=>{rh(t)})}),$.push({id:"toggle-memory-debug",secondary:!0,title:t("commandPalette.item.toggleMemoryDebug"),icon:n.jsx(F,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.toggleMemoryDebug"),onSelect:me(()=>{window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))})}),Dr()&&$.splice(1,0,{id:"new-mini-chat",title:t("commandPalette.item.newMiniChat"),icon:n.jsx(F,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:t("commandPalette.item.newMiniChat"),onSelect:me(()=>{Rn("desktop_open_draft_mini_chat_window",{directory:on(S||j?.path||""),projectId:j?.id??null}).catch(se=>{console.warn("[command-palette] failed to open draft mini chat window",se)})})}),$},[t,me,W,o,b,l,d,S,a,r,j?.id,j?.path,v,y,p,m]),Pe=ve($=>$.routingFeatureAvailable),le=oh(),pe=ih(),je=c.useMemo(()=>{const $=pn();return{isVSCode:_s(),isWeb:!$&&va(),isDesktop:$,isMobile:W,routingAvailable:Pe,enterpriseMode:le,jevBlockedByEnterprise:pe}},[W,Pe,le,pe]),he=c.useMemo(()=>ah.filter($=>$.slug!=="home").filter($=>$.isAvailable?$.isAvailable(je):!0).map($=>{const se=lh($.slug)??"settings-3",we=($.keywords??[]).join(" ");return{id:`settings:${$.slug}`,title:$.title,icon:$.slug==="mcp"?n.jsx(nb,{className:"mr-2 h-4 w-4"}):n.jsx(F,{name:se,className:"mr-2 h-4 w-4"}),searchText:`${$.title} ${$.group} ${we}`,onSelect:me(()=>{i($.slug),r(!0)})}}),[je,me,i,r]),X=c.useMemo(()=>{const $=g.filter(se=>!rb(se)&&!se.parentID);return ob($,h,w)},[g,h,w]),de=Ru(),fe=Je($=>$.worktreeMetadata),H=c.useCallback(($,se)=>{const we=fe.get($);return we?.branch?we.branch.trim()||null:se&&de.get(se)?.trim()||null},[fe,de]),[ge,Me]=c.useState([]),[Ne,Ie]=c.useState(""),Te=Yj(L,E),Le=Je($=>$.availableWorktrees),_e=c.useMemo(()=>L?Le.map($=>on($.path)).filter($=>$.startsWith(`${L}/`)).map($=>`${$}/`):[],[Le,L]),P=c.useRef(_e);P.current=_e;const V=ve($=>$.messageSearchEnabled)&&!_s(),Q=ve($=>$.messageSearchReasoningEnabled),ue=ve($=>$.showReasoningTraces),Z=Q&&ue,ee=ce==="reasoning"&&!Z?"any":ce,ke=c.useMemo(()=>j?.path?[...new Set([on(j.path),...Le.map($=>on($.path))])]:[],[j?.path,Le]),ne=k&&U==="project"&&ke.length>0,{state:q,loadMore:ie}=Xj({query:E,enabled:e&&V,limit:k?i0:o0,directories:ne?ke:void 0,role:k&&ee!=="any"?ee:null,includeReasoning:ue}),Ee="hits"in q?q.hits:[];c.useEffect(()=>{if(!e){Me([]),Ie("");return}if(!Te){Me([]),Ie("");return}if(!L){Me([]),Ie("");return}let $=!1;const se=P.current,we=se.length>0?100:40;return R(L,E,we,{type:"file"}).then(tt=>{$||(Me(tt.map(rt=>({path:on(rt.path),name:rt.name,relativePath:rt.relativePath})).filter(rt=>!se.some(Xe=>rt.path.startsWith(Xe)))),Ie(Te))}).catch(()=>{$||(Me([]),Ie(Te))}),()=>{$=!0}},[e,L,E,Te,R]);const Ae=M.length>0,$e=c.useMemo(()=>{if(!Ae)return be.filter(se=>!se.secondary).map(se=>({item:se,score:0}));const $=be.filter(se=>ji(se.searchText,M));return jr($,M,se=>se.searchText,{limit:7,noFuzzy:!0})},[be,M,Ae]),Oe=c.useMemo(()=>{if(!Ae)return[];const $=he.filter(se=>ji(se.searchText,M));return jr($,M,se=>se.searchText,{limit:7,noFuzzy:!0})},[he,M,Ae]),qe=c.useMemo(()=>Ae?jr(X,M,$=>$.title||"",{limit:7,threshold:.2}):X.slice(0,5).map($=>({item:$,score:0})),[X,M,Ae]),ct=c.useMemo(()=>e?Qj(ge,E,Te,Ne):[],[e,ge,Ne,Te,E]),Ve=e&&Te.length>0&&Ne!==Te,nt=c.useMemo(()=>{if(!Ae)return[];const se=N.map(we=>({...we,displayName:we.label||we.path.split("/").pop()||we.path,searchText:`${we.label||""} ${we.path}`})).filter(we=>ji(we.searchText,M));return jr(se,M,we=>we.searchText,{limit:7,threshold:.4})},[N,M,Ae]),kt=ve($=>e&&L?$.contextPanelByDirectory[L]?.tabs:void 0),dt=c.useMemo(()=>!L||!kt?[]:kt.filter($=>$.mode==="file"&&$.targetPath).sort(($,se)=>se.touchedAt-$.touchedAt).slice(0,5).flatMap($=>{const se=on($.targetPath??"");if(!se)return[];const we=se.startsWith(`${L}/`)?se.slice(L.length+1):se;return[{path:se,name:$c(we).name,relativePath:we}]}),[kt,L]),yt=c.useCallback($=>{if(!$)return null;const se=on($);let we=null;for(const tt of N){const rt=on(tt.path);se!==rt&&!se.startsWith(`${rt}/`)||we&&we.length>=rt.length||(we={label:tt.label||rt.split("/").pop()||rt,length:rt.length})}return we?.label??null},[N]),_t=$e.map($=>$.item),Bt=Oe.map($=>$.item),Lt=qe.map($=>$.item),Rt=Ae?ct.map($=>$.item):[],Et=Ae?nt.map($=>$.item):[],Nt=Ae?[]:dt,ye=c.useMemo(()=>{if(!Ae)return["openFiles","sessions","commands"];const $=we=>we.length?we[0].score:1/0,se=[{key:"commands",score:$($e)},{key:"settings",score:$(Oe)},{key:"sessions",score:$(qe)},{key:"files",score:$(ct)},{key:"projects",score:$(nt)}];return se.sort((we,tt)=>we.score-tt.score),[...se.map(we=>we.key),"messages"]},[Ae,$e,Oe,qe,ct,nt]),He=c.useCallback($=>{Y(),ib($.role==="reasoning"?$.id:null),Yi($.sessionId,$.id)},[Y]),mt=c.useCallback($=>{Y(),x($.id,Is($))},[Y,x]),Ke=c.useCallback(async $=>{if(!L)return;const se=await Cf(T,$,{directory:L});if(!se.ok){We.error(Nf(se.reason));return}u(L,$),Y()},[L,T,u,Y]),B=c.useCallback(($,se)=>{Y(),b({selectedProjectId:$,directoryOverride:se})},[Y,b]),Se=c.useCallback($=>zn(Fr($,f)),[f]),Fe=($,se)=>{const{name:we,directory:tt}=$c($.relativePath||$.name);return n.jsxs(Cn,{value:`${se}:${$.path}`,onSelect:()=>{Ke($.path)},children:[n.jsx(Pa,{filePath:$.path,className:"mr-2 size-4 shrink-0"}),n.jsx("span",{className:"shrink-0 truncate","aria-label":$.relativePath,children:we}),tt?n.jsx(Kc,{text:tt,className:"flex-1"}):null]},`${se}:${$.path}`)};return n.jsxs(Ds,{open:e,onOpenChange:($,se)=>{if(!$&&k&&se.reason==="escape-key"){se.cancel(),I(!1);return}s($)},children:[n.jsxs(Gs,{className:"sr-only",children:[n.jsx(qs,{children:t("commandPalette.title")}),n.jsx(Ys,{children:t("commandPalette.description")})]}),n.jsx(Es,{className:"gap-0 overflow-hidden p-0 max-w-[min(720px,calc(100vw-2rem))]",layerClassName:"items-start pt-[12vh]",showCloseButton:!1,children:n.jsxs(ab,{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:[n.jsx(lb,{value:K,onValueChange:A,placeholder:t(k?"commandPalette.messages.placeholder":"commandPalette.input.placeholder"),onKeyDown:$=>{k&&$.key==="Backspace"&&K.length===0&&($.preventDefault(),I(!1))}}),k?n.jsx(t0,{scope:U,onScopeChange:z,projectScopeAvailable:ke.length>0,author:ee,onAuthorChange:re,reasoningAvailable:Z,onBack:()=>I(!1)}):null,n.jsx("div",{className:De("min-h-0",k?"h-[min(403px,calc(60vh-37px))]":"h-[min(440px,60vh)]"),children:n.jsx(cb,{children:k?n.jsxs(n.Fragment,{children:[Ee.map($=>n.jsx(Lc,{hit:$,projectLabel:yt($.directory),onSelect:He},`${$.role}:${$.id}`)),q.status==="ready"&&q.next?n.jsxs(Cn,{value:"message:load-more",onSelect:ie,disabled:q.loadingMore,children:[n.jsx(F,{name:"more",className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"truncate text-muted-foreground",children:t("commandPalette.messages.loadMore")})]}):null,n.jsxs("div",{className:"px-4 py-2 typography-meta text-muted-foreground",role:"status",children:[q.status==="idle"||q.status==="too-short"?t("commandPalette.messages.tooShort"):q.status==="loading"&&Ee.length===0?t("commandPalette.messages.searching"):q.status==="error"?t("commandPalette.messages.error"):q.status==="unavailable"?t("commandPalette.messages.unavailable"):q.status==="ready"&&Ee.length===0?t("commandPalette.messages.empty"):null,q.status==="ready"&&q.index?.backfill.state==="running"?` ${t("commandPalette.messages.indexing",{done:q.index.backfill.done,total:q.index.backfill.total})}`:null]})]}):n.jsxs(n.Fragment,{children:[n.jsx(db,{children:t("commandPalette.empty.noResults")}),ye.map($=>$==="messages"?!Ae||Ee.length===0?null:n.jsxs(Bn,{heading:t("commandPalette.group.messages"),children:[Ee.map(se=>n.jsx(Lc,{hit:se,projectLabel:yt(se.directory),onSelect:He},`${se.role}:${se.id}`)),n.jsxs(Cn,{value:"message:show-all",onSelect:()=>I(!0),children:[n.jsx(F,{name:"search",className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"truncate text-muted-foreground",children:t("commandPalette.messages.showAll")})]})]},"messages"):$==="openFiles"&&Nt.length>0?n.jsx(Bn,{heading:t("commandPalette.group.openFiles"),children:Nt.map(se=>Fe(se,"open-file"))},"openFiles"):$==="commands"&&_t.length>0?n.jsx(Bn,{heading:t("commandPalette.group.commands"),children:_t.map(se=>n.jsxs(Cn,{value:se.id,onSelect:se.onSelect,children:[se.icon,n.jsx("span",{className:"truncate",children:se.title}),se.shortcutId?n.jsx(ub,{children:Se(se.shortcutId)}):null]},se.id))},"commands"):$==="settings"&&Bt.length>0?n.jsx(Bn,{heading:t("commandPalette.group.settings"),children:Bt.map(se=>n.jsxs(Cn,{value:se.id,onSelect:se.onSelect,children:[se.icon,n.jsx("span",{className:"truncate",children:se.title})]},se.id))},"settings"):$==="sessions"&&Lt.length>0?n.jsx(Bn,{heading:t("commandPalette.group.sessions"),children:Lt.map(se=>{const we=se.title||t("commandPalette.session.untitled"),tt=Is(se),rt=H(se.id,tt),Xe=yt(tt);return n.jsxs(Cn,{value:`session:${se.id}`,onSelect:()=>mt(se),children:[n.jsx(F,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:we}),Xe?n.jsx("span",{className:"max-w-[180px] shrink-0 truncate text-muted-foreground typography-meta",children:Xe}):null,rt?n.jsxs("span",{className:"inline-flex max-w-[160px] shrink-0 items-center gap-1 text-muted-foreground typography-meta",children:[n.jsx(F,{name:"git-branch",className:"h-3 w-3"}),n.jsx("span",{className:"truncate",children:rt})]}):null]},se.id)})},"sessions"):$==="files"&&Rt.length>0?n.jsx(Bn,{heading:t("commandPalette.group.files"),children:Rt.map(se=>Fe(se,"file"))},"files"):$==="projects"&&Et.length>0?n.jsx(Bn,{heading:t("commandPalette.group.projects"),children:Et.map(se=>n.jsxs(Cn,{value:`project:${se.id}`,onSelect:()=>B(se.id,se.path),children:[n.jsx(F,{name:"folder",className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"shrink-0 truncate",children:se.displayName}),n.jsx(Kc,{text:se.path,className:"flex-1"})]},`project:${se.id}`))},"projects"):null),Ve?n.jsx("div",{className:"px-4 py-2 typography-meta text-muted-foreground",children:t("commandPalette.empty.searchingFiles")}):null]})})}),W?null:n.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:[n.jsxs("span",{children:[n.jsx("kbd",{className:"font-sans",children:"↑↓"})," ",t("commandPalette.footer.navigate")]}),n.jsxs("span",{children:[n.jsx("kbd",{className:"font-sans",children:"↵"})," ",t("commandPalette.footer.open")]}),n.jsxs("span",{children:[n.jsx("kbd",{className:"font-sans",children:"esc"})," ",t("commandPalette.footer.close")]})]})]})})]})},zc=(t,e,s)=>zn(Fr(t,e),s),l0=()=>{const t=Ye.c(47),{t:e}=jt(),s=ve(c0),r=ve(d0),i=ve(u0);let o,l,a,d,u,f,p,m,b,x,v,y;if(t[0]!==s||t[1]!==r||t[2]!==i||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:[zn("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:[`${zn($i("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${zn($i("switch_session_tab",i))} + 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=W=>n.jsxs("div",{children:[n.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(W.categoryKey)}),n.jsx("div",{className:"space-y-1",children:W.items.map(L=>{const K=L.id?fb(L.id):void 0,A=L.descriptionKey??(K?.customizable?K.settingsLabelKey:void 0);if(!A||L.id&&!Fr(L.id,i))return null;const D=L.id?zc(L.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(L.keys)?L.keys:L.keys.split(" / ");return n.jsxs("div",{className:"flex items-center gap-3 py-1 px-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[L.icon&&n.jsx(F,{name:L.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"typography-meta",children:e(A)})]}),n.jsx("div",{"aria-hidden":!0,className:"min-w-4 flex-1 border-b border-dotted border-border"}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:(Array.isArray(D)?D:[D]).map((E,M)=>n.jsxs(c.Fragment,{children:[M>0&&n.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),n.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:E})]},`${E}-${M}`))})]},L.id||A)})})]},W.categoryKey);a=Ds,v=s,y=r,l=Es,b="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=n.jsx(F,{name:"command",className:"h-5 w-5"}),t[16]=C):C=t[16];let R;t[17]!==e?(R=e("helpDialog.title"),t[17]=e,t[18]=R):R=t[18];let T;t[19]!==R?(T=n.jsxs(qs,{className:"flex items-center gap-2",children:[C,R]}),t[19]=R,t[20]=T):T=t[20];let O;t[21]!==e?(O=e("helpDialog.description"),t[21]=e,t[22]=O):O=t[22];let _;t[23]!==O?(_=n.jsx(Ys,{children:O}),t[23]=O,t[24]=_):_=t[24],t[25]!==T||t[26]!==_?(x=n.jsxs(Gs,{children:[T,_]}),t[25]=T,t[26]=_,t[27]=x):x=t[27],o=gn,f="flex-1 min-h-0 mt-3",p="pr-1",m=!0,d="grid grid-cols-1 gap-x-12 gap-y-4 lg:grid-cols-2",u=["left","right"].map(W=>n.jsxs("div",{className:"space-y-4",children:[j.filter(L=>L.column===W).map(N),W==="right"&&n.jsxs("ul",{className:"space-y-0.5 px-2 typography-meta text-muted-foreground",children:[n.jsxs("li",{children:["• ",e("helpDialog.proTips.commandPalette",{shortcut:zc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))})]}),n.jsxs("li",{children:["• ",e("helpDialog.proTips.recentSessions")]}),n.jsxs("li",{children:["• ",e("helpDialog.proTips.leaderSequences")]})]})]},W)),t[0]=s,t[1]=r,t[2]=i,t[3]=e,t[4]=o,t[5]=l,t[6]=a,t[7]=d,t[8]=u,t[9]=f,t[10]=p,t[11]=m,t[12]=b,t[13]=x,t[14]=v,t[15]=y}else o=t[4],l=t[5],a=t[6],d=t[7],u=t[8],f=t[9],p=t[10],m=t[11],b=t[12],x=t[13],v=t[14],y=t[15];let g;t[28]!==d||t[29]!==u?(g=n.jsx("div",{className:d,children:u}),t[28]=d,t[29]=u,t[30]=g):g=t[30];let h;t[31]!==o||t[32]!==f||t[33]!==p||t[34]!==m||t[35]!==g?(h=n.jsx(o,{outerClassName:f,className:p,disableHorizontal:m,children:g}),t[31]=o,t[32]=f,t[33]=p,t[34]=m,t[35]=g,t[36]=h):h=t[36];let w;t[37]!==l||t[38]!==h||t[39]!==b||t[40]!==x?(w=n.jsxs(l,{className:b,children:[x,h]}),t[37]=l,t[38]=h,t[39]=b,t[40]=x,t[41]=w):w=t[41];let S;return t[42]!==a||t[43]!==w||t[44]!==v||t[45]!==y?(S=n.jsx(a,{open:v,onOpenChange:y,children:w}),t[42]=a,t[43]=w,t[44]=v,t[45]=y,t[46]=S):S=t[46],S};function c0(t){return t.isHelpDialogOpen}function d0(t){return t.setHelpDialogOpen}function u0(t){return t.shortcutOverrides}const f0=()=>{const t=Ye.c(32),{t:e}=jt(),s=ve(p0),r=ve(m0),i=ve(h0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await Hn(i)).ok){We.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}We.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=n.jsx(qs,{children:a}),t[5]=a,t[6]=d):d=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=n.jsx(Ys,{children:u}),t[9]=u,t[10]=f):f=t[10];let p;t[11]!==d||t[12]!==f?(p=n.jsxs(Gs,{children:[d,f]}),t[11]=d,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 b;t[16]!==l||t[17]!==m?(b=n.jsx("div",{className:"flex items-center justify-end",children:n.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:m})}),t[16]=l,t[17]=m,t[18]=b):b=t[18];let x;t[19]!==i||t[20]!==e?(x=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=x):x=t[21];let v;t[22]!==x?(v=n.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]=v):v=t[23];let y;t[24]!==p||t[25]!==b||t[26]!==v?(y=n.jsxs(Es,{className:"max-w-2xl",children:[p,b,v]}),t[24]=p,t[25]=b,t[26]=v,t[27]=y):y=t[27];let g;return t[28]!==s||t[29]!==r||t[30]!==y?(g=n.jsx(Ds,{open:s,onOpenChange:r,children:y}),t[28]=s,t[29]=r,t[30]=y,t[31]=g):g=t[31],g};function p0(t){return t.isOpenCodeStatusDialogOpen}function m0(t){return t.setOpenCodeStatusDialogOpen}function h0(t){return t.openCodeStatusText}const g0=t=>{const e=Ye.c(16),{enabled:s,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=s===void 0?!0:s;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const x=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(x)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let f,p;e[5]!==a||e[6]!==o||e[7]!==i?(f=()=>{if(!a||typeof window>"u")return;const x=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",x),()=>window.removeEventListener("openchamber:sidebar-session-search",x)},p=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=f,e[9]=p):(f=e[8],p=e[9]),c.useEffect(f,p);let m,b;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(m=()=>{if(!a||!r||typeof document>"u")return;const x=v=>{l.current&&(l.current.contains(v.target)||i(!1))};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},b=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=m,e[15]=b):(m=e[14],b=e[15]),c.useEffect(m,b)},b0=t=>{const e=Ye.c(4);let s;e[0]!==t?(s=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(x0)),u=[];a.forEach(m=>{const b=d.get(m);b&&(u.push(b),d.delete(m))});const f=[],p=[];return l.forEach(m=>{d.has(m.id)&&(m.isArchivedBucket?p.push(m):f.push(m))}),[...f,...u,...p]},e[0]=t,e[1]=s):s=e[1];const r=s;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function x0(t){return[t.id,t]}const so="oc.sessions.projectCollapse",Vc="oc.sessions.groupOrder",Uc="oc.sessions.groupCollapse",Hc=t=>{if(!t)return new Set;try{const e=_a(Un()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},y0=t=>{if(!t)return new Map;try{const e=uf(Un(),_a(Un())).safeParse(JSON.parse(t));if(!e.success)return new Map;const s=new Map;for(const[r,i]of Object.entries(e.data))s.set(r,i);return s}catch{return new Map}},w0=t=>{const e=Ye.c(39),{isVSCode:s,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Co(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>Hc(o.getItem(so)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>Hc(o.getItem(Uc)),e[2]=u):u=e[2];const[f,p]=c.useState(u);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=()=>y0(o.getItem(Vc)),e[3]=m):m=e[3];const[b,x]=c.useState(m),v=c.useRef(0),y=c.useRef(!1),g=c.useRef(!1),h=c.useRef(null),w=c.useRef(null);let S;e[4]!==s?(S=()=>{if(s)return;const pe=w.current;if(w.current=null,h.current=null,!pe)return;const{projects:je}=Vt.getState(),he=je.map(X=>({...X,sidebarCollapsed:pe.has(X.id)}));sr({projects:he}).catch(v0)},e[4]=s,e[5]=S):S=e[5];const j=S;let N;e[6]!==j||e[7]!==s?(N=pe=>{!globalThis.window||s||(w.current=pe,h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{j()},700))},e[6]=j,e[7]=s,e[8]=N):N=e[8];const C=N;let R,T;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=()=>()=>{globalThis.window&&h.current!==null&&window.clearTimeout(h.current),h.current=null,w.current=null},T=[],e[9]=R,e[10]=T):(R=e[9],T=e[10]),c.useEffect(R,T);let O,_;e[11]!==b?(_=()=>{if(g.current)try{o.setItem(Vc,JSON.stringify(Object.fromEntries(b.entries())))}catch{}},O=[b,o],e[11]=b,e[12]=O,e[13]=_):(O=e[12],_=e[13]),c.useEffect(_,O);let W,L;e[14]!==f?(W=()=>{if(y.current)try{o.setItem(Uc,JSON.stringify(Array.from(f)))}catch{}},L=[f,o],e[14]=f,e[15]=W,e[16]=L):(W=e[15],L=e[16]),c.useEffect(W,L);let K;e[17]!==r||e[18]!==C?(K=()=>{v.current=Date.now()+150,y.current=!0,p(new Set),d(()=>{const pe=new Set(r.map(S0));try{o.setItem(so,JSON.stringify(Array.from(pe)))}catch{}return C(pe),pe})},e[17]=r,e[18]=C,e[19]=K):K=e[19];const A=K;let D;e[20]!==C?(D=()=>{v.current=Date.now()+150,y.current=!0,p(new Set),d(()=>{const pe=new Set;try{o.setItem(so,JSON.stringify([]))}catch{}return C(pe),pe})},e[20]=C,e[21]=D):D=e[21];const E=D;let M;e[22]!==C?(M=pe=>{v.current=Date.now()+150,d(je=>{const he=new Set(je);he.has(pe)?he.delete(pe):he.add(pe);try{o.setItem(so,JSON.stringify(Array.from(he)))}catch{}return C(he),he})},e[22]=C,e[23]=M):M=e[23];const k=M;let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=pe=>{y.current=!0,p(je=>{const he=new Set(je);return he.has(pe)?he.delete(pe):he.add(pe),he})},e[24]=I):I=e[24];const U=I;let z;e[25]===Symbol.for("react.memo_cache_sentinel")?(z=pe=>{g.current=!0,x(pe)},e[25]=z):z=e[25];const ce=z,{getOrderedGroups:re}=b0(b);let Y;e[26]!==f||e[27]!==a||e[28]!==b?(Y={collapsedProjects:a,collapsedGroups:f,groupOrderByProject:b},e[26]=f,e[27]=a,e[28]=b,e[29]=Y):Y=e[29];const me=Y;let be;e[30]!==A||e[31]!==E||e[32]!==re||e[33]!==C||e[34]!==k?(be={setCollapsedProjects:d,toggleProject:k,collapseAllProjects:A,expandAllProjects:E,scheduleCollapsedProjectsPersist:C,setCollapsedGroups:p,toggleGroup:U,setGroupOrderByProject:ce,getOrderedGroups:re},e[30]=A,e[31]=E,e[32]=re,e[33]=C,e[34]=k,e[35]=be):be=e[35];const Pe=be;let le;return e[36]!==Pe||e[37]!==me?(le={state:me,actions:Pe},e[36]=Pe,e[37]=me,e[38]=le):le=e[38],le};function v0(){}function S0(t){return t.id}const j0=5*6e4,k0=t=>{const e=Ye.c(31),{normalizedProjects:s,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=hn(),u=Yn(C0);let f,p;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==s||e[4]!==o?(f=()=>{if(!a||!d||s.length===0){o(new Map);return}s.forEach(N=>{Wi(()=>u(N.normalizedPath,d))})},p=[a,s,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=s,e[4]=o,e[5]=f,e[6]=p):(f=e[5],p=e[6]),c.useEffect(f,p);let m,b;e[7]!==a||e[8]!==i||e[9]!==s||e[10]!==o?(m=()=>{if(!a)return;const N=new Map;s.forEach(C=>{N.set(C.id,i.get(C.normalizedPath)?.isGitRepo??null)}),o(N)},b=[a,s,i,o],e[7]=a,e[8]=i,e[9]=s,e[10]=o,e[11]=m,e[12]=b):(m=e[11],b=e[12]),c.useEffect(m,b);let x;if(e[13]!==i||e[14]!==s){let N;e[16]!==i?(N=C=>{const R=i.get(C.normalizedPath)?.branch??"";return`${C.id}:${R}`},e[16]=i,e[17]=N):N=e[17],x=s.map(N).join("|"),e[13]=i,e[14]=s,e[15]=x}else x=e[15];const v=x;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=new Map,e[18]=y):y=e[18];const g=c.useRef(y);let h;e[19]===Symbol.for("react.memo_cache_sentinel")?(h=new Map,e[19]=h):h=e[19];const w=c.useRef(h);let S;e[20]!==a||e[21]!==i||e[22]!==s||e[23]!==l?(S=()=>{if(!a)return;let N=!1;const C=setTimeout(()=>{(async()=>{const T=new Set(s.map(N0));for(const A of g.current.keys())T.has(A)||(g.current.delete(A),w.current.delete(A));const O=Date.now(),_=s.filter(A=>{const D=i.get(A.normalizedPath);if(D?.isGitRepo===!1)return g.current.delete(A.id),w.current.delete(A.id),!1;if(D?.isGitRepo!==!0||D.branch===null)return!1;const E=D.branch.trim(),M=`${A.normalizedPath}\0${E}`,k=g.current.get(A.id);if(k===M){const I=w.current.get(A.id);return I&&(I.at=O),!1}return!(k!==void 0&&O-(w.current.get(A.id)?.at??0)<j0)});if(_.length===0)return;const W=await pb(_,2,async A=>{const D=i.get(A.normalizedPath)?.branch?.trim()??"",E=`${A.normalizedPath}\0${D}`,M=await Wi(()=>ku(A.normalizedPath,D?{knownBranch:D}:void 0)).catch(A0);return{id:A.id,inputKey:E,branch:M}});if(N)return;const L=W.filter(P0);if(L.length===0)return;const K=Date.now();l(A=>{const D=new Map(A);return L.forEach(E=>{const{id:M,branch:k}=E;k&&D.set(M,k)}),D}),L.forEach(A=>{const{id:D,inputKey:E,branch:M}=A;g.current.set(D,E),M&&w.current.set(D,{branch:M,at:K})})})()},150);return()=>{N=!0,clearTimeout(C)}},e[20]=a,e[21]=i,e[22]=s,e[23]=l,e[24]=S):S=e[24];let j;e[25]!==a||e[26]!==i||e[27]!==s||e[28]!==v||e[29]!==l?(j=[a,s,v,i,l],e[25]=a,e[26]=i,e[27]=s,e[28]=v,e[29]=l,e[30]=j):j=e[30],c.useEffect(S,j)};function C0(t){return t.ensureStatus}function N0(t){return t.id}function A0(){return null}function P0(t){return t.branch}const I0=t=>{const e=Ye.c(10),{open:s,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==s||e[2]!==i?(l=s&&i?n.jsx(ch,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=s,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=n.jsx(Es,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:n.jsx(gn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:n.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==s||e[8]!==a?(d=n.jsx(Ds,{open:s,onOpenChange:r,children:a}),e[6]=r,e[7]=s,e[8]=a,e[9]=d):d=e[9],d};function D0(t){const e=Ye.c(179),{t:s}=jt(),r=Mu(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenArchive:u,headerActionIconClass:f,headerActionButtonClass:p,isSessionSearchOpen:m,setIsSessionSearchOpen:b,sessionSearchInputRef:x,sessionSearchQuery:v,setSessionSearchQuery:y,hasSessionSearchQuery:g,searchMatchCount:h,collapseAllProjects:w,expandAllProjects:S}=t,j=ts(V0),N=ts(z0),C=cs(K0),R=cs(W0),T=cs($0),O=cs(_0),_=cs(L0),W=cs(F0),L=cs(B0),K=cs(O0),A=cs(T0),D=cs(M0),E=o&&A==="single",M=o&&L==="timeline";if(i)return null;let k;e[0]!==p?(k=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=p,e[1]=k):k=e[1];let I;e[2]!==s?(I=s("sessions.sidebar.header.actions.addProject"),e[2]=s,e[3]=I):I=e[3];let U;e[4]!==f?(U=n.jsx(F,{name:"folder-add",className:f}),e[4]=f,e[5]=U):U=e[5];let z;e[6]!==a||e[7]!==k||e[8]!==I||e[9]!==U?(z=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:a,className:k,"aria-label":I,children:U})}),e[6]=a,e[7]=k,e[8]=I,e[9]=U,e[10]=z):z=e[10];let ce;e[11]!==s?(ce=s("sessions.sidebar.header.actions.addProject"),e[11]=s,e[12]=ce):ce=e[12];let re;e[13]!==ce?(re=n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:ce})}),e[13]=ce,e[14]=re):re=e[14];let Y;e[15]!==z||e[16]!==re?(Y=n.jsxs(vt,{children:[z,re]}),e[15]=z,e[16]=re,e[17]=Y):Y=e[17];let me;e[18]!==p?(me=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=p,e[19]=me):me=e[19];let be;e[20]!==s?(be=s("sessions.sidebar.header.actions.scheduledTasks"),e[20]=s,e[21]=be):be=e[21];let Pe;e[22]!==f?(Pe=n.jsx(F,{name:"calendar-schedule",className:f}),e[22]=f,e[23]=Pe):Pe=e[23];let le;e[24]!==d||e[25]!==me||e[26]!==be||e[27]!==Pe?(le=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,className:me,"aria-label":be,children:Pe})}),e[24]=d,e[25]=me,e[26]=be,e[27]=Pe,e[28]=le):le=e[28];let pe;e[29]!==s?(pe=s("sessions.sidebar.header.actions.scheduledTasks"),e[29]=s,e[30]=pe):pe=e[30];let je;e[31]!==pe?(je=n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:pe})}),e[31]=pe,e[32]=je):je=e[32];let he;e[33]!==le||e[34]!==je?(he=n.jsxs(vt,{children:[le,je]}),e[33]=le,e[34]=je,e[35]=he):he=e[35];let X;e[36]!==p?(X=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=p,e[37]=X):X=e[37];let de;e[38]!==s?(de=s("sessions.sidebar.nav.archive"),e[38]=s,e[39]=de):de=e[39];let fe;e[40]!==f?(fe=n.jsx(F,{name:"archive",className:f}),e[40]=f,e[41]=fe):fe=e[41];let H;e[42]!==u||e[43]!==X||e[44]!==de||e[45]!==fe?(H=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:u,className:X,"aria-label":de,children:fe})}),e[42]=u,e[43]=X,e[44]=de,e[45]=fe,e[46]=H):H=e[46];let ge;e[47]!==s?(ge=s("sessions.sidebar.nav.archive"),e[47]=s,e[48]=ge):ge=e[48];let Me;e[49]!==ge?(Me=n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:ge})}),e[49]=ge,e[50]=Me):Me=e[50];let Ne;e[51]!==H||e[52]!==Me?(Ne=n.jsxs(vt,{children:[H,Me]}),e[51]=H,e[52]=Me,e[53]=Ne):Ne=e[53];let Ie;e[54]!==r||e[55]!==f||e[56]!==s?(Ie=r.length>0&&n.jsxs(Cs,{children:[n.jsx(js,{asChild:!0,children:n.jsx(ht,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":s("sessions.sidebar.header.actions.extensionPages"),children:n.jsx(F,{name:"apps",className:f})})}),n.jsxs(ks,{align:"start",children:[n.jsx(nr,{children:s("sessions.sidebar.header.actions.extensionPages")}),r.map(R0)]})]}),e[54]=r,e[55]=f,e[56]=s,e[57]=Ie):Ie=e[57];let Te;e[58]!==he||e[59]!==Ne||e[60]!==Ie||e[61]!==Y?(Te=n.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[Y,he,Ne,Ie]}),e[58]=he,e[59]=Ne,e[60]=Ie,e[61]=Y,e[62]=Te):Te=e[62];let Le;e[63]!==b?(Le=()=>b(E0),e[63]=b,e[64]=Le):Le=e[64];let _e;e[65]!==p?(_e=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[65]=p,e[66]=_e):_e=e[66];let P;e[67]!==s?(P=s("sessions.sidebar.header.actions.searchSessions"),e[67]=s,e[68]=P):P=e[68];let oe;e[69]!==f?(oe=n.jsx(F,{name:"search",className:f}),e[69]=f,e[70]=oe):oe=e[70];let V;e[71]!==m||e[72]!==Le||e[73]!==_e||e[74]!==P||e[75]!==oe?(V=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Le,className:_e,"aria-label":P,"aria-expanded":m,children:oe})}),e[71]=m,e[72]=Le,e[73]=_e,e[74]=P,e[75]=oe,e[76]=V):V=e[76];let Q;e[77]!==s?(Q=s("sessions.sidebar.header.actions.searchSessions"),e[77]=s,e[78]=Q):Q=e[78];let ue;e[79]!==Q?(ue=n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Q})}),e[79]=Q,e[80]=ue):ue=e[80];let Z;e[81]!==V||e[82]!==ue?(Z=n.jsxs(vt,{children:[V,ue]}),e[81]=V,e[82]=ue,e[83]=Z):Z=e[83];const ee=j&&"bg-interactive-hover text-primary";let ke;e[84]!==p||e[85]!==ee?(ke=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent",ee),e[84]=p,e[85]=ee,e[86]=ke):ke=e[86];let ne;e[87]!==j||e[88]!==s?(ne=s(j?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[87]=j,e[88]=s,e[89]=ne):ne=e[89];let q;e[90]!==f?(q=n.jsx(F,{name:"checkbox-multiple",className:f}),e[90]=f,e[91]=q):q=e[91];let ie;e[92]!==j||e[93]!==ke||e[94]!==ne||e[95]!==q||e[96]!==N?(ie=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:N,className:ke,"aria-label":ne,"aria-pressed":j,children:q})}),e[92]=j,e[93]=ke,e[94]=ne,e[95]=q,e[96]=N,e[97]=ie):ie=e[97];let Ee;e[98]!==j||e[99]!==s?(Ee=s(j?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[98]=j,e[99]=s,e[100]=Ee):Ee=e[100];let Ae;e[101]!==Ee?(Ae=n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Ee})}),e[101]=Ee,e[102]=Ae):Ae=e[102];let $e;e[103]!==ie||e[104]!==Ae?($e=n.jsxs(vt,{children:[ie,Ae]}),e[103]=ie,e[104]=Ae,e[105]=$e):$e=e[105];let Oe;e[106]!==p?(Oe=De(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[106]=p,e[107]=Oe):Oe=e[107];let qe;e[108]!==s?(qe=s("sessions.sidebar.header.displayMode.label"),e[108]=s,e[109]=qe):qe=e[109];let ct;e[110]!==f?(ct=n.jsx(F,{name:"equalizer-2",className:f}),e[110]=f,e[111]=ct):ct=e[111];let Ve;e[112]!==Oe||e[113]!==qe||e[114]!==ct?(Ve=n.jsx(St,{asChild:!0,children:n.jsx(js,{asChild:!0,children:n.jsx("button",{type:"button",className:Oe,"aria-label":qe,children:ct})})}),e[112]=Oe,e[113]=qe,e[114]=ct,e[115]=Ve):Ve=e[115];let nt;e[116]!==s?(nt=s("sessions.sidebar.header.displayMode.label"),e[116]=s,e[117]=nt):nt=e[117];let kt;e[118]!==nt?(kt=n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:nt})}),e[118]=nt,e[119]=kt):kt=e[119];let dt;e[120]!==Ve||e[121]!==kt?(dt=n.jsxs(vt,{children:[Ve,kt]}),e[120]=Ve,e[121]=kt,e[122]=dt):dt=e[122];let yt;e[123]!==K||e[124]!==o||e[125]!==L||e[126]!==s||e[127]!==M?(yt=o?n.jsxs(n.Fragment,{children:[n.jsx(nr,{children:s("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(Ke=>{const[B,Se]=Ke;return n.jsxs(Wt,{onClick:()=>{K(B),sr({sidebarViewMode:B})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(Se)}),L===B?n.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]},B)}),M?null:n.jsx(ws,{})]}):null,e[123]=K,e[124]=o,e[125]=L,e[126]=s,e[127]=M,e[128]=yt):yt=e[128];let _t;e[129]!==A||e[130]!==T||e[131]!==D||e[132]!==O||e[133]!==W||e[134]!==o||e[135]!==s||e[136]!==M||e[137]!==_?(_t=M?null:n.jsxs(n.Fragment,{children:[n.jsx(nr,{children:s("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(Ke=>{const[B,Se]=Ke;return n.jsxs(Wt,{onClick:()=>{O(B),sr({sidebarProjectSortOrder:B})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(Se)}),T===B?n.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]},B)}),n.jsx(ws,{}),o?n.jsxs(n.Fragment,{children:[n.jsx(nr,{children:s("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(Ke=>{const[B,Se]=Ke;return n.jsxs(Wt,{onClick:()=>{W(B),sr({sidebarWorktreeSortOrder:B})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(Se)}),_===B?n.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]},B)}),n.jsx(ws,{})]}):null,o?n.jsxs(n.Fragment,{children:[n.jsx(nr,{children:s("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Ke=>{const[B,Se]=Ke;return n.jsxs(Wt,{onClick:()=>{D(B),sr({sidebarProjectDisplayMode:B})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(Se)}),A===B?n.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]},B)}),n.jsx(ws,{})]}):null]}),e[129]=A,e[130]=T,e[131]=D,e[132]=O,e[133]=W,e[134]=o,e[135]=s,e[136]=M,e[137]=_,e[138]=_t):_t=e[138];let Bt;e[139]!==E||e[140]!==l||e[141]!==C||e[142]!==s||e[143]!==M||e[144]!==R?(Bt=!M&&l&&!E?n.jsxs(Wt,{onClick:()=>{R(),sr({sidebarShowRecentSection:!C})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s("sessions.sidebar.header.displayMode.showRecent")}),C?n.jsx(F,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[139]=E,e[140]=l,e[141]=C,e[142]=s,e[143]=M,e[144]=R,e[145]=Bt):Bt=e[145];let Lt;e[146]!==w||e[147]!==S||e[148]!==E||e[149]!==s||e[150]!==M?(Lt=!M&&!E?n.jsxs(n.Fragment,{children:[n.jsx(ws,{}),n.jsxs(Wt,{onClick:w,className:"flex items-center gap-2",children:[n.jsx(F,{name:"contract-up-down",className:"h-4 w-4"}),n.jsx("span",{children:s("sessions.sidebar.header.displayMode.collapseAll")})]}),n.jsxs(Wt,{onClick:S,className:"flex items-center gap-2",children:[n.jsx(F,{name:"expand-up-down",className:"h-4 w-4"}),n.jsx("span",{children:s("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[146]=w,e[147]=S,e[148]=E,e[149]=s,e[150]=M,e[151]=Lt):Lt=e[151];let Rt;e[152]!==yt||e[153]!==_t||e[154]!==Bt||e[155]!==Lt?(Rt=n.jsxs(ks,{align:"end",className:"min-w-[180px]",children:[yt,_t,Bt,Lt]}),e[152]=yt,e[153]=_t,e[154]=Bt,e[155]=Lt,e[156]=Rt):Rt=e[156];let Et;e[157]!==dt||e[158]!==Rt?(Et=n.jsxs(Cs,{children:[dt,Rt]}),e[157]=dt,e[158]=Rt,e[159]=Et):Et=e[159];let Nt;e[160]!==Z||e[161]!==$e||e[162]!==Et?(Nt=n.jsxs("div",{className:"flex items-center gap-1.5",children:[Z,$e,Et]}),e[160]=Z,e[161]=$e,e[162]=Et,e[163]=Nt):Nt=e[163];let ye;e[164]!==Te||e[165]!==Nt?(ye=n.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[Te,Nt]}),e[164]=Te,e[165]=Nt,e[166]=ye):ye=e[166];let He;e[167]!==g||e[168]!==m||e[169]!==h||e[170]!==x||e[171]!==v||e[172]!==b||e[173]!==y||e[174]!==s?(He=m?n.jsx("div",{className:"pb-1",children:n.jsx(Zd,{inputRef:x,value:v,onSearch:y,onClose:()=>b(!1),placeholder:s("sessions.sidebar.header.search.placeholder"),clearLabel:s("sessions.sidebar.header.search.clear"),leadingHint:g?h===1?s("sessions.sidebar.header.search.matchCountSingle",{count:h}):s("sessions.sidebar.header.search.matchCountPlural",{count:h}):void 0,trailingHint:s("sessions.sidebar.header.search.escapeHint")})}):null,e[167]=g,e[168]=m,e[169]=h,e[170]=x,e[171]=v,e[172]=b,e[173]=y,e[174]=s,e[175]=He):He=e[175];let mt;return e[176]!==ye||e[177]!==He?(mt=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:n.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[ye,He]})}),e[176]=ye,e[177]=He,e[178]=mt):mt=e[178],mt}function E0(t){return!t}function R0(t){return n.jsxs(Wt,{onSelect:()=>ve.getState().setOpenGuestPage(t.id),children:[n.jsx(Br,{icon:hb(t.icon),iconSrc:mb(t.id,t.icon,ym().authenticatedAsset),className:"size-4"}),n.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function M0(t){return t.setProjectDisplayMode}function T0(t){return t.projectDisplayMode}function O0(t){return t.setSidebarViewMode}function B0(t){return t.sidebarViewMode}function F0(t){return t.setWorktreeSortOrder}function L0(t){return t.worktreeSortOrder}function _0(t){return t.setProjectSortOrder}function $0(t){return t.projectSortOrder}function W0(t){return t.toggleRecentSection}function K0(t){return t.showRecentSection}function z0(t){return t.toggleMode}function V0(t){return t.enabled}const no="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 U0(t){const e=Ye.c(14),{onOpenSettings:s,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,f=d===void 0?!0:d,{t:p}=jt();if(!u&&!f)return null;let m;e[0]!==o||e[1]!==s||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==p?(m=u?n.jsxs(n.Fragment,{children:[n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:s,className:no,"aria-label":p("sessions.sidebar.footer.actions.settings"),children:n.jsx(F,{name:"settings-3",className:"h-4.5 w-4.5"})})}),n.jsx(wt,{side:"top",sideOffset:4,children:n.jsx("p",{children:p("sessions.sidebar.footer.actions.settings")})})]}),n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:r,className:no,"aria-label":p("usageStats.openAction"),children:n.jsx(F,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),n.jsx(wt,{side:"top",sideOffset:4,children:n.jsx("p",{children:p("usageStats.openAction")})})]}),n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:i,className:no,"aria-label":p("sessions.sidebar.footer.actions.shortcuts"),children:n.jsx(F,{name:"command",className:"h-4.5 w-4.5"})})}),n.jsx(wt,{side:"top",sideOffset:4,children:n.jsx("p",{children:p("sessions.sidebar.footer.actions.shortcuts")})})]}),n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:no,"aria-label":p("sessions.sidebar.footer.actions.aboutOpenChamber"),children:n.jsx(F,{name:"information",className:"h-4.5 w-4.5"})})}),n.jsx(wt,{side:"top",sideOffset:4,children:n.jsx("p",{children:p("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=s,e[2]=i,e[3]=r,e[4]=u,e[5]=p,e[6]=m):m=e[6];let b;e[7]!==l||e[8]!==f||e[9]!==p?(b=f?n.jsx(ht,{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:l,children:p("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=f,e[9]=p,e[10]=b):b=e[10];let x;return e[11]!==m||e[12]!==b?(x=n.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[m,b]}),e[11]=m,e[12]=b,e[13]=x):x=e[13],x}const H0=t=>{for(const e of t.sessions.values())if(e.tabs.some(Vd))return!0;return!1},G0=()=>{const t=Ye.c(4),{terminal:e}=hn(),s=Ot(H0);let r,i;return t[0]!==s||t[1]!==e?(r=()=>{const o=q0,l=Y0;if(s)return Mi(e,"",l,o);let a=Q0;return a=Mi(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,s],t[0]=s,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function q0(t){const e=Ot.getState(),s=dh(t.sessions),r=new Set([...e.sessions.keys(),...s.keys()]);for(const i of r)e.reconcileServerSessions(i,s.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function Y0(){return new Map(Ot.getState().actionMutationRevisions)}function Q0(){}const Yf=2*6e4,ki=Yf-1e4,X0=15e3,J0=()=>document.visibilityState==="visible";function Z0(t,e,s,r,i){const o=Ye.c(15),l=ys(ek),a=c.useRef(t),d=c.useRef(e),u=c.useRef(s);let f;o[0]!==i||o[1]!==r||o[2]!==l?(f=y=>{!i||!r||!J0()||l(a.current,r,{minAgeMs:y,linkedRefs:d.current,linkedIssueRefs:u.current})},o[0]=i,o[1]=r,o[2]=l,o[3]=f):f=o[3];const p=f;let m,b;o[4]!==t||o[5]!==s||o[6]!==e||o[7]!==p?(m=()=>{a.current=t,d.current=e,u.current=s,p(ki)},b=[t,s,e,p],o[4]=t,o[5]=s,o[6]=e,o[7]=p,o[8]=m,o[9]=b):(m=o[8],b=o[9]),c.useEffect(m,b);let x,v;o[10]!==i||o[11]!==r||o[12]!==p?(x=()=>{if(!i||!r)return;const y=window.setInterval(()=>p(ki),Yf),g=()=>p(X0);document.addEventListener("visibilitychange",g),window.addEventListener("focus",g);const h=ys.persist.onFinishHydration(()=>p(ki));return()=>{h(),window.clearInterval(y),document.removeEventListener("visibilitychange",g),window.removeEventListener("focus",g)}},v=[i,r,p],o[10]=i,o[11]=r,o[12]=p,o[13]=x,o[14]=v):(x=o[13],v=o[14]),c.useEffect(x,v)}function ek(t){return t.syncOpenPrSummaries}const tk=t=>{const e=Ye.c(12),{normalizedProjects:s,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:f,addSessionToFolder:p}=t,m=r===void 0?!0:r;let b,x;e[0]!==p||e[1]!==f||e[2]!==m||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==s||e[8]!==i||e[9]!==d?(b=()=>{!m||o||!l||a||s.forEach(v=>{if(d.has(v.normalizedPath))return;const y=Tu(v.normalizedPath),g=i.archivedSessionsByProject.get(v.id)??[],h=u[y]??[],w=new Map(h.map(sk));g.forEach(S=>{const j=gb(S,v.normalizedPath),N=j.toLowerCase();let C=w.get(N);C||(C=f(y,j),w.set(N,C)),C.sessionIds.includes(S.id)||p(y,C.id,S.id)})})},x=[s,m,i,o,l,a,d,u,f,p],e[0]=p,e[1]=f,e[2]=m,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=s,e[8]=i,e[9]=d,e[10]=b,e[11]=x):(b=e[10],x=e[11]),c.useEffect(b,x)};function sk(t){return[t.name.toLowerCase(),t]}function nk({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:s,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&s===t)return{kind:"preserve-current"};if(s==null){const u=!!(e&&Array.from(i.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 d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const rk=t=>{const e=Ye.c(26),{projectSections:s,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:f,openNewSessionDraft:p,setSessionSwitcherOpen:m}=t;let b,x;if(e[0]!==s){x=new Map,b=new Map;const N=(C,R,T,O)=>{x.has(C)||x.set(C,new Map);const _=x.get(C);O.forEach(W=>{const L=ut(W.worktree?.path??W.session.directory??T??R);_.set(W.session.id,{directory:L}),b.has(C)||b.set(C,{id:W.session.id,directory:L}),W.children.length>0&&N(C,R,L,W.children)})};s.forEach(C=>{C.groups.forEach(R=>{N(C.project.id,C.project.normalizedPath,R.directory,R.sessions)})}),e[0]=s,e[1]=b,e[2]=x}else b=e[1],x=e[2];let v;e[3]!==b||e[4]!==x?(v={metaByProject:x,firstSessionByProject:b},e[3]=b,e[4]=x,e[5]=v):v=e[5];const y=v,g=c.useRef(null);let h,w;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==f||e[12]!==u||e[13]!==p||e[14]!==s||e[15]!==y||e[16]!==o||e[17]!==m?(h=()=>{if(!r||u||ve.getState().isNewWorktreeDialogOpen||g.current===r)return;const N=s.find(O=>O.project.id===r);if(!N)return;if(g.current===null){g.current=r;return}const C=y.metaByProject.get(r);if(l&&C&&C.has(l)){g.current=r,o(O=>{if(O.get(r)===l)return O;const _=new Map(O);return _.set(r,l),_});return}const R=nk({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:C,metaByProject:y.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:y.firstSessionByProject.get(r)?.id??null});if(R.kind==="preserve-current"){a===r&&(g.current=r);return}if(g.current=r,R.kind==="open-draft"){f&&m(!1),p({selectedProjectId:N.project.id,directoryOverride:N.project.normalizedPath});return}if(R.kind!=="select-session")return;const T=C?.get(R.sessionId)?.directory??null;d(R.sessionId,T)},w=[r,i,l,a,d,u,f,p,s,y,m,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=f,e[12]=u,e[13]=p,e[14]=s,e[15]=y,e[16]=o,e[17]=m,e[18]=h,e[19]=w):(h=e[18],w=e[19]),c.useLayoutEffect(h,w);let S,j;e[20]!==r||e[21]!==l||e[22]!==y||e[23]!==o?(S=()=>{if(!r||!l)return;const N=y.metaByProject.get(r);!N||!N.has(l)||o(C=>{if(C.get(r)===l)return C;const R=new Map(C);return R.set(r,l),R})},j=[r,l,y,o],e[20]=r,e[21]=l,e[22]=y,e[23]=o,e[24]=S,e[25]=j):(S=e[24],j=e[25]),c.useEffect(S,j)},ok=t=>{const e=Ye.c(20);let s,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...s}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=i,e[4]=o):(s=e[1],r=e[2],i=e[3],o=e[4]);const l=Je(ik),a=Je(ak);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let f;e[8]!==r?(f=()=>new Map(r),e[8]=r,e[9]=f):f=e[9];const[p,m]=c.useState(f);let b;e[10]!==p||e[11]!==s||e[12]!==l||e[13]!==u||e[14]!==a?(b={...s,activeSessionByProject:p,setActiveSessionByProject:m,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=p,e[11]=s,e[12]=l,e[13]=u,e[14]=a,e[15]=b):b=e[15],rk(b);let x,v;return e[16]!==p||e[17]!==i?(x=()=>{i(p)},v=[p,i],e[16]=p,e[17]=i,e[18]=x,e[19]=v):(x=e[18],v=e[19]),c.useEffect(x,v),null};function ik(t){return t.currentSessionId}function ak(t){return!!t.newSessionDraft?.open}const lk=t=>{const e=Ye.c(7),{ownership:s}=t;let r;e[0]!==s?(r=d=>s.sessionsByProject.get(d)??[],e[0]=s,e[1]=r):r=e[1];const i=r;let o;e[2]!==s?(o=d=>s.archivedSessionsByProject.get(d)??[],e[2]=s,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},$n=(t,e)=>`${t}\0${e}`,Dn=(t,e)=>t??Ra(e)??ut(e??null),Mr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??ut(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},Ya=t=>t.startsWith("__archived__:"),ck=(t,e)=>{const s=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!s)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==s.id);return(e.mainWorkspaceOnly?[s,...r?[r]:[]]:[...t.groups.find(o=>o.isMain)?[t.groups.find(o=>o.isMain)]:[],...t.groups.filter(o=>!o.isMain)]).map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?o.id===s.id:o.isMain}))},Gc=(t,e,s)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&s.add(i.session.id),o};for(const i of t)r(i)},pr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const s of t.children)if(pr(s,e))return!0;return!1},dk=({isSubtaskSession:t,archivedBucket:e,isVSCode:s,sessionDirectory:r})=>!t&&!e&&!s&&!Ma(r),uk=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:s})=>!t||e||s,fk=(t,e,s)=>{const r=new Map,i=o=>{const l=Is(o.session)??ut(o.worktree?.path)??s;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},ca=(t,e)=>{const s=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(s.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},Qf=t=>{const e=new Map(t.map(l=>[l.id,l])),s=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=s.get(l.parentId)??[];a.push(l),s.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of s.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},Xf=(t,e)=>{const s=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const m=i.get(u.parentId)??[];m.push(u.id),i.set(u.parentId,m)}const f=new Set;let p=u.id;for(;p;){if(f.has(p)){o.add(u.id);break}f.add(p),p=r.get(p)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const f=r.get(u);if(!f)return!1;a.add(u);let p=o.has(u);return!p&&e.archivedBucket&&f.nodeCount===0?p=(i.get(u)??[]).some(d):(!p&&!e.searchQuery&&(p=!0),!p&&(f.nodeCount>0||!s&&No([f.name],e.searchQuery))&&(p=!0),p||(p=(i.get(u)??[]).some(d))),a.delete(u),p&&l.add(u),p};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},qc=new WeakMap;let Yc=1;const pk=t=>{const e=qc.get(t);if(e!==void 0)return e;const s=Yc;return Yc+=1,qc.set(t,s),s},Mo=t=>t.children.length===0?"":t.children.map(s=>{const r=pk(s.session);return s.children.length===0?`${s.session.id}@${r}`:`${s.session.id}@${r}:${Mo(s)}`}).join("|"),Jf=(t,e,s,r,i,o)=>{const l=Qt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const f=d.session.directory??i,p=u.session.directory??o,m=Fl(l,f??"",d.session.id),b=Fl(l,p??"",u.session.id);return(m?s.has(m):!1)!==(b?r.has(b):!1)?!0:d.children.some((x,v)=>a(x,u.children[v]))};return a(t,e)},mk=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,hk=(t,e)=>t?t.branchLabel??null:e??null,gk=(t,e)=>{if(e)return null;const s=t?.branch?.trim(),r=ut(t?.path??null);return s&&r?_o(r,s):null},To=(t,e,s,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${s}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o},ro=t=>"run"in t,bk=(t,e)=>`${t}:active:run:${e}`,Ci=(t,e,s)=>{if(s||e.runKeyBySessionId.size===0)return[...t];const r=[],i=new Map;for(const o of t){const l=e.runKeyBySessionId.get(o.session.id),a=l?e.runs.get(l):void 0;if(!a){r.push(o);continue}const d=i.get(a.key);if(d){d.lanes.push(o);continue}const u={run:a,lanes:[o]};i.set(a.key,u),r.push(u)}for(const o of i.values()){const l=new Map(o.run.memberIds.map((a,d)=>[a,d]));o.lanes.sort((a,d)=>(l.get(a.session.id)??0)-(l.get(d.session.id)??0))}return r},Zf=(t,e)=>{const s=e.trim().toLowerCase(),r=s.startsWith("ses_"),i=o=>o.reduce((l,a)=>l+(!r||a.session.id.toLowerCase()===s?1:0)+i(a.children),0);return i(t)},xk=[],yk=new Set,Qc=32,Xc=64,wk=3,vk=7,oo=32,Ln=28,Jc=(t,e,s,r)=>{const i=r.get(t.session.id),o=r.get(e.session.id);if(i!==void 0||o!==void 0){if(i===void 0)return 1;if(o===void 0)return-1;if(i!==o)return i-o}return Ta(t.session,e.session,s,Ea)},io=t=>{const e=new Map,s=new Map,r=[],i=new WeakMap,o=t.map(l=>({node:l,visited:!1})).reverse();for(;o.length>0;){const l=o.pop();if(!l)continue;if(!l.visited){e.set(l.node.session.id,l.node),s.set(l.node.session.id,l.node.session);const d=r.length;r.push(l.node.session.id),i.set(l.node,[d,d+1]),o.push({node:l.node,visited:!0});for(let u=l.node.children.length-1;u>=0;u-=1){const f=l.node.children[u];f&&o.push({node:f,visited:!1})}continue}const a=i.get(l.node);a&&i.set(l.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:s,preorderIds:Object.freeze(r),subtreeRangeByNode:i}},Sk=(t,e,s)=>`${t}:${e?"archived":"active"}:${s}`,jk=(t,e)=>{let s=null;for(const r of t){if(r.rowIndex>e)break;s=r}return s},kk=t=>{const e=[],s=[],r=[],i=[],o=[],l=new Map,a=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds),f=t.workSessionIds??yk;let p=0;const b=[...[...t.authoritativeSections.flatMap(A=>A.groups.flatMap(D=>D.sessions)),...t.chatGroup?.sessions??[]]];for(;b.length>0;){const A=b.pop();A&&(l.set(A.session.id,A.session),b.push(...A.children))}const x=A=>{const D=a.get(A)??0;return a.set(A,D+1),D===0?A:`${A}:${D}`},v=A=>{e.push(Object.freeze(A))},y=t.runIndex??bb,g=(A,D)=>{const E=bk(D.renderContext,A.run.key),M=D.renderContext!=="timeline"&&(d||t.expandedParents.has(E)),k=A.lanes[0]?.session.id,I=k&&D.getSecondaryMeta?D.getSecondaryMeta(k):D.secondaryMeta;v({kind:"run",key:x(`${D.containerKey}:run:${A.run.key}`),estimateSize:D.renderContext==="timeline"?Xc:Qc,run:A.run,depth:D.baseDepth??0,laneNodes:Object.freeze([...A.lanes]),projectId:D.projectId,projectLabel:I?.projectLabel??null,groupDirectory:D.groupDirectory,renderContext:D.renderContext,expansionKey:E,expanded:M,forceExpanded:d}),M&&w(A.lanes,(D.baseDepth??0)+1,D)},h=A=>{for(const D of Ci(A.nodes,y,A.archived))ro(D)?g(D,A):w([D],A.baseDepth??0,A)},w=(A,D,E)=>{const M=[...A].reverse().map(k=>({node:k,depth:D,directory:E.groupDirectory}));for(;M.length>0;){const k=M.pop();if(!k)continue;const I=x(`${E.containerKey}:session:${k.node.session.id}`),U=k.node.session.directory??k.directory;l.set(k.node.session.id,k.node.session),v({kind:"session",key:I,estimateSize:E.renderContext==="timeline"?Xc:Qc,node:k.node,depth:k.depth,projectId:E.projectId,groupDirectory:k.directory,ownerKey:E.ownerKey,selectionScopeKey:E.selectionScopeKey,archived:E.archived,renderContext:E.renderContext,secondaryMeta:E.getSecondaryMeta?E.getSecondaryMeta(k.node.session.id):E.secondaryMeta??null});const z=E.indexedNodes?.subtreeRangeByNode.get(k.node),ce=z&&z[1]>z[0]+1?Object.freeze([(E.selectionPoolOffset??0)+z[0]+1,(E.selectionPoolOffset??0)+z[1]]):void 0;if(s.push(Object.freeze({id:k.node.session.id,rowKey:I,scopeKey:E.selectionScopeKey,archived:E.archived,descendantRange:ce})),!(!d&&!t.expandedParents.has(Sk(E.renderContext,E.archived,k.node.session.id))))for(let re=k.node.children.length-1;re>=0;re-=1){const Y=k.node.children[re];Y&&M.push({node:Y,depth:k.depth+1,directory:U})}}},S=A=>{const D=t.groupSearchDataByGroup.get(A);if(D?.hasMatch!==!0)return 0;const E=f.size>0?D.filteredNodes.filter(k=>f.has(k.session.id)):[];return Math.max(0,D.matchedSessionCount-Zf(E,t.normalizedQuery))+D.folderNameMatchCount+(D.groupMatches?1:0)},j=(A,D,E,M,k)=>{const I=t.groupSearchDataByGroup.get(A);if(d){const ne=S(A);if(ne===0)return;p+=ne}const U=(d?I?.filteredNodes??[]:A.sessions).filter(ne=>!f.has(ne.session.id)).sort((ne,q)=>Jc(ne,q,u,t.sessionOrderIndex)),z=io(U),ce=r.length;r.push(...z.preorderIds);for(const[ne,q]of z.sessionsById)l.set(ne,q);const re=Dn(E,A.directory),Y=!d&&t.collapsedGroups.has(D);if(!M){const ne=z.preorderIds.flatMap(q=>z.sessionsById.get(q)??[]);v({kind:"group-header",key:`${D}:header`,estimateSize:oo,group:A,groupKey:D,projectId:E,collapsed:Y,forceExpanded:d,allSessions:Object.freeze(ne)})}if(Y)return;const me=Mr(A).flatMap(({scopeKey:ne,directory:q})=>(t.foldersMap[ne]??xk).map(ie=>({folder:ie,scopeKey:ne,scopeDirectory:q,ownerKey:re,nodes:ca(ie.sessionIds,z.byId).sort((Ee,Ae)=>Jc(Ee,Ae,u,t.sessionOrderIndex))}))),be=Xf(me.map(ne=>({id:ne.folder.id,name:ne.folder.name,parentId:ne.folder.parentId,nodeCount:ne.nodes.length})),{archivedBucket:A.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),Pe=me.filter(ne=>be.has(ne.folder.id)),le=new Map(Pe.map(ne=>[$n(ne.scopeKey,ne.folder.id),ne])),pe=new Map;for(const ne of Pe){if(!ne.folder.parentId)continue;const q=$n(ne.scopeKey,ne.folder.parentId),ie=pe.get(q)??[];ie.push(ne),pe.set(q,ie)}const je=Qf(Pe.map(ne=>({...ne.folder,scopeKey:ne.scopeKey}))).map(ne=>le.get($n(ne.scopeKey??"",ne.id))).filter(ne=>!!ne),he=new Set(Pe.flatMap(ne=>ne.folder.sessionIds)),X=U.filter(ne=>!he.has(ne.session.id)),de=new Map,fe=je.map(ne=>({folder:ne,visited:!1})),H=new Set;for(;fe.length>0;){const ne=fe.pop();if(!ne)continue;const q=$n(ne.folder.scopeKey,ne.folder.folder.id);if(!ne.visited){if(H.has(q))continue;H.add(q),fe.push({folder:ne.folder,visited:!0});for(const Ee of pe.get(q)??[])fe.push({folder:Ee,visited:!1});continue}const ie=ne.folder.nodes.flatMap(Ee=>{const Ae=z.subtreeRangeByNode.get(Ee);return Ae?z.preorderIds.slice(Ae[0],Ae[1]).flatMap($e=>z.sessionsById.get($e)??[]):[Ee.session]});for(const Ee of pe.get(q)??[])ie.push(...de.get($n(Ee.scopeKey,Ee.folder.id))??[]);de.set(q,Object.freeze(ie))}const ge=new Set,Me=(ne,q)=>{const ie=$n(ne.scopeKey,ne.folder.id);if(ge.has(ie))return;ge.add(ie);const Ee=q?`${q} / ${ne.folder.name}`:ne.folder.name,Ae=`${D}:folder:${ie}`,$e=!d&&t.collapsedFolders.has(ne.folder.id),Oe=de.get(ie)??[],qe=$e&&!A.isArchivedBucket?ca([...new Set(Oe.map(nt=>nt.id))],z.byId):[],ct=re?t.folderAuthorityByOwner.get(re):void 0,Ve=!!re&&!A.isArchivedBucket&&!Ya(ne.scopeKey)&&ct?.complete===!0&&ct.scopeKeys.includes(ne.scopeKey);if(v({kind:"folder-header",key:Ae,estimateSize:oo,group:A,folder:ne.folder,displayName:Ee,scopeKey:ne.scopeKey,scopeDirectory:ne.scopeDirectory,ownerKey:re,nodes:ne.nodes,activityNodes:qe,projectId:E,archived:A.isArchivedBucket===!0,collapsed:$e,forceExpanded:d,deleteSessions:Oe,subFolderCount:pe.get(ie)?.length??0,dropEnabled:Ve}),re&&o.push(Object.freeze({rowKey:Ae,scopeKey:ne.scopeKey,folderId:ne.folder.id,ownerKey:re,enabled:Ve})),!$e){h({nodes:ne.nodes,containerKey:Ae,projectId:E,groupDirectory:ne.scopeDirectory??A.directory,ownerKey:re,selectionScopeKey:re,archived:A.isArchivedBucket===!0,renderContext:"project",indexedNodes:z,selectionPoolOffset:ce,baseDepth:1});for(const nt of pe.get(ie)??[])Me(nt,Ee)}};for(const ne of je)Me(ne,"");const Ne=E?t.sessionBatchSize:void 0,Ie=k?.initial??Ne??(t.hideDirectoryControls?10:5),Te=k?.increment??Ne??7,Le=Math.max(Ie,t.visibleCountByContainer.get(D)??Ie),_e=ne=>!ro(ne)&&k?.pinnedAlwaysVisible===!0&&Ou(u,ne.session.directory??A.directory,ne.session.id),P=Ci(X,y,A.isArchivedBucket===!0),oe=P.filter(ne=>!_e(ne));let V=Le;const Q=A.isArchivedBucket||d?P:P.filter(ne=>_e(ne)?!0:V<=0?!1:(V-=1,!0)),ue=Q.flatMap(ne=>ro(ne)?ne.lanes:[ne]);h({nodes:ue,containerKey:D,projectId:E,groupDirectory:A.directory,ownerKey:re,selectionScopeKey:re,archived:A.isArchivedBucket===!0,renderContext:k?.renderContext??"project",indexedNodes:z,selectionPoolOffset:ce});const Z=P.length-Q.length,ee=Le-V;!d&&!A.isArchivedBucket&&Z>0?v({kind:"show-control",key:`${D}:more`,estimateSize:Ln,control:"more",containerKey:D,currentCount:ee,increment:Te}):!d&&!A.isArchivedBucket&&oe.length>Ie&&Z===0&&v({kind:"show-control",key:`${D}:fewer`,estimateSize:Ln,control:"fewer",containerKey:D,currentCount:ee,increment:Te});const ke=t.groupStatusByKey.get(D);U.length===0&&Pe.length===0?ke&&ke.state!=="ready"?v({kind:"status",key:`${D}:status`,estimateSize:Ln,status:ke,group:A,groupKey:D}):v({kind:"empty",key:`${D}:empty`,estimateSize:Ln,emptyKind:A.isArchivedBucket?"archived":"group",group:A,projectId:E}):ke&&ke.state!=="ready"&&ke.state!=="loading"&&v({kind:"status",key:`${D}:status`,estimateSize:Ln,status:ke,group:A,groupKey:D})},N=A=>{const D=!d&&t.collapsedActivities.has(A),E=e.length;return v({kind:"activity-header",key:`activity:${A}:header`,estimateSize:oo,activityKey:A,collapsed:D,forceExpanded:d}),i.push(Object.freeze({rowIndex:E,kind:"activity",id:A})),D},C=t.viewMode==="timeline",R=A=>"run"in A,T=A=>{const D=Ci(A.map(M=>M.node),y,!1),E=new Map(A.map(M=>[M.node,M]));return D.flatMap(M=>{if(!ro(M)){const k=E.get(M);return k?[k]:[]}return[{run:M.run,items:M.lanes.flatMap(k=>E.get(k)??[])}]})},O=(A,D,E,M)=>{const k=A.items[0];if(!k)return;const I=A.items.map(Y=>Y.node),U=io(I),z=r.length;r.push(...U.preorderIds);const ce=Dn(k.projectId,k.groupDirectory),re=new Map(A.items.map(Y=>[Y.node.session.id,Y.getSecondaryMeta?Y.getSecondaryMeta(Y.node.session.id):Y.secondaryMeta]));g({run:A.run,lanes:I},{nodes:I,containerKey:D,projectId:k.projectId,groupDirectory:k.groupDirectory,ownerKey:ce,selectionScopeKey:M?ce:null,archived:!1,renderContext:E,getSecondaryMeta:Y=>re.get(Y)??null,indexedNodes:U,selectionPoolOffset:z})},_=(A,D,E,M,k=()=>1)=>{for(const I of T(A)){if(R(I)){O(I,D,E,M),d&&(p+=I.items.reduce((Y,me)=>Y+k(me),0));continue}const U=I,z=io([U.node]),ce=r.length;r.push(...z.preorderIds);const re=Dn(U.projectId,U.groupDirectory);h({nodes:[U.node],containerKey:D,projectId:U.projectId,groupDirectory:U.groupDirectory,ownerKey:re,selectionScopeKey:null,archived:!1,renderContext:E,secondaryMeta:U.secondaryMeta,getSecondaryMeta:U.getSecondaryMeta,indexedNodes:z,selectionPoolOffset:ce}),d&&(p+=k(U))}};t.chatGroup&&(!d||S(t.chatGroup)>0)&&(N("chats")||j(t.chatGroup,"activity:chats",null,!0,C?{initial:wk,increment:vk,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}:void 0));const W=t.workItems??[];if(W.length>0&&(N("work")||_(W,"activity:work",C?"timeline":"recent",!1,D=>uh(D.node,t.normalizedQuery))),C){const A=(t.timelineItems??[]).filter(D=>!f.has(D.node.session.id));A.length>0&&(N("timeline")||_(A,"activity:timeline","timeline",!1))}if(!C&&t.showRecentSection)for(const A of t.recentSections){const D={...A,items:A.items.filter(re=>!f.has(re.node.session.id))};if(D.items.length===0||N("active-now"))continue;const M=`activity:${D.key}`,k=7,I=Math.max(k,t.visibleCountByContainer.get(M)??k),U=T(D.items),z=d?U:U.slice(0,I);for(const re of z){if(R(re)){O(re,M,"recent",!0),d&&(p+=re.items.length);continue}const Y=re,me=io([Y.node]),be=r.length;r.push(...me.preorderIds),h({nodes:[Y.node],containerKey:M,projectId:Y.projectId,groupDirectory:Y.groupDirectory,ownerKey:Dn(Y.projectId,Y.groupDirectory),selectionScopeKey:Dn(Y.projectId,Y.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:Y.secondaryMeta,getSecondaryMeta:Y.getSecondaryMeta,indexedNodes:me,selectionPoolOffset:be}),d&&(p+=1)}const ce=U.length-z.length;!d&&ce>0?v({kind:"show-control",key:`${M}:more`,estimateSize:Ln,control:"more",containerKey:M,currentCount:z.length,increment:7}):!d&&U.length>k&&v({kind:"show-control",key:`${M}:fewer`,estimateSize:Ln,control:"fewer",containerKey:M,currentCount:z.length,increment:7})}let L=C?[]:t.singleProjectMode?t.sections.filter(A=>A.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const A=L.find(D=>D.project.id===t.activeProjectId)??L[0];L=A?[A]:[]}for(const A of L){const D=ck(A,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(d&&!D.some(M=>S(M.group)>0))continue;const E=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(A.project.id);if(!t.showOnlyMainWorkspace){const M=e.length;v({kind:"project-header",key:`project:${A.project.id}:header`,estimateSize:oo,section:A,collapsed:E,forceExpanded:d}),i.push(Object.freeze({rowIndex:M,kind:"project",id:A.project.id}))}if(!E)for(const M of D)j(M.group,M.groupKey,M.projectId,M.hideGroupLabel)}e.length===0&&v({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const K=new Map;return e.forEach((A,D)=>K.set(A.key,D)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(s),selectionDescendantIds:Object.freeze(r),rowIndexByKey:K,stickyHeaders:Object.freeze(i),folderDropTargets:Object.freeze(o),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:d?p:0})},Ck=(t,e)=>t.map(s=>{const r=ut(s.path)??s.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
996
|
+
`),Nk=[],Ak=t=>{const{normalizedProjects:e,getSessionsForProject:s,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:f,normalizedSessionSearchQuery:p,filterSessionNodesForSearch:m,buildGroupSearchText:b,foldersMap:x,standaloneGroups:v}=t,y=c.useRef(new Map),g=c.useMemo(()=>{const T=y.current,O=new Map;let _=0,W=0;const L=(A,D)=>A.length===D.length&&A.every((E,M)=>E===D[M]),K=e.map(A=>{const D=s(A.id),E=r(A.id),M=i.get(A.normalizedPath)??Nk,k=o.has(A.id)?!!o.get(A.id):d,I=l.get(A.id)??null,U=Ck(M,a),z=T.get(A.id);if(z&&z.project===A&&L(z.activeSessions,D)&&L(z.archivedSessions,E)&&z.availableWorktrees===M&&z.rootBranch===I&&z.worktreeBranchesKey===U&&z.isRepo===k&&z.buildGroupedSessions===u)return _+=1,O.set(A.id,z),z.section;if(W+=1,z){const me=z.project!==A?"project":L(z.activeSessions,D)?L(z.archivedSessions,E)?z.availableWorktrees!==M?"worktrees":z.rootBranch!==I?"branch":z.worktreeBranchesKey!==U?"worktreeBranches":z.isRepo!==k?"repo":"builder":"archived":"sessions";vs(`ui.sidebar.project_section.rebuilt_reason.${me}`)}const ce=Bu([...D,...E]),re=u(ce,A.normalizedPath,M,I,k),Y={project:A,groups:re};return O.set(A.id,{project:A,activeSessions:D,archivedSessions:E,availableWorktrees:M,rootBranch:I,worktreeBranchesKey:U,isRepo:k,buildGroupedSessions:u,section:Y}),Y});return y.current=O,_>0&&vs("ui.sidebar.project_section.reused",_),W>0&&vs("ui.sidebar.project_section.rebuilt",W),K},[e,s,r,i,o,d,u,l,a]),h=c.useMemo(()=>g,[g]),w=c.useMemo(()=>{const T=new WeakMap;if(!f)return T;const _=p.trim().toLowerCase().startsWith("ses_"),W=L=>{const K=m(L.sessions,p),A=Zf(K,p),D=!_&&No([b(L)],p),E=Mr(L).flatMap(({scopeKey:k})=>x[k]??[]),M=_?0:E.filter(k=>No([k.name],p)).length;T.set(L,{filteredNodes:K,matchedSessionCount:A,folderNameMatchCount:M,groupMatches:D,hasMatch:D||A>0||M>0})};return h.forEach(L=>{L.groups.forEach(W)}),v.forEach(W),T},[f,h,v,m,p,b,x]),S=c.useMemo(()=>f?h.map(T=>({...T,groups:T.groups.filter(O=>w.get(O)?.hasMatch===!0)})).filter(T=>T.groups.length>0):h,[f,h,w]),j=f?S:h,N=c.useRef(new WeakMap),C=c.useMemo(()=>{const T=N.current;return j.map(O=>{const _=T.get(O);if(_&&_.query===p)return _.section;const W=O.groups.filter(k=>!k.isArchivedBucket),L=O.groups.filter(k=>k.isArchivedBucket),K=W.flatMap(k=>f?w.get(k)?.filteredNodes??[]:k.sessions),A=W.map(k=>({scopeKey:k.folderScopeKey??ut(k.directory??null),directory:k.directory??null})).filter(k=>!!k.scopeKey),D=W.find(k=>k.isMain)??null,E={id:"flat",label:D?.label??"",branch:D?.branch??null,description:D?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:D?.directory??O.project.normalizedPath,folderScopeKey:D?.folderScopeKey??O.project.normalizedPath,folderScopes:A,sessions:K};if(f){const k=W.map(I=>w.get(I)).filter(I=>!!I);w.set(E,{filteredNodes:K,matchedSessionCount:k.reduce((I,U)=>I+U.matchedSessionCount,0),folderNameMatchCount:k.reduce((I,U)=>I+U.folderNameMatchCount,0),groupMatches:k.some(I=>I.groupMatches),hasMatch:k.some(I=>I.hasMatch)})}const M={project:O.project,groups:[E,...L]};return T.set(O,{query:p,section:M}),M})},[w,f,p,j]),R=c.useMemo(()=>{if(!f)return 0;const T=(_,W)=>{const L=w.get(W);if(!L)return _;const K=L.folderNameMatchCount+(L.groupMatches?1:0);return _+L.matchedSessionCount+K},O=j.reduce((_,W)=>W.groups.reduce(T,_),0);return v.reduce(T,O)},[f,j,v,w]);return{projectSections:g,visibleProjectSections:h,groupSearchDataByGroup:w,searchableProjectSections:S,sectionsForRender:j,flatSectionsForRender:C,searchMatchCount:R}},Pk=180,Zc=150,Ik=2,Dk=8,ed=[-1,1],Ni=t=>`${t.directory}
|
|
997
|
+
${t.sessionId}`,Ek=t=>t?.directory?.trim()||null,Rk=({enabled:t=!0,currentSessionId:e,sortedSessions:s,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>_s(),[]),f=c.useCallback(()=>{d.current+=1,l.current=[],o.current.forEach(b=>window.clearTimeout(b)),o.current.clear()},[]),p=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<Ik&&l.current.length>0;){const b=l.current.shift();if(!b)break;if(b.generation!==d.current||Je.getState().currentSessionId===b.sessionId||Ki(b.sessionId,b.directory).renderable)continue;const v=Ni(b);a.current.add(v),i({directory:b.directory,sessionID:b.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(v),p()})}},[t,u,i]),m=c.useCallback(b=>{const x=b?.id,v=Ek(b);if(!t||u||!x||!v||x===e)return;const y={sessionId:x,directory:v,generation:d.current},g=Ni(y);if(Ki(x,v).renderable||a.current.has(g)||l.current.some(S=>Ni(S)===g))return;const h=o.current.get(g);h!==void 0&&window.clearTimeout(h);const w=window.setTimeout(()=>{if(o.current.delete(g),y.generation!==d.current)return;const S=l.current;S.length>=Dk&&S.shift(),S.push(y),p()},Pk);o.current.set(g,w)},[e,t,u,p]);c.useEffect(()=>{f()},[f,e,t,u]),c.useEffect(()=>{if(!t||u||!e||s.length===0)return;const b=window.setTimeout(()=>{const x=s.findIndex(v=>v.id===e);if(!(x<0))for(const v of ed)m(s[x+v])},Zc);return()=>window.clearTimeout(b)},[e,t,u,m,s]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const b=window.setTimeout(()=>{const x=r.findIndex(v=>v.id===e);if(!(x<0))for(const v of ed)m(r[x+v])},Zc);return()=>window.clearTimeout(b)},[e,t,u,r,m]),c.useEffect(()=>f,[f])},Mk=t=>{const e=Ye.c(3),s=Je(Tk);let r;return e[0]!==t||e[1]!==s?(r={...t,currentSessionId:s},e[0]=t,e[1]=s,e[2]=r):r=e[2],Rk(r),null};function Tk(t){return t.currentSessionId}const Ok=t=>{const e=Ye.c(83),{folder:s,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:f,children:p,renderBody:m,mobileVariant:b,alwaysShowActions:x,isRenaming:v,renameDraft:y,onRenameDraftChange:g,onRenameSave:h,onRenameCancel:w,droppableRef:S,isDropTarget:j,onNewSession:N,depth:C,hideActions:R,archivedBucket:T}=t,O=a===void 0?null:a,_=m===void 0?!0:m,L=x===void 0?b===void 0?!1:b:x,K=v===void 0?!1:v,A=y===void 0?"":y,D=j===void 0?!1:j,E=R===void 0?!1:R,M=T===void 0?!1:T,{t:k}=jt(),[I,U]=c.useState(!1),[z,ce]=c.useState(""),re=c.useRef(null),Y=K||I,me=K?A:z;let be;e[0]!==s.name?(be=()=>{ce(s.name),U(!0)},e[0]=s.name,e[1]=be):be=e[1];const Pe=be;let le;e[2]!==me||e[3]!==s.name||e[4]!==K||e[5]!==u||e[6]!==h?(le=()=>{const Ae=me.trim();Ae&&Ae!==s.name&&u(Ae),K&&h&&h(),U(!1),ce("")},e[2]=me,e[3]=s.name,e[4]=K,e[5]=u,e[6]=h,e[7]=le):le=e[7];const pe=le;let je;e[8]!==K||e[9]!==w?(je=()=>{K&&w&&w(),U(!1),ce("")},e[8]=K,e[9]=w,e[10]=je):je=e[10];const he=je;let X;e[11]!==K||e[12]!==g?(X=Ae=>{K&&g?g(Ae):ce(Ae)},e[11]=K,e[12]=g,e[13]=X):X=e[13];const de=X;let fe,H;e[14]!==K?(fe=()=>{if(!K)return;const Ae=()=>{const qe=re.current;qe&&(qe.focus(),qe.select())},$e=requestAnimationFrame(Ae),Oe=window.setTimeout(Ae,0);return()=>{cancelAnimationFrame($e),window.clearTimeout(Oe)}},H=[K],e[14]=K,e[15]=fe,e[16]=H):(fe=e[15],H=e[16]),c.useEffect(fe,H);const ge=l?"folder":"folder-open",Me=D&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let Ne;e[17]!==Me?(Ne=De("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",Me),e[17]=Me,e[18]=Ne):Ne=e[18];let Ie;e[19]!==d||e[20]!==Y?(Ie=Y?void 0:Ae=>{Ae.currentTarget.blur(),d()},e[19]=d,e[20]=Y,e[21]=Ie):Ie=e[21];const Te=Y?void 0:"button",Le=Y?void 0:0;let _e;e[22]!==d||e[23]!==Y?(_e=Y?void 0:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),d())},e[22]=d,e[23]=Y,e[24]=_e):_e=e[24];let P;e[25]!==s.name||e[26]!==l||e[27]!==k?(P=l?k("sessions.sidebar.folderItem.expandAria",{folderName:s.name}):k("sessions.sidebar.folderItem.collapseAria",{folderName:s.name}),e[25]=s.name,e[26]=l,e[27]=k,e[28]=P):P=e[28];const oe=M?L?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":L?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let V;e[29]!==oe?(V=De("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",oe),e[29]=oe,e[30]=V):V=e[30];const Q=D?"text-primary":"text-muted-foreground";let ue;e[31]!==Q?(ue=De("h-3.5 w-3.5 flex-shrink-0",Q),e[31]=Q,e[32]=ue):ue=e[32];let Z;e[33]!==ge||e[34]!==ue?(Z=n.jsx(F,{name:ge,className:ue}),e[33]=ge,e[34]=ue,e[35]=Z):Z=e[35];let ee;e[36]!==O||e[37]!==r||e[38]!==me||e[39]!==s.name||e[40]!==he||e[41]!==de||e[42]!==pe||e[43]!==l||e[44]!==D||e[45]!==Y||e[46]!==i||e[47]!==k?(ee=Y?n.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:Bk,onMouseDown:Fk,onSubmit:Ae=>{Ae.preventDefault(),pe()},children:[n.jsx("input",{ref:re,value:me,onChange:Ae=>de(Ae.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:k("sessions.sidebar.folderItem.namePlaceholder"),onClick:Lk,onPointerDown:_k,onMouseDown:$k,onKeyDown:Ae=>{if(Ae.key==="Escape"){Ae.stopPropagation(),he();return}(Ae.key===" "||Ae.key==="Enter")&&Ae.stopPropagation()}}),n.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:Wk,onPointerDown:Kk,onMouseDown:zk,children:n.jsx(F,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),he()},onPointerDown:Vk,onMouseDown:Uk,className:"shrink-0 text-muted-foreground hover:text-foreground",children:n.jsx(F,{name:"close",className:"size-4"})})]}):n.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:De("typography-ui-label font-semibold truncate",D?"text-primary":"text-muted-foreground"),children:r??s.name})}),n.jsx(wt,{side:"right",sideOffset:8,className:"max-w-xs",children:r??s.name})]}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),O?n.jsx(fh,{state:O}):null,l?n.jsx(F,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):n.jsx(F,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=O,e[37]=r,e[38]=me,e[39]=s.name,e[40]=he,e[41]=de,e[42]=pe,e[43]=l,e[44]=D,e[45]=Y,e[46]=i,e[47]=k,e[48]=ee):ee=e[48];let ke;e[49]!==V||e[50]!==Z||e[51]!==ee?(ke=n.jsxs("div",{className:V,children:[Z,ee]}),e[49]=V,e[50]=Z,e[51]=ee,e[52]=ke):ke=e[52];let ne;e[53]!==L||e[54]!==M||e[55]!==s.name||e[56]!==Pe||e[57]!==E||e[58]!==f||e[59]!==N||e[60]!==Y||e[61]!==k?(ne=!Y&&(!E||M)?n.jsx("div",{className:De("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",L?"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:n.jsxs("div",{className:"flex items-center gap-0.5",children:[!M&&N?n.jsx("button",{type:"button",onClick:Ae=>{Ae.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":k("sessions.sidebar.folderItem.newSessionAria",{folderName:s.name}),title:k("sessions.sidebar.project.actions.newSession"),children:n.jsx(F,{name:"add",className:"h-3.5 w-3.5"})}):null,M?null:n.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),Pe()},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":k("sessions.sidebar.folderItem.renameAria",{folderName:s.name}),children:n.jsx(F,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),n.jsx("button",{type:"button",onClick:Ae=>{Ae.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":M?k("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:s.name}):k("sessions.sidebar.folderItem.deleteFolderAria",{folderName:s.name}),children:n.jsx(F,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=L,e[54]=M,e[55]=s.name,e[56]=Pe,e[57]=E,e[58]=f,e[59]=N,e[60]=Y,e[61]=k,e[62]=ne):ne=e[62];let q;e[63]!==S||e[64]!==Ne||e[65]!==Ie||e[66]!==Te||e[67]!==Le||e[68]!==_e||e[69]!==P||e[70]!==ke||e[71]!==ne?(q=n.jsxs("div",{ref:S,className:Ne,onClick:Ie,role:Te,tabIndex:Le,onKeyDown:_e,"aria-label":P,children:[ke,ne]}),e[63]=S,e[64]=Ne,e[65]=Ie,e[66]=Te,e[67]=Le,e[68]=_e,e[69]=P,e[70]=ke,e[71]=ne,e[72]=q):q=e[72];let ie;e[73]!==p||e[74]!==l||e[75]!==_||e[76]!==i||e[77]!==o||e[78]!==k?(ie=!l&&_?n.jsxs("div",{className:"pb-1",children:[o,i.length>0?p:o?null:n.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:k("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=p,e[74]=l,e[75]=_,e[76]=i,e[77]=o,e[78]=k,e[79]=ie):ie=e[79];let Ee;return e[80]!==q||e[81]!==ie?(Ee=n.jsxs("div",{className:"oc-folder",children:[q,ie]}),e[80]=q,e[81]=ie,e[82]=Ee):Ee=e[82],Ee},ep=c.memo(Ok);function Bk(t){return t.stopPropagation()}function Fk(t){return t.stopPropagation()}function Lk(t){return t.stopPropagation()}function _k(t){return t.stopPropagation()}function $k(t){return t.stopPropagation()}function Wk(t){return t.stopPropagation()}function Kk(t){return t.stopPropagation()}function zk(t){return t.stopPropagation()}function Vk(t){return t.stopPropagation()}function Uk(t){return t.stopPropagation()}function Hk(t){const e=Ye.c(11);let s,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:s,...i}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=i):(s=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let l;e[4]!==s||e[5]!==r||e[6]!==o?(l={nodes:s,includeUnreadSubtasks:r,enabled:o},e[4]=s,e[5]=r,e[6]=o,e[7]=l):l=e[7];const a=eu(l);let d;return e[8]!==a||e[9]!==i?(d=n.jsx(ep,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=d):d=e[10],d}const Tr=t=>{const e=Ye.c(13),{directory:s,className:r}=t,{t:i}=jt();let o;e[0]!==s?(o=wm(s),e[0]=s,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=v=>v.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Ot(a)?.tabs.some(Vd))return null;let f;e[4]!==i?(f=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=f):f=e[5];const p=f;let m;e[6]!==r?(m=De("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=m):m=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(F,{name:"pulse",className:"size-3.5"}),e[8]=b):b=e[8];let x;return e[9]!==l||e[10]!==p||e[11]!==m?(x=n.jsx("span",{className:m,role:"img","aria-label":p,title:p,"data-action-directory":l,children:b}),e[9]=l,e[10]=p,e[11]=m,e[12]=x):x=e[12],x},td=new Map([["blocked",0],["open",1],["draft",2],["merged",3],["closed",4]]),sd=t=>td.get(t.visualState)??td.size,Gk=t=>`${t.repo?.owner.toLowerCase()??""}/${t.repo?.repo.toLowerCase()??""}#${t.number}`,qk=(t,e)=>{const s=new Set,r=[];for(const i of t?[t,...e]:e){const o=Gk(i);s.has(o)||(s.add(o),r.push(i))}return r.sort((i,o)=>sd(i)-sd(o))},Yk=t=>{switch(t.visualState){case"merged":return"sessions.sidebar.group.pr.status.merged";case"open":return t.mergeableState!=="blocked"&&(t.canMerge===!0||t.mergeableState==="clean"||t.checks?.state==="success")?"sessions.sidebar.group.pr.status.readyToMerge":"sessions.sidebar.group.pr.status.open";case"blocked":return t.mergeableState==="dirty"?"sessions.sidebar.group.pr.status.mergeConflicts":t.checks?.state==="failure"?"sessions.sidebar.group.pr.status.checksFailing":"sessions.sidebar.group.pr.status.mergeBlocked";case"draft":return"sessions.sidebar.group.pr.status.draft";case"closed":return"sessions.sidebar.group.pr.status.closed";default:return null}},Qk={open:{color:"var(--pr-open)",statusKey:"sessions.sidebar.group.issue.status.open",priority:0},completed:{color:"var(--pr-merged)",statusKey:"sessions.sidebar.group.issue.status.completed",priority:2},not_planned:{color:"var(--pr-closed)",statusKey:"sessions.sidebar.group.issue.status.notPlanned",priority:3}},nd=1,tp=(t,e)=>{let s=0;return t.map(i=>{if(i.source!=="github")return{item:{key:i.key,label:i.identifier,icon:i.source==="linear"?"linear":"record-circle",color:null,statusKey:null,url:i.url,title:i.title},priority:nd};const o=e[s]??null;s+=1;const l=o?Qk[o.state]:null;return{item:{key:i.key,label:`#${i.number}`,icon:"record-circle",color:l?.color??null,statusKey:l?.statusKey??null,url:i.url,title:o?.title||i.title},priority:l?.priority??nd}}).sort((i,o)=>i.priority-o.priority).map(i=>i.item)};function sp(t,e){if(!t)return null;const s=Yk(t);return s?s==="sessions.sidebar.group.pr.status.mergeConflicts"&&t.checks?.state==="failure"?`${e(s)} · ${e("chat.chatInput.prCheckContext")}`:e(s):null}const Xk=t=>{const e=Ye.c(19),{sessionId:s,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:d}=t,u=i===void 0?null:i,f=a===void 0?!1:a,p=`session-drag:${r??s}`;let m;e[0]!==f||e[1]!==u||e[2]!==o||e[3]!==s||e[4]!==l?(m={type:"session",sessionId:s,ownerKey:u,sessionDirectory:o,sessionTitle:l,archivedBucket:f},e[0]=f,e[1]=u,e[2]=o,e[3]=s,e[4]=l,e[5]=m):m=e[5];let b;e[6]!==f||e[7]!==p||e[8]!==m?(b={id:p,disabled:f,data:m},e[6]=f,e[7]=p,e[8]=m,e[9]=b):b=e[9];const{attributes:x,listeners:v,setNodeRef:y,isDragging:g}=Ux(b);let h;e[10]!==v?(h=N=>{N.stopPropagation(),v?.onPointerDown&&v.onPointerDown(N)},e[10]=v,e[11]=h):h=e[11];const w=h,S=`touch-pan-y select-none${g?" opacity-30":""}`;let j;return e[12]!==x||e[13]!==d||e[14]!==w||e[15]!==v||e[16]!==y||e[17]!==S?(j=n.jsx("div",{ref:y,...x,...v,onPointerDown:w,className:S,children:d}),e[12]=x,e[13]=d,e[14]=w,e[15]=v,e[16]=y,e[17]=S,e[18]=j):j=e[18],j},np=t=>{const e=Ye.c(20),{folderId:s,scopeKey:r,ownerKey:i,disabled:o,children:l}=t,a=o===void 0?!1:o;let d;e[0]!==s||e[1]!==r?(d=$n(r,s),e[0]=s,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let f;e[3]!==a||e[4]!==r?(f=a||Ya(r),e[3]=a,e[4]=r,e[5]=f):f=e[5];let p;e[6]!==s||e[7]!==i||e[8]!==r?(p={type:"folder",folderId:s,scopeKey:r,ownerKey:i},e[6]=s,e[7]=i,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:b,isOver:x}=Hx(m);let v;e[14]!==l||e[15]!==x||e[16]!==b?(v=l(b,x),e[14]=l,e[15]=x,e[16]=b,e[17]=v):v=e[17];let y;return e[18]!==v?(y=n.jsx(n.Fragment,{children:v}),e[18]=v,e[19]=y):y=e[19],y},Jk=t=>{const e=Ye.c(22),{scopeKey:s,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=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=Ko(un(Vo,d),un(zo,u)),[p,m]=c.useState(null),[b,x]=c.useState("Session"),[v,y]=c.useState(null),[g,h]=c.useState(null);if(!s){let O;return e[2]!==l?(O=n.jsx(n.Fragment,{children:l}),e[2]=l,e[3]=O):O=e[3],O}let w;e[4]!==o||e[5]!==a?(w=O=>{m(null),y(null),h(null);const{active:_,over:W}=O;if(!W)return;const L=_.data.current,K=W.data.current;L?.type!=="session"||!L.sessionId||!L.ownerKey||L.archivedBucket===!0||a&&L.ownerKey!==a||K?.type!=="folder"||!K.folderId||!K.scopeKey||!K.ownerKey||Ya(K.scopeKey)||K.ownerKey!==L.ownerKey||o(L.sessionId,{folderId:K.folderId,scopeKey:K.scopeKey,ownerKey:K.ownerKey},L.ownerKey)},e[4]=o,e[5]=a,e[6]=w):w=e[6];const S=w;let j,N;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=O=>{const _=O.active.data.current;if(_?.type==="session"&&_.sessionId){m(_.sessionId),x(_.sessionTitle??"Session");const W=O.active.rect.current.initial?.width,L=O.active.rect.current.initial?.height;y(W??null),h(L??null)}},N=()=>{m(null),y(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]!==b||e[12]!==v||e[13]!==i?(C=p&&i?n.jsxs("div",{style:{width:v?`${v}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:[n.jsx(F,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),n.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:b})]}):null,e[9]=g,e[10]=p,e[11]=b,e[12]=v,e[13]=i,e[14]=C):C=e[14];let R;e[15]!==C?(R=n.jsx(Gx,{children:C}),e[15]=C,e[16]=R):R=e[16];let T;return e[17]!==l||e[18]!==S||e[19]!==f||e[20]!==R?(T=n.jsxs(Uo,{sensors:f,collisionDetection:Ho,onDragStart:j,onDragCancel:N,onDragEnd:S,children:[l,R]}),e[17]=l,e[18]=S,e[19]=f,e[20]=R,e[21]=T):T=e[21],T},rp=c.createContext(null),Zk=({entries:t,descendantIds:e,sessionsById:s,children:r})=>{const i=c.useRef(t),o=c.useRef(e),l=c.useRef(s);i.current=t,o.current=e,l.current=s;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>l.current}),n.jsx(rp.Provider,{value:a.current,children:r})},op=()=>c.useContext(rp),e2=(t,e,s)=>{const r=t[0];if(!r)return null;const i=s??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const f of u)l.has(f)||(l.add(f),o.push(f))}return o.length>0?{ids:o,scopeKey:i}:null},ip=(t,e)=>{if(t.size===0)return!1;for(const s of t)if(!e.get(s)?.time?.archived)return!1;return!0},t2=t=>{const e=Ye.c(29),{menuInstanceKey:s,contextMenuInstanceKey:r,openSidebarMenuKey:i,setOpenSidebarMenuKey:o,hasDeferredCloseWork:l,onCloseComplete:a}=t,[d,u]=c.useState(!1),[f,p]=c.useState(!1),m=i===s&&!f,b=r?i===r&&!f:d;let x;e[0]!==l||e[1]!==i||e[2]!==o?(x=T=>{if(i===T){if(l()){p(!0);return}o(null)}},e[0]=l,e[1]=i,e[2]=o,e[3]=x):x=e[3];const v=x;let y;e[4]!==s||e[5]!==v||e[6]!==o?(y=T=>{if(T){u(!1),p(!1),o(s);return}v(s)},e[4]=s,e[5]=v,e[6]=o,e[7]=y):y=e[7];const g=y;let h;e[8]!==r||e[9]!==v||e[10]!==o?(h=T=>{if(!r){u(T);return}if(T){p(!1),o(r);return}v(r)},e[8]=r,e[9]=v,e[10]=o,e[11]=h):h=e[11];const w=h;let S;e[12]!==r||e[13]!==s||e[14]!==a||e[15]!==i||e[16]!==o?(S=T=>{T||(a(),p(!1),(i===s||i===r)&&o(null))},e[12]=r,e[13]=s,e[14]=a,e[15]=i,e[16]=o,e[17]=S):S=e[17];const j=S;let N;e[18]!==m||e[19]!==s||e[20]!==o?(N=()=>{p(!1),o(m?null:s)},e[18]=m,e[19]=s,e[20]=o,e[21]=N):N=e[21];const C=N;let R;return e[22]!==w||e[23]!==g||e[24]!==j||e[25]!==b||e[26]!==m||e[27]!==C?(R={isMenuOpen:m,isContextMenuOpen:b,handleMenuOpenChange:g,handleContextMenuOpenChange:w,handleMenuOpenChangeComplete:j,toggleMenu:C},e[22]=w,e[23]=g,e[24]=j,e[25]=b,e[26]=m,e[27]=C,e[28]=R):R=e[28],R},s2=t=>{const e=Ye.c(10),{project:s,fallback:r}=t,{currentTheme:i}=mr(),o=s.iconImage??null;let l;e[0]!==s.id||e[1]!==o?(l={id:s.id,iconImage:o},e[0]=s.id,e[1]=o,e[2]=l):l=e[2];let a;e[3]!==i.colors.surface.foreground||e[4]!==i.metadata.variant?(a={themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},e[3]=i.colors.surface.foreground,e[4]=i.metadata.variant,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==l||e[8]!==a?(d=n.jsx($u,{project:l,options:a,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=l,e[8]=a,e[9]=d):d=e[9],d},n2=t=>{const e=Ye.c(13),{project:s}=t,r=s?.icon?Lu[s.icon]:null,i=s?.color?_u[s.color]??null:null;let o;e[0]!==i||e[1]!==r?(o=r?n.jsx(F,{name:r,className:De("h-3.5 w-3.5",!i&&"text-muted-foreground/75"),style:i?{color:i}:void 0}):n.jsx(F,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/75",style:i?{color:i}:void 0}),e[0]=i,e[1]=r,e[2]=o):o=e[2];const l=o;if(!s?.iconImage){let f;return e[3]!==l?(f=n.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:l}),e[3]=l,e[4]=f):f=e[4],f}let a;e[5]!==s.iconBackground?(a=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[5]=s.iconBackground,e[6]=a):a=e[6];let d;e[7]!==l||e[8]!==s?(d=n.jsx(s2,{project:s,fallback:l}),e[7]=l,e[8]=s,e[9]=d):d=e[9];let u;return e[10]!==a||e[11]!==d?(u=n.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:d}),e[10]=a,e[11]=d,e[12]=u):u=e[12],u},da=t=>{const e=Ye.c(48),{compact:s,project:r,projectLabel:i,title:o,titleClassName:l,branchLabel:a,thirdLineLead:d,statusDot:u,pinnedMarker:f,timeSlot:p,directoryIndicator:m,prBadge:b,zombieIndicator:x,goal:v,badges:y,doneHint:g,providerId:h,metaPaddingClass:w,hideMetaOnHoverClass:S}=t,j=s===void 0?!1:s,N=d===void 0?null:d,C=v===void 0?null:v,R=g===void 0?null:g,T=!j&&(!!a||!!N||!!b||!!x||!!C||!!y||!!h);let O;e[0]!==S||e[1]!==w?(O=De("ml-auto flex flex-shrink-0 items-center gap-1 transition-opacity",w,S),e[0]=S,e[1]=w,e[2]=O):O=e[2];const _=j?C:null,W=j?y:null;let L;e[3]!==p?(L=n.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:p}),e[3]=p,e[4]=L):L=e[4];let K;e[5]!==m||e[6]!==R||e[7]!==f||e[8]!==u||e[9]!==O||e[10]!==_||e[11]!==W||e[12]!==L?(K=n.jsxs("span",{className:O,children:[_,W,m,f,R,u,L]}),e[5]=m,e[6]=R,e[7]=f,e[8]=u,e[9]=O,e[10]=_,e[11]=W,e[12]=L,e[13]=K):K=e[13];const A=K;if(j){let ce;e[14]!==l?(ce=De("min-w-0 flex-1 truncate typography-ui-label font-normal",l),e[14]=l,e[15]=ce):ce=e[15];let re;e[16]!==ce||e[17]!==o?(re=n.jsx("div",{className:ce,children:o}),e[16]=ce,e[17]=o,e[18]=re):re=e[18];let Y;return e[19]!==A||e[20]!==re?(Y=n.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[re,A]}),e[19]=A,e[20]=re,e[21]=Y):Y=e[21],Y}let D;e[22]!==r?(D=n.jsx(n2,{project:r}),e[22]=r,e[23]=D):D=e[23];let E;e[24]!==i?(E=i?n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/85",children:i}):null,e[24]=i,e[25]=E):E=e[25];let M;e[26]!==A||e[27]!==D||e[28]!==E?(M=n.jsxs("div",{className:"relative flex h-5 w-full min-w-0 items-center gap-1",children:[D,E,A]}),e[26]=A,e[27]=D,e[28]=E,e[29]=M):M=e[29];let k;e[30]!==l?(k=De("w-full min-w-0 truncate typography-ui-label font-normal",l),e[30]=l,e[31]=k):k=e[31];let I;e[32]!==k||e[33]!==o?(I=n.jsx("div",{className:k,children:o}),e[32]=k,e[33]=o,e[34]=I):I=e[34];let U;e[35]!==y||e[36]!==a||e[37]!==C||e[38]!==T||e[39]!==b||e[40]!==h||e[41]!==N||e[42]!==x?(U=T?n.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[N??(a?n.jsxs(n.Fragment,{children:[n.jsx(F,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:a})]}):null),n.jsxs("span",{className:"ml-auto flex flex-shrink-0 items-center gap-1",children:[C,x??b,y,h?n.jsx(Fu,{providerId:h,className:"h-4 w-4 flex-shrink-0 opacity-45"}):null]})]}):null,e[35]=y,e[36]=a,e[37]=C,e[38]=T,e[39]=b,e[40]=h,e[41]=N,e[42]=x,e[43]=U):U=e[43];let z;return e[44]!==M||e[45]!==I||e[46]!==U?(z=n.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[M,I,U]}),e[44]=M,e[45]=I,e[46]=U,e[47]=z):z=e[47],z};let ua=!1;const fa=new Set;let rd=!1;function r2(){for(const t of fa)t()}function ap(t){ua!==t&&(ua=t,r2())}function ao(t){ap(t.shiftKey)}function o2(){ap(!1)}function i2(){if(rd||typeof window>"u")return;rd=!0;const t={capture:!0,passive:!0};window.addEventListener("keydown",ao,t),window.addEventListener("keyup",ao,t),window.addEventListener("pointermove",ao,t),window.addEventListener("pointerdown",ao,t),window.addEventListener("blur",o2)}function a2(t){return i2(),fa.add(t),()=>{fa.delete(t)}}function l2(){return ua}function c2(){return!1}function lp(){return ps.useSyncExternalStore(a2,l2,c2)}const cp=async(t,e,s)=>{const r=s.getRuntimeKey(),i=ut(t.path);if(!i)throw new Error("Unable to resolve worktree project");const o=await s.listProjectWorktrees(t,{force:!0});if(s.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const l=s.getCurrentProjects(),a=l.find(x=>x.id===t.id)??null;if(!a||ut(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const d=Qa({rawWorktreesByProjectRef:s.rawWorktreesByProjectRef,publishedWorktreesByProject:s.getPublishedWorktreesByProject(),runtimeKey:r}),u=o.map(x=>Oo(x));u.sort((x,v)=>dp({metadata:x},{metadata:v}));const f=xb(d.worktreesByProject,i,u,e?.projectDirectory);d2(s.rawWorktreesByProjectRef,r),s.rawWorktreesByProjectRef.current={runtimeKey:r,revision:s.rawWorktreesByProjectRef.current.revision,worktreesByProject:f};const p=s.getPublishedWorktreesByProject(),m=yb(s.partitionWorktreesByRegisteredProject(l,f),p),b=[...m.values()].flat();return s.recordWorktreesSeen(b.map(x=>x.path),s.now()),s.worktreeMapsEqual(m,p)||s.publishTopology({availableWorktrees:b,availableWorktreesByProject:m}),u},d2=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),u2=t=>new Map([...t.entries()].map(([e,s])=>[e,s.map(r=>Oo(r))])),Qa=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:u2(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),dp=(t,e)=>{const s=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=s.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},od=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Oo=t=>({...t,path:ut(t.path)??t.path,projectDirectory:ut(t.projectDirectory)??t.projectDirectory,worktreeRoot:ut(t.worktreeRoot??t.path)??t.worktreeRoot}),id=t=>{const{currentWorktree:e,path:s,projectDirectory:r,projectRootBranch:i}=t,l=ut(e?.path??null)===s,a=l?e?.branch??"":i??"",d={path:s,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||od(s):i||od(s),name:l?e?.name:void 0,worktreeRoot:l?ut(e?.worktreeRoot??s)??s:s,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:i?"branch":void 0};return l&&e?{...e,...d}:d},ad=t=>{const e=ut(t.projectPath??null),s=ut(t.sourceDirectory??null)??ut(t.currentWorktree?.path??null),r=ut(t.discoveredWorktrees.find(f=>ut(f.projectDirectory??null))?.projectDirectory??null),i=ut(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=f=>{const p=ut(f.metadata.path??null);!p||l.has(p)||l.set(p,{...f,metadata:Oo({...f.metadata,path:p})})};for(const f of t.discoveredWorktrees){const p=ut(f.path??null);p&&a({metadata:Oo({...f,path:p,projectDirectory:ut(f.projectDirectory??null)??o??e??p}),isPrimary:o===p,isCurrent:s===p})}o&&!l.has(o)&&a({metadata:id({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:s===o}),s&&!l.has(s)&&a({metadata:id({path:s,projectDirectory:o??e??s,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===s,isCurrent:!0});const d=[],u=[];for(const f of l.values()){if(f.isPrimary){d.push(f);continue}u.push(f)}return d.sort((f,p)=>f.metadata.path.localeCompare(p.metadata.path,void 0,{sensitivity:"base"})),u.sort(dp),[...d,...u]},up=(t,e)=>{const s=t.projectId?e.projects.find(o=>o.id===t.projectId)??null:null;if(s)return s;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const i=t.currentWorktree?.projectDirectory??null;return i?e.resolveProject(i):null},f2=(t,e)=>{const s=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=Qa({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:s}),o=up(t,e),l=ut(o?.path??null);return{cachedTargets:ad({projectPath:l,discoveredWorktrees:l?i.worktreesByProject.get(l)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!o||!l)throw new Error("Unable to resolve worktree project");const d=await cp(o,t.currentWorktree,e);return ad({projectPath:l,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},p2=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),s=[...e.values()].flat();return t.recordWorktreesSeen(s.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:s,availableWorktreesByProject:e}),!0},m2=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),h2=(t,e)=>ut(t.worktree?.path??null)===ut(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,g2=[],b2=[],Cr=6,lo=14,ld=Cr+14+6,Ai=new WeakMap,x2=t=>{const e=t.closest("[data-session-row]"),s=e?.closest(".overlay-scrollbar-container");if(!e||!s)return;Ai.get(s)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,l=null;const a=()=>{o=!0,l!==null&&window.cancelAnimationFrame(l),l=null,Ai.delete(s),s.removeEventListener("wheel",a),s.removeEventListener("touchstart",a)},d=()=>{if(o||!e.isConnected||!s.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(s.scrollTop+=u,vs("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(d)};s.addEventListener("wheel",a,{passive:!0}),s.addEventListener("touchstart",a,{passive:!0}),Ai.set(s,a),l=window.requestAnimationFrame(d)},y2=c.memo(function(e){const s=Ye.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:f}=e,p=lp(),m=p?i:r;let b;s[0]!==u||s[1]!==f||s[2]!==p?(b=N=>{if(p||N.shiftKey){f(N);return}u(N)},s[0]=u,s[1]=f,s[2]=p,s[3]=b):b=s[3];const x=b,v=p?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let y;s[4]!==o||s[5]!==v?(y=De("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",v,o),s[4]=o,s[5]=v,s[6]=y):y=s[6];const g=p?"delete-bin":"archive";let h;s[7]!==l||s[8]!==g?(h=n.jsx(F,{name:g,className:l}),s[7]=l,s[8]=g,s[9]=h):h=s[9];let w;s[10]!==x||s[11]!==m||s[12]!==d||s[13]!==a||s[14]!==y||s[15]!==h?(w=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",className:y,"aria-label":m,onPointerDown:a,onMouseDown:d,onClick:x,onKeyDown:P2,children:h})}),s[10]=x,s[11]=m,s[12]=d,s[13]=a,s[14]=y,s[15]=h,s[16]=w):w=s[16];let S;s[17]!==m?(S=n.jsx(wt,{side:"left",sideOffset:8,children:m}),s[17]=m,s[18]=S):S=s[18];let j;return s[19]!==w||s[20]!==S?(j=n.jsxs(vt,{children:[w,S]}),s[19]=w,s[20]=S,s[21]=j):j=s[21],j});function w2(t){vs("ui.sidebar_session_node.render");const{t:e}=jt(),{node:s,depth:r=0,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:m,notifyOnSubtasks:b,editingId:x,editingRowKey:v,setEditingId:y,setEditingRowKey:g,editTitle:h,setEditTitle:w,handleSaveEdit:S,handleCancelEdit:j,toggleParent:N,handleSessionSelect:C,handleSessionDoubleClick:R,handleCopySessionId:T,openSidebarMenuKey:O,setOpenSidebarMenuKey:_,createFolderAndStartRename:W,handleDeleteSession:L,handleRestoreSession:K,startSessionWorktreeMenuLoad:A,onEditProject:D,mobileVariant:E,alwaysShowActions:M,secondaryMeta:k,renderContext:I="project",rowKey:U,dragKey:z,children:ce}=t,re=Er(ae=>ae.toggle),Y=qt(ae=>ae.getFoldersForScope),me=qt(ae=>ae.getSessionFolderId),be=qt(ae=>ae.removeSessionFromFolder),Pe=qt(ae=>ae.addSessionToFolder),le=ve(ae=>ae.openContextPanelTab),pe=c.useMemo(()=>_s(),[]),je=c.useMemo(()=>Dr(),[]),he=c.useContext(wb),X=pe?"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",de=pe?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",fe=pe,H=!d&&!E,ge=ve(ae=>ae.sessionWorkEnabled),Me=ve(ae=>ae.sessionRecapEnabled),Ne=ge&&!d&&!s.session.parentID&&!Ma(s.session.directory),Ie=Ne&&!M,Te=(Ie?1:0)+(H?1:0)+(fe?1:0),Le=pe?["group-hover:pr-8","group-hover:pr-14","group-hover:pr-18","group-hover:pr-22"][Te]:["group-hover:pr-3 group-has-[:focus-visible]:pr-3","group-hover:pr-7 group-has-[:focus-visible]:pr-7","group-hover:pr-11 group-has-[:focus-visible]:pr-11"][Te],_e=H?"pr-13":"pr-7",P=pe?["pr-8","pr-14","pr-18","pr-22"][Te]:["pr-3","pr-7","pr-11"][Te],oe=c.useRef(!1),[V,Q]=c.useState(!1),ue=c.useRef(x);ue.current=x;const Z=c.useRef(null),ee=c.useRef(!1),ke=c.useRef(S);ke.current=S;const ne=h,q=c.useRef(ne);q.current=ne;const ie=c.useRef(null),Ee=c.useRef(!1),Ae=c.useRef(null),$e=c.useRef(null),Oe=s.session,qe=Oe,ct=Vt(c.useCallback(ae=>{if(k?.projectLabel||!o)return null;const It=ae.projects.find(Ht=>Ht.id===o);return It?It.label?.trim()||$o(ut(It.path)??It.path,null)||It.path:null},[o,k?.projectLabel])),Ve=I==="timeline"||I==="timeline-chat",nt=I==="timeline-chat",kt=Vt(c.useCallback(ae=>!Ve||!o?null:ae.projects.find(It=>It.id===o)??null,[Ve,o])),dt=k?.projectLabel??(ct?Wu(ct):null),yt=hk(k,s.worktree?.branch??null),_t=c.useMemo(()=>gk(s.worktree,pe),[pe,s.worktree]),Bt=Ku(_t),Lt=c.useMemo(()=>pe?g2:zu(Oe),[pe,Oe]),Rt=vb(Lt),Et=c.useMemo(()=>qk(Bt,Rt),[Bt,Rt]),Nt=Bt?`var(--pr-${Bt.visualState})`:void 0,ye=!!yt&&I==="recent",He=c.useMemo(()=>pe?b2:Oa(Oe),[pe,Oe]),mt=c.useMemo(()=>He.flatMap(ae=>ae.source==="github"?[{owner:ae.owner,repo:ae.repo,number:ae.number}]:[]),[He]),Ke=Vu(mt),B=c.useMemo(()=>Et.length>0?Et.map(ae=>{const It=sp(ae,e);return{key:`${ae.repo?.owner??""}/${ae.repo?.repo??""}#${ae.number}`,icon:"git-pull-request",label:`#${ae.number}`,color:`var(--pr-${ae.visualState})`,url:ae.url,title:ae.title,text:It?`#${ae.number} · ${It}`:`#${ae.number}`}}):tp(He,Ke).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.label})),[Ke,He,Et,e]),Se=B[0]??null,Fe=Math.max(0,B.length-1),$=B.map(ae=>ae.text).join(", "),se=Je(ae=>ae.currentSessionId===Oe.id),we=ut(Oe.directory??null)??ut(i??null),tt=a!==void 0?a:o??we??null,rt=hu(),Xe=Uu(),G=pe,Ce=ts(ae=>ae.enabled),bt=ts(c.useCallback(ae=>ae.selectedIds.has(Oe.id),[Oe.id])),xe=ts(ae=>ae.toggleSelected),xt=ts(ae=>ae.setRange),Mt=op(),pt=U??Oe.id,at=x===Oe.id&&v===pt,Be=c.useCallback(ae=>{const It=[],Ht=Zt=>{Zt.children.forEach(us=>{It.push(us.session.id),Ht(us)})};return Ht(ae),It},[]),Ue=c.useCallback(ae=>{const It=[],Ht=Zt=>{Zt.children.forEach(us=>{It.push(us.session),Ht(us)})};return Ht(ae),It},[]),[lt,et]=c.useState(!1),[ft,Ct]=c.useState(!0),it=`${I}:${d?"archived":"active"}:${Oe.id}`,Tt=U?`session-menu:${U}`:it,$t=U?`session-context:${U}`:null,ss=Hu(c.useCallback(ae=>!!ae.sessionMemoryState.get(Sb(Oe.id))?.isZombie,[Oe.id])),Re=iu(Oe.id),Ze=Re!==null,ot=jb(Oe.id,Ze),gt=xf(Oe.id),Dt=Sa(Oe.id,we),At=gt||Dt,Xt=s.worktree??Je.getState().getWorktreeMetadata(Oe.id)??null,[ns,Jt]=c.useState([]),[bn,rs]=c.useState(!1),[nn,Qs]=c.useState(!1),as=c.useRef(!1),Ws=c.useRef(0),xn=kb(Oe.id,we??void 0,{bootstrap:!1}),yn=Cb(qe),bs=Ne&&Gu(qe),Ks=bs&&!Ze&&Nb(qe),wn=e(bs?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),vn=async()=>{try{await Fb(Oe.id,we,bs?"done":"open")}catch{We.error(e("sessions.sidebar.session.work.updateFailed"))}},Ns=yn?n.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(Ll[yn.status]),"aria-label":e(Ll[yn.status]),children:n.jsx(F,{name:"target",className:"h-3 w-3",style:{color:Ab[yn.status]}})}):null,xs=qe.title||e("sessions.sidebar.session.untitled"),Xs=!Ve&&s.children.length>0,Js=Ou(u,we,Oe.id),zs=it,Sn=p?!0:f.has(zs),$r=c.useMemo(()=>fk(s,Sn,we),[Sn,s,we]),Zs=Pb($r),te=!!qe.parentID,st=au(Oe.id)>0&&(!te||b),Pt=qe.time?.updated||qe.time?.created||Date.now(),J=qu(Pt),ze=Yu(Pt),{isMenuOpen:Qe,isContextMenuOpen:Ft,handleMenuOpenChange:zt,handleContextMenuOpenChange:Kt,handleMenuOpenChangeComplete:Ut,toggleMenu:As}=t2({menuInstanceKey:Tt,contextMenuInstanceKey:$t,openSidebarMenuKey:O,setOpenSidebarMenuKey:_,hasDeferredCloseWork:()=>Z.current!==null,onCloseComplete:()=>{if(!Z.current)return;const{id:ae,title:It}=Z.current;Z.current=null,y(ae),g(pt),w(It)}}),Rs=Qe||Ft,On=c.useMemo(()=>Ib(qe)?.key??null,[qe]),Jo=c.useMemo(()=>Be(s).length,[Be,s]),Zo=c.useCallback(async ae=>{const It=[];let Ht=0;for(const Zt of ae)try{if(!we)throw new Error("Session directory is required for export");const us=await rt({directory:we,sessionID:Zt.session.id});if(!us)throw new Error("Session runtime changed during export");const Gt=Zt.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Ms=Zt.session.agent,Yt=await Zo(Zt.children);Ht+=Yt.skipped,It.push({title:Gt,agent:Ms,records:us,children:Yt.children})}catch{Ht+=Be(Zt).length+1}return{children:It,skipped:Ht}},[Be,rt,we,e]),ei=c.useCallback(ae=>{ae<=0||We.warning(ae===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:ae}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:ae}))},[e]),ti=c.useCallback(async ae=>{if(!we){We.error(e("sessions.sidebar.session.export.nothingToExport"));return}const It=await rt({directory:we,sessionID:Oe.id}).catch(()=>null);if(!It){We.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(It.length===0){We.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Ht,Zt=0;if(ae&&s.children.length>0){const Yt=await Zo(s.children);Ht=Yt.children,Zt=Yt.skipped}const us=gu(It,qe.title??null,Ht),Gt=bu(qe.title??null),Ms=await xu(us,Gt);if(Ms){We.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Eb()),onClick:()=>{Db(Ms).then(Yt=>{Yt||We.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),ei(Zt);return}yu(us,Gt),We.success(e("sessions.sidebar.session.export.success")),ei(Zt)},[Zo,rt,s.children,qe.title,Oe.id,we,ei,e]),Xa=wu(),Np=c.useMemo(()=>vu(Xa),[Xa]),Ap=c.useCallback(ae=>{gf({entry:ae,t:e,session:{id:Oe.id,title:qe.title,directory:we},loadRecords:()=>we?rt({directory:we,sessionID:Oe.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>We.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[rt,qe.title,Oe.id,we,e]),Pp=c.useCallback(async()=>{if(s.children.length>0){Ct(!0),et(!0);return}await ti(!1)},[ti,s.children.length]),Ip=c.useCallback(()=>{we&&Rn("desktop_open_session_mini_chat_window",{sessionId:Oe.id,directory:we,apiBaseUrl:fr(),clientToken:jo()}).catch(ae=>{console.warn("[session-sidebar] failed to open mini chat window",ae)})},[Oe.id,we]);if(c.useEffect(()=>{if(!at)return;const ae=It=>{const Zt=(It.target instanceof HTMLElement?It.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(pt)}"]`);$e.current&&!Zt&&ke.current(q.current)};return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[at,pt]),c.useLayoutEffect(()=>{if(!at){ie.current===pt&&(ie.current=null);return}ie.current!==pt&&(ie.current=pt,Ee.current=!0)},[h,at,pt]),c.useLayoutEffect(()=>{if(!at||!Ee.current)return;const ae=Ae.current;!ae||ae.value!==h||(Ee.current=!1,ae.focus(),ae.select())},[h,at,ne]),at){const ae=n.jsxs("form",{ref:$e,"data-session-rename-form":pt,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:It=>{It.preventDefault(),S(ne)},children:[n.jsx("input",{ref:Ae,value:ne,onChange:It=>w(It.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:It=>Ti(It,j)}),n.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:n.jsx(F,{name:"check",className:"size-3.5"})}),n.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:n.jsx(F,{name:"close",className:"size-3.5"})})]});return Ve?n.jsx("div",{style:{paddingLeft:Cr+4},className:De("group relative my-0.5 flex items-center rounded-md pr-2.5",nt?"py-1":"py-1.5",se&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:n.jsx(da,{compact:nt,project:kt,projectLabel:dt,title:ae,titleClassName:"text-foreground",branchLabel:yt,statusDot:null,pinnedMarker:null,timeSlot:ze,directoryIndicator:null,prBadge:Se?n.jsxs("span",{className:De("inline-flex flex-shrink-0 items-center gap-1 typography-micro",!Se.color&&"text-muted-foreground"),style:Se.color?{color:Se.color}:void 0,children:[n.jsx(F,{name:Se.icon,className:"h-3 w-3"}),n.jsx("span",{className:"leading-none tabular-nums",children:Se.label}),Fe>0?n.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",Fe]}):null]}):null,zombieIndicator:null,goal:Ns,badges:null,hideMetaOnHoverClass:""})},Oe.id):n.jsx("div",{style:{paddingLeft:ld+r*lo},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:n.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:ae})},Oe.id)}const hr=xn.length,Wr=Zs===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:Zs}),si=mk({actionsAlwaysVisible:M&&!pe,menuOpen:Rs,hideOnHoverClass:de}),Ja=!At&&!Ze&&st&&!se,Jn=Ze||Ja,Za=n.jsx(du,{state:Re??"unread"}),Kr=(Ze||Ja)&&ot,Dp=!M&&Xs&&(At||Jn||Js),el=Js&&!At&&!Jn,tl=n.jsx(F,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),sl=n.jsx(F,{name:"loader-4",className:"h-3 w-3 flex-shrink-0 animate-spin text-primary","aria-label":e(Dt?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}),Ep=At||Jn||el?n.jsx("span",{style:{left:Cr+r*lo},className:De("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",Dp?"opacity-100 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0":""),children:At?sl:Jn?Za:el?tl:null}):null,Rp=Xs&&!M&&(At||Jn||Js),Mp=Xs?n.jsx("span",{role:"button",tabIndex:0,onClick:ae=>{ae.stopPropagation(),ae.currentTarget.blur(),N(zs)},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.stopPropagation(),N(zs))},style:{minWidth:14,minHeight:14,left:Cr+r*lo},className:De("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",Rp?"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(Sn?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:Sn?n.jsx(F,{name:"arrow-down-s",className:"h-3 w-3"}):n.jsx(F,{name:"arrow-right-s",className:"h-3 w-3"})}):null,ni=ss?n.jsx(F,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Tp=ae=>{ae.preventDefault(),ae.stopPropagation(),As()},Op=ae=>{ae.preventDefault(),ae.stopPropagation()},Bp=ae=>{ae.preventDefault(),ae.stopPropagation()},ri=ae=>{ae.preventDefault(),ae.stopPropagation()},oi=ae=>{ae.preventDefault(),ae.stopPropagation()},Fp=ae=>{ae.preventDefault(),ae.stopPropagation(),_(null),L(Oe,{archivedBucket:d})},Lp=ae=>{ae.preventDefault(),ae.stopPropagation(),_(null),L(Oe,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},_p=ae=>{ae.preventDefault(),ae.stopPropagation()},$p=ae=>{ae.preventDefault(),ae.stopPropagation()},Wp=ae=>{ae.preventDefault(),ae.stopPropagation(),he?.vscode?.executeCommand("openchamber.openSessionInEditor",Oe.id,xs)},nl=ae=>{if(oe.current){oe.current=!1;return}if(Ce){if(ae?.preventDefault(),ae?.stopPropagation(),ae?.shiftKey){const It=Mt?.getEntries(),Ht=It??Array.from(document.querySelectorAll("[data-session-row]")).map(Gt=>Gt.getAttribute("data-session-row")).filter(Gt=>!!Gt).map(Gt=>({id:Gt,rowKey:Gt,scopeKey:tt,archived:d})),Zt=It?ts.getState().anchorRowKey:ts.getState().anchorId,us=new Map;us.set(Oe.id,Be(s)),xt(Zt,pt,Ht,Mt?.getDescendantIds()??[],tt,us);return}xe(Oe.id,tt,Be(s),pt);return}ae?.currentTarget&&x2(ae.currentTarget),C(Oe.id,we)},Kp=ae=>{ae.defaultPrevented||(ae.target instanceof HTMLElement?ae.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||nl(ae)},zp=ae=>{(ae.button===2||ae.button===0&&ae.ctrlKey&&!Ce)&&(oe.current=!0)},Vp=ae=>{E&&ae.pointerType==="touch"&&Q(!0),ae.button===0&&!se&&!Ce&&!G&&we&&!Ki(Oe.id,we).renderable&&Xe({directory:we,sessionID:Oe.id}).catch(()=>{})},rl=ae=>{E&&ae.pointerType==="touch"&&Q(!1)},Up=ae=>{as.current=ae,Ws.current+=1;const It=Ws.current;if(!ae){rs(!1),Qs(!1);return}const Ht=A({projectId:o??null,sourceDirectory:we,currentWorktree:Xt});Jt(Ht.cachedTargets),rs(!0),Qs(!1),Ht.refreshTargets.then(Zt=>{!as.current||Ws.current!==It||(Jt(Zt),rs(!1),Qs(!1))}).catch(()=>{!as.current||Ws.current!==It||(rs(!1),Qs(!0))})},ol=({Item:ae,Separator:It,Sub:Ht,SubTrigger:Zt,SubContent:us})=>n.jsxs(n.Fragment,{children:[n.jsxs(ae,{onClick:()=>{Z.current={id:Oe.id,title:xs}},className:"[&>svg]:mr-1",children:[n.jsx(F,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),n.jsx(Xi,{sessionID:Oe.id,directory:we,open:Rs,Item:ae}),n.jsxs(ae,{onClick:()=>T(Oe.id),className:"[&>svg]:mr-1",children:[n.jsx(F,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),n.jsxs(ae,{onClick:()=>we&&re({directory:we,sessionId:Oe.id}),className:"[&>svg]:mr-1",children:[Js?n.jsx(F,{name:"unpin",className:"mr-1 h-4 w-4"}):n.jsx(F,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(Js?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),Ne?n.jsxs(ae,{onClick:()=>{vn()},className:"[&>svg]:mr-1",children:[n.jsx(F,{name:bs?"check":"eye",className:"mr-1 h-4 w-4"}),e(bs?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]}):null,n.jsxs(ae,{onClick:()=>{Pp()},className:"[&>svg]:mr-1",children:[n.jsx(F,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),Np.map(Gt=>n.jsxs(ae,{onClick:()=>Ap(Gt),className:"[&>svg]:mr-1",children:[n.jsx(Br,{icon:Gt.icon,iconSrc:Gt.iconSrc,className:"mr-1 size-4"}),Gt.action.label]},`${Gt.guest.id}:${Gt.action.id}`)),Ve&&o&&D?n.jsxs(ae,{onClick:()=>D(o),className:"[&>svg]:mr-1",children:[n.jsx(F,{name:"pencil-ai",className:"h-4 w-4"}),e("sessions.sidebar.project.actions.edit")]}):null,dk({isSubtaskSession:te,archivedBucket:!!d,isVSCode:pe,sessionDirectory:we})?(()=>{const Gt=uk({sessionDirectory:we,isStreaming:Ze,isMovingToWorktree:gt}),Ms=m2({targets:ns,isRefreshing:bn,loadFailed:nn});return n.jsxs(Ht,{onOpenChange:Up,children:[n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(Zt,{disabled:Gt,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":Oe.id,children:[n.jsx(F,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),n.jsx(wt,{side:"right",className:"max-w-72",children:e(gt?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ze?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),n.jsxs(us,{className:"min-w-[220px]","data-session-worktree-submenu":Oe.id,children:[ns.map(Yt=>{const Ts=ut(Yt.metadata.path??null)??Yt.metadata.path,gr=Yt.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):Yt.metadata.label||Yt.metadata.branch||Yt.metadata.name||Yt.metadata.path,ls=Yt.isCurrent||Yt.metadata.worktreeStatus!=="ready";return n.jsxs(ae,{disabled:ls,title:Yt.metadata.path,"data-session-worktree-target":Ts,onClick:()=>{ls||!we||Zi({kind:"existing",root:qe,descendants:Ue(s),sourceDirectory:we,destination:Yt.metadata,messages:Ji(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[n.jsx("span",{className:"truncate",children:gr}),Yt.isCurrent?n.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),Yt.isCurrent?n.jsx(F,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},Ts)}),Ms.refreshState==="loading"?n.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,Ms.refreshState==="error"?n.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,n.jsx(It,{}),n.jsxs(ae,{disabled:Gt,"data-session-worktree-new-action":"true",onClick:()=>{Gt||!we||Zi({kind:"quick",root:qe,descendants:Ue(s),sourceDirectory:we,messages:Ji(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[n.jsx(F,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,On?n.jsxs(ae,{onClick:()=>ve.getState().setRunOverviewKey(On),className:"[&>svg]:mr-1",children:[n.jsx(zi,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]}):null,we&&!d&&!Ve?(()=>{const Gt=[],Ms=ls=>{const ms=ut(ls??null);ms&&!Gt.includes(ms)&&Gt.push(ms)};if(o&&!pe){const ls=Vt.getState().projects.find(Zn=>Zn.id===o),ms=ut(ls?.path??null);Ms(ms),ms&&(Je.getState().availableWorktreesByProject.get(ms)??[]).forEach(Zn=>Ms(Zn.path))}Ms(Ra(we)),Ms(we);const Yt=Gt.flatMap(ls=>Y(ls).map(ms=>({scope:ls,folder:ms}))),Ts=Yt.find(({scope:ls,folder:ms})=>me(ls,Oe.id)===ms.id)??null,gr=Gt[0]??we;return n.jsxs(n.Fragment,{children:[n.jsx(It,{}),n.jsxs(Ht,{children:[n.jsxs(Zt,{className:"[&>svg]:mr-1",children:[n.jsx(F,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),n.jsxs(us,{className:"min-w-[180px]",children:[Yt.length===0?n.jsx(ae,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):Yt.map(({scope:ls,folder:ms})=>{const Zn=Ts?.folder.id===ms.id;return n.jsxs(ae,{onClick:()=>{if(Zn){be(ls,Oe.id);return}Ts&&Ts.scope!==ls&&be(Ts.scope,Oe.id),Pe(ls,ms.id,Oe.id)},children:[n.jsx("span",{className:"flex-1 truncate",children:ms.name}),Zn?n.jsx(F,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ms.id)}),n.jsx(It,{}),n.jsxs(ae,{onClick:()=>{const ls=W(gr);ls&&(ee.current=!0,Ts&&Ts.scope!==gr&&be(Ts.scope,Oe.id),Pe(gr,ls.id,Oe.id))},children:[n.jsx(F,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Ts?n.jsxs(ae,{onClick:()=>{be(Ts.scope,Oe.id)},className:"text-destructive focus:text-destructive",children:[n.jsx(F,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,pe?null:n.jsxs(ae,{disabled:!we,onClick:()=>{we&&le(we,{mode:"chat",dedupeKey:`session:${Oe.id}`,label:xs,sessionTitleFallback:xs})},className:"[&>svg]:mr-1",children:[n.jsx(F,{name:"chat-4",className:"mr-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),n.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")})]}),je?n.jsxs(ae,{disabled:!we,onClick:Ip,className:"[&>svg]:mr-1",children:[n.jsx(F,{name:"window",className:"mr-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,n.jsx(It,{}),d?null:n.jsxs(ae,{className:"[&>svg]:mr-1",onClick:()=>L(Oe,{archivedBucket:d}),children:[n.jsx(F,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),d?n.jsxs(ae,{className:"[&>svg]:mr-1",onClick:()=>K(Oe),children:[n.jsx(F,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,n.jsxs(ae,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>L(Oe,{archivedBucket:d,hardDelete:!0}),children:[n.jsx(F,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),Hp=ae=>{ae.preventDefault(),ae.stopPropagation(),vn()},ii=M?"h-6 w-6":Ve&&!nt?"h-5 w-5":"h-4 w-4",zr=M?"h-3.5 w-3.5":Ve&&!nt?"h-3 w-3":"h-2.5 w-2.5",Gp=M?"h-4 w-4":Ve&&!nt?"h-3.5 w-3.5":"h-3 w-3",il=Me&&!Ze&&Rb(qe)?.recap||null,al=e("sessions.sidebar.session.work.doneSuggested"),ai=ae=>Ks?n.jsx("span",{className:De("inline-flex flex-shrink-0 items-center text-muted-foreground/75",ae),title:al,"aria-label":al,children:n.jsx(F,{name:"check",className:"h-3.5 w-3.5"})}):null,ll=!Ve&&Ks,qp=hr>0||Zs>0||ll?n.jsxs(n.Fragment,{children:[ll?ai():null,hr>0?n.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:[n.jsx(F,{name:"shield",className:"h-3 w-3"}),n.jsx("span",{className:"leading-none",children:hr})]}):null,Zs>0?n.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:Wr,"aria-label":Wr,children:[n.jsx(F,{name:"question",className:"h-3 w-3"}),n.jsx("span",{className:"leading-none",children:Zs})]}):null]}):null,Yp=Ve&&Se?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",className:De("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",!Se.color&&"text-muted-foreground"),style:Se.color?{color:Se.color}:void 0,disabled:!Se.url,"aria-label":$,onPointerDown:ri,onMouseDown:oi,onClick:ae=>{ae.preventDefault(),ae.stopPropagation(),Se.url&&Mn(Se.url)},onKeyDown:ae=>ae.stopPropagation(),children:[n.jsx(F,{name:Se.icon,className:"h-3 w-3"}),n.jsx("span",{className:"leading-none tabular-nums",children:Se.label}),Fe>0?n.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",Fe]}):null]})}),n.jsx(wt,{side:"top",sideOffset:6,children:n.jsx("div",{className:"flex max-w-xs flex-col gap-1",children:B.map(ae=>n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{children:ae.text}),ae.title?n.jsx("p",{className:"truncate text-muted-foreground",children:ae.title}):null]},ae.key))})})]}):null,Qp=Ve?n.jsx(da,{compact:nt,project:kt,projectLabel:dt,title:Pr(xs,m),titleClassName:se||bt?"text-interactive-selection-foreground":st?"text-foreground":"text-foreground/80",branchLabel:yt,statusDot:At?sl:Jn?Za:null,pinnedMarker:Js&&!At?tl:null,timeSlot:Kr?n.jsx(ci,{sessionId:Oe.id,running:Ze,className:"typography-micro"}):ze,directoryIndicator:!d&&we?n.jsx(Tr,{directory:we}):null,prBadge:Yp,zombieIndicator:ni,goal:Ns,badges:qp,doneHint:ai(),providerId:qe.model?.providerID??null,metaPaddingClass:M?H?"pr-13":"pr-7":void 0,hideMetaOnHoverClass:M&&!pe?"":De(de,Rs&&"opacity-0")}):null,Xp=n.jsx(ks,{align:"end",className:"min-w-[180px]",finalFocus:()=>ee.current?(ee.current=!1,!1):!ue.current,children:ol({Item:Wt,Separator:ws,Sub:Tb,SubTrigger:Ob,SubContent:Bb})}),Jp=n.jsx(Hi,{children:n.jsx(Gi,{className:"app-region-no-drag z-50",children:n.jsx(qi,{"data-slot":"dropdown-menu-content",finalFocus:()=>ee.current?(ee.current=!1,!1):!ue.current,style:{color:"var(--surface-elevated-foreground)"},className:De(Bi,"min-w-[180px]"),children:ol({Item:({className:ae,...It})=>n.jsx(af,{className:De(cu,ae),...It}),Separator:({className:ae,...It})=>n.jsx(of,{className:De(lu,ae),...It}),Sub:Xx,SubTrigger:({className:ae,children:It,...Ht})=>n.jsxs(Jx,{className:De(Mb,ae),...Ht,children:[It,n.jsx(F,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:ae,children:It,...Ht})=>n.jsx(Hi,{children:n.jsx(Gi,{className:"app-region-no-drag z-50",children:n.jsx(qi,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:De(Bi,ae),...Ht,children:It})})})})})})});return n.jsxs(c.Fragment,{children:[n.jsx(Xk,{sessionId:Oe.id,dragKey:z??pt,ownerKey:l??tt,sessionDirectory:we??null,sessionTitle:xs,archivedBucket:d,children:n.jsxs(cf,{open:Ft,onOpenChange:Kt,onOpenChangeComplete:Ut,children:[n.jsxs(lf,{render:n.jsx("div",{"data-session-row":Oe.id,"data-session-scope":tt??"","data-session-archived":d?"1":"0","aria-current":se?"page":void 0,onClick:Kp,style:{paddingLeft:Ve?Cr+4:ld+r*lo},className:De("group relative my-0.5 flex cursor-pointer items-center rounded-md pr-2.5",Ve&&!nt?"py-1.5":"py-1",Ve&&!(se||bt)&&"hover:bg-interactive-hover/60",(se||bt)&&"bg-interactive-selection/70 text-interactive-selection-foreground",bt&&"ring-1 ring-inset ring-border")}),children:[Ve?null:Ep,Ve?null:Mp,n.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-pressed":Ce?bt:void 0,onPointerDown:Vp,onPointerUp:rl,onPointerCancel:rl,onMouseDown:zp,onClick:ae=>nl(ae),onDoubleClick:ae=>{ae.stopPropagation(),R(Oe.id,xs)},className:De("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 transition-[padding]",V&&"bg-interactive-hover/70",Ve?void 0:M?pe?Le:_e:Rs?P:Le),children:Ve?Qp:n.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[n.jsx("div",{className:De("block min-w-0 flex-1 truncate typography-ui-label font-normal",se||bt?"text-interactive-selection-foreground":st?"text-foreground":"text-foreground/80"),children:Pr(xs,m)}),!d&&we&&I==="recent"?n.jsx(Tr,{directory:we,className:M?void 0:Rs?"mr-1":pe?"group-hover:mr-1":"group-hover:mr-1 group-has-[:focus-visible]:mr-1"}):null,ai(De(si,M?"ml-2":"ml-1")),M?n.jsx("span",{className:De("inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",!Ks&&"ml-2"),children:Kr?n.jsx(ci,{sessionId:Oe.id,running:Ze}):n.jsxs(n.Fragment,{children:[Ns,ye?n.jsx(F,{name:"git-branch",className:De("h-3 w-3",!Nt&&"text-muted-foreground/60"),style:Nt?{color:Nt}:void 0}):null,ze]})}):Kr||Ns||ye||I==="recent"?n.jsx("div",{className:De("relative flex h-4 flex-shrink-0 items-center justify-end",!Ks&&"ml-1",Rs?"hidden":pe?"group-hover:hidden":"group-hover:hidden group-has-[:focus-visible]:hidden"),children:n.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:Kr?n.jsx(ci,{sessionId:Oe.id,running:Ze,className:"typography-micro"}):n.jsxs(n.Fragment,{children:[Ns,ye?n.jsx(F,{name:"git-branch",className:De("h-3 w-3",!Nt&&"text-muted-foreground/60"),style:Nt?{color:Nt}:void 0}):null,I==="recent"?n.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:ze}):null]})})}):null,hr>0?n.jsxs("span",{className:De("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",si),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[n.jsx(F,{name:"shield",className:"h-3 w-3"}),n.jsx("span",{className:"leading-none",children:hr})]}):null,Zs>0?n.jsxs("span",{className:De("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",si),title:Wr,"aria-label":Wr,children:[n.jsx(F,{name:"question",className:"h-3 w-3"}),n.jsx("span",{className:"leading-none",children:Zs})]}):null]})})}),!pe&&!Ve?n.jsx(wt,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:n.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:xs}),n.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:J,children:ze})]}),dt&&!Ve?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[n.jsx(F,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:dt})]}):null,yt?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[n.jsx(F,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:Nt?{color:Nt}:void 0}),n.jsx("span",{className:"min-w-0 truncate",children:yt})]}):null,B.map(ae=>n.jsxs("button",{type:"button",className:De("group/pr flex min-w-0 flex-col rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",!ae.color&&"text-muted-foreground"),style:ae.color?{color:ae.color}:void 0,disabled:!ae.url,onPointerDown:It=>It.stopPropagation(),onClick:It=>{It.stopPropagation(),ae.url&&Mn(ae.url)},children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 group-hover/pr:underline group-disabled/pr:no-underline",children:[n.jsx(F,{name:ae.icon,className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:ae.text})]}),ae.title?n.jsx("span",{className:"min-w-0 truncate pl-[18px] text-muted-foreground",children:ae.title}):null]},ae.key)),il?n.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:il}):null]})}):null]})}),ni&&!E&&!Ve?n.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 z-10",children:ni}):null,n.jsxs("div",{className:De("absolute right-1 z-10 flex items-center gap-0.5 transition-opacity",Ve&&!nt?"top-1.5 h-5":"top-1/2 -translate-y-1/2",Rs||M&&!pe?"opacity-100":De("opacity-0",X)),children:[Ie?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",className:De("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",ii,bs?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":wn,onPointerDown:ri,onMouseDown:oi,onClick:Hp,onKeyDown:ae=>ae.stopPropagation(),children:n.jsx(F,{name:bs?"check":"eye",className:bs?Gp:zr})})}),n.jsx(wt,{side:"left",sideOffset:8,children:wn})]}):null,H?n.jsx(y2,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:ii,iconSizeClass:zr,onPointerDown:ri,onMouseDown:oi,onArchive:Fp,onDelete:Lp}):null,fe?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",className:De("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",ii),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:_p,onMouseDown:$p,onClick:Wp,onKeyDown:ae=>ae.stopPropagation(),children:n.jsx(F,{name:"external-link",className:zr})})}),n.jsx(wt,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,n.jsxs(Cs,{open:Qe,onOpenChange:zt,onOpenChangeComplete:Ut,children:[n.jsx(js,{asChild:!0,children:n.jsx("button",{type:"button",className:De("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",M?"h-6 w-6 opacity-100":Rs?"h-4 w-4 opacity-100":De("h-4 w-4 opacity-0",X)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Op,onMouseDown:Bp,onClick:Tp,onKeyDown:ae=>ae.stopPropagation(),children:n.jsx(F,{name:"more-2",className:zr})})}),Xp]})]})]}),Jp]})}),Xs&&Sn?ce:null,n.jsx(Ds,{open:lt,onOpenChange:et,children:n.jsxs(Es,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(Gs,{children:[n.jsx(qs,{children:e("sessions.sidebar.session.export.dialog.title")}),n.jsx(Ys,{children:Jo===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:Jo}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:Jo})})]}),n.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:ft,onChange:ae=>Ct(ae.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),n.jsxs(qn,{children:[n.jsx(ht,{type:"button",onClick:()=>et(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),n.jsx(ht,{type:"button",onClick:()=>{et(!1),ti(ft)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},Oe.id)}const cd=t=>ut(t.session.directory??null),v2=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),S2=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",s=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(s)?t.openSidebarMenuKey.slice(s.length):null},dd=t=>t.menuOpenSessionId??S2(t),co=(t,e,s)=>e?s.has(t.node.session.id)?!0:pr(t.node,e):!1,pa=(t,e,s,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(s.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let l=0;l<t.children.length;l+=1)if(pa(t.children[l],e.children[l],s,r,i))return!0;return!1},j2=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const s=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return pa(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${s}:${i.session.id}`)||pa(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},k2=(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&&Qu(t,e),C2=(t,e)=>{if(t.node.session.id!==e.node.session.id||!k2(t.node.session,e.node.session)||!h2(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(cd(t.node)!==cd(e.node))return"nodeDirectory";if(!v2(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&Jf(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&j2(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(co(t,t.editingId,t.subtreeContainsEditing)||co(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editingRowKey!==e.editingRowKey&&(t.editingRowKey===t.rowKey||e.editingRowKey===e.rowKey))return"editingRowKey";if(t.editTitle!==e.editTitle&&(co(t,t.editingId,t.subtreeContainsEditing)||co(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=dd(t),i=dd(e);if(pr(t.node,r)||pr(e.node,i))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"},N2=(t,e)=>{const s=C2(t,e);return s===null?!0:(vs(`ui.sidebar_session_node.props_changed.${s}`),!1)},A2=c.memo(w2,N2);function P2(t){return t.stopPropagation()}const I2=t=>{const{t:e}=jt(),s=c.useRef(null),r=c.useRef(t.editingId),i=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);r.current=t.editingId,i.current=t.editTitle,o.current=t.deleteSessionConfirm;const l=ve(k=>k.setSessionSwitcherOpen),a=Je(k=>k.setCurrentSession),d=Je(k=>k.updateSessionTitle),u=Je(k=>k.deleteSession),f=Je(k=>k.deleteSessions),p=Je(k=>k.archiveSession),m=Je(k=>k.archiveSessions),b=Je(k=>k.unarchiveSession),{mobileVariant:x,allowReselect:v,onSessionSelected:y,resetSessionSearch:g,descendantIds:h,showDeletionDialog:w,setDeleteSessionConfirm:S,setEditingId:j,setEditingRowKey:N,editingSessionId:C,editingOccurrenceKey:R,setEditTitle:T}=t;c.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const O=c.useCallback((k,I)=>{if(Ri("navigation.session_select"),ve.getState().closeMainSurfaces(),x&&l(!1),k===Je.getState().currentSessionId){v&&y?.(k),g();return}Ri("navigation.session_state_set"),a(k,I??null),y?.(k),g()},[v,x,y,g,a,l]),_=c.useCallback((k,I)=>{j(k),N(R),T(I)},[R,T,j,N]),W=c.useCallback(async k=>{if(!r.current)return;const U=(k??i.current).trim();if(U)try{await d(C,U)}catch(z){console.error("[session-actions] rename failed",z),We.error(e("sessions.sidebar.session.rename.error",{detail:tu(z instanceof Error?z:new Error(String(z)),e)}))}j(null),N(null),T("")},[C,T,j,N,e,d]),L=c.useCallback(()=>{j(null),N(null),T("")},[T,j,N]),K=c.useCallback(k=>{Hn(k).then(I=>{if(I.ok){We.success(e("sessions.sidebar.session.copyId.success"));return}We.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>We.error(e("sessions.sidebar.session.copyId.error")))},[e]),A=c.useCallback(async(k,I,U)=>{const z=I?.archivedBucket===!0||I?.hardDelete===!0,ce=U?.descendantIds??h;await ph(z?"delete":"archive",k,ce,{archiveSession:p,archiveSessions:m,deleteSession:u,deleteSessions:f},e)},[p,m,u,f,h,e]),D=c.useCallback((k,I)=>{const U=I?.archivedBucket===!0||I?.hardDelete===!0,z=Gd(k.id,h,U);if(!w||I?.skipConfirm===!0){A(k,I,{descendantIds:z});return}S({session:k,descendantCount:z.length,descendantIds:z,archivedBucket:U})},[h,A,S,w]),E=c.useCallback(async()=>{const k=o.current;if(!k)return;const{session:I,archivedBucket:U,descendantIds:z}=k;S(null),await A(I,{archivedBucket:U},{descendantIds:z})},[A,S]),M=c.useCallback(async k=>{await b(k.id)?We.success(e("sessions.sidebar.session.restore.success")):We.error(e("sessions.sidebar.session.restore.error"))},[e,b]);return c.useMemo(()=>({handleSessionSelect:O,handleSessionDoubleClick:_,handleSaveEdit:W,handleCancelEdit:L,handleCopySessionId:K,handleDeleteSession:D,handleRestoreSession:M,confirmDeleteSession:E}),[L,K,D,M,W,_,O,E])};function D2(t){const e=Ye.c(71),{t:s}=jt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let d,u,f,p,m,b,x,v,y,g;if(e[0]!==i||e[1]!==s||e[2]!==r){const k=s("sessions.sidebar.session.untitled");p=Ds,y=!!r,e[13]!==i?(g=U=>{U||i(null)},e[13]=i,e[14]=g):g=e[14],f=Es,x=!1,v="max-w-sm gap-5",u=Gs;let I;e[15]!==s||e[16]!==r?.archivedBucket?(I=r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.title"):s("sessions.sidebar.dialogs.archiveSession.title"),e[15]=s,e[16]=r?.archivedBucket,e[17]=I):I=e[17],e[18]!==I?(b=n.jsx(qs,{children:I}),e[18]=I,e[19]=b):b=e[19],d=Ys,m=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?s("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||k,count:r.descendantCount}):s("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||k,count:r.descendantCount}):r.descendantCount===1?s("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||k,count:r.descendantCount}):s("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||k,count:r.descendantCount}):r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||k}):s("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||k}),e[0]=i,e[1]=s,e[2]=r,e[3]=d,e[4]=u,e[5]=f,e[6]=p,e[7]=m,e[8]=b,e[9]=x,e[10]=v,e[11]=y,e[12]=g}else d=e[3],u=e[4],f=e[5],p=e[6],m=e[7],b=e[8],x=e[9],v=e[10],y=e[11],g=e[12];let h;e[20]!==d||e[21]!==m?(h=n.jsx(d,{children:m}),e[20]=d,e[21]=m,e[22]=h):h=e[22];let w;e[23]!==u||e[24]!==b||e[25]!==h?(w=n.jsxs(u,{children:[b,h]}),e[23]=u,e[24]=b,e[25]=h,e[26]=w):w=e[26];let S;e[27]!==l||e[28]!==o?(S=()=>l(!o),e[27]=l,e[28]=o,e[29]=S):S=e[29];const j=!o;let N;e[30]!==o?(N=o?n.jsx(F,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(F,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=N):N=e[31];let C;e[32]!==s?(C=s("sessions.sidebar.dialogs.neverAsk"),e[32]=s,e[33]=C):C=e[33];let R;e[34]!==N||e[35]!==C||e[36]!==S||e[37]!==j?(R=n.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]=R):R=e[38];let T;e[39]!==i?(T=()=>i(null),e[39]=i,e[40]=T):T=e[40];let O;e[41]!==s?(O=s("sessions.sidebar.dialogs.cancel"),e[41]=s,e[42]=O):O=e[42];let _;e[43]!==T||e[44]!==O?(_=n.jsx("button",{type:"button",onClick:T,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:O}),e[43]=T,e[44]=O,e[45]=_):_=e[45];let W;e[46]!==a?(W=()=>{a()},e[46]=a,e[47]=W):W=e[47];let L;e[48]!==s||e[49]!==r?.archivedBucket?(L=r?.archivedBucket?s("sessions.sidebar.bulkActions.delete"):s("sessions.sidebar.bulkActions.archive"),e[48]=s,e[49]=r?.archivedBucket,e[50]=L):L=e[50];let K;e[51]!==W||e[52]!==L?(K=n.jsx("button",{type:"button",onClick:W,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:L}),e[51]=W,e[52]=L,e[53]=K):K=e[53];let A;e[54]!==_||e[55]!==K?(A=n.jsxs("div",{className:"flex items-center gap-2",children:[_,K]}),e[54]=_,e[55]=K,e[56]=A):A=e[56];let D;e[57]!==R||e[58]!==A?(D=n.jsxs(qn,{className:"w-full sm:items-center sm:justify-between",children:[R,A]}),e[57]=R,e[58]=A,e[59]=D):D=e[59];let E;e[60]!==f||e[61]!==x||e[62]!==D||e[63]!==v||e[64]!==w?(E=n.jsxs(f,{showCloseButton:x,className:v,children:[w,D]}),e[60]=f,e[61]=x,e[62]=D,e[63]=v,e[64]=w,e[65]=E):E=e[65];let M;return e[66]!==p||e[67]!==E||e[68]!==y||e[69]!==g?(M=n.jsx(p,{open:y,onOpenChange:g,children:E}),e[66]=p,e[67]=E,e[68]=y,e[69]=g,e[70]=M):M=e[70],M}function E2(t){const e=Ye.c(57),{t:s}=jt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let f;e[0]!==d||e[1]!==u||e[2]!==s?(f=s(d?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]=d,e[1]=u,e[2]=s,e[3]=f):f=e[3];const p=f;let m;e[4]!==d||e[5]!==u||e[6]!==s?(m=d?u===1?s("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):s("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?s("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):s("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=s,e[7]=m):m=e[7];const b=m,x=!!r;let v;e[8]!==i?(v=M=>{M||i(null)},e[8]=i,e[9]=v):v=e[9];let y;e[10]!==p?(y=n.jsx(qs,{children:p}),e[10]=p,e[11]=y):y=e[11];let g;e[12]!==b?(g=n.jsx(Ys,{children:b}),e[12]=b,e[13]=g):g=e[13];let h;e[14]!==y||e[15]!==g?(h=n.jsxs(Gs,{children:[y,g]}),e[14]=y,e[15]=g,e[16]=h):h=e[16];let w;e[17]!==l||e[18]!==o?(w=()=>l(!o),e[17]=l,e[18]=o,e[19]=w):w=e[19];const S=!o;let j;e[20]!==o?(j=o?n.jsx(F,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(F,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=j):j=e[21];let N;e[22]!==s?(N=s("sessions.sidebar.dialogs.neverAsk"),e[22]=s,e[23]=N):N=e[23];let C;e[24]!==N||e[25]!==w||e[26]!==S||e[27]!==j?(C=n.jsxs("button",{type:"button",onClick:w,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]=w,e[26]=S,e[27]=j,e[28]=C):C=e[28];let R;e[29]!==i?(R=()=>i(null),e[29]=i,e[30]=R):R=e[30];let T;e[31]!==s?(T=s("sessions.sidebar.dialogs.cancel"),e[31]=s,e[32]=T):T=e[32];let O;e[33]!==R||e[34]!==T?(O=n.jsx("button",{type:"button",onClick:R,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:T}),e[33]=R,e[34]=T,e[35]=O):O=e[35];let _;e[36]!==a?(_=()=>{a()},e[36]=a,e[37]=_):_=e[37];let W;e[38]!==d||e[39]!==s?(W=s(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=s,e[40]=W):W=e[40];let L;e[41]!==_||e[42]!==W?(L=n.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:W}),e[41]=_,e[42]=W,e[43]=L):L=e[43];let K;e[44]!==O||e[45]!==L?(K=n.jsxs("div",{className:"flex items-center gap-2",children:[O,L]}),e[44]=O,e[45]=L,e[46]=K):K=e[46];let A;e[47]!==C||e[48]!==K?(A=n.jsxs(qn,{className:"w-full sm:items-center sm:justify-between",children:[C,K]}),e[47]=C,e[48]=K,e[49]=A):A=e[49];let D;e[50]!==A||e[51]!==h?(D=n.jsxs(Es,{showCloseButton:!1,className:"max-w-sm gap-5",children:[h,A]}),e[50]=A,e[51]=h,e[52]=D):D=e[52];let E;return e[53]!==x||e[54]!==D||e[55]!==v?(E=n.jsx(Ds,{open:x,onOpenChange:v,children:D}),e[53]=x,e[54]=D,e[55]=v,e[56]=E):E=e[56],E}function fp(t){const e=Ye.c(36),{t:s}=jt(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=j=>{j||i(null)},e[0]=i,e[1]=a):a=e[1];let d;e[2]!==s?(d=s("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==d?(u=n.jsx(qs,{children:d}),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==s||e[7]!==r?(f=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?s("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):s("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):s("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):s("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=s,e[7]=r,e[8]=f):f=e[8];let p;e[9]!==f?(p=n.jsx(Ys,{children:f}),e[9]=f,e[10]=p):p=e[10];let m;e[11]!==u||e[12]!==p?(m=n.jsxs(Gs,{children:[u,p]}),e[11]=u,e[12]=p,e[13]=m):m=e[13];let b;e[14]!==i?(b=()=>i(null),e[14]=i,e[15]=b):b=e[15];let x;e[16]!==s?(x=s("sessions.sidebar.dialogs.cancel"),e[16]=s,e[17]=x):x=e[17];let v;e[18]!==b||e[19]!==x?(v=n.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:x}),e[18]=b,e[19]=x,e[20]=v):v=e[20];let y;e[21]!==s?(y=s("sessions.sidebar.bulkActions.delete"),e[21]=s,e[22]=y):y=e[22];let g;e[23]!==o||e[24]!==y?(g=n.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:y}),e[23]=o,e[24]=y,e[25]=g):g=e[25];let h;e[26]!==g||e[27]!==v?(h=n.jsxs(qn,{children:[v,g]}),e[26]=g,e[27]=v,e[28]=h):h=e[28];let w;e[29]!==h||e[30]!==m?(w=n.jsxs(Es,{showCloseButton:!1,className:"max-w-sm gap-5",children:[m,h]}),e[29]=h,e[30]=m,e[31]=w):w=e[31];let S;return e[32]!==l||e[33]!==a||e[34]!==w?(S=n.jsx(Ds,{open:l,onOpenChange:a,children:w}),e[32]=l,e[33]=a,e[34]=w,e[35]=S):S=e[35],S}const R2=new Set;function M2(t){const e=Ye.c(113),{node:s,depth:r,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d,secondaryMeta:u,renderContext:f,rowKey:p,dragKey:m,renderExtras:b,pinnedSessionIds:x,expandedParents:v,hasSessionSearchQuery:y,normalizedSessionSearchQuery:g,notifyOnSubtasks:h,editingId:w,editingRowKey:S,setEditingId:j,setEditingRowKey:N,editTitle:C,setEditTitle:R,toggleParent:T,openSidebarMenuKey:O,setOpenSidebarMenuKey:_,allowReselect:W,onSessionSelected:L,resetSessionSearch:K,deleteSessionConfirm:A,setDeleteSessionConfirm:D,startFolderRename:E,startSessionWorktreeMenuLoad:M,onEditProject:k,mobileVariant:I,alwaysShowActions:U,renderChildren:z}=t,ce=r===void 0?0:r,re=d===void 0?!1:d,Y=f===void 0?"project":f,me=z===void 0?!0:z;vs("ui.sidebar_tree_item.render");const be=p??`${Y}:${re?"archived":"active"}:${s.session.id}`,Pe=qt(F2),le=qt(B2),pe=ve(O2),je=ve(T2);let he;if(e[0]!==s){he=[];const q=ie=>ie.children.forEach(Ee=>{he.push(Ee.session.id),q(Ee)});q(s),e[0]=s,e[1]=he}else he=e[1];const X=he.join(`
|
|
998
|
+
`);let de;e[2]!==X?(de=X?X.split(`
|
|
999
|
+
`):[],e[2]=X,e[3]=de):de=e[3];const fe=de;let H;e[4]!==Pe||e[5]!==E||e[6]!==le?(H=(q,ie)=>{if(!q)return null;ie&&qt.getState().collapsedFolderIds.has(ie)&&le(ie);const Ee=Pe(q,"New folder",ie);return E(q,Ee),Ee},e[4]=Pe,e[5]=E,e[6]=le,e[7]=H):H=e[7];const ge=H;let Me;e[8]!==W||e[9]!==A||e[10]!==fe||e[11]!==C||e[12]!==w||e[13]!==be||e[14]!==I||e[15]!==s.session.id||e[16]!==L||e[17]!==K||e[18]!==D||e[19]!==R||e[20]!==j||e[21]!==N||e[22]!==pe?(Me={mobileVariant:I,allowReselect:W,onSessionSelected:L,resetSessionSearch:K,descendantIds:fe,showDeletionDialog:pe,setDeleteSessionConfirm:D,deleteSessionConfirm:A,editingId:w,setEditingId:j,setEditingRowKey:N,editingSessionId:s.session.id,editingOccurrenceKey:be,editTitle:C,setEditTitle:R},e[8]=W,e[9]=A,e[10]=fe,e[11]=C,e[12]=w,e[13]=be,e[14]=I,e[15]=s.session.id,e[16]=L,e[17]=K,e[18]=D,e[19]=R,e[20]=j,e[21]=N,e[22]=pe,e[23]=Me):Me=e[23];const Ne=I2(Me),Ie=b?.childRenderExtrasFor,Te=s.session.directory??i;let Le;e[24]!==re||e[25]!==o||e[26]!==Y||e[27]!==Te?(Le={groupDirectory:Te,projectId:o,archivedBucket:re,renderContext:Y},e[24]=re,e[25]=o,e[26]=Y,e[27]=Te,e[28]=Le):Le=e[28];const _e=Le,P=m??p??s.session.id,oe=b?.subtreeContainsEditing??R2,V=b?.menuOpenSessionId??null,Q=b?.nodeStructureKey??"",ue=b?.relativeTimeTick;let Z;e[29]!==W||e[30]!==U||e[31]!==_e||e[32]!==Ie||e[33]!==A||e[34]!==ce||e[35]!==C||e[36]!==w||e[37]!==S||e[38]!==v||e[39]!==l||e[40]!==y||e[41]!==I||e[42]!==s.children||e[43]!==g||e[44]!==h||e[45]!==L||e[46]!==O||e[47]!==x||e[48]!==me||e[49]!==K||e[50]!==a||e[51]!==D||e[52]!==R||e[53]!==j||e[54]!==N||e[55]!==_||e[56]!==E||e[57]!==M||e[58]!==T?(Z=me?s.children.map(q=>n.jsx(Bo,{node:q,pinnedSessionIds:x,expandedParents:v,hasSessionSearchQuery:y,normalizedSessionSearchQuery:g,notifyOnSubtasks:h,editingId:w,editingRowKey:S,setEditingId:j,setEditingRowKey:N,editTitle:C,setEditTitle:R,toggleParent:T,openSidebarMenuKey:O,setOpenSidebarMenuKey:_,allowReselect:W,onSessionSelected:L,resetSessionSearch:K,deleteSessionConfirm:A,setDeleteSessionConfirm:D,startFolderRename:E,startSessionWorktreeMenuLoad:M,mobileVariant:I,alwaysShowActions:U,depth:ce+1,folderOwnerKey:l,selectionScopeKey:a,..._e,renderExtras:Ie?.(q)},q.session.id)):null,e[29]=W,e[30]=U,e[31]=_e,e[32]=Ie,e[33]=A,e[34]=ce,e[35]=C,e[36]=w,e[37]=S,e[38]=v,e[39]=l,e[40]=y,e[41]=I,e[42]=s.children,e[43]=g,e[44]=h,e[45]=L,e[46]=O,e[47]=x,e[48]=me,e[49]=K,e[50]=a,e[51]=D,e[52]=R,e[53]=j,e[54]=N,e[55]=_,e[56]=E,e[57]=M,e[58]=T,e[59]=Z):Z=e[59];let ee;e[60]!==U||e[61]!==re||e[62]!==ge||e[63]!==ce||e[64]!==C||e[65]!==w||e[66]!==S||e[67]!==be||e[68]!==v||e[69]!==l||e[70]!==i||e[71]!==y||e[72]!==I||e[73]!==s||e[74]!==g||e[75]!==h||e[76]!==k||e[77]!==O||e[78]!==x||e[79]!==o||e[80]!==Y||e[81]!==u||e[82]!==a||e[83]!==Ne.handleCancelEdit||e[84]!==Ne.handleCopySessionId||e[85]!==Ne.handleDeleteSession||e[86]!==Ne.handleRestoreSession||e[87]!==Ne.handleSaveEdit||e[88]!==Ne.handleSessionDoubleClick||e[89]!==Ne.handleSessionSelect||e[90]!==R||e[91]!==j||e[92]!==N||e[93]!==_||e[94]!==M||e[95]!==P||e[96]!==oe||e[97]!==V||e[98]!==Q||e[99]!==ue||e[100]!==Z||e[101]!==T?(ee=n.jsx(A2,{expandedParents:v,hasSessionSearchQuery:y,normalizedSessionSearchQuery:g,notifyOnSubtasks:h,editingId:w,editingRowKey:S,setEditingId:j,setEditingRowKey:N,editTitle:C,setEditTitle:R,handleSaveEdit:Ne.handleSaveEdit,handleCancelEdit:Ne.handleCancelEdit,toggleParent:T,handleSessionSelect:Ne.handleSessionSelect,handleSessionDoubleClick:Ne.handleSessionDoubleClick,handleCopySessionId:Ne.handleCopySessionId,openSidebarMenuKey:O,setOpenSidebarMenuKey:_,createFolderAndStartRename:ge,handleDeleteSession:Ne.handleDeleteSession,handleRestoreSession:Ne.handleRestoreSession,startSessionWorktreeMenuLoad:M,onEditProject:k,mobileVariant:I,alwaysShowActions:U,pinnedSessionIds:x,node:s,depth:ce,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:re,secondaryMeta:u,renderContext:Y,rowKey:be,dragKey:P,subtreeContainsEditing:oe,menuOpenSessionId:V,nodeStructureKey:Q,relativeTimeTick:ue,children:Z}),e[60]=U,e[61]=re,e[62]=ge,e[63]=ce,e[64]=C,e[65]=w,e[66]=S,e[67]=be,e[68]=v,e[69]=l,e[70]=i,e[71]=y,e[72]=I,e[73]=s,e[74]=g,e[75]=h,e[76]=k,e[77]=O,e[78]=x,e[79]=o,e[80]=Y,e[81]=u,e[82]=a,e[83]=Ne.handleCancelEdit,e[84]=Ne.handleCopySessionId,e[85]=Ne.handleDeleteSession,e[86]=Ne.handleRestoreSession,e[87]=Ne.handleSaveEdit,e[88]=Ne.handleSessionDoubleClick,e[89]=Ne.handleSessionSelect,e[90]=R,e[91]=j,e[92]=N,e[93]=_,e[94]=M,e[95]=P,e[96]=oe,e[97]=V,e[98]=Q,e[99]=ue,e[100]=Z,e[101]=T,e[102]=ee):ee=e[102];let ke;e[103]!==A||e[104]!==s.session.id||e[105]!==Ne.confirmDeleteSession||e[106]!==D||e[107]!==je||e[108]!==pe?(ke=A?.session.id===s.session.id?n.jsx(D2,{value:A,setValue:D,showDeletionDialog:pe,setShowDeletionDialog:je,onConfirm:Ne.confirmDeleteSession}):null,e[103]=A,e[104]=s.session.id,e[105]=Ne.confirmDeleteSession,e[106]=D,e[107]=je,e[108]=pe,e[109]=ke):ke=e[109];let ne;return e[110]!==ee||e[111]!==ke?(ne=n.jsxs(n.Fragment,{children:[ee,ke]}),e[110]=ee,e[111]=ke,e[112]=ne):ne=e[112],ne}function T2(t){return t.setShowDeletionDialog}function O2(t){return t.showDeletionDialog}function B2(t){return t.toggleFolderCollapse}function F2(t){return t.createFolder}const L2=(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&&Qu(t.session,e.session)&&ut(t.worktree?.path??null)===ut(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,_2=(t,e)=>{if(t.node!==e.node&&!L2(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 s=e.node.session.id;if((t.renderExtras?.subtreeContainsEditing?.has(s)??!1)!==(e.renderExtras?.subtreeContainsEditing?.has(s)??!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 i of r)if(t[i]!==e[i])return!1;return!0},Bo=c.memo(M2,_2),ma=6,ud=14,$2=ma+14+6,W2=4;function fd(t){const e=Ye.c(7),{providerIDs:s,ringClass:r}=t;let i;if(e[0]!==s||e[1]!==r){let l;e[3]!==r?(l=a=>n.jsx("span",{className:De("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:n.jsx(Fu,{providerId:a,className:"h-3 w-3"})},a),e[3]=r,e[4]=l):l=e[4],i=s.slice(0,W2).map(l),e[0]=s,e[1]=r,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=n.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:i}),e[5]=i,e[6]=o):o=e[6],o}function K2(t){const e=Ye.c(95),{run:s,depth:r,laneNodes:i,renderContext:o,projectId:l,projectLabel:a,expansionKey:d,expanded:u,forceExpanded:f,notifyOnSubtasks:p,toggleParent:m}=t,{t:b}=jt();let x;e[0]!==s.key?(x=H=>H.runOverviewKey===s.key,e[0]=s.key,e[1]=x):x=e[1];const v=ve(x),y=o==="timeline";let g;e[2]!==y||e[3]!==l?(g=H=>y&&l?H.projects.find(ge=>ge.id===l)??null:null,e[2]=y,e[3]=l,e[4]=g):g=e[4];const h=Vt(g),w=s.lanes.length;let S;e[5]!==w||e[6]!==b?(S=w===1?b("sessions.sidebar.run.laneCountSingle",{count:w}):b("sessions.sidebar.run.laneCountPlural",{count:w}),e[5]=w,e[6]=b,e[7]=S):S=e[7];const j=S;let N;e[8]!==i?(N=[...i],e[8]=i,e[9]=N):N=e[9];const C=N;let R;e[10]!==C||e[11]!==p?(R=n.jsx(su,{nodes:C,includeUnreadSubtasks:p}),e[10]=C,e[11]=p,e[12]=R):R=e[12];const T=R,O=v?"text-interactive-selection-foreground":"text-foreground/80";let _;e[13]!==s.key?(_=()=>ve.getState().setRunOverviewKey(s.key),e[13]=s.key,e[14]=_):_=e[14];const W=_;if(y){const H=s.key,ge=v?"page":void 0;let Me;e[15]!==s.title||e[16]!==b?(Me=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[15]=s.title,e[16]=b,e[17]=Me):Me=e[17];let Ne;e[18]===Symbol.for("react.memo_cache_sentinel")?(Ne={paddingLeft:ma+4},e[18]=Ne):Ne=e[18];const Ie=v?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let Te;e[19]!==Ie?(Te=De("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",Ie),e[19]=Ie,e[20]=Te):Te=e[20];const Le=s.title;let _e;e[21]===Symbol.for("react.memo_cache_sentinel")?(_e=n.jsx(zi,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[21]=_e):_e=e[21];let P;e[22]!==j?(P=n.jsxs(n.Fragment,{children:[_e,n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:j})]}),e[22]=j,e[23]=P):P=e[23];let oe;e[24]!==s.lastActivity?(oe=Yu(s.lastActivity),e[24]=s.lastActivity,e[25]=oe):oe=e[25];let V;e[26]!==s.providerIDs?(V=n.jsx(fd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[26]=s.providerIDs,e[27]=V):V=e[27];let Q;e[28]!==T||e[29]!==a||e[30]!==s.title||e[31]!==P||e[32]!==oe||e[33]!==V||e[34]!==h||e[35]!==O?(Q=n.jsx(da,{project:h,projectLabel:a,title:Le,titleClassName:O,branchLabel:null,thirdLineLead:P,statusDot:T,pinnedMarker:null,timeSlot:oe,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:V,hideMetaOnHoverClass:""}),e[28]=T,e[29]=a,e[30]=s.title,e[31]=P,e[32]=oe,e[33]=V,e[34]=h,e[35]=O,e[36]=Q):Q=e[36];let ue;return e[37]!==W||e[38]!==s.key||e[39]!==Te||e[40]!==Q||e[41]!==ge||e[42]!==Me?(ue=n.jsx("button",{type:"button","data-run-row":H,"aria-current":ge,"aria-label":Me,onClick:W,style:Ne,className:Te,children:Q}),e[37]=W,e[38]=s.key,e[39]=Te,e[40]=Q,e[41]=ge,e[42]=Me,e[43]=ue):ue=e[43],ue}let L;e[44]!==d||e[45]!==f||e[46]!==m?(L=H=>{H.stopPropagation(),f||m(d)},e[44]=d,e[45]=f,e[46]=m,e[47]=L):L=e[47];const K=L,A=s.key,D=v?"page":void 0,E=$2+r*ud;let M;e[48]!==E?(M={paddingLeft:E},e[48]=E,e[49]=M):M=e[49];const k=v?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let I;e[50]!==k?(I=De("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-2.5",k),e[50]=k,e[51]=I):I=e[51];let U;e[52]!==K?(U=H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),K(H))},e[52]=K,e[53]=U):U=e[53];const z=ma+r*ud;let ce;e[54]!==z?(ce={left:z},e[54]=z,e[55]=ce):ce=e[55];let re;e[56]!==u||e[57]!==b?(re=b(u?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[56]=u,e[57]=b,e[58]=re):re=e[58];const Y=u?"arrow-down-s":"arrow-right-s";let me;e[59]!==Y?(me=n.jsx(F,{name:Y,className:"h-3 w-3"}),e[59]=Y,e[60]=me):me=e[60];let be;e[61]!==u||e[62]!==U||e[63]!==ce||e[64]!==re||e[65]!==me||e[66]!==K?(be=n.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":u,"aria-label":re,children:me}),e[61]=u,e[62]=U,e[63]=ce,e[64]=re,e[65]=me,e[66]=K,e[67]=be):be=e[67];let Pe;e[68]!==W?(Pe=H=>{H.stopPropagation(),W()},e[68]=W,e[69]=Pe):Pe=e[69];let le;e[70]!==s.title||e[71]!==b?(le=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[70]=s.title,e[71]=b,e[72]=le):le=e[72];let pe;e[73]===Symbol.for("react.memo_cache_sentinel")?(pe=n.jsx(zi,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[73]=pe):pe=e[73];let je;e[74]!==O?(je=De("block min-w-0 flex-1 truncate typography-ui-label font-normal",O),e[74]=O,e[75]=je):je=e[75];let he;e[76]!==s.title||e[77]!==je?(he=n.jsx("span",{className:je,children:s.title}),e[76]=s.title,e[77]=je,e[78]=he):he=e[78];let X;e[79]!==s.providerIDs?(X=n.jsx(fd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar"}),e[79]=s.providerIDs,e[80]=X):X=e[80];let de;e[81]!==T||e[82]!==Pe||e[83]!==le||e[84]!==he||e[85]!==X?(de=n.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":le,children:[pe,he,X,T]}),e[81]=T,e[82]=Pe,e[83]=le,e[84]=he,e[85]=X,e[86]=de):de=e[86];let fe;return e[87]!==W||e[88]!==s.key||e[89]!==M||e[90]!==I||e[91]!==be||e[92]!==de||e[93]!==D?(fe=n.jsxs("div",{"data-run-row":A,"aria-current":D,onClick:W,style:M,className:I,children:[be,de]}),e[87]=W,e[88]=s.key,e[89]=M,e[90]=I,e[91]=be,e[92]=de,e[93]=D,e[94]=fe):fe=e[94],fe}const z2=c.memo(K2),V2=24,U2=t=>Array.from({length:Math.min(t,V2)},(e,s)=>s),H2=(t,e,s)=>{const r=new Set(t);for(const i of e)i>=0&&i<s&&r.add(i);return[...r].sort((i,o)=>i-o)},G2=(t,e)=>t.find(s=>s.end>e)?.index??0;function pd(t,e){return t.key.startsWith("activity:active-now:")&&(e?.kind==="project-header"||e?.kind==="group-header")?"pb-4":e?.kind==="activity-header"||e?.kind==="project-header"||e?.kind==="group-header"&&t.kind!=="project-header"?"pb-2":void 0}function q2({model:t,scrollElement:e,pinnedRowIndexes:s,renderRow:r,onFirstVisibleIndexChange:i}){const o=t.rows,l=c.useCallback(()=>e,[e]),a=c.useCallback(y=>o[y]?.estimateSize??32,[o]),d=c.useCallback(y=>o[y]?.key??y,[o]),u=c.useCallback(y=>H2(dy(y),s,o.length),[s,o.length]),f=cy({count:o.length,enabled:e!==null,getScrollElement:l,estimateSize:a,getItemKey:d,overscan:8,rangeExtractor:u}),p=f.getVirtualItems(),m=e?f.getTotalSize():0,b=e?Math.max(m-e.clientHeight,0):0,x=e?Math.min(e.scrollTop,b):0,v=G2(p,x);if(c.useLayoutEffect(()=>{i(v)},[v,i]),!e){const y=U2(o.length),g=y.reduce((w,S)=>w+(o[S]?.estimateSize??0),0),h=o.reduce((w,S)=>w+S.estimateSize,0);return n.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[y.map(w=>{const S=o[w];return S?n.jsx("div",{className:pd(S,o[w+1]),children:r(S,w)},S.key):null}),h>g?n.jsx("div",{"aria-hidden":"true",style:{height:h-g}}):null]})}return n.jsx("div",{"data-sidebar-virtual-ready":"true",style:{height:m,position:"relative"},children:p.map(y=>{const g=o[y.index];return g?n.jsx("div",{className:`[&_[data-session-row]]:my-px ${pd(g,o[y.index+1])??""}`,"data-index":y.index,"data-sidebar-virtual-start":y.start,ref:f.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${y.start}px)`},children:r(g,y.index)},g.key):null})})}const Y2={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"},Q2=t=>{const e=Ye.c(48),{activityKey:s,collapsed:r,forceExpanded:i,alwaysShowActions:o,onToggle:l,onNewChat:a,timelineView:d}=t,u=d===void 0?!1:d,{t:f}=jt(),p=s==="chats";if(u){const W=i?void 0:l;let L;e[0]===Symbol.for("react.memo_cache_sentinel")?(L=De("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]=L):L=e[0];const K=!r,A=md[s];let D;e[1]!==f||e[2]!==A?(D=f(A),e[1]=f,e[2]=A,e[3]=D):D=e[3];let E;e[4]!==D?(E=n.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:D}),e[4]=D,e[5]=E):E=e[5];let M;e[6]!==r||e[7]!==i?(M=i?null:n.jsx(F,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5 text-muted-foreground"}),e[6]=r,e[7]=i,e[8]=M):M=e[8];let k;return e[9]!==i||e[10]!==W||e[11]!==K||e[12]!==E||e[13]!==M?(k=n.jsx("div",{className:"relative group/chats -mr-2",children:n.jsxs("button",{type:"button",onClick:W,disabled:i,className:L,"aria-expanded":K,children:[E,M]})}),e[9]=i,e[10]=W,e[11]=K,e[12]=E,e[13]=M,e[14]=k):k=e[14],k}const m=i?void 0:l,b=p?"pr-10":"pr-3.5";let x;e[15]!==b?(x=De("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",b),e[15]=b,e[16]=x):x=e[16];const v=!r,y=Y2[s],g=!i&&"group-hover:hidden";let h;e[17]!==g?(h=De("h-3.5 w-3.5 text-muted-foreground/80",g),e[17]=g,e[18]=h):h=e[18];let w;e[19]!==y||e[20]!==h?(w=n.jsx(F,{name:y,className:h}),e[19]=y,e[20]=h,e[21]=w):w=e[21];let S;e[22]!==r||e[23]!==i?(S=i?null:n.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:n.jsx(F,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[22]=r,e[23]=i,e[24]=S):S=e[24];let j;e[25]!==S||e[26]!==w?(j=n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[w,S]}),e[25]=S,e[26]=w,e[27]=j):j=e[27];const N=md[s];let C;e[28]!==f||e[29]!==N?(C=f(N),e[28]=f,e[29]=N,e[30]=C):C=e[30];let R;e[31]!==C?(R=n.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:C}),e[31]=C,e[32]=R):R=e[32];let T;e[33]!==i||e[34]!==j||e[35]!==R||e[36]!==m||e[37]!==x||e[38]!==v?(T=n.jsxs("button",{type:"button",onClick:m,disabled:i,className:x,"aria-expanded":v,children:[j,R]}),e[33]=i,e[34]=j,e[35]=R,e[36]=m,e[37]=x,e[38]=v,e[39]=T):T=e[39];let O;e[40]!==o||e[41]!==p||e[42]!==a||e[43]!==f?(O=p?n.jsx("button",{type:"button",onClick:W=>{W.stopPropagation(),a()},className:De("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",o?"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:n.jsx(F,{name:"add",className:"h-4 w-4"})}):null,e[40]=o,e[41]=p,e[42]=a,e[43]=f,e[44]=O):O=e[44];let _;return e[45]!==T||e[46]!==O?(_=n.jsxs("div",{className:"relative group/chats -ml-2.5 -mr-2",children:[T,O]}),e[45]=T,e[46]=O,e[47]=_):_=e[47],_},pp=c.createContext(null);function hd(t){let e=0,s=t;for(;s;){e+=s.offsetTop;const o=s.offsetParent;s=o instanceof HTMLElement?o:null}const r=t.closest("[data-sidebar-virtual-start]"),i=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(i)?i:0)}function X2(t){const e=Ye.c(14),{enabled:s,suspended:r,layoutKey:i,scrollRef:o,children:l}=t,a=r===void 0?!1:r,d=i===void 0?"":i;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[0]=u):u=e[0];const f=c.useRef(u),p=c.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 b=m;let x;e[2]!==s||e[3]!==o||e[4]!==a?(x=()=>{const h=o.current;if(!s||a||!h)return;const w=document.createElement("div");w.dataset.sidebarCrossfadeLayer="true",w.className="pointer-events-none sticky top-0 z-30 h-0",w.style.marginBlock="0px",h.prepend(w);let S=null,j=null,N=null,C=0;const R=new Set;let T=[];const O=window.matchMedia("(prefers-reduced-motion: reduce)"),_=Z2,W=()=>{N?.cancel(),N=null,j?.remove(),j=null},L=()=>{let M=null,k=-1/0;for(const{entry:I,top:U}of T)U<=h.scrollTop&&U>=k&&(k=U,M=I);if(S!==M){if(W(),S&&M&&!O.matches){const I=S.host.cloneNode(!0);I instanceof HTMLElement&&(I.inert=!0,I.setAttribute("aria-hidden","true"),I.querySelectorAll("[id]").forEach(J2),I.className="pointer-events-none absolute inset-x-0 top-0 z-30",j=I)}S&&(_(S,S.slot),S.slot.style.removeProperty("height")),S=M,w.hidden=!M,M&&(M.slot.style.height=`${M.host.getBoundingClientRect().height}px`,_(M,w),j&&(w.append(j),N=j.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),N.onfinish=W))}},K=()=>{S&&(S.slot.style.height=`${S.host.getBoundingClientRect().height}px`);const M=hd(h)+h.clientTop;T=Array.from(f.current,k=>({entry:k,top:hd(k.slot)-M})),L()},A=new ResizeObserver(K),D=new MutationObserver(()=>{cancelAnimationFrame(C),C=requestAnimationFrame(K)});A.observe(h);const E=()=>{D.disconnect();for(const M of R)f.current.has(M)||(A.unobserve(M.host),M.slot.parentElement&&A.unobserve(M.slot.parentElement),R.delete(M));for(const M of f.current){const k=M.slot.closest("[data-sidebar-virtual-start]");k&&D.observe(k,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),R.has(M)||(A.observe(M.host),M.slot.parentElement&&A.observe(M.slot.parentElement),R.add(M))}cancelAnimationFrame(C),C=requestAnimationFrame(K)};return p.current=E,h.addEventListener("scroll",L,{passive:!0}),E(),K(),()=>{p.current=null,cancelAnimationFrame(C),h.removeEventListener("scroll",L),A.disconnect(),D.disconnect(),W(),w.hidden=!0,S&&(_(S,S.slot),S.slot.style.removeProperty("height")),w.remove()}},e[2]=s,e[3]=o,e[4]=a,e[5]=x):x=e[5];let v;e[6]!==s||e[7]!==d||e[8]!==o||e[9]!==a?(v=[s,a,d,o],e[6]=s,e[7]=d,e[8]=o,e[9]=a,e[10]=v):v=e[10],c.useLayoutEffect(x,v);const y=s?b:null;let g;return e[11]!==l||e[12]!==y?(g=n.jsx(pp.Provider,{value:y,children:l}),e[11]=l,e[12]=y,e[13]=g):g=e[13],g}function J2(t){return t.removeAttribute("id")}function Z2(t,e){const s=document.activeElement,r=s instanceof HTMLElement&&t.host.contains(s);e.moveBefore&&e.isConnected&&t.host.isConnected?e.moveBefore(t.host,null):e.append(t.host),r&&s.focus({preventScroll:!0})}function eC(t){const e=Ye.c(15);let s,r;e[0]!==t?({register:r,...s}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const i=c.useRef(null),[o]=c.useState(tC);let l,a;e[3]!==o||e[4]!==r?(l=()=>{const m=i.current;if(!m)return;m.append(o);const b=r({slot:m,host:o});return()=>{b(),o.remove()}},a=[o,r],e[3]=o,e[4]=r,e[5]=l,e[6]=a):(l=e[5],a=e[6]),c.useLayoutEffect(l,a);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{ref:i}),e[7]=d):d=e[7];let u;e[8]!==s?(u=n.jsx("div",{...s}),e[8]=s,e[9]=u):u=e[9];let f;e[10]!==o||e[11]!==u?(f=Zp.createPortal(u,o),e[10]=o,e[11]=u,e[12]=f):f=e[12];let p;return e[13]!==f?(p=n.jsxs(n.Fragment,{children:[d,f]}),e[13]=f,e[14]=p):p=e[14],p}function tC(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function mp(t){const e=Ye.c(3),s=c.useContext(pp);let r;return e[0]!==t||e[1]!==s?(r=s?n.jsx(eC,{...t,register:s}):n.jsx("div",{...t}),e[0]=t,e[1]=s,e[2]=r):r=e[2],r}const sC=t=>{const e=Ye.c(3),[s,r]=c.useState(!1);let i,o;return e[0]!==t?(i=()=>{if(!t){r(!1);return}let l=!0;const a=()=>{ar.getDirectoryAvailability(t).then(d=>{l&&d!=="unknown"&&r(d==="missing")})};return a(),window.addEventListener("focus",a),()=>{l=!1,window.removeEventListener("focus",a)}},o=[t],e[0]=t,e[1]=i,e[2]=o):(i=e[1],o=e[2]),c.useEffect(i,o),s},Pi=t=>{const e=Ye.c(22),{id:s,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u}=t,f=u===void 0?!1:u,{currentTheme:p}=mr(),m=i?Lu[i]:null,b=o?_u[o]??null:null,x=d!==void 0,v=x?f?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let y;e[0]!==f||e[1]!==x||e[2]!==d?(y=x?n.jsx("span",{className:De("h-3.5 w-3.5 items-center justify-center text-muted-foreground",f?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:n.jsx(F,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=f,e[1]=x,e[2]=d,e[3]=y):y=e[3];let g;e[4]!==f||e[5]!==p||e[6]!==x||e[7]!==b||e[8]!==v||e[9]!==s||e[10]!==a||e[11]!==l||e[12]!==m?(g=l?n.jsx("span",{className:De("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",x&&f?"hidden":"inline-flex",v),style:a?{backgroundColor:a}:void 0,children:n.jsx($u,{project:{id:s,iconImage:l},options:{themeVariant:p.metadata.variant,iconColor:p.colors.surface.foreground},className:"h-full w-full object-contain",fallback:m?n.jsx(F,{name:m,className:"h-3.5 w-3.5",style:b?{color:b}:void 0}):n.jsx(F,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:b?{color:b}:void 0})})}):m?n.jsx(F,{name:m,className:De("h-3.5 w-3.5",v),style:b?{color:b}:void 0}):n.jsx(F,{name:"folder",className:De("h-3.5 w-3.5 text-muted-foreground/80",v),style:b?{color:b}:void 0}),e[4]=f,e[5]=p,e[6]=x,e[7]=b,e[8]=v,e[9]=s,e[10]=a,e[11]=l,e[12]=m,e[13]=g):g=e[13];let h;e[14]!==y||e[15]!==g?(h=n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[y,g]}),e[14]=y,e[15]=g,e[16]=h):h=e[16];let w;e[17]!==r?(w=n.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=w):w=e[18];let S;return e[19]!==h||e[20]!==w?(S=n.jsxs(n.Fragment,{children:[h,w]}),e[19]=h,e[20]=w,e[21]=S):S=e[21],S},nC=t=>{const e=Ye.c(62),{id:s,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:p,isRepo:m,hideDirectoryControls:b,alwaysShowActions:x,onToggle:v,onNewSession:y,onNewWorktreeSession:g,onManageWorktrees:h,onManageSpaces:w,onRenameStart:S,onClose:j,children:N,showCreateButtons:C,hideHeader:R,statusIndicator:T,openSidebarMenuKey:O,setOpenSidebarMenuKey:_,projectPickerOptions:W,onProjectSelect:L}=t,K=r===void 0?!1:r,A=C===void 0?!0:C,D=R===void 0?!1:R,E=T===void 0?null:T,{t:M}=jt(),k=sC(l);let I;e[0]!==K||e[1]!==s?(I={id:s,disabled:K},e[0]=K,e[1]=s,e[2]=I):I=e[2];const{attributes:U,listeners:z,setNodeRef:ce,transform:re,transition:Y,isDragging:me}=Go(I),be=c.useRef(!1),Pe=`project:${s}`,le=O===Pe,[pe,je]=c.useState(!1),he=!!(W&&L);let X;e[3]!==Pe||e[4]!==_?(X=ee=>{ee&&je(!1),_(ee?Pe:null)},e[3]=Pe,e[4]=_,e[5]=X):X=e[5];const de=X;let fe;e[6]!==b||e[7]!==m||e[8]!==j||e[9]!==w||e[10]!==h||e[11]!==y||e[12]!==S||e[13]!==A||e[14]!==M?(fe=ee=>n.jsxs(n.Fragment,{children:[A&&!m&&!b&&y&&n.jsxs(ee,{onClick:y,children:[n.jsx(F,{name:"add",className:"mr-1.5 h-4 w-4"}),M("sessions.sidebar.project.actions.newSession")]}),m&&!b&&h&&n.jsxs(ee,{onClick:h,children:[n.jsx(F,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),M("sessions.sidebar.project.actions.manageWorktrees")]}),m&&!b&&w&&n.jsxs(ee,{onClick:w,children:[n.jsx(F,{name:"box-3",className:"mr-1.5 h-4 w-4"}),M("spaces.page.menuItem")]}),n.jsxs(ee,{onClick:S,children:[n.jsx(F,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),M("sessions.sidebar.project.actions.edit")]}),n.jsxs(ee,{onClick:j,className:"text-destructive focus:text-destructive",children:[n.jsx(F,{name:"close",className:"mr-1.5 h-4 w-4"}),M("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=b,e[7]=m,e[8]=j,e[9]=w,e[10]=h,e[11]=y,e[12]=S,e[13]=A,e[14]=M,e[15]=fe):fe=e[15];const H=fe,ge=iC,Me=aC,Ne=lC;let Ie;e[16]===Symbol.for("react.memo_cache_sentinel")?(Ie=ee=>{(ee.button===2||ee.button===0&&ee.ctrlKey)&&(be.current=!0)},e[16]=Ie):Ie=e[16];const Te=Ie;let Le;e[17]!==v?(Le=ee=>{if(ee.currentTarget.blur(),be.current){be.current=!1;return}v()},e[17]=v,e[18]=Le):Le=e[18];const _e=Le;let P;e[19]!==re?(P=qo.Transform.toString(re),e[19]=re,e[20]=P):P=e[20];let oe;e[21]!==P||e[22]!==Y?(oe={transform:P,transition:Y},e[21]=P,e[22]=Y,e[23]=oe):oe=e[23];const V=me&&"opacity-30";let Q;e[24]!==V?(Q=De("relative",V),e[24]=V,e[25]=Q):Q=e[25];let ue;e[26]!==x||e[27]!==U||e[28]!==k||e[29]!==de||e[30]!==_e||e[31]!==b||e[32]!==D||e[33]!==s||e[34]!==p||e[35]!==pe||e[36]!==le||e[37]!==he||e[38]!==m||e[39]!==z||e[40]!==y||e[41]!==g||e[42]!==L||e[43]!==d||e[44]!==o||e[45]!==l||e[46]!==a||e[47]!==f||e[48]!==u||e[49]!==i||e[50]!==W||e[51]!==H||e[52]!==A||e[53]!==E||e[54]!==M?(ue=D?null:n.jsx(n.Fragment,{children:n.jsxs(Jd,{open:pe,onOpenChange:je,children:[n.jsx(Xd,{render:n.jsx(mp,{className:De("-ml-2.5 -mr-2 text-left group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:ee=>{b||(ee.preventDefault(),je(!0))}}),children:n.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...U,children:[he?n.jsxs(Cs,{children:[n.jsx(js,{asChild:!0,children:n.jsxs("button",{type:"button",className:De("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 transition-[padding]",m&&!b?x||le?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":x||le?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":M("sessions.sidebar.project.selectAria",{project:i}),children:[n.jsx(Pi,{id:s,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f}),n.jsx(F,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?n.jsx(Tr,{directory:l,className:"ml-auto"}):null]})}),n.jsx(ks,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:W?.map(ee=>n.jsxs(Wt,{onClick:()=>L?.(ee.id),className:"flex items-center justify-between gap-3",title:ee.projectDescription,children:[n.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:n.jsx(Pi,{...ee})}),ee.id===s?n.jsx(F,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},ee.id))})]}):n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",onMouseDown:Te,onClick:_e,...z,className:De("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 transition-[padding]",m&&!b?x||le?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":x||le?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[n.jsx(Pi,{id:s,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:p,alwaysShowActions:x}),k?n.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:M("sessions.sidebar.project.folderMissing"),"aria-label":M("sessions.sidebar.project.folderMissing"),children:n.jsx(F,{name:"alert",className:"h-3 w-3"})}):null,E?n.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:E}):null,l?n.jsx(Tr,{directory:l,className:"ml-auto"}):null]})}),n.jsx(wt,{side:"right",sideOffset:8,children:o})]}),n.jsxs("div",{className:De("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",A?"right-7":"right-0.5"),children:[A&&m&&!b&&g?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),g()},className:De("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":M("sessions.sidebar.project.actions.newWorktree"),children:n.jsx(F,{name:"node-tree",className:"h-4 w-4"})})}),n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:M("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,b?null:n.jsxs(Cs,{open:le,onOpenChange:de,children:[n.jsx(js,{asChild:!0,children:n.jsx("button",{type:"button",className:De("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",le?"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":M("sessions.sidebar.project.actions.projectMenu"),onPointerDown:Me,onMouseDown:Ne,onClick:ge,children:n.jsx(F,{name:"more-2",className:"h-3.5 w-3.5"})})}),n.jsx(ks,{align:"end",className:"min-w-[180px]",children:H(Wt)})]})]}),A&&y?n.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),y()},className:De("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":M(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:n.jsx(F,{name:"add",className:"h-4 w-4"})})}),n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:M(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),n.jsx(Qd,{className:"min-w-[180px]",children:H(Wn)})]})}),e[26]=x,e[27]=U,e[28]=k,e[29]=de,e[30]=_e,e[31]=b,e[32]=D,e[33]=s,e[34]=p,e[35]=pe,e[36]=le,e[37]=he,e[38]=m,e[39]=z,e[40]=y,e[41]=g,e[42]=L,e[43]=d,e[44]=o,e[45]=l,e[46]=a,e[47]=f,e[48]=u,e[49]=i,e[50]=W,e[51]=H,e[52]=A,e[53]=E,e[54]=M,e[55]=ue):ue=e[55];let Z;return e[56]!==N||e[57]!==ce||e[58]!==oe||e[59]!==Q||e[60]!==ue?(Z=n.jsxs("div",{ref:ce,style:oe,className:Q,children:[ue,N]}),e[56]=N,e[57]=ce,e[58]=oe,e[59]=Q,e[60]=ue,e[61]=Z):Z=e[61],Z},rC=t=>{const e=Ye.c(21),{id:s,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==s?(l={id:s,disabled:o},e[0]=o,e[1]=s,e[2]=l):l=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:f,transition:p,isDragging:m}=Go(l);let b;e[3]!==a||e[4]!==u?(b={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=b):b=e[5];const x=b;let v;e[6]!==f?(v=qo.Transform.toString(f),e[6]=f,e[7]=v):v=e[7];let y;e[8]!==v||e[9]!==p?(y={transform:v,transition:p},e[8]=v,e[9]=p,e[10]=y):y=e[10];const g=m&&"opacity-50";let h;e[11]!==g?(h=De("space-y-0.5 rounded-md",g),e[11]=g,e[12]=h):h=e[12];let w;e[13]!==i||e[14]!==x?(w=i(x),e[13]=i,e[14]=x,e[15]=w):w=e[15];let S;return e[16]!==d||e[17]!==y||e[18]!==h||e[19]!==w?(S=n.jsx("div",{ref:d,style:y,className:h,children:w}),e[16]=d,e[17]=y,e[18]=h,e[19]=w,e[20]=S):S=e[20],S},oC=c.memo(rC);function iC(t){t.stopPropagation()}function aC(t){t.stopPropagation()}function lC(t){t.stopPropagation()}const gd=[],cC=t=>{const e=Ye.c(6),{nodes:s,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==s?(o={nodes:s,includeUnreadSubtasks:r},e[0]=r,e[1]=s,e[2]=o):o=e[2];const l=eu(o);let a;return e[3]!==i||e[4]!==l?(a=i(l),e[3]=i,e[4]=l,e[5]=a):a=e[5],a},Ii=(t,e)=>e?t.sessions.some(s=>pr(s,e)):!1,dC=(t,e,s)=>t.sessions.some(r=>Jf(r,r,e,s,t.directory,t.directory)),uC=(t,e,s)=>{const r=i=>{const o=i.session.id;return e.get(o)!==s.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},fC=(t,e,s)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const l=`project:${r}:${o.session.id}`;return e.has(l)!==s.has(l)?!0:o.children.some(i)};return t.sessions.some(i)},pC=(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&&dC(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&uC(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&fC(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Ii(e.group,t.editingId)||Ii(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Ii(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const s=e.group.isArchivedBucket===!0,r=To(e.group.sessions,t.openSidebarMenuKey,"project",s),i=To(e.group.sessions,e.openSidebarMenuKey,"project",s);if(r||i)return!1}if(t.folderRename!==e.folderRename){const s=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??ut(e.group.directory??null)];if(s.includes(t.folderRename?.scopeKey??null)||s.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},mC=c.memo(function(e){const s=Ye.c(23),{label:r,sessions:i,worktree:o}=e,{t:l}=jt(),a=lp();let d;s[0]!==i||s[1]!==a||s[2]!==o?(d=g=>{g.stopPropagation(),Hs.requestDelete({sessions:i,mode:"worktree",worktree:o,skipDialogIfSafe:a||g.shiftKey})},s[0]=i,s[1]=a,s[2]=o,s[3]=d):d=s[3];const u=a?"text-destructive":"text-muted-foreground";let f;s[4]!==u?(f=De("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),s[4]=u,s[5]=f):f=s[5];let p;s[6]!==r||s[7]!==a||s[8]!==l?(p=a?l("sessions.sidebar.group.actions.deleteGroupAndBranchAria",{label:r}):l("sessions.sidebar.group.actions.deleteGroupAria",{label:r}),s[6]=r,s[7]=a,s[8]=l,s[9]=p):p=s[9];let m;s[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(F,{name:"delete-bin",className:"h-4 w-4"}),s[10]=m):m=s[10];let b;s[11]!==d||s[12]!==f||s[13]!==p?(b=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,className:f,"aria-label":p,children:m})}),s[11]=d,s[12]=f,s[13]=p,s[14]=b):b=s[14];let x;s[15]!==a||s[16]!==l?(x=l(a?"sessions.sidebar.group.actions.deleteWorktreeAndBranch":"sessions.sidebar.group.actions.deleteWorktree"),s[15]=a,s[16]=l,s[17]=x):x=s[17];let v;s[18]!==x?(v=n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:x})}),s[18]=x,s[19]=v):v=s[19];let y;return s[20]!==b||s[21]!==v?(y=n.jsxs(vt,{children:[b,v]}),s[20]=b,s[21]=v,s[22]=y):y=s[22],y}),bd=[];function hC(t){const{t:e}=jt(),{group:s,groupKey:r,projectId:i,hideGroupLabel:o,renderBody:l=!0,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,groupSearchDataByGroup:u,visibleSessionCount:f,sessionBatchSize:p,collapsedGroups:m,hideDirectoryControls:b,showMoreGroupSessions:x,resetGroupSessionLimit:v,mobileVariant:y,alwaysShowActions:g,activeProjectId:h,setActiveProjectIdOnly:w,setSessionSwitcherOpen:S,openNewSessionDraft:j,pinnedSessionIds:N,sessionOrderIndex:C,notifyOnSubtasks:R,onToggleCollapsedGroup:T,dragHandleProps:O,compactBodyPadding:_=!1,expandedParents:W,editingId:L,editingRowKey:K,openSidebarMenuKey:A,editTitle:D,folderRename:E,setFolderRenameDraft:M,clearFolderRename:k}=t,I=qt(Re=>Re.toggleFolderCollapse),U=qt(Re=>Re.renameFolder),z=qt(Re=>Re.deleteFolder),ce=qt(Re=>Re.addSessionToFolder),re=ve(Re=>Re.showDeletionDialog),[Y,me]=c.useState(null),be=c.useCallback((Re,Ze)=>{const ot=C.get(Re.session.id),gt=C.get(Ze.session.id);if(ot!==void 0||gt!==void 0){if(ot===void 0)return 1;if(gt===void 0)return-1;if(ot!==gt)return ot-gt}return Ta(Re.session,Ze.session,N,Ea)},[N,C]),Pe=a?u.get(s):null,le=a?!1:m.has(r),pe=c.useMemo(()=>{if(s.isMain||s.isArchivedBucket||o)return null;const Re=ut(s.directory??null),Ze=s.branch?.trim();return Re&&Ze?_o(Re,Ze):null},[s.branch,s.directory,s.isArchivedBucket,s.isMain,o]),je=Ku(pe),he=je?`var(--pr-${je.visualState})`:void 0,X=sp(je,e),de=je?X?`#${je.number} · ${X}`:`#${je.number}`:void 0,fe=Wo(),H=c.useMemo(()=>{const Re=s.folderScopes?.map(Ze=>ut(Ze.directory))??[ut(s.directory??null)];return[...new Set(Re.filter(Ze=>!!Ze))]},[s.directory,s.folderScopes]);c.useSyncExternalStore(c.useCallback(Re=>H.length>0?fe.subscribeBootstrap(Re):()=>{},[H.length,fe]),c.useCallback(()=>H.map(Re=>`${Re}\0${fe.getBootstrapState(Re)??""}\0${fe.getBootstrapFailure(Re)??""}\0${fe.getInitializationState(Re)??""}\0${fe.getInitializationFailure(Re)??""}`).join(""),[H,fe]),c.useCallback(()=>"",[]));const ge=H.some(Re=>{const Ze=fe.getBootstrapState(Re);return Ze==="queued"||Ze==="running"}),Me=H.find(Re=>fe.getBootstrapState(Re)==="failed"||fe.getInitializationState(Re)==="failed")??null,Ne=Me!==null&&fe.getBootstrapState(Me)==="failed",Ie=Me?Ne?fe.getBootstrapFailure(Me):fe.getInitializationFailure(Me):void 0,Te=Ie==="os-permission"&&Ud(),[Le,_e]=c.useState(!1),P=c.useCallback(()=>{Me&&fe.requestBootstrap({directory:Me,priority:le?"visible":"expanded",reason:s.isMain?"project-expanded":"worktree-expanded",force:!0})},[fe,Me,s.isMain,le]),oe=c.useCallback(async()=>{if(!(!Me||!Te||Le)){_e(!0);try{(await Hd(Me)).success&&P()}finally{_e(!1)}}},[Te,Me,Le,P]),V=p??(b?10:5),Q=Math.max(V,f??V),ue=a?Pe?.groupMatches===!0:!1,Z=a,ee=c.useMemo(()=>[...Z?Pe?.filteredNodes??[]:s.sessions].sort(be),[be,s.sessions,Pe?.filteredNodes,Z]),ke=s.folderScopeKey??ut(s.directory??null),ne=Dn(i,s.directory),q=c.useMemo(()=>s.folderScopes&&s.folderScopes.length>0?s.folderScopes:ke?[{scopeKey:ke,directory:s.directory??null}]:[],[ke,s.directory,s.folderScopes]),ie=qt(Vn(c.useCallback(Re=>q.map(({scopeKey:Ze})=>Re.foldersMap[Ze]??gd),[q]))),Ee=c.useMemo(()=>q.flatMap(({scopeKey:Re,directory:Ze},ot)=>(ie[ot]??gd).map(Dt=>({folder:Dt,scopeKey:Re,scopeDirectory:Ze}))),[ie,q]),Ae=qt(Vn(c.useCallback(Re=>new Set(ie.flatMap(Ze=>Ze.filter(ot=>Re.collapsedFolderIds.has(ot.id)).map(ot=>ot.id))),[ie]))),$e=c.useMemo(()=>{const Re=new Map,Ze=ot=>{ot.forEach(gt=>{Re.set(gt.session.id,gt),gt.children.length>0&&Ze(gt.children)})};return Ze(ee),Re},[ee]),Oe=c.useMemo(()=>Ee.map(({folder:Re,scopeKey:Ze,scopeDirectory:ot})=>{const gt=ca(Re.sessionIds,$e).sort(be);return{folder:Re,scopeKey:Ze,scopeDirectory:ot,nodes:gt}}),[Ee,$e,be]),qe=c.useMemo(()=>{const Re=Xf(Oe.map(({folder:Ze,nodes:ot})=>({id:Ze.id,name:Ze.name,parentId:Ze.parentId,nodeCount:ot.length})),{archivedBucket:s.isArchivedBucket===!0,searchQuery:a?d:""});return Oe.filter(({folder:Ze})=>Re.has(Ze.id))},[Oe,s.isArchivedBucket,a,d]),ct=L,Ve=A,nt=c.useMemo(()=>new Set(qe.flatMap(Re=>Re.folder.sessionIds)),[qe]),kt=c.useMemo(()=>ee.filter(Re=>!nt.has(Re.session.id)),[ee,nt]),dt=c.useMemo(()=>{const Re=new Map(qe.map(Ze=>[Ze.folder.id,Ze]));return Qf(qe.map(Ze=>Ze.folder)).map(Ze=>Re.get(Ze.id)).filter(Ze=>!!Ze)},[qe]),yt=c.useMemo(()=>{const Re=new Map;return qe.forEach(Ze=>{if(!Ze.folder.parentId)return;const ot=Re.get(Ze.folder.parentId)??[];ot.push(Ze),Re.set(Ze.folder.parentId,ot)}),Re},[qe]),_t=c.useMemo(()=>{const Re=new Map(qe.map(gt=>[gt.folder.id,gt])),Ze=new Map,ot=(gt,Dt)=>{const At=Ze.get(gt);if(At!==void 0)return At;if(Dt.has(gt))return[];Dt.add(gt);const Xt=Re.get(gt),ns=Xt?[...Xt.nodes]:[];for(const Jt of yt.get(gt)??[])ns.push(...ot(Jt.folder.id,Dt));return Ze.set(gt,ns),ns};return qe.forEach(({folder:gt})=>ot(gt.id,new Set)),Ze},[qe,yt]),Bt="project",Lt=c.useMemo(()=>{const Re=new Set;return Gc(ee,ct,Re),qe.forEach(({nodes:Ze})=>{Gc(Ze,ct,Re)}),Re},[ee,qe,ct]),Rt=c.useMemo(()=>{if(!Ve)return null;const Re=To(ee,Ve,Bt,!!s.isArchivedBucket);if(Re)return Re;for(const{nodes:Ze}of qe){const ot=To(Ze,Ve,Bt,!!s.isArchivedBucket);if(ot)return ot}return null},[Ve,ee,qe,s.isArchivedBucket]),Et=c.useCallback(Re=>{const Ze=new WeakMap,ot=gt=>{Ze.set(gt,Mo(gt));for(const Dt of gt.children)ot(Dt)};return Re.forEach(ot),Ze},[]),Nt=c.useMemo(()=>Et(ee),[Et,ee]),ye=c.useMemo(()=>{const Re=new WeakMap;return qe.forEach(({nodes:Ze})=>{Ze.forEach(ot=>Re.set(ot,Mo(ot)))}),Re},[qe]),He=c.useCallback(Re=>Nt.get(Re)??ye.get(Re)??"",[Nt,ye]),mt=c.useCallback(Re=>({subtreeContainsEditing:Lt,menuOpenSessionId:Rt,nodeStructureKey:He(Re)}),[Lt,Rt,He]),Ke=kt.length,B=s.isArchivedBucket||a?kt:kt.slice(0,Q),Se=Ke-B.length,Fe=!s.isArchivedBucket&&!a&&Ke>V&&Se===0,$=c.useCallback(Re=>{const Ze=[],ot=gt=>{gt.forEach(Dt=>{Ze.push(Dt.session),Dt.children.length>0&&ot(Dt.children)})};return ot(Re),Ze},[]),se=c.useMemo(()=>$(ee),[$,ee]),we=c.useMemo(()=>{if(je||s.isMain||s.isArchivedBucket||o)return bd;const Re=new Map;for(const Ze of se)for(const ot of Oa(Ze))Re.has(ot.key)||Re.set(ot.key,ot);return Re.size>0?[...Re.values()]:bd},[se,s.isArchivedBucket,s.isMain,je,o]),tt=c.useMemo(()=>we.flatMap(Re=>Re.source==="github"?[{owner:Re.owner,repo:Re.repo,number:Re.number}]:[]),[we]),rt=Vu(tt),Xe=c.useMemo(()=>tp(we,rt).map(Re=>({...Re,text:Re.statusKey?`${Re.label} · ${e(Re.statusKey)}`:Re.label})),[rt,we,e]),G=Xe[0]??null,Ce=c.useMemo(()=>{if(!s.isArchivedBucket)return new Map;const Re=new Map,Ze=new Map;for(const{folder:gt}of qe){if(!gt.parentId)continue;const Dt=Ze.get(gt.parentId)??[];Dt.push(gt.id),Ze.set(gt.parentId,Dt)}const ot=(gt,Dt)=>{if(Dt.has(gt))return[];Dt.add(gt);const At=qe.find(({folder:Jt})=>Jt.id===gt),Xt=At?$(At.nodes):[],ns=Ze.get(gt)??[];for(const Jt of ns)Xt.push(...ot(Jt,Dt));return Xt};for(const{folder:gt}of qe)Re.set(gt.id,ot(gt.id,new Set));return Re},[qe,$,s.isArchivedBucket]);if(a&&!ue&&dt.length===0&&kt.length===0)return null;const bt=!s.isMain&&!!s.branch,xe=s.branch&&Lb(s.branch,s.label)?{label:s.branch}:null,xt=le?n.jsx(su,{nodes:ee,includeUnreadSubtasks:R}):null,Mt=(Re,Ze)=>{const{folder:ot,scopeKey:gt,scopeDirectory:Dt,nodes:At}=Re,Xt=Ce.get(ot.id)??[],ns=E?.folderId===ot.id&&E?.scopeKey===gt,Jt=a?!1:Ae.has(ot.id),bn=rs=>n.jsx(np,{folderId:ot.id,scopeKey:gt,ownerKey:ne,children:(nn,Qs)=>n.jsx(ep,{folder:ot,displayName:Ze,sessions:At,isCollapsed:Jt,collapsedActivityState:rs,onToggle:()=>I(ot.id),onRename:as=>{U(gt,ot.id,as)},onDelete:()=>{if(s.isArchivedBucket){Hs.requestDelete({sessions:Xt,mode:"session"});return}if(!re){z(gt,ot.id);return}const as=qe.filter(({folder:xn})=>xn.parentId===ot.id).length,Ws=At.length;me({scopeKey:gt,folderId:ot.id,folderName:ot.name,subFolderCount:as,sessionCount:Ws})},groupDirectory:Dt??s.directory,projectId:i,mobileVariant:y,alwaysShowActions:g,isRenaming:ns,renameDraft:ns?E?.draft:void 0,onRenameDraftChange:M,onRenameSave:()=>{const as=E?.draft.trim()??"";as&&U(gt,ot.id,as),k()},onRenameCancel:k,droppableRef:nn,isDropTarget:Qs,depth:0,onNewSession:()=>{i&&i!==h&&w(i),y&&S(!1),j({selectedProjectId:i,directoryOverride:Dt??s.directory,targetFolderId:ot.id,target:s.draftTarget})},hideActions:!1,archivedBucket:s.isArchivedBucket===!0,children:At.map(as=>n.jsx(Bo,{node:as,pinnedSessionIds:N,expandedParents:W,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:R,editingId:L,editingRowKey:K,editTitle:D,openSidebarMenuKey:A,mobileVariant:y,alwaysShowActions:g,groupDirectory:Dt??s.directory,projectId:i,folderOwnerKey:ne,selectionScopeKey:ne,archivedBucket:s.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:Lt,menuOpenSessionId:Rt,nodeStructureKey:He(as),childRenderExtrasFor:mt},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},as.session.id))})},ot.id);return Jt?n.jsx(cC,{nodes:_t.get(ot.id)??At,includeUnreadSubtasks:R,children:bn},ot.id):bn(null)},pt=()=>{const Re=new Map;for(const Dt of qe){const At=Dt.folder.parentId;if(!At)continue;const Xt=Re.get(At);Xt?Xt.push(Dt):Re.set(At,[Dt])}const Ze=[],ot=new Set,gt=(Dt,At)=>{if(ot.has(Dt.folder.id))return;ot.add(Dt.folder.id);const Xt=At?`${At} / ${Dt.folder.name}`:Dt.folder.name;Ze.push(Mt(Dt,Xt)),!(!a&&Ae.has(Dt.folder.id))&&(Re.get(Dt.folder.id)??[]).forEach(Jt=>gt(Jt,Xt))};return dt.forEach(Dt=>gt(Dt,"")),Ze},at=!!(!s.isMain&&s.worktree),Be=s.worktree?.worktreeStatus==="missing"?n.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:n.jsx(F,{name:"alert",className:"h-3 w-3"})}):null,Ue=s.space&&s.space.state!=="complete"?n.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:n.jsx(F,{name:"alert",className:"h-3 w-3"})}):null,lt=at||!!s.space,et=!!s.space,ft=g?et?"pr-20":lt?"pr-14":"pr-7":et?"pr-2 group-hover/gh:pr-20 group-focus-within/gh:pr-20":lt?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",Ct=Me?n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Ie==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":Ne?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),Te?n.jsx(ht,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:Le,onClick:()=>{oe()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,n.jsx(ht,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:P,children:e("sessions.sidebar.group.empty.retry")})]}):null,it=Re=>n.jsx(Bo,{node:Re,pinnedSessionIds:N,expandedParents:W,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:R,editingId:L,editingRowKey:K,editTitle:D,openSidebarMenuKey:A,mobileVariant:y,alwaysShowActions:g,groupDirectory:s.directory,projectId:i,folderOwnerKey:ne,selectionScopeKey:ne,archivedBucket:s.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:Lt,menuOpenSessionId:Rt,nodeStructureKey:He(Re),childRenderExtrasFor:mt},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},Re.session.id),Tt=n.jsxs(Jk,{scopeKey:q[0]?.scopeKey??ke,ownerKey:ne,hasFolders:qe.length>0,onSessionDroppedOnFolder:(Re,Ze)=>{const ot=qe.find(({folder:Dt,scopeKey:At})=>Dt.id===Ze.folderId&&At===Ze.scopeKey);if(!ot)return;const gt=qt.getState();for(const{scopeKey:Dt}of q)Dt!==ot.scopeKey&>.getSessionFolderId(Dt,Re)&>.removeSessionFromFolder(Dt,Re);ce(ot.scopeKey,Ze.folderId,Re)},children:[pt(),B.map(it),Ke===0&&qe.length===0?!s.isArchivedBucket&&!ge&&!Ct&&s.directory&&!s.emptyMessage?n.jsx(ht,{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:()=>{i&&i!==h&&w(i),y&&S(!1),j({selectedProjectId:i,directoryOverride:s.directory,target:s.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):n.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:s.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):ge?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(F,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Ct||(s.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,Ke>0&&Ct?n.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:Ct}):null,Se>0?n.jsx("button",{type:"button",onClick:()=>x(r,B.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,Fe?n.jsx("button",{type:"button",onClick:()=>v(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]}),$t="pb-2",ss=n.jsx(fp,{value:Y,setValue:me,onConfirm:()=>{const Re=Y;Re&&(z(Re.scopeKey,Re.folderId),me(null))}});return o?l?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"oc-group",children:n.jsx("div",{className:De("oc-group-body",$t),children:Tt})}),ss]}):null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"oc-group",children:[n.jsxs("div",{className:De("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),children:[n.jsxs(vt,{disabled:je?!X:!G,children:[n.jsx(St,{asChild:!0,children:n.jsx("div",{className:"min-w-0 flex-1",onClick:()=>T(r),role:"button",tabIndex:0,onKeyDown:Re=>{(Re.key==="Enter"||Re.key===" ")&&(Re.preventDefault(),T(r))},"aria-label":le?e("sessions.sidebar.group.expandAria",{label:s.label}):e("sessions.sidebar.group.collapseAria",{label:s.label}),"aria-expanded":!le,children:n.jsxs("div",{ref:O?.setActivatorNodeRef,className:De("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",ft),...O?.listeners??{},children:[n.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[n.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:s.isArchivedBucket?n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[n.jsx(F,{name:"archive",className:De("h-3.5 w-3.5 shrink-0 text-muted-foreground",g?"hidden":"group-hover/gh:hidden")}),n.jsx("span",{className:De("text-muted-foreground h-3.5 w-3.5 items-center justify-center",g?"inline-flex":"hidden group-hover/gh:inline-flex"),children:le?n.jsx(F,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):n.jsx(F,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:Pr(s.label,d)}),Be,xt]}):!s.isMain||s.worktree?n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[n.jsx(F,{name:s.space?"box-3":"git-branch",className:De("h-3.5 w-3.5 shrink-0",!he&&"text-muted-foreground",g?"hidden":"group-hover/gh:hidden"),style:he?{color:he}:void 0,"aria-label":s.space?e("sessions.sidebar.group.space"):void 0}),n.jsx("span",{className:De("text-muted-foreground h-3.5 w-3.5 items-center justify-center",g?"inline-flex":"hidden group-hover/gh:inline-flex"),children:le?n.jsx(F,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):n.jsx(F,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),n.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:Pr(s.label,d)}),Be,Ue,xt,je?n.jsxs("button",{type:"button",className:"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",style:he?{color:he}:void 0,disabled:!je.url,"aria-label":de,onPointerDown:Re=>Re.stopPropagation(),onKeyDown:Re=>Re.stopPropagation(),onClick:Re=>{Re.stopPropagation(),je.url&&Mn(je.url)},children:["#",je.number]}):G?n.jsxs("button",{type:"button",className:De("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",!G.color&&"text-muted-foreground"),style:G.color?{color:G.color}:void 0,"aria-label":Xe.map(Re=>Re.text).join(", "),onPointerDown:Re=>Re.stopPropagation(),onKeyDown:Re=>Re.stopPropagation(),onClick:Re=>{Re.stopPropagation(),Mn(G.url)},children:[n.jsx(F,{name:G.icon,className:"h-3 w-3"}),G.label,Xe.length>1?n.jsxs("span",{className:"text-muted-foreground",children:["+",Xe.length-1]}):null]}):null]}):n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[n.jsx("span",{className:"min-w-0 truncate",children:Pr(s.label,d)}),xt]})}),bt&&xe?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[s.isArchivedBucket?n.jsx(F,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):n.jsx(F,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:xe.label})]}):null]}),!s.isArchivedBucket&&s.directory?n.jsx(Tr,{directory:s.directory,className:"self-center"}):null]})})}),je&&X?n.jsxs(wt,{side:"right",sideOffset:8,className:"max-w-xs",children:[n.jsxs("p",{children:["#",je.number," · ",X]}),je.title?n.jsx("p",{className:"truncate text-muted-foreground",children:je.title}):null]}):!je&&G?n.jsx(wt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx("div",{className:"flex flex-col gap-1",children:Xe.map(Re=>n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{children:Re.text}),Re.title?n.jsx("p",{className:"truncate text-muted-foreground",children:Re.title}):null]},Re.key))})}):null]}),s.isArchivedBucket&&se.length>0?n.jsx("div",{className:De("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:n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Re=>{Re.stopPropagation(),Hs.requestDelete({sessions:se,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:s.label}),children:n.jsx(F,{name:"delete-bin",className:"h-4 w-4"})})}),n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,s.directory&&!s.isMain&&s.worktree?n.jsx("div",{className:De("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:n.jsx(mC,{label:s.label,sessions:se,worktree:s.worktree})}):null,s.space?n.jsx("div",{className:De("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:n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Re=>{Re.stopPropagation(),s.space&&po.getState().openAccessDialog(s.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:s.label}),children:n.jsx(F,{name:"key",className:"h-4 w-4"})})}),n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,s.space?n.jsx("div",{className:De("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:n.jsx(mh,{spaceId:s.space.id,label:s.label})}):null,s.directory?n.jsx("div",{className:De("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:n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Re=>{Re.stopPropagation(),i&&i!==h&&w(i),y&&S(!1),j({selectedProjectId:i,directoryOverride:s.directory,preserveDirectoryOverride:!!s.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:s.label}),children:n.jsx(F,{name:"add",className:"h-4 w-4"})})}),n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),s.space?n.jsx(hh,{spaceId:s.space.id,className:"pb-1 pl-5"}):null,!le&&l?n.jsx("div",{className:De("oc-group-body",$t),children:Tt}):null]}),ss]})}const gC=c.memo(hC,pC),uo=({projectId:t,mobileVariant:e,closeMobileSwitcher:s,setActiveProjectIdOnly:r,setSessionSwitcherOpen:i})=>{t&&r(t),e&&s&&i(!1)},xd=(t,e)=>Wu(t.label?.trim()||$o(t.normalizedPath,e)||t.normalizedPath);function bC(t){const e=Ye.c(105),{model:s,view:r,actions:i}=t;vs("ui.sidebar_projects_list.render");const{t:o}=jt(),l=Wo(),a=qt(IC),d=qt(PC),u=qt(AC),f=qt(NC),p=ve(CC),m=ve(kC)&&!_s(),[b,x]=c.useState(null),[v,y]=c.useState(null),[g,h]=c.useState(null),[w,S]=c.useState(null),[j,N]=c.useState(!1),C=c.useRef(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={activationConstraint:{distance:8}},e[0]=R):R=e[0];let T;e[1]===Symbol.for("react.memo_cache_sentinel")?(T={activationConstraint:{delay:200,tolerance:6}},e[1]=T):T=e[1];let O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O={coordinateGetter:Qx},e[2]=O):O=e[2];const _=Ko(un(Vo,R),un(zo,T),un(qx,O));let W;e[3]===Symbol.for("react.memo_cache_sentinel")?(W=P=>{C.current=P,S(P)},e[3]=W):W=e[3];const L=W;let K;if(e[4]!==s.projectSections||e[5]!==r.homeDirectory){let P;e[7]!==r.homeDirectory?(P=oe=>({id:oe.project.id,projectLabel:xd(oe.project,r.homeDirectory),projectDescription:Rr(oe.project.normalizedPath,r.homeDirectory),projectIcon:oe.project.icon,projectColor:oe.project.color,projectIconImage:oe.project.iconImage,projectIconBackground:oe.project.iconBackground}),e[7]=r.homeDirectory,e[8]=P):P=e[8],K=s.projectSections.map(P),e[4]=s.projectSections,e[5]=r.homeDirectory,e[6]=K}else K=e[6];const A=K;let D;e:{if(!r.stickyZoneHeaders){D=-1;break e}let P;if(e[9]!==s.rowModel.stickyHeaders||e[10]!==v){let oe;e[12]!==v?(oe=V=>`${V.kind}:${V.id}`===v,e[12]=v,e[13]=oe):oe=e[13],P=s.rowModel.stickyHeaders.findIndex(oe),e[9]=s.rowModel.stickyHeaders,e[10]=v,e[11]=P}else P=e[11];D=P}const E=D;let M;if(e[14]!==g||e[15]!==s.groupProps.editingRowKey||e[16]!==s.rowModel.rowIndexByKey||e[17]!==s.rowModel.rows||e[18]!==s.rowModel.stickyHeaders||e[19]!==s.state.openSidebarMenuKey||e[20]!==E){if(M=new Set,g){let P;e[22]!==g||e[23]!==s.rowModel.rowIndexByKey?(P=s.rowModel.rowIndexByKey.get(g),e[22]=g,e[23]=s.rowModel.rowIndexByKey,e[24]=P):P=e[24];const oe=P;oe!==void 0&&M.add(oe)}for(let P=0;P<s.rowModel.rows.length;P=P+1,P){const oe=s.rowModel.rows[P];oe?.kind==="session"&&(s.groupProps.editingRowKey===oe.key||s.state.openSidebarMenuKey===`session-menu:${oe.key}`||s.state.openSidebarMenuKey===`session-context:${oe.key}`)&&M.add(P)}if(E>=0){const P=Math.max(0,E-1),oe=Math.min(s.rowModel.stickyHeaders.length-1,E+1);for(let V=P;V<=oe;V=V+1,V){const Q=s.rowModel.stickyHeaders[V];Q&&M.add(Q.rowIndex)}}e[14]=g,e[15]=s.groupProps.editingRowKey,e[16]=s.rowModel.rowIndexByKey,e[17]=s.rowModel.rows,e[18]=s.rowModel.stickyHeaders,e[19]=s.state.openSidebarMenuKey,e[20]=E,e[21]=M}else M=e[21];const k=M;let I;e[25]!==s.rowModel.stickyHeaders||e[26]!==r.stickyZoneHeaders?(I=P=>{const oe=r.stickyZoneHeaders?jk(s.rowModel.stickyHeaders,P):null,V=oe?`${oe.kind}:${oe.id}`:null;y(Q=>Q===V?Q:V)},e[25]=s.rowModel.stickyHeaders,e[26]=r.stickyZoneHeaders,e[27]=I):I=e[27];const U=I;let z;e[28]!==l||e[29]!==o?(z=P=>{const oe=()=>{if(!P.status.directory){Ba();return}l.requestBootstrap({directory:P.status.directory,priority:"expanded",reason:P.group.isMain?"project-expanded":"worktree-expanded",force:!0})},V=async()=>{if(!P.status.directory)return;(await Hd(P.status.directory)).success&&oe()};let Q;e:switch(P.status.state){case"permission-denied":{Q=o("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Q=o("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Q=o("sessions.sidebar.group.empty.initializationFailed");break e}default:Q=o("sessions.sidebar.group.empty.loadingSessions")}return n.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[P.status.state==="loading"?n.jsx(F,{name:"loader-4",className:"size-3 animate-spin"}):null,Q,P.status.canGrantAccess?n.jsx(ht,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{V()},children:o("sessions.sidebar.group.empty.grantAccess")}):null,P.status.state!=="loading"?n.jsx(ht,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:oe,children:o("sessions.sidebar.group.empty.retry")}):null]})})},e[28]=l,e[29]=o,e[30]=z):z=e[30];const ce=z;let re;e[31]!==i||e[32]!==u||e[33]!==s.emptyState||e[34]!==s.groupProps||e[35]!==s.projectRepoStatus||e[36]!==s.searchEmptyState||e[37]!==s.singleProjectMode||e[38]!==s.state||e[39]!==A||e[40]!==d||e[41]!==ce||e[42]!==p||e[43]!==m||e[44]!==o||e[45]!==a||e[46]!==r.alwaysShowActions||e[47]!==r.hideDirectoryControls||e[48]!==r.homeDirectory||e[49]!==r.mobileVariant||e[50]!==r.projectSortOrder||e[51]!==r.stickyZoneHeaders||e[52]!==r.timelineView||e[53]!==r.worktreeSortOrder?(re=P=>{if(P.kind==="activity-header")return n.jsx(mp,{className:r.stickyZoneHeaders?"sticky top-0 z-20 bg-sidebar":void 0,"data-sidebar-sticky-header":r.stickyZoneHeaders?"true":void 0,children:n.jsx(Q2,{activityKey:P.activityKey,collapsed:P.collapsed,forceExpanded:P.forceExpanded,alwaysShowActions:r.alwaysShowActions,timelineView:r.timelineView,onToggle:()=>{if(!P.collapsed){const oe=`activity:${P.activityKey}`;i.group.resetGroupSessionLimit(oe),s.state.setVisibleActivityCountByKey(V=>{if(!V.has(oe))return V;const Q=new Map(V);return Q.delete(oe),Q})}s.state.setCollapsedActivityKeys(oe=>{const V=new Set(oe);return V.has(P.activityKey)?V.delete(P.activityKey):V.add(P.activityKey),V})},onNewChat:()=>{ve.getState().closeMainSurfaces(),r.mobileVariant&&i.setSessionSwitcherOpen(!1),i.openNewSessionDraft({selectedProjectId:_b,directoryOverride:null})}})});if(P.kind==="project-header"){const oe=P.section.project,V=xd(oe,r.homeDirectory);return n.jsx(nC,{id:oe.id,disabled:s.singleProjectMode||P.forceExpanded||s.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:V,projectDescription:Rr(oe.normalizedPath,r.homeDirectory),projectDirectory:oe.normalizedPath,projectIcon:oe.icon,projectColor:oe.color,projectIconImage:oe.iconImage,projectIconBackground:oe.iconBackground,isCollapsed:P.collapsed,isRepo:!!s.projectRepoStatus.get(oe.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:P.collapsed?i.renderProjectStatusIndicator?.(oe.id,P.section.groups):null,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,projectPickerOptions:s.singleProjectMode?A:void 0,onProjectSelect:s.singleProjectMode?i.setSingleProjectId:void 0,onToggle:()=>{!P.forceExpanded&&!s.singleProjectMode&&i.toggleProject(oe.id)},onNewSession:()=>{uo({projectId:oe.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:oe.id,directoryOverride:oe.normalizedPath})},onNewWorktreeSession:()=>{uo({projectId:oe.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewWorktreeDialog()},onManageWorktrees:()=>i.openWorktreesPage(oe.id),onManageSpaces:m?()=>ve.getState().setSpacesPageProjectId(oe.id):void 0,onRenameStart:()=>i.openProjectEditDialog(oe.id),onClose:()=>i.removeProject(oe.id),showCreateButtons:!0})}if(P.kind==="group-header")return n.jsx(oC,{id:P.groupKey,disabled:P.forceExpanded||s.state.editingId!==null||r.worktreeSortOrder!=="manual",children:oe=>n.jsx(gC,{...s.groupProps,...i.group,group:P.group,groupKey:P.groupKey,projectId:P.projectId,visibleSessionCount:s.state.visibleSessionCountByGroup.get(P.groupKey),editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,dragHandleProps:oe,renderBody:!1})});if(P.kind==="folder-header"){const oe=s.groupProps.folderRename?.folderId===P.folder.id&&s.groupProps.folderRename.scopeKey===P.scopeKey;return n.jsx(np,{folderId:P.folder.id,scopeKey:P.scopeKey,ownerKey:P.ownerKey,disabled:!P.dropEnabled,children:(V,Q)=>n.jsx(Hk,{notifyOnSubtasks:s.groupProps.notifyOnSubtasks,activityNodes:P.activityNodes,folder:P.folder,displayName:P.displayName,sessions:P.nodes,isCollapsed:P.collapsed,onToggle:P.forceExpanded?jC:()=>a(P.folder.id),onRename:ue=>d(P.scopeKey,P.folder.id,ue),onDelete:()=>{P.archived?Hs.requestDelete({sessions:[...P.deleteSessions],mode:"session"}):p?x({scopeKey:P.scopeKey,folderId:P.folder.id,folderName:P.folder.name,subFolderCount:P.subFolderCount,sessionCount:P.nodes.length}):u(P.scopeKey,P.folder.id)},renderBody:!1,groupDirectory:P.scopeDirectory??P.group.directory,projectId:P.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:oe,renameDraft:oe?s.groupProps.folderRename?.draft:void 0,onRenameDraftChange:s.groupProps.setFolderRenameDraft,onRenameSave:()=>{const ue=s.groupProps.folderRename?.draft.trim();ue&&d(P.scopeKey,P.folder.id,ue),s.groupProps.clearFolderRename()},onRenameCancel:s.groupProps.clearFolderRename,droppableRef:V,isDropTarget:Q,onNewSession:()=>{uo({projectId:P.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:P.projectId,directoryOverride:P.scopeDirectory??P.group.directory,targetFolderId:P.folder.id,target:P.group.draftTarget})},archivedBucket:P.archived})})}if(P.kind==="session"){const oe=new Set;return pr(P.node,s.state.editingId)&&oe.add(P.node.session.id),n.jsx("div",{onFocusCapture:()=>h(P.key),onBlurCapture:()=>h(V=>V===P.key?null:V),children:n.jsx(Bo,{...s.groupProps,node:P.node,depth:P.depth,groupDirectory:P.groupDirectory,projectId:P.projectId,folderOwnerKey:P.ownerKey,selectionScopeKey:P.selectionScopeKey,archivedBucket:P.archived,renderContext:P.renderContext,rowKey:P.key,dragKey:P.key,secondaryMeta:P.secondaryMeta,renderChildren:!1,editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:oe,menuOpenSessionId:s.state.openSidebarMenuKey===`session-menu:${P.key}`||s.state.openSidebarMenuKey===`session-context:${P.key}`?P.node.session.id:null,nodeStructureKey:Mo(P.node)}})})}if(P.kind==="run")return n.jsx(z2,{run:P.run,depth:P.depth,laneNodes:P.laneNodes,renderContext:P.renderContext,projectId:P.projectId,projectLabel:P.projectLabel,expansionKey:P.expansionKey,expanded:P.expanded,forceExpanded:P.forceExpanded,notifyOnSubtasks:s.groupProps.notifyOnSubtasks,toggleParent:s.groupProps.toggleParent});if(P.kind==="show-control")return n.jsx("button",{type:"button",className:De("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:()=>{P.containerKey.startsWith("activity:")?s.state.setVisibleActivityCountByKey(oe=>{const V=new Map(oe);return P.control==="more"?V.set(P.containerKey,P.currentCount+P.increment):V.delete(P.containerKey),V}):P.control==="more"?i.group.showMoreGroupSessions(P.containerKey,P.currentCount,P.increment):i.group.resetGroupSessionLimit(P.containerKey)},children:o(P.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")});if(P.kind==="status")return ce(P);if(P.emptyKind==="sidebar")return s.emptyState;if(P.emptyKind==="search")return s.searchEmptyState;if(P.emptyKind==="group"&&P.group?.directory&&!P.group.emptyMessage){const oe=P.group;return n.jsx(ht,{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:()=>{uo({projectId:P.projectId??null,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:P.projectId,directoryOverride:oe.directory,target:oe.draftTarget})},children:o("sessions.sidebar.group.empty.startSession")})}return n.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:P.emptyKind==="archived"?o("sessions.sidebar.group.empty.noArchivedSessions"):P.group?.emptyMessage??o("sessions.sidebar.group.empty.noSessionsInWorkspace")})},e[31]=i,e[32]=u,e[33]=s.emptyState,e[34]=s.groupProps,e[35]=s.projectRepoStatus,e[36]=s.searchEmptyState,e[37]=s.singleProjectMode,e[38]=s.state,e[39]=A,e[40]=d,e[41]=ce,e[42]=p,e[43]=m,e[44]=o,e[45]=a,e[46]=r.alwaysShowActions,e[47]=r.hideDirectoryControls,e[48]=r.homeDirectory,e[49]=r.mobileVariant,e[50]=r.projectSortOrder,e[51]=r.stickyZoneHeaders,e[52]=r.timelineView,e[53]=r.worktreeSortOrder,e[54]=re):re=e[54];const Y=re;let me;e[55]!==s.rowModel.rows?(me=s.rowModel.rows.flatMap(SC),e[55]=s.rowModel.rows,e[56]=me):me=e[56];const be=me;let Pe;e[57]!==s.sectionsForRender?(Pe=new Set(s.sectionsForRender.map(vC)),e[57]=s.sectionsForRender,e[58]=Pe):Pe=e[58];const le=Pe;let pe;e[59]!==s.rowModel.stickyHeaders?(pe=s.rowModel.stickyHeaders.map(wC).join(""),e[59]=s.rowModel.stickyHeaders,e[60]=pe):pe=e[60];const je=pe,he=!r.timelineView;let X;e[61]!==le?(X=P=>{N(le.has(String(P.active.id)))},e[61]=le,e[62]=X):X=e[62];let de;e[63]===Symbol.for("react.memo_cache_sentinel")?(de=()=>N(!1),e[63]=de):de=e[63];let fe;e[64]!==i||e[65]!==f||e[66]!==s.rowModel.folderAuthorityByOwner||e[67]!==s.rowModel.folderDropTargets||e[68]!==s.rowModel.rows||e[69]!==s.sectionsForRender||e[70]!==s.state||e[71]!==r.hasSessionSearchQuery||e[72]!==r.projectSortOrder?(fe=P=>{if(N(!1),!P.over)return;const oe=P.active.data.current,V=P.over.data.current;if(oe?.type==="session"&&oe.sessionId&&oe.ownerKey&&oe.archivedBucket!==!0&&V?.type==="folder"&&V.folderId&&V.scopeKey&&V.ownerKey===oe.ownerKey){const Oe=s.rowModel.folderDropTargets.find(Ve=>Ve.folderId===V.folderId&&Ve.scopeKey===V.scopeKey&&Ve.ownerKey===oe.ownerKey),qe=s.rowModel.folderAuthorityByOwner.get(oe.ownerKey);if(!Oe?.enabled||qe?.complete!==!0)return;const ct=qt.getState();for(const Ve of qe.scopeKeys)Ve!==V.scopeKey&&ct.removeSessionFromFolder(Ve,oe.sessionId);f(V.scopeKey,V.folderId,oe.sessionId);return}if(r.hasSessionSearchQuery||s.state.editingId!==null||P.active.id===P.over.id)return;const Q=String(P.active.id),ue=String(P.over.id),Z=s.sectionsForRender.map(yC),ee=Z.indexOf(Q),ke=Z.indexOf(ue);if(ee>=0&&ke>=0&&r.projectSortOrder==="manual"){i.reorderProjects(ee,ke);return}const ne=s.rowModel.rows.find(Oe=>Oe.kind==="group-header"&&Oe.groupKey===Q),q=s.rowModel.rows.find(Oe=>Oe.kind==="group-header"&&Oe.groupKey===ue);if(!ne||!q||ne.projectId!==q.projectId||!ne.projectId)return;const ie=ne.projectId,Ee=s.sectionsForRender.find(Oe=>Oe.project.id===ie);if(!Ee)return;const Ae=Ee.groups.findIndex(Oe=>Oe.id===ne.group.id),$e=Ee.groups.findIndex(Oe=>Oe.id===q.group.id);Ae<0||$e<0||i.setGroupOrderByProject(Oe=>new Map(Oe).set(ie,nf(Ee.groups,Ae,$e).map(xC)))},e[64]=i,e[65]=f,e[66]=s.rowModel.folderAuthorityByOwner,e[67]=s.rowModel.folderDropTargets,e[68]=s.rowModel.rows,e[69]=s.sectionsForRender,e[70]=s.state,e[71]=r.hasSessionSearchQuery,e[72]=r.projectSortOrder,e[73]=fe):fe=e[73];let H;e[74]!==U||e[75]!==s.rowModel||e[76]!==k||e[77]!==Y||e[78]!==w?(H=n.jsx(q2,{model:s.rowModel,scrollElement:w,pinnedRowIndexes:k,renderRow:Y,onFirstVisibleIndexChange:U}),e[74]=U,e[75]=s.rowModel,e[76]=k,e[77]=Y,e[78]=w,e[79]=H):H=e[79];let ge;e[80]!==be||e[81]!==H?(ge=n.jsx(La,{items:be,strategy:rf,children:H}),e[80]=be,e[81]=H,e[82]=ge):ge=e[82];let Me;e[83]!==_||e[84]!==X||e[85]!==fe||e[86]!==ge?(Me=n.jsx(Uo,{sensors:_,collisionDetection:Ho,onDragStart:X,onDragCancel:de,onDragEnd:fe,children:ge}),e[83]=_,e[84]=X,e[85]=fe,e[86]=ge,e[87]=Me):Me=e[87];let Ne;e[88]!==he||e[89]!==Me?(Ne=n.jsx(gn,{ref:L,useScrollShadow:!0,hideTopScrollShadow:he,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 pl-2.5 pr-2 [overflow-anchor:none]",children:Me}),e[88]=he,e[89]=Me,e[90]=Ne):Ne=e[90];let Ie;e[91]!==j||e[92]!==Ne||e[93]!==r.stickyZoneHeaders||e[94]!==je?(Ie=n.jsx(X2,{enabled:r.stickyZoneHeaders,suspended:j,layoutKey:je,scrollRef:C,children:Ne}),e[91]=j,e[92]=Ne,e[93]=r.stickyZoneHeaders,e[94]=je,e[95]=Ie):Ie=e[95];let Te;e[96]!==u||e[97]!==b?(Te=()=>{b&&(u(b.scopeKey,b.folderId),x(null))},e[96]=u,e[97]=b,e[98]=Te):Te=e[98];let Le;e[99]!==b||e[100]!==Te?(Le=n.jsx(fp,{value:b,setValue:x,onConfirm:Te}),e[99]=b,e[100]=Te,e[101]=Le):Le=e[101];let _e;return e[102]!==Ie||e[103]!==Le?(_e=n.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[Ie,Le]}),e[102]=Ie,e[103]=Le,e[104]=_e):_e=e[104],_e}function xC(t){return t.id}function yC(t){return t.project.id}function wC(t){const{kind:e,id:s,rowIndex:r}=t;return`${e}:${s}:${r}`}function vC(t){return t.project.id}function SC(t){return t.kind==="project-header"?[t.section.project.id]:t.kind==="group-header"?[t.groupKey]:[]}function jC(){}function kC(t){return t.isolatedSpacesEnabled}function CC(t){return t.showDeletionDialog}function NC(t){return t.addSessionToFolder}function AC(t){return t.deleteFolder}function PC(t){return t.renameFolder}function IC(t){return t.toggleFolderCollapse}const DC=c.memo(bC),ha=new Map,yd=(t,e)=>{for(const s of t){const r=ut(s??null);r&&!ha.has(r)&&ha.set(r,e)}},wd=t=>{const e=ut(t??null);return e?ha.get(e)??0:0},wr=t=>!!t.time?.archived,EC=t=>{const{t:e}=jt(),s=c.useRef(t.gitBranches);s.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),i=c.useCallback(a=>{const d=ut(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${d}`.toLowerCase()},[e]),o=c.useCallback((a,d)=>{if(!d)return a;const u=d.trim().toLowerCase(),f=u.startsWith("ses_");return a.flatMap(p=>{if(f&&wr(p.session))return[];if(f?p.session.id.toLowerCase()===u:No([i(p.session)],d))return[p];const b=o(p.children,d);return b.length===0?[]:[{...p,children:b}]})},[i]),l=c.useCallback((a,d,u,f,p)=>{const m=ut(d??null),b=Bu(a),x=new Map(b.map(k=>[k.id,k])),v=new Map;b.forEach(k=>{const I=k.parentID;if(!I)return;const U=x.get(I);if(!U||wr(U)!==wr(k))return;const z=v.get(I)??[];z.push(k),v.set(I,z)});const y=$b(u,m),g=(m&&!t.isVSCode?t.spacesByProject?.get(m):void 0)??[],h=new Map;for(const k of g){const I=ut(k.directory);I&&h.set(I,k)}const w=k=>{const I=ut(k.directory??null),U=t.worktreeMetadata.get(k.id)??null;if(U)return U;if(I){const z=y.get(I)??null;if(z&&I!==m)return z}return null},S=new Set,j=k=>{S.add(k.id);const I=v.get(k.id)??[],U=[];for(const z of I)S.has(z.id)||U.push(j(z));return{session:k,children:U,worktree:w(k)}},N=b.filter(k=>{const I=k.parentID;if(!I)return!0;const U=x.get(I);return U?wr(U)!==wr(k):!0}),C=[],R=k=>{S.has(k.id)||C.push(j(k))};N.forEach(R),b.forEach(R);const T=new Map,O="__archived__",_=k=>{if(k.time?.archived)return O;if(t.isVSCode||t.runKeyBySessionId?.has(k.id))return m??"__project_root__";const I=t.sessionOwners?.get(k.id)?.scopeDirectory;if(I){if(I===m)return m??"__project_root__";if(y.has(I)||h.has(I))return I}const z=ut(t.worktreeMetadata.get(k.id)?.path??null)??Is(k);return z&&z!==m&&y.has(z)?z:m??"__project_root__"};C.forEach(k=>{const I=_(k.session);T.has(I)||T.set(I,[]),T.get(I)?.push(k)});const W=m??"__project_root__",L=[{id:"root",label:p&&f&&f!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:f}):e("sessions.sidebar.grouping.projectRoot"),branch:f??null,description:m?Rr(m,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:m,folderScopeKey:m,sessions:T.get(W)??[]}],K=new Map;u.forEach(k=>{const I=ut(k.path)??k.path,U=T.get(I)??[],z=U.length>0,ce=U.reduce((re,Y)=>{const me=Wb(Y.session,t.sessionOrderRanks);return Number.isFinite(me)?Math.max(re,me):re},0);K.set(I,{hasActiveSession:z,lastUpdatedAt:ce})});const A=(k,I)=>{const U=(k.label||k.branch||k.name||k.path||"").toLowerCase(),z=(I.label||I.branch||I.name||I.path||"").toLowerCase();return U.localeCompare(z)},D=t.worktreeSortOrder!=="recent"?[...u].sort(A):[...u].sort((k,I)=>{const U=ut(k.path)??k.path,z=ut(I.path)??I.path,ce=K.get(U)??{hasActiveSession:!1,lastUpdatedAt:0},re=K.get(z)??{hasActiveSession:!1,lastUpdatedAt:0};if(ce.hasActiveSession!==re.hasActiveSession)return ce.hasActiveSession?-1:1;if(ce.hasActiveSession&&re.hasActiveSession)return re.lastUpdatedAt-ce.lastUpdatedAt;const Y=wd(k.path),me=wd(I.path);return Y!==me?me-Y:A(k,I)});(t.isVSCode?[]:D).forEach(k=>{const I=ut(k.path)??k.path,U=s.current.get(I)?.trim()||null,z=k.branch?.trim()||null,re=!!(U&&z&&k.label&&_l(k.label)===_l(z))?U:k.label||k.name||$o(I,t.homeDirectory)||I;L.push({id:`worktree:${I}`,label:re,branch:U||z,description:Rr(I,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:k,directory:I,folderScopeKey:I,sessions:T.get(I)??[]})});for(const[k,I]of h)L.push({id:`space:${I.id}`,label:I.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:I,directory:k,folderScopeKey:k,sessions:T.get(k)??[]});const M=T.get(O)??[];return M.length>0&&L.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?Tu(m):null,sessions:M}),L},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,t.worktreeSortOrder,t.sessionOwners,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},RC=t=>{const e=Ye.c(60),{selectedCount:s,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:f,onArchive:p,onDelete:m,onDone:b}=t,{t:x}=jt(),v=s>0,y=v&&!!r&&!o;let g;e[0]!==s||e[1]!==x?(g=x("sessions.sidebar.bulkActions.selectedCount",{count:s}),e[0]=s,e[1]=x,e[2]=g):g=e[2];let h;e[3]!==g?(h=n.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:g}),e[3]=g,e[4]=h):h=e[4];let w;e[5]!==y||e[6]!==u||e[7]!==a||e[8]!==l||e[9]!==d||e[10]!==i||e[11]!==x?(w=y?n.jsxs(Cs,{children:[n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(js,{asChild:!0,children:n.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:n.jsx(F,{name:"folder",className:"h-4 w-4"})})})}),n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:x("sessions.sidebar.bulkActions.moveToFolder")})})]}),n.jsxs(ks,{align:"end",className:"min-w-[180px]",children:[i.length===0?n.jsx(Wt,{disabled:!0,className:"text-muted-foreground",children:x("sessions.sidebar.folders.none")}):i.map(z=>n.jsx(Wt,{onClick:()=>l(z.id),children:n.jsx("span",{className:"flex-1 truncate",children:z.name})},z.id)),n.jsx(ws,{}),n.jsxs(Wt,{onClick:a,children:[n.jsx(F,{name:"add",className:"mr-1 h-4 w-4"}),x("sessions.sidebar.folders.newFolderEllipsis")]}),u?n.jsxs(Wt,{onClick:d,className:"text-destructive focus:text-destructive",children:[n.jsx(F,{name:"close",className:"mr-1 h-4 w-4"}),x("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=y,e[6]=u,e[7]=a,e[8]=l,e[9]=d,e[10]=i,e[11]=x,e[12]=w):w=e[12];let S;e[13]!==o||e[14]!==v||e[15]!==f||e[16]!==x?(S=o?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:f,disabled:!v,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:n.jsx(F,{name:"inbox-unarchive",className:"h-4 w-4"})})}),n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:x("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=o,e[14]=v,e[15]=f,e[16]=x,e[17]=S):S=e[17];let j;e[18]!==o||e[19]!==v||e[20]!==p||e[21]!==x?(j=o?null:n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:p,disabled:!v,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:n.jsx(F,{name:"archive",className:"h-4 w-4"})})}),n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:x("sessions.sidebar.bulkActions.archive")})})]}),e[18]=o,e[19]=v,e[20]=p,e[21]=x,e[22]=j):j=e[22];const N=!v;let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=De("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 R;e[24]!==x?(R=x("sessions.sidebar.bulkActions.delete"),e[24]=x,e[25]=R):R=e[25];let T;e[26]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(F,{name:"delete-bin",className:"h-4 w-4"}),e[26]=T):T=e[26];let O;e[27]!==m||e[28]!==N||e[29]!==R?(O=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:m,disabled:N,className:C,"aria-label":R,children:T})}),e[27]=m,e[28]=N,e[29]=R,e[30]=O):O=e[30];let _;e[31]!==x?(_=x("sessions.sidebar.bulkActions.delete"),e[31]=x,e[32]=_):_=e[32];let W;e[33]!==_?(W=n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:_})}),e[33]=_,e[34]=W):W=e[34];let L;e[35]!==O||e[36]!==W?(L=n.jsxs(vt,{children:[O,W]}),e[35]=O,e[36]=W,e[37]=L):L=e[37];let K;e[38]!==x?(K=x("sessions.sidebar.header.actions.exitSelection"),e[38]=x,e[39]=K):K=e[39];let A;e[40]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(F,{name:"close",className:"h-4 w-4"}),e[40]=A):A=e[40];let D;e[41]!==b||e[42]!==K?(D=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:b,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":K,children:A})}),e[41]=b,e[42]=K,e[43]=D):D=e[43];let E;e[44]!==x?(E=x("sessions.sidebar.header.actions.exitSelection"),e[44]=x,e[45]=E):E=e[45];let M;e[46]!==E?(M=n.jsx(wt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:E})}),e[46]=E,e[47]=M):M=e[47];let k;e[48]!==D||e[49]!==M?(k=n.jsxs(vt,{children:[D,M]}),e[48]=D,e[49]=M,e[50]=k):k=e[50];let I;e[51]!==L||e[52]!==k||e[53]!==w||e[54]!==S||e[55]!==j?(I=n.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[w,S,j,L,k]}),e[51]=L,e[52]=k,e[53]=w,e[54]=S,e[55]=j,e[56]=I):I=e[56];let U;return e[57]!==h||e[58]!==I?(U=n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[h,I]}),e[57]=h,e[58]=I,e[59]=U):U=e[59],U},vd=new Map,MC=(t,e)=>{if(!t)return[];const s=e(t);return s.length>0?s.map(r=>r.scopeKey):[t]},TC=(t,e)=>{const s=t.sessionIds.filter(o=>e.has(o));if(s.length===0)return{ready:!1,value:null};const r=t.archivedBucket||ip(new Set(s),e),i={sessionIds:s,sessionCount:s.length,archivedBucket:r};return{ready:s.length===t.sessionIds.length&&r===t.archivedBucket,value:i}},OC=t=>{const e=Ye.c(89),{t:s}=jt();let r;e[0]!==s?(r=V=>{const Q=Kb(V);return Q?{description:tu(Q,s)}:void 0},e[0]=s,e[1]=r):r=e[1];const i=r,{isInlineEditing:o,showDeletionDialog:l,foldersMap:a,getFolderScopesForProject:d,addSessionsToFolder:u,removeSessionsFromFolders:f,createFolderAndStartRename:p,archiveSessions:m,unarchiveSessions:b,deleteSessions:x,bulkDeleteConfirm:v,setBulkDeleteConfirm:y}=t,g=ts(BC),h=ts(FC),w=h>0,S=ts(LC),j=ts(_C),N=op(),C=$C,R=WC;let T;e[2]!==w||e[3]!==N||e[4]!==S?(T=w&&ip(S,N?.getSessionsById()??vd),e[2]=w,e[3]=N,e[4]=S,e[5]=T):T=e[5];const O=T;let _;e:{if(j){_=j;break e}_=null}const W=_;let L;e[6]!==W||e[7]!==d?(L=MC(W,d),e[6]=W,e[7]=d,e[8]=L):L=e[8];const K=L;let A;if(e[9]!==a||e[10]!==K){let V;e[12]!==a?(V=Q=>a[Q]??[],e[12]=a,e[13]=V):V=e[13],A=K.flatMap(V),e[9]=a,e[10]=K,e[11]=A}else A=e[11];const D=A;let E;e[14]!==a||e[15]!==K?(E=V=>{for(const Q of K)if((a[Q]??[]).some(ue=>ue.id===V))return Q;return null},e[14]=a,e[15]=K,e[16]=E):E=e[16];const M=E;let k;e:{if(!w){k=!1;break e}for(const V of K)for(const Q of a[V]??[])for(const ue of Q.sessionIds)if(S.has(ue)){k=!0;break e}k=!1}const I=k;let U;e[17]!==u||e[18]!==f||e[19]!==S||e[20]!==K?(U=(V,Q)=>{const ue=Array.from(S);for(const Z of K)Z!==V&&f(Z,ue);u(V,Q,ue)},e[17]=u,e[18]=f,e[19]=S,e[20]=K,e[21]=U):U=e[21];const z=U;let ce;e[22]!==w||e[23]!==z||e[24]!==M?(ce=V=>{if(!w)return;const Q=M(V);Q&&z(Q,V)},e[22]=w,e[23]=z,e[24]=M,e[25]=ce):ce=e[25];const re=ce;let Y;e[26]!==p||e[27]!==w||e[28]!==z||e[29]!==K?(Y=()=>{const V=K[0];if(!V||!w)return;const Q=p(V);Q&&z(V,Q.id)},e[26]=p,e[27]=w,e[28]=z,e[29]=K,e[30]=Y):Y=e[30];const me=Y;let be;e[31]!==w||e[32]!==f||e[33]!==S||e[34]!==K?(be=()=>{if(!w)return;const V=Array.from(S);for(const Q of K)f(Q,V)},e[31]=w,e[32]=f,e[33]=S,e[34]=K,e[35]=be):be=e[35];const Pe=be;let le;e[36]!==m||e[37]!==x||e[38]!==i||e[39]!==s?(le=async(V,Q)=>{if(V.length!==0)if(Q){const{deletedIds:ue,failedIds:Z}=await x(V);ue.length>0&&We.success(ue.length===1?s("sessions.sidebar.bulkActions.deletedSingle",{count:ue.length}):s("sessions.sidebar.bulkActions.deletedPlural",{count:ue.length})),Z.length>0&&We.error(Z.length===1?s("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Z.length}):s("sessions.sidebar.bulkActions.failedDeletePlural",{count:Z.length}),i(Z)),ts.getState().removeMany(ue)}else{const{archivedIds:ue,failedIds:Z}=await m(V);ue.length>0&&We.success(ue.length===1?s("sessions.sidebar.bulkActions.archivedSingle",{count:ue.length}):s("sessions.sidebar.bulkActions.archivedPlural",{count:ue.length})),Z.length>0&&We.error(Z.length===1?s("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Z.length}):s("sessions.sidebar.bulkActions.failedArchivePlural",{count:Z.length}),i(Z)),ts.getState().removeMany(ue)}},e[36]=m,e[37]=x,e[38]=i,e[39]=s,e[40]=le):le=e[40];const pe=le;let je;e[41]!==pe||e[42]!==w||e[43]!==S||e[44]!==y||e[45]!==l?(je=V=>{if(!w)return;const Q=Array.from(S);if(!l){pe(Q,V);return}y({sessionIds:Q,sessionCount:Q.length,archivedBucket:V})},e[41]=pe,e[42]=w,e[43]=S,e[44]=y,e[45]=l,e[46]=je):je=e[46];const he=je;let X;e[47]!==O||e[48]!==he?(X=()=>he(O),e[47]=O,e[48]=he,e[49]=X):X=e[49];const de=X;let fe;e[50]!==he?(fe=()=>he(!1),e[50]=he,e[51]=fe):fe=e[51];const H=fe;let ge;e[52]!==he?(ge=()=>he(!0),e[52]=he,e[53]=ge):ge=e[53];const Me=ge;let Ne;e[54]!==O||e[55]!==i||e[56]!==w||e[57]!==S||e[58]!==s||e[59]!==b?(Ne=async()=>{if(!w||!O)return;const V=Array.from(S),{restoredIds:Q,failedIds:ue}=await b(V);Q.length>0&&We.success(Q.length===1?s("sessions.sidebar.bulkActions.restoredSingle",{count:Q.length}):s("sessions.sidebar.bulkActions.restoredPlural",{count:Q.length})),ue.length>0&&We.error(ue.length===1?s("sessions.sidebar.bulkActions.failedRestoreSingle",{count:ue.length}):s("sessions.sidebar.bulkActions.failedRestorePlural",{count:ue.length}),i(ue)),ts.getState().removeMany(Q)},e[54]=O,e[55]=i,e[56]=w,e[57]=S,e[58]=s,e[59]=b,e[60]=Ne):Ne=e[60];const Ie=Ne;let Te;e[61]!==v||e[62]!==pe||e[63]!==N||e[64]!==y?(Te=async()=>{if(!v)return;const V=N?.getSessionsById()??vd,Q=TC(v,V);if(!Q.ready){y(Q.value);return}y(null),await pe(Q.value.sessionIds,Q.value.archivedBucket)},e[61]=v,e[62]=pe,e[63]=N,e[64]=y,e[65]=Te):Te=e[65];const Le=Te;let _e,P;e[66]!==v||e[67]!==de||e[68]!==o||e[69]!==N||e[70]!==g?(_e=()=>{if(!g)return;const V=/Macintosh|Mac OS X/.test(navigator.userAgent||""),Q=ue=>{if(v||o)return;const Z=ue.target instanceof HTMLElement?ue.target:null;if(Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable))return;const ee=V?ue.metaKey:ue.ctrlKey;if(ue.key==="Escape"){ue.preventDefault(),ts.getState().disable();return}if(ee&&ue.key==="Backspace"){ue.preventDefault(),de();return}if(ee&&(ue.key==="a"||ue.key==="A")){const ke=e2(N?.getEntries()??[],N?.getDescendantIds()??[],ts.getState().scopeKey);if(!ke)return;ue.preventDefault(),ts.getState().replaceAll(ke.ids,ke.scopeKey)}};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},P=[v,de,o,N,g],e[66]=v,e[67]=de,e[68]=o,e[69]=N,e[70]=g,e[71]=_e,e[72]=P):(_e=e[71],P=e[72]),c.useEffect(_e,P);let oe;return e[73]!==I||e[74]!==D||e[75]!==O||e[76]!==Le||e[77]!==W||e[78]!==H||e[79]!==me||e[80]!==de||e[81]!==Me||e[82]!==re||e[83]!==Pe||e[84]!==Ie||e[85]!==w||e[86]!==h||e[87]!==g?(oe={selectionModeEnabled:g,hasSelection:w,selectedIdsSize:h,bulkScopeIsArchived:O,derivedSelectionScope:W,bulkScopeFolders:D,bulkCanRemoveFromFolder:I,handleToggleSelectionMode:C,handleExitSelectionMode:R,handleBulkMoveToFolder:re,handleBulkCreateFolderAndMove:me,handleBulkRemoveFromFolder:Pe,handleBulkDelete:de,handleBulkArchive:H,handleBulkHardDelete:Me,handleBulkRestore:Ie,confirmBulkDelete:Le},e[73]=I,e[74]=D,e[75]=O,e[76]=Le,e[77]=W,e[78]=H,e[79]=me,e[80]=de,e[81]=Me,e[82]=re,e[83]=Pe,e[84]=Ie,e[85]=w,e[86]=h,e[87]=g,e[88]=oe):oe=e[88],oe};function BC(t){return t.enabled}function FC(t){return t.selectedIds.size}function LC(t){return t.selectedIds}function _C(t){return t.scopeKey}function $C(){ts.getState().toggleMode()}function WC(){ts.getState().disable()}function KC(t){const e=Ye.c(37),{getFolderScopesForProject:s,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=ve(XC),d=ve(QC),u=qt(YC),f=qt(qC),p=qt(GC),m=qt(HC),b=Je(UC),x=Je(VC),v=Je(zC);let y;e[0]!==f||e[1]!==i?(y=N=>{const C=f(N,"New folder");return i(N,C),C},e[0]=f,e[1]=i,e[2]=y):y=e[2];let g;e[3]!==p||e[4]!==b||e[5]!==o||e[6]!==v||e[7]!==u||e[8]!==s||e[9]!==r||e[10]!==m||e[11]!==a||e[12]!==y||e[13]!==x?(g={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:s,addSessionsToFolder:p,removeSessionsFromFolders:m,createFolderAndStartRename:y,archiveSessions:b,unarchiveSessions:x,deleteSessions:v,bulkDeleteConfirm:o,setBulkDeleteConfirm:l},e[3]=p,e[4]=b,e[5]=o,e[6]=v,e[7]=u,e[8]=s,e[9]=r,e[10]=m,e[11]=a,e[12]=y,e[13]=x,e[14]=g):g=e[14];const h=OC(g);let w;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?(w=h.selectionModeEnabled?n.jsx(RC,{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]=w):w=e[28];let S;e[29]!==h.confirmBulkDelete||e[30]!==o||e[31]!==d||e[32]!==a?(S=n.jsx(E2,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:d,onConfirm:h.confirmBulkDelete}),e[29]=h.confirmBulkDelete,e[30]=o,e[31]=d,e[32]=a,e[33]=S):S=e[33];let j;return e[34]!==w||e[35]!==S?(j=n.jsxs(n.Fragment,{children:[w,S]}),e[34]=w,e[35]=S,e[36]=j):j=e[36],j}function zC(t){return t.deleteSessions}function VC(t){return t.unarchiveSessions}function UC(t){return t.archiveSessions}function HC(t){return t.removeSessionsFromFolders}function GC(t){return t.addSessionsToFolder}function qC(t){return t.createFolder}function YC(t){return t.foldersMap}function QC(t){return t.setShowDeletionDialog}function XC(t){return t.showDeletionDialog}const hp="oc.sessions.expandedParents.v3",JC=_a(Un()),ZC=()=>{try{const t=globalThis.localStorage.getItem(hp);if(t===null)return new Set;const e=JC.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},e3=()=>{const[t,e]=c.useState(ZC),s=c.useRef(t);s.current=t;const r=c.useCallback(i=>{const o=zb(s.current,i);s.current=o,e(o);try{globalThis.localStorage.setItem(hp,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},t3=t=>{const e=Ye.c(22),{childStores:s,sections:r,chatGroup:i,canGrantAccess:o}=t,l=gs(s3),a=gs(n3);let d;e[0]!==i||e[1]!==r?(d=[...r.flatMap(r3),...i?[{key:"activity:chats",group:i}]:[]].map(a3),e[0]=i,e[1]=r,e[2]=d):d=e[2];const u=d;let f;e[3]!==u?(f=new Set(u.flatMap(l3)),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 b;e[7]!==s||e[8]!==m.length?(b=w=>m.length>0?s.subscribeBootstrap(w):c3,e[7]=s,e[8]=m.length,e[9]=b):b=e[9];let x;e[10]!==s||e[11]!==m?(x=()=>m.map(w=>`${w}\0${s.getBootstrapState(w)??""}\0${s.getBootstrapFailure(w)??""}\0${s.getInitializationState(w)??""}\0${s.getInitializationFailure(w)??""}`).join(""),e[10]=s,e[11]=m,e[12]=x):x=e[12];const v=c.useSyncExternalStore(b,x,d3);let y;if(e[13]!==o||e[14]!==s||e[15]!==l||e[16]!==u||e[17]!==a){y=new Map;for(const{key:w,archived:S,directories:j}of u){const N=j.find(C=>s.getBootstrapState(C)==="failed"||s.getInitializationState(C)==="failed");if(N){const C=s.getBootstrapState(N)==="failed",R=C?s.getBootstrapFailure(N):s.getInitializationFailure(N);y.set(w,{state:R==="os-permission"?"permission-denied":C?"load-failed":"initialization-failed",directory:N,canGrantAccess:R==="os-permission"&&o})}else{const C=a||!S&&j.length>0&&j.every(R=>s.getBootstrapState(R)==="complete");y.set(w,{state:C?"ready":l==="error"?"load-failed":"loading",directory:C?j[0]??null:null,canGrantAccess:!1})}}e[13]=o,e[14]=s,e[15]=l,e[16]=u,e[17]=a,e[18]=y}else y=e[18];const g=y;let h;return e[19]!==v||e[20]!==g?(h={groupStatusByKey:g,bootstrapSnapshot:v},e[19]=v,e[20]=g,e[21]=h):h=e[21],h};function s3(t){return t.status}function n3(t){return t.hasLoaded}function r3(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function o3(t){return ut(t.directory)}function i3(t){return!!t}function a3(t){const{key:e,group:s}=t;return{key:e,archived:s.isArchivedBucket===!0,directories:Mr(s).map(o3).filter(i3)}}function l3(t){return t.directories}function c3(){}function d3(){return""}const u3=5*6e4,f3=[],Sd=[],jd=[],p3=t=>!t.parentID,m3=({topology:t,view:e,actions:s})=>{const{alwaysShowActions:r,notifyOnSubtasks:i,projectViewActions:o,rowActions:l,...a}=s,d=qt(Be=>Be.foldersMap),u=qt(Be=>Be.collapsedFolderIds),f=qt(Be=>Be.createFolder),p=qt(Be=>Be.addSessionToFolder),m=e.projectView,{getOrderedGroups:b,setGroupOrderByProject:x,toggleGroup:v,toggleProject:y}=o,g=gh({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),h=Vb(Be=>Be.projects),w=vm(),S=c.useMemo(()=>new Map(w.map(Be=>[Be.id,Be.name])),[w]),j=c.useMemo(()=>{const Be=new Map;for(const Ue of w){const lt=ut(Ue.projectDirectory);if(!lt)continue;const et=Be.get(lt);et?et.push(Ue):Be.set(lt,[Ue])}return Be},[w]),N=c.useMemo(()=>bh(g.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,g.archivedSessions,h,w),[h,g.archivedSessions,g.sessions,w,t.availableWorktreesByProject,t.isVSCode,t.projects]),[C,R]=c.useState(new Map),[T,O]=c.useState(new Set),[_,W]=c.useState(new Map),L=c.useCallback((Be,Ue,lt=7)=>{R(et=>new Map(et).set(Be,Ue+lt))},[]),K=c.useCallback(Be=>{R(Ue=>{if(!Ue.has(Be))return Ue;const lt=new Map(Ue);return lt.delete(Be),lt})},[]),A=cs(Be=>Be.showRecentSection),D=cs(Be=>Be.projectDisplayMode),E=cs(Be=>Be.singleProjectId),M=cs(Be=>Be.setSingleProjectId),I=!t.isVSCode&&!Sm()&&D==="single",U=e.sidebarViewMode==="timeline"&&!t.isVSCode,z=xh({enabled:A&&!I&&!U,isVSCode:t.isVSCode,pinnedSessionIds:g.pinnedSessionIds,sessionOrderRanks:g.sessionOrderRanks,sessions:g.rootSessions}),ce=c.useMemo(()=>Ub(g.rootSessions,Be=>ut(t.worktreeMetadata.get(Be.id)?.projectDirectory??Be.directory??null)),[g.rootSessions,t.worktreeMetadata]),re=c.useRef(null),Y=c.useMemo(()=>{const Be=Array.from(ce.runKeyBySessionId,([Ue,lt])=>`${Ue}\0${lt}`).sort().join("");return re.current?.signature!==Be&&(re.current={signature:Be,map:ce.runKeyBySessionId}),re.current.map},[ce]),[me,be]=c.useState(null),[Pe,le]=c.useState(null),[pe,je]=c.useState(""),[he,X]=c.useState(null),[de,fe]=c.useState(null),[H,ge]=c.useState(null),Me=c.useCallback((Be,Ue)=>{ge({scopeKey:Be,folderId:Ue.id,draft:Ue.name})},[]),Ne=c.useCallback(Be=>{ge(Ue=>Ue?{...Ue,draft:Be}:null)},[]),Ie=c.useCallback(()=>ge(null),[]),{expandedParents:Te,toggleParent:Le}=e3(),_e=Je(Be=>Be.setCurrentSession),P=c.useCallback((Be,Ue)=>{Be!==Je.getState().currentSessionId&&_e(Be,Ue)},[_e]),oe=Uu(),V=cs(Be=>Be.worktreeSortOrder),{buildGroupedSessions:Q,filterSessionNodesForSearch:ue,buildGroupSearchText:Z}=EC({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:g.pinnedSessionIds,sessionOrderRanks:g.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:V,sessionOwners:N.bySessionId,spacesByProject:j,runKeyBySessionId:Y}),{getSessionsForProject:ee,getArchivedSessionsForProject:ke}=lk({ownership:N}),ne=c.useMemo(()=>{if(t.isVSCode)return null;const Be=Hb(e.homeDirectory)??g.chatSessions.map(lt=>Ra(lt.directory)).find(Boolean)??null;if(!Be)return null;const Ue=Array.from(new Set([Be,...g.chatSessions.map(lt=>ut(lt.directory??null)).filter(Boolean)])).filter(lt=>!!lt).map(lt=>({scopeKey:lt,directory:lt}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Be,folderScopeKey:Be,folderScopes:Ue,draftTarget:"chat",sessions:g.chatSessions.filter(lt=>!lt.time?.archived&&p3(lt)).map(lt=>tr(g.childrenMap,lt))}},[g.chatSessions,g.childrenMap,t.isVSCode,e.homeDirectory]),q=c.useMemo(()=>ne?[ne]:f3,[ne]),{projectSections:ie,groupSearchDataByGroup:Ee,sectionsForRender:Ae,flatSectionsForRender:$e}=Ak({normalizedProjects:t.projects,getSessionsForProject:ee,getArchivedSessionsForProject:ke,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:Q,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:ue,buildGroupSearchText:Z,foldersMap:d,standaloneGroups:q}),Oe=e.onSearchMatchCountChange;c.useEffect(()=>()=>Oe(0),[Oe]);const qe=Wo(),ct=e.useGroupedSections?Ae:$e,Ve=c.useMemo(()=>e.showInlineArchived?ct:ct.map(Be=>Be.groups.some(Ue=>Ue.isArchivedBucket)?{...Be,groups:Be.groups.filter(Ue=>!Ue.isArchivedBucket)}:Be),[ct,e.showInlineArchived]),nt=c.useCallback(Be=>$e.find(lt=>lt.project.id===Be)?.groups.find(lt=>!lt.isArchivedBucket)?.folderScopes??[],[$e]);tk({enabled:!0,normalizedProjects:t.projects,ownership:N,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:g.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:d,createFolder:f,addSessionToFolder:p});const{github:kt}=hn(),dt=mn(Be=>Be.status),yt=mn(Be=>Be.hasChecked),_t=ys(Be=>Be.ensureEntry),Bt=ys(Be=>Be.setParams),Lt=ys(Be=>Be.refreshTargets),Rt=c.useRef(new Set),Et=c.useMemo(()=>new Map(g.orderedSessions.map((Be,Ue)=>[Be.id,Ue])),[g.orderedSessions]),Nt=c.useMemo(()=>V!=="manual"?Ve:Ve.map(Be=>{const Ue=b(Be.project.id,Be.groups);return Ue===Be.groups?Be:{...Be,groups:Ue}}),[b,Ve,V]),ye=c.useMemo(()=>{const Be=new Map(z.map(ft=>[ft.id,tr(g.childrenMap,ft)])),Ue=[...Be.values()],lt=[];for(;Ue.length>0;){const ft=Ue.pop();if(!ft)break;lt.push(ft.session),Ue.push(...ft.children)}const et=di({sessions:lt,projects:t.projects,ownerBySessionId:N.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,hideBranchMatchingProjectLabel:!0});return yh({sessions:z,getSessionLocation:ft=>et.get(ft)??null,getSessionNode:ft=>Be.get(ft.id)??tr(g.childrenMap,ft),query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""})},[g.childrenMap,N.bySessionId,z,S,t.availableWorktreesByProject,t.gitBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),He=c.useMemo(()=>{if(!U)return Sd;const Be=new Set(g.rootSessions.map(et=>et.id)),Ue=g.orderedSessions.filter(et=>Be.has(et.id)&&!et.time?.archived),lt=di({sessions:Ue,projects:t.projects,ownerBySessionId:N.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return kl({sessions:Ue,getSessionLocation:et=>lt.get(et)??null,getSessionNode:et=>({...tr(g.childrenMap,et),children:[],worktree:lt.get(et.id)?.worktree??null}),query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""})},[g.childrenMap,g.orderedSessions,g.rootSessions,N.bySessionId,S,U,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),mt=ve(Be=>Be.sessionWorkEnabled),Ke=c.useMemo(()=>{if(!mt)return jd;const Be=g.orderedSessions.filter(Ue=>!Ue.parentID&&!Ue.time?.archived&&!Ma(Ue.directory)&&Gu(Ue));return Be.length>0?Be:jd},[g.orderedSessions,mt]),B=c.useMemo(()=>new Set(Ke.map(Be=>Be.id)),[Ke]),Se=c.useMemo(()=>{if(Ke.length===0)return Sd;const Be=di({sessions:[...Ke],projects:t.projects,ownerBySessionId:N.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!U}),Ue=new Map(Ke.map(ft=>{const Ct=tr(g.childrenMap,ft),it={...Ct,children:U?[]:Ct.children,worktree:Be.get(ft.id)?.worktree??null};return[ft.id,it]})),lt=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",et=lt?Ke.filter(ft=>{const Ct=Ue.get(ft.id);return Ct?wh(Ct,lt):!1}):[...Ke];return kl({sessions:et,getSessionLocation:ft=>Be.get(ft)??null,getSessionNode:ft=>Ue.get(ft.id)??tr(g.childrenMap,ft),query:""})},[g.childrenMap,N.bySessionId,S,U,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery,Ke]),Fe=c.useMemo(()=>{const Be=new Map,Ue=new Map,lt=new Map,et=(Ct,it)=>{const Tt=it?.trim();Ct&&Tt&&Be.set(_o(Ct,Tt),{directory:Ct,branch:Tt})},ft=Ct=>{if(et(ut(Ct.worktree?.path??null),Ct.worktree?.branch),!t.isVSCode){for(const it of zu(Ct.session))Ue.set(`${it.owner.toLowerCase()}/${it.repo.toLowerCase()}#${it.number}`,{owner:it.owner,repo:it.repo,number:it.number});for(const it of Oa(Ct.session))it.source==="github"&<.set(`${it.owner.toLowerCase()}/${it.repo.toLowerCase()}#${it.number}`,{owner:it.owner,repo:it.repo,number:it.number})}Ct.children.forEach(ft)};return Se.forEach(Ct=>ft(Ct.node)),U?(He.forEach(Ct=>ft(Ct.node)),{targets:Be,linkedRefs:[...Ue.values()],linkedIssueRefs:[...lt.values()]}):(ye.forEach(Ct=>Ct.items.forEach(it=>ft(it.node))),ie.forEach(Ct=>{m.collapsedProjects.has(Ct.project.id)||Ct.groups.forEach(it=>{if(it.isArchivedBucket||(it.sessions.forEach(ft),it.isMain))return;const Tt=ut(it.directory??null);et(Tt,it.branch?.trim()||t.gitBranches.get(Tt||""))})}),{targets:Be,linkedRefs:[...Ue.values()],linkedIssueRefs:[...lt.values()]})},[ie,m.collapsedProjects,ye,He,U,t.gitBranches,t.isVSCode,Se]),$=Fe.targets,se=c.useMemo(()=>[...$.keys()],[$]),we=!!(yt&&dt?.connected);c.useEffect(()=>{if(!kt||!we)return;const Be=new Map,Ue=Date.now();$.forEach(({directory:lt,branch:et},ft)=>{const Ct=ys.getState().entries[ft],it=Ct?.status?.pr?.state==="closed"||Ct?.status?.pr?.state==="merged",Tt=`${lt}::${et}`,$t=Math.max(Ct?.lastRefreshAt??0,Ct?.lastDiscoveryPollAt??0),ss=!!(Ct?.isInitialStatusResolved&&(!Ct.status?.pr||it)&&(!Rt.current.has(Tt)||Ue-$t>=u3));(!Ct||!Ct.isInitialStatusResolved||ss)&&(ss&&Rt.current.add(Tt),Be.set(ft,{directory:lt,branch:et}))}),Be.forEach((lt,et)=>{_t(et),Bt(et,{...lt,remoteName:null,canShow:!0,github:kt,githubAuthChecked:yt,githubConnected:we})}),Be.size&&Lt([...Be.values()],{silent:!0,markInitialResolved:!0})},[_t,kt,yt,we,Lt,Bt,$]),Z0(se,Fe.linkedRefs,Fe.linkedIssueRefs,kt,we);const{groupStatusByKey:tt,bootstrapSnapshot:rt}=t3({childStores:qe,sections:Nt,chatGroup:ne,canGrantAccess:Ud()});let Xe=null;I&&(ie.some(Be=>Be.project.id===E)?Xe=E:ie.some(Be=>Be.project.id===e.activeProjectId)?Xe=e.activeProjectId:Xe=ie[0]?.project.id??null);const G=c.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:Ee,collapsedGroups:m.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:i,pinnedSessionIds:g.pinnedSessionIds,sessionOrderIndex:Et,expandedParents:Te,editingId:me,editingRowKey:Pe,editTitle:pe,sessionBatchSize:I&&!e.useGroupedSections?20:void 0,setEditingId:be,setEditingRowKey:le,setEditTitle:je,toggleParent:Le,allowReselect:l.allowReselect,onSessionSelected:l.onSessionSelected,resetSessionSearch:l.resetSessionSearch,deleteSessionConfirm:de,setDeleteSessionConfirm:fe,startFolderRename:Me,startSessionWorktreeMenuLoad:s.startSessionWorktreeMenuLoad,onEditProject:U?a.openProjectEditDialog:void 0,folderRename:H,setFolderRenameDraft:Ne,clearFolderRename:Ie}),[g.pinnedSessionIds,r,i,m.collapsedGroups,Ee,Et,pe,me,Pe,Te,H,Ne,Ie,Me,de,s.startSessionWorktreeMenuLoad,a.openProjectEditDialog,U,l,Le,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,I]),Ce=c.useMemo(()=>({showMoreGroupSessions:L,resetGroupSessionLimit:K,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,onToggleCollapsedGroup:v}),[K,L,v,a.openNewSessionDraft,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen]),bt=c.useMemo(()=>{const Be=new Map;for(const Ue of Nt)for(const lt of Ue.groups){const et=Dn(Ue.project.id,lt.directory);if(!et)continue;const ft=Mr(lt),Ct=Be.get(et),it=[...new Set([...Ct?.scopeKeys??[],...ft.map($t=>$t.scopeKey)])],Tt=g.hasAuthoritativeGlobalSessions&&ft.every($t=>{const ss=ut($t.directory);return!ss||qe.getBootstrapState(ss)==="complete"});Be.set(et,{scopeKeys:it,complete:(Ct?.complete??!0)&&Tt})}if(ne){const Ue=Dn(null,ne.directory);Ue&&Be.set(Ue,{scopeKeys:Mr(ne).map(lt=>lt.scopeKey),complete:g.hasAuthoritativeGlobalSessions})}return Be},[rt,ne,qe,g.hasAuthoritativeGlobalSessions,Nt]),xe=c.useMemo(()=>new Map([...C,..._]),[_,C]),xt=c.useMemo(()=>kk({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:U?"timeline":"projects",sections:Nt,authoritativeSections:ie,chatGroup:ne,recentSections:ye,timelineItems:He,workItems:Se,workSessionIds:B,showRecentSection:A&&!I&&!U,foldersMap:d,groupSearchDataByGroup:Ee,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:m.collapsedProjects,collapsedGroups:m.collapsedGroups,collapsedFolders:u,collapsedActivities:T,expandedParents:Te,visibleCountByContainer:xe,pinnedSessionIds:g.pinnedSessionIds,sessionOrderIndex:Et,groupStatusByKey:tt,folderAuthorityByOwner:bt,activeProjectId:e.activeProjectId,singleProjectMode:I&&!U,singleProjectId:Xe,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:I&&!e.useGroupedSections?20:void 0,runIndex:ce}),[ce,ne,T,He,U,Se,B,u,g.pinnedSessionIds,Te,bt,d,Ee,tt,Nt,ie,m.collapsedGroups,m.collapsedProjects,ye,Xe,Et,A,I,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,xe]);c.useEffect(()=>{Oe(xt.searchMatchCount)},[Oe,xt.searchMatchCount]);const Mt=c.useMemo(()=>({rowModel:xt,sectionsForRender:Nt,projectSections:ie,singleProjectMode:I,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:me,openSidebarMenuKey:he,setOpenSidebarMenuKey:X,visibleSessionCountByGroup:C,collapsedActivityKeys:T,setCollapsedActivityKeys:O,visibleActivityCountByKey:_,setVisibleActivityCountByKey:W},groupProps:G}),[G,me,he,ie,Nt,xt,t.projectRepoStatus,e.emptyState,e.searchEmptyState,C,_,T,I]),pt=c.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,stickyZoneHeaders:e.stickyZoneHeaders,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:V,timelineView:U}),[U,V,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder,e.stickyZoneHeaders]),at=c.useMemo(()=>({group:Ce,toggleProject:y,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:M}),[Ce,a.openNewSessionDraft,a.openNewWorktreeDialog,a.openProjectEditDialog,a.openWorktreesPage,a.removeProject,a.reorderProjects,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen,x,y,a.renderProjectStatusIndicator,M]);return n.jsxs(n.Fragment,{children:[n.jsx(G0,{}),n.jsx(ok,{projectSections:ie,activeProjectId:e.activeProjectId,initialActiveSessionByProject:s.initialActiveSessionByProject,persistActiveSessionByProject:s.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:s.openNewSessionDraft,setSessionSwitcherOpen:s.setSessionSwitcherOpen,sessionOwnerBySessionId:N.bySessionId,handleSessionSelect:P}),n.jsx(Mk,{sortedSessions:g.orderedSessions,recentSessions:z,prefetchSession:oe}),n.jsxs(Zk,{entries:xt.selectionEntries,descendantIds:xt.selectionDescendantIds,sessionsById:xt.sessionById,children:[n.jsx(KC,{getFolderScopesForProject:nt,isInlineEditing:me!==null,startFolderRename:Me}),n.jsx(DC,{model:Mt,view:pt,actions:at})]})]})},h3=t=>{const e=Ye.c(2);let s;return e[0]!==t?(s=t.view.isVisible?n.jsx(m3,{...t}):null,e[0]=t,e[1]=s):s=e[1],s},gp=(t,e,s)=>{const r=new Set;for(const i of t){const o=ut(i.path);o&&r.add(o)}if(s?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=ut(o.path);l&&r.add(l)}return r},kd="oc.sessions.activeSessionByProject",g3=[],b3=uf(Un(),Un().min(1).catch("")),x3=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:s,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{Ri("react.session_sidebar_render"),vs("ui.session_sidebar.render"),vs(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),vs(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=jt(),[a,d]=c.useState(!1),[u,f]=c.useState(""),p=c.useCallback(()=>{f(""),d(!1)},[]),[m,b]=c.useState(0),x=c.useRef(null),v=c.useRef(null),[y,g]=c.useState(null),h=c.useMemo(()=>Co(),[]),[w,S]=c.useState(new Map),j=ve(xe=>xe.isNewWorktreeDialogOpen),N=ve(xe=>xe.setNewWorktreeDialogOpen),[C,R]=c.useState(!1),T=c.useMemo(()=>{try{const xe=h.getItem(kd);if(!xe)return new Map;const xt=b3.safeParse(JSON.parse(xe));if(!xt.success)return new Map;const Mt=new Map;return Object.entries(xt.data).forEach(([pt,at])=>{at&&Mt.set(pt,at)}),Mt}catch{return new Map}},[h]),O=c.useCallback(xe=>{try{h.setItem(kd,JSON.stringify(Object.fromEntries(xe.entries())))}catch{}},[h]),[_,W]=c.useState(new Map),L=is(xe=>xe.homeDirectory),K=Vt(xe=>xe.projects),A=Vt(xe=>xe.activeProjectId),D=Vt(xe=>xe.removeProject),E=Vt(xe=>xe.setActiveProjectIdOnly),M=Vt(xe=>xe.updateProjectMeta),k=Vt(xe=>xe.reorderProjects),I=ve(xe=>xe.setSettingsDialogOpen),U=ve(xe=>xe.toggleHelpDialog),z=ve(xe=>xe.setAboutDialogOpen),ce=ve(xe=>xe.setSessionSwitcherOpen),re=ve(xe=>xe.setScheduledTasksDialogOpen),Y=ve(xe=>xe.setArchivePageOpen),me=ve(xe=>xe.setUsageStatsPageOpen),be=ve(xe=>xe.setWorktreesPageProjectId),Pe=ve(xe=>xe.notifyOnSubtasks),le=c.useMemo(()=>u.trim().toLowerCase(),[u]),pe=le.length>0;g0({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:v,sessionSearchContainerRef:x});const je=Ru(t),he=c.useMemo(()=>_s(),[]),X=Je(xe=>xe.setCurrentSession),de=Je(xe=>xe.worktreeMetadata),fe=Je(xe=>xe.availableWorktreesByProject),H=Je(xe=>xe.openNewSessionDraft),ge=c.useMemo(()=>gp(K,fe,{includeWorktrees:!he}),[fe,he,K]),Me=c.useCallback(xe=>{ve.getState().closeMainSurfaces(),H(xe),he&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[he,H]),Ne=Nr(Vn(xe=>({checkForUpdates:xe.checkForUpdates,available:xe.available,runtimeType:xe.runtimeType,info:xe.info,downloading:xe.downloading,downloaded:xe.downloaded,progress:xe.progress,error:xe.error,downloadUpdate:xe.downloadUpdate,restartToUpdate:xe.restartToUpdate}))),Ie=Qt(),Te=c.useMemo(()=>`${Ie}|${K.map(xe=>`${xe.id}:${ut(xe.path)??""}`).join("|")}`,[K,Ie]),[Le,_e]=c.useState(he?Te:null),[P,oe]=c.useReducer(xe=>xe+1,0),V=!he&&Le!==Te,[Q,ue]=c.useState(new Set),Z=c.useRef(Q);Z.current=Q;const ee=es(xe=>xe.isConnected),ke=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let xe=!1;return(async()=>{const Mt=Ie,pt=es.getState().isConnected,at=Vt.getState().projects;if(Je.setState({worktreeDiscoveryByProject:new Map(at.map(Re=>[ut(Re.path)??Re.path,"loading"]))}),at.length===0||he){xe||(ke.current={runtimeKey:null,revision:0,worktreesByProject:new Map},ue(new Set),_e(Te));return}const Be=Je.getState().availableWorktreesByProject,Ue=Qa({rawWorktreesByProjectRef:ke,publishedWorktreesByProject:Be,runtimeKey:Mt}),lt=Ue.revision,et=new Map(Ue.worktreesByProject),ft=new Set,Ct=3;let it=0;const Tt=Array.from({length:Ct},async()=>{for(;;){const Re=it;if(it+=1,Re>=at.length)return;const Ze=at[Re],ot=ut(Ze.path);if(ot)try{const gt=await Wi(async()=>Yn.getState().directories.get(ot)?.isGitRepo??await fu(ot)?Kl({id:Ze.id,path:ot}):null);if(gt===null){et.delete(ot);continue}if(xe)return;gt.length===0?et.delete(ot):et.set(ot,gt)}catch{ft.add(ot)}}});if(await Promise.all(Tt),xe||Qt()!==Mt)return;const $t=new Set(at.map(Re=>ut(Re.path)).filter(Boolean));for(const Re of et.keys())$t.has(Re)||et.delete(Re);p2({rawWorktreesByProjectRef:ke,runtimeKey:Mt,capturedRevision:lt,nextRawWorktreesByProject:et,publishedWorktreesByProject:Be,partitionWorktreesByRegisteredProject:Wl,projects:at,worktreeMapsEqual:$l,recordWorktreesSeen:yd,publishTopology:Re=>{Je.setState(Re)},requestRediscovery:()=>{oe()},now:()=>Date.now()})&&(ue(ft),Je.setState({worktreeDiscoveryByProject:new Map(at.map(Re=>{const Ze=ut(Re.path)??Re.path;return[Ze,ft.has(Ze)?"error":"ready"]}))}),_e(Te),ft.size>0&&!pt&&es.getState().isConnected&&oe())})(),()=>{xe=!0}},[he,Te,Ie,P]),c.useEffect(()=>{ee&&Z.current.size>0&&oe()},[ee]);const ne=c.useMemo(()=>pn(),[]),{isTablet:q}=Tn(),ie=e||q,Ee=c.useMemo(()=>n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[n.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),n.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),Ae=c.useMemo(()=>K.find(xe=>xe.id===y)??null,[K,y]),$e=c.useCallback(xe=>{y&&M(y,{label:xe.label,icon:xe.icon,color:xe.color,iconBackground:xe.iconBackground,defaultAgent:xe.defaultAgent??null,defaultModel:xe.defaultModel??null,defaultVariant:xe.defaultVariant??null})},[y,M]),Oe=c.useCallback(()=>{N(!0)},[N]),qe=c.useCallback(()=>{const xe=Nr.getState();if(xe.available&&xe.info){R(!0);return}Ne.checkForUpdates().then(()=>{const{available:xt,error:Mt}=Nr.getState();if(Mt){We.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:Mt});return}if(!xt){We.success(l("sessions.sidebar.updateCheck.latestVersion"));return}R(!0)})},[l,Ne]),ct=c.useCallback(()=>{e&&ce(!1),I(!0)},[e,ce,I]),Ve=Ne.available&&(Ne.runtimeType==="desktop"||Ne.runtimeType==="web"),nt=c.useCallback(()=>{Hs.requestDirectoryDialog()},[]),kt=c.useMemo(()=>K.flatMap(xe=>{const xt=ut(xe.path);return xt?[{id:xe.id,path:xe.path,label:xe.label,normalizedPath:xt,icon:xe.icon??void 0,color:xe.color??void 0,iconImage:xe.iconImage??void 0,iconBackground:xe.iconBackground??void 0,addedAt:xe.addedAt,lastOpenedAt:xe.lastOpenedAt,sidebarCollapsed:xe.sidebarCollapsed}]:[]}),[K]),dt=c.useMemo(()=>kt.map(xe=>xe.normalizedPath),[kt]),yt=Gb(t?dt:g3);k0({enabled:t,normalizedProjects:kt,gitRepoStatus:yt,setProjectRepoStatus:S,setProjectRootBranches:W});const _t=Je(xe=>xe.isLoading),Bt=c.useRef(!1);A&&w.has(A)&&(Bt.current=!!w.get(A));const Lt=cs(xe=>xe.showArchivedSessions),Rt=cs(xe=>xe.projectSortOrder),Et=cs(xe=>xe.sidebarViewMode),Nt=Vt(xe=>xe.manualProjectOrder),ye={isVisible:t,mobileVariant:e,onSessionSelected:s,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:q,projects:K,activeProjectId:A,manualProjectOrder:Nt,worktreeMetadata:de,availableWorktreesByProject:fe,gitBranches:je,gitRepoStatus:yt,updateStore:Ne,showArchivedSessions:Lt,projectSortOrder:Rt,projectRepoStatus:w,projectRootBranches:_,resolvedWorktreeTopologyKey:Le,unresolvedWorktreeProjectPaths:Q,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:y,updateDialogOpen:C},He=c.useRef(null),mt=He.current;if(mt){let xe=!1;for(const xt of Object.keys(ye))Object.is(mt[xt],ye[xt])||(vs(`ui.session_sidebar.source.${xt}`),xe=!0);xe||vs("ui.session_sidebar.source.parent_or_context")}He.current=ye;const Ke=c.useMemo(()=>vh(kt,Rt,Nt),[kt,Rt,Nt]),B=w0({isVSCode:he,projects:Ke}),Se=c.useMemo(()=>n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[n.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noMatches.title")}),n.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noMatches.description")})]}),[l]),Fe=he&&Lt,$=!he,se=he?"projects":Et,we=se==="projects",Xe=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",G="h-4.5 w-4.5",Ce=c.useMemo(()=>({projects:K,getCurrentProjects:()=>Vt.getState().projects,rawWorktreesByProjectRef:ke,getPublishedWorktreesByProject:()=>Je.getState().availableWorktreesByProject,resolveProject:xe=>Fi(xe),listProjectWorktrees:Kl,partitionWorktreesByRegisteredProject:Wl,worktreeMapsEqual:$l,recordWorktreesSeen:yd,publishTopology:xe=>{Je.setState(xe)},getRuntimeKey:Qt,now:()=>Date.now()}),[K]),bt=c.useCallback(xe=>{const xt=up(xe,{projects:K,resolveProject:Fi});return f2(xe,{...Ce,projectRootBranch:xt?_.get(xt.id)??null:null})},[_,K,Ce]);return c.useEffect(()=>{if(!he)return Qn(xe=>{if(xe.type==="session-created"){oe();return}if(xe.type==="worktree-changed")for(const xt of qb(xe.directories)){const Mt=ut(xt.path),pt=Qt(),at=Be=>{!Mt||Qt()!==pt||Je.setState(Ue=>({worktreeDiscoveryByProject:new Map(Ue.worktreeDiscoveryByProject).set(Mt,Be)}))};at("loading"),cp(xt,null,Ce).then(()=>{!Mt||Qt()!==pt||(at("ready"),ue(Be=>{if(!Be.has(Mt))return Be;const Ue=new Set(Be);return Ue.delete(Mt),Ue}))}).catch(()=>{!Mt||Qt()!==pt||(at("error"),ue(Be=>new Set(Be).add(Mt)))})}})},[he,Ce]),n.jsx(Vi,{delay:400,closeDelay:0,timeout:300,children:n.jsxs("div",{ref:x,className:De("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[n.jsx(D0,{hideDirectoryControls:i,showProjectDisplayControls:!he,showRecentControls:!he,handleOpenDirectoryDialog:nt,onOpenScheduled:()=>{e&&ce(!1),re(!0)},onOpenArchive:()=>{e&&ce(!1),Y(!0)},headerActionIconClass:G,headerActionButtonClass:Xe,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:v,sessionSearchQuery:u,setSessionSearchQuery:f,hasSessionSearchQuery:pe,searchMatchCount:m,collapseAllProjects:B.actions.collapseAllProjects,expandAllProjects:B.actions.expandAllProjects}),n.jsx(h3,{topology:{projects:Ke,availableWorktreesByProject:fe,knownDirectories:ge,isVSCode:he,worktreeMetadata:de,gitBranches:je,projectRepoStatus:w,projectRootBranches:_,lastRepoStatus:Bt.current},view:{isVisible:t,hasSessionSearchQuery:pe,normalizedSessionSearchQuery:le,activeProjectId:A,showInlineArchived:Fe,useGroupedSections:$,homeDirectory:L,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:ne,stickyZoneHeaders:we,projectSortOrder:Rt,sidebarViewMode:se,emptyState:Ee,searchEmptyState:Se,isSessionsLoading:_t,isWorktreeTopologyLoading:V,unresolvedWorktreeProjectPaths:Q,projectView:B.state,onSearchMatchCountChange:b},actions:{rowActions:{allowReselect:r,onSessionSelected:s,resetSessionSearch:p},alwaysShowActions:ie,notifyOnSubtasks:Pe,setActiveProjectIdOnly:E,setSessionSwitcherOpen:ce,openNewSessionDraft:Me,openNewWorktreeDialog:Oe,openWorktreesPage:xe=>{e&&ce(!1),be(xe)},openProjectEditDialog:g,removeProject:D,reorderProjects:k,startSessionWorktreeMenuLoad:bt,initialActiveSessionByProject:T,persistActiveSessionByProject:O,projectViewActions:B.actions}}),n.jsx(U0,{onOpenSettings:ct,onOpenUsage:()=>me(!ve.getState().isUsageStatsPageOpen),onOpenShortcuts:U,onOpenAbout:()=>z(!0),onOpenUpdate:qe,showRuntimeButtons:!he,showUpdateButton:Ve}),n.jsx(qd,{open:C,onOpenChange:R,info:Ne.info,downloading:Ne.downloading,downloaded:Ne.downloaded,progress:Ne.progress,error:Ne.error,onDownload:Ne.downloadUpdate,onRestart:Ne.restartToUpdate,runtimeType:Ne.runtimeType}),n.jsx(I0,{open:!!Ae,onOpenChange:xe=>{xe||g(null)},project:Ae,onSave:$e}),n.jsx(Sh,{open:j,onOpenChange:N,onWorktreeCreated:(xe,xt)=>{if(ve.getState().closeMainSurfaces(),e&&ce(!1),xt?.sessionId){X(xt.sessionId,xe);return}H({directoryOverride:xe,preserveDirectoryOverride:!0})}})]})})},y3=c.memo(x3),an=t=>t?n.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,Ls=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},w3=()=>{const{t}=jt(),[e,s]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,d]=c.useState([]),[u,f]=c.useState(!1),[p,m]=c.useState(!1),[b,x]=c.useState(!1),[v,y]=c.useState(!1),[g,h]=c.useState(new Set),w=Je(P=>P.getWorktreeMetadata),S=Je(P=>P.newSessionDraft),j=Je(P=>P.setNewSessionDraftTarget),N=Je(P=>P.setDraftBootstrapPendingDirectory),C=Yb,R=Je(P=>P.deleteSessions),T=Je(P=>P.archiveSessions),O=ve(P=>P.showDeletionDialog),_=ve(P=>P.setShowDeletionDialog),W=is(P=>P.currentDirectory),L=is(P=>P.homeDirectory),K=is(P=>P.isHomeReady),A=Vt(P=>P.projects),D=Vt(P=>P.activeProjectId),{isMobile:E,isTablet:M,hasTouchInput:k}=Tn(),I=E||M||k,U=c.useMemo(()=>{const oe=(D?A.find(V=>V.id===D)??null:null)?.path??W;return Ls(oe)},[D,W,A]),z=c.useCallback(P=>{const V=Ls(P.projectDirectory)||U;return{id:(A.find(ue=>Ls(ue.path)===V)??null)?.id??`path:${V}`,path:V}},[U,A]),ce=v&&g.size>0,re=c.useMemo(()=>{const P=o?.worktree;return P&&typeof P.branch=="string"&&P.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:oe})=>typeof oe.branch=="string"&&oe.branch.trim().length>0)},[o?.worktree,a]),Y=o?.mode==="worktree",me=Y,be=b||!Y||!re,Pe=b||!Y;c.useEffect(()=>{r||!K||A.length>0||(i(!0),s(!0))},[r,K,A.length]);const le=c.useCallback(P=>{l({sessions:P.sessions,dateLabel:P.dateLabel,mode:P.mode??"session",worktree:P.worktree??null})},[]),pe=c.useCallback(()=>{l(null),d([]),f(!1),m(!1),x(!1),y(!1),h(new Set)},[]),je=c.useCallback(async P=>{if(P.sessions.length===0)return;if(P.sessions.length===1){const ue=P.sessions[0];await C(ue.id)?We.success(t("sessions.sidebar.session.delete.success")):We.error(t("sessions.sidebar.session.delete.error"));return}const oe=P.sessions.map(ue=>ue.id),{deletedIds:V,failedIds:Q}=await R(oe);if(V.length>0){const ue=Q.length>0?Q.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Q.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Q.length}):P.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:P.dateLabel}):void 0;We.success(V.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:V.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:V.length}),{description:an(ue)})}Q.length>0&&We.error(Q.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Q.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Q.length}),{description:an(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[C,R,t]);c.useEffect(()=>Hs.onDirectoryRequest(()=>{s(!0)}),[]),c.useEffect(()=>{if(!o){d([]),f(!1),m(!1),y(!1),h(new Set);return}const P=o.sessions.map(Q=>{const ue=w(Q.id);return ue?{session:Q,metadata:ue}:null}).filter(Q=>!!Q);d(P),f(!1),y(!1),h(new Set);const oe=new Map;if(o.worktree?.path&&oe.set(Ls(o.worktree.path),o.worktree),P.forEach(({metadata:Q})=>{Q.path&&oe.set(Ls(Q.path),Q)}),oe.size===0){y(!0);return}let V=!1;return(async()=>{const Q=new Map,ue=new Set;await Promise.all(Array.from(oe.entries()).map(async([Z,ee])=>{try{const ke=await zl(ee.path);Q.set(Z,ke),ke?.isDirty&&ue.add(Z)}catch{ee.status&&(Q.set(Z,ee.status),ee.status.isDirty&&ue.add(Z))}})).catch(Z=>{console.warn("Failed to inspect worktree status before deletion:",Z)}),!V&&(h(ue),y(!0),l(Z=>{if(!Z?.worktree?.path)return Z;const ee=Ls(Z.worktree.path),ke=Q.get(ee);if(!ke)return Z;const ne=Z.worktree.status;return ne?.isDirty===ke.isDirty&&ne?.ahead===ke.ahead&&ne?.behind===ke.behind&&ne?.upstream===ke.upstream?Z:{...Z,worktree:{...Z.worktree,status:ke}}}),d(Z=>Z.map(ee=>{const ke=Ls(ee.metadata.path),ne=Q.get(ke);return ne?{session:ee.session,metadata:{...ee.metadata,status:ne}}:ee})))})(),()=>{V=!0}},[o,w]),c.useEffect(()=>{re||f(!1)},[re]);const he=c.useCallback(async(P,oe,V)=>{const Q=u&&re,ue=z(P),Z=Ls(P.path),ee=Ls(ue.path);try{await pu(ue,P,{deleteRemoteBranch:Q,deleteLocalBranch:oe});const ke=Ls(S?.directoryOverride);return S?.open&&Z&&ke===Z&&ee&&(N(null),j({projectId:ue.id,directoryOverride:ee},{force:!0})),Ls(W)===Z&&ee&&is.getState().setDirectory(ee,{showOverlay:!1}),!0}catch(ke){return We.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:fi(P)}),{id:V,description:an(ke instanceof Error?ke.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[re,W,u,z,S?.directoryOverride,S?.open,N,j,t]),X=c.useCallback((P,oe,V)=>{const Q=u&&re,ue=We.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:fi(P)}));return(async()=>{try{if(oe.length>0){const{failedIds:ke}=await T(oe);if(ke.length>0){We.error(ke.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:ke.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:ke.length}),{id:ue,description:an(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await he(P,V,ue))return;const ee=t(Q?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");We.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:fi(P)}),{id:ue,description:an(ee)})}catch(Z){We.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:ue,description:an(Z instanceof Error?Z.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[T,re,u,he,t]),de=c.useRef(new Set),fe=c.useCallback(async(P,oe)=>{const V=Ls(P.path);if(!de.current.has(V)){de.current.add(V);try{const Q=await zl(P.path).catch(()=>{});if(!Qb(Q)){le({sessions:oe,mode:"worktree",worktree:P});return}await X(P,oe.map(ue=>ue.id),!0)}finally{de.current.delete(V)}}},[le,X]);c.useEffect(()=>Hs.onDeleteRequest(P=>{if(!O&&(P.mode??"session")==="session"){je(P);return}if(P.mode==="worktree"&&P.skipDialogIfSafe&&P.worktree){fe(P.worktree,P.sessions);return}le(P)}),[le,O,je,fe]);const H=c.useCallback(async()=>{if(o){x(!0);try{const P=me,oe=P&&u,V=P&&p;if(Y&&o.worktree){X(o.worktree,o.sessions.map(Q=>Q.id),V),pe();return}if(o.sessions.length===1){const Q=o.sessions[0];if(!await C(Q.id)){We.error(t("sessions.sidebar.session.delete.error")),x(!1);return}const Z=!Y&&P?t(oe?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;We.success(t("sessions.sidebar.session.delete.success"),{description:an(Z),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const Q=o.sessions.map(ke=>ke.id);let ue=[],Z=[];const ee=await R(Q);if(ue=ee.deletedIds,Z=ee.failedIds,ue.length>0){const ke=!Y&&P?t(oe?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,q=[Z.length>0?Z.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Z.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Z.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,ke].filter(Boolean).join(" ");We.success(ue.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ue.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ue.length}),{description:an(q||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(Z.length>0&&(We.error(Z.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Z.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Z.length}),{description:an(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ue.length===0)){x(!1);return}}pe()}finally{x(!1)}}},[o,u,p,C,R,pe,me,Y,X,t]),ge=o?.worktree??a[0]?.metadata??null,Me=o?o.mode==="worktree"?o.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):o.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:o.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:o.sessions.length}):o.sessions.length===1?o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:o.sessions.length,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:o.sessions.length}):"",Ne=o?n.jsxs("div",{className:De(Y?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&n.jsxs("div",{className:De(Y?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[Y&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),n.jsxs("ul",{className:De(Y?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(P=>n.jsxs("li",{className:De(Y?"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:[n.jsx("span",{className:De(!Y&&"hidden"),children:"•"}),n.jsx("span",{className:"truncate",children:P.title||t("sessions.sidebar.session.untitled")})]},P.id)),o.sessions.length>5&&n.jsx("li",{className:De(Y?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),Y?n.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(F,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),ge?.label?n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:ge.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:ge?Rr(ge.path,L):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),ce&&n.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):n.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Ie=Y?re?n.jsxs("button",{type:"button",onClick:()=>{be||f(P=>!P)},disabled:be,className:De("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",be?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[u?n.jsx(F,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(F,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):n.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,Te=Y?n.jsxs("button",{type:"button",onClick:()=>{Pe||m(P=>!P)},disabled:Pe,className:De("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?n.jsx(F,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(F,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Le=Y?n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col items-start gap-1",children:[Te,Ie]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ht,{variant:"ghost",onClick:pe,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ht,{variant:"destructive",onClick:H,disabled:b,children:t(b?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("button",{type:"button",onClick:()=>_(!O),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":!O,children:[O?n.jsx(F,{name:"checkbox-blank",className:"size-4"}):n.jsx(F,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ht,{variant:"ghost",onClick:pe,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ht,{variant:"destructive",onClick:H,disabled:b,children:b?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),_e=Y?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[I?n.jsx(ju,{open:!!o,onClose:()=>{b||pe()},title:_e,footer:n.jsx("div",{className:"flex justify-end gap-2",children:Le}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[Me&&n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:Me}),Ne]})}):n.jsx(Ds,{open:!!o,onOpenChange:P=>{if(!P){if(b)return;pe()}},children:n.jsxs(Es,{className:De(Y?"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:[n.jsxs(Gs,{children:[n.jsxs(qs,{className:De(Y&&"flex items-center gap-2"),children:[Y&&n.jsx(F,{name:"delete-bin",className:"h-5 w-5"}),_e]}),Me&&n.jsx(Ys,{children:Me})]}),n.jsx("div",{className:De(Y&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:Ne}),n.jsx(qn,{className:"mt-2 gap-2 pt-1 pb-1",children:Le})]})}),n.jsx(jh,{open:e,onOpenChange:s})]})},So=100;function v3(){const t=Ye.c(116),{t:e}=jt(),s=ve(R3),r=ve(E3),i=Je(D3),o=Je(I3),l=is(P3);let a;t[0]!==s?(a=Pe=>s?Pe.archivedSessions:[],t[0]=s,t[1]=a):a=t[1];const d=gs(Vn(a)),[u,f]=c.useState(""),[p,m]=c.useState(null),[b,x]=c.useState(So),v=Xb(A3);let y,g;t[2]!==s?(y=()=>{s&&Zb().catch(N3)},g=[s],t[2]=s,t[3]=y,t[4]=g):(y=t[3],g=t[4]),c.useEffect(y,g);let h;t[5]!==l||t[6]!==v||t[7]!==e?(h=Pe=>{const le=v?.get(Pe);return le?le.name:Pe?$o(Pe,l)||Pe:e("sessions.archivePage.otherProjects")},t[5]=l,t[6]=v,t[7]=e,t[8]=h):h=t[8];const w=h;let S;t[9]!==u?(S=u.trim().toLowerCase(),t[9]=u,t[10]=S):S=t[10];const j=S;let N;e:{if(!s){let le;t[11]===Symbol.for("react.memo_cache_sentinel")?(le=[],t[11]=le):le=t[11],N=le;break e}let Pe;t[12]!==d?(Pe=[...d].sort(C3),t[12]=d,t[13]=Pe):Pe=t[13],N=Pe}const C=N;let R;if(t[14]!==w||t[15]!==C||t[16]!==v){const Pe=new Map;for(const le of C){const pe=ut(Is(le))??"",je=Pe.get(pe);if(je){je.sessions.push(le);continue}Pe.set(pe,{directory:pe,label:w(pe),sessions:[le],fromDeletedSpace:v?.has(pe)??!1})}R=[...Pe.values()].sort(k3),t[14]=w,t[15]=C,t[16]=v,t[17]=R}else R=t[17];const T=R;let O;e:{if(j){if(j.startsWith("ses_")){let pe;if(t[18]!==j||t[19]!==C){let je;t[21]!==j?(je=he=>he.id.toLowerCase()===j,t[21]=j,t[22]=je):je=t[22],pe=C.filter(je),t[18]=j,t[19]=C,t[20]=pe}else pe=t[20];O=pe;break e}let le;t[23]!==j||t[24]!==C?(le=Jb(C,j,j3),t[23]=j,t[24]=C,t[25]=le):le=t[25],O=le;break e}if(p===null){O=C;break e}let Pe;t[26]!==T||t[27]!==p?(Pe=T.find(le=>le.directory===p)?.sessions??[],t[26]=T,t[27]=p,t[28]=Pe):Pe=t[28],O=Pe}const _=O;let W,L,K,A,D,E,M,k,I,U;if(t[29]!==d.length||t[30]!==T||t[31]!==_||t[32]!==w||t[33]!==j||t[34]!==s||t[35]!==u||t[36]!==p||t[37]!==i||t[38]!==r||t[39]!==v||t[40]!==e||t[41]!==o||t[42]!==b){k=Symbol.for("react.early_return_sentinel");e:{const Pe=_.slice(0,b);W=_.length-Pe.length;const le=d.length;let pe;t[53]===Symbol.for("react.memo_cache_sentinel")?(pe=V=>{m(V),x(So)},t[53]=pe):pe=t[53];const je=pe;let he;t[54]!==i||t[55]!==r?(he=V=>{const Q=ut(Is(V));i(V.id,Q??void 0),r(!1)},t[54]=i,t[55]=r,t[56]=he):he=t[56];const X=he;let de;t[57]!==e||t[58]!==o?(de=V=>{o(V.id).then(Q=>{Q?We.success(e("sessions.sidebar.session.restore.success")):We.error(e("sessions.sidebar.session.restore.error"))})},t[57]=e,t[58]=o,t[59]=de):de=t[59];const fe=de;if(!s){k=null;break e}let H;t[60]!==e?(H=(V,Q,ue,Z,ee,ke,ne,q)=>{const ie=q===void 0?!1:q;return n.jsxs("div",{className:"group/dir relative",children:[n.jsxs("button",{type:"button",onClick:ee,title:ie?e("spaces.archive.groupTitle",{name:Q}):ke,className:De("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",ne?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",Z?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[ie?n.jsx(F,{name:"box-3",className:"h-3.5 w-3.5 flex-shrink-0"}):null,n.jsx("span",{className:"min-w-0 flex-1 truncate",children:Q}),n.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:ue})]}),ne?n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>Hs.requestDelete({sessions:ne,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:Q}),children:n.jsx(F,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),n.jsx(wt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},V)},t[60]=e,t[61]=H):H=t[61];const ge=H;M="absolute inset-0 z-10 flex flex-col bg-background",D="flex min-h-0 flex-1";let Me;if(t[62]!==ge||t[63]!==p||t[64]!==e||t[65]!==le){let V;t[67]===Symbol.for("react.memo_cache_sentinel")?(V=()=>je(null),t[67]=V):V=t[67],Me=ge("__all__",e("sessions.archivePage.allDirectories"),le,p===null,V),t[62]=ge,t[63]=p,t[64]=e,t[65]=le,t[66]=Me}else Me=t[66];let Ne;if(t[68]!==T||t[69]!==ge||t[70]!==p){let V;t[72]!==ge||t[73]!==p?(V=Q=>ge(Q.directory||"__none__",Q.label,Q.sessions.length,p===Q.directory,()=>je(Q.directory),Q.directory||void 0,Q.sessions,Q.fromDeletedSpace),t[72]=ge,t[73]=p,t[74]=V):V=t[74],Ne=T.map(V),t[68]=T,t[69]=ge,t[70]=p,t[71]=Ne}else Ne=t[71];t[75]!==Me||t[76]!==Ne?(E=n.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:n.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[Me,Ne]})}),t[75]=Me,t[76]=Ne,t[77]=E):E=t[77],K="flex min-w-0 flex-1 flex-col";let Ie;t[78]===Symbol.for("react.memo_cache_sentinel")?(Ie=V=>{f(V),x(So)},t[78]=Ie):Ie=t[78];let Te;t[79]!==e?(Te=e("sessions.archivePage.searchPlaceholder"),t[79]=e,t[80]=Te):Te=t[80];let Le;t[81]!==e?(Le=e("sessions.sidebar.header.search.clear"),t[81]=e,t[82]=Le):Le=t[82];let _e;t[83]!==u||t[84]!==Te||t[85]!==Le?(_e=n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx(Zd,{value:u,onSearch:Ie,placeholder:Te,clearLabel:Le})}),t[83]=u,t[84]=Te,t[85]=Le,t[86]=_e):_e=t[86];let P;t[87]!==_.length||t[88]!==e?(P=_.length===1?e("sessions.archivePage.countSingle",{count:_.length}):e("sessions.archivePage.countPlural",{count:_.length}),t[87]=_.length,t[88]=e,t[89]=P):P=t[89];let oe;t[90]!==P?(oe=n.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:P}),t[90]=P,t[91]=oe):oe=t[91],t[92]!==_e||t[93]!==oe?(A=n.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[_e,oe]}),t[92]=_e,t[93]=oe,t[94]=A):A=t[94],L="min-h-0 flex-1 overflow-y-auto px-6 py-3",I="mx-auto w-full max-w-3xl space-y-0.5",U=Pe.length===0?n.jsx("div",{className:"py-10 text-center text-muted-foreground",children:n.jsx("p",{className:"typography-ui-label font-semibold",children:e(j?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):Pe.map(V=>{const Q=ut(Is(V))??"",ue=Q?w(Q):null,Z=!(v?.has(Q)??!1);return n.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>X(V),role:"button",tabIndex:0,onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&(ee.preventDefault(),X(V))},children:[n.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:V.title||e("sessions.sidebar.session.untitled")}),j&&ue?n.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:Q,children:ue}):null,n.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:qu(V.time?.archived??V.time?.updated??V.time?.created??Date.now())}),Z?n.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),fe(V)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:V.title||e("sessions.sidebar.session.untitled")}),children:n.jsx(F,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}):null,n.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),Hs.requestDelete({sessions:[V],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:V.title||e("sessions.sidebar.session.untitled")}),children:n.jsx(F,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},V.id)})}t[29]=d.length,t[30]=T,t[31]=_,t[32]=w,t[33]=j,t[34]=s,t[35]=u,t[36]=p,t[37]=i,t[38]=r,t[39]=v,t[40]=e,t[41]=o,t[42]=b,t[43]=W,t[44]=L,t[45]=K,t[46]=A,t[47]=D,t[48]=E,t[49]=M,t[50]=k,t[51]=I,t[52]=U}else W=t[43],L=t[44],K=t[45],A=t[46],D=t[47],E=t[48],M=t[49],k=t[50],I=t[51],U=t[52];if(k!==Symbol.for("react.early_return_sentinel"))return k;let z;t[95]!==W||t[96]!==e?(z=W>0?n.jsx("button",{type:"button",onClick:()=>x(S3),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[95]=W,t[96]=e,t[97]=z):z=t[97];let ce;t[98]!==z||t[99]!==I||t[100]!==U?(ce=n.jsxs("div",{className:I,children:[U,z]}),t[98]=z,t[99]=I,t[100]=U,t[101]=ce):ce=t[101];let re;t[102]!==L||t[103]!==ce?(re=n.jsx("div",{className:L,children:ce}),t[102]=L,t[103]=ce,t[104]=re):re=t[104];let Y;t[105]!==K||t[106]!==A||t[107]!==re?(Y=n.jsxs("div",{className:K,children:[A,re]}),t[105]=K,t[106]=A,t[107]=re,t[108]=Y):Y=t[108];let me;t[109]!==D||t[110]!==E||t[111]!==Y?(me=n.jsxs("div",{className:D,children:[E,Y]}),t[109]=D,t[110]=E,t[111]=Y,t[112]=me):me=t[112];let be;return t[113]!==M||t[114]!==me?(be=n.jsx("div",{className:M,children:me}),t[113]=M,t[114]=me,t[115]=be):be=t[115],be}function S3(t){return t+So}function j3(t){return[t.title]}function k3(t,e){return e.sessions.length-t.sessions.length}function C3(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function N3(){}function A3(t){return t.byDirectory}function P3(t){return t.homeDirectory}function I3(t){return t.unarchiveSession}function D3(t){return t.setCurrentSession}function E3(t){return t.setArchivePageOpen}function R3(t){return t.isArchivePageOpen}function M3(){const t=Ye.c(18),{t:e}=jt(),s=ve(B3),r=ve(O3),i=Vt(T3);let o;t[0]!==s?(o=b=>b.projects.find(x=>x.id===s)??null,t[0]=s,t[1]=o):o=t[1];const l=Vt(o);if(!s||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(F,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=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=n.jsx("div",{className:"flex items-center",children:n.jsxs(ht,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=f):f=t[11];let p;t[12]!==l.id||t[13]!==l.path?(p=n.jsx(kh,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=p):p=t[14];let m;return t[15]!==f||t[16]!==p?(m=n.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:n.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:n.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 T3(t){return t.setActiveProjectIdOnly}function O3(t){return t.setNewWorktreeDialogOpen}function B3(t){return t.worktreesPageProjectId}function F3(){const t=Ye.c(52),{t:e}=jt(),s=ve(_3);let r;t[0]!==s?(r=R=>R.projects.find(T=>T.id===s)??null,t[0]=s,t[1]=r):r=t[1];const i=Vt(r),{journey:o,error:l}=jm(),[a,d]=c.useState(!1);if(!i)return null;let u,f,p,m,b,x,v,y,g,h;if(t[2]!==l||t[3]!==o||t[4]!==i||t[5]!==e){const R=o?km(o,i.path):[];h="absolute inset-0 z-10 flex flex-col bg-background",g="flex-1 overflow-y-auto px-6 py-4",v="mx-auto w-full max-w-4xl space-y-4";let T,O;t[16]===Symbol.for("react.memo_cache_sentinel")?(T=()=>d(!0),O=n.jsx(F,{name:"box-3",className:"mr-1 h-3.5 w-3.5"}),t[16]=T,t[17]=O):(T=t[16],O=t[17]);let _;t[18]!==e?(_=e("spaces.page.new"),t[18]=e,t[19]=_):_=t[19],t[20]!==_?(y=n.jsx("div",{className:"flex items-center",children:n.jsxs(ht,{size:"sm",onClick:T,children:[O,_]})}),t[20]=_,t[21]=y):y=t[21],u=nx,t[22]!==e?(f=e("spaces.page.listTitle"),t[22]=e,t[23]=f):f=t[23],t[24]!==l||t[25]!==e?(p=l?n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("spaces.page.loadFailed",{reason:ex(e,tx(l))})}):null,t[24]=l,t[25]=e,t[26]=p):p=t[26],t[27]!==l||t[28]!==o||t[29]!==e?(m=o===null&&!l?n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("spaces.page.loading")}):null,t[27]=l,t[28]=o,t[29]=e,t[30]=m):m=t[30],b=o!==null&&!l&&R.length===0?n.jsx("p",{className:"typography-meta text-muted-foreground/70",children:e("spaces.page.empty")}):null,x=R.length>0?n.jsx("div",{className:"space-y-1",children:R.map(L3)}):null,t[2]=l,t[3]=o,t[4]=i,t[5]=e,t[6]=u,t[7]=f,t[8]=p,t[9]=m,t[10]=b,t[11]=x,t[12]=v,t[13]=y,t[14]=g,t[15]=h}else u=t[6],f=t[7],p=t[8],m=t[9],b=t[10],x=t[11],v=t[12],y=t[13],g=t[14],h=t[15];let w;t[31]!==u||t[32]!==f||t[33]!==p||t[34]!==m||t[35]!==b||t[36]!==x?(w=n.jsxs(u,{title:f,children:[p,m,b,x]}),t[31]=u,t[32]=f,t[33]=p,t[34]=m,t[35]=b,t[36]=x,t[37]=w):w=t[37];let S;t[38]!==w||t[39]!==v||t[40]!==y?(S=n.jsxs("div",{className:v,children:[y,w]}),t[38]=w,t[39]=v,t[40]=y,t[41]=S):S=t[41];let j;t[42]!==S||t[43]!==g?(j=n.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]!==i?(N=a?n.jsx(sx,{open:!0,onOpenChange:R=>{R||d(!1)},project:{id:i.id,path:i.path}}):null,t[45]=a,t[46]=i,t[47]=N):N=t[47];let C;return t[48]!==j||t[49]!==N||t[50]!==h?(C=n.jsxs("div",{className:h,children:[j,N]}),t[48]=j,t[49]=N,t[50]=h,t[51]=C):C=t[51],C}function L3(t){return n.jsx(Ch,{entry:t,actions:"menu"},t.id)}function _3(t){return t.spacesPageProjectId}function $3(t,e,s){const[r,i]=c.useState(null),o=c.useRef(s);return o.current=s,c.useEffect(()=>{if(!t||r)return;let l=!1;return rx(e).then(a=>{l||i(()=>a)},a=>{console.error("[on-demand] failed to load component",a),l||o.current()}),()=>{l=!0}},[r,e,t]),r}function W3(t){const e=[],s=(r,i)=>{const o=ut(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const K3=new Map,z3=t=>{const e=Ye.c(23),{isVSCode:s}=t,r=Wo(),i=Vt(V3),o=is(U3),l=Je(H3);let a;e[0]!==s?(a=T=>s?K3:T.availableWorktreesByProject,e[0]=s,e[1]=a):a=e[1];const d=Je(a),u=!s;let f;e[2]!==d||e[3]!==i||e[4]!==u?(f=gp(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=f):f=e[5];const p=f,m=gs(G3),b=gs(q3),x=gs(Y3),v=`session-list-sync:${c.useId()}`;let y,g;e[6]!==v||e[7]!==r||e[8]!==o||e[9]!==l?(y=()=>(r.setBootstrapDemand(v,W3({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(v)),g=[v,r,o,l],e[6]=v,e[7]=r,e[8]=o,e[9]=l,e[10]=y,e[11]=g):(y=e[10],g=e[11]),c.useEffect(y,g);const h=c.useRef(null);let w,S;e[12]!==s||e[13]!==p?(w=()=>{const T=new Set(p),O=h.current;h.current=T;const _=O?[...T].filter(W=>!O.has(W)):s?[...T]:[];_.length&&ja(_,Ao())},S=[s,p],e[12]=s,e[13]=p,e[14]=w,e[15]=S):(w=e[14],S=e[15]),c.useEffect(w,S);let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[16]=j):j=e[16],c.useEffect(Q3,j);let N;e[17]!==b||e[18]!==m?(N=[...m,...b],e[17]=b,e[18]=m,e[19]=N):N=e[19];const C=N;let R;e[20]!==C||e[21]!==x?(R={enabled:!0,hasAuthoritativeGlobalSessions:x,sessions:C},e[20]=C,e[21]=x,e[22]=R):R=e[22],Nh(R)};function V3(t){return t.projects}function U3(t){return t.currentDirectory}function H3(t){return t.currentSessionDirectory}function G3(t){return t.activeSessions}function q3(t){return t.archivedSessions}function Y3(t){return t.status==="ready"}function Q3(){let t=null,e=!1;const s=new Set,r=Qn(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")s.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,s.clear(),Ba(Ao());return}const o=[...s];s.clear(),o.length&&ja(o,Ao())},500)});return()=>{t&&clearTimeout(t),r()}}const X3=()=>sn(()=>import("./SettingsWindow-Dst0yiV7.js"),__vite__mapDeps([148,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,149,84,85,86,87,88,89,90,150,134,135,136,137,124,125,109,110,94,95,96,97,98,99,100,101,102,103,104,105,106,107,151,152,153])).then(t=>t.SettingsWindow),J3=()=>{const t=Ye.c(74);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],z3(e),Ah();const s=ve(Z3),r=ve(e4),i=ve(t4),o=ve(s4),l=ve(n4);let a;t[1]!==l?(a=()=>l(!1),t[1]=l,t[2]=a):a=t[2];const d=$3(o,X3,a),u=ve(r4),f=ve(o4),p=ve(i4),m=ve(a4),b=ve(l4),x=ve(c4),v=ve(d4),y=Mu();let g;if(t[3]!==y||t[4]!==v){let _e;t[6]!==v?(_e=P=>P.id===v,t[6]=v,t[7]=_e):_e=t[7],g=y.find(_e),t[3]=y,t[4]=v,t[5]=g}else g=t[5];const h=g;let w,S;t[8]!==h||t[9]!==v?(w=()=>{v&&!h&&ve.getState().setOpenGuestPage(null)},S=[v,h],t[8]=h,t[9]=v,t[10]=w,t[11]=S):(w=t[10],S=t[11]),c.useEffect(w,S);let j;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=[],t[12]=j):j=t[12],c.useEffect(f4,j);const N=f||p||m||!!b||x||u||!!h;let C;t[13]===Symbol.for("react.memo_cache_sentinel")?(C=[],t[13]=C):C=t[13],c.useEffect(m4,C);const{isMobile:R}=Tn();Ph();let T,O;t[14]!==R||t[15]!==i?(T=()=>{ve.getState().isMobile!==R&&i(R)},O=[R,i],t[14]=R,t[15]=i,t[16]=T,t[17]=O):(T=t[16],O=t[17]),c.useEffect(T,O);let _,W,L,K,A;t[18]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(a0,{}),_=n.jsx(l0,{}),W=n.jsx(f0,{}),L=n.jsx(Ih,{}),K=n.jsx(w3,{}),t[18]=_,t[19]=W,t[20]=L,t[21]=K,t[22]=A):(_=t[18],W=t[19],L=t[20],K=t[21],A=t[22]);let D;t[23]!==r?(D=r?n.jsxs(n.Fragment,{children:[n.jsx(Dh,{}),n.jsx(Eh,{}),n.jsx(Rh,{}),n.jsx(Mh,{}),n.jsx(Th,{})]}):null,t[23]=r,t[24]=D):D=t[24];let E;t[25]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Iw,{}),t[25]=E):E=t[25];let M;t[26]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(Pw,{}),t[26]=M):M=t[26];let k;t[27]!==s?(k=n.jsx(y3,{isVisible:s}),t[27]=s,t[28]=k):k=t[28];let I;t[29]!==R||t[30]!==s||t[31]!==k?(I=n.jsx(Aw,{isOpen:s,isMobile:R,className:"border-border",topBar:M,children:k}),t[29]=R,t[30]=s,t[31]=k,t[32]=I):I=t[32];let U;t[33]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsx(Cw,{}),t[33]=U):U=t[33];const z=N&&"invisible";let ce;t[34]!==z?(ce=De("absolute inset-0",z),t[34]=z,t[35]=ce):ce=t[35];const re=!o&&!N;let Y;t[36]!==re?(Y=n.jsx(hs,{children:n.jsx(nu,{active:re})}),t[36]=re,t[37]=Y):Y=t[37];let me;t[38]!==ce||t[39]!==Y?(me=n.jsx("div",{className:ce,children:Y}),t[38]=ce,t[39]=Y,t[40]=me):me=t[40];let be;t[41]===Symbol.for("react.memo_cache_sentinel")?(be=n.jsx(hs,{children:n.jsx(Oh,{})}),t[41]=be):be=t[41];let Pe;t[42]===Symbol.for("react.memo_cache_sentinel")?(Pe=n.jsx(hs,{children:n.jsx(Bh,{})}),t[42]=Pe):Pe=t[42];let le;t[43]===Symbol.for("react.memo_cache_sentinel")?(le=n.jsx(hs,{children:n.jsx(v3,{})}),t[43]=le):le=t[43];let pe;t[44]!==m?(pe=m&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(hs,{children:n.jsx(Fh,{})})}),t[44]=m,t[45]=pe):pe=t[45];let je;t[46]===Symbol.for("react.memo_cache_sentinel")?(je=n.jsx(hs,{children:n.jsx(M3,{})}),t[46]=je):je=t[46];let he;t[47]!==x?(he=x?n.jsx(hs,{children:n.jsx(F3,{})}):null,t[47]=x,t[48]=he):he=t[48];let X;t[49]!==h?(X=h&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(hs,{children:n.jsx(ly,{mode:`plugin:${h.id}`,surface:"page",item:null,onDismiss:h4})})}),t[49]=h,t[50]=X):X=t[50];let de;t[51]!==me||t[52]!==pe||t[53]!==he||t[54]!==X?(de=n.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[me,be,Pe,le,pe,je,he,X]}),t[51]=me,t[52]=pe,t[53]=he,t[54]=X,t[55]=de):de=t[55];let fe;t[56]===Symbol.for("react.memo_cache_sentinel")?(fe=n.jsx(vj,{}),t[56]=fe):fe=t[56];let H;t[57]!==de?(H=n.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:n.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:n.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:[de,fe]})})}),t[57]=de,t[58]=H):H=t[58];let ge;t[59]===Symbol.for("react.memo_cache_sentinel")?(ge=n.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:n.jsx(hs,{children:n.jsx(Ej,{})})}),t[59]=ge):ge=t[59];let Me;t[60]===Symbol.for("react.memo_cache_sentinel")?(Me=n.jsx(hs,{children:n.jsx(Lx,{})}),t[60]=Me):Me=t[60];let Ne;t[61]!==H?(Ne=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[U,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[H,ge,Me]})]}),t[61]=H,t[62]=Ne):Ne=t[62];let Ie;t[63]!==I||t[64]!==Ne?(Ie=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[I,Ne]}),t[63]=I,t[64]=Ne,t[65]=Ie):Ie=t[65];let Te;t[66]!==d||t[67]!==o||t[68]!==l?(Te=d?n.jsx(d,{open:o,onOpenChange:l}):null,t[66]=d,t[67]=o,t[68]=l,t[69]=Te):Te=t[69];let Le;return t[70]!==D||t[71]!==Ie||t[72]!==Te?(Le=n.jsx(Lh,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[A,_,W,L,K,D,E,Ie,Te]})}),t[70]=D,t[71]=Ie,t[72]=Te,t[73]=Le):Le=t[73],Le};function Z3(t){return t.isSidebarOpen}function e4(t){return t.isolatedSpacesEnabled}function t4(t){return t.setIsMobile}function s4(t){return t.isSettingsDialogOpen}function n4(t){return t.setSettingsDialogOpen}function r4(t){return t.runOverviewKey!==null}function o4(t){return t.isScheduledTasksDialogOpen}function i4(t){return t.isArchivePageOpen}function a4(t){return t.isUsageStatsPageOpen}function l4(t){return t.worktreesPageProjectId}function c4(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function d4(t){return t.openGuestPageId}function u4(){return ve.getState().setOpenGuestPage(null)}function f4(){return Or(u4)}function p4(){return ve.getState().closeMainSurfaces()}function m4(){const t=p4,e=Je.subscribe((s,r)=>{const i=!!s.currentSessionId&&s.currentSessionId!==r.currentSessionId,o=!!s.newSessionDraft?.open&&s.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function h4(){return ve.getState().setOpenGuestPage(null)}const bp=12,g4=[{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"}],b4=t=>{const e=Ye.c(18),{isActive:s,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,f=l===void 0?g4:l,p=ps.useRef(!1);let m,b;e[0]!==s||e[1]!==a?(m=()=>{!s&&p.current&&a?.(),s&&(p.current=!0)},b=[s,a],e[0]=s,e[1]=a,e[2]=m,e[3]=b):(m=e[2],b=e[3]),ps.useEffect(m,b);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=Array.from({length:bp},x4),e[4]=x):x=e[4];const v=x;if(!s)return null;let y;e[5]!==i?(y=De("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=y):y=e[6];let g;if(e[7]!==d||e[8]!==f||e[9]!==u){let w;e[11]!==d||e[12]!==u?(w=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 n.jsx("div",{className:"firework-burst",style:j,children:v.map((N,C)=>{const R=N.x*S.radius,T=N.y*S.radius,O={"--translate-x":`${R}px`,"--translate-y":`${T}px`,"--particle-delay":`${N.delay}ms`,color:`var(${S.colorVar})`};return n.jsx("span",{className:"firework-particle",style:O},`${S.id}-${C}-${d}`)})},`${S.id}-${d}`)},e[11]=d,e[12]=u,e[13]=w):w=e[13],g=f.map(w),e[7]=d,e[8]=f,e[9]=u,e[10]=g}else g=e[10];let h;return e[14]!==d||e[15]!==y||e[16]!==g?(h=n.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":d,children:g}),e[14]=d,e[15]=y,e[16]=g,e[17]=h):h=e[17],h};function x4(t,e){const s=Math.PI*2*e/bp;return{x:Math.cos(s),y:Math.sin(s),delay:e*18}}const y4=t=>{const e=Ye.c(13);let s;e[0]!==t?(s={},e[0]=t,e[1]=s):s=e[1];const{durationMs:r}=s,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=ps.useState(o),d=ps.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const f=u;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{f(),a(w4)},e[4]=p):p=e[4];const m=p;let b;e[5]!==i?(b=()=>{f(),a(v4),d.current=window.setTimeout(()=>{a(S4),d.current=null},i)},e[5]=i,e[6]=b):b=e[6];const x=b;let v,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>f(),y=[f],e[7]=v,e[8]=y):(v=e[7],y=e[8]),ps.useEffect(v,y);let g;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==x?(g={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:x,dismissFireworks:m},e[9]=l.cycle,e[10]=l.isActive,e[11]=x,e[12]=g):g=e[12],g};function w4(t){return t.isActive?{...t,isActive:!1}:t}function v4(t){return{isActive:!0,cycle:t.cycle+1}}function S4(t){return t.isActive?{...t,isActive:!1}:t}const xp=c.createContext(void 0),j4=t=>{const e=Ye.c(10),{children:s}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=y4();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=n.jsx(b4,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let f;return e[6]!==s||e[7]!==u||e[8]!==d?(f=n.jsxs(xp.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f},S5=()=>{const t=c.useContext(xp);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},ga="openchamber_requests_in_flight",yp=1e3,k4=300*1e3,Fo=Math.ceil(k4/yp),C4=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ga)==="1"}catch{return!1}},wp=()=>({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 N4=1;const A4=(t,e)=>{const s=window.__openchamberRequestsInFlight__;!s||!s.enabled||(s.inFlight+=1,s.totalStarted+=1,s.inFlight>s.peak&&(s.peak=s.inFlight),s.inFlightStarts.set(t,e))},P4=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},vp=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),s=[];for(const r of t.inFlightStarts.values())s.push(Math.max(0,e-r));return s.sort((r,i)=>r-i),s},ur=(t,e)=>{const s=t.length;if(s===0)return 0;if(s===1)return t[0];const r=e/100*(s-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},I4=()=>{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 s=async(r,i)=>{const o=N4++;A4(o,Date.now());try{return await e(r,i)}finally{P4(o)}};window.fetch=s},Cd=()=>{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>Fo&&t.splice(0,t.length-Fo)},D4=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=vp(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(ur(e,50)),t.p90Samples.push(ur(e,90)),t.p99Samples.push(ur(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,vr(t.samples),vr(t.p50Samples),vr(t.p90Samples),vr(t.p99Samples),vr(t.maxSamples),t.lastSampleAt=Date.now()},E4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(D4,yp))},Nd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Ad=t=>{if(!(typeof window>"u"))try{if(t){Nd(),Cd(),window.localStorage.setItem(ga,"1"),window.__openchamberRequestsInFlight__=wp(),I4(),E4();return}window.localStorage.removeItem(ga),Nd(),Cd(),delete window.__openchamberRequestsInFlight__}catch{}},R4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=wp();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},ba=()=>{if(typeof window>"u")return Pd();const t=window.__openchamberRequestsInFlight__;if(!C4()||!t)return Pd();const e=vp(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:ur(e,50),ageP90:ur(e,90),ageP99:ur(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:Fo}},Pd=()=>({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:Fo});function M4(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const Sp=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const s=Math.floor(e/60),r=Math.round(e%60);return`${s}m ${r}s`},xa=t=>`${(t/1e3).toFixed(2)} s`,fs=t=>{const e=Ye.c(8),{label:s,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==s?(o=n.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:s}),e[1]=s,e[2]=o):o=e[2];let l;e[3]!==r?(l=n.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=n.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},Id=t=>{const e=Ye.c(43),{title:s,snapshot:r,emptyLabel:i}=t,{t:o}=jt();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==s){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(B4,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let f;e[10]!==s?(f=n.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:s}),e[10]=s,e[11]=f):f=e[11];let p;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(p=r.startedAt?Sp(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=p):p=e[15];let m;e[16]!==p?(m=n.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:p}),e[16]=p,e[17]=m):m=e[17];let b;e[18]!==f||e[19]!==m?(b=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f,m]}),e[18]=f,e[19]=m,e[20]=b):b=e[20];let x;e[21]!==o?(x=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=x):x=e[22];let v;e[23]!==r.entries.length||e[24]!==x?(v=n.jsx(fs,{label:x,value:r.entries.length}),e[23]=r.entries.length,e[24]=x,e[25]=v):v=e[25];let y;e[26]!==o?(y=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=y):y=e[27];let g;e[28]!==y||e[29]!==u?(g=n.jsx(fs,{label:y,value:u}),e[28]=y,e[29]=u,e[30]=g):g=e[30];let h;e[31]!==o?(h=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=h):h=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==o?(w=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=w):w=e[35];let S;e[36]!==h||e[37]!==w?(S=n.jsx(fs,{label:h,value:w}),e[36]=h,e[37]=w,e[38]=S):S=e[38];let j;e[39]!==g||e[40]!==S||e[41]!==v?(j=n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[v,g,S]}),e[39]=g,e[40]=S,e[41]=v,e[42]=j):j=e[42],l=n.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,j,a.length===0?n.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):n.jsx(gn,{outerClassName:"max-h-64",className:"pr-1",children:n.jsx("div",{className:"space-y-1",children:a.map(N=>n.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[n.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:N.metric}),n.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[n.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:N.count})}),n.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:N.avg})}),n.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:N.max})}),n.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:N.total})})]})]},N.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=s,e[7]=l}else l=e[7];return l},Dd=t=>{const e=Ye.c(24),{series:s,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=s.reduce(F4,0),u=r>0?52/r:0;let f;e[0]!==d||e[1]!==a?(f=S=>a-d+S,e[0]=d,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 b=m;let x;e[5]!==l?(x=n.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=x):x=e[6];const v=`0 0 ${a} 56`;let y;e[7]!==a?(y=n.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]=y):y=e[8];let g;if(e[9]!==s||e[10]!==p||e[11]!==b){let S;e[13]!==p||e[14]!==b?(S=(j,N)=>{const C=j.samples.length;if(C===0)return null;const R=j.samples.map((O,_)=>`${p(_)},${b(O).toFixed(2)}`),T=`M ${R.join(" L ")}`;return n.jsxs(c.Fragment,{children:[j.filled?n.jsx("path",{d:`M ${p(0)},56 L ${R.join(" L ")} L ${p(C-1)},56 Z`,fill:`color-mix(in srgb, ${j.color} 18%, transparent)`,stroke:"none"}):null,n.jsx("path",{d:T,fill:"none",stroke:j.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},N)},e[13]=p,e[14]=b,e[15]=S):S=e[15],g=s.map(S),e[9]=s,e[10]=p,e[11]=b,e[12]=g}else g=e[12];let h;e[16]!==o||e[17]!==v||e[18]!==y||e[19]!==g?(h=n.jsxs("svg",{viewBox:v,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[y,g]}),e[16]=o,e[17]=v,e[18]=y,e[19]=g,e[20]=h):h=e[20];let w;return e[21]!==x||e[22]!==h?(w=n.jsxs("div",{className:"relative w-full",children:[x,h]}),e[21]=x,e[22]=h,e[23]=w):w=e[23],w},T4=t=>{const e=Ye.c(100),{onClose:s}=t,{t:r}=jt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=Je(L4),u=Hu(_4),f=Nu(),p=ox($4),m=ys(W4),[b,x]=c.useState(K4),[v,y]=c.useState(z4),[g,h]=c.useState(V4),w=[{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(U4,0),e[0]=g.samples,e[1]=S):S=e[1];const j=S,N=w.reduce(G4,0);let C;e[2]!==b.entries?(C=new Map,b.entries.forEach(ct=>{C.set(ct.metric,ct.count)}),e[2]=b.entries,e[3]=C):C=e[3];let R;e[4]!==C?(R=C.get("ui.message_list.render")??0,e[4]=C,e[5]=R):R=e[5];let T;e[6]!==C?(T=C.get("ui.message_list.render.streaming")??0,e[6]=C,e[7]=T):T=e[7];let O;e[8]!==C?(O=C.get("ui.chat_message.render")??0,e[8]=C,e[9]=O):O=e[9];let _;e[10]!==C?(_=C.get("ui.chat_message.render.streaming")??0,e[10]=C,e[11]=_):_=e[11];let W;e[12]!==C?(W=C.get("ui.chat_message.render.static_during_stream")??0,e[12]=C,e[13]=W):W=e[13];let L;e[14]!==C?(L=C.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=C,e[15]=L):L=e[15];let K;e[16]!==R||e[17]!==T||e[18]!==O||e[19]!==_||e[20]!==W||e[21]!==L?(K={messageListRender:R,messageListRenderStreaming:T,chatMessageRender:O,chatMessageRenderStreaming:_,chatMessageRenderStaticDuringStream:W,chatMessageRenderStaticOutsideActiveTurnDuringStream:L},e[16]=R,e[17]=T,e[18]=O,e[19]=_,e[20]=W,e[21]=L,e[22]=K):K=e[22];const A=K;let D,E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const ct=()=>{x(mo()),y(ho()),h(ba())};ct();const Ve=window.setInterval(ct,500);return()=>window.clearInterval(Ve)},D=[],e[23]=D,e[24]=E):(D=e[23],E=e[24]),c.useEffect(E,D);let M,k;e[25]!==l?(M=()=>{if(l==="idle")return;const ct=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(ct)},k=[l],e[25]=l,e[26]=M,e[27]=k):(M=e[26],k=e[27]),c.useEffect(M,k);let I=0,U=0,z=0;for(const ct of Object.keys(p)){const Ve=p[ct]??[];U=U+Ve.length;for(const nt of Ve)nt.role==="user"?z=z+1:nt.role==="assistant"&&(I=I+1)}let ce;e[28]!==I||e[29]!==U||e[30]!==z?(ce={assistant:I,total:U,user:z},e[28]=I,e[29]=U,e[30]=z,e[31]=ce):ce=e[31];const re=ce;let Y;if(e[32]!==d||e[33]!==p||e[34]!==u||e[35]!==f||e[36]!==r){let ct;e[38]!==d||e[39]!==p||e[40]!==u||e[41]!==r?(ct=Ve=>{const nt=p[Ve.id]??[];let kt=0,dt=0;for(const _t of nt)_t.role==="user"?dt=dt+1:_t.role==="assistant"&&(kt=kt+1);const yt=u.get(Ve.id);return{id:Ve.id,title:Ve.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:kt,messageCount:nt.length,userMessageCount:dt,isStreaming:yt?.isStreaming||!1,isZombie:yt?.isZombie||!1,backgroundCount:yt?.backgroundMessageCount||0,lastAccessed:yt?.lastAccessedAt||0,isCurrent:Ve.id===d}},e[38]=d,e[39]=p,e[40]=u,e[41]=r,e[42]=ct):ct=e[42],Y=f.map(ct).sort(q4),e[32]=d,e[33]=p,e[34]=u,e[35]=f,e[36]=r,e[37]=Y}else Y=e[37];const me=Y;let be;e[43]!==p?(be=Object.keys(p),e[43]=p,e[44]=be):be=e[44];const Pe=be.length;let le;e[45]===Symbol.for("react.memo_cache_sentinel")?(le=async()=>{try{const ct={generatedAt:new Date().toISOString(),ui:mo(),vscode:ho()};await navigator.clipboard.writeText(JSON.stringify(ct,null,2)),a("copied")}catch{a("error")}},e[45]=le):le=e[45];const pe=le,je=ax,he="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let X;e[46]===Symbol.for("react.memo_cache_sentinel")?(X={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=X):X=e[46];let de;e[47]!==i?(de=M4(i),e[47]=i,e[48]=de):de=e[48];let fe;e[49]!==de?(fe=n.jsx(F,{name:de,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=de,e[50]=fe):fe=e[50];let H;e[51]!==r?(H=r("memoryDebugPanel.title"),e[51]=r,e[52]=H):H=e[52];let ge;e[53]!==H?(ge=n.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:H}),e[53]=H,e[54]=ge):ge=e[54];let Me;e[55]!==fe||e[56]!==ge?(Me=n.jsxs("div",{className:"flex items-center gap-2",children:[fe,ge]}),e[55]=fe,e[56]=ge,e[57]=Me):Me=e[57];let Ne;e[58]!==i?(Ne=i==="streaming"?n.jsxs(n.Fragment,{children:[n.jsx(ht,{size:"xs",variant:"ghost",onClick:pe,children:n.jsx(F,{name:"file-copy",className:"h-3.5 w-3.5"})}),n.jsx(ht,{size:"xs",variant:"ghost",onClick:()=>{Cm(),x(mo()),y(ho())},children:n.jsx(F,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=Ne):Ne=e[59];let Ie;e[60]!==i?(Ie=i==="requests"?n.jsx(ht,{size:"xs",variant:"ghost",onClick:()=>{R4(),h(ba())},children:n.jsx(F,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=Ie):Ie=e[61];let Te;e[62]!==s?(Te=s?n.jsx(ht,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:s,children:n.jsx(F,{name:"close",className:"h-4 w-4"})}):null,e[62]=s,e[63]=Te):Te=e[63];let Le;e[64]!==Ne||e[65]!==Ie||e[66]!==Te?(Le=n.jsxs("div",{className:"flex items-center gap-1",children:[Ne,Ie,Te]}),e[64]=Ne,e[65]=Ie,e[66]=Te,e[67]=Le):Le=e[67];let _e;e[68]!==Me||e[69]!==Le?(_e=n.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Me,Le]}),e[68]=Me,e[69]=Le,e[70]=_e):_e=e[70];let P;e[71]===Symbol.for("react.memo_cache_sentinel")?(P={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=P):P=e[71];const oe=i==="memory"?"secondary":"ghost";let V;e[72]===Symbol.for("react.memo_cache_sentinel")?(V=()=>o("memory"),e[72]=V):V=e[72];let Q;e[73]!==r?(Q=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=Q):Q=e[74];let ue;e[75]!==oe||e[76]!==Q?(ue=n.jsx(ht,{size:"sm",variant:oe,className:"flex-1",onClick:V,children:Q}),e[75]=oe,e[76]=Q,e[77]=ue):ue=e[77];const Z=i==="streaming"?"secondary":"ghost";let ee;e[78]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>o("streaming"),e[78]=ee):ee=e[78];let ke;e[79]!==r?(ke=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=ke):ke=e[80];let ne;e[81]!==Z||e[82]!==ke?(ne=n.jsx(ht,{size:"sm",variant:Z,className:"flex-1",onClick:ee,children:ke}),e[81]=Z,e[82]=ke,e[83]=ne):ne=e[83];const q=i==="requests"?"secondary":"ghost";let ie;e[84]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>o("requests"),e[84]=ie):ie=e[84];let Ee;e[85]!==r?(Ee=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Ee):Ee=e[86];let Ae;e[87]!==q||e[88]!==Ee?(Ae=n.jsx(ht,{size:"sm",variant:q,className:"flex-1",onClick:ie,children:Ee}),e[87]=q,e[88]=Ee,e[89]=Ae):Ae=e[89];let $e;e[90]!==ue||e[91]!==ne||e[92]!==Ae?($e=n.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:P,children:[ue,ne,Ae]}),e[90]=ue,e[91]=ne,e[92]=Ae,e[93]=$e):$e=e[93];const Oe=i==="memory"?n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[n.jsx(fs,{label:r("memoryDebugPanel.metric.totalMessages"),value:re.total}),n.jsx(fs,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Pe} / ${Vl.MAX_SESSIONS}`}),n.jsx(fs,{label:r("memoryDebugPanel.metric.userMessages"),value:re.user}),n.jsx(fs,{label:r("memoryDebugPanel.metric.assistantMessages"),value:re.assistant})]}),n.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),n.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:ix()})})]}),n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),n.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Vl.ZOMBIE_TIMEOUT/1e3/60})})]}),n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),n.jsx("span",{className:"text-[var(--surface-foreground)]",children:m})]})]}),n.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[n.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),n.jsx(gn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:me.map(ct=>n.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:ct.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:ct.title}),ct.isStreaming?n.jsx(F,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,ct.isZombie?n.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:ct.assistantMessageCount,user:ct.userMessageCount})}),n.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:ct.messageCount})}),ct.backgroundCount>0?n.jsxs("span",{className:"text-[var(--status-info)]",children:["+",ct.backgroundCount]}):null]})]},ct.id))})]}),n.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:n.jsxs(vt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ht,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:f.map(Y4),currentSessionId:d,cachedSessions:Object.keys(p),messageRoleCounts:re,sessionMessageRoleCounts:me.map(Q4),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),n.jsx(wt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?n.jsxs("div",{className:"space-y-3",children:[n.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:[n.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),n.jsx(ht,{size:"xs",variant:"outline",onClick:pe,children:r("memoryDebugPanel.actions.copyJson")})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsx(fs,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),n.jsx(fs,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:v.entries.length}),n.jsx(fs,{label:r("memoryDebugPanel.metric.messageListRenders"),value:A.messageListRender}),n.jsx(fs,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:A.messageListRenderStreaming}),n.jsx(fs,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:A.chatMessageRender}),n.jsx(fs,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:A.chatMessageRenderStreaming}),n.jsx(fs,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:A.chatMessageRenderStaticDuringStream}),n.jsx(fs,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:A.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),n.jsx(Id,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),v.entries.length>0?n.jsx(Id,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:v,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[n.jsx(fs,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${g.totalSettled} / ${g.totalStarted}`}),n.jsx(fs,{label:r("memoryDebugPanel.requests.tracking"),value:g.startedAt?Sp(g.durationMs):r("memoryDebugPanel.common.idle")})]}),g.samples.length===0?n.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")}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),n.jsxs("span",{children:[n.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:g.inFlight}),n.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),n.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:g.peak})]})]}),n.jsx(Dd,{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}`}),n.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),n.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:xa(g.peakAgeMs)})]}),n.jsx(Dd,{series:w.map(X4),peak:N,windowSeconds:g.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:xa(N)}),n.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:w.map(J4)}),n.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[n.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:g.windowSeconds})}),n.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let qe;return e[94]!==je||e[95]!==X||e[96]!==_e||e[97]!==$e||e[98]!==Oe?(qe=n.jsxs(je,{className:he,style:X,children:[_e,$e,Oe]}),e[94]=je,e[95]=X,e[96]=_e,e[97]=$e,e[98]=Oe,e[99]=qe):qe=e[99],qe},O4=T4;function B4(t,e){return t+e.count}function F4(t,e){return Math.max(t,e.samples.length)}function L4(t){return t.currentSessionId}function _4(t){return t.sessionMemoryState}function $4(t){return t.message}function W4(t){return t.totalRequestCount}function K4(){return mo()}function z4(){return ho()}function V4(){return ba()}function U4(t,e){return Math.max(t,e)}function H4(t,e){return Math.max(t,e)}function G4(t,e){return e.samples.reduce(H4,t)}function q4(t,e){return e.lastAccessed-t.lastAccessed}function Y4(t){return{id:t.id,title:t.title}}function Q4(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function X4(t){return{samples:t.samples,color:t.color}}function J4(t){return n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),n.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:xa(t.current)})]},t.label)}const Z4=()=>{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()??"":""},eN=async()=>{const t=Z4()||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")},Ed="openchamber:menu-action",Di="openchamber:check-for-updates",tN=t=>{const e=Je(g=>g.openNewSessionDraft),s=ve(g=>g.toggleCommandPalette),r=ve(g=>g.setCommandPaletteOpen),i=ve(g=>g.toggleHelpDialog),o=ve(g=>g.toggleSidebar),l=ve(g=>g.setSessionSwitcherOpen),a=ve(g=>g.setSettingsDialogOpen),d=ve(g=>g.setAboutDialogOpen),u=Nr(g=>g.checkForUpdates),{setThemeMode:f}=mr(),p=c.useRef(!1),m=c.useCallback(()=>{p.current||(p.current=!0,u().then(()=>{const{available:g,error:h}=Nr.getState();if(h){We.error("Failed to check for updates",{description:h});return}g||We.success("You are on the latest version")}).finally(()=>{p.current=!1}))},[u]),b=c.useCallback(()=>{Hs.requestDirectoryDialog()},[]),x=c.useCallback(g=>{const h=lx();if(h.length===0)return;const w=Je.getState().currentSessionId,S=h.findIndex(C=>C.id===w);let j=g>0?0:h.length-1;S>=0&&(j=(S+g+h.length)%h.length);const N=h[j];N&&(l(!1),Je.getState().setCurrentSession(N.id))},[l]),v=c.useCallback(g=>{const{activeProjectId:h,projects:w,setActiveProject:S}=Vt.getState();if(w.length===0)return;const j=w.findIndex(R=>R.id===h);let N=g>0?0:w.length-1;j>=0&&(N=(j+g+w.length)%w.length);const C=w[N];C&&S(C.id)},[]),y=c.useCallback(g=>{switch(g){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":s();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const h=Je.getState(),w=is.getState().currentDirectory;e(h.currentSessionId&&w?{directoryOverride:w}:void 0)}break;case"new-worktree-session":l(!1),Du();break;case"change-workspace":b();break;case"toggle-right-sidebar":{const h=is.getState().currentDirectory;if(!h)break;const w=ve.getState(),S=In(h),j=w.contextPanelByDirectory[S];j?.isOpen?w.closeContextPanel(S):j?.activeTabId?w.setActiveContextPanelTab(S,j.activeTabId):w.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const h=is.getState().currentDirectory;if(!h)break;ve.getState().openContextSurface(In(h),"git");break}case"open-right-sidebar-files":{const h=is.getState().currentDirectory;if(!h)break;ve.getState().openContextSurface(In(h),"file");break}case"toggle-terminal":{const h=is.getState().currentDirectory;if(!h)break;ve.getState().openContextSurface(In(h),"terminal");break}case"toggle-terminal-expanded":{const h=is.getState().currentDirectory;if(!h)break;const w=In(h),S=ve.getState(),j=S.contextPanelByDirectory[w];(j?.isOpen?j.tabs.find(C=>C.id===j.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(w,"terminal"),S.toggleContextPanelExpanded(w);break}case"copy":{const h=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(h)||eN();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":cx();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":Ul(-1);break;case"go-forward":Ul(1);break;case"previous-session":x(-1);break;case"next-session":x(1);break;case"previous-project":v(-1);break;case"next-project":v(1);break;case"help-dialog":i();break;case"download-logs":{Eu().catch(()=>{We.error("Failed to collect OpenCode status")});break}}},[b,v,x,t,e,d,l,r,a,f,s,i,o]);c.useEffect(()=>{const g=w=>{const S=w.detail;S&&y(S)},h=()=>{m()};return window.addEventListener(Ed,g),window.addEventListener(Di,h),()=>{window.removeEventListener(Ed,g),window.removeEventListener(Di,h)}},[y,m]),c.useEffect(()=>{if(typeof window>"u")return;const h=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof h!="function")return;let w=null,S=null;return h("openchamber:menu-action",j=>{const N=j?.payload;typeof N=="string"&&y(N)}).then(j=>{w=j}).catch(()=>{}),h("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Di))}).then(j=>{S=j}).catch(()=>{}),()=>{(async()=>{try{const N=w?.();N instanceof Promise&&await N}catch{}try{const N=S?.();N instanceof Promise&&await N}catch{}})()}},[y])},sN="openchamber:tray-action",nN=5e3,rN=500,oN=20,Rd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Md=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,jp=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},kp=t=>t.title.trim()||"Question",iN=(t,e)=>Ta(t,e,Er.getState().ids,Da.getState().rankById),aN=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},lN=(t,e,s,r,i)=>{if(!t)return"";const o=ou(s,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||aN(t),d=bo(t);let u=d&&i.get(d)||"";if(!u){for(const[f,p]of Yn.getState().directories)if(bo(f)===d){u=p.status?.current??"";break}}if(!u)for(const f of r.values()){const p=f.find(m=>bo(m.path)===d);if(p?.branch){u=p.branch;break}}return u?`${a} · ${u}`:a},cN=()=>{const{results:t,dropdownProviderIds:e,displayMode:s}=rr.getState(),r=s==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of ux){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[f,p]of Object.entries(a.usage?.windows??{})){const m=r==="remaining"?p.remainingPercent:p.usedPercent;d.push({label:px(f),value:fx(p.valueLabel,m)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},dN=async()=>{try{if(Lo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=fr();if(e&&dl(e,t))return"Local OpenChamber";const r=(await _d()).hosts.find(i=>e?dl(e,Nm(i)):!1);return r?.label?.trim()?$d(r.label.trim()):"Instance"}catch{return""}},uN=()=>{const t=new Map,e=new Map,s=[],r=new Map;let i;try{i=Ui()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(bo(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const f=u?.type,p=f==="busy"?"busy":f==="retry"?"retry":"idle",m=t.get(d);(!m||m==="idle")&&t.set(d,p)}for(const[d,u]of Object.entries(a.permission??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||d;s.push({kind:"permission",id:f.id,sessionId:p,sessionTitle:"",label:jp(f),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||d;s.push({kind:"form",id:f.id,sessionId:p,sessionTitle:"",label:kp(f),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},fN=(t,e)=>{const s=Xu.getState().index.session,r=gs.getState().activeSessions,i=new Map;for(const h of r)if(h?.id&&h.parentID){const w=i.get(h.parentID)??[];w.push(h.id),i.set(h.parentID,w)}const o=h=>{const w=[],S=[...i.get(h)??[]],j=new Set;for(;S.length;){const N=S.pop();j.has(N)||(j.add(N),w.push(N),S.push(...i.get(N)??[]))}return w},l=ve.getState();let a=0;if(l.dockBadgeEnabled)for(const h of r){if(!h?.id||h.parentID)continue;let w=s.unseenCount[h.id]??0;w===0&&l.notifyOnSubtasks&&(w=o(h.id).reduce((S,j)=>S+(s.unseenCount[j]??0),0)),w>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=uN(),u=new Map(d.titleById);for(const h of r)h?.id&&h.title&&u.set(h.id,h.title);const f=Fa.getState().statusById,p=h=>{const w=d.statusById.get(h);return w&&w!=="idle"?w:f.get(h)?.status.type??w??"idle"},m=h=>{const w=h.map(S=>p(S));return w.includes("busy")?"busy":w.includes("retry")?"retry":"idle"},b=Vt.getState().projects,x=Je.getState().availableWorktreesByProject,v=r.filter(h=>h?.id&&!h.parentID).slice().sort(iN).slice(0,oN).map(h=>{const w=[h.id,...o(h.id)],S=Is(h)??"";return{id:h.id,title:h.title||"Untitled session",status:m(w),branch:S?d.branchByDirectory.get(S)??"":"",unseen:w.reduce((j,N)=>j+(s.unseenCount[N]??0),0),hasError:w.some(j=>s.unseenHasError[j]??!1),directory:S,subtitle:lN(S,h,b,x,d.branchByDirectory)}}),y=d.approvals.map(h=>({...h,sessionTitle:u.get(h.sessionId)||""})),g=new Set(y.map(h=>h.id));for(const[h,w]of Ju.getState().bySession){const S=u.get(h)||"";for(const j of w.permissions)g.has(j.id)||(g.add(j.id),y.push({kind:"permission",id:j.id,sessionId:h,sessionTitle:S,label:jp(j),directory:w.directory}));for(const j of w.forms)g.has(j.id)||(g.add(j.id),y.push({kind:"form",id:j.id,sessionId:h,sessionTitle:S,label:kp(j),directory:w.directory}))}return{sessions:v,approvals:y,instanceName:t,usage:cN(),dockBadgeCount:a}},pN=()=>{c.useEffect(()=>{if(!Rd()||!Dr())return;const t=Md();let e=!1,s="",r=null,i="";const o=()=>{if(e)return;const C=fN(i,t),R=JSON.stringify(C);R!==s&&(s=R,Rn("desktop_tray_update",C))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},rN))},a=Xu.subscribe(()=>l()),d=gs.subscribe(()=>l()),u=ve.subscribe((C,R)=>{(C.dockBadgeEnabled!==R.dockBadgeEnabled||C.notifyOnSubtasks!==R.notifyOnSubtasks)&&l()}),f=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),f;dN().then(C=>{e||(i=C,o())});const p=new Map,m=()=>{if(e)return;let C;try{C=Ui()}catch{return}const R=new Set;for(const[T,O]of C.children.entries())R.add(T),p.has(T)||p.set(T,O.subscribe(()=>l()));for(const[T,O]of p)R.has(T)||(O(),p.delete(T))};let b=null;try{b=Ui().subscribeRegistry(()=>{m(),l()})}catch{}m();const x=Vt.subscribe(()=>l()),v=Je.subscribe(()=>l()),y=Yn.subscribe(()=>l()),g=Fa.subscribe(()=>l()),h=Ju.subscribe(()=>l()),w=Da.subscribe(()=>l()),S=Er.subscribe(()=>l()),j=rr.subscribe(()=>l());rr.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:C,results:R}=rr.getState();C.length>0&&C.some(O=>!R.some(_=>_.providerId===O))&&rr.getState().fetchQuotas(C)});const N=window.setInterval(()=>{m(),o()},nN);return o(),()=>{f(),window.clearInterval(N),x(),v(),y(),g(),h(),w(),S(),j(),b?.();for(const C of p.values())C();p.clear()}},[]),c.useEffect(()=>{if(!Rd()||!Md()||!Dr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=i=>{i.type==="respond-permission"&&dx(i.sessionId,i.id,i.response).catch(()=>{We.error("Failed to respond to permission request")})};let r=null;return e(sN,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||s(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},mN=30*6e4,hN=(t,e,s=mN)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>s||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Sr=null;const gN=()=>{if(Sr)return Sr;const t=Qt();return Sr=(async()=>{const e=await ar.getHostSessionStatusSnapshot();if(!e||Qt()!==t)return;const s=Fa.getState(),r=gs.getState().entityById,i=hN(e,{isKnown:l=>s.statusById.has(l)||s.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?Is(a):null}});for(const[l,a]of i)mx(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?Is(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}hx(o)})().finally(()=>{Sr=null}),Sr},bN=45e3,xN=[1e3,2e3,4e3],yN=(t,e,s=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const f=await u().catch(()=>!1);if(i)return;a||=f;const p=a?void 0:xN[l];p!==void 0&&(l+=1),o=s(()=>{o=void 0,d(e)},p??bN)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},wN=t=>{const e=Ye.c(3);let s,r;e[0]!==t?(s=()=>{if(!t)return;const i=vN;let o=i();const l=Or(()=>{o(),o=i()});return()=>{l(),o()}},r=[t],e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]),c.useEffect(s,r)};function vN(){const t=Qt();let e=!0;const s=async i=>(i?await gx(Ao()):await Ba(),!e||Qt()!==t?!1:(gN(),gs.getState().status==="ready")),r=yN(()=>s(!0),()=>s(!1));return()=>{e=!1,r()}}const SN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,jN=t=>{const e=Ye.c(3),s=t?.enabled??!0;let r,i;e[0]!==s?(r=()=>{if(!(!s||pn()||!va()||!globalThis.window))return Qn(kN)},i=[s],e[0]=s,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function kN(t){if(t.type!=="notification")return;const e=ve.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&SN())return;Ld()?.notifications?.notifyAgentCompletion(t.payload)}const CN=6e4,NN=t=>{const e=Ye.c(10),s=ve(AN),r=bx(PN),o=_h(t)?.path??null;let l,a;e[0]!==s||e[1]!==r||e[2]!==o?(l=()=>{s&&r(o,{maxAgeMs:CN})},a=[s,r,o],e[0]=s,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==s||e[6]!==r||e[7]!==o?(d=()=>{if(s)return Qn(f=>{f.type==="agent-memory-changed"&&r(o)})},u=[s,r,o],e[5]=s,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function AN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function PN(t){return t.load}const IN=()=>{const t=Ye.c(4),{t:e}=jt(),s=ve(DN);let r,i;t[0]!==s||t[1]!==e?(r=()=>Qn(o=>{o.type==="browser-provider-reset"&&(s("builtin"),We.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[s,e],t[0]=s,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i)};function DN(t){return t.setBrowserProvider}const Td="pwa-install-toast-shown",Od="pwa-install-toast-dismissed",EN=()=>{const t=Ye.c(6),{browserTab:e}=$h(),{t:s}=jt(),r=c.useRef(s);let i,o;t[0]!==s?(i=()=>{r.current=s},o=[s],t[0]=s,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!va()||!e)return;let d=null,u=null;const f=()=>{u!==null&&(We.dismiss(u),u=null)},p=async()=>{if(!d)return;const x=d;d=null,f(),await x.prompt();const{outcome:v}=await x.userChoice;v==="accepted"&&We.success(r.current("pwa.installPrompt.started"))},m=x=>{const v=x;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const y=Co(),g=Am();Wh({dismissed:y.getItem(Od),sessionShown:g.getItem(Td),hasActiveToast:u!==null})&&(g.setItem(Td,"true"),u=We.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:()=>{Co().setItem(Od,"true"),f()}}}))},b=()=>{d=null,f(),We.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",m),window.addEventListener("appinstalled",b),()=>{f(),window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",b)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},RN=({open:t,onOpenChange:e})=>{const{t:s}=jt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[f,p]=c.useState(!1),[m,b]=c.useState(null),[x,v]=c.useState(!1);c.useCallback(async()=>{},[m,d,r,s]),c.useEffect(()=>{if(!t)return;(async()=>{try{const h=await ds("/api/system/info");if(h.ok){const w=await h.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){o(w.openchamberVersion);return}}}catch{}o(await xx())})()},[t]),c.useEffect(()=>{if(!t)return;let g=!1;return(async()=>{try{const w=await ds("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const S=await w.json().catch(()=>null),j=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!g&&j&&a(j)}catch{}})(),()=>{g=!0}},[t]),c.useEffect(()=>{{b(null),v(!1);return}},[t,r]);const y=i;return n.jsx(Ds,{open:t,onOpenChange:e,children:n.jsx(Es,{className:"max-w-xs p-6",children:n.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[n.jsx(Au,{width:64,height:64}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),n.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[y&&n.jsx("p",{children:s("aboutDialog.openChamberVersionLabel",{version:y})}),l&&n.jsx("p",{children:s("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,n.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[n.jsxs("div",{className:"flex items-center justify-center gap-4",children:[n.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:[n.jsx(F,{name:"github-fill",className:"h-4 w-4"}),n.jsx("span",{children:"GitHub"})]}),n.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:[n.jsx(F,{name:"discord-fill",className:"h-4 w-4"}),n.jsx("span",{children:"Discord"})]})]}),n.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:[n.jsx(F,{name:"twitter-xfill",className:"h-4 w-4"}),n.jsx("span",{children:"@openchamber_dev"})]})]}),n.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:s("aboutDialog.footerNote")})]})})})},ya="project-config-invalid",MN=()=>{const t=Ye.c(9),{t:e}=jt(),s=es(TN);let r;t[0]!==s?(r=m=>m.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const i=es(r),[o,l]=ps.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const m=es.getState(),b=m.activeDirectoryKey;l(!0),Promise.all([m.loadProviders({directory:b,source:"projectConfigError:retry"}),m.loadAgents({directory:b,source:"projectConfigError:retry"})]).finally(()=>l(!1))},t[2]=a):a=t[2];const d=a;let u,f;t[3]!==i||t[4]!==o||t[5]!==e?(u=()=>{if(!i){We.dismiss(ya);return}We.error(e("projectConfigError.toast.title"),{id:ya,duration:1/0,description:n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[n.jsx("span",{className:"break-all font-mono typography-meta",children:i.path??e("projectConfigError.toast.unknownFile")}),i.message&&n.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:i.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(o?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:m=>{m.preventDefault(),o||d()}}})},f=[i,o,d,e],t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=f):(u=t[6],f=t[7]),ps.useEffect(u,f);let p;return t[8]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[8]=p):p=t[8],ps.useEffect(BN,p),null};function TN(t){return t.activeDirectoryKey}function ON(){We.dismiss(ya)}function BN(){return ON}const FN="\x1B",LN=new RegExp(`${FN}\\[[0-9;?]*[ -/]*[@-~]`,"g"),fo=Un().transform(t=>t.replace(LN,"").trim()).nullish(),_N=Zl({isOpenCodeReady:ec().optional(),openCodeRunning:ec().optional(),lastOpenCodeError:fo,opencodeBinaryResolved:fo,lastOpenCodeLaunchDiagnostics:Zl({sourceBinary:fo,binary:fo}).nullish()}),$N=async(t,e=ds)=>{const s=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)throw new Error(`Startup diagnostics request failed (${s.status})`);const r=_N.parse(await s.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}},WN=(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"}},Bd=Xn(()=>sn(()=>import("./OnboardingScreen-CiTV2_OT.js"),__vite__mapDeps([154,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.OnboardingScreen}))),KN=()=>{const t=Ye.c(3),e=ve(qN),s=ve(YN);let r;return t[0]!==e||t[1]!==s?(r=n.jsx(RN,{open:e,onOpenChange:s}),t[0]=e,t[1]=s,t[2]=r):r=t[2],r},zN=t=>{const e=Ye.c(33),{onRetry:s,isRetrying:r}=t,{t:i}=jt(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const j=new AbortController,N=Qt(),C=setTimeout(()=>j.abort(),5e3);return $N(j.signal).then(R=>{!j.signal.aborted&&Qt()===N&&l(R)}).catch(QN).finally(()=>clearTimeout(C)),()=>{j.abort(),clearTimeout(C)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);const u=es(XN),f=o?null:u?.message??null;let p;e[2]!==i?(p=i("startup.initRecovery.title"),e[2]=i,e[3]=p):p=e[3];let m;e[4]!==p?(m=n.jsx("h1",{className:"typography-title text-foreground",children:p}),e[4]=p,e[5]=m):m=e[5];let b;e[6]!==o||e[7]!==u||e[8]!==i?(b=i(WN(o,u)),e[6]=o,e[7]=u,e[8]=i,e[9]=b):b=e[9];let x;e[10]!==b?(x=n.jsx("p",{className:"typography-body text-muted-foreground",children:b}),e[10]=b,e[11]=x):x=e[11];let v;e[12]!==m||e[13]!==x?(v=n.jsxs("div",{className:"flex flex-col gap-2",children:[m,x]}),e[12]=m,e[13]=x,e[14]=v):v=e[14];let y;e[15]!==f||e[16]!==i?(y=f&&n.jsxs("dl",{className:"w-full min-w-0 text-left","aria-live":"polite",children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.lastError")}),n.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]=i,e[17]=y):y=e[17];let g;e[18]!==o||e[19]!==i?(g=o&&n.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),n.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),n.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[18]=o,e[19]=i,e[20]=g):g=e[20];let h;e[21]!==r||e[22]!==i?(h=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[21]=r,e[22]=i,e[23]=h):h=e[23];let w;e[24]!==r||e[25]!==s||e[26]!==h?(w=n.jsx(ht,{type:"button",onClick:s,disabled:r,children:h}),e[24]=r,e[25]=s,e[26]=h,e[27]=w):w=e[27];let S;return e[28]!==w||e[29]!==v||e[30]!==y||e[31]!==g?(S=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[v,y,g,w]})}),e[28]=w,e[29]=v,e[30]=y,e[31]=g,e[32]=S):S=e[32],S},Fd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",VN=()=>{if(typeof window>"u"||!ay())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),s=typeof e=="string"?e.trim():"";if(!s)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:s,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},UN=t=>{const e=Ye.c(25),{embeddedSessionChat:s,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=is(JN),l=Je(ZN),a=Je(e5),d=kx(),u=c.useRef(null);let f;e[0]!==s.directory?(f=Fd(s.directory),e[0]=s.directory,e[1]=f):f=e[1];const p=f;let m;e[2]!==o?(m=Fd(o),e[2]=o,e[3]=m):m=e[3];const b=m;let x,v;if(e[4]!==b||e[5]!==l||e[6]!==s.directory||e[7]!==s.sessionId||e[8]!==p||e[9]!==r||e[10]!==a||e[11]!==d?(x=()=>{if(r||p&&b!==p)return;const j=`${p}
|
|
1000
|
+
${s.sessionId}`;u.current===j&&l||(u.current=j,a(s.sessionId,s.directory),d.ensureSessionRenderable(s.sessionId,!0))},v=[b,l,s.directory,s.sessionId,p,r,a,d],e[4]=b,e[5]=l,e[6]=s.directory,e[7]=s.sessionId,e[8]=p,e[9]=r,e[10]=a,e[11]=d,e[12]=x,e[13]=v):(x=e[12],v=e[13]),c.useEffect(x,v),p&&b!==p)return null;let y;e[14]!==i?(y=n.jsx(Zu,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=y):y=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(ru,{}),e[16]=g):g=e[16];let h;e[17]!==i||e[18]!==s.allowPromptingSubagentSessions||e[19]!==s.readOnly?(h=n.jsx(nu,{active:i,messagesEnabled:!0,readOnly:s.readOnly,initialAllowPromptingSubagentSessions:s.allowPromptingSubagentSessions}),e[17]=i,e[18]=s.allowPromptingSubagentSessions,e[19]=s.readOnly,e[20]=h):h=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(ef,{}),e[21]=w):w=e[21];let S;return e[22]!==y||e[23]!==h?(S=n.jsxs(n.Fragment,{children:[y,g,h,w]}),e[22]=y,e[23]=h,e[24]=S):S=e[24],S};function HN({apis:t}){c.useEffect(()=>{Pm("App:mounted"),Im()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=es(X=>X.initializeApp),s=es(X=>X.isInitialized),r=es(X=>X.isConnected),i=es(X=>X.providers.length),o=es(X=>X.agents.length),l=es(X=>X.loadProviders),a=es(X=>X.loadAgents),d=Je(X=>X.error),u=Je(X=>X.clearError),f=is(X=>X.currentDirectory),p=is(X=>X.setDirectory),m=is(X=>X.isSwitchingDirectory),[b,x]=c.useState(!1),v=mn(X=>X.refreshStatus),y=_i(X=>X.refreshStatus),[g,h]=c.useState(()=>t.runtime.isVSCode),[w,S]=c.useState(!1),[j,N]=c.useState(!1),[C,R]=c.useState(0),[T,O]=c.useState(0),[_,W]=c.useState(!1),L=ve(X=>X.wideChatLayoutEnabled),K=ve(X=>X.mobileKeyboardMode),A=c.useMemo(()=>pn(),[]),D=Ca(X=>X.setPlanModeEnabled),[E,M]=c.useState(()=>ul()),[k,I]=c.useState(()=>{const X=fl();return X!==null?pl({isDesktopShell:!0,bootOutcome:X}):null}),U=c.useRef(!1),z=c.useMemo(()=>VN(),[]),ce=!z||w;c.useEffect(()=>(ml(b),Ad(b),()=>{ml(!1),Ad(!1)}),[b]),c.useEffect(()=>{Dm(K)},[K]),c.useEffect(()=>{h(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Or(X=>{zh(X)&&Vh(X),O(de=>de+1),N(!1),R(de=>de+1)}),[]);const re=Hl(X=>{const de=Qt();return Object.values(X.runsByOriginalSessionID).filter(fe=>fe.status==="running"&&fe.runtimeKey===de).map(fe=>`${fe.originalSessionID}:${fe.phase}:${fe.lastForwardedMessageID??""}:${fe.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(z)return;const X=Qt(),de=Object.values(Hl.getState().runsByOriginalSessionID).filter(fe=>fe.status==="running"&&fe.runtimeKey===X);for(const fe of de)yx(fe.originalSessionID)},[re,z,T]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",L),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[L]),c.useEffect(()=>(hl(t),()=>hl(null)),[t]),c.useEffect(()=>{z||(v(t.github,{force:!0}),y(t.linear,{force:!0}))},[t.github,t.linear,z,r,v,y,T]),wx();const Y=E==="valid",me=k?.screen==="main";c.useEffect(()=>{if(!Em({isDesktopShell:A,isInitialized:s,bootOutcomeKnown:Y,bootViewIsMain:me}))return;const X=setTimeout(()=>{const de=document.getElementById("initial-loading");de&&(de.classList.add("fade-out"),setTimeout(()=>{de.remove()},300))},150);return()=>clearTimeout(X)},[A,s,Y,me]),c.useEffect(()=>{if(!A||E!=="malformed")return;const X=document.getElementById("initial-loading");X&&(X.textContent="Desktop startup failed — please restart the app.")},[A,E]),c.useEffect(()=>{if(A)return;const X=setTimeout(()=>{const de=document.getElementById("initial-loading");de&&!s&&(de.classList.add("fade-out"),setTimeout(()=>{de.remove()},300))},5e3);return()=>clearTimeout(X)},[A,s]),c.useEffect(()=>{let X=!1;return(async()=>{const fe=await ds("/health",{method:"GET"}).catch(()=>null);if(!fe||!fe.ok||X)return;const H=await fe.json().catch(()=>null);if(!H||X)return;const ge=H.planModeExperimentalEnabled;D(ge===!0||ge===1||ge==="1"||ge==="true")})(),()=>{X=!0}},[D]),c.useEffect(()=>{g||e()},[e,g]),c.useEffect(()=>{if(g||s)return;let X=!0,de,fe=0;const H=10,ge=1e3,Me=async()=>{if(!X)return;if(fe>=H){N(!0);return}const Ne=es.getState();if(Ne.isInitialized){N(!1);return}fe+=1,await Ne.initializeApp();const Ie=es.getState();if(!X)return;if(Ie.isInitialized){N(!1);return}if(fe>=H){N(!0);return}const Te=Math.min(ge*Math.pow(2,fe-1),16e3);de=setTimeout(Me,Te)};return de=setTimeout(Me,ge),()=>{X=!1,de&&clearTimeout(de)}},[C,s,g]),c.useEffect(()=>{s&&N(!1)},[s]),c.useEffect(()=>{if(!j)return;const X=document.getElementById("initial-loading");X&&(X.classList.add("fade-out"),setTimeout(()=>{X.remove()},300))},[j]),c.useEffect(()=>{if(g||!r||i>0&&o>0)return;let X=!0,de=0;const fe=15,H=async()=>{const Me=es.getState();if(!(Me.providers.length>0&&Me.agents.length>0))try{Me.providers.length===0&&await l({source:"startupRecovery"}),es.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};H();const ge=setInterval(()=>{if(X){if(++de>=fe){clearInterval(ge);return}H()}},2e3);return()=>{X=!1,clearInterval(ge)}},[r,g,a,l,i,o]),c.useEffect(()=>{m||g||r&&ar.setDirectory(f)},[f,m,r,g]),c.useEffect(()=>{if(!z||typeof window>"u")return;const X=H=>{S(H?.visible===!0)},de=H=>{if(H.origin!==window.location.origin||H.source!==window.parent)return;const ge=H.data;ge?.type===df&&X(ge.payload)},fe=window;return fe.__openchamberSetEmbeddedVisibility=X,window.addEventListener("message",de),iy(),()=>{window.removeEventListener("message",de),fe.__openchamberSetEmbeddedVisibility===X&&delete fe.__openchamberSetEmbeddedVisibility}},[z]),c.useEffect(()=>{!z?.directory||g||f!==z.directory&&p(z.directory,{showOverlay:!1})},[f,z,g,p]),c.useEffect(()=>{if(!z||typeof window>"u")return;const X=de=>{de.storageArea===window.localStorage&&de.key==="ui-store"&&ve.persist.rehydrate()};return window.addEventListener("storage",X),()=>{window.removeEventListener("storage",X)}},[z]),c.useEffect(()=>{if(typeof window>"u")return;const X=de=>{const fe=de.detail,H=typeof fe?.sessionId=="string"?fe.sessionId.trim():"";if(!H)return;const ge=typeof fe?.directory=="string"&&fe.directory.trim().length>0?fe.directory.trim():null;if(!ge){Yi(H,typeof fe?.messageId=="string"?fe.messageId.trim():null);return}Je.getState().setCurrentSession(H,ge)};return window.addEventListener("openchamber:open-session",X),z||Rm().then(de=>{for(const fe of de)Yi(fe.sessionId,fe.messageId)}),()=>window.removeEventListener("openchamber:open-session",X)},[z]);const be=c.useRef(!1);c.useEffect(()=>{!s||z||be.current||(be.current=!0,Uh({refresh:!1}))},[z,s]),c.useEffect(()=>{if(typeof window>"u")return;const X=()=>{Rn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",X),()=>window.removeEventListener("openchamber:open-mini-chat",X)},[]),c.useEffect(()=>{if(typeof window>"u")return;const X=()=>{const de=Je.getState().currentSessionId;de&&Pu(de)};return window.addEventListener("focus",X),()=>window.removeEventListener("focus",X)},[]),c.useEffect(()=>{if(typeof window>"u")return;const X=de=>{const fe=de.detail,H=typeof fe?.directory=="string"&&fe.directory.trim().length>0?fe.directory.trim():null,ge=typeof fe?.projectId=="string"&&fe.projectId.trim().length>0?fe.projectId.trim():null,Me=!!(H||ge);ve.getState().setSessionSwitcherOpen(!1),Je.getState().openNewSessionDraft({target:Me?"project":"chat",selectedProjectId:Me?ge:null,directoryOverride:Me?H:null,preserveDirectoryOverride:!!H})};return window.addEventListener("openchamber:open-draft-session",X),()=>window.removeEventListener("openchamber:open-draft-session",X)},[]),c.useEffect(()=>{typeof window>"u"||!s||m||U.current||(U.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,m]),vx({enabled:ce}),jN({enabled:ce}),NN(f||null),IN(),Sx(),Hh(),EN(),jx(),_x(),Gh();const Pe=c.useCallback(()=>{x(X=>!X)},[]);tN(Pe),pN(),wN(!z),c.useEffect(()=>{if(z)return;const X=()=>x(de=>!de);return window.addEventListener("openchamber:memory-debug-toggle",X),()=>window.removeEventListener("openchamber:memory-debug-toggle",X)},[z]),c.useEffect(()=>{z||d&&setTimeout(()=>u(),5e3)},[u,z,d]),c.useEffect(()=>{if(!A||E!=="not-injected")return;let X=!1,de=0;const fe=200,H=2e3,ge=50,Me=()=>{if(X)return;de++;const Ne=ul();if(Ne!=="not-injected"){if(X=!0,M(Ne),Ne==="valid"){const Te=fl();Te&&I(pl({isDesktopShell:!0,bootOutcome:Te}))}return}const Ie=Math.min(fe*Math.pow(1.1,de),H);if(de>=ge){const Te=document.getElementById("initial-loading");Te&&!Te.textContent?.includes("taking longer")&&(Te.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Me,Ie)};return window.setTimeout(Me,fe),()=>{X=!0}},[A,E]);const le=c.useCallback(async()=>{if(Mm({isDesktopShell:pn(),isDesktopLocalOriginActive:Lo()})){await Tm();return}window.location.reload()},[]),pe=c.useCallback(async()=>{if(!_){N(!1),W(!0);try{await es.getState().initializeApp()}finally{W(!1)}es.getState().isInitialized||R(X=>X+1)}},[_]),je=X=>{if(X.screen==="recovery")return X.variant};if(A&&k&&k.screen!=="main"){if(k.screen==="chooser")return n.jsx(hs,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(Bd,{mode:"first-launch",localAvailable:k.localAvailable!==!1,onCliAvailable:le,onChooseRemote:()=>{}})})})});const X=je(k),de=k.screen==="recovery"&&"url"in k?k.url:void 0;return n.jsx(hs,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(Bd,{mode:"recovery",recoveryVariant:X,recoveryHostUrl:de,recoveryHostLabel:void 0,localAvailable:k.localAvailable!==!1,onCliAvailable:le})})})})}if(z)return n.jsx(hs,{children:n.jsx(Gl,{sdk:ar.getSdkClient(),directory:f||"",children:n.jsx(ql,{apis:t,children:n.jsx(Vi,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:"h-full text-foreground bg-background",children:[n.jsx(UN,{embeddedSessionChat:z,isVSCodeRuntime:g,embeddedBackgroundWorkEnabled:ce}),n.jsx(Yl,{}),n.jsx(Ql,{})]})})})},T)});if(j&&!s&&!g&&!z)return n.jsx(hs,{children:n.jsx(zN,{onRetry:()=>{pe()},isRetrying:_},T)});const he=!s&&!A;return n.jsx(hs,{children:n.jsx(Gl,{sdk:ar.getSdkClient(),directory:f||"",children:n.jsx(ql,{apis:t,children:n.jsx(j4,{children:n.jsx(Vi,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:A?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(Zu,{embeddedBackgroundWorkEnabled:ce}),n.jsx(ru,{}),n.jsx(MN,{}),n.jsx(J3,{}),n.jsx(qh,{ready:s&&(!A||Y&&me)}),n.jsx(ef,{}),n.jsx(Yl,{}),n.jsx(Ql,{}),!he&&n.jsxs(n.Fragment,{children:[n.jsx(Yh,{}),n.jsx(KN,{}),b&&n.jsx(O4,{onClose:()=>x(!1)})]})]})})})})},T)})}function GN(t){const e=Ye.c(2);let s;return e[0]!==t?(s=n.jsx(Kh,{children:n.jsx(HN,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function qN(t){return t.isAboutDialogOpen}function YN(t){return t.setAboutDialogOpen}function QN(){}function XN(t){return t.lastInitFailure}function JN(t){return t.currentDirectory}function ZN(t){return t.currentSessionId}function e5(t){return t.setCurrentSession}const t5=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Cx();Qh();Om().then(()=>{Promise.all([Bm(),Nx()]).catch(t=>{console.error("[main] settings init failed:",t)}),Ax(),Px(),Ix()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Cp=document.getElementById("root");if(!Cp)throw new Error("Root element not found");Dx();em.createRoot(Cp).render(n.jsx(ps.StrictMode,{children:n.jsx(Ex,{children:n.jsx(Rx,{children:n.jsx(Mx,{children:n.jsx(Tx,{children:n.jsx(GN,{apis:t5})})})})})}));const j5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Gw as W,Bw as a,S5 as b,Nf as g,j5 as m,Hw as u,Cf as v};
|