@openchamber/web 2.3.0 → 2.3.1
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/AboutDialog-C1ulAXh5.js +1 -0
- package/dist/assets/ArchiveView-DJo1Bpw_.js +1 -0
- package/dist/assets/{CommandPalette-1VlA7PbL.js → CommandPalette-B6r6DPF9.js} +2 -2
- package/dist/assets/{DiffView-SHdJJ6tl.js → DiffView-mJuVm7Z4.js} +2 -2
- package/dist/assets/{FilePreviewCommentMenu-DlVgwRsr.js → FilePreviewCommentMenu-Ca4ziuof.js} +1 -1
- package/dist/assets/{FilesView-BeMtsSlV.js → FilesView-BBFbfDp9.js} +3 -3
- package/dist/assets/{GitView-npRGKKx8.js → GitView-WL1wkRFF.js} +3 -3
- package/dist/assets/GuestSurfacePane-peVDY5gW.js +1 -0
- package/dist/assets/HelpDialog-Dxc2yneu.js +1 -0
- package/dist/assets/{InProgressOperationBanner-B6iO22_7.js → InProgressOperationBanner-Dy0RiPsD.js} +1 -1
- package/dist/assets/JsonTreeView-BKUmh7Iw.js +1 -0
- package/dist/assets/MarkdownImageGallery-Cd6hLNmi.js +1 -0
- package/dist/assets/MarkdownRendererImpl-C-3B3mBt.js +1 -0
- package/dist/assets/MemoryDebugPanel-b116r1SF.js +1 -0
- package/dist/assets/OnboardingScreen-vBEhpU3q.js +1 -0
- package/dist/assets/OpenCodeStatusDialog-DH7dJ6MH.js +1 -0
- package/dist/assets/{PatchDiff-Du2s7T3U.js → PatchDiff-yM7vgQgi.js} +1 -1
- package/dist/assets/{PierreDiffViewer-B9K0gBvV.js → PierreDiffViewer-DnHKbYGl.js} +1 -1
- package/dist/assets/{PlanView-IkTcPrbw.js → PlanView-j0hLJmto.js} +2 -2
- package/dist/assets/RunOverview-ZuFZvDcu.js +2 -0
- package/dist/assets/ScheduledTasksDialog-UKXFFI91.js +5 -0
- package/dist/assets/{SettingsView-DIy5ZL4-.js → SettingsView-gB_NvyX4.js} +8 -8
- package/dist/assets/SettingsWindow-Dfb_RFpD.js +1 -0
- package/dist/assets/SourceBoardView-BjaL0nKs.js +1 -0
- package/dist/assets/SpaceAccessDialog-XzHRmIdT.js +1 -0
- package/dist/assets/SpaceApplyDialog-CxX9mrzT.js +1 -0
- package/dist/assets/{SpaceRow-YPmKQKeD.js → SpaceRow-vCpOCANO.js} +1 -1
- package/dist/assets/SpaceSetupOutput-CDZvJCf_.js +1 -0
- package/dist/assets/SpacesView-D3a9bCzn.js +1 -0
- package/dist/assets/{SubmoduleDiffSummary-RDY5md3p.js → SubmoduleDiffSummary-CQyRcvDZ.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Dx85XZJs.js → ToolOutputDialog-judR_5mS.js} +2 -2
- package/dist/assets/{ToolPartDiffPreview-Dtv0xF9O.js → ToolPartDiffPreview-Ca9ISxfg.js} +1 -1
- package/dist/assets/UsageStatsView-C63Emjfj.js +1 -0
- package/dist/assets/{Virtualizer-DL535kyR.js → Virtualizer-DNgIEKcx.js} +1 -1
- package/dist/assets/{WalkthroughView-DcxbT5tc.js → WalkthroughView-D74b_7sC.js} +2 -2
- package/dist/assets/WorktreesView-hcm8Eb_C.js +1 -0
- package/dist/assets/appThemeRegistry-COeayQaQ.js +1 -0
- package/dist/assets/{ar-lP51qqz9.js → ar-1_zdYVV5.js} +2 -2
- package/dist/assets/computeVirtualFileMetrics-MZqvCQy0.js +3 -0
- package/dist/assets/{de-CpROAvTV.js → de-Ci7SGEQP.js} +3 -3
- package/dist/assets/{decorate-BNB7jeKg.js → decorate-CZeRRVC7.js} +1 -1
- package/dist/assets/{es-Bb8LKRhE.js → es-ZJii-6Tt.js} +2 -2
- package/dist/assets/{fr-BlNN9FC2.js → fr-C-hK8mvI.js} +2 -2
- package/dist/assets/{he-r546pCuc.js → he-t07CylP8.js} +2 -2
- package/dist/assets/index-D2tPUss-.js +1 -0
- package/dist/assets/{initializeSharedPreferences-dCHO04bl.js → initializeSharedPreferences-FxFkTjgn.js} +1 -1
- package/dist/assets/{isDiffPlainText-BwicHPpI.js → isDiffPlainText-C1F9opE5.js} +1 -1
- package/dist/assets/{isFilePlainText-Dk2R7BJo.js → isFilePlainText-B4SyJ-ni.js} +1 -1
- package/dist/assets/{ja-evNvJAHz.js → ja-iJr8aONy.js} +2 -2
- package/dist/assets/{katex-CMY-1eWf.css → katex-BEX7X_K8.css} +1 -1
- package/dist/assets/{katex.min-Iw9WSgM9.js → katex.min-C-51hS9A.js} +18 -18
- package/dist/assets/{ko-BPQP7lXe.js → ko-D5ow_yz-.js} +2 -2
- package/dist/assets/main-BtGnuno4.js +1048 -0
- package/dist/assets/main-uj5954n5.js +2 -0
- package/dist/assets/markdownCore-rBXCnAJp.js +9 -0
- package/dist/assets/miniChat-yWQmT2OS.js +2 -0
- package/dist/assets/mobile-NDAeGtzL.js +2 -0
- package/dist/assets/{moveWorkspacePath-B31RGdgu.js → moveWorkspacePath-BINgpJ9S.js} +1 -1
- package/dist/assets/{nl-CkQXd1nU.js → nl-CfqYrSVe.js} +2 -2
- package/dist/assets/{parseDiffFromFile-DcsKSY0J.js → parseDiffFromFile--DE4eHIp.js} +2 -2
- package/dist/assets/{patchFileDiff-Cx-HpjyI.js → patchFileDiff-BfFUmWgS.js} +1 -1
- package/dist/assets/pierreDiffTint-D9K6_CVD.js +29 -0
- package/dist/assets/{pl-C4i9Aizi.js → pl-Bn2_jAhL.js} +4 -4
- package/dist/assets/{pt-BR-CoYnG1CH.js → pt-BR-ZSDgn6cI.js} +2 -2
- package/dist/assets/relocateRestoredSession-C85Tk2y9.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-BvAEmWhZ.js +2 -0
- package/dist/assets/{renderMobileApp-gDKxRJQi.js → renderMobileApp-T20l8ise.js} +7 -7
- package/dist/assets/{restartOpenCode-dq-SGun3.js → restartOpenCode-VEmIrLer.js} +1 -1
- package/dist/assets/runtimeEndpointReset-ExJsaWzA.js +55 -0
- package/dist/assets/scheduledTasksApi-NSyxVfHu.js +1 -0
- package/dist/assets/{selectionMarkdown-sDTBbKLh.js → selectionMarkdown-BJ2RhTXc.js} +2 -2
- package/dist/assets/{sessionOwnership-kZAtwMQd.js → sessionOwnership-BAX1xEJC.js} +1 -1
- package/dist/assets/{shikiHighlight-BRNXPlF-.js → shikiHighlight-DOzrE7BE.js} +1 -1
- package/dist/assets/{space-apply-CCOKLfrX.js → space-apply-DB_ZfJBW.js} +1 -1
- package/dist/assets/space-close-1kNlTkW1.js +1 -0
- package/dist/assets/{spaceNetwork-DUxJClu3.js → spaceNetwork-DA16ov_y.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-B6UJwdZz.js → textMateThemeFromAppTheme-BfIrjFAU.js} +1 -1
- package/dist/assets/{tr-D-_lz-lC.js → tr-C89uz1hs.js} +2 -2
- package/dist/assets/{uk-B49PGMYB.js → uk-uTYVPFrO.js} +2 -2
- package/dist/assets/{useAppFontEffects-3EN8Ava3.js → useAppFontEffects-C1ceAD51.js} +185 -185
- package/dist/assets/useCallableModelProviders-BkLsgs6y.js +1 -0
- package/dist/assets/{useInlineCommentController-l9cWyfuR.js → useInlineCommentController-ynkUsoVA.js} +1 -1
- package/dist/assets/{useRootScrollLock-UAQn24Y8.js → useRootScrollLock-DnoKH1HE.js} +2 -2
- package/dist/assets/{vendor-codemirror-autocomplete-C8FBSI9t.js → vendor-codemirror-autocomplete-BRKmCSiY.js} +1 -1
- package/dist/assets/{vendor-codemirror-commands-BhRb6jns.js → vendor-codemirror-commands-MmBpgSOc.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-angular-Bj5Pk8sp.js +1 -0
- package/dist/assets/vendor-codemirror-lang-cpp-tZt-BOgi.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-DfdrZ848.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-go-BHJEONih.js → vendor-codemirror-lang-go-C9OcoXdP.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-html-C5kFuJzc.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-Divn2dnj.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-javascript-CUmSxayT.js → vendor-codemirror-lang-javascript-DmPuKUEa.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-jinja-B-8miA-Q.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-L0wsFFxi.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-CWlCIxCI.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-Dm8xthAW.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-CPn-qinN.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-DKIOifjN.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-BAVa3Hg5.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-Dab90hdg.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-eezaHFBZ.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-C1Jj9uuJ.js → vendor-codemirror-lang-sql-Vu-PR7cv.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-vue-BthRGZHy.js +1 -0
- package/dist/assets/vendor-codemirror-lang-wast-Db6KSic0.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-DQkh4sc1.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-Bt2N__AW.js +1 -0
- package/dist/assets/vendor-codemirror-language-DkBxRck3.js +3 -0
- package/dist/assets/vendor-codemirror-language-data-CTYHXywt.js +2 -0
- package/dist/assets/{vendor-codemirror-search-CvXM_pZg.js → vendor-codemirror-search-BKAwkhkm.js} +1 -1
- package/dist/assets/vendor-codemirror-streamparser-CmlTsbN2.js +1 -0
- package/dist/assets/vendor-codemirror-view-B66jUSmE.js +4 -0
- package/dist/assets/{vendor-replit-codemirror-vim-Ck2X_WZC.js → vendor-replit-codemirror-vim-D0bqFa1D.js} +5 -5
- package/dist/assets/{worker-DdhrXE7g.js → worker-BbEdJ2Oi.js} +18 -18
- package/dist/assets/workerFactory-Bw5qLmrM.js +1 -0
- package/dist/assets/{zh-CN-CS-9Os9n.js → zh-CN-DdTNG52a.js} +2 -2
- package/dist/assets/{zh-TW-D0XYVdcl.js → zh-TW-DPm_33Fi.js} +2 -2
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/index.js +4 -0
- package/server/lib/environment/store.js +3 -4
- package/server/lib/environment/store.test.js +17 -0
- package/server/lib/fs/DOCUMENTATION.md +4 -2
- package/server/lib/fs/routes.js +48 -13
- package/server/lib/fs/routes.test.js +118 -5
- package/server/lib/git/DOCUMENTATION.md +3 -1
- package/server/lib/git/contributor-remote.js +4 -0
- package/server/lib/git/contributor-remote.test.js +21 -0
- package/server/lib/git/service.js +20 -25
- package/server/lib/git/service.test.js +99 -0
- package/server/lib/git/worktree-creation.js +4 -5
- package/server/lib/github/DOCUMENTATION.md +1 -1
- package/server/lib/github/routes.auth.test.js +14 -0
- package/server/lib/github/routes.js +13 -5
- package/server/lib/github/routes.mutations.test.js +18 -2
- package/server/lib/message-queue/DOCUMENTATION.md +8 -2
- package/server/lib/message-queue/runtime.js +3 -2
- package/server/lib/message-queue/runtime.test.js +64 -2
- package/server/lib/openchamber-control/service.js +48 -13
- package/server/lib/openchamber-control/service.test.js +42 -0
- package/server/lib/opencode/DOCUMENTATION.md +3 -1
- package/server/lib/opencode/project-start-command.d.ts +11 -0
- package/server/lib/opencode/project-start-command.js +56 -0
- package/server/lib/opencode/project-start-command.test.js +80 -0
- package/server/lib/opencode/session-activity.js +43 -3
- package/server/lib/opencode/session-activity.test.js +97 -0
- package/server/lib/opencode/settings-runtime.js +19 -1
- package/server/lib/opencode/settings-runtime.test.js +23 -0
- package/server/lib/opencode/skill-routes.js +34 -1
- package/server/lib/opencode/skill-routes.test.js +99 -0
- package/server/lib/quota/DOCUMENTATION.md +13 -1
- package/server/lib/quota/providers/antigravity/api.js +104 -0
- package/server/lib/quota/providers/antigravity/auth.js +45 -0
- package/server/lib/quota/providers/antigravity/index.js +76 -0
- package/server/lib/quota/providers/antigravity/transforms.js +168 -0
- package/server/lib/quota/providers/antigravity/transforms.test.js +162 -0
- package/server/lib/quota/providers/codex.js +28 -4
- package/server/lib/quota/providers/codex.test.js +29 -0
- package/server/lib/quota/providers/google/auth.js +4 -49
- package/server/lib/quota/providers/google/transforms.js +3 -22
- package/server/lib/quota/providers/index.js +8 -0
- package/server/lib/quota/providers/opencode-go.js +3 -1
- package/server/lib/quota/providers/opencode-go.test.js +12 -0
- package/server/lib/routing/DOCUMENTATION.md +3 -1
- package/server/lib/routing/runtime.js +34 -1
- package/server/lib/routing/runtime.test.js +43 -1
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +11 -0
- package/server/lib/scheduled-tasks/existing-session.js +52 -8
- package/server/lib/scheduled-tasks/existing-session.test.js +121 -0
- package/server/lib/scheduled-tasks/routes.js +26 -0
- package/server/lib/scheduled-tasks/runtime.js +1 -0
- package/server/lib/session-assist/runtime.js +3 -0
- package/server/lib/session-assist/runtime.test.js +47 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +10 -1
- package/server/lib/skills-catalog/install.js +1 -1
- package/server/lib/skills-catalog/installed-sources.d.ts +17 -0
- package/server/lib/skills-catalog/installed-sources.js +112 -0
- package/server/lib/skills-catalog/installed-sources.test.js +94 -0
- package/server/lib/small-model/DOCUMENTATION.md +12 -5
- package/server/lib/small-model/index.js +6 -4
- package/server/lib/small-model/index.test.js +40 -0
- package/server/lib/small-model/routes.js +3 -2
- package/server/lib/source-control/change-request-worktree.js +2 -6
- package/server/lib/source-control/mutation-storage.js +4 -1
- package/server/lib/source-control/mutation-storage.test.js +21 -0
- package/server/lib/spaces/DOCUMENTATION.md +1 -1
- package/server/lib/spaces/journey.js +10 -3
- package/server/lib/spaces/journey.test.js +13 -1
- package/server/lib/terminal/history.js +22 -2
- package/server/lib/terminal/history.test.js +23 -0
- package/server/lib/terminal/theme-response.js +14 -0
- package/server/lib/terminal/theme-response.test.js +10 -0
- package/dist/assets/AboutDialog-e8ek_kPI.js +0 -1
- package/dist/assets/ArchiveView-CjF4_TFg.js +0 -1
- package/dist/assets/GuestSurfacePane-4kmEXPLD.js +0 -1
- package/dist/assets/HelpDialog-CITMqPDK.js +0 -1
- package/dist/assets/JsonTreeView-xGikhCtL.js +0 -1
- package/dist/assets/MarkdownImageGallery-D0FJyr7C.js +0 -1
- package/dist/assets/MarkdownRendererImpl-BIM7Pjwk.js +0 -1
- package/dist/assets/MemoryDebugPanel-CBk8QW-M.js +0 -1
- package/dist/assets/OnboardingScreen-Cy6ARiMS.js +0 -1
- package/dist/assets/OpenCodeStatusDialog-YMHuJzwt.js +0 -1
- package/dist/assets/RunOverview-CHkGSW1x.js +0 -2
- package/dist/assets/ScheduledTasksDialog-77SO8zdJ.js +0 -4
- package/dist/assets/SettingsWindow-X74FIkdo.js +0 -1
- package/dist/assets/SourceBoardView-Cff2ejOW.js +0 -1
- package/dist/assets/SpaceAccessDialog-BXMZNRei.js +0 -1
- package/dist/assets/SpaceApplyDialog-BEJd2ryu.js +0 -1
- package/dist/assets/SpaceSetupOutput-Cb3XcIII.js +0 -1
- package/dist/assets/SpacesView-I3HaRKtW.js +0 -1
- package/dist/assets/UsageStatsView-DwTt9zIz.js +0 -1
- package/dist/assets/WorktreesView-Bh7GLvrR.js +0 -1
- package/dist/assets/appThemeRegistry-Bzb67M9O.js +0 -1
- package/dist/assets/computeVirtualFileMetrics-WAp98Bb7.js +0 -3
- package/dist/assets/index-BsupKM40.js +0 -1
- package/dist/assets/main-C_QGhDBL.js +0 -1048
- package/dist/assets/main-pWZ7F_hy.js +0 -2
- package/dist/assets/markdownCore-6gz4uJDQ.js +0 -9
- package/dist/assets/miniChat-DnaTfdYh.js +0 -2
- package/dist/assets/mobile-C7DIJqP8.js +0 -2
- package/dist/assets/pierreDiffTint-B297eqF0.js +0 -28
- package/dist/assets/relocateRestoredSession-D3lujODj.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-BF4hNe69.js +0 -2
- package/dist/assets/runtimeEndpointReset-D6Lxhk0S.js +0 -55
- package/dist/assets/scheduledTasksApi-DUbAMrjW.js +0 -1
- package/dist/assets/space-close-CWcWwH4_.js +0 -1
- package/dist/assets/useCallableModelProviders-BB9xkUzM.js +0 -1
- package/dist/assets/vendor-codemirror-lang-angular-BpYCRJSk.js +0 -1
- package/dist/assets/vendor-codemirror-lang-cpp-BI3uPyjT.js +0 -1
- package/dist/assets/vendor-codemirror-lang-css-B2_PZTBl.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-BpvvTxbZ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-java-BM5LQZ4u.js +0 -1
- package/dist/assets/vendor-codemirror-lang-jinja-D8nLZQPK.js +0 -1
- package/dist/assets/vendor-codemirror-lang-json-VDxF27mO.js +0 -1
- package/dist/assets/vendor-codemirror-lang-less-BecU2BJP.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-DCw83Anh.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-CimQAQbQ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-php-C5Kpnpyb.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-BFE1OJNx.js +0 -3
- package/dist/assets/vendor-codemirror-lang-rust-hqZDyGIJ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-sass-CAZML-Jl.js +0 -1
- package/dist/assets/vendor-codemirror-lang-vue-BHOTXcKp.js +0 -1
- package/dist/assets/vendor-codemirror-lang-wast-DcCHfPUI.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-BO_V-1wZ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-yaml-CPimap_N.js +0 -1
- package/dist/assets/vendor-codemirror-language-BBADuAkg.js +0 -3
- package/dist/assets/vendor-codemirror-language-data-Cu5ZbrPm.js +0 -2
- package/dist/assets/vendor-codemirror-view-1e0FQ6Wn.js +0 -4
- package/dist/assets/workerFactory-De9YXIdE.js +0 -1
|
@@ -1,1048 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-npRGKKx8.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/katex.min-Iw9WSgM9.js","assets/vendor-zod-CVhJ1Zpv.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DgOf1DP0.js","assets/katex-CMY-1eWf.css","assets/useAppFontEffects-3EN8Ava3.js","assets/vendor-base-ui-CXFyogip.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-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-CvuLsk7D.js","assets/vendor-tanstack-virtual-core-DPaNcJcT.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-BhRb6jns.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-1e0FQ6Wn.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-BBADuAkg.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-CUmSxayT.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-C8FBSI9t.js","assets/vendor-codemirror-lang-json-VDxF27mO.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-B2_PZTBl.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-BpvvTxbZ.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CimQAQbQ.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Cu5ZbrPm.js","assets/vendor-codemirror-lang-python-BFE1OJNx.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.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-legendapp-list-BCBzRcfK.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-D6Lxhk0S.js","assets/InProgressOperationBanner-B6iO22_7.js","assets/changesTree-CePHbFcj.js","assets/PierreDiffViewer-B9K0gBvV.js","assets/parseDiffFromFile-DcsKSY0J.js","assets/computeVirtualFileMetrics-WAp98Bb7.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-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.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/isDiffPlainText-BwicHPpI.js","assets/pierreDiffTint-B297eqF0.js","assets/Virtualizer-DL535kyR.js","assets/useInlineCommentController-l9cWyfuR.js","assets/appThemeRegistry-Bzb67M9O.js","assets/textMateThemeFromAppTheme-B6UJwdZz.js","assets/useRootScrollLock-UAQn24Y8.js","assets/moveWorkspacePath-B31RGdgu.js","assets/sessionOwnership-kZAtwMQd.js","assets/PlanView-IkTcPrbw.js","assets/shikiHighlight-BRNXPlF-.js","assets/vendor-codemirror-search-CvXM_pZg.js","assets/vendor-replit-codemirror-vim-Ck2X_WZC.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/FilePreviewCommentMenu-DlVgwRsr.js","assets/WalkthroughView-DcxbT5tc.js","assets/patchFileDiff-Cx-HpjyI.js","assets/useCallableModelProviders-BB9xkUzM.js","assets/DiffView-SHdJJ6tl.js","assets/SubmoduleDiffSummary-RDY5md3p.js","assets/FilesView-BeMtsSlV.js","assets/JsonTreeView-xGikhCtL.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-Dk2R7BJo.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/scheduledTasksApi-DUbAMrjW.js","assets/GuestSurfacePane-4kmEXPLD.js","assets/SettingsWindow-X74FIkdo.js","assets/SettingsView-DIy5ZL4-.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/restartOpenCode-dq-SGun3.js","assets/CommandPalette-1VlA7PbL.js","assets/HelpDialog-CITMqPDK.js","assets/OpenCodeStatusDialog-YMHuJzwt.js","assets/RunOverview-CHkGSW1x.js","assets/ScheduledTasksDialog-77SO8zdJ.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/ArchiveView-CjF4_TFg.js","assets/UsageStatsView-DwTt9zIz.js","assets/SourceBoardView-Cff2ejOW.js","assets/WorktreesView-Bh7GLvrR.js","assets/SpacesView-I3HaRKtW.js","assets/SpaceRow-YPmKQKeD.js","assets/SpaceAccessDialog-BXMZNRei.js","assets/spaceNetwork-DUxJClu3.js","assets/SpaceApplyDialog-BEJd2ryu.js","assets/space-apply-CCOKLfrX.js","assets/SpaceSetupOutput-Cb3XcIII.js","assets/OnboardingScreen-Cy6ARiMS.js","assets/AboutDialog-e8ek_kPI.js","assets/MemoryDebugPanel-CBk8QW-M.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as He,j as n,R as c,r as ds,c as ga,h as Yp}from"./vendor-react-BUCujlKS.js";import{u as de,cm as Ls,b as _s,m as Sn,e as gs,cw as Hd,ah as ba,Y as Yt,$ as No,n as ot,aV as Ss,ar as pn,ap as io,aq as hn,cx as Ur,a2 as fr,aG as Xp,at as Vd,cy as Qp,b7 as vs,cz as ya,cA as ao,cB as Io,cC as Zp,cD as hr,cE as Ii,cF as Ro,cG as Yn,a8 as lo,l as an,cH as Wn,aU as Jp,cI as Gd,cJ as em,cK as tm,cL as fn,cM as sm,cN as Ud,cO as nm,cP as rm,cQ as qd,cR as om,q as im,t as am,b9 as lm,aY as Do,aZ as cm,b1 as dm,b2 as um,ak as fm,ao as hm,aj as Fs,v as co,aR as uo,cS as pm,ai as xa,cr as Sa,bb as fo,aI as En,bm as os,a0 as Yd,az as To,cT as mm,cU as gm,cV as bm,aJ as Xd,cl as Mo,cW as Qd,cX as ym,cY as Ri,cZ as xm,bI as Zd,bJ as Jd,Z as Sm,bn as vm,bc as wm,c_ as km,c$ as Ml,bx as eu,as as tu,_ as jm,be as Cm,d0 as Pm,d1 as Em,aE as Nm,aC as Im,d2 as Rm,aK as Dm,bd as Tm,bA as Mm,d3 as Am,d4 as Om,d5 as Al,d6 as ai,d7 as Ol,d8 as Bl,d9 as Bm,av as Fl,da as Fm,db as Lm,dc as _m,aD as $m,dd as zm,i as Wm,a as Km}from"./katex.min-Iw9WSgM9.js";import{_ as ss}from"./vendor-vite-runtime-DD1OZmLC.js";import{b7 as Hm,b8 as va,a7 as Vm,ai as su,b9 as Gm,a2 as Um,a3 as qm,a5 as Di,g as Ym,l as Xm,h as Qm,f as Zm,j as Jm,k as eg,m as tg,P as sg,Q as ng,K as rg,W as og,X as ig,R as ag,G as lg,w as cg,u as dg,C as ug,ba as Tn,aq as fg,bb as nu,bc as ru,D as ou,A as jr,F as iu,z as wa,$ as hg,a0 as pg,an as mg,ao as gg,Z as bg,aF as au,bd as yg,ap as xg,aW as Sg,S as Ll,be as vg,aI as ka,aH as wg,a8 as kg,a6 as lu,bf as Rn,bg as cu,ah as jg,bh as du,bi as Cg,bj as _l,a9 as Pg,aa as Eg,b as Ng,a as Ig,bk as Rg,bl as or,ae as Dg,bm as Tg,af as $l,a1 as pr,ab as Mg,a4 as Ag,ag as Og,as as Bg,aE as Fg,aw as Lg,bn as _g,aB as $g,aC as zg,aG as Wg,bo as Kg,bp as Hg,bq as Vg,a$ as Gg,br as Ug,aJ as qg,ar as Yg,bs as Xg,au as Qg,bt as Zg,bu as Jg,ax as eb,ay as tb,aA as sb,az as nb,aD as rb,bv as ob,bw as ib}from"./runtimeEndpointReset-D6Lxhk0S.js";import{u as wt,jK as ab,I as Z,U as At,V as Tt,T as Ot,as as Cr,a2 as Zt,F as nt,cc as uu,L as ve,cu as ja,cv as Ca,cw as Pa,l8 as Mr,G as ws,J as Xn,ef as fu,ee as hu,b7 as Ti,l9 as lb,la as pu,b8 as mu,dy as gu,aE as js,aF as Cs,aG as Ps,bT as bn,aH as qt,l as Gs,E as Us,D as qs,Q as Ao,Z as Qn,q as $s,t as zs,z as _e,lb as cb,lc as db,ld as zl,le as Wl,a1 as bu,lf as ub,lg as Kl,lh as fb,li as yu,lj as Ea,lk as Mi,by as xu,ll as hb,lm as pb,ln as mb,gr as Su,lo as Na,lp as gb,gi as Ln,ar as Mn,lq as bb,gj as yb,d2 as vu,lr as xb,d3 as Sb,ls as wu,ak as Oo,lt as ku,lu as ju,lv as Cu,lw as Pu,lx as Eu,ly as Nu,ii as sr,bd as Ia,an as Ra,d7 as Iu,o as yn,B as Ct,lz as Ru,eN as Da,lA as Ai,n as Pr,aI as bs,ag as Du,aj as Tu,lB as vb,lC as wb,aq as Ws,iv as Mu,iu as Au,ex as mn,bS as Oi,ie as kb,dP as jb,ap as vn,lD as Cb,lE as Pb,c7 as Eb,c6 as Nb,fp as Ib,f6 as Rb,fF as Db,ew as Ou,dQ as en,d_ as Tb,ac as ls,dZ as Bu,ez as Bi,ey as _n,eA as Fu,lF as Lu,lG as _u,lH as Mb,lI as Ab,lJ as Ob,eC as Ta,bJ as Bb,bH as Fb,bG as Lb,bI as _b,bB as $b,y as ho,co as Hl,bM as zb,bO as Vl,lK as Wb,lL as Kb,jI as Hb,cb as Ma,dY as Vb,e0 as Aa,eK as Gb,d$ as Ub,ao as gn,fv as $u,ct as qb,lM as Fn,aa as Yb,lN as Xb,_ as ns,gl as zu,lO as Qb,bD as Zb,x as Wu,br as Jb,lP as ey,lQ as ty,eM as Ku,lR as nr,lS as Hu,lT as Fi,lU as Li,lV as Gl,g7 as Dn,g6 as qr,cg as sy,lW as ny,lX as Er,cY as Oa,lY as Ba,lZ as ry,cx as wn,l_ as oy,l$ as iy,m0 as ay,m1 as ly,a7 as cy,m2 as Vu,aL as dy,eU as uy,aN as fy,m3 as Bn,m4 as Ul,m5 as ql,m6 as li,bj as hy,m7 as Yl,fQ as py,fT as my,e3 as gy,fU as by,bb as yy,g5 as Fa,g8 as Gu,m8 as Bo,g9 as La,ga as _a,cI as xy,C as Sy,m9 as ci,ma as vy,mb as wy,mc as Uu,md as ky,me as qu,hq as jy,mf as Cy,mg as Py,mh as Ey,mi as Ny,ah as Iy,mj as Xl,mk as Ry,ml as Ql,mm as Zl,gG as po,gf as $a,cH as Yu,mn as Dy,gF as za,gH as mr,mo as Xu,l0 as cs,ih as Qu,ij as Zu,g2 as Ju,g3 as ef,g4 as tf,mp as Ty,kL as Jl,mq as My,mr as sf,ms as Ay,mt as nf,mu as _i,bF as rf,mv as Wa,mw as Oy,mx as By,my as Fy,cF as Fo,l7 as Xt,mz as Ly,kd as of,mA as af,mB as lf,mC as xr,mD as ec,mE as _y,mF as Sr,mG as $y,mH as zy,mI as Ka,mJ as mo,mK as Ha,mL as cf,mM as df,mN as uf,mO as ff,a9 as Wy,mP as Ky,gn as Hy,gv as Vy,gy as Va,gI as Gy,gw as Uy,gx as qy,mQ as Yy,eg as Xy,N as Qy,eh as hf,jZ as Zy,mR as Jy,mS as ex,mT as Kn,mU as tx,go as sx,mV as Yr,de as Lo,gz as $i,mW as nx,gJ as rx,mX as ox,mY as pf,O as xn,gC as ix,mZ as ax,e5 as lx,ci as mf,m_ as cx,m$ as dx,n0 as tc,kb as ux,n1 as fx,a3 as hx,gE as px,kJ as mx,f7 as kn,n2 as gx,n3 as bx,n4 as yx,cS as xx,n5 as Sx,dp as sc,dn as nc,bA as rc,n6 as vx,n7 as wx,cf as kx,n8 as jx,gq as oc,gs as di,gt as Cx,n9 as Px,gu as Ex,na as Nx,k as Ix,nb as Rx,eo as zi,fM as Dx,nc as gf,nd as Tx,cL as Mx,ne as ic,nf as Ax,cJ as Ox,dA as bf,ng as Wi,W as yf,dz as xf,cG as Sf,nh as Bx,b$ as Xr,h_ as Fx,gg as Lx,h$ as _x,jc as $x,gk as zx,bR as Wx,kY as ac,ni as Kx,da as Hx,nj as Vx,cU as lc,db as Gx,dd as Ux,dc as qx,dj as Yx,di as Xx,g_ as Qx,dh as Zx,df as Jx,dg as e1,a as t1,s as s1,b as n1,c as r1,h5 as o1,dq as i1,dr as a1,ds as l1,dt as c1}from"./useAppFontEffects-3EN8Ava3.js";import{u as vf,S as d1,W as wf,f as kf,a as u1,G as f1,b as h1,c as p1}from"./useRootScrollLock-UAQn24Y8.js";import{f as _o,h as sn,T as $o,M as zo,D as Wo,j as Ko,d as m1,b as g1,k as b1,i as y1}from"./vendor-dnd-kit-core-BZknOX2w.js";import{r as x1,h as S1,u as Ho,S as Ga,a as jf,v as Cf,s as v1}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Vo}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Pf,M as Ef,k as Nf,l as Ki,m as Hi,n as Vi,o as If,p as w1,q as k1}from"./vendor-base-ui-CXFyogip.js";import{c as Nr,u as Zn,p as j1}from"./vendor-zustand-BAGL70zf.js";import{r as Ua,a as Go,n as C1,s as rn,o as Gi,b as cc}from"./vendor-zod-CVhJ1Zpv.js";import{D as P1,a as E1,m as dc,G as N1}from"./moveWorkspacePath-B31RGdgu.js";import{c as I1}from"./sessionOwnership-kZAtwMQd.js";import{u as R1}from"./vendor-tanstack-react-virtual-CvuLsk7D.js";import{m as D1,d as T1}from"./vendor-tanstack-virtual-core-DPaNcJcT.js";const M1=t=>{const e=He.c(23),{directory:s,className:r,iconClassName:o}=t,{t:i}=wt(),a=de(A1);let l;e[0]!==s?(l=Ls(s),e[0]=s,e[1]=l):l=e[1];const d=l;let u;e[2]!==d?(u=w=>ab(d?w.journey?.get(d):void 0),e[2]=d,e[3]=u):u=e[3];const f=_s(u);let h;e[4]!==d?(h=w=>d?w.actions.get(d)?.kind==="running":!1,e[4]=d,e[5]=h):h=e[5];const m=_s(h);if(!a||!d||!f||Sn())return null;let g;e[6]!==i?(g=i("spaces.header.apply"),e[6]=i,e[7]=g):g=e[7];const b=g;let v;e[8]!==d?(v=()=>_s.getState().openApplyDialog(d),e[8]=d,e[9]=v):v=e[9];let S;e[10]!==o?(S=n.jsx(Z,{name:"git-merge",className:o}),e[10]=o,e[11]=S):S=e[11];let x;e[12]!==m||e[13]!==r||e[14]!==b||e[15]!==v||e[16]!==S?(x=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":b,disabled:m,onClick:v,className:r,children:S})}),e[12]=m,e[13]=r,e[14]=b,e[15]=v,e[16]=S,e[17]=x):x=e[17];let p;e[18]!==b?(p=n.jsx(Tt,{side:"bottom",children:b}),e[18]=b,e[19]=p):p=e[19];let y;return e[20]!==x||e[21]!==p?(y=n.jsxs(Ot,{children:[x,p]}),e[20]=x,e[21]=p,e[22]=y):y=e[22],y};function A1(t){return t.isolatedSpacesEnabled}function O1(t){const e=He.c(36),{directory:s,className:r}=t,{currentTheme:o}=Cr(),i=Zt(L1),a=nt(F1),l=gs(B1);let d;e[0]!==s||e[1]!==l?(d=Hd(s,l),e[0]=s,e[1]=l,e[2]=d):d=e[2];const u=d;let f;e[3]!==s||e[4]!==u||e[5]!==i||e[6]!==a?(f=u||!s?null:uu(i,a,s),e[3]=s,e[4]=u,e[5]=i,e[6]=a,e[7]=f):f=e[7];const h=f;if(u){let P;e[8]!==r?(P=ve("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),e[8]=r,e[9]=P):P=e[9];let A;return e[10]!==P?(A=n.jsx(Z,{name:"chat-4",className:P}),e[10]=P,e[11]=A):A=e[11],A}if(!h)return null;const m=h.icon?ja[h.icon]:null;let g;e[12]!==h.color?(g=Ca(h.color)??void 0,e[12]=h.color,e[13]=g):g=e[13];const b=g;let v;e[14]!==r||e[15]!==b||e[16]!==m?(v=m?n.jsx(Z,{name:m,className:ve("h-3.5 w-3.5 shrink-0",r),style:b?{color:b}:void 0}):n.jsx(Z,{name:"folder",className:ve("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),style:b?{color:b}:void 0}),e[14]=r,e[15]=b,e[16]=m,e[17]=v):v=e[17];const S=v;if(!h.iconImage)return S;let x;e[18]!==r?(x=ve("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[18]=r,e[19]=x):x=e[19];let p;e[20]!==h.iconBackground?(p=h.iconBackground?{backgroundColor:h.iconBackground}:void 0,e[20]=h.iconBackground,e[21]=p):p=e[21];let y;e[22]!==h.iconImage||e[23]!==h.id?(y={id:h.id,iconImage:h.iconImage},e[22]=h.iconImage,e[23]=h.id,e[24]=y):y=e[24];let w;e[25]!==o.colors.surface.foreground||e[26]!==o.metadata.variant?(w={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[25]=o.colors.surface.foreground,e[26]=o.metadata.variant,e[27]=w):w=e[27];let j;e[28]!==S||e[29]!==y||e[30]!==w?(j=n.jsx(Pa,{project:y,options:w,className:"h-full w-full object-contain",fallback:S}),e[28]=S,e[29]=y,e[30]=w,e[31]=j):j=e[31];let k;return e[32]!==x||e[33]!==p||e[34]!==j?(k=n.jsx("span",{className:x,style:p,children:j}),e[32]=x,e[33]=p,e[34]=j,e[35]=k):k=e[35],k}function B1(t){return t.homeDirectory}function F1(t){return t.availableWorktreesByProject}function L1(t){return t.projects}const _1=({transform:t})=>({...t,y:0}),$1=16,z1=t=>{if(t.shiftKey||t.ctrlKey||t.metaKey||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;const e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*$1:t.deltaY;t.currentTarget.scrollLeft+=ba(t.currentTarget)?-e:e},W1={Item:qt,Separator:bn},K1={Item:({className:t,...e})=>n.jsx(Ef,{className:ve(mu,t),...e}),Separator:({className:t,...e})=>n.jsx(Pf,{className:ve(pu,t),...e})},H1=t=>{const e=He.c(63),{tab:s,isActive:r,suppressControls:o,onSelect:i,onClose:a,renderMenu:l,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:f}=t,{t:h}=wt(),[m,g]=c.useState(!1),[b,v]=c.useState(!1),[S,x]=c.useState(!1);let p;e[0]!==s.id?(p={id:s.id},e[0]=s.id,e[1]=p):p=e[1];const{attributes:y,listeners:w,setNodeRef:j,transform:k,transition:P,isDragging:A}=Ho(p);let B;e[2]!==h||e[3]!==s.session.title?(B=s.session.title?.trim()||h("sessions.sidebar.session.untitled"),e[2]=h,e[3]=s.session.title,e[4]=B):B=e[4];const R=B,E=!o&&(m||b),T=s.id;let z;e[5]!==s.session?(z=Xn(s.session),e[5]=s.session,e[6]=z):z=e[6];const O=va(T,z),W=fu(s.id),D=W!==null,N=hu(s.id)>0&&!r&&!D,C=D||N;let I;e[7]!==d||e[8]!==S||e[9]!==r||e[10]!==m||e[11]!==i||e[12]!==s?(I=Ce=>({session:s.session,open:m||S,isActive:r,select:()=>i(s),closeOtherTabs:()=>d(s.id),components:Ce}),e[7]=d,e[8]=S,e[9]=r,e[10]=m,e[11]=i,e[12]=s,e[13]=I):I=e[13];const H=I;let M;e[14]!==k?(M=Vo.Translate.toString(k),e[14]=k,e[15]=M):M=e[15];let _;e[16]!==M||e[17]!==P?(_={transform:M,transition:P},e[16]=M,e[17]=P,e[18]=_):_=e[18];const F=A&&"z-10 opacity-60";let ee;e[19]!==F?(ee=ve("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",F),e[19]=F,e[20]=ee):ee=e[20];const ne=r?"true":"false";let re;e[21]!==r?(re=r?{"data-active-session-tab":!0}:{},e[21]=r,e[22]=re):re=e[22];let te;e[23]!==u?(te=Ce=>u?.(Ce),e[23]=u,e[24]=te):te=e[24];let K;e[25]!==f||e[26]!==r||e[27]!==O||e[28]!==H||e[29]!==m||e[30]!==a||e[31]!==u||e[32]!==i||e[33]!==E||e[34]!==l||e[35]!==C||e[36]!==o||e[37]!==h||e[38]!==s||e[39]!==R||e[40]!==W?(K=n.jsx(Nf,{render:Ce=>n.jsxs("div",{...Ce,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>i(s),onKeyDown:r?void 0:Y=>{(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),i(s))},onAuxClick:Y=>{Y.button===1&&(Y.preventDefault(),a(s.id))},"data-controls-open":E?"true":"false",className:ve("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":ve("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",E&&"bg-interactive-hover text-foreground")),children:[n.jsxs("div",{className:ve("flex min-w-0 flex-1 items-center",!o&&"group-hover/session-tab:pe-10",E&&"pe-10"),children:[n.jsx(O1,{directory:Xn(s.session),className:"me-1.5"}),n.jsx("div",{className:ve("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!o&&"session-tab-title"),children:r?f:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:n.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[13px] font-medium leading-4",children:R})})}),O?n.jsx(Z,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":h("sessions.aiRename.generating")}):C?n.jsx(gu,{state:W??"unread",className:ve("ms-1.5 shrink-0",!o&&"group-hover/session-tab:opacity-0",E&&"opacity-0")}):null]}),o?null:n.jsxs("div",{onClick:G1,onPointerDown:U1,className:ve("absolute inset-e-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",E&&"flex opacity-100"),children:[n.jsxs(js,{open:m,onOpenChange:Y=>{g(Y),Y&&v(!0)},onOpenChangeComplete:Y=>{Y||v(!1),u?.(Y)},children:[n.jsx(Cs,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":h("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"more",className:"size-4"})})}),n.jsx(Ps,{align:"start",className:"min-w-[190px]",children:l(H(W1))})]}),n.jsx("button",{type:"button","aria-label":h("header.sessionTabs.closeTab"),onClick:()=>a(s.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"close",className:"size-4"})})]})]})}),e[25]=f,e[26]=r,e[27]=O,e[28]=H,e[29]=m,e[30]=a,e[31]=u,e[32]=i,e[33]=E,e[34]=l,e[35]=C,e[36]=o,e[37]=h,e[38]=s,e[39]=R,e[40]=W,e[41]=K):K=e[41];let q,oe;e[42]===Symbol.for("react.memo_cache_sentinel")?(q={color:"var(--surface-elevated-foreground)"},oe=ve(Ti,"min-w-[190px]"),e[42]=q,e[43]=oe):(q=e[42],oe=e[43]);let fe;e[44]!==H||e[45]!==l?(fe=l(H(K1)),e[44]=H,e[45]=l,e[46]=fe):fe=e[46];let ce;e[47]!==fe?(ce=n.jsx(Ki,{children:n.jsx(Hi,{className:"app-region-no-drag z-50",children:n.jsx(Vi,{"data-slot":"dropdown-menu-content",style:q,className:oe,children:fe})})}),e[47]=fe,e[48]=ce):ce=e[48];let ke;e[49]!==S||e[50]!==te||e[51]!==K||e[52]!==ce?(ke=n.jsxs(If,{open:S,onOpenChange:x,onOpenChangeComplete:te,children:[K,ce]}),e[49]=S,e[50]=te,e[51]=K,e[52]=ce,e[53]=ke):ke=e[53];let De;return e[54]!==y||e[55]!==w||e[56]!==j||e[57]!==ne||e[58]!==re||e[59]!==ke||e[60]!==_||e[61]!==ee?(De=n.jsx("div",{ref:j,style:_,className:ee,"data-active":ne,...re,...y,...w,children:ke}),e[54]=y,e[55]=w,e[56]=j,e[57]=ne,e[58]=re,e[59]=ke,e[60]=_,e[61]=ee,e[62]=De):De=e[62],De},V1=t=>{const e=He.c(66),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,a=o===void 0?!1:o,{t:l,direction:d}=wt(),u=d==="rtl",f=Mr(q1),h=Mr(Y1),m=Mr(X1),g=Mr(Q1),b=nt(Z1),v=nt(J1),S=ws(eS),x=Hm(b);let p,y;e[0]!==x||e[1]!==b||e[2]!==h?(p=()=>{b&&h(b,x)},y=[b,x,h],e[0]=x,e[1]=b,e[2]=h,e[3]=p,e[4]=y):(p=e[3],y=e[4]),c.useEffect(p,y);let w;if(e[5]!==S){w=new Map;for(const G of S)w.set(G.id,G);e[5]=S,e[6]=w}else w=e[6];const j=w;let k;if(e[7]!==j||e[8]!==f){k=[];for(const G of f){const ae=j.get(G);ae&&k.push({id:G,session:ae})}e[7]=j,e[8]=f,e[9]=k}else k=e[9];const P=k;let A;e[10]!==v?(A=G=>{v(G.id,Xn(G.session))},e[10]=v,e[11]=A):A=e[11];const B=A,R=tS;let E;e[12]!==m||e[13]!==b||e[14]!==B||e[15]!==P?(E=G=>{if(m(G),b&&b!==G){const ae=P.find(ge=>ge.id===G);ae&&B(ae)}},e[12]=m,e[13]=b,e[14]=B,e[15]=P,e[16]=E):E=e[16];const T=E;let z;e[17]===Symbol.for("react.memo_cache_sentinel")?(z={activationConstraint:{distance:8}},e[17]=z):z=e[17];let O;e[18]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{delay:200,tolerance:6}},e[18]=O):O=e[18];const W=_o(sn(zo,z),sn($o,O));let D;e[19]!==g?(D=G=>{const{active:ae,over:ge}=G;ge&&ae.id!==ge.id&&g(String(ae.id),String(ge.id))},e[19]=g,e[20]=D):D=e[20];const Q=D,N=c.useRef(null);let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C={left:!1,right:!1},e[21]=C):C=e[21];const[I,H]=c.useState(C);let M;e[22]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{const G=N.current;if(!G)return;const ae=G.scrollWidth-G.clientWidth,ge=ba(G)?ae+G.scrollLeft:G.scrollLeft,me=ge>2,be=ge<ae-2;H(ye=>ye.left===me&&ye.right===be?ye:{left:me,right:be})},e[22]=M):M=e[22];const _=M;let F;e[23]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{_();const G=N.current;if(!G||!globalThis.ResizeObserver)return;const ae=new ResizeObserver(_);return ae.observe(G),()=>ae.disconnect()},e[23]=F):F=e[23];let ee;e[24]!==P.length?(ee=[_,P.length],e[24]=P.length,e[25]=ee):ee=e[25],c.useEffect(F,ee);let ne;e[26]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{N.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[26]=ne):ne=e[26];let re;e[27]!==b?(re=[b],e[27]=b,e[28]=re):re=e[28],c.useEffect(ne,re);const te=I.left&&I.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":I.left?"linear-gradient(to right, transparent, black 24px)":I.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let K;e[29]!==P?(K=P.map(sS),e[29]=P,e[30]=K):K=e[30];const q=K;let oe;e[31]!==b||e[32]!==P?(oe=!!b&&!P.some(G=>G.id===b),e[31]=b,e[32]=P,e[33]=oe):oe=e[33];const fe=oe;let ce;e[34]!==l?(ce=l("header.sessionTabs.stripAria"),e[34]=l,e[35]=ce):ce=e[35];let ke;e[36]!==te?(ke=te?{maskImage:te,WebkitMaskImage:te}:void 0,e[36]=te,e[37]=ke):ke=e[37];let De;e[38]===Symbol.for("react.memo_cache_sentinel")?(De=[_1],e[38]=De):De=e[38];const Ce=u?x1:S1;let Y;e[39]!==i||e[40]!==b||e[41]!==T||e[42]!==B||e[43]!==r||e[44]!==s||e[45]!==a||e[46]!==P?(Y=P.map(G=>n.jsx(H1,{tab:G,isActive:G.id===b,suppressControls:G.id===b&&a,onSelect:B,onClose:R,renderMenu:s,closeOtherTabs:T,onMenuOpenChangeComplete:r,children:G.id===b?i:null},G.id)),e[39]=i,e[40]=b,e[41]=T,e[42]=B,e[43]=r,e[44]=s,e[45]=a,e[46]=P,e[47]=Y):Y=e[47];let je;e[48]!==Ce||e[49]!==Y||e[50]!==q?(je=n.jsx(Ga,{items:q,strategy:Ce,children:Y}),e[48]=Ce,e[49]=Y,e[50]=q,e[51]=je):je=e[51];let we;e[52]!==Q||e[53]!==W||e[54]!==je?(we=n.jsx(Wo,{sensors:W,collisionDetection:Ko,modifiers:De,onDragEnd:Q,children:je}),e[52]=Q,e[53]=W,e[54]=je,e[55]=we):we=e[55];let Pe;e[56]!==i||e[57]!==fe?(Pe=fe?n.jsx("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag 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:i})}):null,e[56]=i,e[57]=fe,e[58]=Pe):Pe=e[58];let L;e[59]!==ke||e[60]!==we||e[61]!==Pe?(L=n.jsxs("div",{ref:N,onScroll:_,onWheel:z1,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:ke,children:[we,Pe]}),e[59]=ke,e[60]=we,e[61]=Pe,e[62]=L):L=e[62];let ie;return e[63]!==ce||e[64]!==L?(ie=n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ce,children:L}),e[63]=ce,e[64]=L,e[65]=ie):ie=e[65],ie};function G1(t){return t.stopPropagation()}function U1(t){return t.stopPropagation()}function q1(t){return t.tabIds}function Y1(t){return t.ensureTab}function X1(t){return t.closeOtherTabs}function Q1(t){return t.reorderTabs}function Z1(t){return t.currentSessionId}function J1(t){return t.setCurrentSession}function eS(t){return t.activeSessions}function tS(t){lb(t)}function sS(t){return t.id}const nS=500;function Qt(t){const e=He.c(9),{hint:s,children:r}=t,[o,i]=c.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=(f,h)=>{f&&h.reason==="trigger-focus"||i(f)},e[0]=a):a=e[0];let l;e[1]!==r?(l=n.jsx(At,{asChild:!0,children:r}),e[1]=r,e[2]=l):l=e[2];let d;e[3]!==s?(d=n.jsx(Tt,{side:"right",sideOffset:8,className:"max-w-64",children:s}),e[3]=s,e[4]=d):d=e[4];let u;return e[5]!==o||e[6]!==l||e[7]!==d?(u=n.jsxs(Ot,{delayDuration:nS,open:o,onOpenChange:a,children:[l,d]}),e[5]=o,e[6]=l,e[7]=d,e[8]=u):u=e[8],u}const rS=t=>{const e=He.c(29),{open:s,onOpenChange:r,onPick:o}=t,{t:i}=wt(),a=Zt(oS),l=gs(iS);let d;e[0]!==i?(d=i("sessions.moveChatToProject.title"),e[0]=i,e[1]=d):d=e[1];let u;e[2]!==d?(u=n.jsx(Gs,{children:d}),e[2]=d,e[3]=u):u=e[3];let f;e[4]!==i?(f=i("sessions.moveChatToProject.description"),e[4]=i,e[5]=f):f=e[5];let h;e[6]!==f?(h=n.jsx(Us,{children:f}),e[6]=f,e[7]=h):h=e[7];let m;e[8]!==u||e[9]!==h?(m=n.jsxs(qs,{children:[u,h]}),e[8]=u,e[9]=h,e[10]=m):m=e[10];let g;if(e[11]!==l||e[12]!==r||e[13]!==o||e[14]!==a){let x;e[16]!==l||e[17]!==r||e[18]!==o?(x=p=>n.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-start hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] focus-visible:outline-none",onClick:()=>{r(!1),o(p.path)},children:[n.jsx(Z,{name:"folder",className:"size-4 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:p.label?.trim()||Ao(p.path)}),n.jsx("span",{className:"min-w-0 max-w-[45%] truncate typography-micro text-muted-foreground",children:Qn(p.path,l)})]},p.id),e[16]=l,e[17]=r,e[18]=o,e[19]=x):x=e[19],g=a.map(x),e[11]=l,e[12]=r,e[13]=o,e[14]=a,e[15]=g}else g=e[15];let b;e[20]!==g?(b=n.jsx("div",{className:"flex max-h-[50vh] flex-col gap-0.5 overflow-y-auto",children:g}),e[20]=g,e[21]=b):b=e[21];let v;e[22]!==m||e[23]!==b?(v=n.jsxs($s,{className:"max-w-md",children:[m,b]}),e[22]=m,e[23]=b,e[24]=v):v=e[24];let S;return e[25]!==r||e[26]!==s||e[27]!==v?(S=n.jsx(zs,{open:s,onOpenChange:r,children:v}),e[25]=r,e[26]=s,e[27]=v,e[28]=S):S=e[28],S};function oS(t){return t.projects}function iS(t){return t.homeDirectory}function uc(t){const e=He.c(28),{sessionId:s,onArchive:r,Item:o}=t,{t:i}=wt();let a;e[0]!==s?(a=k=>!!k.entityById.get(s)?.time.archived,e[0]=s,e[1]=a):a=e[1];const l=ws(a);let d;e[2]!==s?(d=k=>!!k.entityById.get(s)?.parentID,e[2]=s,e[3]=d):d=e[3];const u=ws(d),f=nt(aS);let h;e[4]!==s||e[5]!==i||e[6]!==f?(h=async()=>{await f(s)?_e.success(i("sessions.sidebar.session.restore.success")):_e.error(i("sessions.sidebar.session.restore.error"))},e[4]=s,e[5]=i,e[6]=f,e[7]=h):h=e[7];const m=h;if(l&&u)return null;const g=l?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let b;e[8]!==i||e[9]!==g?(b=i(g),e[8]=i,e[9]=g,e[10]=b):b=e[10];let v;e[11]!==l||e[12]!==r||e[13]!==m?(v=l?()=>{m()}:r,e[11]=l,e[12]=r,e[13]=m,e[14]=v):v=e[14];const S=l?"inbox-unarchive":"inbox-archive";let x;e[15]!==S?(x=n.jsx(Z,{name:S,className:"me-1 size-4"}),e[15]=S,e[16]=x):x=e[16];const p=l?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let y;e[17]!==i||e[18]!==p?(y=i(p),e[17]=i,e[18]=p,e[19]=y):y=e[19];let w;e[20]!==o||e[21]!==y||e[22]!==v||e[23]!==x?(w=n.jsxs(o,{onClick:v,children:[x,y]}),e[20]=o,e[21]=y,e[22]=v,e[23]=x,e[24]=w):w=e[24];let j;return e[25]!==w||e[26]!==b?(j=n.jsx(Qt,{hint:b,children:w}),e[25]=w,e[26]=b,e[27]=j):j=e[27],j}function aS(t){return t.unarchiveSession}const Rf=async t=>{const{entry:e,session:s}=t,r=Yt(),o={sessionId:s.id,sessionTitle:s.title,directory:s.directory};if(!(cb(e.action)&&db(e.guest,"conversation"))){await zl(e,Wl(e.action.id,o),t.t,r);return}let a=!1;const l=No(()=>{a=!0});let d;try{d=await t.loadRecords()}finally{l()}if(!a){if(!d){t.onLoadFailed();return}await zl(e,Wl(e.action.id,o,d),t.t,r)}};function Ui(t){const e=He.c(14),{sessionID:s,directory:r,open:o,Item:i}=t,{t:a}=wt(),{pending:l,disabled:d,hint:u,run:f}=Vm(s,r,o),h=l?"loader-4":"ai-generate-2",m=l?"me-1 size-4 animate-spin":"me-1 size-[15px]";let g;e[0]!==h||e[1]!==m?(g=n.jsx(Z,{name:h,className:m}),e[0]=h,e[1]=m,e[2]=g):g=e[2];let b;e[3]!==a?(b=a("sessions.aiRename.action"),e[3]=a,e[4]=b):b=e[4];let v;e[5]!==i||e[6]!==d||e[7]!==f||e[8]!==g||e[9]!==b?(v=n.jsx("span",{className:"block",children:n.jsxs(i,{disabled:d,onClick:f,className:"w-full",children:[g,b]})}),e[5]=i,e[6]=d,e[7]=f,e[8]=g,e[9]=b,e[10]=v):v=e[10];let S;return e[11]!==u||e[12]!==v?(S=n.jsx(Qt,{hint:u,children:v}),e[11]=u,e[12]=v,e[13]=S):S=e[13],S}const go=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class Df extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const Uo=Nr(()=>({pendingSessionIds:new Set})),Tf=t=>{const e=He.c(2);let s;return e[0]!==t?(s=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=s):s=e[1],Uo(s)},fc=(t,e)=>{Uo.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}})},lS=async(t,e)=>{try{const d=(await mb(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const s=ot(t),r=ot(e)??e,o=nt.getState().availableWorktreesByProject,a=(o.get(r)??o.get(e)??[]).find(l=>ot(l.path)===s)?.branch?.trim();if(a)return a;throw new Error("Unable to determine the current branch")},hc=t=>{for(const e of t){const s=fb(e.id);if(s==="unknown")throw new Error("Session status is unavailable");if(s==="active")throw new Error("Session is not idle")}};class cS extends Error{constructor(e,s){super(e,{cause:s}),this.name="IncompleteRollbackError"}}const dS=(t,e)=>{const s=e.map(({sessionId:r,error:o})=>`${r}: ${o.message}`).join(", ");return new cS(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${s}`,{moveError:t,rollbackFailures:e})},uS=async(t,e,s,r)=>{const o=[];for(const i of[...t].reverse()){if(yu(i.id)){o.push({sessionId:i.id,error:new Error("Session is not idle")});continue}try{await bu(i,s,e),nt.getState().setWorktreeMetadata(i.id,r.get(i.id)??null)}catch(a){o.push({sessionId:i.id,error:a instanceof Error?a:new Error(String(a))})}}return o},pc=async(t,e,s)=>{try{await Su(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${s.message}`)}throw s},mc=async(t,e)=>{const s=e?[t,e]:[t];try{await Ea(s)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},qa=async(t,e)=>{if(Uo.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");fc(t.root.id,!0);try{const s=[...t.descendants,t.root],r=new Map(s.map(l=>[l.id,nt.getState().getWorktreeMetadata(l.id)]));hc(s);let o=null;const i=[];let a=!1;try{o=await e();for(const[l,d]of s.entries()){hc(s.slice(l));try{await bu(d,t.sourceDirectory,o.directory)}catch(u){throw ub(u)&&(a=!0),u}i.push(d),d.id!==t.root.id&&nt.getState().setWorktreeMetadata(d.id,o.metadata?Kl(o.metadata):null)}}catch(l){const d=l instanceof Error?l:new Error(String(l)),u=await uS(i,t.sourceDirectory,o?.directory??t.sourceDirectory,r);if(a&&await mc(t.sourceDirectory,o?.directory),u.length>0)throw dS(d,u);if(o?.onMoveFailure&&!a)return o.onMoveFailure(d);throw o?.onMoveFailure&&a?new Df(d):d}return nt.getState().setWorktreeMetadata(t.root.id,o.metadata?Kl(o.metadata):null),await mc(t.sourceDirectory,o.directory),o.directory}finally{fc(t.root.id,!1)}},fS=async t=>{const e=ot(t.sourceDirectory)??t.sourceDirectory,s=ot(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 qa(t,async()=>({directory:t.destination.path,metadata:t.destination}))},hS=async t=>{if((ot(t.sourceDirectory)??t.sourceDirectory)===(ot(t.projectDirectory)??t.projectDirectory))throw new Error("Source and destination are the same");return qa(t,async()=>({directory:t.projectDirectory,metadata:null}))},pS=async t=>qa(t,async()=>{const e=Mi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const s=await xu(t.sourceDirectory)?await lS(t.sourceDirectory,e.path):null,r=await hb(e,s?{startRef:s}:{});try{await pb(r.path)}catch(o){const i=o instanceof Error?o:new Error(String(o));return pc(e,r,i)}return{directory:r.path,metadata:r,onMoveFailure:async o=>pc(e,r,o)}}),mS=t=>{(t.kind==="existing"?fS({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):t.kind==="project"?hS({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,projectDirectory:t.projectDirectory}):pS({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>_e.success(t.messages.success)).catch(s=>{const r=s instanceof Error?s:new Error(String(s));_e.error(t.messages.failure,{description:r instanceof Df?t.messages.outcomeUnknown:r.message})})},bo=t=>{Uo.getState().pendingSessionIds.has(t.root.id)||mS(t)},ui="--oc-titlebar-controls-width",qi=new Set;let gr=null;const Mf=t=>{gr===null?t.style.removeProperty(ui):t.style.getPropertyValue(ui)!==gr&&t.style.setProperty(ui,gr)},gS=t=>{const e=`${Math.round(t)}px`;e!==gr&&(gr=e,qi.forEach(Mf))},Af=t=>{if(t)return qi.add(t),Mf(t),()=>{qi.delete(t)}},ir="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground data-[popup-open]:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 transition-colors",jn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},bS=()=>{Ss("ui.header.render");const{t,direction:e}=wt(),s=de(V=>V.isSidebarOpen),r=Na(),o=de(V=>V.sessionTabsEnabled),i=nt(V=>!!V.newSessionDraft?.open),a=nt(V=>V.currentSessionId),l=gb(a??""),d=Tf(a??""),u=ws(Zn(c.useCallback(V=>{if(!a)return null;const Ie=[...V.activeSessions,...V.archivedSessions].find(Qe=>Qe.id===a);if(!Ie)return null;const Le=Ie;return{title:Ie.title??null,directory:Le.directory??null,created:Ie.time?.created??null,slug:Le.slug??null,parentId:Ie.parentID??null}},[a]))),f=Zt(Zn(V=>{if(!V.activeProjectId)return null;const Ie=V.projects.find(Le=>Le.id===V.activeProjectId);return Ie?{id:Ie.id,path:Ie.path,label:Ie.label}:null})),h=c.useMemo(()=>{if(!f)return null;const V=f.label?.trim();if(V)return V;const Ie=f.path.split(/[\\/]/).filter(Boolean);return Ie[Ie.length-1]??null},[f]),m=Ln(V=>V.loadSettings),{isMobile:g}=Mn(),b=c.useRef(null),[v,S]=c.useState(()=>typeof window>"u"?!1:pn()),x=c.useMemo(()=>io(),[]),p=bb(),[y,w]=c.useState(!1),j=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:k,side:P}=vf(),A=c.useMemo(()=>{if(typeof window>"u")return null;const V=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(typeof navigator>"u")return null;const Ie=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Ie)return null;const Le=Number.parseInt(Ie[1],10),Qe=Number.parseInt(Ie[2],10);return Number.isNaN(Le)?null:Le===10?Qe:Le},[]);ds.useEffect(()=>{typeof window>"u"||S(pn())},[]);const B=c.useMemo(()=>Sn(),[]),R=de(V=>V.workStatusPanelVisible),E=de(V=>V.workStatusPanelEnabled),T=de(V=>V.setWorkStatusPanelEnabled),z=de(V=>V.workStatusPanelFits),O=de(V=>V.workStatusOverlayOpen),W=de(V=>V.setWorkStatusOverlayOpen),Q=E&&z||O,N=c.useCallback(()=>{if(E&&!z){W(!O);return}T(!E)},[W,T,O,E,z]);yb(),c.useEffect(()=>{m()},[m]);const C=a?u??null:null,I=c.useRef(null),[H,M]=c.useState(0);c.useEffect(()=>{if(!a){I.current&&(I.current=null,M(Qe=>Qe+1));return}if(C){I.current={sessionId:a,session:C,expiresAt:Date.now()+2e3};return}const V=I.current;if(!V||V.sessionId!==a)return;const Ie=V.expiresAt-Date.now();if(Ie<=0){I.current=null,M(Qe=>Qe+1);return}const Le=window.setTimeout(()=>{I.current?.sessionId===a&&(I.current=null),M(Qe=>Qe+1)},Ie);return()=>{window.clearTimeout(Le)}},[a,C]);const _=(()=>{if(C)return C;if(!a)return null;const V=I.current;return V&&V.sessionId===a&&V.expiresAt>Date.now()?V.session:null})(),F=nt(V=>a?V.worktreeMetadata.get(a)?.path??"":""),ee=nt(V=>a?V.worktreeMetadata.get(a)?.branch?.trim()??null:null),ne=vu(V=>a?V.getAttachment(a):void 0),re=c.useMemo(()=>ne?xb(ne,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,ne]),te=c.useMemo(()=>ne?ne.legacy?"legacy":ne.degraded?"degraded":ne.worktreeStatus==="pending"?"pending":ne.worktreeStatus==="missing"?"missing":ne.worktreeStatus==="invalid"?"invalid":ne.attentionReason?"attention":null:null,[ne]),K=c.useMemo(()=>jn(F||""),[F]),q=c.useMemo(()=>{const V=typeof _?.directory=="string"?_.directory:"";return jn(V||"")},[_?.directory]),oe=va(a??"",q),fe=nt(V=>V.newSessionDraft?.open?jn(V.newSessionDraft.bootstrapPendingDirectory??V.newSessionDraft.directoryOverride??""):""),ce=nt(V=>V.newSessionDraft.target),ke=nt(V=>V.newSessionDraft.selectedProjectId),De=nt(V=>V.currentSessionDirectory),Ce=gs(V=>V.homeDirectory),Y=c.useMemo(()=>K||q||fe,[fe,q,K]),je=nt(V=>{const Ie=jn(K||q||"");if(!Ie)return null;for(const Le of V.availableWorktreesByProject.values()){const yt=Le.find(Rt=>jn(Rt.path)===Ie)?.branch?.trim();if(yt)return yt}return null}),Pe=Sb(Y||null)||ee||je,L=i?ce==="chat":Hd(q||De,Ce),ie=!L&&!R&&!!(h||Pe||!i&&te),G=c.useMemo(()=>{if(!a)return h??"OpenChamber";const V=_?.title?.trim();return V&&V.length>0?V:"Untitled Session"},[h,_?.title,a]),ae=wu(),ge=nt(V=>V.updateSessionTitle),me=nt(V=>V.archiveSessions),be=nt(V=>V.deleteSessions),[ye,Te]=c.useState(!1),[$,he]=c.useState(!1),se=c.useRef(null),[Ne,Ue]=c.useState(""),[We,Ke]=c.useState(!1),Be=Zt(V=>V.projects.length>0),[U,Me]=c.useState(null),Ge=c.useRef(null),Ve=c.useCallback(()=>{a&&(Ue(_?.title?.trim()||G),Te(!0))},[_?.title,a,G]),dt=c.useRef(Ve);dt.current=Ve;const et=c.useCallback(V=>{V&&(V.focus(),V.select())},[]);c.useEffect(()=>{if(he(!1),Me(null),a&&se.current===a){se.current=null,dt.current();return}Te(!1),Ue("")},[a]);const ct=c.useCallback(async()=>{if(!a)return;const V=Ne.trim();V&&V!==_?.title?.trim()&&await ge(a,V),Te(!1)},[_?.title,a,Ne,ge]);c.useEffect(()=>{if(!ye)return;const V=Ie=>{const Le=Ie.target;(!Le||!Ge.current?.contains(Le))&&ct()};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[ye,ct]);const pe=c.useCallback(V=>{V&&Oo(V).then(Ie=>{_e[Ie.ok?"success":"error"](t(Ie.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(t("sessions.sidebar.session.copyId.error")))},[t]),Ee=c.useCallback(async()=>{if(!a||!Y){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const V=await ae({sessionID:a,directory:Y}).catch(()=>null);if(!V){_e.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(V.length===0){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Ie=ku(V,_?.title??null),Le=ju(_?.title??null);await Cu(Ie,Le)||Pu(Ie,Le),_e.success(t("sessions.sidebar.session.export.success"))},[_?.title,a,ae,Y,t]),qe=Eu(),Ye=c.useMemo(()=>Nu(qe),[qe]),$e=c.useCallback(V=>{a&&Rf({entry:V,t,session:{id:a,title:_?.title,directory:q??Y},loadRecords:async()=>{if(!Y)return null;try{return await ae({sessionID:a,directory:Y})}catch{return null}},onLoadFailed:()=>_e.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[_?.title,a,ae,Y,q,t]),tt=c.useCallback(V=>Ye.map(Ie=>n.jsxs(V,{onClick:()=>$e(Ie),children:[n.jsx(sr,{icon:Ie.icon,iconSrc:Ie.iconSrc,className:"me-1 size-4"}),Ie.action.label]},`${Ie.guest.id}:${Ie.action.id}`)),[Ye,$e]),ht=l?.type==="busy"||l?.type==="retry",vt=c.useCallback(()=>{if(!a||!q||ht||d)return;const V=ws.getState().activeSessions,Ie=V.find(yt=>yt.id===a);if(!Ie)return;const Le=[],Qe=[a];for(let yt=0;yt<Qe.length;yt+=1){const Rt=Qe[yt];for(const zt of V)zt.parentID===Rt&&(Le.push(zt),Qe.push(zt.id))}bo({kind:"quick",root:Ie,descendants:Le,sourceDirectory:q,messages:go(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[a,ht,d,q,t]),Bt=c.useCallback(V=>{if(!a||!q||ht||d)return;const Ie=ws.getState().activeSessions,Le=Ie.find(Rt=>Rt.id===a);if(!Le)return;const Qe=[],yt=[a];for(let Rt=0;Rt<yt.length;Rt+=1)for(const zt of Ie)zt.parentID===yt[Rt]&&(Qe.push(zt),yt.push(zt.id));bo({kind:"project",root:Le,descendants:Qe,sourceDirectory:q,projectDirectory:V,messages:go(t,{success:"sessions.moveChatToProject.success",failure:"sessions.moveChatToProject.failed"})})},[a,ht,d,q,t]),kt=c.useCallback(async(V,Ie)=>{const Le=[Ie,...su(Ie,[],V==="delete")],Qe=nt.getState().currentSessionId===Ie?Ie:null;if(V==="delete"){const{failedIds:zt}=await be(Le);zt.length>0?_e.error(t("sessions.sidebar.session.delete.error")):_e.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:yt,failedIds:Rt}=await me(Le);if(Rt.length>0){_e.error(t("sessions.sidebar.session.archive.error"));return}_e.success(t("sessions.sidebar.session.archive.success"),Gm(yt,Qe,t))},[me,be,t]),St=c.useCallback(async()=>{if(!U)return;const{action:V,sessionId:Ie}=U;Me(null),await kt(V,Ie)},[U,kt]),xt=de(V=>V.openGuestPageId),Mt=Ia(V=>V.guests.find(Ie=>Ie.id===xt)),jt=de(V=>V.isScheduledTasksDialogOpen),$t=de(V=>V.isArchivePageOpen),Wt=de(V=>V.isUsageStatsPageOpen),Kt=de(V=>V.isSourceBoardOpen),rt=de(V=>V.worktreesPageProjectId),ut=de(V=>V.isolatedSpacesEnabled?V.spacesPageProjectId:null),pt=de(V=>V.runOverviewKey),ue=Um(pt),lt=rt??ut,ft=Zt(V=>{if(!lt)return null;const Ie=V.projects.find(Le=>Le.id===lt);return Ie?.label?.trim()||Ie?.path?.split("/").pop()||null}),mt=c.useMemo(()=>Mt?{title:Mt.pageTitle??Mt.name,subtitle:null}:jt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:$t?{title:t("sessions.archivePage.title"),subtitle:null}:Wt?{title:t("usageStats.title"),subtitle:null}:Kt?{title:t("sourceBoard.title"),subtitle:null}:rt?{title:t("sessions.worktreesPage.title",{project:ft??""}),subtitle:null}:ut?{title:t("spaces.page.title",{project:ft??""}),subtitle:null}:pt?{title:ue??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[Mt,$t,ue,pt,jt,Kt,Wt,ut,ft,t,rt]),It=Ra(V=>V.planModeEnabled),xe=nt(V=>V.isSessionPlanAvailable),it=It&&a?xe(a):!1,X=c.useRef("");c.useEffect(()=>{if(!It||!a)return;const V=`${a||"none"}:${q||"none"}:${_?.created||0}:${_?.slug||"none"}`;X.current!==V&&(X.current=V)},[It,it,_?.slug,_?.created,a,q]);const le=q||jn(De||"")||K,Xe=c.useCallback(()=>{hn("desktop_open_draft_mini_chat_window",{directory:L?"":fe,projectId:L?null:ke,apiBaseUrl:fr(),clientToken:Ur()}).catch(V=>{console.warn("[header] failed to open draft mini chat window",V)})},[fe,ke,L]),Ae=c.useCallback(()=>{if(i){Xe();return}a&&hn("desktop_open_session_mini_chat_window",{sessionId:a,directory:q||jn(De||"")||K,apiBaseUrl:fr(),clientToken:Ur()}).catch(V=>{console.warn("[header] failed to open session mini chat window",V)})},[a,Xe,i,De,q,K]),Je=x&&(i||!!a),Fe=c.useCallback((V,Ie)=>{hn("desktop_open_session_mini_chat_window",{sessionId:V,directory:Ie,apiBaseUrl:fr(),clientToken:Ur()}).catch(Le=>{console.warn("[header] failed to open session mini chat window",Le)})},[]),gt=ir,bt=c.useMemo(()=>v&&j&&!y?"88px":p?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!v||k)&&!B?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[v,y,j,p,B,k]),Et=(!v||k)&&!B?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",Ft=e==="rtl",es=Ft?Et:bt,Re=Ft?bt:Et,Ze=k&&P!==Vd(e);ds.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",es)},[es]);const at=s?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",_t=s?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ds.useEffect(()=>{if(!v||!j){w(!1);return}let V=!1;const Ie=async()=>{try{const Qe=await hn("desktop_is_window_fullscreen");V||w(Qe===!0)}catch{V||w(!1)}},Le=()=>{Ie()};return Ie(),window.addEventListener("openchamber:window-resized",Le),()=>{V=!0,window.removeEventListener("openchamber:window-resized",Le)}},[v,j]);const Vt=c.useMemo(()=>!v||!j||A===null?"":A>=26?"h-11":A<=15?"h-14":"",[v,j,A]),Ht=c.useMemo(()=>v&&j&&!y?A!==null&&A<=15?"56px":"44px":"0px",[v,y,j,A]),Oe=c.useMemo(()=>{const Ie=`max(${v&&j?"2.75rem":"3rem"}, ${Ht}, var(--oc-wco-titlebar-height, 0px))`,Le=v&&!k||B;if(Le&&Ht==="0px")return{};const Qe={minHeight:Ie,height:Ie};return!Ze&&(!Le||Ft)&&(Qe.paddingInlineEnd=Re),Qe},[Ze,v,j,Ft,B,Re,Ht,k]),ze=c.useRef(null),st=c.useCallback(V=>{!V||V===ze.current||(ze.current=V,document.documentElement.style.setProperty("--oc-header-height",`${V}px`))},[]),Nt=c.useCallback(()=>{typeof document>"u"||st(b.current?.getBoundingClientRect().height)},[st]);ds.useEffect(()=>{if(typeof window>"u")return;Nt();const V=b.current;if(!V||typeof ResizeObserver>"u")return()=>{};let Ie=0;const Le=()=>{Ie||(Ie=requestAnimationFrame(()=>{Ie=0,Nt()}))},Qe=new ResizeObserver(yt=>{const Rt=yt[yt.length-1];st(Rt?.borderBoxSize?.[0]?.blockSize??Rt?.target.getBoundingClientRect().height)});return Qe.observe(V),window.addEventListener("resize",Le),window.addEventListener("orientationchange",Le),()=>{Ie&&cancelAnimationFrame(Ie),Qe.disconnect(),window.removeEventListener("resize",Le),window.removeEventListener("orientationchange",Le)}},[st,Nt]),ds.useEffect(()=>{Nt()},[Nt,g,Vt]);const Dt=c.useCallback(async V=>{const Ie=V.target;Ie.closest(".app-region-no-drag")||Ie.closest("button, a, input, select, textarea")||V.button===0&&v&&await Xp()},[v]);Iu({rename_current_session:()=>{if(!a||g)return!1;Ve()},archive_current_session:()=>{if(!a||g||ws.getState().entityById.get(a)?.time.archived)return!1;if(de.getState().showDeletionDialog){Me({action:"archive",sessionId:a});return}kt("archive",a)}});const ts=n.jsxs(n.Fragment,{children:[n.jsx(M1,{directory:Y,className:ve(ir,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"}),n.jsx(qm,{directory:Y,className:ve(ir,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"})]}),fs=c.useCallback(({session:V,open:Ie,isActive:Le,select:Qe,closeOtherTabs:yt,components:Rt})=>{const{Item:zt,Separator:Jt}=Rt,Rs=Le&&!B&&!L&&_&&!_.parentId,ys=Le&&!B&&L&&_&&!_.parentId&&Be;return n.jsxs(n.Fragment,{children:[n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(zt,{onClick:()=>{Le||Qe(),se.current=V.id},children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(Ui,{sessionID:V.id,directory:V.directory,open:Ie,Item:zt}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(zt,{onClick:()=>pe(V.id),children:[n.jsx(Z,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(Jt,{}),Le?n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(zt,{onClick:()=>{Ee()},children:[n.jsx(Z,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,x?n.jsxs(zt,{onClick:()=>Fe(V.id,Le?le:V.directory??""),children:[n.jsx(Z,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,Le?tt(zt):null,Rs?n.jsx(Qt,{hint:t(d?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ht?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(zt,{disabled:!q||ht||d,onClick:vt,className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,ys?n.jsx(Qt,{hint:t(ht?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:n.jsx("span",{className:"block",children:n.jsxs(zt,{disabled:!q||ht||d,onClick:()=>Ke(!0),className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,n.jsx(Jt,{}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(zt,{onClick:yt,children:[n.jsx(Z,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(Jt,{}),n.jsx(uc,{sessionId:V.id,Item:zt,onArchive:()=>Me({action:"archive",sessionId:V.id})}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(zt,{className:"text-destructive focus:text-destructive",onClick:()=>Me({action:"delete",sessionId:V.id}),children:[n.jsx(Z,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[pe,_,le,Ee,x,Be,L,ht,d,B,vt,Fe,tt,q,t]),us=()=>n.jsxs("div",{onMouseDown:Dt,className:ve("app-region-drag relative flex h-12 select-none items-center",Ze?"pe-0":"pe-2.5",Vt),style:Oe,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] ease-out motion-reduce:transition-none",style:{width:at,transitionDuration:`${r}ms`}}),n.jsx("div",{ref:Af,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] ease-out motion-reduce:transition-none",style:{width:_t,transitionDuration:`${r}ms`}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[mt?n.jsxs(n.Fragment,{children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"icon",className:"app-region-no-drag me-1 size-6 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>de.getState().closeMainSurfaces(),children:n.jsx(Z,{name:"arrow-left",className:"size-4"})})}),n.jsx(Tt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),n.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[n.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:mt.title}),mt.subtitle?n.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:mt.subtitle}):null]})]}):B||!o?n.jsxs("div",{className:"app-region-no-drag me-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-start",children:[oe?n.jsx(Z,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,s?null:n.jsx(d1,{align:"start",children:n.jsx("button",{type:"button",className:gt,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(Z,{name:"history",className:"h-4 w-4"})})}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[ye?n.jsxs("form",{ref:Ge,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:V=>V.stopPropagation(),onSubmit:V=>{V.preventDefault(),ct()},children:[n.jsx("input",{ref:et,value:Ne,onChange:V=>Ue(V.target.value),onKeyDown:V=>Di(V,()=>Te(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),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(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Te(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"close",className:"size-4"})})]}):i?null:n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:G}),ie?n.jsxs("span",{className:ve("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",i?"typography-ui-label text-[14px] text-foreground":"typography-micro text-[10.5px] text-muted-foreground/75"),children:[h?n.jsx("span",{className:"truncate",children:h}):null,Pe?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(Z,{name:"git-branch",className:ve("flex-shrink-0 text-muted-foreground/70",i?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{className:ve("truncate",i&&"text-muted-foreground"),children:Pe})]}):null,!i&&te?n.jsxs("span",{className:ve("inline-flex min-w-0 items-center gap-0.5",te==="attention"||te==="invalid"||te==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[n.jsx(Z,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:re})]}):null]}):null]}),n.jsx("div",{className:ve("flex h-[18px] shrink-0 items-center justify-center",ie?"self-start":"self-center"),children:a&&!i&&!ye?n.jsxs(js,{open:$,onOpenChange:he,onOpenChangeComplete:V=>{!V&&se.current&&se.current===a&&(se.current=null,Ve())},children:[n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{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(Z,{name:"more",className:"size-4"})})}),n.jsxs(Ps,{align:"end",className:"min-w-[190px]",children:[n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(qt,{onClick:()=>{se.current=a},children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(Ui,{sessionID:a,directory:q,open:$,Item:qt}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(qt,{onClick:()=>a&&pe(a),children:[n.jsx(Z,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(bn,{}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(qt,{onClick:()=>{Ee()},children:[n.jsx(Z,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),x?n.jsxs(qt,{onClick:()=>Fe(a,le),children:[n.jsx(Z,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,tt(qt),!B&&!L&&_&&!_.parentId?n.jsx(Qt,{hint:t(d?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ht?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(qt,{disabled:!q||ht||d,onClick:vt,className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,n.jsx(bn,{}),n.jsx(uc,{sessionId:a,Item:qt,onArchive:()=>Me({action:"archive",sessionId:a})}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(qt,{className:"text-destructive focus:text-destructive",onClick:()=>{a&&Me({action:"delete",sessionId:a})},children:[n.jsx(Z,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:n.jsx(V1,{renderMenu:fs,suppressActiveTabControls:ye,onMenuOpenChangeComplete:V=>{!V&&se.current&&se.current===a&&(se.current=null,Ve())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:ye?n.jsxs("form",{ref:Ge,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:V=>V.stopPropagation(),onSubmit:V=>{V.preventDefault(),ct()},children:[n.jsx("input",{ref:et,value:Ne,onChange:V=>Ue(V.target.value),onKeyDown:V=>Di(V,()=>Te(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),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(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Te(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"close",className:"size-4"})})]}):n.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap oc-ui-start-align text-[13px] font-medium leading-4 text-foreground max-w-full",children:i?t("sessions.switcher.draftTitle"):G})})})}),mt||B||!o?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[Je?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Ae,className:ir,children:n.jsx(Z,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"bottom",children:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat")})]}):null,B?null:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":Q,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:N,className:ve(ir,Q&&"text-foreground"),children:n.jsx(Z,{name:"list-indefinite",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"bottom",children:t(E&&!z?O?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":E?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ts,n.jsx(wf,{visible:Ze,position:P})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:b,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:us()}),n.jsx(rS,{open:We,onOpenChange:Ke,onPick:Bt}),n.jsx(zs,{open:U!==null,onOpenChange:V=>{V||Me(null)},children:n.jsxs($s,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(qs,{children:[n.jsx(Gs,{children:U?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),n.jsx(Us,{children:U?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:G}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:G})})]}),n.jsxs(yn,{children:[n.jsx(Ct,{variant:"outline",size:"sm",onClick:()=>Me(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Ct,{variant:"destructive",size:"sm",onClick:()=>{St()},children:U?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})})]})},gc=280,bc=264,yc=500,yS=({isOpen:t,isMobile:e,children:s,className:r,topBar:o})=>{const{t:i,direction:a}=wt(),l=de(O=>O.sidebarWidth),d=de(O=>O.setSidebarWidth),[u,f]=c.useState(!1),h=c.useRef(0),m=c.useRef(l||gc),g=c.useRef(null),b=c.useRef(null),v=c.useRef(null),S=c.useCallback(O=>Math.min(yc,Math.max(bc,O)),[]),x=c.useCallback(O=>{const W=v.current;W&&(W.style.width=`${O}px`,W.style.minWidth=`${O}px`,W.style.maxWidth=`${O}px`,W.style.setProperty("--oc-left-sidebar-width",`${O}px`),document.documentElement.style.setProperty("--oc-left-sidebar-width",`${O}px`))},[]);c.useEffect(()=>{e&&u&&f(!1)},[e,u]),c.useEffect(()=>{u||(g.current=null,b.current=null)},[u]);const p=Math.min(yc,Math.max(bc,l||gc)),y=t?p:0,w=u?g.current??y:y,j=u?w:p;c.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${j}px`)},[j]);const[k,P]=c.useState(!t);t&&k&&P(!1);const A=Na(),B=c.useRef(t),R=c.useRef(t);if(c.useLayoutEffect(()=>{B.current=t,R.current!==t&&(R.current=t,Ru(A),t||Da(()=>{B.current||P(!0)}))},[t,A]),e)return null;const E=O=>{if(t){try{O.currentTarget.setPointerCapture(O.pointerId)}catch{}b.current=O.pointerId,f(!0),h.current=O.clientX,m.current=y,g.current=y,x(y),O.preventDefault()}},T=O=>{if(e||!u||b.current!==O.pointerId)return;const W=(O.clientX-h.current)*(a==="rtl"?-1:1),D=S(m.current+W);g.current!==D&&(g.current=D,x(D))},z=O=>{if(b.current!==O.pointerId||e)return;try{O.currentTarget.releasePointerCapture(O.pointerId)}catch{}const W=S(g.current??y);b.current=null,g.current=null,f(!1),d(W)};return n.jsxs("div",{ref:v,"data-left-sidebar":"",className:ve("relative flex h-full overflow-hidden border-e border-border",u?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",!t&&"border-e-0",r),style:{width:`${w}px`,minWidth:`${w}px`,maxWidth:`${w}px`,"--oc-left-sidebar-width":`${j}px`,overflowX:"clip",transitionDuration:`${A}ms`,transitionTimingFunction:Ai},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)] rtl:shadow-[inset_2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&n.jsx("div",{className:ve("absolute inset-e-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",u&&"bg-[var(--interactive-border)]"),onPointerDown:E,onPointerMove:T,onPointerUp:z,onPointerCancel:z,role:"separator","aria-orientation":"vertical","aria-label":i("sidebar.resize.leftPanelAria")}),n.jsxs("aside",{className:ve("relative z-10 flex h-full shrink-0 flex-col transition-opacity ease-out motion-reduce:transition-none",u&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${A}ms`,overflowX:"hidden",contentVisibility:k?"hidden":void 0},inert:!t||void 0,children:[o,n.jsx(Pr,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:n.jsx(bs,{children:s})})]})]})},xS=()=>{const t=He.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-start-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",{ref:Af,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},Ar="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",SS=()=>{const t=He.c(45),{t:e,locale:s,direction:r}=wt(),o=de(vS),i=de(wS),a=de(kS),l=c.useRef(null),d=Du(Tu("toggle_sidebar",a)),u=jS,{usesFramelessChrome:f,side:h}=vf();let m;t[0]!==s?(m=I=>{const H=I.currentTarget.getBoundingClientRect();hn("desktop_show_app_menu",{x:H.left,y:H.bottom,locale:s}).catch(CS)},t[0]=s,t[1]=m):m=t[1];const g=m;let b,v;t[2]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{if(typeof document>"u")return;const I=l.current;if(!I)return;const H=()=>{const _=Math.max(I.getBoundingClientRect().width,I.scrollWidth);gS(_)};if(H(),typeof ResizeObserver>"u")return;const M=new ResizeObserver(H);return M.observe(I),()=>{M.disconnect()}},v=[],t[2]=b,t[3]=v):(b=t[2],v=t[3]),c.useEffect(b,v);const S="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",x=i?"var(--oc-left-sidebar-width, 100%)":void 0;let p;t[4]!==x?(p={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:x},t[4]=x,t[5]=p):p=t[5];const y="flex min-w-0 items-center gap-2";let w;t[6]!==r||t[7]!==f||t[8]!==h?(w=f&&h===Vd(r)?n.jsx(wf,{visible:!0,position:h}):null,t[6]=r,t[7]=f,t[8]=h,t[9]=w):w=t[9];let j;t[10]!==g||t[11]!==e||t[12]!==f?(j=f?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:g,"aria-label":e("header.actions.openAppMenuAria"),className:ve(Ar,"shrink-0"),children:n.jsx(Z,{name:"menu-2",className:"h-4 w-4"})})}),n.jsx(Tt,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=g,t[11]=e,t[12]=f,t[13]=j):j=t[13];const k=Ot;let P;t[14]!==e?(P=e("header.actions.openSessionsAria"),t[14]=e,t[15]=P):P=t[15];const A=i&&"text-foreground";let B;t[16]!==A?(B=ve(Ar,"shrink-0",A),t[16]=A,t[17]=B):B=t[17];let R;t[18]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Z,{name:"layout-left",className:"h-4 w-4"}),t[18]=R):R=t[18];let E;t[19]!==i||t[20]!==B||t[21]!==P||t[22]!==o?(E=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":P,"aria-pressed":i,className:B,children:R})}),t[19]=i,t[20]=B,t[21]=P,t[22]=o,t[23]=E):E=t[23];const T=Tt,z=e("header.actions.openSessionsWithShortcut",{shortcut:d});let O;t[24]!==z?(O=n.jsx("p",{children:z}),t[24]=z,t[25]=O):O=t[25];let W;t[26]!==T||t[27]!==O?(W=n.jsx(T,{children:O}),t[26]=T,t[27]=O,t[28]=W):W=t[28];let D;t[29]!==k||t[30]!==E||t[31]!==W?(D=n.jsxs(k,{children:[E,W]}),t[29]=k,t[30]=E,t[31]=W,t[32]=D):D=t[32];let Q;t[33]!==u||t[34]!==i||t[35]!==e?(Q=i?n.jsxs("button",{type:"button",onClick:u,className:ve(Ar,"-ms-1 w-auto min-w-0 px-1.5 font-normal"),children:[n.jsx(Z,{name:"chat-new",className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:u,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:ve(Ar,"-ms-1 shrink-0"),children:n.jsx(Z,{name:"chat-new",className:"h-4 w-4"})})}),n.jsx(Tt,{children:n.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[33]=u,t[34]=i,t[35]=e,t[36]=Q):Q=t[36];let N;t[37]!==D||t[38]!==Q||t[39]!==w||t[40]!==j?(N=n.jsxs("div",{ref:l,className:y,children:[w,j,D,Q]}),t[37]=D,t[38]=Q,t[39]=w,t[40]=j,t[41]=N):N=t[41];let C;return t[42]!==N||t[43]!==p?(C=n.jsx("div",{className:S,style:p,children:N}),t[42]=N,t[43]=p,t[44]=C):C=t[44],C};function vS(t){return t.toggleSidebar}function wS(t){return t.isSidebarOpen}function kS(t){return t.shortcutOverrides}function jS(){de.getState().closeMainSurfaces(),nt.getState().openNewSessionDraft()}function CS(t){console.warn("[titlebar] failed to open app menu",t)}function PS(t,e,s){const r=He.c(5),[o,i]=c.useState();let a,l;return r[0]!==s||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let d=!1;return(async()=>{const[u,f]=await Promise.all([vb(t),wb(t)]).catch(ES);if(d)return;const h=ot(u),m=ot(f);if(!h||!m||m===h)return;const g=s||"",b=m.split("/").filter(Boolean).pop()||m;i({source:"sdk",path:m,projectDirectory:h,branch:g,label:g||b,name:b,worktreeRoot:m,worktreeStatus:"ready",headState:g?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},l=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=a,r[4]=l):(a=r[3],l=r[4]),c.useEffect(a,l),e??o}function ES(){return["",""]}const NS=()=>{const t=He.c(3),e=de(IS),s=de(RS);let r;return t[0]!==e||t[1]!==s?(r=()=>{s("integrations"),e(!0)},t[0]=e,t[1]=s,t[2]=r):r=t[2],r};function IS(t){return t.setSettingsDialogOpen}function RS(t){return t.setSettingsPage}const DS="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)]",xc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",TS=({className:t,identity:e=Au})=>{const{t:s}=wt(),{sourceControl:r}=Ws(),o=Mu(e),i=e.provider==="gitlab",a=i?"gitlab":"github-fill",l=o?.status??null,d=mn(x=>x.setStatus),[u,f]=c.useState(!1),h=c.useCallback(async x=>{if(!(!x||u)){f(!0);try{d(e,await r.authActivate(e,x))}catch(p){console.error("Failed to switch source control account:",p)}finally{f(!1)}}},[e,u,d,r]);if(l?.status!=="connected")return null;const m=l.user.username||null,g=l.user.avatarUrl??null,b=l.accounts,v=i?m?s("header.gitlab.connectedWithLogin",{login:m}):s("header.gitlab.connected"):m?s("header.github.connectedWithLogin",{login:m}):s("header.github.connected"),S=g?n.jsx("img",{src:g,alt:m?s("header.github.avatarWithLogin",{login:m}):s(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(Z,{name:a,className:"h-3.5 w-3.5 text-foreground"});return b.length<=1?n.jsx("div",{className:ve(xc,t),title:v,children:S}):n.jsxs(js,{children:[n.jsx(Cs,{asChild:!0,children:n.jsx("button",{type:"button",className:ve(xc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:v,disabled:u,children:S})}),n.jsxs(Ps,{align:"end",className:"w-64",children:[n.jsx(Oi,{className:"typography-ui-header font-semibold text-foreground",children:s(i?"header.gitlab.accountsTitle":"header.github.accountsTitle")}),n.jsx(bn,{}),b.map(x=>{const p=x.user,y=!!x.current,w=s(kb(x.source??"oauth"));return n.jsxs(qt,{className:"gap-2",disabled:u,onSelect:()=>{y||h(x.id)},children:[p?.avatarUrl?n.jsx("img",{src:p.avatarUrl,alt:p.username?s("header.github.avatarWithLogin",{login:p.username}):s(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:n.jsx(Z,{name:a,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:p?.name?.trim()||p.username||(i?"GitLab":"GitHub")}),p.username?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:p.username}),n.jsx("span",{className:"mx-1 opacity-50",children:"·"}),n.jsx("span",{children:w})]}):null]}),y?n.jsx(Z,{name:"check",className:"h-4 w-4 text-primary"}):null]},x.id)})]})]})},MS=t=>JSON.stringify(jb(t)),AS=async(t,e)=>{const s=await t.projectUpstream(e);if(!s?.isFork||!s.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,s.upstream.owner,s.upstream.name);return{upstream:s.upstream,branches:r}},Of=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function OS(t){if(!Of(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function BS(t,e,s){const r=He.c(16),{sourceControl:o}=Ws(),[i,a]=ds.useState(null);let l;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(l=JSON.stringify([t.provider,t.repositoryId,t.bindingRevision,e]),r[0]=t.bindingRevision,r[1]=t.provider,r[2]=t.repositoryId,r[3]=e,r[4]=l):l=r[4];const d=l;let u;r[5]!==t||r[6]!==d||r[7]!==e||r[8]!==o?(u=()=>{if(t.provider!=="github")return;let h=!1;return o.githubReferences(t,{kind:"pull",query:`#${e}`}).then(m=>{if(h||!m.connected)return;const g=m.items.find(b=>b.kind==="pull"&&b.number===e);g&&a({key:d,pull:g})}).catch(FS),()=>{h=!0}},r[5]=t,r[6]=d,r[7]=e,r[8]=o,r[9]=u):u=r[9];let f;return r[10]!==t||r[11]!==d||r[12]!==e||r[13]!==s||r[14]!==o?(f=[t,d,e,s,o],r[10]=t,r[11]=d,r[12]=e,r[13]=s,r[14]=o,r[15]=f):f=r[15],ds.useEffect(u,f),i?.key===d?i.pull:null}function FS(){}const LS=t=>{const e=He.c(58),{directory:s,context:r,changeRequest:o,onChanged:i}=t,a=vn(),l=Zt(_S),[d,u]=ds.useState(0),[f,h]=ds.useState(!1),[m]=ds.useState($S),g=BS(r,o.number,d);let b;e[0]!==o?(b=Cb(o),e[0]=o,e[1]=b):b=e[1];const v=b;let S;e[2]!==g||e[3]!==v?(S=g?{...v,labels:g.labels,commentCount:g.commentCount}:v,e[2]=g,e[3]=v,e[4]=S):S=e[4];const x=S,{detail:p,refresh:y}=Pb(s,x,!0),w=Ym(x);let j;e[5]!==i||e[6]!==y?(j=()=>{y(),u(zS),i()},e[5]=i,e[6]=y,e[7]=j):j=e[7];const k=j;let P;e[8]!==x?(P={source:"github",reference:x},e[8]=x,e[9]=P):P=e[9];const A=P,B=a??s;let R;e[10]===Symbol.for("react.memo_cache_sentinel")?(R={status:"idle"},e[10]=R):R=e[10];let E;e[11]!==r||e[12]!==A||e[13]!==k?(E=n.jsx(Zm,{item:A,project:null,context:r,onStartWorktree:KS,onChanged:k}),e[11]=r,e[12]=A,e[13]=k,e[14]=E):E=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=()=>h(!0),e[15]=T):T=e[15];let z;e[16]!==w.attachComment||e[17]!==w.attachComments?(z={onAttach:w.attachComment,onAttachAll:w.attachComments},e[16]=w.attachComment,e[17]=w.attachComments,e[18]=z):z=e[18];let O;e[19]!==r||e[20]!==x||e[21]!==k?(O=n.jsx(Jm,{reference:x,context:r,onChanged:k}),e[19]=r,e[20]=x,e[21]=k,e[22]=O):O=e[22];let W;e[23]!==r||e[24]!==p||e[25]!==x||e[26]!==k?(W=n.jsx(eg,{pull:x,detail:p,context:r,onChanged:k}),e[23]=r,e[24]=p,e[25]=x,e[26]=k,e[27]=W):W=e[27];let D;e[28]!==r||e[29]!==x||e[30]!==k?(D=n.jsx(Xm,{reference:x,context:r,onRefresh:k},x.number),e[28]=r,e[29]=x,e[30]=k,e[31]=D):D=e[31];const Q=l??"";let N;e[32]!==B||e[33]!==Q?(N={id:Q,path:B},e[32]=B,e[33]=Q,e[34]=N):N=e[34];let C;e[35]!==r||e[36]!==B||e[37]!==x||e[38]!==N?(C=n.jsx(tg,{pull:x,project:N,context:r,projectOwnsDirectory:HS,currentDirectory:B}),e[35]=r,e[36]=B,e[37]=x,e[38]=N,e[39]=C):C=e[39];let I;e[40]!==p||e[41]!==A||e[42]!==m||e[43]!==W||e[44]!==D||e[45]!==C||e[46]!==E||e[47]!==z||e[48]!==O?(I=n.jsx(Eb,{item:A,pullStatus:Nb,linearDetail:R,githubDetail:p,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:WS,now:m,footer:E,onOpenChecks:T,commentAttachments:z,labelsControl:O,reviewersControl:W,reply:D,pullLinks:C}),e[40]=p,e[41]=A,e[42]=m,e[43]=W,e[44]=D,e[45]=C,e[46]=E,e[47]=z,e[48]=O,e[49]=I):I=e[49];let H;e[50]!==w.attachFailedChecks||e[51]!==f||e[52]!==r||e[53]!==x?(H=n.jsx(Qm,{pull:x,context:r,open:f,onOpenChange:h,onAttachFailed:w.attachFailedChecks}),e[50]=w.attachFailedChecks,e[51]=f,e[52]=r,e[53]=x,e[54]=H):H=e[54];let M;return e[55]!==I||e[56]!==H?(M=n.jsxs(n.Fragment,{children:[I,H]}),e[55]=I,e[56]=H,e[57]=M):M=e[57],M};function _S(t){return t.activeProjectId}function $S(){return Date.now()}function zS(t){return t+1}function WS(){}function KS(){}function HS(){return!0}function VS(t,e){const{git:s,sourceControl:r}=Ws(),{t:o}=wt(),i=sg(),a=ng({directory:t,branch:e,chooseContributor:i.choose}),l=rg(t,s,r),d=async()=>{const f=l.start();if(!f)return _e.info(o("gitView.pr.toast.gitBusy")),!1;const h=o("gitView.toast.syncActionFailed",{action:o("gitView.publish.title")});try{return await(await a.prepare("push",{onOperation:f.onOperation}))(),f.isCurrent()}catch(m){if(m instanceof Ib){if(m.code==="stale-runtime")return!1;const g=a.errorMessage(m);return g?_e.info(g):_e.error(h),!1}return m instanceof Rb||m instanceof Db?(_e.error(h,{description:m.message||void 0}),!1):(_e.error(h,{description:m instanceof Error?m.message:String(m)}),!1)}finally{f.finish()}},u=n.jsxs(n.Fragment,{children:[a.context?n.jsx(og,{context:a.context,onSelect:a.settle}):null,a.confirmDialog,n.jsx(ig,{candidates:i.candidates,onSelect:i.settle})]});return{push:d,dialogs:u}}const GS=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"}},US=(t,e)=>{const{currentSessionId:s,getDirectoryForSession:r}=nt.getState(),o=s?r(s):null;!s||!o||ot(o)!==ot(t)||Wb(s,o,Kb({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},qS=t=>{const e=t?.changeRequest??t?.pr;return e?Hb({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},YS=[2e3,5e3];let Sc=0;const XS=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(Sc+=1,`source-control-${Date.now().toString(36)}-${Sc.toString(36)}`)},QS=(t,e,s)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...s]),Bf="openchamber:pr-create-as-draft:v1",vc=()=>{try{return localStorage.getItem(Bf)==="true"}catch{return!1}},ZS=t=>{try{localStorage.setItem(Bf,String(t))}catch{}},fi=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),dn=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):""},JS=(t,e)=>{const s=dn(t);if(!s||s.includes("->"))return"";if(e){const o=`${e}/`;return s.startsWith(o)?s.slice(o.length).trim():""}const r=s.indexOf("/");return r>0?s.slice(r+1).trim():s},ev=(t,e)=>`${t}::${e}`,hi=new Map,wc=Ma;function tv(t,e,s){const r=He.c(14);let o;r[0]!==s?(o=s?MS(s):null,r[0]=s,r[1]=o):o=r[1];const i=o;let a;r[2]===Symbol.for("react.memo_cache_sentinel")?(a={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=a):a=r[2];const[l,d]=c.useState(a);let u,f;r[3]!==i||r[4]!==t||r[5]!==s||r[6]!==e?(u=()=>{if(!t||!s||!i)return;let m=!1;return(async()=>{try{const g=await AS(e,s);m||d({contextKey:i,detectedUpstream:g.upstream,upstreamBranches:g.branches})}catch{}})(),()=>{m=!0}},f=[i,t,s,e],r[3]=i,r[4]=t,r[5]=s,r[6]=e,r[7]=u,r[8]=f):(u=r[7],f=r[8]),c.useEffect(u,f);let h;return r[9]!==i||r[10]!==l.contextKey||r[11]!==l.detectedUpstream||r[12]!==l.upstreamBranches?(h=l.contextKey===i?{detectedUpstream:l.detectedUpstream,upstreamBranches:l.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=i,r[10]=l.contextKey,r[11]=l.detectedUpstream,r[12]=l.upstreamBranches,r[13]=h):h=r[13],h}const sv=({directory:t,branch:e,baseBranch:s,trackingBranch:r,ahead:o=0,remoteBranches:i=[],onGeneratedDescription:a})=>{const{t:l}=wt(),d=Ou(t),u=c.useCallback((Oe,ze)=>l(en(Oe,d?.provider),ze),[d?.provider,l]),f=NS(),{sourceControl:h}=Ws(),m=mn(Oe=>Oe.entries),{isMobile:g,hasTouchInput:b,screenWidth:v}=Mn(),S=de(Oe=>Oe.openContextSurface),x=Tb(Oe=>Oe.requestTarget),p=!g&&v>=768&&!Sn(),y=c.useMemo(()=>ev(t,e),[t,e]),w=c.useMemo(()=>hi.get(y)??null,[y]),j=ls(Oe=>Oe.ensureEntry),k=ls(Oe=>Oe.setParams),P=ls(Oe=>Oe.beginActiveContextsLoad),A=ls(Oe=>Oe.commitActiveContexts),B=ls(Oe=>Oe.releaseActiveContexts),R=c.useId(),E=ls(Oe=>Oe.startWatching),T=ls(Oe=>Oe.stopWatching),z=ls(Oe=>Oe.refresh),[O,W]=c.useState(()=>w?.title??fi(e)),[D,Q]=c.useState(()=>w?.body??""),[N,C]=c.useState(()=>w?.draft??vc()),[I,H]=c.useState(()=>w?.additionalContext??""),[M,_]=c.useState(()=>{const Oe=typeof w?.targetBaseBranch=="string"?dn(w.targetBaseBranch):"";return Oe||dn(s)}),[F,ee]=c.useState(!1),[ne,re]=c.useState(!1),[te,K]=c.useState(!1),q=Bu(t,h),oe=q.scope.runtimeKey;c.useEffect(()=>{if(!t)return;const Oe=q.scope.runtimeKey,ze=P(Oe,t,R),st=q.contexts.filter(Nt=>Bi(m[_n(Nt)],Nt).connected);return A(Oe,t,R,ze,st),()=>{B(Oe,t,R)}},[P,q.contexts,q.scope.runtimeKey,A,t,B,m,R]);const ce=q.contexts[0]??null,ke=mn(Oe=>d?Oe.entries[_n(d)]?.hasChecked===!0:!1),De=ce?.primaryRemote??null,Ce=c.useMemo(()=>ce?_n(ce):"",[ce]),Y=mn(Oe=>Oe.entries[Ce]),je=ce?Bi(Y,ce):{authChecked:Y?.hasChecked??!1,connected:!1},we=je.authChecked,[Pe,L]=c.useState(0),[ie,G]=c.useState({key:"",status:"loading",capabilities:null}),[ae,ge]=c.useState(!1),{detectedUpstream:me,upstreamBranches:be}=tv(t,h,ce);c.useEffect(()=>{if(!ce)return;let Oe=!1;const ze=_n(ce);return G({key:ze,status:"loading",capabilities:null}),h.capabilities(ce).then(st=>{Oe||G({key:ze,status:"ready",capabilities:st})}).catch(()=>{Oe||G({key:ze,status:"error",capabilities:null})}),()=>{Oe=!0}},[Pe,ce,h]);const ye=ie.key===Ce?ie:null,Te=ye?.status==="ready"?ye.capabilities:null;c.useEffect(()=>{ge(!1)},[t]);const he=!!(t&&e&&s&&(e!==s||me!==null)),se=c.useMemo(()=>ce?Fu(ce,e):"",[e,ce]),Ne=c.useRef(se);Ne.current=se;const Ue=c.useCallback((Oe,ze)=>Oe===Yt()&&ze===Ne.current,[]),We=ls(Oe=>Oe.entries[se]),Ke=c.useMemo(()=>se?[se]:[],[se]);Lu(_u(Ke));const Be=We?.isLoading??!1,U=je.connected?We?.status??null:null,Me=q.error?u("settings.gitlab.status.operationFailed"):We?.error??null,Ge=We?.isInitialStatusResolved??!1,Ve=c.useMemo(()=>{const Oe=ae?null:De,ze=new Set;for(const Dt of i){const ts=JS(Dt,Oe);!ts||ts==="HEAD"||ze.add(ts)}if(ae)for(const Dt of be)Dt&&Dt!=="HEAD"&&ze.add(Dt);const st=dn(s);st&&st!=="HEAD"&&ze.add(st);const Nt=dn(M);return Nt&&Nt!=="HEAD"&&ze.add(Nt),Array.from(ze).sort((Dt,ts)=>Dt.localeCompare(ts))},[s,i,De,M,be,ae]);c.useEffect(()=>{const Oe=dn(s);if(!M&&Oe){_(Oe);return}if(Ve.length!==0&&!Ve.includes(M)){const ze=Ve.includes(Oe)?Oe:Ve[0];ze&&_(ze)}},[Ve,s,M]);const dt=c.useRef([]),et=c.useRef(new Map),ct=c.useCallback(Oe=>{const ze=et.current.get(Oe);if(ze?.inFlight)return null;if(ze)return ze.inFlight=!0,ze.key;const st=XS();return et.current.set(Oe,{key:st,inFlight:!0}),st},[]),pe=c.useCallback((Oe,ze,st)=>{const Nt=et.current.get(Oe);!Nt||Nt.key!==ze||(st?Nt.inFlight=!1:et.current.delete(Oe))},[]);c.useEffect(()=>{me&&ge(!0)},[me]),c.useEffect(()=>{ae&&me?.defaultBranch&&_(me.defaultBranch)},[ae,me?.defaultBranch]);const Ee=U?.changeRequest??U?.pr??null,qe=U?.identity??ce,Ye=c.useMemo(()=>U?.project??(U?.repo&&qe?{...U.repo,...qe,id:`${U.repo.owner}/${U.repo.repo}`,name:U.repo.repo}:null),[U?.project,U?.repo,qe]),$e=Ee?.state==="merged"||Ee?.state==="closed",tt=$e?null:Ee,ht=U?.ci?.summary??U?.checks??null,[vt,Bt]=c.useState(!1),kt=c.useRef(!0);c.useEffect(()=>(kt.current=!0,()=>{kt.current=!1}),[]);const St=c.useCallback(async Oe=>{await z(se,Oe)},[se,z]),xt=c.useCallback((Oe,ze)=>{dt.current.forEach(st=>{window.clearTimeout(st)}),dt.current=YS.map(st=>window.setTimeout(()=>{Ue(Oe,ze)&&z(ze,{force:!0,silent:!0,markInitialResolved:!0})},st))},[Ue,z]),Mt=c.useCallback(async(Oe,ze,st)=>{await OS({error:Oe,isCurrent:()=>Ue(ze,st),refresh:()=>z(st,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>xt(ze,st)})},[Ue,z,xt]);c.useEffect(()=>{!ce||!se||(j(se),k(se,{directory:t,branch:e,remoteName:ce.primaryRemote,canShow:he,identity:ce,readContext:ce,sourceControl:h,authChecked:je.authChecked,connected:je.connected}))},[e,he,t,j,se,ce,h,je.authChecked,je.connected,k]);const jt=600,$t=c.useCallback(async()=>{if(vt)return;Bt(!0);const Oe=Date.now();try{await St({force:!0})}finally{const ze=jt-(Date.now()-Oe);ze>0&&await new Promise(st=>window.setTimeout(st,ze)),kt.current&&Bt(!1)}},[vt,St]);c.useEffect(()=>{if(!(!ce||!se))return E(se),()=>{T(se)}},[se,ce,E,T]),c.useEffect(()=>{const Oe=hi.get(y)??null;W(Oe?.title??fi(e)),Q(Oe?.body??""),C(Oe?.draft??vc()),_(Oe?.targetBaseBranch?dn(Oe.targetBaseBranch):dn(s))},[s,e,y]),c.useEffect(()=>{!ce||!se||!je.connected||St({markInitialResolved:!0})},[se,ce,St,je.connected]),c.useEffect(()=>{!he||!ce||!je.connected||St({force:!0,silent:!0,markInitialResolved:!0})},[he,ce,St,je.connected]),c.useEffect(()=>{const Oe=()=>{const st=ls.getState().entries[se]?.lastRefreshAt??0;Date.now()-st>6e4&&St({force:!0,silent:!0})},ze=()=>{document.visibilityState==="visible"&&Oe()};return window.addEventListener("focus",Oe),document.addEventListener("visibilitychange",ze),()=>{window.removeEventListener("focus",Oe),document.removeEventListener("visibilitychange",ze)}},[se,St]),c.useEffect(()=>{we&&!je.connected&&St({force:!0,silent:!0,markInitialResolved:!0})},[St,je.connected,we]),c.useEffect(()=>{!t||!e||hi.set(y,{title:O,body:D,draft:N,additionalContext:I,targetBaseBranch:M})},[y,O,D,N,I,M,t,e]),c.useEffect(()=>()=>{dt.current.forEach(Oe=>{window.clearTimeout(Oe)}),dt.current=[]},[se,oe]),c.useEffect(()=>()=>{et.current.clear()},[]);const Wt=ae&&me?.defaultBranchSha?me.defaultBranchSha:ce?`${ce.primaryRemote}/${M}`:M;c.useEffect(()=>{if(!t||!e||!Wt)return;let Oe=!1;return Mb(t,{from:Wt,to:e,maxCount:2}).then(ze=>{const st=ze.all.length===1?ze.all[0]?.message.trim():"";Oe||!st||W(Nt=>Nt===fi(e)?st:Nt)}).catch(()=>{}),()=>{Oe=!0}},[e,Wt,t]);const Kt=!r||o>0,rt=VS(t,e),ut=c.useId(),pt=Oe=>{C(Oe),ZS(Oe)},ue=c.useCallback(async()=>{if(!F&&t){ee(!0);try{const ze={base:Wt,head:e,...ce?.provider?{changeRequestProvider:ce.provider}:{}};I&&(ze.context=I);const st=await Ab(t,ze);st.title?.trim()&&W(st.title.trim()),st.body?.trim()&&Q(st.body.trim()),a?.()}catch(Oe){const ze=Oe instanceof Error?Oe.message:String(Oe);_e.error(u("gitView.pr.toast.generateDescriptionFailed"),{description:ze})}finally{ee(!1)}}},[I,e,Wt,t,F,a,ce,u]),lt=c.useCallback(async()=>{if(Te?.changeRequests!==!0){_e.error(u("gitView.pr.toast.createPrFailed"),{description:u("gitView.pr.capabilitiesUnavailable")});return}const Oe=O.trim();if(!Oe){_e.error(u("gitView.pr.toast.titleRequired"));return}const ze=M.trim();if(!ze){_e.error(u("gitView.pr.toast.baseBranchRequired"));return}if(!ae&&ze===e){_e.error(u("gitView.pr.toast.baseMustDifferFromHead"));return}const st=ae?me:Ye;if(!ce||!st){_e.error(u("gitView.pr.toast.createPrFailed"),{description:Me??u("gitView.pr.statusUnavailable")});return}if(Kt&&(re(!0),!await rt.push())){re(!1);return}const Nt=Yt(),Dt=se,ts={owner:st.owner,name:st.name},fs=D.trim()?D:void 0,us=ae?void 0:ce.primaryRemote,Se=ae?ce.primaryRemote:void 0,V=QS(Nt,ce,[ts.owner,ts.name,e,ze,Oe,fs,N,us,Se]),Ie=ct(V);if(!Ie){re(!1);return}re(!0);let Le=!1,Qe=!1;try{const yt={...ce,idempotencyKey:Ie,target:{project:ts,head:e,base:ze},title:Oe,draft:N};fs!==void 0&&(yt.body=fs),us&&(yt.remote=us),Se&&(yt.headRemote=Se);const Rt=await h.changeRequestCreate(yt);if(Qe=!0,pe(V,Ie,!1),!Ue(Nt,Dt)||(_e.success(u("gitView.pr.toast.prCreated")),await St({force:!0}),!Ue(Nt,Dt)))return;const zt=ls.getState().entries[Dt]?.status,Jt=zt?.changeRequest??zt?.pr;Jt&&Jt.number===Rt.target.number&&US(t,Jt),xt(Nt,Dt)}catch(yt){const Rt=yt instanceof Error?yt:new Error(String(yt));Le=Of(Rt);const zt=Rt.message;_e.error(u("gitView.pr.toast.createPrFailed"),{description:zt}),Le&&await Mt(Rt,Nt,Dt)}finally{Qe||pe(V,Ie,Le),re(!1)}},[ct,D,e,rt,me,t,N,Me,pe,Ue,Kt,se,ce,Mt,St,xt,h,Te?.changeRequests,Ye,M,O,ae,u]),ft="border-0 bg-transparent rounded-none px-4 py-3";if(!he)return n.jsx("section",{className:ft,children:n.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[n.jsx("div",{className:"min-w-0 typography-meta text-muted-foreground",children:u("gitView.pullRequest.availableOnFeatureBranches")}),n.jsx(TS,{identity:d??void 0})]})});const mt=U?.changeRequest&&U.changeRequest.state==="open"?U.changeRequest:tt&&Ye&&qe?{...qe,id:`${Ye.owner}/${Ye.name}#${tt.number}`,number:tt.number,project:{...qe,id:Ye.id,owner:Ye.owner,name:Ye.name,url:Ye.url??""},title:tt.title,body:tt.body,url:tt.url,state:tt.state,draft:tt.draft,base:tt.base,head:tt.head,headSha:tt.headSha,mergeable:tt.mergeable,mergeableState:tt.mergeableState}:null;if(mt&&ce)return n.jsx("div",{className:"h-full min-h-0",children:n.jsx(LS,{directory:t,context:ce,changeRequest:mt,onChanged:()=>{St({force:!0,silent:!0,markInitialResolved:!0})}})});const It=Ye?.url||null,xe=ae&&me?.url?me.url:It,it=ye?.status==="error",X=!!U?.connected,le=!!(!ce&&d&&q.status==="ready"&&ke),Xe=!!(qe&&we&&U?.connected===!1)||le,Ae=qe??d,Je=Ae?Ob(Ae.provider):null,Fe=qS(U),gt=Fe?`var(--pr-${Fe})`:"var(--status-info)",bt=Fe==="draft"?"git-pr-draft":Fe==="merged"?"git-merge":Fe==="closed"?"git-close-pull-request":"git-pull-request",Et=Ee?[`${Ee.state}${Ee.draft?" (draft)":""}`,Ee.state==="open"&&Ee.mergeable===!1?u("gitView.pr.notMergeable"):null,Ee.state==="open"&&typeof Ee.mergeableState=="string"&&Ee.mergeableState&&Ee.mergeableState!=="unknown"?Ee.mergeableState:null].filter(Boolean).join(" · "):"",Ft=ht?ht.total>0?`${ht.success}/${ht.total} ${u("gitView.pr.checks.label")}`:`${ht.state} ${u("gitView.pr.checks.label")}`:"",es="px-0 py-3 border-b border-border/40 flex flex-col gap-1",Re="flex flex-col gap-3 py-3",Ze=n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Be||vt,onClick:()=>{$t()},"aria-label":u("gitView.pr.actions.refreshAria"),children:n.jsx(Z,{name:Be||vt?"loader-4":"refresh",className:ve("size-4 text-muted-foreground",(Be||vt)&&"animate-spin")})})}),n.jsx(Tt,{children:n.jsx("p",{children:u("gitView.pr.actions.refresh")})})]}),at=te||I.trim().length>0,_t=Kt?r?o===1?u("gitView.pr.unpushed.one"):u("gitView.pr.unpushed.many",{count:o}):u("gitView.pr.unpushed.unpublished"):null,Vt=u(Kt?N?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":N?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),Ht=ne||!X||Te?.changeRequests!==!0||!M.trim()||!ae&&M.trim()===e;return n.jsxs("section",{className:ft,children:[Ee?n.jsxs("div",{className:es,children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsxs(Ct,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{wc(Ee.url)},"aria-label":Je?u("gitView.pr.actions.openOnProviderAria",{provider:Je}):u("gitView.header.openPullRequest"),children:[n.jsx(Z,{name:bt,className:"size-4 shrink-0",style:{color:gt}}),Je?u("gitView.pr.actions.openOnProvider",{provider:Je}):u("gitView.header.openPullRequest")]}),n.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:u("gitView.pullRequest.title")}),n.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:Ta(qe?.provider,Ee.number)})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:Ze})]}),n.jsxs("div",{className:"@container/pr-actions 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:gt},children:Et}),ht?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${GS(ht.state)}`}),Ft]}):null,r&&De&&r.split("/")[0]!==De?n.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",De]}):null]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:p&&(ce?.provider==="github"||ce?.provider==="gitlab")?n.jsxs(Ct,{variant:"outline",size:"sm",className:ve("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",DS),onClick:()=>{x(t,{source:{kind:"pr",number:Ee.number,...Ye?{sourceRepo:{owner:Ye.owner,repo:Ye.name}}:{}},context:ce}),S(t,"walkthrough")},"aria-label":u("walkthrough.action.open"),children:[n.jsx(Z,{name:"route",className:"size-4"}),n.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:u("walkthrough.action.open")})]}):null})]})]}):null,n.jsxs("div",{className:Re,children:[it?n.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3",children:[n.jsx("div",{className:"typography-ui-label text-[var(--status-error)]",children:u("gitView.pr.capabilitiesUnavailable")}),n.jsx(Ct,{variant:"outline",size:"sm",onClick:()=>L(Oe=>Oe+1),children:u("settings.sourceControl.transport.retry")})]}):null,Xe&&Je?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-meta text-muted-foreground",children:u("gitView.pr.providerNotConnected",{provider:Je})}),n.jsx(Ct,{variant:"outline",size:"sm",onClick:f,className:"w-fit",children:u("gitView.pr.actions.openSettings")})]}):null,Me?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-ui-label text-foreground",children:u("gitView.pr.statusUnavailable")}),n.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:Me}),q.error?n.jsx(Ct,{variant:"outline",size:"sm",onClick:()=>{q.retry()},disabled:q.status==="loading",children:u("settings.sourceControl.transport.retry")}):null,xe?n.jsx(Ct,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:n.jsxs("a",{href:xe,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(Z,{name:"external-link",className:"size-4"}),u("gitView.pr.actions.repo")]})}):null]}):null,(tt||!Ee&&!Ge)&&!Me&&!Xe&&(q.status==="loading"||ce)?n.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}),u("gitView.pr.checkingStatus")]}):n.jsxs("div",{className:"flex flex-col gap-3",children:[Ee&&$e?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(Z,{name:Ee.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:gt}}),n.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Ee.state==="merged"?u("gitView.pr.history.merged",{number:Ee.number,base:Ee.base||M}):u("gitView.pr.history.closed",{number:Ee.number})}),n.jsx(Ct,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{wc(Ee.url)},"aria-label":u("gitView.pr.actions.openOnProviderAria",{provider:Je}),children:n.jsx(Z,{name:"external-link",className:"size-3.5"})})]}):null,n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx(Z,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",title:e,children:e}),n.jsx(Z,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),ae&&me?n.jsxs("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:[me.owner,"/",me.name]}):null,Ve.length>0?n.jsxs(Bb,{value:M,onValueChange:_,children:[n.jsx(Fb,{className:"w-auto min-w-0","aria-label":u("gitView.pr.field.baseBranch"),children:n.jsx(Lb,{placeholder:u("gitView.pr.placeholder.selectBaseBranch")})}),n.jsx(_b,{children:Ve.map(Oe=>n.jsx($b,{value:Oe,children:Oe},Oe))})]}):n.jsx(ho,{value:M,onChange:Oe=>_(Oe.target.value),placeholder:u("gitView.pr.placeholder.main"),"aria-label":u("gitView.pr.field.baseBranch"),className:"h-7 w-32"}),n.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-0.5",children:[xe?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:n.jsx("a",{href:xe,target:"_blank",rel:"noopener noreferrer","aria-label":u("gitView.pr.actions.repo"),children:n.jsx(Z,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),n.jsx(Tt,{children:n.jsx("p",{children:u("gitView.pr.actions.repo")})})]}):null,Ze]})]}),n.jsxs("label",{className:"space-y-1",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.title")}),n.jsx(ho,{value:O,onChange:Oe=>W(Oe.target.value),placeholder:u("gitView.pr.placeholder.title"),autoCorrect:b?"on":"off",autoCapitalize:b?"sentences":"off",spellCheck:b})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("label",{htmlFor:ut,className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.description")}),n.jsxs("div",{className:"flex items-center",children:[n.jsxs(Ct,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:ue,disabled:F||ne,children:[F?n.jsx(Z,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(Z,{name:"ai-generate-2",className:"size-3.5 text-primary"}),u("gitView.commit.generate")]}),n.jsxs(js,{children:[n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:F||ne,"aria-label":u("gitView.pr.generate.optionsAria"),children:n.jsx(Z,{name:"arrow-down-s",className:"size-3.5"})})}),n.jsx(Ps,{align:"end",className:"w-60",children:n.jsxs(qt,{onSelect:()=>K(!0),children:[n.jsx(Z,{name:"sticky-note",className:"size-4 shrink-0"}),u("gitView.pr.generate.withNotes")]})})]})]})]}),at?n.jsxs("div",{className:"relative",children:[n.jsx(Hl,{value:I,onChange:Oe=>H(Oe.target.value),className:"min-h-[72px] pe-9",placeholder:u("gitView.pr.placeholder.additionalContext"),"aria-label":u("gitView.pr.generate.notesAria"),autoFocus:te&&!I}),n.jsx(Ct,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{H(""),K(!1)},"aria-label":u("gitView.pr.generate.removeNotesAria"),children:n.jsx(Z,{name:"close",className:"size-3.5"})})]}):null,n.jsx(Hl,{id:ut,value:D,onChange:Oe=>Q(Oe.target.value),className:"min-h-[140px]",placeholder:u("gitView.pr.placeholder.whatChanged"),autoCorrect:b?"on":"off",autoCapitalize:b?"sentences":"off",spellCheck:b})]}),_t?n.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[n.jsx(Z,{name:"arrow-up",className:"size-3.5 shrink-0"}),_t]}):null,n.jsx("div",{className:"flex justify-end",children:n.jsxs("div",{className:"flex items-center",children:[n.jsxs(Ct,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:lt,disabled:Ht,children:[ne?n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(Z,{name:N?"git-pr-draft":"git-pull-request",className:"size-4"}),n.jsx("span",{children:Vt})]}),n.jsxs(js,{children:[n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:ne,"aria-label":u("gitView.pr.createKindAria"),children:n.jsx(Z,{name:"arrow-down-s",className:"size-4"})})}),n.jsx(Ps,{align:"end",className:"w-56",children:n.jsxs(zb,{value:N?"draft":"ready",onValueChange:Oe=>pt(Oe==="draft"),children:[n.jsx(Vl,{value:"ready",children:u("gitView.pr.actions.createPr")}),n.jsx(Vl,{value:"draft",children:u("gitView.pr.actions.createDraftPr")})]})})]})]})}),rt.dialogs]})]})]})},nv=()=>{const t=He.c(100),{t:e}=wt(),{git:s,sourceControl:r}=Ws(),o=vn(),{rootIsGitRepo:i,gitDirectory:a,nestedRepos:l}=Vb(o??null),d=Aa(a??null),u=Gb(a??null),f=Ub(a??null),h=Bu(a,r),{ensureAll:m,ensureNestedRepos:g,selectNestedRepo:b}=gn(Zn(rv)),v=nt(ov),S=nt(iv),x=nt(av),p=nt(lv);let y;t[0]!==o?(y=ot(o),t[0]=o,t[1]=y):y=t[1];const w=y;let j;if(t[2]!==p||t[3]!==w||t[4]!==x){e:{if(!w){j=void 0;break e}let we;if(t[6]!==p||t[7]!==w){let L;t[9]!==w?(L=ie=>ot(ie.path)===w,t[9]=w,t[10]=L):L=t[10],we=p.find(L),t[6]=p,t[7]=w,t[8]=we}else we=t[8];const Pe=we;if(Pe){j=Pe;break e}for(const L of x.values())if(ot(L.path)===w){j=L;break e}j=void 0}t[2]=p,t[3]=w,t[4]=x,t[5]=j}else j=t[5];const k=j;let P;t[11]!==v||t[12]!==k||t[13]!==S?.open||t[14]!==x?(P=()=>{if(v)return x.get(v)??k;if(S?.open)return k},t[11]=v,t[12]=k,t[13]=S?.open,t[14]=x,t[15]=P):P=t[15],S?.open;let A;t[16]!==P?(A=P(),t[16]=P,t[17]=A):A=t[17];const B=A;let R;t[18]!==v?(R=we=>v?we.getAttachment(v):void 0,t[18]=v,t[19]=R):R=t[19];const E=vu(R),T=E&&!E.degraded&&!E.legacy?E.worktreeRoot??void 0:void 0,z=PS(o,B,d?.current??void 0);let O,W;t[20]!==m||t[21]!==s||t[22]!==a?(O=()=>{!a||!s||m(a,s)},W=[a,m,s],t[20]=m,t[21]=s,t[22]=a,t[23]=O,t[24]=W):(O=t[23],W=t[24]),c.useEffect(O,W);const[D,Q]=c.useState(null);let N;t[25]!==T||t[26]!==z?.projectDirectory?(N=()=>{const we=T||z?.projectDirectory;if(!we){Q(null);return}let Pe=!1;return $u(we).then(L=>{if(Pe)return;const ie=L.trim();Q(ie&&ie!=="HEAD"?ie:null)}).catch(()=>{Pe||Q(null)}),()=>{Pe=!0}},t[25]=T,t[26]=z?.projectDirectory,t[27]=N):N=t[27];const C=z?.projectDirectory;let I;t[28]!==T||t[29]!==C?(I=[T,C],t[28]=T,t[29]=C,t[30]=I):I=t[30],c.useEffect(N,I);let H;e:{if(!u?.all){let Pe;t[31]===Symbol.for("react.memo_cache_sentinel")?(Pe=[],t[31]=Pe):Pe=t[31],H=Pe;break e}let we;t[32]!==u.all?(we=u.all.filter(cv).sort(),t[32]=u.all,t[33]=we):we=t[33],H=we}const M=H;let _;e:{if(!u?.all){let Pe;t[34]===Symbol.for("react.memo_cache_sentinel")?(Pe=[],t[34]=Pe):Pe=t[34],_=Pe;break e}let we;t[35]!==u.all?(we=u.all.filter(dv).map(uv).sort(),t[35]=u.all,t[36]=we):we=t[36],_=we}const F=_,ee=d?.current??null,ne=h.contexts[0]?.primaryRemote,re=ne?u?.defaultBranches?.[ne]:void 0;let te;t[37]!==h.contexts[0]||t[38]!==h.read?.repository.remotes||t[39]!==ee||t[40]!==re||t[41]!==M||t[42]!==D||t[43]!==z?.createdFromBranch?(te=()=>ag({remoteNames:new Set(h.contexts[0]?.primaryRemote?[h.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(h.read?.repository.remotes.map(fv)??[]),localBranches:M,worktreeCreatedFromBranch:z?.createdFromBranch,rootBranchHint:D,defaultBranch:re,headBranch:ee,fallbackToConventional:!1}),t[37]=h.contexts[0],t[38]=h.read?.repository.remotes,t[39]=ee,t[40]=re,t[41]=M,t[42]=D,t[43]=z?.createdFromBranch,t[44]=te):te=t[44],z?.createdFromBranch;let K;t[45]!==te?(K=te(),t[45]=te,t[46]=K):K=t[46];const q=K,oe=Ou(o??null)?.provider;if(!o){let we;t[47]===Symbol.for("react.memo_cache_sentinel")?(we=n.jsx(Z,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[47]=we):we=t[47];let Pe;t[48]!==oe||t[49]!==e?(Pe=e(en("gitView.pullRequest.title",oe)),t[48]=oe,t[49]=e,t[50]=Pe):Pe=t[50];let L;t[51]!==Pe?(L=n.jsx("div",{className:"typography-ui-header text-foreground",children:Pe}),t[51]=Pe,t[52]=L):L=t[52];let ie;t[53]!==oe||t[54]!==e?(ie=e(en("gitView.pullRequest.createHint",oe)),t[53]=oe,t[54]=e,t[55]=ie):ie=t[55];let G;t[56]!==ie?(G=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ie}),t[56]=ie,t[57]=G):G=t[57];let ae;return t[58]!==L||t[59]!==G?(ae=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[we,L,G]}),t[58]=L,t[59]=G,t[60]=ae):ae=t[60],ae}if(i===!1&&f!==!0){let we;t[61]!==o||t[62]!==g?(we=()=>{g(o,{force:!0})},t[61]=o,t[62]=g,t[63]=we):we=t[63];let Pe;return t[64]!==o||t[65]!==f||t[66]!==l||t[67]!==i||t[68]!==we?(Pe=n.jsx(lg,{root:o,rootIsGitRepo:i,resolvedIsGitRepo:f,nestedRepos:l,onRetryDiscovery:we}),t[64]=o,t[65]=f,t[66]=l,t[67]=i,t[68]=we,t[69]=Pe):Pe=t[69],Pe}if(!ee){let we;t[70]===Symbol.for("react.memo_cache_sentinel")?(we=n.jsx(Z,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[70]=we):we=t[70];let Pe;t[71]!==oe||t[72]!==e?(Pe=e(en("gitView.pullRequest.title",oe)),t[71]=oe,t[72]=e,t[73]=Pe):Pe=t[73];let L;t[74]!==Pe?(L=n.jsx("div",{className:"typography-ui-header text-foreground",children:Pe}),t[74]=Pe,t[75]=L):L=t[75];let ie;t[76]!==oe||t[77]!==e?(ie=e(en("gitView.pullRequest.createHint",oe)),t[76]=oe,t[77]=e,t[78]=ie):ie=t[78];let G;t[79]!==ie?(G=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ie}),t[79]=ie,t[80]=G):G=t[80];let ae;return t[81]!==L||t[82]!==G?(ae=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[we,L,G]}),t[81]=L,t[82]=G,t[83]=ae):ae=t[83],ae}const fe=i===!1&&Array.isArray(l)&&l.length>0;let ce;t[84]!==o||t[85]!==a||t[86]!==l||t[87]!==b||t[88]!==fe?(ce=fe?n.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:n.jsx(cg,{repositories:l,selectedRepository:a??null,onSelectRepository:we=>{o&&b(o,we)},repositoryRoot:o??void 0})}):null,t[84]=o,t[85]=a,t[86]=l,t[87]=b,t[88]=fe,t[89]=ce):ce=t[89];const ke=a??o,De=d?.tracking??void 0,Ce=d?.ahead??0;let Y;t[90]!==q||t[91]!==ee||t[92]!==F||t[93]!==ke||t[94]!==De||t[95]!==Ce?(Y=n.jsx(Pr,{as:qb,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:n.jsx(sv,{directory:ke,branch:ee,baseBranch:q,trackingBranch:De,ahead:Ce,remoteBranches:F})}),t[90]=q,t[91]=ee,t[92]=F,t[93]=ke,t[94]=De,t[95]=Ce,t[96]=Y):Y=t[96];let je;return t[97]!==ce||t[98]!==Y?(je=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ce,Y]}),t[97]=ce,t[98]=Y,t[99]=je):je=t[99],je};function rv(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function ov(t){return t.currentSessionId}function iv(t){return t.newSessionDraft}function av(t){return t.worktreeMetadata}function lv(t){return t.availableWorktrees}function cv(t){return!t.startsWith("remotes/")}function dv(t){return t.startsWith("remotes/")}function uv(t){return t.replace(/^remotes\//,"")}function fv(t){return t.name}const yo=new Map,hv=(t,e)=>{if(t.size!==e.size)return!1;for(const[s,r]of t)if(e.get(s)!==r)return!1;return!0},pv=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},mv=(t,e)=>{if(e.length===0)return yo;const s=new Set(e),r=new Map,o=new Map;for(const i of t)for(const a of i.session){if(!s.has(a.id))continue;const l=a.title?.trim();if(!l)continue;const d=pv(a),u=r.get(a.id);u!==void 0&&u>d||(r.set(a.id,d),o.set(a.id,l))}return o.size===0?yo:o},Ya=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,kc=60,gv=t=>{try{return new URL(t).origin}catch{return""}},pi=new Set,Ff=Nr()((t,e)=>({byOrigin:{},resolve:(s,r,o)=>{const i=gv(s);!i||!r||e().byOrigin[i]||pi.has(i)||(pi.add(i),Fn("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(a=>{const l=typeof a?.dataUrl=="string"?a.dataUrl:"";l&&t(d=>{const u={...d.byOrigin,[i]:l},f=Object.keys(u);if(f.length<=kc)return{byOrigin:u};for(const h of f.slice(0,f.length-kc))delete u[h];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{pi.delete(i)}))}})),Xa=t=>t,Yi=t=>{const e=Xa(t).type;return typeof e=="string"?e:""},bv=t=>{const e=Xa(t).tool;return typeof e=="string"?e:""},yv=t=>{const e=Xa(t).text;return typeof e=="string"?e:""},xv=t=>{const e=Yi(t);return e==="tool"?bv(t).trim().toLowerCase()||"tool":e||"unknown"},Sv=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=xv(s);e.includes(r)||e.push(r)}return e.join(" + ")},vv=t=>t.replace(/\s+/g," ").trim(),wv=t=>{for(const s of t)if(Yi(s)==="text"){const r=vv(yv(s));if(r.length===0)continue;return r}const e=t.filter(s=>Yi(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},kv=(t,e,s)=>`${s(t)} / ${s(e)}`,jv=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Cv=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=jv(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}})},Xi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Qr={user:0,assistant:0,tool:0,other:0},un=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,jc=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{...Xi,total:un(s)};if(!s||typeof s!="object")return Xi;const r=s,o=un(r.input),i=un(r.output),a=un(r.reasoning),l=un(r.cache?.read),d=un(r.cache?.write),u=un(r.total);return{input:o,output:i,reasoning:a,cacheRead:l,cacheWrite:d,total:u>0?u:o+i+a+l+d}},Pv=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Ns=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+Ns(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+Ns(s),0):0,Ev=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...Qr,assistant:Ns(s.text)+Ns(s.content)};const o=Pv(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Ns(s.input)+Ns(s.output)+Ns(s.error)+Ns(s.call?.input)+Ns(s.call?.output)+Ns(s.call?.error)+Ns(s.raw)+Math.round(Ns(s.metadata)*.25)+Math.round(Ns(s.state)*.1)+Math.round((Qp(t)??0)*.1),other:0}:e==="user"?{user:o.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:o.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:o.length}},Cc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),Nv=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",Iv=(t,e)=>{if(t.length===0)return{...Qr};const s=t.reduce((r,o)=>{const i=Nv(o);let a={...Qr};for(const l of o.parts)a=Cc(a,Ev(l,i));return Cc(r,a)},{...Qr});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)}},Nn=t=>t.toLocaleString(Wu()),Rv=(t,e)=>!t||!Number.isFinite(t)?"-":Zb(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Dv=(t,e,s)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===s);return{providerName:r?.name||e||"-",modelName:o?.name||s||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},Tv=()=>{const t=He.c(219),{t:e}=wt(),s=dg(),r=de(Mv);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,a]=c.useState(o),[l,d]=c.useState(null),u=c.useRef(null),f=nt(Av),h=nt(Ov),m=Yb(h??void 0),g=Xb(f??"",h??void 0),b=ns(Bv);let v;t[1]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),a(Fv),d(null)},t[1]=v):v=t[1];let S;t[2]!==h||t[3]!==f?(S=[h,f],t[2]=h,t[3]=f,t[4]=S):S=t[4],c.useEffect(v,S);let x,p;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},p=[],t[5]=x,t[6]=p):(x=t[5],p=t[6]),c.useEffect(x,p);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=async(Je,Fe)=>{(await Oo(Fe)).ok?(d(Je),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{d(bt=>bt===Je?null:bt),u.current=null},2e3)):d(null)},t[7]=y):y=t[7];const w=y;let j;t[8]!==f||t[9]!==m?(j=f?m.find(Je=>Je.id===f)??null:null,t[8]=f,t[9]=m,t[10]=j):j=t[10];const k=j;let P,A,B,R,E,T,z;if(t[11]!==g){P=g.filter(Lv),z=g.filter(_v);const Je=zu(g.map($v));B=Je?g[Je.index]??null:null,R=Je?.state==="compacted";let Fe;t[19]!==B?(T=B?jc(B):Xi,Fe=Qb({input:T.input,cache:{read:T.cacheRead,write:T.cacheWrite}}),t[19]=B,t[20]=Fe,t[21]=T):(Fe=t[20],T=t[21]),A=Fe,E=P.reduce(zv,0),t[11]=g,t[12]=P,t[13]=A,t[14]=B,t[15]=R,t[16]=E,t[17]=T,t[18]=z}else P=t[12],A=t[13],B=t[14],R=t[15],E=t[16],T=t[17],z=t[18];const O=E,W=B?.info??null,D=b,Q=W?.providerID||"",N=W?.modelID||"";let C;t[22]!==N||t[23]!==D||t[24]!==Q?(C=Dv(D,Q,N),t[22]=N,t[23]=D,t[24]=Q,t[25]=C):C=t[25];const I=C,H=I.contextLimit,M=R?null:H&&H>0?Math.min(999,T.total/H*100):0;let _;if(t[26]!==g){const Je=[...g].reverse().find(Wv),Fe=Je?.info.role==="system"?Je.info.text:"";_=Iv(g,Fe),t[26]=g,t[27]=_}else _=t[27];const F=_,ee=F.user,ne=F.assistant,re=F.tool,te=Math.max(0,T.input-ee-ne-re),K=ee+ne+re+te,q=g[0]?.info?.time?.created,oe=g.length>0?g[g.length-1]?.info?.time?.created:null;let fe;t[28]!==k?.title||t[29]!==e?(fe=k?.title||e("contextSidebar.session.untitled"),t[28]=k?.title,t[29]=e,t[30]=fe):fe=t[30];const ce=k?.time?.created??q??null,ke=oe??k?.time?.created??null;let De;t[31]!==ne||t[32]!==te||t[33]!==re||t[34]!==ee?(De={user:ee,assistant:ne,tool:re,other:te},t[31]=ne,t[32]=te,t[33]=re,t[34]=ee,t[35]=De):De=t[35];let Ce;t[36]!==P.length||t[37]!==K||t[38]!==A||t[39]!==H||t[40]!==I||t[41]!==g.length||t[42]!==fe||t[43]!==ce||t[44]!==ke||t[45]!==De||t[46]!==T||t[47]!==O||t[48]!==M||t[49]!==z.length?(Ce={sessionTitle:fe,messagesCount:g.length,userMessagesCount:z.length,assistantMessagesCount:P.length,createdAt:ce,lastActivityAt:ke,providerModel:I,tokenBreakdown:T,usagePercent:M,cacheHitRate:A,totalAssistantCost:O,contextLimit:H,breakdown:De,breakdownTotal:K},t[36]=P.length,t[37]=K,t[38]=A,t[39]=H,t[40]=I,t[41]=g.length,t[42]=fe,t[43]=ce,t[44]=ke,t[45]=De,t[46]=T,t[47]=O,t[48]=M,t[49]=z.length,t[50]=Ce):Ce=t[50];const Y=Ce;if(!f){let Je;t[51]!==e?(Je=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=Je):Je=t[52];let Fe;return t[53]!==Je?(Fe=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Je}),t[53]=Je,t[54]=Fe):Fe=t[54],Fe}let je;t[55]!==e?(je=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=je):je=t[56];let we;t[57]!==je||t[58]!==Y.breakdown.user?(we={key:"user",label:je,value:Y.breakdown.user,color:"var(--status-success)"},t[57]=je,t[58]=Y.breakdown.user,t[59]=we):we=t[59];let Pe;t[60]!==e?(Pe=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=Pe):Pe=t[61];let L;t[62]!==Pe||t[63]!==Y.breakdown.assistant?(L={key:"assistant",label:Pe,value:Y.breakdown.assistant,color:"var(--primary-base)"},t[62]=Pe,t[63]=Y.breakdown.assistant,t[64]=L):L=t[64];let ie;t[65]!==e?(ie=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=ie):ie=t[66];let G;t[67]!==ie||t[68]!==Y.breakdown.tool?(G={key:"tool",label:ie,value:Y.breakdown.tool,color:"var(--status-warning)"},t[67]=ie,t[68]=Y.breakdown.tool,t[69]=G):G=t[69];let ae;t[70]!==e?(ae=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=ae):ae=t[71];let ge;t[72]!==ae||t[73]!==Y.breakdown.other?(ge={key:"other",label:ae,value:Y.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=ae,t[73]=Y.breakdown.other,t[74]=ge):ge=t[74];let me;t[75]!==we||t[76]!==L||t[77]!==G||t[78]!==ge?(me=[we,L,G,ge],t[75]=we,t[76]=L,t[77]=G,t[78]=ge,t[79]=me):me=t[79];const be=me;let ye;t[80]!==s||t[81]!==Y.sessionTitle?(ye=s?n.jsx(ug,{children:n.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:n.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:Y.sessionTitle,children:Y.sessionTitle})})}):null,t[80]=s,t[81]=Y.sessionTitle,t[82]=ye):ye=t[82];let Te;t[83]!==s||t[84]!==Y.sessionTitle?(Te=s?null:n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:Y.sessionTitle}),t[83]=s,t[84]=Y.sessionTitle,t[85]=Te):Te=t[85];const $=!s&&"mt-1";let he;t[86]!==$?(he=ve($,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70"),t[86]=$,t[87]=he):he=t[87];let se;t[88]!==Y.providerModel.modelName||t[89]!==Y.providerModel.providerName?(se=n.jsxs("span",{children:[Y.providerModel.providerName," / ",Y.providerModel.modelName]}),t[88]=Y.providerModel.modelName,t[89]=Y.providerModel.providerName,t[90]=se):se=t[90];let Ne;t[91]!==r||t[92]!==Y.createdAt?(Ne=Y.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:Rv(Y.createdAt,r)})]}),t[91]=r,t[92]=Y.createdAt,t[93]=Ne):Ne=t[93];let Ue;t[94]!==he||t[95]!==se||t[96]!==Ne?(Ue=n.jsxs("div",{className:he,children:[se,Ne]}),t[94]=he,t[95]=se,t[96]=Ne,t[97]=Ue):Ue=t[97];let We;t[98]!==Te||t[99]!==Ue?(We=n.jsxs("div",{className:"mb-6",children:[Te,Ue]}),t[98]=Te,t[99]=Ue,t[100]=We):We=t[100];let Ke;t[101]!==e?(Ke=e("contextSidebar.section.context"),t[101]=e,t[102]=Ke):Ke=t[102];let Be;t[103]!==Ke?(Be=n.jsx("span",{className:"typography-micro text-muted-foreground",children:Ke}),t[103]=Ke,t[104]=Be):Be=t[104];let U;t[105]!==Y.tokenBreakdown.total||t[106]!==Y.usagePercent?(U=Y.usagePercent===null?"—":Nn(Y.tokenBreakdown.total),t[105]=Y.tokenBreakdown.total,t[106]=Y.usagePercent,t[107]=U):U=t[107];let Me;t[108]!==Y.contextLimit?(Me=Y.contextLimit?` / ${Nn(Y.contextLimit)}`:"",t[108]=Y.contextLimit,t[109]=Me):Me=t[109];let Ge;t[110]!==U||t[111]!==Me?(Ge=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[U,Me]}),t[110]=U,t[111]=Me,t[112]=Ge):Ge=t[112];let Ve;t[113]!==Be||t[114]!==Ge?(Ve=n.jsxs("div",{className:"flex items-baseline justify-between",children:[Be,Ge]}),t[113]=Be,t[114]=Ge,t[115]=Ve):Ve=t[115];let dt;t[116]!==Y.usagePercent?(dt=Y.usagePercent!==null&&Y.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,Y.usagePercent)}%`,backgroundColor:Y.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[116]=Y.usagePercent,t[117]=dt):dt=t[117];let et;t[118]!==dt?(et=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:dt}),t[118]=dt,t[119]=et):et=t[119];let ct;t[120]!==e||t[121]!==Y.usagePercent?(ct=Y.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:Y.usagePercent.toFixed(1)}),t[120]=e,t[121]=Y.usagePercent,t[122]=ct):ct=t[122];let pe;t[123]!==ct?(pe=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:ct}),t[123]=ct,t[124]=pe):pe=t[124];let Ee;t[125]!==Ve||t[126]!==et||t[127]!==pe?(Ee=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Ve,et,pe]}),t[125]=Ve,t[126]=et,t[127]=pe,t[128]=Ee):Ee=t[128];let qe;t[129]!==e?(qe=e("contextSidebar.stats.messages"),t[129]=e,t[130]=qe):qe=t[130];let Ye;t[131]!==Y.messagesCount?(Ye=Nn(Y.messagesCount),t[131]=Y.messagesCount,t[132]=Ye):Ye=t[132];let $e;t[133]!==qe||t[134]!==Ye?($e={label:qe,value:Ye},t[133]=qe,t[134]=Ye,t[135]=$e):$e=t[135];let tt;t[136]!==e?(tt=e("contextSidebar.stats.user"),t[136]=e,t[137]=tt):tt=t[137];let ht;t[138]!==Y.userMessagesCount?(ht=Nn(Y.userMessagesCount),t[138]=Y.userMessagesCount,t[139]=ht):ht=t[139];let vt;t[140]!==tt||t[141]!==ht?(vt={label:tt,value:ht},t[140]=tt,t[141]=ht,t[142]=vt):vt=t[142];let Bt;t[143]!==e?(Bt=e("contextSidebar.stats.assistant"),t[143]=e,t[144]=Bt):Bt=t[144];let kt;t[145]!==Y.assistantMessagesCount?(kt=Nn(Y.assistantMessagesCount),t[145]=Y.assistantMessagesCount,t[146]=kt):kt=t[146];let St;t[147]!==Bt||t[148]!==kt?(St={label:Bt,value:kt},t[147]=Bt,t[148]=kt,t[149]=St):St=t[149];let xt;t[150]!==e?(xt=e("contextSidebar.stats.cost"),t[150]=e,t[151]=xt):xt=t[151];let Mt;t[152]!==Y.totalAssistantCost?(Mt=kf(Y.totalAssistantCost),t[152]=Y.totalAssistantCost,t[153]=Mt):Mt=t[153];let jt;t[154]!==xt||t[155]!==Mt?(jt={label:xt,value:Mt},t[154]=xt,t[155]=Mt,t[156]=jt):jt=t[156];let $t;t[157]!==$e||t[158]!==vt||t[159]!==St||t[160]!==jt?($t=[$e,vt,St,jt],t[157]=$e,t[158]=vt,t[159]=St,t[160]=jt,t[161]=$t):$t=t[161];const Wt=$t;let Kt;t[162]!==Wt?(Kt=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:Wt.map(Kv)}),t[162]=Wt,t[163]=Kt):Kt=t[163];let rt;t[164]!==e?(rt=e("contextSidebar.section.lastAssistantMessage"),t[164]=e,t[165]=rt):rt=t[165];let ut;t[166]!==rt?(ut=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:rt}),t[166]=rt,t[167]=ut):ut=t[167];let pt;t[168]!==e||t[169]!==Y.cacheHitRate.hasInput||t[170]!==Y.cacheHitRate.percent||t[171]!==Y.tokenBreakdown.cacheRead||t[172]!==Y.tokenBreakdown.cacheWrite||t[173]!==Y.tokenBreakdown.input||t[174]!==Y.tokenBreakdown.output||t[175]!==Y.tokenBreakdown.reasoning?(pt=n.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:Y.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:Y.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:Y.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:Y.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:Y.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:Y.cacheHitRate.hasInput?Y.cacheHitRate.percent:null,format:"percent"}].map(Hv)}),t[168]=e,t[169]=Y.cacheHitRate.hasInput,t[170]=Y.cacheHitRate.percent,t[171]=Y.tokenBreakdown.cacheRead,t[172]=Y.tokenBreakdown.cacheWrite,t[173]=Y.tokenBreakdown.input,t[174]=Y.tokenBreakdown.output,t[175]=Y.tokenBreakdown.reasoning,t[176]=pt):pt=t[176];let ue;t[177]!==ut||t[178]!==pt?(ue=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ut,pt]}),t[177]=ut,t[178]=pt,t[179]=ue):ue=t[179];let lt;t[180]!==be||t[181]!==Y.breakdownTotal?(lt=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:be.map(Je=>Je.value<=0||Y.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${Je.value/Y.breakdownTotal*100}%`,backgroundColor:Je.color}},Je.key))}),t[180]=be,t[181]=Y.breakdownTotal,t[182]=lt):lt=t[182];let ft;t[183]!==be||t[184]!==Y.breakdownTotal?(ft=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:be.map(Je=>{const Fe=Y.breakdownTotal>0?Je.value/Y.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:Je.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[Je.label," ",n.jsxs("span",{className:"tabular-nums",children:[Fe.toFixed(0),"%"]})]})]},Je.key)})}),t[183]=be,t[184]=Y.breakdownTotal,t[185]=ft):ft=t[185];let mt;t[186]!==lt||t[187]!==ft?(mt=n.jsxs("div",{className:"mb-6",children:[lt,ft]}),t[186]=lt,t[187]=ft,t[188]=mt):mt=t[188];let It;t[189]!==e?(It=e("contextSidebar.section.rawMessages"),t[189]=e,t[190]=It):It=t[190];let xe;t[191]!==It?(xe=n.jsx("div",{className:"typography-micro text-muted-foreground",children:It}),t[191]=It,t[192]=xe):xe=t[192];let it;if(t[193]!==l||t[194]!==i||t[195]!==g||t[196]!==e||t[197]!==r){let Je;t[199]!==l||t[200]!==i||t[201]!==e||t[202]!==r?(Je=Fe=>{const gt=Fe.info.role,bt=gt==="assistant",Et=gt==="user",Ft=i[Fe.info.id]===!0,es=l===Fe.info.id,Re=Fe.info.time?.created??null,Ze=Sv(Fe.parts),at=bt?jc({info:Fe.info,parts:Fe.parts}):null,_t=Et?wv(Fe.parts):"",Vt=Cv(Re,r),Ht=Ze||"—",Oe=at?kv(at.input,at.output,Nn):"",ze=gt||"unknown",st=Ze?`${ze}: ${Ze}`:ze,Nt=Ft?JSON.stringify({info:Fe.info,parts:Fe.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-start hover:bg-[var(--interactive-hover)]","aria-expanded":Ft,onClick:()=>{a(Dt=>({...Dt,[Fe.info.id]:Dt[Fe.info.id]!==!0}))},children:n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:bt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Et?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:bt?Ht:st}),bt&&n.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:Oe})]}),n.jsx("span",{className:"text-end text-muted-foreground",children:Vt})]})}),Ft&&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 inset-e-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:Dt=>{Dt.stopPropagation(),w(Fe.info.id,Nt)},"aria-label":e(es?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(es?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:es?n.jsx(Z,{name:"check",className:"size-3.5"}):n.jsx(Z,{name:"file-copy",className:"size-3.5"})})}),n.jsx(Jb,{language:"json",code:Nt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Fe.info.id)},t[199]=l,t[200]=i,t[201]=e,t[202]=r,t[203]=Je):Je=t[203],it=[...g].reverse().map(Je),t[193]=l,t[194]=i,t[195]=g,t[196]=e,t[197]=r,t[198]=it}else it=t[198];let X;t[204]!==it?(X=n.jsx("div",{className:"mt-2.5 space-y-1",children:it}),t[204]=it,t[205]=X):X=t[205];let le;t[206]!==xe||t[207]!==X?(le=n.jsxs("div",{children:[xe,X]}),t[206]=xe,t[207]=X,t[208]=le):le=t[208];let Xe;t[209]!==We||t[210]!==Ee||t[211]!==Kt||t[212]!==ue||t[213]!==mt||t[214]!==le?(Xe=n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[We,Ee,Kt,ue,mt,le]}),t[209]=We,t[210]=Ee,t[211]=Kt,t[212]=ue,t[213]=mt,t[214]=le,t[215]=Xe):Xe=t[215];let Ae;return t[216]!==ye||t[217]!==Xe?(Ae=n.jsxs(Pr,{outerClassName:"h-full",className:"bg-background",children:[ye,Xe]}),t[216]=ye,t[217]=Xe,t[218]=Ae):Ae=t[218],Ae};function Mv(t){return t.timeFormatPreference}function Av(t){return t.currentSessionId}function Ov(t){return t.currentSessionDirectory}function Bv(t){return t.providers}function Fv(t){return Object.keys(t).length>0?{}:t}function Lv(t){return t.info.role==="assistant"}function _v(t){return t.info.role==="user"}function $v(t){return t.info}function zv(t,e){const s=un(e.info.cost);return t+s}function Wv(t){return t.info.role==="system"}function Kv(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 Hv(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)}%`:Nn(t.value):"—"})]},t.label)}const Lf=(t,e,s,r=t.currentTarget)=>{t.key!=="Escape"||!e||t.target instanceof Node&&!(r??t.currentTarget).contains(t.target)||ey(t.target)||ty(t.target)||t.defaultPrevented||(t.preventDefault(),t.stopPropagation(),s())},Vv=280,Gv=.28,Uv=240,qv=.35,Yv=(t,e,s=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=s?s.top:i-Math.min(Uv,e.height*qv),l=Math.min(Vv,t.width*Gv,e.width/4),d=e.left-t.left>=1,u=r-o>=1,f=Math.max(0,a-t.top),h=d?e.left:t.left+l,m=u?o:r-l;return{left:{left:t.left,top:t.top,width:h-t.left,height:d?t.height:f},right:{left:m,top:t.top,width:r-m,height:u?t.height:f},bottom:{left:e.left,top:a,width:e.width,height:Math.max(0,i-a)}}},mi=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,Xv=(t,e)=>mi(t.bottom,e)?"bottom":mi(t.left,e)?"left":mi(t.right,e)?"right":null,on=Nr(()=>({drag:null,hovered:null})),Zr=t=>{if(!t)return null;const{left:e,top:s,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:s,width:r,height:o}:null},gi=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),bi=t=>Zr(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),_f=t=>{const e=Zr(document.querySelector("[data-workspace-row]")),s=Zr(document.querySelector("[data-workspace-chat]"));if(!e||!s)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=Yv(e,s,Zr(r)),i={left:bi("left")??gi(o.left),right:bi("right")??gi(o.right),bottom:bi("bottom")??gi(o.bottom)};return on.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},$f=t=>{const{drag:e,hovered:s}=on.getState();if(!e)return;const r=Xv(e.targets,t);r!==s&&on.setState({hovered:r})},Qi=()=>{on.getState().drag&&on.setState({drag:null,hovered:null})},zf=t=>{const{drag:e,hovered:s}=on.getState();if(on.setState({drag:null,hovered:null}),!e||!s)return!1;const r=de.getState();s!==e.from&&r.moveContextSurfaceToZone(e.mode,s);const o=t?vs(t):"";if(o){const i=de.getState();ya(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},Qa=(t,e)=>{let s=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(s||(s=_f(t)),s&&$f(a)):s&&(Qi(),s=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),s?(zf(i),!0):!1),cancel:()=>{o(),s&&Qi()}}},Pc={left:null,right:null,bottom:null},vr=Nr(()=>({body:Pc,headerSlot:Pc})),Wf=(t,e,s)=>{const r=vr.getState()[t];r[e]!==s&&vr.setState({[t]:{...r,[e]:s}})},Qv=(t,e)=>Wf("body",t,e),Zv=(t,e)=>Wf("headerSlot",t,e),Jr=t=>{const e=c.useRef(t);e.current=t;const[s,r]=c.useState(t),o=c.useCallback(()=>r(e.current),[]);return c.useLayoutEffect(()=>{Da(o)},[t,o]),c.useEffect(()=>()=>Ku(o),[o]),t||s},Jv=nr(()=>ss(()=>import("./GitView-npRGKKx8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.GitView}))),ew=nr(()=>ss(()=>import("./PlanView-IkTcPrbw.js"),__vite__mapDeps([124,1,2,3,4,5,6,7,8,125,29,30,31,32,33,34,28,35,36,37,126,127,128,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,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,118,83,129,119,120,105,106,90,91,92,93,94,95,96,97,98,99,100,101,102,103])).then(t=>({default:t.PlanView}))),Kf=320,Hf=600,Vf=400,tw=100,sw=24,nw=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},Ec=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Kf,Math.round(t))):Hf,rw=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Kf,t-Vf),ow=(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},eo=(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==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):Yn(t)?Ia.getState().guests.find(r=>r.id===lo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),iw=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},aw=(t,e,s)=>{if(t.mode==="chat"){const r=Ya(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||s("contextPanel.mode.chat")}return t.mode==="browser"?Ro(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?iw(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):eo(t.mode,s)},lw=t=>{const e=He.c(8),{mode:s}=t,r=Ba();let o;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],o=r.find(u),e[0]=s,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??ry,l=i?.iconSrc;let d;return e[5]!==a||e[6]!==l?(d=n.jsx(sr,{icon:a,iconSrc:l,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=l,e[7]=d):d=e[7],d},Nc=(t,e={})=>{if(t.mode==="file")return t.targetPath?n.jsx(Oa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(ru,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx(Z,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx(Z,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx(Z,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="notes")return n.jsx(Z,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx(Z,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return n.jsx(Z,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx(Z,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return n.jsx(Z,{name:"chat-4",className:"h-3.5 w-3.5"});if(Yn(t.mode))return n.jsx(lw,{mode:t.mode});if(t.mode==="browser"){const s=cw(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(Z,{name:"global",className:"h-3.5 w-3.5"})}},cw=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},dw=t=>{const e=Er(),s=c.useRef(yo),r=c.useRef(t);r.current=t;const o=t.length>0;return c.useSyncExternalStore(c.useCallback(i=>o?e.subscribeAllSelected(a=>a.session,i):()=>{},[e,o]),c.useCallback(()=>{const i=Array.from(e.children.values(),l=>l.getState()),a=mv(i,r.current);return hv(s.current,a)?s.current:(s.current=a,a)},[e]),()=>yo)},uw=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,fw=8,hw='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',pw=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="plan",Gf=320,Uf=160,qf=200,mw={right:{axis:"x",gutter:"mb-2 ms-2 me-1.5",gutterSize:"0.875rem",expanded:"absolute inset-y-0 inset-e-0 z-20 min-w-0",handle:"absolute bottom-2 inset-s-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},left:{axis:"x",gutter:"mb-2 ms-1.5 me-2",gutterSize:"0.875rem",expanded:"absolute inset-y-0 inset-s-0 z-20 min-w-0",handle:"absolute bottom-2 inset-e-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},bottom:{axis:"y",gutter:"mb-2 mt-2",gutterSize:"1rem",expanded:"absolute inset-x-0 bottom-0 z-20 min-h-0",handle:"absolute inset-x-0 top-1 z-50 h-2 cursor-row-resize",sizeVariable:"--oc-context-panel-height"}},Ic=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Uf,Math.round(t))):Gf,gw=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Uf,t-qf),yi=({zone:t="right"})=>{const e=mw[t],s=Na(),r=e.axis==="y",{t:o,direction:i}=wt(),a=i==="rtl",l=vn()??"",d=Hu(l||null),u=c.useCallback((xe,it)=>o(en(xe,d),it),[d,o]),f=c.useMemo(()=>nw(l),[l]),h=de(xe=>f?xe.contextPanelByDirectory[f]:void 0),m=de(xe=>xe.contextSurfaceZones),g=de(xe=>xe.closeContextZone),b=de(xe=>xe.closeContextPanelTab),v=de(xe=>xe.pinContextPanelTab),S=de(xe=>xe.toggleContextPanelExpanded),x=de(xe=>xe.setContextPanelWidth),p=de(xe=>xe.setContextPanelHeight),y=de(xe=>xe.setActiveContextPanelTab),w=de(xe=>xe.reorderContextPanelTabs),j=de(xe=>xe.contextEditorTreeVisible),k=de(xe=>xe.contextEditorTreeWidth),P=de(xe=>xe.setContextEditorTreeWidth),A=de(xe=>xe.toggleContextEditorTree),B=de(xe=>xe.contextEditorVisible),R=de(xe=>xe.toggleContextEditor),E=de(xe=>xe.fileTreeSide),T=de(xe=>xe.openNewContextBrowserTab),z=Ff(xe=>xe.byOrigin),[O,W]=c.useState(null),D=c.useCallback(xe=>{W(xe),Zv(t,xe)},[t]),Q=c.useCallback(xe=>{Qv(t,xe)},[t]),N=c.useMemo(()=>h?.tabs??[],[h?.tabs]),C=h?ao(h,m,t):null,I=h?Io(h,t):Zp,H=Fi(xe=>xe.workStatusReserved),M=Fi(xe=>xe.chatCovered),_=t==="bottom"&&M,F=!!(I.isOpen&&C)&&!_,ee=c.useMemo(()=>N.some(xe=>xe.mode==="file"&&xe.targetPath),[N]),ne=ee&&(B||!j),re=C?.mode??null,te=!r&&re==="file"&&!ne,K=!!(F&&I.expanded&&!te),q=re?r?h?.heightByMode?.[re]:h?.widthByMode?.[re]:void 0,oe=te?k:r?Ic(q??Gf,Number.POSITIVE_INFINITY):Ec(q??(re?Li(re):Hf),Number.POSITIVE_INFINITY),fe=c.useCallback((xe,it)=>r?Ic(xe,gw(it)):Ec(xe,rw(it)),[r]),ce=r?qf:Vf,ke=t==="right"?"left":t==="left"?"right":null,De=de(xe=>{if(!ke||!f)return 0;const it=xe.contextPanelByDirectory[f],X=it&&hr(it,xe.contextSurfaceZones,ke)?ao(it,xe.contextSurfaceZones,ke):null;if(!it||!X)return 0;const le=it.tabs.some(Xe=>Xe.mode==="file"&&Xe.targetPath)&&(xe.contextEditorVisible||!xe.contextEditorTreeVisible);return X.mode==="file"&&!le?xe.contextEditorTreeWidth:it.widthByMode[X.mode]??Li(X.mode)}),Ce=ke==="right"&&H&&!M&&De===0?Gl:De,[Y,je]=c.useState(null),we=c.useRef(null),Pe=c.useRef(Ce);Pe.current=Ce;const L=c.useRef(()=>!1);L.current=xe=>K||!te&&xe-Pe.current-ce<oe;const ie=c.useCallback(()=>{const xe=we.current;je(xe!==null&&L.current(xe)?xe:null)},[]),G=Y!==null?Y-Ce:null,ae=t==="left"?Y:G,ge=te?oe:fe(oe,G),me=F&&C?.mode==="chat",be=c.useMemo(()=>{const xe=[];if(!me)return xe;for(const it of N){if(it.mode!=="chat")continue;const X=Ya(it.dedupeKey);X&&!xe.includes(X)&&xe.push(X)}return xe},[me,N]),ye=dw(be),[Te,$]=c.useState(!1),he=c.useRef(0),se=c.useRef(ge),Ne=c.useRef(null),Ue=c.useRef(null),We=c.useRef(null),Ke=c.useRef(!1);c.useLayoutEffect(()=>{const xe=r?We.current?.parentElement:We.current?.closest("[data-workspace-row]");if(!xe||typeof ResizeObserver>"u")return;const it=new ResizeObserver(X=>{const le=X[X.length-1]?.contentRect,Xe=r?le?.height:le?.width;we.current=Xe?Math.round(Xe):null,Da(ie)});return it.observe(xe),we.current=(r?xe.clientHeight:xe.clientWidth)||null,ie(),()=>{it.disconnect(),Ku(ie)}},[ie,r]),c.useLayoutEffect(()=>{ie()},[ie,oe,K,Ce]),c.useEffect(()=>{if(!F||Ke.current){Ke.current=F;return}const xe=window.requestAnimationFrame(()=>{We.current?.focus({preventScroll:!0})});return Ke.current=!0,()=>window.cancelAnimationFrame(xe)},[F]);const Be=c.useRef(null),U=c.useRef(null),Me=c.useCallback(()=>{U.current=null;const xe=We.current,it=Ne.current;!xe||it===null||xe.style.setProperty(e.sizeVariable,`${it}px`)},[e.sizeVariable]);c.useEffect(()=>()=>{U.current!==null&&clearTimeout(U.current)},[]);const Ge=c.useCallback(xe=>{const it=Be.current,X=te?Ii(xe):fe(xe,it);return it===null?X:Math.min(X,Math.max(1,it))},[fe,te]),Ve=c.useCallback(xe=>{if(!F||K||!f)return;Ue.current=xe.pointerId,$(!0),he.current=r?xe.clientY:xe.clientX,se.current=ge,Ne.current=ge;const it=r?We.current?.parentElement?.clientHeight:(We.current?.closest("[data-workspace-row]")?.clientWidth??0)-Pe.current;Be.current=it&&it>0?it:null,document.documentElement.style.cursor=r?"row-resize":"col-resize",xe.preventDefault()},[f,K,F,r,ge]),dt=c.useCallback(()=>{const xe=Ge(Ne.current??ge);Ne.current=null,Be.current=null,U.current!==null&&(clearTimeout(U.current),U.current=null),document.documentElement.style.cursor="",te?P(xe):f&&re&&(r?p(f,re,xe):x(f,re,xe)),$(!1),Ue.current=null},[re,Ge,f,te,r,P,p,x,ge]);c.useEffect(()=>{if(!Te)return;const xe=le=>{if(Ue.current!==le.pointerId)return;const Xe=r?le.clientY:le.clientX,Ae=t==="left"?Xe-he.current:he.current-Xe,Je=!r&&a?-Ae:Ae,Fe=Ge(se.current+Je);Ne.current!==Fe&&(Ne.current=Fe,U.current===null&&(U.current=setTimeout(Me,tw)))},it=le=>{Ue.current===le.pointerId&&dt()},X=()=>{dt()};return window.addEventListener("pointermove",xe),window.addEventListener("pointerup",it),window.addEventListener("pointercancel",it),window.addEventListener("blur",X),()=>{window.removeEventListener("pointermove",xe),window.removeEventListener("pointerup",it),window.removeEventListener("pointercancel",it),window.removeEventListener("blur",X)}},[Me,Ge,dt,Te,a,r,t]),c.useEffect(()=>{Te||(Ne.current=null,document.documentElement.style.cursor="")},[Te]);const et=c.useCallback(()=>{f&&g(f,t)},[g,f,t]),ct=c.useCallback(()=>{f&&S(f,t)},[f,S,t]),pe=c.useCallback(xe=>{Lf(xe,F,et)},[et,F]),Ee=C?.mode==="file"||C?.mode==="chat"||C?.mode==="browser",qe=c.useMemo(()=>C?N.filter(xe=>xe.mode===C.mode):[],[C,N]),Ye=c.useMemo(()=>qe.map(xe=>{const it=aw(xe,ye,u),X=uw(it,sw),le=ow(xe.targetPath,l);return{id:xe.id,label:X,icon:Nc(xe,z),title:le?`${it}: ${le}`:it,closeLabel:o("contextPanel.tab.closeTabAria",{label:X}),preview:xe.preview}}),[qe,l,z,ye,o,u]),$e=C?.mode==="context"?n.jsx(Tn,{value:O,children:n.jsx(Tv,{})}):C?.mode==="git"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(Tn,{value:O,children:n.jsx(Jv,{isActive:F})})}):C?.mode==="pr"?n.jsx(nv,{}):C?.mode==="notes"?n.jsx(Tn,{value:O,children:n.jsx(fg,{visible:F})}):C?.mode==="plan"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(Tn,{value:O,children:n.jsx(ew,{targetPath:C.targetPath,savedProjectPlan:C.projectPlanId&&C.projectPlanRef?{projectRef:C.projectPlanRef,planId:C.projectPlanId}:null})})}):null,tt=C?.mode==="file",ht=de(xe=>xe.closeContextPanelTabs),vt=c.useCallback(xe=>{if(!f)return null;const{id:it,index:X,allIds:le,close:Xe}=xe,Ae=()=>ht(f,le.filter(Ze=>Ze!==it)),Je=le.slice(0,X),Fe=le.slice(X+1),gt=()=>ht(f,a?Fe:Je),bt=()=>ht(f,a?Je:Fe),Et=()=>ht(f,le),Ft=le.length>1,es=a?X===le.length-1:X===0,Re=a?X===0:X===le.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs(Dn,{onClick:Xe,children:[n.jsx(Z,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),n.jsx(qr,{}),n.jsxs(Dn,{onClick:Ae,disabled:!Ft,children:[n.jsx(Z,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),n.jsxs(Dn,{onClick:gt,disabled:es,children:[n.jsx(Z,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),n.jsxs(Dn,{onClick:bt,disabled:Re,children:[n.jsx(Z,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),n.jsx(qr,{}),n.jsxs(Dn,{onClick:Et,disabled:!Ft,children:[n.jsx(Z,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),C?n.jsxs(n.Fragment,{children:[n.jsx(qr,{}),n.jsx(nu,{mode:C.mode})]}):null]})},[C,ht,f,a,o]),Bt=c.useCallback((xe,it)=>{const X=N.find(Xe=>Xe.id===xe);if(!X)return null;const le=Qa({mode:X.mode,label:eo(X.mode,u),from:t},it);return{finish:()=>le.finish(f),cancel:le.cancel}},[f,u,N,t]),[kt,St]=c.useState(null),xt=c.useCallback(xe=>{if(!C||xe.button!==0||xe.pointerType==="touch"||xe.target instanceof Element&&xe.target.closest(hw))return;const it=C.mode,X=eo(it,u),le={x:xe.clientX,y:xe.clientY};let Xe=!1;const Ae=bt=>{const Et={x:bt.clientX,y:bt.clientY};!Xe&&(Math.hypot(Et.x-le.x,Et.y-le.y)<fw||(Xe=_f({mode:it,label:X,from:t}),!Xe))||$f(Et)},Je=()=>{window.removeEventListener("pointermove",Ae),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",gt),window.removeEventListener("blur",gt)},Fe=()=>{Je(),Xe&&zf(f)},gt=()=>{Je(),Xe&&Qi()};window.addEventListener("pointermove",Ae),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",gt),window.addEventListener("blur",gt)},[C,f,u,t]);c.useEffect(()=>{if(kt)return kt.addEventListener("pointerdown",xt),()=>kt.removeEventListener("pointerdown",xt)},[xt,kt]);const Mt=n.jsxs("header",{ref:St,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[Ee?n.jsx(sy,{items:Ye,activeId:C?.id??null,onSelect:xe=>{f&&y(f,xe)},onClose:xe=>{f&&b(f,xe)},onReorder:(xe,it)=>{f&&w(f,xe,it)},onDoubleClickTab:xe=>{f&&v(f,xe)},layoutMode:"scrollable",variant:"default",tabContextMenu:vt,onTabDragOut:Bt}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 group-has-[[data-context-panel-toolbar]]/panel-header:hidden",children:[C?.mode==="pr"&&d==="gitlab"?n.jsx(Z,{name:"gitlab",className:"h-3.5 w-3.5"}):C?Nc(C,z):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:C?.mode==="pr"&&d==="gitlab"?o("contextPanel.mode.mr"):C?eo(C.mode,u):null})]}),n.jsx("div",{ref:D,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[C?.mode==="browser"?n.jsx(Ct,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&T(f)},className:"h-7 w-7 p-0",title:o("contextPanel.browser.newTab"),"aria-label":o("contextPanel.browser.newTab"),children:n.jsx(Z,{name:"add",className:"h-3.5 w-3.5"})}):null,tt?["left","right"].map(xe=>{const it=xe===E;if(!it&&!ee)return null;const X=o(it?"contextRail.editorTree.toggle":"contextRail.editor.toggle");return n.jsx(Ct,{type:"button",variant:"ghost",size:"sm",onClick:it?A:R,className:"h-7 w-7 p-0",title:X,"aria-label":X,"aria-pressed":it?j:ne,children:n.jsx(Z,{name:xe==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})},xe)}):null,te?null:n.jsx(Ct,{type:"button",variant:"ghost",size:"sm",onClick:ct,className:"h-7 w-7 p-0",title:o(K?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":o(K?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:K?n.jsx(Z,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx(Z,{name:"fullscreen",className:"h-3.5 w-3.5"})}),n.jsx(Ct,{type:"button",variant:"ghost",size:"sm",onClick:et,className:"h-7 w-7 p-0",title:o("contextPanel.actions.closePanel"),"aria-label":o("contextPanel.actions.closePanel"),children:n.jsx(Z,{name:"close",className:"h-3.5 w-3.5"})})]})]}),jt=t==="right"&&H&&!M,$t=ae!==null?`${ae}px`:"100%",Wt=F?K?$t:`min(var(${e.sizeVariable}), 100%)`:jt?`${Gl}px`:"0px",Kt=t==="bottom"&&hr(h,m,"left"),rt=t==="bottom"&&(H&&!M||hr(h,m,"right")),ut=`${F}|${K}|${jt}|${F?oe:""}`,pt=c.useRef(ut),ue=c.useRef(M),lt=ue.current!==M;c.useLayoutEffect(()=>{ue.current=M},[M]),c.useLayoutEffect(()=>{pt.current!==ut&&(pt.current=ut,lt||Ru(s))},[ut,lt,s]);const ft=!Jr(F),mt={[e.sizeVariable]:F&&K?$t:`${ge}px`,...r?{height:Wt,maxHeight:"100%"}:{width:Wt,maxWidth:"100%"},transitionDuration:lt?"0ms":`${s}ms`,transitionTimingFunction:Ai},It=K?ae!==null?`calc(${ae}px - ${e.gutterSize})`:"100%":`calc(var(${e.sizeVariable}) - ${e.gutterSize})`;return n.jsxs("aside",{ref:We,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":F?"true":"false",tabIndex:-1,className:ve("flex min-h-0 flex-col overflow-clip bg-background",K?e.expanded:r?"relative w-full flex-shrink-0":"relative h-full flex-shrink-0",r?"transition-[height]":"transition-[width]","motion-reduce:transition-none"),onKeyDownCapture:pe,style:mt,children:[t==="right"?n.jsx("div",{ref:ny,className:ve("absolute inset-y-0 inset-e-0 z-0 flex",M&&"invisible")}):null,F&&!K&&n.jsx("div",{className:e.handle,onPointerDown:Ve,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsxs("div",{"data-zone-card":"",className:ve("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Kt?"ms-0":"ms-2"),t==="bottom"&&(rt?"me-0":"me-1.5"),r?null:"h-[calc(100%-0.5rem)]","oc-panel-edge overflow-hidden rounded-[10px] bg-background",r?"transition-[height,opacity]":"transition-[width,opacity]",!F&&"pointer-events-none select-none opacity-0"),style:{...r?{height:It,width:`calc(100% - ${(Kt?0:.5)+(rt?0:.375)}rem)`}:{width:It},transitionDuration:`${s}ms`,transitionTimingFunction:Ai},inert:ft||void 0,children:[Mt,n.jsx("div",{ref:Q,className:ve("relative min-h-0 flex-1 overflow-hidden",Te&&"pointer-events-none"),children:C&&pw(C.mode)?$e:null})]})]})},bw=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"},yw=async(t,e)=>{try{const s=await an("/api/dev-servers",{signal:t,directory:e});if(!s.ok)return{kind:"unavailable"};const r=await s.json();if(!r||typeof r!="object")return{kind:"unavailable"};const o=r.servers;return Array.isArray(o)?{kind:"ready",servers:o.filter(bw)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},xw=async t=>{try{const e=await an("/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}},Sw=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}},vw=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const o=Sw(r);o!==null&&!s.has(o)&&s.set(o,r)}return e?e.map(r=>{const o=s.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...s.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},Zi="__openchamberBrowserAnnotationActive",ww=`(() => {
|
|
3
|
-
try {
|
|
4
|
-
var host = document.querySelector('[data-openchamber-annotation]');
|
|
5
|
-
if (host && host.parentNode) host.parentNode.removeChild(host);
|
|
6
|
-
} catch (error) { /* page navigated away */ }
|
|
7
|
-
try {
|
|
8
|
-
var cursor = document.getElementById('openchamber-annotation-cursor');
|
|
9
|
-
if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
|
|
10
|
-
} catch (error) { /* page navigated away */ }
|
|
11
|
-
try { delete window['${Zi}']; } catch (error) { /* non-configurable */ }
|
|
12
|
-
})();`,kw=(t,e)=>{const s=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
|
|
13
|
-
var CONFIG = ${s};
|
|
14
|
-
var THEME = CONFIG.theme;
|
|
15
|
-
var LABELS = CONFIG.labels;
|
|
16
|
-
var OVERLAY_ATTR = 'data-openchamber-annotation';
|
|
17
|
-
var Z_OVERLAY = 2147483646;
|
|
18
|
-
var MAX_TEXT = 400;
|
|
19
|
-
var MIN_RECT = 3;
|
|
20
|
-
var EDITOR_GAP = 10;
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
|
|
24
|
-
if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
|
|
25
|
-
} catch (error) { /* nothing to clean */ }
|
|
26
|
-
|
|
27
|
-
window['${Zi}'] = true;
|
|
28
|
-
|
|
29
|
-
var counter = 0;
|
|
30
|
-
var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
|
|
31
|
-
|
|
32
|
-
var selected = null;
|
|
33
|
-
var regions = [];
|
|
34
|
-
var strokes = [];
|
|
35
|
-
var tool = 'select';
|
|
36
|
-
var settled = false;
|
|
37
|
-
|
|
38
|
-
// ---------------------------------------------------------------- geometry
|
|
39
|
-
|
|
40
|
-
var rectFrom = function (domRect) {
|
|
41
|
-
return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
|
|
42
|
-
};
|
|
43
|
-
var normalizeRect = function (ax, ay, bx, by) {
|
|
44
|
-
return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
|
|
45
|
-
};
|
|
46
|
-
var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
|
|
47
|
-
|
|
48
|
-
// ------------------------------------------------------------- description
|
|
49
|
-
|
|
50
|
-
var isOverlayNode = function (element) {
|
|
51
|
-
var node = element;
|
|
52
|
-
while (node) {
|
|
53
|
-
if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
|
|
54
|
-
node = node.parentNode || (node.host || null);
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
var elementFromPoint = function (x, y) {
|
|
60
|
-
var found = document.elementFromPoint(x, y);
|
|
61
|
-
if (!found || isOverlayNode(found)) return null;
|
|
62
|
-
return found;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
var selectorPart = function (element) {
|
|
66
|
-
var part = element.tagName.toLowerCase();
|
|
67
|
-
if (element.id) return part + '#' + element.id;
|
|
68
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
69
|
-
if (className) {
|
|
70
|
-
var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
|
|
71
|
-
if (first) part += '.' + first;
|
|
72
|
-
}
|
|
73
|
-
return part;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
var buildSelector = function (element) {
|
|
77
|
-
if (element.id) return '#' + element.id;
|
|
78
|
-
var parts = [];
|
|
79
|
-
var node = element;
|
|
80
|
-
var depth = 0;
|
|
81
|
-
while (node && node.nodeType === 1 && depth < 5) {
|
|
82
|
-
var part = selectorPart(node);
|
|
83
|
-
var parent = node.parentElement;
|
|
84
|
-
if (parent) {
|
|
85
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
86
|
-
return child.tagName === node.tagName;
|
|
87
|
-
});
|
|
88
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
89
|
-
}
|
|
90
|
-
parts.unshift(part);
|
|
91
|
-
if (node.id) break;
|
|
92
|
-
node = parent;
|
|
93
|
-
depth += 1;
|
|
94
|
-
}
|
|
95
|
-
return parts.join(' > ');
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
|
|
99
|
-
var STYLE_PROPS = [
|
|
100
|
-
'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
|
|
101
|
-
'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
|
|
102
|
-
'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
var describe = function (element) {
|
|
106
|
-
var computed = window.getComputedStyle(element);
|
|
107
|
-
var attributes = {};
|
|
108
|
-
for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
|
|
109
|
-
var name = INTERESTING_ATTRS[i];
|
|
110
|
-
var value = element.getAttribute(name);
|
|
111
|
-
if (value) attributes[name] = String(value).slice(0, 200);
|
|
112
|
-
}
|
|
113
|
-
var computedStyle = {};
|
|
114
|
-
for (var j = 0; j < STYLE_PROPS.length; j += 1) {
|
|
115
|
-
var prop = STYLE_PROPS[j];
|
|
116
|
-
computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
|
|
117
|
-
}
|
|
118
|
-
var ancestry = [];
|
|
119
|
-
var node = element.parentElement;
|
|
120
|
-
var depth = 0;
|
|
121
|
-
while (node && node.nodeType === 1 && depth < 4) {
|
|
122
|
-
var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
|
|
123
|
-
if (node.id) entry.id = node.id;
|
|
124
|
-
var cls = typeof node.className === 'string' ? node.className.trim() : '';
|
|
125
|
-
if (cls) entry.className = cls.slice(0, 200);
|
|
126
|
-
ancestry.unshift(entry);
|
|
127
|
-
node = node.parentElement;
|
|
128
|
-
depth += 1;
|
|
129
|
-
}
|
|
130
|
-
var box = element.getBoundingClientRect();
|
|
131
|
-
var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
|
|
132
|
-
return {
|
|
133
|
-
tag: element.tagName.toLowerCase(),
|
|
134
|
-
text: text.slice(0, MAX_TEXT),
|
|
135
|
-
selector: buildSelector(element),
|
|
136
|
-
path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
|
|
137
|
-
bounds: rectFrom(box),
|
|
138
|
-
center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
|
|
139
|
-
attributes: attributes,
|
|
140
|
-
computedStyle: computedStyle,
|
|
141
|
-
ancestry: ancestry
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
// ------------------------------------------------------------------ chrome
|
|
146
|
-
|
|
147
|
-
var host = document.createElement('div');
|
|
148
|
-
host.setAttribute(OVERLAY_ATTR, '');
|
|
149
|
-
// A manual popover: shown, it joins the browser's top layer without making
|
|
150
|
-
// the rest of the page inert. See "top layer" below.
|
|
151
|
-
host.setAttribute('popover', 'manual');
|
|
152
|
-
// Every declaration is !important: as a popover, and later inside a page
|
|
153
|
-
// dialog, the host matches page rules such as [popover]{background:...},
|
|
154
|
-
// which would otherwise paint a sheet over the whole page.
|
|
155
|
-
host.style.cssText = [
|
|
156
|
-
'all:initial', 'display:block', 'position:fixed', 'inset:0', 'width:auto', 'height:auto',
|
|
157
|
-
'max-width:none', 'max-height:none', 'margin:0', 'padding:0', 'border:0', 'background:transparent',
|
|
158
|
-
'overflow:visible', 'opacity:1', 'transform:none', 'z-index:' + Z_OVERLAY, 'pointer-events:none'
|
|
159
|
-
].join(' !important;') + ' !important';
|
|
160
|
-
var shadow = host.attachShadow({ mode: 'closed' });
|
|
161
|
-
|
|
162
|
-
var style = document.createElement('style');
|
|
163
|
-
style.textContent = [
|
|
164
|
-
':host{all:initial}',
|
|
165
|
-
'*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
|
|
166
|
-
'.layer{position:fixed;inset:0;pointer-events:none}',
|
|
167
|
-
'.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
|
|
168
|
-
'.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}',
|
|
169
|
-
'.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}',
|
|
170
|
-
'.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}',
|
|
171
|
-
'.tools button:hover{background:' + THEME.primaryFaint + '}',
|
|
172
|
-
'.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
|
|
173
|
-
'.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}',
|
|
174
|
-
'.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}',
|
|
175
|
-
'.editor textarea::placeholder{color:' + THEME.mutedText + '}',
|
|
176
|
-
'.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}',
|
|
177
|
-
'.editor button svg{width:16px;height:16px;display:block}',
|
|
178
|
-
'.editor button[disabled]{opacity:.5;cursor:default}'
|
|
179
|
-
].join('');
|
|
180
|
-
shadow.appendChild(style);
|
|
181
|
-
|
|
182
|
-
var cursorStyle = document.createElement('style');
|
|
183
|
-
cursorStyle.id = 'openchamber-annotation-cursor';
|
|
184
|
-
document.head.appendChild(cursorStyle);
|
|
185
|
-
var setCursor = function (value) {
|
|
186
|
-
cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
var svgNS = 'http://www.w3.org/2000/svg';
|
|
190
|
-
var svg = document.createElementNS(svgNS, 'svg');
|
|
191
|
-
svg.setAttribute('class', 'layer');
|
|
192
|
-
svg.style.overflow = 'visible';
|
|
193
|
-
shadow.appendChild(svg);
|
|
194
|
-
|
|
195
|
-
var hoverBox = document.createElement('div');
|
|
196
|
-
hoverBox.className = 'box';
|
|
197
|
-
var hoverLabel = document.createElement('div');
|
|
198
|
-
hoverLabel.className = 'label';
|
|
199
|
-
var marqueeBox = document.createElement('div');
|
|
200
|
-
marqueeBox.className = 'box';
|
|
201
|
-
shadow.append(hoverBox, hoverLabel, marqueeBox);
|
|
202
|
-
|
|
203
|
-
var positionBox = function (node, rect) {
|
|
204
|
-
node.style.display = 'block';
|
|
205
|
-
node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
|
|
206
|
-
node.style.width = rect.width + 'px';
|
|
207
|
-
node.style.height = rect.height + 'px';
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
var tools = document.createElement('div');
|
|
211
|
-
tools.className = 'tools';
|
|
212
|
-
shadow.appendChild(tools);
|
|
213
|
-
|
|
214
|
-
var toolButtons = {};
|
|
215
|
-
[['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
|
|
216
|
-
var button = document.createElement('button');
|
|
217
|
-
button.type = 'button';
|
|
218
|
-
button.textContent = entry[1];
|
|
219
|
-
button.addEventListener('click', function () { setTool(entry[0]); });
|
|
220
|
-
toolButtons[entry[0]] = button;
|
|
221
|
-
tools.appendChild(button);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
var editor = document.createElement('div');
|
|
225
|
-
editor.className = 'editor';
|
|
226
|
-
shadow.appendChild(editor);
|
|
227
|
-
|
|
228
|
-
var comment = document.createElement('textarea');
|
|
229
|
-
comment.rows = 1;
|
|
230
|
-
comment.placeholder = LABELS.commentPlaceholder;
|
|
231
|
-
var submit = document.createElement('button');
|
|
232
|
-
submit.type = 'button';
|
|
233
|
-
// Icon-only attach button (Remix attachment-2), matching the chat comment
|
|
234
|
-
// input; the localized label stays available to assistive tech.
|
|
235
|
-
submit.setAttribute('aria-label', LABELS.submit);
|
|
236
|
-
submit.title = LABELS.submit;
|
|
237
|
-
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>';
|
|
238
|
-
editor.append(comment, submit);
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Grows the box with its content.
|
|
242
|
-
*
|
|
243
|
-
* A hidden element reports scrollHeight 0, so measuring one collapses the
|
|
244
|
-
* field to nothing — which is what left a sliver of a click target and an
|
|
245
|
-
* invisible caret. Measuring only while visible, and never below the CSS
|
|
246
|
-
* min-height, keeps it usable.
|
|
247
|
-
*/
|
|
248
|
-
var resizeComment = function () {
|
|
249
|
-
if (editor.style.display === 'none') return;
|
|
250
|
-
comment.style.height = 'auto';
|
|
251
|
-
comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
|
|
252
|
-
};
|
|
253
|
-
comment.addEventListener('input', resizeComment);
|
|
254
|
-
|
|
255
|
-
// -------------------------------------------------------------- selection
|
|
256
|
-
|
|
257
|
-
var lastTargetRect = null;
|
|
258
|
-
|
|
259
|
-
/** Places the comment box under whatever was just marked, kept on screen. */
|
|
260
|
-
var positionEditor = function () {
|
|
261
|
-
if (!lastTargetRect) {
|
|
262
|
-
editor.style.display = 'none';
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
var wasHidden = editor.style.display === 'none';
|
|
266
|
-
editor.style.display = 'flex';
|
|
267
|
-
// Measured now that it is laid out, not while it was still hidden.
|
|
268
|
-
if (wasHidden) resizeComment();
|
|
269
|
-
var box = editor.getBoundingClientRect();
|
|
270
|
-
var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
|
|
271
|
-
var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
|
|
272
|
-
// Above the target when there is no room below, so the box is never left
|
|
273
|
-
// half off the bottom of the page.
|
|
274
|
-
if (top + box.height > window.innerHeight - 8) {
|
|
275
|
-
top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
|
|
276
|
-
}
|
|
277
|
-
left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
|
|
278
|
-
editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
/** Focus after layout: focusing a zero-height field puts the caret nowhere. */
|
|
282
|
-
var focusComment = function () {
|
|
283
|
-
requestAnimationFrame(function () {
|
|
284
|
-
try {
|
|
285
|
-
comment.focus({ preventScroll: true });
|
|
286
|
-
comment.setSelectionRange(comment.value.length, comment.value.length);
|
|
287
|
-
} catch (error) { /* field went away */ }
|
|
288
|
-
});
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
var hasTargets = function () {
|
|
292
|
-
return Boolean(selected) || regions.length > 0 || strokes.length > 0;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
var syncChrome = function () {
|
|
296
|
-
submit.disabled = !hasTargets();
|
|
297
|
-
if (!hasTargets()) {
|
|
298
|
-
lastTargetRect = null;
|
|
299
|
-
editor.style.display = 'none';
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
positionEditor();
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
var syncSelectionVisuals = function () {
|
|
306
|
-
if (!selected) return;
|
|
307
|
-
var rect = rectFrom(selected.element.getBoundingClientRect());
|
|
308
|
-
if (!usableRect(rect)) {
|
|
309
|
-
selected.outline.style.display = 'none';
|
|
310
|
-
selected.badge.style.display = 'none';
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
positionBox(selected.outline, rect);
|
|
314
|
-
selected.badge.style.display = 'block';
|
|
315
|
-
selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
316
|
-
lastTargetRect = rect;
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
var dropSelection = function () {
|
|
320
|
-
if (!selected) return;
|
|
321
|
-
selected.outline.remove();
|
|
322
|
-
selected.badge.remove();
|
|
323
|
-
selected = null;
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
var selectElement = function (element) {
|
|
327
|
-
var wasSelected = selected && selected.element === element;
|
|
328
|
-
dropSelection();
|
|
329
|
-
if (wasSelected) {
|
|
330
|
-
// Clicking the chosen element again clears it, so a misclick costs one
|
|
331
|
-
// click rather than starting over.
|
|
332
|
-
lastTargetRect = null;
|
|
333
|
-
syncChrome();
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
var outline = document.createElement('div');
|
|
337
|
-
outline.className = 'box';
|
|
338
|
-
var badge = document.createElement('div');
|
|
339
|
-
badge.className = 'label';
|
|
340
|
-
badge.textContent = selectorPart(element);
|
|
341
|
-
shadow.append(outline, badge);
|
|
342
|
-
selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
|
|
343
|
-
syncSelectionVisuals();
|
|
344
|
-
syncChrome();
|
|
345
|
-
focusComment();
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
var setTool = function (next) {
|
|
349
|
-
tool = next;
|
|
350
|
-
hoverBox.style.display = 'none';
|
|
351
|
-
hoverLabel.style.display = 'none';
|
|
352
|
-
marqueeBox.style.display = 'none';
|
|
353
|
-
setCursor(next === 'select' ? '' : 'crosshair');
|
|
354
|
-
for (var key in toolButtons) {
|
|
355
|
-
if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
|
|
356
|
-
toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
// ------------------------------------------------------------- interaction
|
|
362
|
-
|
|
363
|
-
var drag = null;
|
|
364
|
-
|
|
365
|
-
var onPointerMove = function (event) {
|
|
366
|
-
if (drag) {
|
|
367
|
-
if (drag.kind === 'marquee') {
|
|
368
|
-
drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
|
|
369
|
-
positionBox(marqueeBox, drag.rect);
|
|
370
|
-
} else if (drag.kind === 'draw') {
|
|
371
|
-
drag.points.push({ x: event.clientX, y: event.clientY });
|
|
372
|
-
drag.path.setAttribute('d', drag.points.map(function (point, index) {
|
|
373
|
-
return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
|
|
374
|
-
}).join(' '));
|
|
375
|
-
}
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (tool !== 'select') return;
|
|
380
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
381
|
-
if (!element) {
|
|
382
|
-
hoverBox.style.display = 'none';
|
|
383
|
-
hoverLabel.style.display = 'none';
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
var rect = rectFrom(element.getBoundingClientRect());
|
|
387
|
-
positionBox(hoverBox, rect);
|
|
388
|
-
hoverLabel.textContent = selectorPart(element);
|
|
389
|
-
hoverLabel.style.display = 'block';
|
|
390
|
-
hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
var onPointerDown = function (event) {
|
|
394
|
-
if (event.button !== 0) return;
|
|
395
|
-
if (isOverlayNode(event.target)) return;
|
|
396
|
-
event.preventDefault();
|
|
397
|
-
event.stopPropagation();
|
|
398
|
-
|
|
399
|
-
if (tool === 'select') {
|
|
400
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
401
|
-
if (element) selectElement(element);
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
if (tool === 'marquee') {
|
|
406
|
-
drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
var path = document.createElementNS(svgNS, 'path');
|
|
411
|
-
path.setAttribute('fill', 'none');
|
|
412
|
-
path.setAttribute('stroke', THEME.primary);
|
|
413
|
-
path.setAttribute('stroke-width', '2.5');
|
|
414
|
-
path.setAttribute('stroke-linecap', 'round');
|
|
415
|
-
path.setAttribute('stroke-linejoin', 'round');
|
|
416
|
-
svg.appendChild(path);
|
|
417
|
-
drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
var onPointerUp = function () {
|
|
421
|
-
if (!drag) return;
|
|
422
|
-
var finished = drag;
|
|
423
|
-
drag = null;
|
|
424
|
-
|
|
425
|
-
if (finished.kind === 'marquee') {
|
|
426
|
-
marqueeBox.style.display = 'none';
|
|
427
|
-
var rect = finished.rect;
|
|
428
|
-
if (!rect || !usableRect(rect)) return;
|
|
429
|
-
// A region marks an area, not the elements inside it: expanding it into a
|
|
430
|
-
// selection made the result depend on the page's markup rather than on
|
|
431
|
-
// what was drawn.
|
|
432
|
-
regions.push({ id: nextId('region'), rect: rect });
|
|
433
|
-
var outline = document.createElementNS(svgNS, 'rect');
|
|
434
|
-
outline.setAttribute('x', String(rect.x));
|
|
435
|
-
outline.setAttribute('y', String(rect.y));
|
|
436
|
-
outline.setAttribute('width', String(rect.width));
|
|
437
|
-
outline.setAttribute('height', String(rect.height));
|
|
438
|
-
outline.style.fill = THEME.primarySoft;
|
|
439
|
-
outline.setAttribute('stroke', THEME.primary);
|
|
440
|
-
outline.setAttribute('stroke-width', '1.5');
|
|
441
|
-
outline.setAttribute('rx', '2');
|
|
442
|
-
svg.appendChild(outline);
|
|
443
|
-
lastTargetRect = rect;
|
|
444
|
-
syncChrome();
|
|
445
|
-
focusComment();
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
var points = finished.points;
|
|
450
|
-
if (points.length < 2) {
|
|
451
|
-
if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
|
|
455
|
-
for (var p = 1; p < points.length; p += 1) {
|
|
456
|
-
minX = Math.min(minX, points[p].x);
|
|
457
|
-
minY = Math.min(minY, points[p].y);
|
|
458
|
-
maxX = Math.max(maxX, points[p].x);
|
|
459
|
-
maxY = Math.max(maxY, points[p].y);
|
|
460
|
-
}
|
|
461
|
-
var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
462
|
-
strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
|
|
463
|
-
lastTargetRect = bounds;
|
|
464
|
-
syncChrome();
|
|
465
|
-
focusComment();
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Swallows the page's own mouse handling while annotating.
|
|
470
|
-
*
|
|
471
|
-
* Blocking pointerdown is not enough: a click still follows it, so marking a
|
|
472
|
-
* button pressed that button and marking a link navigated away from the page
|
|
473
|
-
* being annotated. These are the events that reach page code, so these are
|
|
474
|
-
* the ones that have to stop.
|
|
475
|
-
*/
|
|
476
|
-
var blockPageInteraction = function (event) {
|
|
477
|
-
if (isOverlayNode(event.target)) return;
|
|
478
|
-
event.preventDefault();
|
|
479
|
-
event.stopPropagation();
|
|
480
|
-
};
|
|
481
|
-
var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
|
|
482
|
-
|
|
483
|
-
var onScrollOrResize = function () {
|
|
484
|
-
syncSelectionVisuals();
|
|
485
|
-
positionEditor();
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
var onKeyDown = function (event) {
|
|
489
|
-
if (event.isComposing || event.keyCode === 229) return;
|
|
490
|
-
if (event.key === 'Escape') {
|
|
491
|
-
event.preventDefault();
|
|
492
|
-
event.stopImmediatePropagation();
|
|
493
|
-
finish(null);
|
|
494
|
-
}
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
var onCommentKeyDown = function (event) {
|
|
498
|
-
// Do not let the annotated page treat typed letters as its own shortcuts.
|
|
499
|
-
event.stopPropagation();
|
|
500
|
-
// WebKit can report the composition-confirming Enter as keyCode 229.
|
|
501
|
-
if (event.isComposing || event.keyCode === 229) return;
|
|
502
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
|
503
|
-
event.preventDefault();
|
|
504
|
-
attach();
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
document.addEventListener('pointermove', onPointerMove, true);
|
|
509
|
-
document.addEventListener('pointerdown', onPointerDown, true);
|
|
510
|
-
document.addEventListener('pointerup', onPointerUp, true);
|
|
511
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
512
|
-
window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
|
|
513
|
-
});
|
|
514
|
-
window.addEventListener('scroll', onScrollOrResize, true);
|
|
515
|
-
window.addEventListener('resize', onScrollOrResize, true);
|
|
516
|
-
window.addEventListener('keydown', onKeyDown, true);
|
|
517
|
-
comment.addEventListener('keydown', onCommentKeyDown);
|
|
518
|
-
|
|
519
|
-
// --------------------------------------------------------------- top layer
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Keeps the chrome above a modal dialog or popover the page opens.
|
|
523
|
-
*
|
|
524
|
-
* Those render in the browser's top layer, which no z-index reaches, and a
|
|
525
|
-
* modal dialog also makes everything outside itself inert: the outlines drew
|
|
526
|
-
* under the dialog and the comment box took no typing. So the host is shown
|
|
527
|
-
* as a popover, which puts it in the top layer too, and it lives inside the
|
|
528
|
-
* page's topmost modal dialog, where that inertness does not reach. Showing it
|
|
529
|
-
* again whenever the page puts something new on top keeps it last, so above.
|
|
530
|
-
*
|
|
531
|
-
* Opening our own modal dialog instead would make the page's dialog inert,
|
|
532
|
-
* which is the thing being annotated.
|
|
533
|
-
*/
|
|
534
|
-
var modals = [];
|
|
535
|
-
|
|
536
|
-
var isModalDialog = function (element) {
|
|
537
|
-
if (element.tagName !== 'DIALOG') return false;
|
|
538
|
-
try { return element.matches(':modal'); } catch (error) { return false; }
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
var trackDialog = function (dialog) {
|
|
542
|
-
var index = modals.indexOf(dialog);
|
|
543
|
-
if (index !== -1) modals.splice(index, 1);
|
|
544
|
-
// Opened last, so on top. Dialogs already open when annotation starts are
|
|
545
|
-
// taken in document order, which is the usual order of nesting.
|
|
546
|
-
if (isModalDialog(dialog)) modals.push(dialog);
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
var topModal = function () {
|
|
550
|
-
for (var i = modals.length - 1; i >= 0; i -= 1) {
|
|
551
|
-
if (modals[i].isConnected && isModalDialog(modals[i])) return modals[i];
|
|
552
|
-
}
|
|
553
|
-
return null;
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
var placeHost = function () {
|
|
557
|
-
var parent = topModal() || document.body || document.documentElement;
|
|
558
|
-
var hadFocus = shadow.activeElement === comment;
|
|
559
|
-
if (host.parentNode !== parent) parent.appendChild(host);
|
|
560
|
-
try {
|
|
561
|
-
if (host.matches(':popover-open')) host.hidePopover();
|
|
562
|
-
host.showPopover();
|
|
563
|
-
} catch (error) { /* no popover support: the z-index still covers ordinary pages */ }
|
|
564
|
-
// Moving the host blurs the comment box mid-sentence.
|
|
565
|
-
if (hadFocus) comment.focus({ preventScroll: true });
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
var topLayerObserver = new window.MutationObserver(function (records) {
|
|
569
|
-
var changed = false;
|
|
570
|
-
for (var i = 0; i < records.length; i += 1) {
|
|
571
|
-
if (records[i].type === 'attributes' && records[i].target.tagName === 'DIALOG') {
|
|
572
|
-
trackDialog(records[i].target);
|
|
573
|
-
changed = true;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
if (!host.isConnected) {
|
|
577
|
-
// Removed on purpose, not along with a dialog: the session was cancelled
|
|
578
|
-
// from the app or replaced by a new one. End it, so its listeners stop
|
|
579
|
-
// swallowing the page's clicks and nothing brings the host back.
|
|
580
|
-
for (var j = 0; j < records.length; j += 1) {
|
|
581
|
-
if (Array.prototype.indexOf.call(records[j].removedNodes, host) !== -1) {
|
|
582
|
-
finish(null);
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
changed = true;
|
|
587
|
-
}
|
|
588
|
-
if (!changed) return;
|
|
589
|
-
placeHost();
|
|
590
|
-
// Our own move is not a page change.
|
|
591
|
-
topLayerObserver.takeRecords();
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
var onToggle = function (event) {
|
|
595
|
-
if (event.target === host || event.newState !== 'open') return;
|
|
596
|
-
placeHost();
|
|
597
|
-
topLayerObserver.takeRecords();
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
// With the host inside the page's dialog, clicks on our chrome would reach
|
|
601
|
-
// the dialog's own handlers, and a click outside its box commonly closes it.
|
|
602
|
-
// Typing in the comment box would reach its key handlers the same way.
|
|
603
|
-
var CHROME_EVENTS = BLOCKED_EVENTS.concat([
|
|
604
|
-
'pointerdown', 'pointerup', 'keydown', 'keyup', 'keypress', 'beforeinput', 'input'
|
|
605
|
-
]);
|
|
606
|
-
var keepChromeEvent = function (event) { event.stopPropagation(); };
|
|
607
|
-
CHROME_EVENTS.forEach(function (name) {
|
|
608
|
-
host.addEventListener(name, keepChromeEvent);
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
var startTopLayer = function () {
|
|
612
|
-
Array.prototype.forEach.call(document.querySelectorAll('dialog'), trackDialog);
|
|
613
|
-
placeHost();
|
|
614
|
-
topLayerObserver.observe(document.documentElement, {
|
|
615
|
-
subtree: true,
|
|
616
|
-
childList: true,
|
|
617
|
-
attributes: true,
|
|
618
|
-
attributeFilter: ['open']
|
|
619
|
-
});
|
|
620
|
-
document.addEventListener('toggle', onToggle, true);
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
// ------------------------------------------------------------------ finish
|
|
624
|
-
|
|
625
|
-
var teardown = function () {
|
|
626
|
-
document.removeEventListener('pointermove', onPointerMove, true);
|
|
627
|
-
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
628
|
-
document.removeEventListener('pointerup', onPointerUp, true);
|
|
629
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
630
|
-
window.removeEventListener(name, blockPageInteraction, true);
|
|
631
|
-
});
|
|
632
|
-
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
633
|
-
window.removeEventListener('resize', onScrollOrResize, true);
|
|
634
|
-
window.removeEventListener('keydown', onKeyDown, true);
|
|
635
|
-
comment.removeEventListener('keydown', onCommentKeyDown);
|
|
636
|
-
topLayerObserver.disconnect();
|
|
637
|
-
document.removeEventListener('toggle', onToggle, true);
|
|
638
|
-
setCursor('');
|
|
639
|
-
if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
|
|
640
|
-
if (host.parentNode) host.parentNode.removeChild(host);
|
|
641
|
-
try { delete window['${Zi}']; } catch (error) { /* non-configurable */ }
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
var finish = function (payload) {
|
|
645
|
-
if (settled) return;
|
|
646
|
-
settled = true;
|
|
647
|
-
teardown();
|
|
648
|
-
// Removing the chrome is not enough: the host screenshots this page right
|
|
649
|
-
// after we resolve, and the compositor can still hold a frame containing
|
|
650
|
-
// our outlines. Yield two frames so the page has actually repainted.
|
|
651
|
-
requestAnimationFrame(function () {
|
|
652
|
-
requestAnimationFrame(function () { resolve(payload); });
|
|
653
|
-
});
|
|
654
|
-
};
|
|
655
|
-
|
|
656
|
-
var attach = function () {
|
|
657
|
-
if (!hasTargets()) return;
|
|
658
|
-
finish({
|
|
659
|
-
id: 'annotation-' + Date.now(),
|
|
660
|
-
pageUrl: String(location.href),
|
|
661
|
-
pageTitle: String(document.title || ''),
|
|
662
|
-
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
663
|
-
devicePixelRatio: window.devicePixelRatio || 1,
|
|
664
|
-
comment: comment.value,
|
|
665
|
-
// Zero or one element, never more. Kept as a list so elements, regions
|
|
666
|
-
// and strokes stay one uniform shape for everything downstream.
|
|
667
|
-
elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
|
|
668
|
-
regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
|
|
669
|
-
strokes: strokes.map(function (entry) {
|
|
670
|
-
return { id: entry.id, points: entry.points, bounds: entry.bounds };
|
|
671
|
-
})
|
|
672
|
-
});
|
|
673
|
-
};
|
|
674
|
-
|
|
675
|
-
submit.addEventListener('click', attach);
|
|
676
|
-
|
|
677
|
-
startTopLayer();
|
|
678
|
-
setTool('select');
|
|
679
|
-
syncChrome();
|
|
680
|
-
});`},jw={kind:"idle"},Ys=t=>typeof t=="object"&&t!==null,tn=t=>typeof t=="number"&&Number.isFinite(t),Rc=t=>Ys(t)&&Object.values(t).every(e=>typeof e=="string"),Za=t=>Ys(t)&&tn(t.x)&&tn(t.y)&&tn(t.width)&&tn(t.height),Yf=t=>Ys(t)&&tn(t.x)&&tn(t.y),Cw=t=>Ys(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"),Pw=t=>Ys(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&Za(t.bounds)&&Yf(t.center)&&Rc(t.attributes)&&Rc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(Cw),Ew=t=>Ys(t)&&typeof t.id=="string"&&Pw(t.element),Nw=t=>Ys(t)&&typeof t.id=="string"&&Za(t.rect),Iw=t=>Ys(t)&&typeof t.id=="string"&&Za(t.bounds)&&Array.isArray(t.points)&&t.points.every(Yf),Rw=t=>Ys(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&Ys(t.viewport)&&tn(t.viewport.width)&&tn(t.viewport.height)&&tn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(Ew)&&Array.isArray(t.regions)&&t.regions.every(Nw)&&Array.isArray(t.strokes)&&t.strokes.every(Iw),Dw=1600,Tw=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}),Mw=async({base64:t,mime:e,captureWidth:s,captureHeight:r,cssWidth:o,cssHeight:i,payload:a,accentColor:l,accentFill:d})=>{if(!t)return null;try{const u=await Tw(`data:${e};base64,${t}`),f=Math.max(1,u.naturalWidth||s),h=Math.max(1,u.naturalHeight||r),m=f/Math.max(1,o||f),g=h/Math.max(1,i||h),b=Math.min(1,Dw/f),v=document.createElement("canvas");v.width=Math.max(1,Math.floor(f*b)),v.height=Math.max(1,Math.floor(h*b));const S=v.getContext("2d");if(!S)return null;S.scale(b,b),S.drawImage(u,0,0,f,h);const x=j=>({x:j.x*m,y:j.y*g,width:j.width*m,height:j.height*g}),p=Math.max(2,2.5*m/Math.max(b,.2));S.strokeStyle=l,S.fillStyle=d;const y=j=>{const k=x(j);S.lineWidth=p,S.fillRect(k.x,k.y,k.width,k.height),S.strokeRect(k.x,k.y,k.width,k.height)};for(const j of a.elements)y(j.element.bounds);for(const j of a.regions)y(j.rect);for(const j of a.strokes)j.points.length<2||(S.beginPath(),j.points.forEach((k,P)=>{const A=k.x*m,B=k.y*g;P===0?S.moveTo(A,B):S.lineTo(A,B)}),S.lineCap="round",S.lineJoin="round",S.lineWidth=p*1.4,S.stroke());const w=await new Promise(j=>v.toBlob(j,"image/jpeg",.85));return w?new File([w],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},Aw="({ width: window.innerWidth, height: window.innerHeight })",Ow=async t=>{try{const e=await t.executeJavaScript(Aw,!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}},to=async t=>{try{await t.executeJavaScript(ww,!1)}catch{}},Bw=async({host:t,theme:e,labels:s})=>{const r=kw(e,s),o=await t.executeJavaScript(r,!0);if(o==null)return null;if(!Rw(o))return await to(t),null;const i=o;try{const a=await Ow(t)??i.viewport,l=await t.capturePage();if(!l||!l.base64)return{payload:i,screenshot:null};const d=await Mw({base64:l.base64,mime:l.mime||"image/jpeg",captureWidth:l.width,captureHeight:l.height,cssWidth:a.width,cssHeight:a.height,payload:i,accentColor:e.primary,accentFill:e.primarySoft});return{payload:i,screenshot:d}}catch{return{payload:i,screenshot:null}}},Ms={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)"},Fw=()=>{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()}},Lw=t=>{const e=Fw();if(!e)return{...Ms,colorScheme:t};try{const s=(l,d)=>e.read(`var(${l})`)||d,r=(l,d,u)=>e.read(`color-mix(in srgb, var(${l}) ${d}%, transparent)`)||u,o=e.readVariable("--oc-glass-tooltip-opacity")||"62%",i=e.readVariable("--oc-glass-blur")||"26px",a=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${o}, transparent)`)||Ms.glassSurface,glassFilter:`blur(${i}) saturate(${a})`,primary:s("--primary",Ms.primary),primarySoft:r("--primary",16,Ms.primarySoft),primaryFaint:r("--primary",10,Ms.primaryFaint),primaryContrast:s("--primary-foreground",Ms.primaryContrast),surface:s("--surface-background",Ms.surface),surfaceElevated:s("--surface-elevated",Ms.surfaceElevated),border:s("--border",Ms.border),text:s("--foreground",Ms.text),mutedText:s("--muted-foreground",Ms.mutedText)}}catch{return{...Ms,colorScheme:t}}finally{e.dispose()}},_w=t=>({sessionId:t.sessionId,directory:t.directory?vs(t.directory):null}),$w=2e3,zw=50,xi=400,Is=new Map,nn=new Map;let Ji=null,ea=null;const Ja=new Map;let Js=null,br=null;const so=async t=>{try{const e=await an("/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}},Ww=async(t,e)=>{try{const s=await an("/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)}},Xf=async(t,e=$w)=>{const s=Date.now()+e;for(;!Is.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,zw));return Is.get(t)??null},Dc=t=>Is.has(t)||nn.has(t),xo=t=>Is.get(t)??nn.get(t)??null,ta=()=>[...Is.values(),...[...nn.values()].filter(t=>!Is.has(t.tabId))],Qf=t=>{const e=ea?xo(ea):null,s=e?.directory===Ji?e:null;if(!t.sessionId){if(s)return s.tabId;const i=ta().filter(d=>d.directory===Ji),a=i.filter(d=>Is.has(d.tabId)),l=a.length>0?a:i;return l.length>0?l[l.length-1].tabId:null}if(s?.ownerSessionId===t.sessionId)return s.tabId;const r=Ja.get(t.sessionId);if(r&&xo(r)?.ownerSessionId===t.sessionId)return r;const o=ta().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:s&&s.ownerSessionId===null&&(!t.directory||s.directory===t.directory)?s.tabId:null},Kw=(t,e)=>{t.sessionId&&xo(e)?.ownerSessionId===t.sessionId&&Ja.set(t.sessionId,e)},Zf=async t=>{const e=Is.get(t);if(e)return e;const s=nn.get(t);return s?(s.wake(),Xf(t)):null},Jf=t=>{const e=Qf(t);return ta().filter(s=>!t.sessionId||!t.directory||s.ownerSessionId===t.sessionId||s.directory===t.directory).map(s=>{let r={title:"",url:""};try{r=s.describe()}catch{}const o=s.ownerSessionId===null?"user":s.ownerSessionId===t.sessionId?"you":"another session";return{id:s.tabId,title:r.title,url:r.url,owner:o,active:s.tabId===e}})},eh=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,Hw=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use this session's own tab.`,Vw=t=>{const e=Jf(t);return"This session has no browser tab of its own, and the user is not looking at a tab of theirs in this session's project. Nothing was changed. Open the page with browser.open, or pass tabId to work in a tab the user points you to."+(e.length>0?` Open tabs:
|
|
681
|
-
${e.map(r=>`- ${r.id}: ${r.title||r.url||"blank"} (opened by ${r.owner})`).join(`
|
|
682
|
-
`)}`:"")},Hs=(t,e)=>Ww(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:oy()})}:e),Gw=async t=>{const e=t.action==="browser.open",s=_w(t.context),{tabId:r,...o}=t.parameters,i=r===void 0?null:String(r);if(i!==null){if(!Dc(i)){if(Is.size===0&&nn.size===0&&!Js)return;if(await new Promise(d=>setTimeout(d,xi)),Dc(i)){await Tc(t,s,i,o);return}if(!await so(t.requestId))return;await Hs(t,{ok:!1,error:Hw(i)});return}await Tc(t,s,i,o);return}const a=Qf(s);if(!a&&!(e&&Js)){if(!s.sessionId||(await new Promise(d=>setTimeout(d,xi)),!await so(t.requestId)))return;await Hs(t,{ok:!1,error:Vw(s)});return}if(!(e&&Js!==null)&&s.sessionId&&xo(a)?.ownerSessionId!==s.sessionId&&await new Promise(d=>setTimeout(d,xi)),!!await so(t.requestId))try{const d=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!d){await Hs(t,{ok:!1,error:"url is required"});return}const u=e&&Js?Js(d,t.context):null;if(e&&!u&&!a){await Hs(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(u){s.sessionId&&Ja.set(s.sessionId,u);const h=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!h||h==="fill"){await Hs(t,{ok:!0,data:{url:d,opened:!0,tabId:u}});return}const m=await Xf(u);if(!m){await Hs(t,{ok:!0,data:{url:d,opened:!0,tabId:u,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 g=await m.run("browser.resize",{viewport:h}),b=g&&typeof g=="object"?g.viewport??null:null;await Hs(t,{ok:!0,data:{url:d,opened:!0,tabId:u,viewportApplied:!0,viewport:b}});return}const f=await Zf(a);await Hs(t,f?await th(f,s,t.action,o):{ok:!1,error:eh(a)})}catch(d){await Hs(t,{ok:!1,error:d instanceof Error?d.message:String(d)})}},Tc=async(t,e,s,r)=>{if(!await so(t.requestId))return;Kw(e,s);const o=await Zf(s);await Hs(t,o?await th(o,e,t.action,r):{ok:!1,error:eh(s)})},th=async(t,e,s,r)=>{try{const o=await t.run(s,r);return s==="browser.snapshot"&&Object(o)===o?{ok:!0,data:{...Object(o),tabs:Jf(e)}}:{ok:!0,data:o}}catch(o){return{ok:!1,error:o instanceof Error?o.message:String(o)}}},el=()=>{br||(br=wn(t=>{t.type==="browser-control-request"&&Gw({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},tl=()=>{Is.size>0||nn.size>0||Js||!br||(br(),br=null)},Uw=t=>(Is.set(t.tabId,t),el(),()=>{Is.get(t.tabId)===t&&Is.delete(t.tabId),tl()}),qw=t=>(nn.set(t.tabId,t),el(),()=>{nn.get(t.tabId)===t&&nn.delete(t.tabId),tl()}),Yw=(t,e)=>{Ji=t,e&&(ea=e)},Xw=t=>(Js=t,el(),()=>{Js===t&&(Js=null),tl()}),Qw=50,Zw=6,Jw=2048,e0=200,sh=t=>{const e=Wn(String(t??"").trim());if(!e||e.length>Jw)return"";try{const s=new URL(e);return s.protocol!=="http:"&&s.protocol!=="https:"?"":s.toString()}catch{return""}},t0=(t,e)=>{const s=sh(e.url);if(!s)return t;const r=t.find(a=>a.url===s),o=String(e.title??"").trim().slice(0,e0)||r?.title||"";return[{url:s,title:o,lastVisitedAt:e.at},...t.filter(a=>a.url!==s)].slice(0,Qw)},s0=(t,e)=>{const s=sh(e);return t.filter(r=>r.url!==s)},n0=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),nh=(t,e,s=Zw)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((a,l)=>l.lastVisitedAt-a.lastVisitedAt);if(!r)return o.slice(0,s);const i=r.replace(/^https?:\/\//,"");return o.filter(a=>{const l=n0(a);return a.url===r||l===i?!1:l.includes(i)}).slice(0,s)},Mc=20,no=t=>{const e=ot((t||"").trim());return e?JSON.stringify([Yt(),e]):""},r0=t=>{const e=Object.keys(t);if(e.length<=Mc)return t;const s=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,Mc);return Object.fromEntries(s.map(([r])=>[r,t[r]??[]]))},Hn=Nr()(j1(t=>({byProject:{},recordVisit:(e,s)=>{const r=no(e);r&&t(o=>{const i=o.byProject[r]??[],a=t0(i,{...s,at:Date.now()});return a===i?o:{byProject:r0({...o.byProject,[r]:a})}})},forget:(e,s)=>{const r=no(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:s0(i,s)}}:o})},clear:e=>{const s=no(e);s&&t(r=>{if(!(s in r.byProject))return r;const o={...r.byProject};return delete o[s],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Jp(),partialize:t=>({byProject:t.byProject})})),o0=[],rh=t=>e=>{const s=no(t);return(s?e.byProject[s]:void 0)??o0},sl=t=>{const e=He.c(10),{t:s}=wt();let r;e[0]!==t?(r=Ls(t),e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o?(i=u=>o?u.journey?.get(o):void 0,e[2]=o,e[3]=i):i=e[3];const a=_s(i);if(o===null)return null;if(!a){let u;return e[4]!==s?(u=s("contextPanel.browser.spaceAddress"),e[4]=s,e[5]=u):u=e[5],u}let l;e[6]!==a.machine||e[7]!==a.placeId||e[8]!==s?(l=a.machine??(a.placeId==="docker"?s("spaces.create.place.localDocker"):a.placeId),e[6]=a.machine,e[7]=a.placeId,e[8]=s,e[9]=l):l=e[9];const d=l;return`${a.name} · ${d}`},Ac=6e3,i0=120,a0=80,l0=100,c0=`
|
|
683
|
-
var MAX_ELEMENTS = ${i0};
|
|
684
|
-
var MAX_LABEL_CHARS = ${a0};
|
|
685
|
-
var visible = function (element) {
|
|
686
|
-
var rect = element.getBoundingClientRect();
|
|
687
|
-
if (rect.width < 1 || rect.height < 1) return false;
|
|
688
|
-
var style = window.getComputedStyle(element);
|
|
689
|
-
return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
|
|
690
|
-
};
|
|
691
|
-
var label = function (element) {
|
|
692
|
-
var aria = element.getAttribute('aria-label');
|
|
693
|
-
if (aria) return aria.trim();
|
|
694
|
-
var value = element.getAttribute('value');
|
|
695
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
696
|
-
if (text) return text.slice(0, MAX_LABEL_CHARS);
|
|
697
|
-
if (value) return String(value).slice(0, MAX_LABEL_CHARS);
|
|
698
|
-
var placeholder = element.getAttribute('placeholder');
|
|
699
|
-
return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
|
|
700
|
-
};
|
|
701
|
-
var isUnique = function (selector) {
|
|
702
|
-
try {
|
|
703
|
-
return document.querySelectorAll(selector).length === 1;
|
|
704
|
-
} catch (error) {
|
|
705
|
-
return false;
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* Names an element by what it is, falling back to where it sits.
|
|
711
|
-
*
|
|
712
|
-
* A positional chain like 'main > section:nth-of-type(3) > div > a' survives
|
|
713
|
-
* only until the markup shifts, and says nothing about what it points at.
|
|
714
|
-
* Anything the page states about identity — an id, a test id, an accessible
|
|
715
|
-
* name — outlives edits and reads as the thing it selects. The chain remains
|
|
716
|
-
* as the last resort, because something always has to work.
|
|
717
|
-
*/
|
|
718
|
-
var cssPath = function (element) {
|
|
719
|
-
var tag = element.tagName.toLowerCase();
|
|
720
|
-
|
|
721
|
-
if (element.id) {
|
|
722
|
-
var byId = '#' + CSS.escape(element.id);
|
|
723
|
-
if (isUnique(byId)) return byId;
|
|
724
|
-
}
|
|
725
|
-
var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
|
|
726
|
-
for (var a = 0; a < stableAttrs.length; a += 1) {
|
|
727
|
-
var value = element.getAttribute(stableAttrs[a]);
|
|
728
|
-
if (!value) continue;
|
|
729
|
-
var raw = String(value);
|
|
730
|
-
// A value containing a quote would need escaping for no real gain: such
|
|
731
|
-
// attributes are rare, and the positional chain still covers them.
|
|
732
|
-
if (raw.indexOf('"') !== -1) continue;
|
|
733
|
-
var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
|
|
734
|
-
if (isUnique(byAttr)) return byAttr;
|
|
735
|
-
}
|
|
736
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
737
|
-
if (className) {
|
|
738
|
-
var classes = className.split(/\\s+/).filter(Boolean);
|
|
739
|
-
for (var c = 0; c < classes.length; c += 1) {
|
|
740
|
-
var byClass = tag + '.' + CSS.escape(classes[c]);
|
|
741
|
-
if (isUnique(byClass)) return byClass;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
var parts = [];
|
|
746
|
-
var node = element;
|
|
747
|
-
var depth = 0;
|
|
748
|
-
while (node && node.nodeType === 1 && depth < 6) {
|
|
749
|
-
var part = node.tagName.toLowerCase();
|
|
750
|
-
var parent = node.parentElement;
|
|
751
|
-
if (!parent) { parts.unshift(part); break; }
|
|
752
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
753
|
-
return child.tagName === node.tagName;
|
|
754
|
-
});
|
|
755
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
756
|
-
parts.unshift(part);
|
|
757
|
-
if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
|
|
758
|
-
node = parent;
|
|
759
|
-
depth += 1;
|
|
760
|
-
}
|
|
761
|
-
return parts.join(' > ');
|
|
762
|
-
};
|
|
763
|
-
|
|
764
|
-
/** What a screen reader would announce, or '' when there is nothing to say. */
|
|
765
|
-
var accessibleName = function (element) {
|
|
766
|
-
var aria = element.getAttribute('aria-label');
|
|
767
|
-
if (aria && aria.trim()) return aria.trim();
|
|
768
|
-
var labelled = element.getAttribute('aria-labelledby');
|
|
769
|
-
if (labelled) {
|
|
770
|
-
var source = document.getElementById(labelled.split(/\\s+/)[0]);
|
|
771
|
-
if (source && (source.innerText || '').trim()) return source.innerText.trim();
|
|
772
|
-
}
|
|
773
|
-
var title = element.getAttribute('title');
|
|
774
|
-
if (title && title.trim()) return title.trim();
|
|
775
|
-
var alt = element.getAttribute('alt');
|
|
776
|
-
if (alt && alt.trim()) return alt.trim();
|
|
777
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
778
|
-
if (text) return text;
|
|
779
|
-
var value = element.getAttribute('value');
|
|
780
|
-
return value && String(value).trim() ? String(value).trim() : '';
|
|
781
|
-
};
|
|
782
|
-
var findByText = function (needle) {
|
|
783
|
-
var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
|
|
784
|
-
var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
|
|
785
|
-
var exact = null;
|
|
786
|
-
var partial = null;
|
|
787
|
-
for (var i = 0; i < candidates.length; i += 1) {
|
|
788
|
-
var element = candidates[i];
|
|
789
|
-
if (!visible(element)) continue;
|
|
790
|
-
var text = label(element).toLowerCase();
|
|
791
|
-
if (!text) continue;
|
|
792
|
-
if (text === wanted) { exact = element; break; }
|
|
793
|
-
if (!partial && text.indexOf(wanted) !== -1) partial = element;
|
|
794
|
-
}
|
|
795
|
-
return exact || partial;
|
|
796
|
-
};
|
|
797
|
-
`,Ir=t=>`(() => {
|
|
798
|
-
${c0}
|
|
799
|
-
${t}
|
|
800
|
-
})()`,d0=({selector:t}={})=>Ir(`
|
|
801
|
-
var scopeSelector = ${JSON.stringify(t??"")};
|
|
802
|
-
var root = document;
|
|
803
|
-
if (scopeSelector) {
|
|
804
|
-
try { root = document.querySelector(scopeSelector); }
|
|
805
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
|
|
806
|
-
if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
|
|
807
|
-
}
|
|
808
|
-
var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
|
|
809
|
-
var elements = [];
|
|
810
|
-
var visibleTotal = 0;
|
|
811
|
-
for (var i = 0; i < interactive.length; i += 1) {
|
|
812
|
-
var element = interactive[i];
|
|
813
|
-
if (!visible(element)) continue;
|
|
814
|
-
visibleTotal += 1;
|
|
815
|
-
if (elements.length >= MAX_ELEMENTS) continue;
|
|
816
|
-
|
|
817
|
-
var rect = element.getBoundingClientRect();
|
|
818
|
-
// Empty and default-valued fields are left out rather than serialized as
|
|
819
|
-
// "" and false. Repeated across a hundred entries that overhead dwarfed
|
|
820
|
-
// the information it carried.
|
|
821
|
-
var entry = {
|
|
822
|
-
selector: cssPath(element),
|
|
823
|
-
tag: element.tagName.toLowerCase(),
|
|
824
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
825
|
-
};
|
|
826
|
-
// The list covers the whole document so anything can be clicked without
|
|
827
|
-
// scrolling to it first, which means bounds alone do not say what is on
|
|
828
|
-
// screen — a negative y reads as a bug otherwise.
|
|
829
|
-
if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
|
|
830
|
-
var type = element.getAttribute('type');
|
|
831
|
-
if (type) entry.type = type;
|
|
832
|
-
var role = element.getAttribute('role');
|
|
833
|
-
if (role) entry.role = role;
|
|
834
|
-
var labelText = label(element);
|
|
835
|
-
if (labelText) entry.label = labelText;
|
|
836
|
-
if (element.disabled === true) entry.disabled = true;
|
|
837
|
-
// Flagged rather than described: reporting the accessible name of every
|
|
838
|
-
// element would cost more than it tells, while its absence on something
|
|
839
|
-
// clickable is a defect worth naming.
|
|
840
|
-
if (!accessibleName(element)) entry.missingAccessibleName = true;
|
|
841
|
-
elements.push(entry);
|
|
842
|
-
}
|
|
843
|
-
var body = document.body ? (document.body.innerText || '') : '';
|
|
844
|
-
var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
|
|
845
|
-
var docEl = document.documentElement;
|
|
846
|
-
var result = {
|
|
847
|
-
ok: true,
|
|
848
|
-
url: String(location.href),
|
|
849
|
-
title: String(document.title || ''),
|
|
850
|
-
scope: scopeSelector || 'document',
|
|
851
|
-
scrollY: Math.round(window.scrollY),
|
|
852
|
-
maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
|
|
853
|
-
text: text.slice(0, ${Ac}),
|
|
854
|
-
elements: elements
|
|
855
|
-
};
|
|
856
|
-
// State what was dropped. A capped list that reports only its own length
|
|
857
|
-
// reads as the whole page, and the agent acts as if it had seen everything.
|
|
858
|
-
if (text.length > ${Ac}) {
|
|
859
|
-
result.textTruncated = true;
|
|
860
|
-
result.textTotalChars = text.length;
|
|
861
|
-
}
|
|
862
|
-
if (visibleTotal > elements.length) {
|
|
863
|
-
result.elementsTruncated = true;
|
|
864
|
-
result.interactiveElementsOnPage = visibleTotal;
|
|
865
|
-
}
|
|
866
|
-
return result;
|
|
867
|
-
`),u0=({selector:t,text:e})=>Ir(`
|
|
868
|
-
var selector = ${JSON.stringify(t??"")};
|
|
869
|
-
var text = ${JSON.stringify(e??"")};
|
|
870
|
-
var target = null;
|
|
871
|
-
if (selector) {
|
|
872
|
-
try { target = document.querySelector(selector); }
|
|
873
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
874
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
875
|
-
} else {
|
|
876
|
-
target = findByText(text);
|
|
877
|
-
if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
|
|
878
|
-
}
|
|
879
|
-
if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
|
|
880
|
-
target.scrollIntoView({ block: 'center', inline: 'center' });
|
|
881
|
-
|
|
882
|
-
// A real click is a sequence, and many widgets act on its first half:
|
|
883
|
-
// custom selects open on mousedown or focus and ignore the click itself.
|
|
884
|
-
// Replay what the mouse would send to the middle of the element. The event
|
|
885
|
-
// goes to whatever is drawn there when that sits inside the target, as it
|
|
886
|
-
// would under a real pointer; anything else keeps the target the agent named.
|
|
887
|
-
var rect = target.getBoundingClientRect();
|
|
888
|
-
var x = rect.left + rect.width / 2;
|
|
889
|
-
var y = rect.top + rect.height / 2;
|
|
890
|
-
var drawn = document.elementFromPoint(x, y);
|
|
891
|
-
var hit = drawn && target.contains(drawn) ? drawn : target;
|
|
892
|
-
var fire = function (element, Type, type, extra) {
|
|
893
|
-
var init = {
|
|
894
|
-
bubbles: true, cancelable: true, composed: true, view: window,
|
|
895
|
-
clientX: x, clientY: y, button: 0, buttons: 0, detail: 1,
|
|
896
|
-
pointerId: 1, pointerType: 'mouse', isPrimary: true
|
|
897
|
-
};
|
|
898
|
-
for (var key in extra) init[key] = extra[key];
|
|
899
|
-
return element.dispatchEvent(new Type(type, init));
|
|
900
|
-
};
|
|
901
|
-
var Pointer = window.PointerEvent || window.MouseEvent;
|
|
902
|
-
var Mouse = window.MouseEvent;
|
|
903
|
-
var notBubbling = { bubbles: false, cancelable: false };
|
|
904
|
-
|
|
905
|
-
fire(hit, Pointer, 'pointerover', {});
|
|
906
|
-
fire(hit, Pointer, 'pointerenter', notBubbling);
|
|
907
|
-
fire(hit, Mouse, 'mouseover', {});
|
|
908
|
-
fire(hit, Mouse, 'mouseenter', notBubbling);
|
|
909
|
-
var pointerDown = fire(hit, Pointer, 'pointerdown', { buttons: 1 });
|
|
910
|
-
// A cancelled pointerdown suppresses the mouse events, as in a browser.
|
|
911
|
-
var mouseDown = pointerDown ? fire(hit, Mouse, 'mousedown', { buttons: 1 }) : true;
|
|
912
|
-
// Focus moves on mousedown unless the page prevented it, to the nearest
|
|
913
|
-
// focusable element under the pointer; with none, the old focus is lost.
|
|
914
|
-
if (mouseDown) {
|
|
915
|
-
var focusable = hit.closest('a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]:not([contenteditable="false"])');
|
|
916
|
-
if (focusable && focusable.disabled !== true) focusable.focus({ preventScroll: true });
|
|
917
|
-
else if (document.activeElement && document.activeElement !== document.body) document.activeElement.blur();
|
|
918
|
-
}
|
|
919
|
-
// The mousedown may have redrawn the widget; the release lands on what is
|
|
920
|
-
// under the pointer now, and the click on what both halves share.
|
|
921
|
-
var redrawn = document.elementFromPoint(x, y);
|
|
922
|
-
var up = redrawn && target.contains(redrawn) ? redrawn : (target.isConnected ? target : hit);
|
|
923
|
-
fire(up, Pointer, 'pointerup', {});
|
|
924
|
-
if (pointerDown) fire(up, Mouse, 'mouseup', {});
|
|
925
|
-
var clicked = up;
|
|
926
|
-
if (hit.isConnected) {
|
|
927
|
-
while (clicked && !clicked.contains(hit)) clicked = clicked.parentElement;
|
|
928
|
-
}
|
|
929
|
-
fire(clicked || up, Mouse, 'click', {});
|
|
930
|
-
return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
|
|
931
|
-
`),f0=({selector:t,value:e,submit:s})=>Ir(`
|
|
932
|
-
var selector = ${JSON.stringify(t)};
|
|
933
|
-
var value = ${JSON.stringify(e)};
|
|
934
|
-
var target = null;
|
|
935
|
-
try { target = document.querySelector(selector); }
|
|
936
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
937
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
938
|
-
|
|
939
|
-
var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
940
|
-
if (!editable) return { ok: false, error: selector + ' is not a text field' };
|
|
941
|
-
if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
|
|
942
|
-
|
|
943
|
-
target.scrollIntoView({ block: 'center' });
|
|
944
|
-
target.focus();
|
|
945
|
-
if (target.isContentEditable) {
|
|
946
|
-
target.textContent = value;
|
|
947
|
-
} else {
|
|
948
|
-
// Frameworks track the value through the native setter; assigning the
|
|
949
|
-
// property directly leaves React and friends unaware of the change.
|
|
950
|
-
var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
951
|
-
var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
|
|
952
|
-
if (setter && setter.set) setter.set.call(target, value);
|
|
953
|
-
else target.value = value;
|
|
954
|
-
}
|
|
955
|
-
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
956
|
-
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
957
|
-
|
|
958
|
-
if (${s?"true":"false"}) {
|
|
959
|
-
var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
|
|
960
|
-
target.dispatchEvent(new KeyboardEvent('keydown', enter));
|
|
961
|
-
target.dispatchEvent(new KeyboardEvent('keyup', enter));
|
|
962
|
-
var form = target.form;
|
|
963
|
-
if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
|
|
964
|
-
}
|
|
965
|
-
return { ok: true, selector: cssPath(target), url: String(location.href) };
|
|
966
|
-
`),h0=({selector:t,direction:e})=>Ir(`
|
|
967
|
-
var selector = ${JSON.stringify(t??"")};
|
|
968
|
-
var direction = ${JSON.stringify(e??"")};
|
|
969
|
-
|
|
970
|
-
// Two frames let the layout catch up, but a page in a hidden background tab
|
|
971
|
-
// is not composited and gets no frames at all while still reporting itself
|
|
972
|
-
// visible, so the wait is capped by a timer. The scroll
|
|
973
|
-
// itself is instant, so the position read then is already the final one.
|
|
974
|
-
var settle = function (extra) {
|
|
975
|
-
return new Promise(function (resolve) {
|
|
976
|
-
var done = false;
|
|
977
|
-
var finish = function () {
|
|
978
|
-
if (done) return;
|
|
979
|
-
done = true;
|
|
980
|
-
var doc = document.documentElement;
|
|
981
|
-
var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
982
|
-
var scrollY = Math.round(window.scrollY);
|
|
983
|
-
var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
|
|
984
|
-
result.atTop = scrollY <= 1;
|
|
985
|
-
result.atBottom = scrollY >= maxScrollY - 1;
|
|
986
|
-
for (var key in extra) {
|
|
987
|
-
if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
|
|
988
|
-
}
|
|
989
|
-
resolve(result);
|
|
990
|
-
};
|
|
991
|
-
requestAnimationFrame(function () {
|
|
992
|
-
requestAnimationFrame(finish);
|
|
993
|
-
});
|
|
994
|
-
setTimeout(finish, ${l0});
|
|
995
|
-
});
|
|
996
|
-
};
|
|
997
|
-
|
|
998
|
-
if (selector) {
|
|
999
|
-
var target = null;
|
|
1000
|
-
try { target = document.querySelector(selector); }
|
|
1001
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
1002
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
1003
|
-
// Instant on purpose: the page's own smooth scrolling would still be
|
|
1004
|
-
// animating when the next action runs against it.
|
|
1005
|
-
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
1006
|
-
return settle({ scrolledTo: cssPath(target) });
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
var doc = document.documentElement;
|
|
1010
|
-
var page = Math.round(window.innerHeight * 0.85);
|
|
1011
|
-
var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
1012
|
-
if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
|
|
1013
|
-
else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
|
|
1014
|
-
else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
|
|
1015
|
-
else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
|
|
1016
|
-
else return { ok: false, error: 'Unknown scroll direction: ' + direction };
|
|
1017
|
-
return settle({ direction: direction });
|
|
1018
|
-
`),p0=["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"],m0=({selector:t})=>Ir(`
|
|
1019
|
-
var selector = ${JSON.stringify(t)};
|
|
1020
|
-
var target = null;
|
|
1021
|
-
try { target = document.querySelector(selector); }
|
|
1022
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
1023
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
1024
|
-
|
|
1025
|
-
var computed = window.getComputedStyle(target);
|
|
1026
|
-
var styles = {};
|
|
1027
|
-
var props = ${JSON.stringify(p0)};
|
|
1028
|
-
for (var i = 0; i < props.length; i += 1) {
|
|
1029
|
-
var value = computed.getPropertyValue(props[i]);
|
|
1030
|
-
if (value) styles[props[i]] = String(value).trim();
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
var rect = target.getBoundingClientRect();
|
|
1034
|
-
return {
|
|
1035
|
-
ok: true,
|
|
1036
|
-
selector: cssPath(target),
|
|
1037
|
-
tag: target.tagName.toLowerCase(),
|
|
1038
|
-
label: label(target),
|
|
1039
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
1040
|
-
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
1041
|
-
styles: styles
|
|
1042
|
-
};
|
|
1043
|
-
`),g0=t=>{const e=He.c(18),{entries:s,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:l}=wt();if(s.length===0)return null;let d;e[0]!==l?(d=l("contextPanel.browser.history.label"),e[0]=l,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==s||e[4]!==i||e[5]!==a||e[6]!==o||e[7]!==l){let h;e[9]!==r||e[10]!==i||e[11]!==a||e[12]!==o||e[13]!==l?(h=(m,g)=>n.jsxs("div",{role:"option","aria-selected":g===r,className:ve("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",g===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:b=>{b.preventDefault(),o(m.url)},onPointerEnter:()=>a(g),children:[n.jsx(Z,{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||Ro(m.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.url})]}),n.jsx("button",{type:"button",className:ve("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":l("contextPanel.browser.history.forget"),title:l("contextPanel.browser.history.forget"),onPointerDown:b=>{b.preventDefault(),b.stopPropagation(),i(m.url)},children:n.jsx(Z,{name:"close",className:"size-3","aria-hidden":"true"})})]},m.url),e[9]=r,e[10]=i,e[11]=a,e[12]=o,e[13]=l,e[14]=h):h=e[14],u=s.map(h),e[2]=r,e[3]=s,e[4]=i,e[5]=a,e[6]=o,e[7]=l,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},As=t=>{const e=He.c(17),{icon:s,label:r,onClick:o,disabled:i,pressed:a}=t,l=a?"secondary":"ghost",d=a&&"text-foreground";let u;e[0]!==d?(u=ve("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(Z,{name:s,className:"size-3.5","aria-hidden":"true"}),e[2]=s,e[3]=f):f=e[3];let h;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==l||e[9]!==u||e[10]!==f?(h=n.jsx(At,{asChild:!0,children:n.jsx(Ct,{type:"button",variant:l,size:"xs",className:u,onClick:o,disabled:i,"aria-label":r,"aria-pressed":a,children:f})}),e[4]=i,e[5]=r,e[6]=o,e[7]=a,e[8]=l,e[9]=u,e[10]=f,e[11]=h):h=e[11];let m;e[12]!==r?(m=n.jsx(Tt,{sideOffset:6,children:r}),e[12]=r,e[13]=m):m=e[13];let g;return e[14]!==h||e[15]!==m?(g=n.jsxs(Ot,{children:[h,m]}),e[14]=h,e[15]=m,e[16]=g):g=e[16],g},oh=t=>{const e=He.c(110),{address:s,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:a,onSubmit:l,onBack:d,onForward:u,onReload:f,onOpenExternal:h,canOpenExternal:m,canGoBack:g,canGoForward:b,isLoading:v,onAnnotate:S,onOpenDevTools:x,isAnnotating:p,onHardReload:y,onZoomIn:w,onZoomOut:j,onZoomReset:k,zoomPercent:P,onClearCookies:A,onClearCache:B,onToggleDeviceBar:R,isDeviceBarOpen:E}=t;let T;e[0]!==o?(T=o===void 0?[]:o,e[0]=o,e[1]=T):T=e[1];const z=T,O=m===void 0?!0:m,W=P===void 0?100:P,{t:D}=wt(),[Q,N]=c.useState(!1),[C,I]=c.useState(-1);let H;e[2]!==Q||e[3]!==z?(H=Q?z:[],e[2]=Q,e[3]=z,e[4]=H):H=e[4];const M=H;let _;e[5]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{I(-1)},e[5]=_):_=e[5];let F;e[6]!==s||e[7]!==Q?(F=[s,Q],e[6]=s,e[7]=Q,e[8]=F):F=e[8],c.useEffect(_,F);let ee;e[9]!==l?(ee=Ve=>{N(!1),I(-1),l(Ve)},e[9]=l,e[10]=ee):ee=e[10];const ne=ee;let re;e[11]!==C||e[12]!==ne||e[13]!==M?(re=Ve=>{if(M.length!==0){if(Ve.key==="ArrowDown"||Ve.key==="ArrowUp"){Ve.preventDefault();const dt=Ve.key==="ArrowDown"?1:-1,et=M.length;I(ct=>{const pe=ct+dt;return pe<-1?et-1:pe>=et?-1:pe});return}if(Ve.key==="Escape"&&C>=0){Ve.preventDefault(),I(-1);return}if(Ve.key==="Enter"&&C>=0){Ve.preventDefault();const dt=M[C];dt&&ne(dt.url)}}},e[11]=C,e[12]=ne,e[13]=M,e[14]=re):re=e[14];const te=re;let K;e[15]!==D?(K=D("contextPanel.browser.back"),e[15]=D,e[16]=K):K=e[16];const q=!g;let oe;e[17]!==d||e[18]!==K||e[19]!==q?(oe=n.jsx(As,{icon:"arrow-left",label:K,onClick:d,disabled:q}),e[17]=d,e[18]=K,e[19]=q,e[20]=oe):oe=e[20];let fe;e[21]!==D?(fe=D("contextPanel.browser.forward"),e[21]=D,e[22]=fe):fe=e[22];const ce=!b;let ke;e[23]!==u||e[24]!==fe||e[25]!==ce?(ke=n.jsx(As,{icon:"arrow-right",label:fe,onClick:u,disabled:ce}),e[23]=u,e[24]=fe,e[25]=ce,e[26]=ke):ke=e[26];let De;e[27]!==v||e[28]!==D?(De=D(v?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=v,e[28]=D,e[29]=De):De=e[29];let Ce;e[30]!==f||e[31]!==De?(Ce=n.jsx(As,{icon:"refresh",label:De,onClick:f}),e[30]=f,e[31]=De,e[32]=Ce):Ce=e[32];let Y;e[33]!==y||e[34]!==D?(Y=y?n.jsx(As,{icon:"restart",label:D("contextPanel.browser.hardReload"),onClick:y}):null,e[33]=y,e[34]=D,e[35]=Y):Y=e[35];let je;e[36]!==s||e[37]!==ne?(je=Ve=>{Ve.preventDefault(),ne(s)},e[36]=s,e[37]=ne,e[38]=je):je=e[38];let we;e[39]!==r?(we=r?n.jsx("span",{className:"pointer-events-none absolute inset-s-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:n.jsx(Z,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=we):we=e[40];let Pe;e[41]!==a?(Pe=Ve=>a(Ve.target.value),e[41]=a,e[42]=Pe):Pe=e[42];let L,ie;e[43]===Symbol.for("react.memo_cache_sentinel")?(L=()=>N(!0),ie=()=>N(!1),e[43]=L,e[44]=ie):(L=e[43],ie=e[44]);const G=M.length>0,ae=r&&"ps-8";let ge;e[45]!==ae?(ge=ve("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3",ae,"typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[45]=ae,e[46]=ge):ge=e[46];let me;e[47]!==D?(me=D("contextPanel.browser.addressAria"),e[47]=D,e[48]=me):me=e[48];let be;e[49]!==s||e[50]!==te||e[51]!==Pe||e[52]!==G||e[53]!==ge||e[54]!==me?(be=n.jsx("input",{value:s,onChange:Pe,onFocus:L,onBlur:ie,onKeyDown:te,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":G,"aria-controls":"openchamber-browser-address-suggestions",className:ge,"aria-label":me}),e[49]=s,e[50]=te,e[51]=Pe,e[52]=G,e[53]=ge,e[54]=me,e[55]=be):be=e[55];let ye;e[56]!==i?(ye=Ve=>i?.(Ve),e[56]=i,e[57]=ye):ye=e[57];let Te;e[58]!==C||e[59]!==ne||e[60]!==ye||e[61]!==M?(Te=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(g0,{entries:M,activeIndex:C,onSelect:ne,onForget:ye,onHighlight:I})}),e[58]=C,e[59]=ne,e[60]=ye,e[61]=M,e[62]=Te):Te=e[62];let $;e[63]!==je||e[64]!==we||e[65]!==be||e[66]!==Te?($=n.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:je,children:[we,be,Te]}),e[63]=je,e[64]=we,e[65]=be,e[66]=Te,e[67]=$):$=e[67];let he;e[68]!==w||e[69]!==j||e[70]!==k||e[71]!==D||e[72]!==W?(he=j&&w?n.jsxs("div",{className:"flex shrink-0 items-center",children:[n.jsx(As,{icon:"subtract",label:D("contextPanel.browser.zoomOut"),onClick:j}),W!==100&&k?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsxs(Ct,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:k,"aria-label":D("contextPanel.browser.zoomReset"),children:[W,"%"]})}),n.jsx(Tt,{sideOffset:6,children:D("contextPanel.browser.zoomReset")})]}):null,n.jsx(As,{icon:"add",label:D("contextPanel.browser.zoomIn"),onClick:w})]}):null,e[68]=w,e[69]=j,e[70]=k,e[71]=D,e[72]=W,e[73]=he):he=e[73];let se;e[74]!==A||e[75]!==D?(se=A?n.jsx(As,{icon:"delete-bin",label:D("contextPanel.browser.clearCookies"),onClick:A}):null,e[74]=A,e[75]=D,e[76]=se):se=e[76];let Ne;e[77]!==B||e[78]!==D?(Ne=B?n.jsx(As,{icon:"database-2",label:D("contextPanel.browser.clearCache"),onClick:B}):null,e[77]=B,e[78]=D,e[79]=Ne):Ne=e[79];let Ue;e[80]!==E||e[81]!==R||e[82]!==D?(Ue=R?n.jsx(As,{icon:"smartphone",label:D("contextPanel.browser.deviceToolbar"),onClick:R,pressed:E}):null,e[80]=E,e[81]=R,e[82]=D,e[83]=Ue):Ue=e[83];let We;e[84]!==p||e[85]!==S||e[86]!==D?(We=S?n.jsx(As,{icon:"markup",label:D("contextPanel.browser.annotate.toggle"),onClick:S,pressed:p}):null,e[84]=p,e[85]=S,e[86]=D,e[87]=We):We=e[87];let Ke;e[88]!==x||e[89]!==D?(Ke=x?n.jsx(As,{icon:"terminal-box",label:D("contextPanel.browser.devTools"),onClick:x}):null,e[88]=x,e[89]=D,e[90]=Ke):Ke=e[90];let Be;e[91]!==D?(Be=D("contextPanel.browser.openExternal"),e[91]=D,e[92]=Be):Be=e[92];const U=!O;let Me;e[93]!==h||e[94]!==Be||e[95]!==U?(Me=n.jsx(As,{icon:"external-link",label:Be,onClick:h,disabled:U}),e[93]=h,e[94]=Be,e[95]=U,e[96]=Me):Me=e[96];let Ge;return e[97]!==oe||e[98]!==ke||e[99]!==Ce||e[100]!==Y||e[101]!==$||e[102]!==he||e[103]!==se||e[104]!==Ne||e[105]!==Ue||e[106]!==We||e[107]!==Ke||e[108]!==Me?(Ge=n.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[oe,ke,Ce,Y,$,he,se,Ne,Ue,We,Ke,Me]}),e[97]=oe,e[98]=ke,e[99]=Ce,e[100]=Y,e[101]=$,e[102]=he,e[103]=se,e[104]=Ne,e[105]=Ue,e[106]=We,e[107]=Ke,e[108]=Me,e[109]=Ge):Ge=e[109],Ge},So={kind:"fill"},Oc=240,b0=3840,ih=[{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}],Bc=t=>Number.isFinite(t)?Math.round(Math.min(b0,Math.max(Oc,t))):Oc,vo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},ah=t=>{const e=ih.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},y0=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},x0=(t,e)=>{const s=vo(t);if(!s)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/s.width,o/s.height);return{width:s.width,height:s.height,scale:i}},S0=["mobile","tablet","desktop","fill"],v0={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Fc=t=>typeof t=="string"&&S0.includes(t),sa=t=>t==="fill"?So:ah(v0[t])??So,Or=t=>{const e=vo(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=sa(s),o=vo(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:s,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},w0=t=>{const e=He.c(70),{viewport:s,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:l}=wt();let d;e[0]!==s?(d=vo(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=s.kind==="preset"?s.id:"";let h;e[2]!==r||e[3]!==u?(h=(re,te)=>{const K=Number.parseInt(te,10);if(!Number.isFinite(K))return;const q=u??{width:1280,height:800};r({kind:"custom",width:Bc(re==="width"?K:q.width),height:Bc(re==="height"?K:q.height)})},e[2]=r,e[3]=u,e[4]=h):h=e[4];const m=h;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=ve("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=g):g=e[5];const b=g;let v;e[6]!==r?(v=re=>{const te=ah(re.target.value);r(te??So)},e[6]=r,e[7]=v):v=e[7];let S;e[8]!==l?(S=l("contextPanel.browser.device.preset"),e[8]=l,e[9]=S):S=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=ve("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]=x):x=e[10];let p;e[11]!==l?(p=l("contextPanel.browser.device.responsive"),e[11]=l,e[12]=p):p=e[12];let y;e[13]!==p?(y=n.jsx("option",{value:"",children:p}),e[13]=p,e[14]=y):y=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=ih.map(k0),e[15]=w):w=e[15];let j;e[16]!==f||e[17]!==v||e[18]!==S||e[19]!==y?(j=n.jsxs("select",{value:f,onChange:v,"aria-label":S,className:x,children:[y,w]}),e[16]=f,e[17]=v,e[18]=S,e[19]=y,e[20]=j):j=e[20];const k=u?String(u.width):"";let P;e[21]!==m?(P=re=>m("width",re.target.value),e[21]=m,e[22]=P):P=e[22];let A;e[23]!==l?(A=l("contextPanel.browser.device.width"),e[23]=l,e[24]=A):A=e[24];let B;e[25]!==k||e[26]!==P||e[27]!==A?(B=n.jsx("input",{value:k,onChange:P,placeholder:"—",inputMode:"numeric","aria-label":A,className:b}),e[25]=k,e[26]=P,e[27]=A,e[28]=B):B=e[28];let R;e[29]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=R):R=e[29];const E=u?String(u.height):"";let T;e[30]!==m?(T=re=>m("height",re.target.value),e[30]=m,e[31]=T):T=e[31];let z;e[32]!==l?(z=l("contextPanel.browser.device.height"),e[32]=l,e[33]=z):z=e[33];let O;e[34]!==E||e[35]!==T||e[36]!==z?(O=n.jsx("input",{value:E,onChange:T,placeholder:"—",inputMode:"numeric","aria-label":z,className:b}),e[34]=E,e[35]=T,e[36]=z,e[37]=O):O=e[37];let W;e[38]!==r||e[39]!==s?(W=()=>r(y0(s)),e[38]=r,e[39]=s,e[40]=W):W=e[40];const D=!u;let Q;e[41]!==l?(Q=l("contextPanel.browser.device.rotate"),e[41]=l,e[42]=Q):Q=e[42];let N;e[43]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Z,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=N):N=e[43];let C;e[44]!==W||e[45]!==D||e[46]!==Q?(C=n.jsx(At,{asChild:!0,children:n.jsx(Ct,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:W,disabled:D,"aria-label":Q,children:N})}),e[44]=W,e[45]=D,e[46]=Q,e[47]=C):C=e[47];let I;e[48]!==l?(I=l("contextPanel.browser.device.rotate"),e[48]=l,e[49]=I):I=e[49];let H;e[50]!==I?(H=n.jsx(Tt,{sideOffset:6,children:I}),e[50]=I,e[51]=H):H=e[51];let M;e[52]!==C||e[53]!==H?(M=n.jsxs(Ot,{children:[C,H]}),e[52]=C,e[53]=H,e[54]=M):M=e[54];let _;e[55]!==a||e[56]!==u?(_=u&&a<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(a*100),"%"]}):null,e[55]=a,e[56]=u,e[57]=_):_=e[57];let F;e[58]===Symbol.for("react.memo_cache_sentinel")?(F=["system","light","dark"],e[58]=F):F=e[58];let ee;e[59]!==o||e[60]!==i||e[61]!==l?(ee=n.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:F.map(re=>n.jsx(Ct,{type:"button",variant:o===re?"secondary":"ghost",size:"xs",className:ve("shrink-0 rounded-full px-2.5 typography-micro",o===re?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(re),"aria-pressed":o===re,children:l(re==="system"?"contextPanel.browser.device.schemeSystem":re==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},re))}),e[59]=o,e[60]=i,e[61]=l,e[62]=ee):ee=e[62];let ne;return e[63]!==j||e[64]!==B||e[65]!==O||e[66]!==M||e[67]!==_||e[68]!==ee?(ne=n.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[j,B,R,O,M,_,ee]}),e[63]=j,e[64]=B,e[65]=O,e[66]=M,e[67]=_,e[68]=ee,e[69]=ne):ne=e[69],ne};function k0(t){return n.jsx("option",{value:t.id,children:t.label},t.id)}const lh="oc.browser.hiddenDevServerPorts.v1",j0=Ua(rn(),Go(C1().int().positive())),na=new Set,ch=[];let Br=null;const nl=()=>{const t=Gd().getItem(lh);if(Br&&Br.raw===t)return Br.value;let e={};if(t!==null)try{const s=j0.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return Br={raw:t,value:e},e},dh=t=>{Gd().setItem(lh,JSON.stringify(t));for(const e of na)e()},C0=(t=Yt())=>nl()[t]??ch,P0=t=>{const e=Yt(),s=nl(),r=s[e]??[];r.includes(t)||dh({...s,[e]:[...r,t].sort((o,i)=>o-i)})},E0=()=>{const t=Yt(),e=nl();if(!e[t])return;const s={...e};delete s[t],dh(s)},N0=t=>(na.add(t),()=>{na.delete(t)}),I0=()=>c.useSyncExternalStore(N0,R0,D0);function R0(){return C0()}function D0(){return ch}const T0=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},M0=2e3,A0=t=>Vu("http://localhost",t),uh=t=>{const e=He.c(51),{onOpen:s,directory:r}=t,o=r===void 0?"":r,{t:i}=wt();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={kind:"loading"},e[0]=a):a=e[0];const[l,d]=c.useState(a),u=iy(o);let f;e[1]!==o?(f=()=>A0(o),e[1]=o,e[2]=f):f=e[2];const[h]=c.useState(f);let m;e[3]!==o?(m=()=>ly(o),e[3]=o,e[4]=m):m=e[4];const[g]=c.useState(m);let b;e[5]!==o?(b=em(o),e[5]=o,e[6]=b):b=e[6];const v=b,S=sl(o),x=tm(o);let p,y;e[7]!==o||e[8]!==x?(p=()=>{if(x){d({kind:"ready",servers:[]});return}let I=!0,H=null;const M=new AbortController,_=()=>{yw(M.signal,o).then(F=>{I&&(d(F),H=setTimeout(_,M0))})};return _(),()=>{I=!1,H&&clearTimeout(H),M.abort()}},y=[o,x],e[7]=o,e[8]=x,e[9]=p,e[10]=y):(p=e[9],y=e[10]),c.useEffect(p,y);const w=l.kind==="ready"?l.servers:null;let j;e[11]!==u||e[12]!==w?(j=vw({announced:u,discovered:w}),e[11]=u,e[12]=w,e[13]=j):j=e[13];const k=j,P=I0();let A;if(e[14]!==k||e[15]!==P){let I;e[17]!==P?(I=H=>H.announced||!P.includes(H.port),e[17]=P,e[18]=I):I=e[18],A=k.filter(I),e[14]=k,e[15]=P,e[16]=A}else A=e[16];const B=A,R=k.length-B.length;let E;e[19]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(cy,{width:110,height:110,className:"shrink-0 opacity-20"}),e[19]=E):E=e[19];let T;e[20]!==i?(T=i("contextPanel.browser.empty"),e[20]=i,e[21]=T):T=e[21];let z;e[22]!==T?(z=n.jsx("span",{className:"typography-ui-header text-foreground",children:T}),e[22]=T,e[23]=z):z=e[23];let O;e[24]!==i?(O=i("contextPanel.browser.emptyHint"),e[24]=i,e[25]=O):O=e[25];let W;e[26]!==O?(W=n.jsx("span",{className:"typography-micro text-muted-foreground",children:O}),e[26]=O,e[27]=W):W=e[27];let D;e[28]!==z||e[29]!==W?(D=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[z,W]}),e[28]=z,e[29]=W,e[30]=D):D=e[30];let Q;e[31]!==u||e[32]!==k.length||e[33]!==o||e[34]!==R||e[35]!==v||e[36]!==s||e[37]!==h||e[38]!==S||e[39]!==g||e[40]!==i||e[41]!==B?(Q=k.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-start text-muted-foreground",children:u.length>0?i("contextPanel.browser.devServers.justStarted"):i("contextPanel.browser.devServers.title")}),h&&!g?n.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.remoteOnly")}):null,n.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pe-0.5",children:B.map(I=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(Ct,{type:"button",variant:"outline",size:"sm",className:ve("min-w-0 flex-1 justify-start gap-2",h&&"cursor-default opacity-60"),"aria-disabled":h||void 0,onClick:()=>{h||(ay(o),s(I.url))},children:[v?n.jsx("span",{className:"shrink-0",role:"img","aria-label":S??i("contextPanel.browser.spaceAddress"),title:S??i("contextPanel.browser.spaceAddress"),children:n.jsx(Z,{name:"box-3",className:"size-3.5","aria-hidden":"true"})}):n.jsx(Z,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",children:Ro(I.url)||I.url}),g?n.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":i("contextPanel.browser.devServers.spaceOnlyDesktop"),title:i("contextPanel.browser.devServers.spaceOnlyDesktop"),children:n.jsx(Z,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):n.jsx("span",{className:"ms-auto truncate typography-micro text-muted-foreground",children:T0(I.url)})]}),I.announced?null:n.jsx(Ct,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>P0(I.port),"aria-label":i("contextPanel.browser.devServers.hide",{port:I.port}),title:i("contextPanel.browser.devServers.hide",{port:I.port}),children:n.jsx(Z,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},I.port))}),R>0?n.jsx(Ct,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:E0,children:R===1?i("contextPanel.browser.devServers.showHiddenSingle",{count:R}):i("contextPanel.browser.devServers.showHiddenPlural",{count:R})}):null]}):null,e[31]=u,e[32]=k.length,e[33]=o,e[34]=R,e[35]=v,e[36]=s,e[37]=h,e[38]=S,e[39]=g,e[40]=i,e[41]=B,e[42]=Q):Q=e[42];let N;e[43]!==k.length||e[44]!==l.kind||e[45]!==i?(N=k.length===0&&l.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.unavailable")}):null,e[43]=k.length,e[44]=l.kind,e[45]=i,e[46]=N):N=e[46];let C;return e[47]!==D||e[48]!==Q||e[49]!==N?(C=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:[E,D,Q,N]}),e[47]=D,e[48]=Q,e[49]=N,e[50]=C):C=e[50],C},ks=t=>Math.round(t),O0=(t,e)=>{const s=t.text.trim(),r=Object.entries(t.attributes).map(([l,d])=>`${l}="${d}"`).join(" "),o=t.ancestry.map(l=>l.selectorPart).join(" > "),i=t.computedStyle,a=t.bounds;return[`Element ${e+1}: ${t.tag}`,s?`- Text: ${s}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,o?`- Ancestry: ${o}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${ks(a.x)}, y=${ks(a.y)}, width=${ks(a.width)}, height=${ks(a.height)}`,`- Styles: display=${i.display??""}; position=${i.position??""}; font=${i.fontWeight??""} ${i.fontSize??""} / ${i.lineHeight??""} ${i.fontFamily??""}; color=${i.color??""}; background=${i.backgroundColor??""}`].filter(l=>typeof l=="string")},B0=(t,e)=>{const s=t.rect;return`Region ${e+1}: x=${ks(s.x)}, y=${ks(s.y)}, width=${ks(s.width)}, height=${ks(s.height)}`},F0=(t,e)=>{const s=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${ks(s.x)}, y=${ks(s.y)}, width=${ks(s.width)}, height=${ks(s.height)}`},L0=({payload:t,screenshotAttached:e,intro:s})=>{const r=s.replace(/[.:]+$/g,""),o=t.comment.trim(),i=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${ks(t.viewport.width)}x${ks(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,o?`Comment: ${o}`:null];for(const[a,l]of t.elements.entries())i.push("",...O0(l.element,a));return t.regions.length>0&&(i.push(""),t.regions.forEach((a,l)=>i.push(B0(a,l)))),t.strokes.length>0&&(i.push(""),t.strokes.forEach((a,l)=>i.push(F0(a,l)))),i.filter(a=>typeof a=="string").join(`
|
|
1044
|
-
`)},_0=t=>{const e=He.c(7),{t:s}=wt(),r=nt(z0),o=nt(W0),i=dy(K0),a=uy(H0);let l;return e[0]!==a||e[1]!==i||e[2]!==r||e[3]!==t||e[4]!==o||e[5]!==s?(l=async d=>{const u=r??(o?"draft":null);if(!u){_e.error(s("contextPanel.browser.annotate.noSession"));return}let f=!1;if(d.screenshot)try{await a(d.screenshot),f=!0}catch{f=!1}i({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:L0({payload:d.payload,screenshotAttached:f,intro:s("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),_e.success(s("contextPanel.browser.annotate.attached")),requestAnimationFrame(fy)},e[0]=a,e[1]=i,e[2]=r,e[3]=t,e[4]=o,e[5]=s,e[6]=l):l=e[6],l},$0=()=>{const t=He.c(16),{t:e}=wt();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 o;t[4]!==e?(o=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=i):i=t[7];let a;t[8]!==e?(a=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=a):a=t[9];let l;return t[10]!==s||t[11]!==r||t[12]!==o||t[13]!==i||t[14]!==a?(l={select:s,marquee:r,draw:o,commentPlaceholder:i,submit:a},t[10]=s,t[11]=r,t[12]=o,t[13]=i,t[14]=a,t[15]=l):l=t[15],l};function z0(t){return t.currentSessionId}function W0(t){return t.newSessionDraft?.open}function K0(t){return t.addDraft}function H0(t){return t.addAttachedFile}const V0=3e4,G0=3,U0=250,q0={attempts:0,windowStartedAt:null},Y0=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=V0,r=s?0:t.attempts;return r>=G0?null:{delayMs:U0*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},X0=-3,Fr=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",$n=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Q0=(t,{initialUrl:e,onUrlChange:s})=>{const[r,o]=c.useState(e?{kind:"loading",url:e}:jw),[i,a]=c.useState(e),[l,d]=c.useState(""),[u,f]=c.useState(!1),[h,m]=c.useState(!1),g=c.useRef(s);g.current=s;const b=c.useRef(q0);return c.useEffect(()=>{if(!t)return;const v=()=>{try{const R=t.getURL();return Fr(R)?R:""}catch{return""}},S=()=>{try{f(t.canGoBack()),m(t.canGoForward())}catch{}},x=R=>{Fr(R)&&(a(R),g.current(R))},p=()=>{const R=v();o({kind:"loading",url:R})},y=()=>{const R=v();let E="";try{E=t.getTitle()||""}catch{E=""}d(E),x(R),S(),o(T=>T.kind==="failed"?T:{kind:"ready",url:R,title:E})},w=R=>{const E=$n(R);Fr(E.url)&&(x(E.url),S())},j=R=>{const E=$n(R),T=Array.isArray(E.favicons)?E.favicons.find(Boolean):"",z=v();if(!T||!z)return;let O=-1;try{O=t.getWebContentsId()}catch{return}!Number.isFinite(O)||O<0||Ff.getState().resolve(z,T,O)},k=R=>{const E=$n(R);typeof E.title=="string"&&d(E.title)},P=R=>{const E=$n(R);if(E.isMainFrame===!1)return;const T=typeof E.errorCode=="number"?E.errorCode:0;T!==X0&&o({kind:"failed",url:Fr(E.validatedURL)?E.validatedURL:v(),code:T,description:typeof E.errorDescription=="string"?E.errorDescription:""})};let A=null;const B=()=>{const R=v(),E=Y0(b.current,Date.now());if(!E){o({kind:"failed",url:R,code:0,description:"",crashed:!0});return}b.current=E.state,o({kind:"loading",url:R}),A=setTimeout(()=>{A=null;try{t.reload()}catch{o({kind:"failed",url:R,code:0,description:"",crashed:!0})}},E.delayMs)};t.addEventListener("did-start-loading",p),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",w),t.addEventListener("did-navigate-in-page",w),t.addEventListener("page-title-updated",k),t.addEventListener("page-favicon-updated",j),t.addEventListener("did-fail-load",P),t.addEventListener("render-process-gone",B),t.addEventListener("crashed",B);try{!t.isLoading()&&v()&&y()}catch{}return()=>{A!==null&&clearTimeout(A),t.removeEventListener("render-process-gone",B),t.removeEventListener("crashed",B),t.removeEventListener("did-start-loading",p),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",w),t.removeEventListener("did-navigate-in-page",w),t.removeEventListener("page-title-updated",k),t.removeEventListener("page-favicon-updated",j),t.removeEventListener("did-fail-load",P)}},[t]),{status:r,url:i,title:l,canGoBack:u,canGoForward:h}},Lc=1e3,fh=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},Z0=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},J0=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},ek=(t,e)=>{const s=c.useRef(0),r=c.useRef(0),o=c.useRef(0),i=c.useRef(null),a=c.useCallback(()=>{if(!t||document.activeElement!==t)return;const l=i.current;l&&l.isConnected&&l!==document.body?l.focus({preventScroll:!0}):t.blur()},[t]);return c.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=J0());const l=d=>{if(document.activeElement!==t){i.current=Z0(d);return}const u=e.current,f=s.current>r.current||Date.now()<o.current;u&&fh(u)&&!f||r.current>0||a()};return document.addEventListener("focusin",l,!0),()=>document.removeEventListener("focusin",l,!0)},[a,e,t]),c.useCallback(async l=>{const d=t!==null&&document.activeElement===t;let u=!1;const f=()=>{u&&(u=!1,r.current-=1,o.current=Date.now()+Lc,!d&&r.current===0&&a())},h=()=>(u||(u=!0,r.current+=1),f);s.current+=1;try{return await l(h)}finally{s.current-=1,o.current=Date.now()+Lc,f()}},[a,t])},tk=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),sk=()=>document.visibilityState==="visible",nk=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Lr=.5,rk=-3,ok=4,ik="persist:openchamber-browser",hh=(t,e,s)=>Ls(t)!==null&&qd(e)?{icon:"box-3",label:s}:void 0,_c=t=>{const e=Ls(t);return e?`openchamber-space-preview:${e}`:ik},$c=20,ak=600,lk=2e4,ck=15e3,dk=t=>{if(!t||fh(t))return()=>{};const e=t.getBoundingClientRect(),s=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=s}},uk=({initialUrl:t,directory:e,tabID:s,ownerSessionId:r,visible:o})=>{const{t:i}=wt(),{currentTheme:a}=Cr(),l=c.useRef(null),[d,u]=c.useState(null),f=c.useCallback(pe=>{l.current=pe,u(pe)},[]),h=de(pe=>pe.setContextPanelTabTargetPath),m=c.useRef(Wn(t)),g=m.current!==fn?m.current:"",[b,v]=c.useState(g?null:fn),S=sl(e),[x,p]=c.useState(g),[y,w]=c.useState(!1),[j,k]=c.useState(!1),[P,A]=c.useState(0),B=c.useRef(0),[R,E]=c.useState(!1),[T,z]=c.useState(So),O=c.useRef(T);O.current=T;const W=c.useRef([]),[D,Q]=c.useState("system"),[N,C]=c.useState({width:0,height:0}),I=c.useRef(null),H=c.useRef(null),M=vs(e),_=c.useRef(!!g&&!sm(M,s)),F=c.useRef(null);c.useEffect(()=>{Ud(M,s)},[M,s]);const ee=c.useRef(!1),ne=c.useRef(Date.now()),re=c.useCallback(pe=>{!pe||pe===fn||!e||!s||h(e,s,pe)},[e,s,h]),te=Q0(d,{initialUrl:g,onUrlChange:c.useCallback(pe=>{const Ee=Bn(pe);p(Ee),re(Ee)},[re])}),[K,q]=c.useState(null),[oe,fe]=c.useState(Ls(e)===null);c.useEffect(()=>{const pe=Ls(e);if(pe===null){fe(!0);return}let Ee=!0;return fe(!1),Fn("desktop_space_preview_prepare",{spaceId:pe}).then(()=>{Ee&&fe(!0)}).catch(()=>{Ee&&q(g||"http://localhost/")}),()=>{Ee=!1}},[e,g]);const ce=_0(e),ke=$0(),De=te.status.kind==="loading",Ce=Hn(rh(e)),Y=Hn(pe=>pe.recordVisit),je=Hn(pe=>pe.forget);c.useEffect(()=>{te.status.kind==="ready"&&Y(e,{url:Bn(te.status.url),title:te.status.title})},[e,te.status,Y]);const we=c.useMemo(()=>nh(Ce,x),[Ce,x]),Pe=c.useCallback(pe=>{const Ee=Wn(pe);Ee!==fn&&(_.current=!1,p(Ee),q(null),Ul(Ee,e).then(qe=>{const Ye=l.current;if(!Ye){v(qe);return}try{Ye.loadURL(qe)}catch{v(qe)}}).catch(qe=>{qe instanceof ql&&q(Ee)}))},[e]);c.useEffect(()=>{if(!g)return;let pe=!0;return Ul(g,e).then(Ee=>{pe&&v(Ee)}).catch(Ee=>{if(pe){if(Ee instanceof ql){q(g),_.current=!1,v(fn);return}v(g)}}),()=>{pe=!1}},[]);const L=c.useMemo(()=>({executeJavaScript:async(pe,Ee)=>{const qe=l.current;if(!qe)throw new Error("Browser view is not available");return qe.executeJavaScript(pe,Ee)},capturePage:async()=>{const pe=l.current;if(!pe)return null;const Ee=pe.getWebContentsId();return Number.isFinite(Ee)?await Fn("desktop_browser_capture_page",{webContentsId:Ee}):null}}),[]),ie=c.useCallback(()=>{if(y){w(!1),to(L);return}if(!te.url){_e.error(i("contextPanel.browser.annotate.noPage"));return}const pe=Lw(a.metadata.variant==="light"?"light":"dark");w(!0),Bw({host:L,theme:pe,labels:ke}).then(async Ee=>{w(!1),Ee&&await ce(Ee)}).catch(()=>{w(!1),_e.error(i("contextPanel.browser.annotate.failed"))})},[L,ce,a,y,te.url,ke,i]);c.useEffect(()=>{if(!y)return;const pe=Ee=>{hy(Ee)||Ee.key!=="Escape"||(Ee.preventDefault(),Ee.stopImmediatePropagation(),w(!1),to(L))};return window.addEventListener("keydown",pe,!0),()=>window.removeEventListener("keydown",pe,!0)},[L,y]);const G=c.useRef(!1);c.useEffect(()=>{if(!d)return;const pe=()=>{G.current=!0};return d.addEventListener("dom-ready",pe),d.addEventListener("did-fail-load",pe),()=>{d.removeEventListener("dom-ready",pe),d.removeEventListener("did-fail-load",pe)}},[d]);const ae=c.useCallback(async()=>{const pe=Date.now()+ck;for(;!(l.current&&G.current)&&Date.now()<pe;)await new Promise(Ee=>setTimeout(Ee,100));return l.current},[]),ge=c.useCallback(async(pe=8e3)=>{const Ee=Date.now();for(;;){const qe=l.current;if(!qe)return!1;let Ye=!1;try{Ye=qe.isLoading()}catch{return!1}if(!Ye)return!0;if(Date.now()-Ee>pe)return!1;await new Promise($e=>setTimeout($e,120))}},[]),me=c.useCallback(async(pe,Ee,qe)=>{const Ye=await ae();if(!Ye)throw new Error("The browser panel is not ready");const $e=()=>{Fc(Ee.viewport)&&(z(sa(Ee.viewport)),E(!0))};if(pe==="browser.back"||pe==="browser.forward"){const xt=pe==="browser.back";if(!(xt?Ye.canGoBack():Ye.canGoForward()))throw new Error(xt?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");xt?Ye.goBack():Ye.goForward(),await new Promise($t=>setTimeout($t,150)),await ge();let jt="";try{jt=Ye.getTitle()||""}catch{jt=""}return{url:Bn(Ye.getURL()),title:jt}}if(pe==="browser.capture"){const xt=dk(I.current);try{await new Promise($t=>{requestAnimationFrame(()=>requestAnimationFrame(()=>$t()))}),await ge();const Mt=await L.capturePage();if(!Mt)throw new Error("The page could not be captured");let jt="";try{jt=Ye.getTitle()||""}catch{jt=""}return{...Mt,url:Bn(Ye.getURL()),title:jt,viewport:Or(O.current)}}finally{xt()}}if(pe==="browser.resize"){if(!Fc(Ee.viewport))throw new Error("viewport is required");return $e(),await new Promise(xt=>setTimeout(xt,200)),await ge(),{viewport:Or(sa(Ee.viewport))}}if(pe==="browser.open"){const xt=typeof Ee.url=="string"?Ee.url:"";if(!xt)throw new Error("url is required");$e(),Pe(xt),await new Promise($t=>setTimeout($t,150));const Mt=await ge(25e3);let jt="";try{jt=Ye.getTitle()||""}catch{jt=""}return{url:Wn(xt),title:jt,opened:!0,settled:Mt,viewport:Or(O.current)}}await ge();const tt=xt=>typeof xt=="string"&&xt?xt:void 0,vt=(()=>{switch(pe){case"browser.snapshot":return d0({selector:tt(Ee.selector)});case"browser.click":return u0({selector:tt(Ee.selector),text:tt(Ee.text)});case"browser.type":return f0({selector:String(Ee.selector??""),value:String(Ee.value??""),submit:Ee.submit===!0});case"browser.inspect":return m0({selector:String(Ee.selector??"")});case"browser.scroll":return h0({selector:tt(Ee.selector),direction:tt(Ee.direction)});default:return null}})();if(!vt)throw new Error(`Unsupported browser action: ${pe}`);let Bt=()=>{};(pe==="browser.click"||pe==="browser.type")&&(await Fn("desktop_browser_keep_page_focused",{webContentsId:Ye.getWebContentsId()}).then(Mt=>Mt.focused===!0).catch(()=>!1)||(Bt=qe(),Ye.focus({preventScroll:!0})));let kt;try{kt=await Ye.executeJavaScript(vt,!0)}finally{Bt()}if(!kt||typeof kt!="object")throw new Error("The page returned no result");const St=kt;if(St.ok!==!0)throw new Error(typeof St.error=="string"&&St.error?St.error:"Browser action failed");if(pe==="browser.snapshot"){const xt=W.current;return{...St,viewport:Or(O.current),...xt.length>0?{consoleProblems:[...xt]}:{}}}return(pe==="browser.click"||pe==="browser.type"&&Ee.submit===!0)&&(await new Promise(xt=>setTimeout(xt,150)),await ge()),kt},[L,Pe,ge,ae]),be=ek(d,I),[ye,Te]=c.useState(!1),$=c.useCallback((pe,Ee)=>(Te(!0),be(qe=>me(pe,Ee,qe))),[be,me]),he=c.useCallback(()=>{const pe=l.current;if(!pe)return{title:"",url:""};let Ee="",qe="";try{Ee=pe.getTitle()||""}catch{Ee=""}try{qe=Bn(pe.getURL())}catch{qe=""}return{title:Ee,url:qe}},[]);c.useEffect(()=>Uw({tabId:s,directory:M,ownerSessionId:r,describe:he,run:$}),[he,r,$,M,s]),c.useEffect(()=>{const pe=L;return()=>{to(pe)}},[L]),c.useEffect(()=>{if(!d)return;const pe=qe=>{const Ye=qe;if(typeof Ye.level!="number"||Ye.level<2)return;const $e=Ye.sourceId?`${Ye.sourceId}${Ye.line?`:${Ye.line}`:""}`:"";W.current.push({level:Ye.level>=3?"error":"warning",message:String(Ye.message??"").slice(0,400),source:$e}),W.current.length>$c&&W.current.splice(0,W.current.length-$c)},Ee=()=>{W.current=[]};return d.addEventListener("console-message",pe),d.addEventListener("did-start-loading",Ee),()=>{d.removeEventListener("console-message",pe),d.removeEventListener("did-start-loading",Ee)}},[d]);const se=c.useRef(new Set),Ne=c.useCallback(pe=>{se.current.clear(),Pe(pe)},[Pe]),Ue=c.useRef(te.status);Ue.current=te.status;const We=c.useRef(!1);te.status.kind==="ready"&&te.status.url&&(We.current=!0),c.useEffect(()=>nm(M,s,pe=>{om(Ue.current,We.current)&&Ne(pe)}),[Ne,M,s]),c.useEffect(()=>{if(!d)return;const pe=qe=>{const Ye=$n(qe),$e=typeof Ye.url=="string"?Ye.url:"";!$e||!Yl($e,e)||(qe.preventDefault(),Pe($e))},Ee=qe=>{const Ye=$n(qe);if(Ye.isMainFrame===!1||Ye.errorCode===-3)return;const $e=typeof Ye.validatedURL=="string"?Ye.validatedURL:"";!$e||!Yl($e,e)||se.current.has($e)||(se.current.add($e),Pe($e))};return d.addEventListener("will-navigate",pe),d.addEventListener("did-fail-load",Ee),()=>{d.removeEventListener("will-navigate",pe),d.removeEventListener("did-fail-load",Ee)}},[e,Pe,d]),c.useEffect(()=>{if(!d)return;const pe=Ee=>{const qe=Ee.detail;Ee.preventDefault(),qe?.url&&Pe(qe.url)};return d.addEventListener("new-window",pe),()=>d.removeEventListener("new-window",pe)},[Pe,d]);const Ke=c.useCallback(pe=>{const Ee=Math.min(ok,Math.max(rk,pe));B.current=Ee,A(Ee);try{l.current?.setZoomLevel(Ee)}catch{}},[]);c.useEffect(()=>{const pe=Ee=>{if(!(Ee instanceof CustomEvent))return;const qe=Ee.detail,Ye=l.current;!Ye||document.activeElement!==Ye||(qe==="zoom-in"?Ke(B.current+Lr):qe==="zoom-out"?Ke(B.current-Lr):qe==="zoom-reset"&&Ke(0))};return window.addEventListener("openchamber:zoom",pe),()=>window.removeEventListener("openchamber:zoom",pe)},[Ke]);const Be=c.useCallback(pe=>{Fn("desktop_browser_clear_data",{partition:_c(e),cookies:pe==="cookies",cache:pe==="cache"}).then(()=>{_e.success(i(pe==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{l.current?.reloadIgnoringCache()}catch{}}).catch(()=>_e.error(i("contextPanel.browser.clearFailed")))},[e,i]);c.useEffect(()=>{const pe=I.current;if(!pe||typeof ResizeObserver>"u")return;const Ee=new ResizeObserver(qe=>{const Ye=qe[0]?.contentRect;Ye&&C({width:Ye.width,height:Ye.height})});return Ee.observe(pe),()=>Ee.disconnect()},[]);const U=c.useCallback(pe=>{Q(pe);const Ee=l.current;if(!Ee)return;let qe=-1;try{qe=Ee.getWebContentsId()}catch{return}Fn("desktop_browser_set_color_scheme",{webContentsId:qe,scheme:pe}).catch(Ye=>{Q("system"),_e.error(Ye instanceof Error?Ye.message:i("contextPanel.browser.device.schemeFailed"))})},[i]),Me=c.useCallback(()=>{try{De?l.current?.stop():l.current?.reload()}catch{}},[De]),Ge=te.status,Ve=c.useSyncExternalStore(tk,sk),dt=o&&Ve||r!==null||ye;c.useEffect(()=>{const pe=tt=>{k(!0);const ht=setTimeout(()=>{try{l.current?.reload()}catch{}},tt);return()=>clearTimeout(ht)};if(Ge.kind==="loading")return;const Ee=_.current||F.current===Ge;if(_.current&&(Ge.kind==="failed"||Ge.kind==="ready"&&Ge.url)&&(_.current=!1,F.current=Ge),Ge.kind==="failed"){const tt=rm(Ge,{run:H.current,restored:Ee,watched:dt,now:Date.now()});if(H.current=tt.run,tt.next==="retry")return pe(tt.delayMs);k(tt.next==="pause");return}if(H.current=null,Ge.kind!=="ready"||!Ge.url||!qd(Ge.url)){ee.current=!0,k(!1);return}if(Ee||ee.current||Date.now()-ne.current>lk){ee.current=!0,k(!1);return}let qe=!1,Ye=null;return(Ls(e)?Promise.resolve(null):xw(Bn(Ge.url))).then(tt=>{if(!qe){if(tt===null||tt<500){ee.current=!0,k(!1);return}Ye=pe(ak)}}),()=>{qe=!0,Ye?.()}},[e,Ge,dt]);const et=te.status.kind==="failed"&&!j?te.status:null,ct=x0(T,N);return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[n.jsx(oh,{address:x,onAddressChange:p,onSubmit:Ne,suggestions:we,onForgetSuggestion:pe=>je(e,pe),onBack:()=>{try{l.current?.goBack()}catch{}},onForward:()=>{try{l.current?.goForward()}catch{}},onReload:Me,onOpenExternal:()=>{Ma(te.url||x)},addressMark:hh(e,x,S??i("contextPanel.browser.spaceAddress")),canOpenExternal:Ls(e)===null,canGoBack:te.canGoBack,canGoForward:te.canGoForward,isLoading:De,onAnnotate:ie,isAnnotating:y,onOpenDevTools:()=>{try{l.current?.openDevTools()}catch{}},onHardReload:()=>{try{l.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ke(P+Lr),onZoomOut:()=>Ke(P-Lr),onZoomReset:()=>Ke(0),zoomPercent:Math.round(Math.pow(1.2,P)*100),onClearCookies:()=>Be("cookies"),onClearCache:()=>Be("cache"),onToggleDeviceBar:()=>E(pe=>!pe),isDeviceBarOpen:R}),R?n.jsx(w0,{viewport:T,onViewportChange:z,colorScheme:D,onColorSchemeChange:U,scale:ct?.scale??1}):null,n.jsxs("div",{ref:I,className:ve("relative min-h-0 flex-1 bg-background",ct&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[b!==null&&oe?n.jsx("webview",{ref:f,src:b,partition:_c(e),allowpopups:!0,style:ct?{width:`${ct.width}px`,height:`${ct.height}px`,transform:`scale(${ct.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,b!==null&&!g&&!te.url&&!De?n.jsx(uh,{onOpen:Ne,directory:e}):null,j?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:i("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.waitingForServerHint")})]}):null,K?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[Ls(e)!==null?n.jsx(Z,{name:"box-3",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:i("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i(Ls(e)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:K})})]}):null,et&&!K?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:et.crashed?i("contextPanel.browser.crashed"):i("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:et.crashed?i("contextPanel.browser.crashedHint"):et.description||i("contextPanel.browser.loadFailedUnknown")})]}):null,De?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]})]})},fk=t=>{const e=He.c(74),{initialUrl:s,directory:r,tabID:o}=t,{t:i}=wt(),a=de(pk);let l;e[0]!==s?(l=Wn(s),e[0]=s,e[1]=l):l=e[1];const d=l,u=d!==fn?d:"",[f,h]=c.useState(u);let m;e[2]!==r||e[3]!==u?(m=li(u,r),e[2]=r,e[3]=u,e[4]=m):m=e[4];const[g,b]=c.useState(m);let v;e[5]!==r||e[6]!==u?(v=Vu(u,r)?u:"",e[5]=r,e[6]=u,e[7]=v):v=e[7];const[S,x]=c.useState(v);let p;e[8]!==r?(p=Ls(r),e[8]=r,e[9]=p):p=e[9];const y=p!==null,w=sl(r);let j;e[10]!==u?(j=u?[u]:[],e[10]=u,e[11]=j):j=e[11];const[k,P]=c.useState(j),[A,B]=c.useState(u?0:-1),[R,E]=c.useReducer(mk,0);let T,z;e[12]!==r||e[13]!==o?(T=()=>{Ud(vs(r),o)},z=[r,o],e[12]=r,e[13]=o,e[14]=T,e[15]=z):(T=e[14],z=e[15]),c.useEffect(T,z);let O;e[16]!==r||e[17]!==a||e[18]!==o?(O=je=>{!je||je===fn||!r||!o||a(r,o,je)},e[16]=r,e[17]=a,e[18]=o,e[19]=O):O=e[19];const W=O;let D;e[20]!==r?(D=rh(r),e[20]=r,e[21]=D):D=e[21];const Q=Hn(D),N=Hn(gk),C=Hn(bk);let I;e[22]!==f||e[23]!==Q?(I=nh(Q,f),e[22]=f,e[23]=Q,e[24]=I):I=e[24];const H=I;let M;e[25]!==r||e[26]!==A||e[27]!==W||e[28]!==N?(M=je=>{const we=Wn(je);if(we===fn)return;h(we);const Pe=li(we,r);b(Pe),x(Pe?"":we),W(we),N(r,{url:we}),P(L=>{const ie=A>=0?L.slice(0,A+1):[];return ie[ie.length-1]===we?(B(ie.length-1),ie):(B(ie.length),[...ie,we])})},e[25]=r,e[26]=A,e[27]=W,e[28]=N,e[29]=M):M=e[29];const _=M;let F;e[30]!==r||e[31]!==k||e[32]!==W?(F=je=>{const we=k[je];if(!we)return;B(je),h(we);const Pe=li(we,r);b(Pe),x(Pe?"":we),W(we)},e[30]=r,e[31]=k,e[32]=W,e[33]=F):F=e[33];const ee=F;let ne;e[34]!==r||e[35]!==C?(ne=je=>C(r,je),e[34]=r,e[35]=C,e[36]=ne):ne=e[36];let re,te;e[37]!==ee||e[38]!==A?(re=()=>ee(A-1),te=()=>ee(A+1),e[37]=ee,e[38]=A,e[39]=re,e[40]=te):(re=e[39],te=e[40]);let K;e[41]!==f||e[42]!==g?(K=()=>{Ma(g||f)},e[41]=f,e[42]=g,e[43]=K):K=e[43];let q;e[44]!==w||e[45]!==i?(q=w??i("contextPanel.browser.spaceAddress"),e[44]=w,e[45]=i,e[46]=q):q=e[46];let oe;e[47]!==f||e[48]!==r||e[49]!==q?(oe=hh(r,f,q),e[47]=f,e[48]=r,e[49]=q,e[50]=oe):oe=e[50];const fe=!S,ce=A>0,ke=A>=0&&A<k.length-1;let De;e[51]!==f||e[52]!==_||e[53]!==H||e[54]!==ne||e[55]!==re||e[56]!==te||e[57]!==K||e[58]!==oe||e[59]!==fe||e[60]!==ce||e[61]!==ke?(De=n.jsx(oh,{address:f,onAddressChange:h,onSubmit:_,suggestions:H,onForgetSuggestion:ne,onBack:re,onForward:te,onReload:E,onOpenExternal:K,addressMark:oe,canOpenExternal:fe,canGoBack:ce,canGoForward:ke,isLoading:!1}),e[51]=f,e[52]=_,e[53]=H,e[54]=ne,e[55]=re,e[56]=te,e[57]=K,e[58]=oe,e[59]=fe,e[60]=ce,e[61]=ke,e[62]=De):De=e[62];let Ce;e[63]!==r||e[64]!==y||e[65]!==g||e[66]!==_||e[67]!==R||e[68]!==i||e[69]!==S?(Ce=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:S?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[y?n.jsx(Z,{name:"box-3",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:i(y?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:Ro(S)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.remoteLoopback.hint")})]}):g?n.jsx("iframe",{src:g,title:i("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${R}`):n.jsx(uh,{onOpen:_,directory:r})}),e[63]=r,e[64]=y,e[65]=g,e[66]=_,e[67]=R,e[68]=i,e[69]=S,e[70]=Ce):Ce=e[70];let Y;return e[71]!==De||e[72]!==Ce?(Y=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[De,Ce]}),e[71]=De,e[72]=Ce,e[73]=Y):Y=e[73],Y},hk=t=>{const e=He.c(3),[s]=c.useState(nk);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(uk,{...t}):n.jsx(fk,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function pk(t){return t.setContextPanelTabTargetPath}function mk(t){return t+1}function gk(t){return t.recordVisit}function bk(t){return t.forget}const yk=t=>{const e=He.c(13),{zone:s,children:r}=t,[o]=c.useState(xk);let i;e[0]!==s?(i=m=>m.body[s],e[0]=s,e[1]=i):i=e[1];const a=vr(i);let l,d;e[2]!==a||e[3]!==o||e[4]!==s?(l=()=>{const m=a??vr.getState().body[s];if(!m){o.remove();return}if(o.parentElement===m)return;const g=document.activeElement;m.moveBefore&&o.isConnected?m.moveBefore(o,null):m.append(o),g instanceof HTMLElement&&o.contains(g)&&document.activeElement!==g&&g.focus({preventScroll:!0})},d=[a,o,s],e[2]=a,e[3]=o,e[4]=s,e[5]=l,e[6]=d):(l=e[5],d=e[6]),c.useLayoutEffect(l,d);let u,f;e[7]!==o?(u=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=u,e[9]=f):(u=e[8],f=e[9]),c.useLayoutEffect(u,f);let h;return e[10]!==r||e[11]!==o?(h=ga.createPortal(r,o),e[10]=r,e[11]=o,e[12]=h):h=e[12],h};function xk(){const t=document.createElement("div");return t.style.display="contents",t}const ra=2e4,Sk=(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},_r=(t,e)=>im(am.getState().dictionary,t,e),vk=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"},wk=async(t,e,s)=>{const r=!!(s?.directory&&!yy(e,s.directory));if(t.readFile)return(await t.readFile(e,{optional:!0,directory:s?.directory,allowOutsideWorkspace:r})).content??"";const o=new URLSearchParams({path:e,optional:"true"});s?.directory&&o.set("directory",s.directory),r&&o.set("allowOutsideWorkspace","true");const i=await an(`/api/fs/read?${o.toString()}`,{cache:"no-store",headers:s?.directory?{"x-opencode-directory":s.directory}:void 0});if(!i.ok){const a=await i.json().catch(()=>({error:i.statusText}));throw new Error(a.error||"Failed to read file")}return i.text()},kk=async(t,e,s)=>{if(py(e)||my(e)||gy(e))return{ok:!0};try{const r=await wk(t,e,s);return by(r)?{ok:!1,reason:"binary"}:Sk(r,ra)>ra?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:vk(r)}}},jk=t=>{if(t==="too-large"){const e=ra.toLocaleString(Wu());return _r("contextFileOpen.failure.tooLarge",{count:e})}return _r(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},zc=8;let wr=null;const ph=(t,e)=>Math.abs(e.clientX-t.x)<=zc&&Math.abs(e.clientY-t.y)<=zc,mh=t=>{wr={x:t.clientX,y:t.clientY}},gh=t=>{const e=wr;return wr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:ph(e,t)},bh=t=>wr!==null&&ph(wr,t);let yh=null;const Wc=t=>{yh=t},xh=()=>yh,Kc=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},Sh=(t,e,s)=>{const r=e===null?s:e.type==="directory"?e.path:Kc(e.path);return!r||Kc(t.path)===r||t.type==="directory"&&lm(r,t.path,t.path)!==null?null:r},Ck=(t,e)=>{const s=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${s}`:`${e}/${s}`},Vn=t=>Array.from(t.types).includes("Files"),yr=t=>Array.from(t.types).includes(Bo)?xh():null,vh=(t,e,s)=>t.getData(Bo)===qo(e,s.path),Pk=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]:[]})},Ek=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),rs=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},qo=(t,e)=>{const s=rs(e),r=rs(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},ar=(t,e)=>{const s=qo(t,e);if(s!==".")return s;const r=rs(t);return r.split("/").filter(Boolean).pop()??r},ro=t=>{const e=rs(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},Nk=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),Ik=new Set(["node_modules"]),Rk=t=>Ik.has(t),Dk=t=>{const e=rs(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Tk=8,Vs=new Map,rl=t=>JSON.stringify([Yt(),t]),Mk=t=>{const e=rl(t),s=Vs.get(e);return s?(s.touchedAt=Date.now(),Vs.delete(e),Vs.set(e,s),s):null},Si=t=>{const e=rl(t),s=Vs.get(e);if(s)return s.touchedAt=Date.now(),s;if(Vs.size>=Tk){const o=Vs.keys().next().value;o!==void 0&&Vs.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Vs.set(e,r),r},Ak=t=>{const e=He.c(127),{node:s,root:r,isExpanded:o,isActive:i,isBrowserClient:a,depth:l,isOpen:d,status:u,badge:f,isDropTarget:h,isDragSource:m,canUpload:g,canMove:b,permissions:v,downloadFile:S,onSelect:x,onToggle:p,onRevealPath:y,onOpenDialog:w,onSetDropTarget:j,onDropFiles:k,onPickFiles:P,onMoveDragChange:A,onSetMoveDropTarget:B,onMoveDrop:R}=t,{t:E}=wt(),T=s.type==="directory";let z;e[0]!==T||e[1]!==s.path?(z=T?s.path:ro(s.path),e[0]=T,e[1]=s.path,e[2]=z):z=e[2];const O=z,{canRename:W,canCreateFile:D,canCreateFolder:Q,canDelete:N,canReveal:C}=v,I=!T&&!!S,H=C&&!a,M=T&&g,_=W||D||Q||M||N||I||H,[F,ee]=c.useState(!1),[ne,re]=c.useState(!1);let te;e[3]!==_?(te=$e=>{_&&($e?.preventDefault(),re(!0))},e[3]=_,e[4]=te):te=e[4];const K=te;let q;e[5]!==T||e[6]!==s||e[7]!==x||e[8]!==p?(q=()=>{T?p(s.path):x(s)},e[5]=T,e[6]=s,e[7]=x,e[8]=p,e[9]=q):q=e[9];const oe=q;let fe;e[10]!==T||e[11]!==s||e[12]!==x?(fe=()=>{T||x(s,{pin:!0})},e[10]=T,e[11]=s,e[12]=x,e[13]=fe):fe=e[13];const ce=fe;let ke;e[14]===Symbol.for("react.memo_cache_sentinel")?(ke=$e=>{$e.stopPropagation(),re(!1),ee(!0)},e[14]=ke):ke=e[14];const De=ke;let Ce;e[15]!==D||e[16]!==Q||e[17]!==N||e[18]!==W||e[19]!==H||e[20]!==M||e[21]!==S||e[22]!==a||e[23]!==T||e[24]!==s||e[25]!==w||e[26]!==P||e[27]!==y||e[28]!==E?(Ce=$e=>{const{Item:tt,Separator:ht}=$e;return n.jsxs(n.Fragment,{children:[W&&n.jsxs(tt,{onClick:vt=>{vt.stopPropagation(),w("rename",s)},children:[n.jsx(Z,{name:"edit",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.rename")]}),n.jsxs(tt,{onClick:vt=>{vt.stopPropagation(),Oo(s.path).then(Bt=>{if(Bt.ok){_e.success(E("sidebarFilesTree.toast.pathCopied"));return}_e.error(E("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(Z,{name:"file-copy",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.copyPath")]}),!T&&S&&n.jsxs(tt,{onClick:vt=>{vt.stopPropagation(),S(s.path).catch(Bt=>{console.error("Download failed:",Bt),_e.error(E("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Z,{name:"download",className:"me-2 h-4 w-4"})," ",E(a?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),H&&n.jsxs(tt,{onClick:vt=>{vt.stopPropagation(),y(s.path)},children:[n.jsx(Z,{name:"folder-received",className:"me-2 h-4 w-4"})," ",E(Gu())]}),!T&&H&&Do()&&n.jsxs(tt,{onClick:vt=>{vt.stopPropagation(),cm(s.path).then(Bt=>{Bt||_e.error(E("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Z,{name:"external-link",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.openInDefaultApp")]}),T&&(D||Q||M)&&n.jsxs(n.Fragment,{children:[n.jsx(ht,{}),D&&n.jsxs(tt,{onClick:vt=>{vt.stopPropagation(),w("createFile",s)},children:[n.jsx(Z,{name:"file-add",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.newFile")]}),Q&&n.jsxs(tt,{onClick:vt=>{vt.stopPropagation(),w("createFolder",s)},children:[n.jsx(Z,{name:"folder-add",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.newFolder")]}),M&&n.jsxs(tt,{onClick:vt=>{vt.stopPropagation(),P(s.path)},children:[n.jsx(Z,{name:"upload-2",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.uploadFiles")]})]}),N&&n.jsxs(n.Fragment,{children:[n.jsx(ht,{}),n.jsxs(tt,{onClick:vt=>{vt.stopPropagation(),w("delete",s)},className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.delete")]})]})]})},e[15]=D,e[16]=Q,e[17]=N,e[18]=W,e[19]=H,e[20]=M,e[21]=S,e[22]=a,e[23]=T,e[24]=s,e[25]=w,e[26]=P,e[27]=y,e[28]=E,e[29]=Ce):Ce=e[29];const Y=Ce;let je;e[30]!==b||e[31]!==s.path||e[32]!==s.type||e[33]!==A||e[34]!==r?(je=$e=>{mh($e);const tt=qo(r,s.path);!tt||tt==="."||($e.dataTransfer.setData(Bo,tt),$e.dataTransfer.effectAllowed=b?"copyMove":"copy",b&&A({path:s.path,type:s.type}))},e[30]=b,e[31]=s.path,e[32]=s.type,e[33]=A,e[34]=r,e[35]=je):je=e[35];const we=je;let Pe;e[36]!==b||e[37]!==oe||e[38]!==A?(Pe=$e=>{b&&A(null),gh($e)&&oe()},e[36]=b,e[37]=oe,e[38]=A,e[39]=Pe):Pe=e[39];const L=Pe;let ie;e[40]!==g||e[41]!==j||e[42]!==O?(ie=$e=>{!g||!O||!Vn($e.dataTransfer)||($e.preventDefault(),$e.stopPropagation(),$e.dataTransfer.dropEffect="copy",j(O))},e[40]=g,e[41]=j,e[42]=O,e[43]=ie):ie=e[43];const G=ie;let ae;e[44]!==g||e[45]!==j||e[46]!==O?(ae=$e=>{!g||!O||!Vn($e.dataTransfer)||$e.relatedTarget instanceof Node&&$e.currentTarget.contains($e.relatedTarget)||($e.stopPropagation(),j(null))},e[44]=g,e[45]=j,e[46]=O,e[47]=ae):ae=e[47];const ge=ae;let me;e[48]!==g||e[49]!==k||e[50]!==O?(me=$e=>{!g||!O||!Vn($e.dataTransfer)||($e.preventDefault(),$e.stopPropagation(),k(O,$e.dataTransfer))},e[48]=g,e[49]=k,e[50]=O,e[51]=me):me=e[51];const be=me;let ye;e[52]!==s.path||e[53]!==s.type||e[54]!==r?(ye=($e,tt)=>bh($e)?null:Sh(tt,{path:s.path,type:s.type},r),e[52]=s.path,e[53]=s.type,e[54]=r,e[55]=ye):ye=e[55];const Te=ye;let $;e[56]!==b||e[57]!==Te||e[58]!==G||e[59]!==B?($=$e=>{const tt=b?yr($e.dataTransfer):null;if(!tt){G($e);return}$e.stopPropagation();const ht=Te($e,tt);B(ht),ht&&($e.preventDefault(),$e.dataTransfer.dropEffect="move")},e[56]=b,e[57]=Te,e[58]=G,e[59]=B,e[60]=$):$=e[60];const he=$;let se;e[61]!==b||e[62]!==Te||e[63]!==be||e[64]!==R||e[65]!==B||e[66]!==r?(se=$e=>{const tt=b?yr($e.dataTransfer):null;if(!tt){be($e);return}$e.stopPropagation(),$e.preventDefault(),B(null);const ht=Te($e,tt);ht&&vh($e.dataTransfer,r,tt)&&R(tt,ht)},e[61]=b,e[62]=Te,e[63]=be,e[64]=R,e[65]=B,e[66]=r,e[67]=se):se=e[67];const Ne=se;let Ue;e[68]===Symbol.for("react.memo_cache_sentinel")?(Ue={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[68]=Ue):Ue=e[68];let We;e[69]!==K||e[70]!==ge||e[71]!==he||e[72]!==Ne?(We=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Ue,onContextMenu:K,onDragEnter:he,onDragOver:he,onDragLeave:ge,onDrop:Ne}),e[69]=K,e[70]=ge,e[71]=he,e[72]=Ne,e[73]=We):We=e[73];let Ke;e[74]!==l?(Ke=n.jsx(iu,{depth:l}),e[74]=l,e[75]=Ke):Ke=e[75];let Be;e[76]!==i||e[77]!==m||e[78]!==h?(Be=ve("flex w-full items-center gap-1.5 rounded-md py-1 pe-8 text-start transition-colors select-none",h?"bg-interactive-selection text-interactive-selection-foreground ring-2 ring-inset ring-primary":ou(i),m&&"opacity-50"),e[76]=i,e[77]=m,e[78]=h,e[79]=Be):Be=e[79];let U;e[80]!==l?(U=wa(l),e[80]=l,e[81]=U):U=e[81];let Me;e[82]!==U?(Me={paddingInlineStart:U},e[82]=U,e[83]=Me):Me=e[83];let Ge;e[84]!==T||e[85]!==o||e[86]!==s.extension||e[87]!==s.path?(Ge=T?n.jsx(jr,{expanded:o}):n.jsx(Oa,{filePath:s.path,extension:s.extension,className:"ms-0.5 size-3.5"}),e[84]=T,e[85]=o,e[86]=s.extension,e[87]=s.path,e[88]=Ge):Ge=e[88];let Ve;e[89]!==s.name||e[90]!==s.path?(Ve=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:s.path,children:s.name}),e[89]=s.name,e[90]=s.path,e[91]=Ve):Ve=e[91];let dt;e[92]!==T||e[93]!==d||e[94]!==u?(dt=!T&&n.jsx(hg,{isOpen:d,status:u}),e[92]=T,e[93]=d,e[94]=u,e[95]=dt):dt=e[95];let et;e[96]!==f||e[97]!==T?(et=T&&f&&n.jsx(pg,{badge:f}),e[96]=f,e[97]=T,e[98]=et):et=e[98];let ct;e[99]!==K||e[100]!==ce||e[101]!==L||e[102]!==we||e[103]!==oe||e[104]!==Be||e[105]!==Me||e[106]!==Ge||e[107]!==Ve||e[108]!==dt||e[109]!==et?(ct=n.jsxs("button",{type:"button",onClick:oe,onDoubleClick:ce,onContextMenu:K,draggable:!0,onDragStart:we,onDragEnd:L,className:Be,style:Me,children:[Ge,Ve,dt,et]}),e[99]=K,e[100]=ce,e[101]=L,e[102]=we,e[103]=oe,e[104]=Be,e[105]=Me,e[106]=Ge,e[107]=Ve,e[108]=dt,e[109]=et,e[110]=ct):ct=e[110];let pe;e[111]!==F||e[112]!==_||e[113]!==Y||e[114]!==E?(pe=_&&n.jsx("div",{className:"absolute inset-e-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:n.jsxs(js,{open:F,onOpenChange:ee,children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:De,title:E("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":E("sidebarFilesTree.actions.fileMenuTitle"),children:n.jsx(Z,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(Tt,{side:"bottom",sideOffset:6,children:E("sidebarFilesTree.actions.fileMenuTitle")})]}),n.jsx(Ps,{align:"end",side:"bottom",onCloseAutoFocus:()=>ee(!1),children:Y({Item:qt,Separator:bn})})]})}),e[111]=F,e[112]=_,e[113]=Y,e[114]=E,e[115]=pe):pe=e[115];let Ee;e[116]!==We||e[117]!==Ke||e[118]!==ct||e[119]!==pe?(Ee=n.jsxs(La,{render:We,children:[Ke,ct,pe]}),e[116]=We,e[117]=Ke,e[118]=ct,e[119]=pe,e[120]=Ee):Ee=e[120];let qe;e[121]!==Y?(qe=n.jsx(Fa,{className:"min-w-[180px]",children:Y({Item:Dn,Separator:qr})}),e[121]=Y,e[122]=qe):qe=e[122];let Ye;return e[123]!==ne||e[124]!==Ee||e[125]!==qe?(Ye=n.jsxs(_a,{open:ne,onOpenChange:re,children:[Ee,qe]}),e[123]=ne,e[124]=Ee,e[125]=qe,e[126]=Ye):Ye=e[126],Ye},Ok=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.depth===e.depth&&t.isOpen===e.isOpen&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.isDragSource===e.isDragSource&&t.canUpload===e.canUpload&&t.canMove===e.canMove&&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&&t.onMoveDragChange===e.onMoveDragChange&&t.onSetMoveDropTarget===e.onSetMoveDropTarget&&t.onMoveDrop===e.onMoveDrop,Bk=c.memo(Ak,Ok),Fk=t=>{const e=He.c(6),{visible:s}=t,r=s===void 0?!0:s,o=gn(_k),i=vn();let a;e[0]!==i||e[1]!==o?(a=JSON.stringify([o,i]),e[0]=i,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==a||e[4]!==r?(l=n.jsx(Lk,{visible:r},a),e[3]=a,e[4]=r,e[5]=l):l=e[5],l},Lk=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:s}=wt(),{files:r,runtime:o}=Ws(),i=dm(o.platform),a=vn()??"",l=rs(a.trim()),d=rl(l),u=um(),f=fm(),h=hm(X=>X.searchFiles),m=de(X=>X.openContextFile),g=Aa(t?a:null),[b,v]=c.useState(""),S=xy(b,200),x=c.useRef(null),[p,y]=c.useState([]),[w,j]=c.useState(!1),[k,P]=c.useState(null),[A,B]=c.useState(null),[R,E]=c.useState(null),[T,z]=c.useState(null),{hasTouchOnlyPointer:O}=Mn(),W=!!(r.rename&&l)&&!O,D=de(X=>X.confirmFileTreeMove),Q=de(X=>X.setConfirmFileTreeMove),[N,C]=c.useState({}),[I,H]=c.useState({}),M=c.useRef(new Set),_=c.useRef(new Map),F=c.useMemo(()=>new P1,[]);c.useEffect(()=>()=>F.clear(),[F]);const ee=c.useRef(null);c.useEffect(()=>{if(P(null),E(null),z(null),!l){C({}),H({}),M.current=new Set;return}const X=Mk(l);X?(C({...X.childrenByDir}),H({...X.loadErrorsByDir}),M.current=new Set(X.loadedDirs)):(C({}),H({}),M.current=new Set)},[l]),c.useEffect(()=>{if(!l)return;const X=Si(l);X.childrenByDir=N},[l,N]),c.useEffect(()=>{if(!l)return;const X=Si(l);X.loadErrorsByDir=I},[l,I]),c.useEffect(()=>{if(!l)return;const X=Si(l);X.loadedDirs=new Set(M.current)},[l,N,I]),c.useEffect(()=>()=>{if(!l)return;const X=Vs.get(d);X&&X.loadedDirs.size===0&&Object.keys(X.childrenByDir).length===0&&Vs.delete(d)},[d,l]);const ne=c.useMemo(()=>[],[]),re=c.useMemo(()=>[],[]),te=Fs(X=>l?X.byRoot[l]?.expandedPaths??ne:ne),K=c.useMemo(()=>new Set(te),[te]),q=Fs(X=>l?X.byRoot[l]?.selectedPath??null:null),oe=Fs(X=>X.setSelectedPath),fe=c.useRef(null),ce=c.useRef(null);c.useEffect(()=>{ce.current=q},[q]);const ke=Fs(X=>X.addOpenPath),De=Fs(X=>X.removeOpenPathsByPrefix),Ce=Fs(X=>X.toggleExpandedPath),Y=Fs(X=>X.expandPath),je=Fs(X=>X.collapseAllExpandedPaths),we=de(X=>l?X.contextPanelByDirectory[l]?.tabs??re:re),Pe=c.useMemo(()=>new Set(we.map(X=>X.mode==="file"?X.targetPath:null).filter(X=>typeof X=="string"&&X.length>0).map(X=>rs(X))),[we]),[L,ie]=c.useState(null),[G,ae]=c.useState(null),[ge,me]=c.useState(""),[be,ye]=c.useState(!1),Te=!!r.writeFile,$=!!r.createDirectory,he=!!r.rename,se=!!r.delete,Ne=!!r.revealPath,Ue=c.useMemo(()=>({canRename:he,canCreateFile:Te,canCreateFolder:$,canDelete:se,canReveal:Ne}),[he,Te,$,se,Ne]),We=c.useCallback(X=>{r.revealPath&&r.revealPath(X).catch(()=>{_e.error(s("sidebarFilesTree.toast.revealFailed"))})},[r,s]),Ke=c.useCallback((X,le)=>{ie(X),ae(le),me(X==="rename"&&le.name||""),ye(!1)},[]),Be=c.useCallback((X,le)=>{const Xe=le.filter(Ae=>Ae&&typeof Ae.name=="string"&&Ae.name.length>0).filter(Ae=>u||!Ae.name.startsWith(".")).filter(Ae=>f||!Rk(Ae.name)).map(Ae=>{const Je=Ae.name,Fe=rs(Ae.path||""),gt=Fe?Nk(Fe)?Fe:rs(`${X}/${Fe}`):rs(`${X}/${Je}`),bt=Ae.isDirectory?"directory":"file",Et=bt==="file"&&Je.includes(".")?Je.split(".").pop()?.toLowerCase():void 0;return{name:Je,path:gt,type:bt,extension:Et}});return Ek(Xe)},[f,u]),U=c.useCallback(async(X,le,Xe=!1)=>{if(!e.current||le?.())return;const Ae=rs(X.trim());if(!Ae||!Xe&&M.current.has(Ae))return;const Je=Yt();return F.run(Ae,async Fe=>{const gt=()=>!Fe()||Yt()!==Je;try{const bt=!f,Et=r.listDirectory?(await r.listDirectory(Ae,{respectGitignore:bt})).entries:await co.listLocalDirectory(Ae,{respectGitignore:bt});if(gt())return;_.current.set(Ae,Et.length);const Ft=Be(Ae,Et);M.current=new Set(M.current),M.current.add(Ae),H(es=>{if(!es[Ae])return es;const Re={...es};return delete Re[Ae],Re}),C(es=>es[Ae]&&E1(es[Ae],Ft)?es:{...es,[Ae]:Ft})}catch(bt){if(gt())return;const Et=bt instanceof Error?bt.message:String(bt??"");console.error("Failed to load sidebar directory:",bt),H(Ft=>({...Ft,[Ae]:Et}))}},Xe)},[F,r,Be,f]),Me=c.useCallback(async()=>{if(!l)return;ee.current?.abort();const X=new AbortController;ee.current=X,F.clear();try{const Xe=(Fs.getState().byRoot[l]?.expandedPaths??[]).map(Fe=>rs(Fe)).filter(Fe=>!!Fe&&Fe!==l&&Fe.startsWith(`${l}/`)),Ae=[l,...Xe];M.current=new Set(M.current);for(const Fe of Ae)M.current.delete(Fe);H(Fe=>{if(Object.keys(Fe).length===0)return Fe;const gt={...Fe};let bt=!1;for(const Et of Ae)Et in gt&&(delete gt[Et],bt=!0);return bt?gt:Fe});const Je=()=>X.signal.aborted;await U(l,Je);for(let Fe=0;Fe<Xe.length&&!X.signal.aborted;Fe+=3){const gt=Xe.slice(Fe,Fe+3);await Promise.all(gt.map(bt=>U(bt,Je)))}}catch(le){if(X.signal.aborted)return;console.error("Failed to refresh sidebar tree:",le)}finally{ee.current===X&&(ee.current=null)}},[F,U,l]),Ge=c.useCallback(async X=>{if(!X){await Me();return}const le=rs(X);M.current=new Set(M.current),M.current.delete(le),await U(le,void 0,!0)},[U,Me]);c.useEffect(()=>{l&&(ee.current?.abort(),M.current=new Set,F.clear(),H({}),C(X=>Object.keys(X).length===0?X:{}),U(l))},[F,U,l,u,f]),c.useEffect(()=>{if(!t||!l||te.length===0)return;const X=te.map(Ae=>rs(Ae)).filter(Ae=>!!Ae&&Ae!==l&&Ae.startsWith(`${l}/`)&&!M.current.has(Ae)&&!F.has(Ae)).sort((Ae,Je)=>Ae.split("/").length-Je.split("/").length);if(X.length===0)return;let le=!1;const Xe=()=>le;return(async()=>{for(let Ae=0;Ae<X.length&&!le;Ae+=3){const Je=X.slice(Ae,Ae+3);await Promise.all(Je.map(Fe=>U(Fe,Xe)))}})(),()=>{le=!0}},[F,te,U,l,t]);const Ve=c.useRef(t);c.useEffect(()=>{const X=t&&!Ve.current;Ve.current=t,X&&Me()},[Me,t]);const dt=c.useCallback(({directories:X})=>{if(!l)return;const le=new Set((Fs.getState().byRoot[l]?.expandedPaths??[]).map(Et=>rs(Et))),Xe=l==="/"?"/":`${l}/`,Ae=Et=>{for(let Ft=Et;Ft!==l;Ft=ro(Ft))if(!Ft.startsWith(Xe)||!le.has(Ft))return!1;return!0},Je=Et=>{for(let Ft=Et;Ft===l||Ft.startsWith(Xe);Ft=ro(Ft)){if(M.current.has(Ft))return Ft;if(Ft===l)break}return null},Fe=new Set,gt=new Set;for(const Et of X??M.current){const Ft=Je(rs(Et));Ft&&(Ae(Ft)?Fe:gt).add(Ft)}gt.size>0&&(M.current=new Set([...M.current].filter(Et=>!gt.has(Et))));const bt=[...Fe].filter(Et=>(_.current.get(Et)??0)<=mg);(async()=>{for(let Et=0;Et<bt.length;Et+=3)await Promise.all(bt.slice(Et,Et+3).map(Ft=>U(Ft,void 0,!0)))})()},[U,l]);gg({root:l,active:t,whileInactive:"drop",onChanges:dt}),c.useEffect(()=>{if(!t)return;if(!a){y([]),j(!1);return}const X=S.trim();if(!X){y([]),j(!1);return}let le=!1;return j(!0),h(a,X,150,{includeHidden:u,respectGitignore:!f,type:"file"}).then(Xe=>{if(le)return;const Je=Xe.filter(Fe=>f||!Dk(Fe.path)).map(Fe=>({name:Fe.name,path:rs(Fe.path),type:"file",extension:Fe.extension,relativePath:Fe.relativePath}));y(Je)}).catch(()=>{le||y([])}).finally(()=>{le||j(!1)}),()=>{le=!0}},[a,S,h,u,f,t]);const et=c.useMemo(()=>{const X=new Map;if(!g?.files)return X;for(const le of g.files)le.index==="A"||le.working_dir==="?"?X.set(le.path,"git-added"):le.index==="D"?X.set(le.path,"git-deleted"):(le.index==="M"||le.working_dir==="M")&&X.set(le.path,"git-modified");return X},[g]),ct=c.useMemo(()=>{const X=new Map;if(!g?.files||!l)return X;for(const le of g.files){const Xe=le.index==="M"||le.working_dir==="M",Ae=le.index==="A"||le.working_dir==="?";if(!Xe&&!Ae)continue;const Je=le.path.split("/");if(Je.length<=1)continue;let Fe=l;for(let gt=0;gt<Je.length-1;gt++){Fe=`${Fe}/${Je[gt]}`;let bt=X.get(Fe);bt||(bt={modified:0,added:0},X.set(Fe,bt)),Xe&&bt.modified++,Ae&&bt.added++}}return X},[g,l]),pe=c.useCallback(X=>{if(et.size===0)return null;const le=X.startsWith(l+"/")?X.slice(l.length+1):X;return et.get(le)??null},[et,l]),Ee=c.useCallback(X=>{if(ct.size===0)return null;const le=ct.get(X);return le&&le.modified+le.added>0?le:null},[ct]),qe=c.useCallback(async(X,le)=>{if(!l)return;const Xe=await kk(r,X.path,{directory:l});if(!Xe.ok){_e.error(jk(Xe.reason));return}oe(l,X.path),ke(l,X.path),m(l,X.path,{preview:!le?.pin&&!de.getState().isMobile})},[ke,r,m,l,oe]),Ye=c.useCallback(async X=>{const le=rs(X);l&&(Ce(l,le),M.current.has(le)||await U(le))},[U,l,Ce]),{canUpload:$e,uploadingDirectory:tt,uploadFiles:ht,pickFiles:vt,uploadElements:Bt}=bg({root:l,refreshDirectory:Ge}),kt=tt!==null,St=tt??k,xt=c.useCallback((X,le)=>{const Xe=Pk(le);Xe.length!==0&&(P(null),ht(X,Xe))},[ht]),Mt=c.useCallback(X=>{if(Wc(X),!X){B(null),E(null);return}requestAnimationFrame(()=>{xh()?.path===X.path&&B(X.path)})},[]),jt=c.useCallback(async(X,le)=>{const Xe=Ck(X,le),Ae=await dc(r,l,X.path,Xe);if(Ae==="conflict"){_e.error(s("sidebarFilesTree.toast.nameTaken",{name:Xe.slice(Xe.lastIndexOf("/")+1),folder:ar(l,le)}));return}if(Ae==="failed"){_e.error(s("sidebarFilesTree.toast.operationFailed"));return}le!==l&&Y(l,le),await Promise.all([Ge(ro(X.path)),Ge(le)]).catch(()=>{})},[Y,r,Ge,l,s]),$t=c.useCallback((X,le)=>{if(de.getState().confirmFileTreeMove){z({source:X,targetDirectory:le});return}jt(X,le)},[jt]),Wt=c.useCallback(()=>{T&&(z(null),jt(T.source,T.targetDirectory))},[jt,T]),Kt=c.useCallback((X,le)=>!W||bh(X)?null:Sh(le,null,l),[W,l]),rt=c.useCallback(X=>{const le=yr(X.dataTransfer);if(le){const Xe=Kt(X,le);if(E(Xe),!Xe)return;X.preventDefault(),X.dataTransfer.dropEffect="move";return}!$e||kt||!l||!Vn(X.dataTransfer)||(X.preventDefault(),X.dataTransfer.dropEffect="copy",P(l))},[$e,Kt,kt,l]),ut=c.useCallback(X=>{if(!(X.relatedTarget instanceof Node&&X.currentTarget.contains(X.relatedTarget))){if(yr(X.dataTransfer)){E(null);return}Vn(X.dataTransfer)&&P(null)}},[]),pt=c.useCallback(X=>{const le=yr(X.dataTransfer);if(le){X.preventDefault(),E(null);const Xe=Kt(X,le);Xe&&vh(X.dataTransfer,l,le)&&$t(le,Xe);return}!$e||kt||!l||!Vn(X.dataTransfer)||(X.preventDefault(),xt(l,X.dataTransfer))},[$e,Kt,xt,$t,kt,l]),ue=c.useCallback(async X=>{if(X?.preventDefault(),!G||!L)return;ye(!0);const le=()=>ye(!1),Xe=()=>ie(null);if(L==="createFile"){if(!ge.trim()){_e.error(s("sidebarFilesTree.toast.filenameRequired")),le();return}if(!r.writeFile){_e.error(s("sidebarFilesTree.toast.writeNotSupported")),le();return}const Ae=G.path,Je=Ae?`${Ae}/`:"",Fe=rs(`${Je}${ge.trim()}`);await r.writeFile(Fe,"").then(async gt=>{gt.success&&(_e.success(s("sidebarFilesTree.toast.fileCreated")),await Ge(Ae)),Xe()}).catch(()=>_e.error(s("sidebarFilesTree.toast.operationFailed"))).finally(le);return}if(L==="createFolder"){if(!ge.trim()){_e.error(s("sidebarFilesTree.toast.folderNameRequired")),le();return}const Ae=G.path,Je=Ae?`${Ae}/`:"",Fe=rs(`${Je}${ge.trim()}`);await r.createDirectory(Fe).then(async gt=>{gt.success&&(_e.success(s("sidebarFilesTree.toast.folderCreated")),await Ge(Ae)),Xe()}).catch(()=>_e.error(s("sidebarFilesTree.toast.operationFailed"))).finally(le);return}if(L==="rename"){if(!ge.trim()){_e.error(s("sidebarFilesTree.toast.nameRequired")),le();return}if(!r.rename){_e.error(s("sidebarFilesTree.toast.renameNotSupported")),le();return}const Ae=G.path,Je=Ae.split("/").slice(0,-1).join("/"),Fe=Je?`${Je}/`:"",gt=ge.trim(),bt=rs(`${Fe}${gt}`);try{const Et=await dc(r,l,Ae,bt);Et==="moved"?(_e.success(s("sidebarFilesTree.toast.renamedSuccessfully")),await Ge(Je),Xe()):Et==="conflict"?_e.error(s("sidebarFilesTree.toast.nameTaken",{name:gt,folder:ar(l,Je)})):_e.error(s("sidebarFilesTree.toast.operationFailed"))}catch{_e.error(s("sidebarFilesTree.toast.operationFailed"))}finally{le()}return}if(L==="delete"){if(!r.delete){_e.error(s("sidebarFilesTree.toast.deleteNotSupported")),le();return}const Ae=G.path,Je=Ae.split("/").slice(0,-1).join("/");await r.delete(Ae).then(async Fe=>{Fe.success&&(_e.success(s("sidebarFilesTree.toast.deletedSuccessfully")),await Ge(Je),l&&De(l,Ae),(q===Ae||q&&q.startsWith(Ae+"/"))&&oe(l,null)),Xe()}).catch(()=>_e.error(s("sidebarFilesTree.toast.operationFailed"))).finally(le);return}le()},[L,G,ge,r,Ge,De,l,q,oe,s]);function lt(X,le){return(N[X]??[]).map(Ae=>{const Je=Ae.type==="directory",Fe=Je&&K.has(Ae.path),gt=q===Ae.path;return n.jsxs("li",{"data-file-tree-path":Je?void 0:Ae.path,children:[n.jsx(Bk,{node:Ae,root:l,isExpanded:Fe,isActive:gt,isBrowserClient:i,depth:le,isOpen:!Je&&Pe.has(Ae.path),status:Je?void 0:pe(Ae.path),badge:Je?Ee(Ae.path):void 0,isDropTarget:Je&&(St===Ae.path||R===Ae.path),isDragSource:A===Ae.path,canUpload:$e&&!kt,canMove:W,permissions:Ue,downloadFile:r.downloadFile,onSelect:qe,onToggle:Ye,onRevealPath:We,onOpenDialog:Ke,onSetDropTarget:P,onDropFiles:xt,onPickFiles:vt,onMoveDragChange:Mt,onSetMoveDropTarget:E,onMoveDrop:$t}),Je&&Fe&&n.jsxs("ul",{className:"flex flex-col",children:[I[Ae.path]?n.jsxs("li",{className:"relative flex items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:wa(le+1)},children:[n.jsx(iu,{depth:le+1}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:I[Ae.path],children:I[Ae.path]}),n.jsxs(Ct,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ge(Ae.path)},children:[n.jsx(Z,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):null,lt(Ae.path,le+1)]})]},Ae.path)})}c.useEffect(()=>{const X=ce.current,le=fe.current;if(!X||!le)return;const Xe=le.querySelector(`[data-file-tree-path="${CSS.escape(X)}"]`);!Xe||Xe.offsetParent===null||(ce.current=null,Xe.scrollIntoView({block:"nearest"}))});const ft=!!(l&&N[l]),mt=l?I[l]:null,It=St?ar(l,St):"",xe=R?ar(l,R):"",it=T?T.source.path.slice(T.source.path.lastIndexOf("/")+1):"";return n.jsxs("section",{ref:fe,className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex flex-col border-b border-border/40",children:[n.jsxs("div",{className:"flex h-8 shrink-0 items-center justify-end gap-1 border-t border-border/40 px-2",children:[Te||$||$e?n.jsxs(js,{children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"sm",className:"size-6 p-0 flex-shrink-0","aria-label":s("sidebarFilesTree.actions.addMenuTitle"),children:n.jsx(Z,{name:kt?"loader-4":"add",className:ve("h-4 w-4",kt&&"animate-spin")})})})})}),n.jsx(Tt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.addMenuTitle")})]}),n.jsxs(Ps,{align:"end",className:"min-w-[180px]",children:[Te?n.jsxs(qt,{onClick:()=>Ke("createFile",{path:a,type:"directory"}),children:[n.jsx(Z,{name:"file-add",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.newFile")]}):null,$?n.jsxs(qt,{onClick:()=>Ke("createFolder",{path:a,type:"directory"}),children:[n.jsx(Z,{name:"folder-add",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.newFolder")]}):null,$e?n.jsxs(qt,{disabled:!l||kt,onClick:()=>vt(l),children:[n.jsx(Z,{name:"upload-2",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.uploadFiles")]}):null]})]}):null,n.jsx(N1,{className:"size-6"}),n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Ct,{variant:"ghost",size:"sm",onClick:()=>{Me()},className:"size-6 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.refreshTitle"),"aria-label":s("sidebarFilesTree.actions.refreshTitle"),children:n.jsx(Z,{name:"refresh",className:"h-4 w-4"})})})}),n.jsx(Tt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.refreshTitle")})]}),n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Ct,{variant:"ghost",size:"sm",onClick:()=>{l&&je(l)},className:"size-6 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":s("sidebarFilesTree.actions.collapseAllTitle"),children:n.jsx(Z,{name:"collapse-vertical",className:"h-4 w-4"})})})}),n.jsx(Tt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.collapseAllTitle")})]})]}),n.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[n.jsx(Z,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),n.jsx(ho,{ref:x,value:b,onChange:X=>v(X.target.value),placeholder:s("sidebarFilesTree.search.placeholder"),className:"h-8 ps-8 pe-8 typography-meta"}),b.trim().length>0?n.jsx("button",{type:"button","aria-label":s("sidebarFilesTree.search.clearAria"),className:"absolute inset-e-4 top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{v(""),x.current?.focus()},children:n.jsx(Z,{name:"close",className:"h-4 w-4"})}):null]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsx(Pr,{outerClassName:"h-full min-h-0",className:ve("px-1.5 py-1.5",(St===l||R===l)&&"bg-interactive-selection/10"),onDragEnter:rt,onDragOver:rt,onDragLeave:ut,onDrop:pt,children:n.jsx("ul",{className:"flex flex-col",children:w?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(Z,{name:"loader-4",className:"h-4 w-4 animate-spin"}),s("sidebarFilesTree.state.searching")]}):p.length>0?p.map(X=>{const le=q===X.path;return n.jsx("li",{"data-file-tree-path":X.path,children:n.jsxs("button",{type:"button",onClick:()=>qe(X),onDoubleClick:()=>qe(X,{pin:!0}),draggable:!0,onDragStart:Xe=>{mh(Xe),Wc(null);const Ae=X.relativePath||qo(l??"",X.path);!Ae||Ae==="."||(Xe.dataTransfer.setData(Bo,Ae),Xe.dataTransfer.effectAllowed="copy")},onDragEnd:Xe=>{gh(Xe)&&qe(X)},className:ve("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",ou(le)),title:X.path,children:[n.jsx(Oa,{filePath:X.path,extension:X.extension,className:"size-3.5"}),n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`${X.relativePath??X.path}`})]})},X.path)}):mt?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:mt}),n.jsxs(Ct,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Me()},children:[n.jsx(Z,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):ft&&l?lt(l,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:s("sidebarFilesTree.state.loading")})})}),St?n.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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(Z,{name:kt?"loader-4":"folder-received",className:ve("size-4 flex-shrink-0",kt&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:It,children:s(kt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:It})})]}):R?n.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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(Z,{name:"folder-received",className:"size-4 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:xe,children:s("sidebarFilesTree.drop.moveTarget",{path:xe})})]}):null]}),Bt,n.jsx(zs,{open:!!L,onOpenChange:X=>!X&&ie(null),children:n.jsxs($s,{children:[n.jsxs(qs,{children:[n.jsxs(Gs,{children:[L==="createFile"&&s("sidebarFilesTree.dialog.createFile.title"),L==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.title"),L==="rename"&&s("sidebarFilesTree.dialog.rename.title"),L==="delete"&&s("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(Us,{children:[L==="createFile"&&s("sidebarFilesTree.dialog.createFile.description",{path:G?.path??s("sidebarFilesTree.dialog.rootFallback")}),L==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.description",{path:G?.path??s("sidebarFilesTree.dialog.rootFallback")}),L==="rename"&&s("sidebarFilesTree.dialog.rename.description",{name:G?.name??""}),L==="delete"&&s("sidebarFilesTree.dialog.delete.description",{name:G?.name??""})]})]}),L!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(ho,{value:ge,onChange:X=>me(X.target.value),placeholder:s(L==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:X=>{X.key==="Enter"&&ue()},autoFocus:!0})}),n.jsxs(yn,{children:[n.jsx(Ct,{variant:"outline",onClick:()=>ie(null),disabled:be,children:s("sidebarFilesTree.dialog.cancel")}),n.jsx(Ct,{variant:L==="delete"?"destructive":"default",onClick:()=>{ue()},disabled:be||L!=="delete"&&!ge.trim(),children:be?n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}):s(L==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),n.jsx(zs,{open:T!==null,onOpenChange:X=>{X||z(null)},children:n.jsxs($s,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(qs,{children:[n.jsx(Gs,{children:s("sidebarFilesTree.dialog.move.title")}),n.jsx(Us,{children:T?s("sidebarFilesTree.dialog.move.description",{name:it,folder:ar(l,T.targetDirectory)}):null})]}),n.jsxs(yn,{className:"w-full sm:items-center sm:justify-between",children:[n.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>Q(!D),children:[n.jsx(Sy,{checked:!D,onChange:X=>Q(!X),ariaLabel:s("sidebarFilesTree.dialog.move.neverAsk")}),n.jsx("span",{children:s("sidebarFilesTree.dialog.move.neverAsk")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ct,{variant:"ghost",onClick:()=>z(null),children:s("sidebarFilesTree.dialog.cancel")}),n.jsx(Ct,{onClick:Wt,children:s("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function _k(t){return t.runtimeKey}const $k=nr(()=>ss(()=>import("./WalkthroughView-DcxbT5tc.js"),__vite__mapDeps([130,1,2,9,3,4,5,6,7,8,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,131,83,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,132,86,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.WalkthroughView}))),zk=nr(()=>ss(()=>import("./DiffView-SHdJJ6tl.js"),__vite__mapDeps([133,1,2,3,4,5,6,7,8,131,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,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,134,86,115,116,117,118,119,120,85,121,122,123])).then(t=>({default:t.DiffView}))),Wk=nr(()=>ss(()=>import("./FilesView-BeMtsSlV.js"),__vite__mapDeps([135,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,125,126,127,128,122,136,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,137,138,119,120,83,117,139,118,129,140])).then(t=>({default:t.FilesView}))),wh=c.lazy(()=>ss(()=>import("./useAppFontEffects-3EN8Ava3.js").then(t=>t.nm),__vite__mapDeps([9,1,2,3,4,5,6,7,8,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}))),Hc=c.lazy(()=>ss(()=>import("./GuestSurfacePane-4kmEXPLD.js"),__vite__mapDeps([141,1,2,9,3,4,5,6,7,8,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.GuestSurfacePane}))),kh={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-e border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-s border-border",vertical:!1}},Kk=t=>{const e=He.c(12),{mode:s,docking:r}=t,[o,i]=c.useState(null),a=kh[r.dock],l=Math.max(ky,o??r.size),d=a.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==a.page||e[1]!==d?(u=ve("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,a.page),e[0]=a.page,e[1]=d,e[2]=u):u=e[2];let f;e[3]!==a.vertical||e[4]!==l?(f=a.vertical?{height:l}:{width:l},e[3]=a.vertical,e[4]=l,e[5]=f):f=e[5];let h;e[6]!==s?(h=n.jsx(wh,{mode:s,onResize:i}),e[6]=s,e[7]=h):h=e[7];let m;return e[8]!==u||e[9]!==f||e[10]!==h?(m=n.jsx("div",{className:u,style:f,children:h}),e[8]=u,e[9]=f,e[10]=h,e[11]=m):m=e[11],m},Hk=({visible:t,active:e,fill:s=!1,side:r})=>{const{t:o}=wt(),i=de(y=>y.contextEditorTreeWidth),a=de(y=>y.setContextEditorTreeWidth),[l,d]=c.useState(!1),u=c.useRef(0),f=c.useRef(i),h=c.useRef(null),m=c.useRef(null),g=c.useRef(null),b=c.useCallback(y=>{const w=g.current;w&&(w.style.width=`${y}px`,w.style.setProperty("--oc-editor-tree-width",`${y}px`))},[]),v=y=>{if(t){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}m.current=y.pointerId,d(!0),u.current=y.clientX,f.current=i,h.current=i,y.preventDefault()}},S=y=>{if(!l||m.current!==y.pointerId)return;const w=r==="left"?y.clientX-u.current:u.current-y.clientX,j=ba(y.currentTarget)?-w:w,k=Ii(f.current+j);h.current!==k&&(h.current=k,b(k))},x=y=>{if(m.current!==y.pointerId)return;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}const w=Ii(h.current??i);m.current=null,h.current=null,d(!1),a(w)},p=t?i:0;return n.jsxs("div",{ref:g,className:ve("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",s&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${l?h.current??p:p}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${l?h.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:ve("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!s&&n.jsx("div",{className:ve("absolute top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",r==="left"?"inset-e-0":"inset-s-0",l&&"bg-[var(--interactive-border)]"),onPointerDown:v,onPointerMove:S,onPointerUp:x,onPointerCancel:x,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:ve("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(Fk,{visible:t&&e})})]})},Cn=t=>{const e=He.c(12),{zone:s,isOpen:r,directoryKey:o,className:i,children:a}=t,l=de(Gk);let d;e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==s?(d=m=>{Lf(m,r,()=>{o&&l(o,s)},m.currentTarget.closest("[data-context-zone]"))},e[0]=l,e[1]=o,e[2]=r,e[3]=s,e[4]=d):d=e[4];const u=d;let f;e[5]!==a||e[6]!==i||e[7]!==u?(f=n.jsx("div",{className:i,onKeyDownCapture:u,children:a}),e[5]=a,e[6]=i,e[7]=u,e[8]=f):f=e[8];let h;return e[9]!==f||e[10]!==s?(h=n.jsx(yk,{zone:s,children:f}),e[9]=f,e[10]=s,e[11]=h):h=e[11],h},Vk=()=>{const{t}=wt(),e=vn()??"",s=c.useMemo(()=>e?vs(e):"",[e]),r=de(L=>s?L.contextPanelByDirectory[s]:void 0),o=de(L=>L.contextSurfaceZones),i=de(L=>L.contextPanelByDirectory),a=de(L=>L.closeContextPanelTab),l=de(L=>L.closeContextFile),d=de(L=>L.openContextPanelTab),u=de(L=>L.openAgentBrowserTab),f=de(L=>L.openContextFile),h=de(L=>L.contextEditorTreeVisible),m=de(L=>L.contextEditorVisible),g=de(L=>L.fileTreeSide),b=Fs(L=>L.setSelectedPath),v=vr(L=>L.headerSlot),S=c.useMemo(()=>r?.tabs??[],[r?.tabs]),x=Fi(L=>L.chatCovered),p=c.useMemo(()=>{const L=ie=>{const G=r?ao(r,o,ie):null,ae=ie==="bottom"&&x;return{activeTab:G,isOpen:!!(r&&Io(r,ie).isOpen&&G)&&!ae}};return{left:L("left"),right:L("right"),bottom:L("bottom")}},[x,r,o]),y={left:Jr(p.left.isOpen),right:Jr(p.right.isOpen),bottom:Jr(p.bottom.isOpen)},w=L=>!y[L],j=L=>{const ie=uo(o,L);return{zone:ie,...p[ie]}},k=j("file"),P=j("chat"),A=j("browser"),B=j("diff"),R=j("terminal"),E=j("walkthrough"),[T,z]=c.useState(()=>new Set),O=c.useCallback(L=>{z(ie=>ie.has(L)?ie:new Set(ie).add(L))},[]);c.useEffect(()=>Xw((L,ie)=>{const G=ie.directory?vs(ie.directory):s;if(!G)return null;const ae=u(G,L,ie.sessionId);return ae&&O(ae),ae}),[s,u,O]),c.useEffect(()=>wn(L=>{if(L.type!=="file-open-request")return;const ie=L.directory??e;ie&&f(ie,L.path)}),[e,f]);const W=A.activeTab?.mode==="browser"?A.activeTab.id:null;c.useEffect(()=>{Yw(s,W)},[s,W]);const D=k.activeTab;c.useEffect(()=>{!s||D?.mode!=="file"||!D.targetPath||b(s,D.targetPath,{allowOutsideRoot:!0})},[s,D,b]);const Q=c.useMemo(()=>S.some(L=>L.mode==="file"&&L.targetPath),[S]),N=c.useMemo(()=>S.some(L=>L.mode==="file"),[S]),C=Q&&(m||!h),I=k.activeTab?.mode==="file",H=c.useCallback(L=>{s&&l(s,L)},[l,s]),M=P.isOpen&&P.activeTab?.mode==="chat"?P.activeTab:null,_=M?Ya(M.dedupeKey):null,F=c.useMemo(()=>(M?.targetDirectory?vs(M.targetDirectory):"")||s||null,[M?.targetDirectory,s]),ee=c.useMemo(()=>_?{sessionId:_,directory:F}:null,[_,F]);c.useEffect(()=>{if(!F||!_||typeof window>"u")return;const L=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ci(F,_,!1);return}Uu(_),ci(F,_,!0)};L();const ie=window.setInterval(L,1e4);return window.addEventListener("focus",L),window.addEventListener("blur",L),document.addEventListener("visibilitychange",L),()=>{window.clearInterval(ie),window.removeEventListener("focus",L),window.removeEventListener("blur",L),document.removeEventListener("visibilitychange",L),ci(F,_,!1)}},[F,_]);const ne=B.activeTab,re=c.useCallback(L=>{!s||ne?.mode!=="diff"||d(s,{mode:"diff",targetPath:ne.targetPath,stagedDiff:L==="staged",diffScope:L})},[ne,s,d]),te=A.isOpen&&A.activeTab?.mode==="browser"?A.activeTab.id:null;c.useEffect(()=>{te&&O(te)},[te,O]);const{loadedBrowserTabs:K,sleepingBrowserTabs:q}=c.useMemo(()=>{const L=[],ie=[];for(const[ae,ge]of Object.entries(i)){const me=ae===s;for(const be of ge.tabs){if(be.mode!=="browser"||!me&&be.ownerSessionId===null)continue;const ye={directory:ae,id:be.id,targetPath:be.targetPath,ownerSessionId:be.ownerSessionId};(T.has(be.id)||me&&be.id===te?L:ie).push(ye)}}const G=ae=>`${ae.directory}\0${ae.id}`;return L.sort((ae,ge)=>G(ae)<G(ge)?-1:1),{loadedBrowserTabs:L,sleepingBrowserTabs:ie}},[i,s,te,T]);c.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const L=q.map(ie=>qw({tabId:ie.id,directory:ie.directory,ownerSessionId:ie.ownerSessionId,describe:()=>({title:"",url:ie.targetPath??""}),wake:()=>O(ie.id)}));return()=>L.forEach(ie=>ie())},[q,O]);const oe=c.useMemo(()=>S.filter(L=>L.mode==="diff"),[S]),fe=c.useMemo(()=>S.find(L=>L.mode==="terminal")??null,[S]),ce=c.useMemo(()=>S.some(L=>L.mode==="walkthrough"),[S]),ke=c.useMemo(()=>S.filter(L=>Yn(L.mode)),[S]),De=Ia(L=>L.guests),Ce=c.useMemo(()=>new Set(De.filter(vy).map(L=>L.id)),[De]),Y=c.useMemo(()=>{const L=new Map;for(const ie of De){const G=wy(ie);G&&L.set(ie.id,G)}return L},[De]),je=R.zone,we=c.useCallback(L=>{const ie=Qa({mode:"terminal",label:t("layout.mainTab.terminal"),from:je},L);return{finish:()=>ie.finish(s),cancel:ie.cancel}},[s,t,je]),Pe=(L,ie)=>ie?v[L]:null;return n.jsxs(n.Fragment,{children:[N?n.jsxs(Cn,{zone:k.zone,isOpen:k.isOpen,directoryKey:s,className:ve("absolute inset-0 flex",g==="left"&&"flex-row-reverse",I?"flex":"hidden"),children:[Q||!h?n.jsx("div",{className:ve("h-full min-w-0 flex-1",Q&&!C&&"hidden"),children:Q?n.jsx(c.Suspense,{fallback:null,children:n.jsx(Wk,{mode:"editor-only",visible:!w(k.zone)&&I&&C,onCloseFile:H})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx(Z,{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(Hk,{visible:h,active:k.isOpen&&I,fill:!C,side:g})]}):null,M&&_&&ee?n.jsx(Cn,{zone:P.zone,isOpen:P.isOpen,directoryKey:s,className:"absolute inset-0 bg-background",children:n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:_}),className:"h-full",children:n.jsx(au,{pinnedSession:ee,readOnly:M.readOnly})})},M.id):null,K.map(L=>{const ie=L.directory===s&&A.activeTab?.id===L.id;return n.jsx(Cn,{zone:A.zone,isOpen:A.isOpen,directoryKey:s,className:ve("absolute inset-0",!ie&&"invisible pointer-events-none"),children:n.jsx("div",{className:"h-full","aria-hidden":!ie||void 0,children:n.jsx(hk,{initialUrl:L.targetPath??"",directory:L.directory,tabID:L.id,ownerSessionId:L.ownerSessionId,visible:ie&&A.isOpen})})},`${L.directory}\0${L.id}`)}),oe.map(L=>{const ie=B.activeTab?.id===L.id;return n.jsx(Cn,{zone:B.zone,isOpen:B.isOpen,directoryKey:s,className:ve("absolute inset-0",!ie&&"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(Tn,{value:Pe(B.zone,ie),children:n.jsx(zk,{visible:B.isOpen&&ie,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:L.diffScope??(L.stagedDiff?"staged":null),onDiffScopeChange:re,targetFilePath:L.targetPath,flushContent:!0})})})},L.id)}),fe?n.jsx(Cn,{zone:R.zone,isOpen:R.isOpen,directoryKey:s,className:ve("absolute inset-0",R.activeTab?.mode==="terminal"?"block":"hidden"),children:n.jsx(Tn,{value:Pe(R.zone,R.activeTab?.mode==="terminal"),children:n.jsx(yg.Provider,{value:we,children:n.jsx(xg,{visible:R.isOpen&&R.activeTab?.mode==="terminal",directory:fe.targetDirectory,onLastTabClosed:()=>{s&&a(s,fe.id)}})})})}):null,ce?n.jsx(Cn,{zone:E.zone,isOpen:E.isOpen,directoryKey:s,className:ve("absolute inset-0",E.activeTab?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(Tn,{value:Pe(E.zone,E.activeTab?.mode==="walkthrough"),children:n.jsx($k,{directory:e,visible:E.isOpen&&E.activeTab?.mode==="walkthrough"})})})}):null,ke.map(L=>{if(!Yn(L.mode))return null;const ie=j(L.mode),G=lo(L.mode),ae=Ce.has(G),ge=Y.get(G),me=ie.activeTab?.id===L.id,be=me&&ie.isOpen;return ae&&!ge&&!be?null:n.jsx(Cn,{zone:ie.zone,isOpen:ie.isOpen,directoryKey:s,className:ve("absolute inset-0",me?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:ae?ge?n.jsxs("div",{className:ve("flex h-full",kh[ge.dock].container),children:[n.jsx(Kk,{mode:L.mode,docking:ge}),n.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:be?n.jsx(Hc,{mode:L.mode}):null})]}):n.jsx(Hc,{mode:L.mode}):n.jsx(wh,{mode:L.mode})})},L.id)})]})};function Gk(t){return t.closeContextZone}const Uk={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},qk=()=>{const t=He.c(20),{t:e}=wt(),s=on(Yk),r=on(Xk),o=c.useRef(null),[i,a]=c.useState(!1);let l,d;t[0]!==s?(l=()=>{if(!s){a(!1);return}const x=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(x)},d=[s],t[0]=s,t[1]=l,t[2]=d):(l=t[1],d=t[2]),c.useEffect(l,d);let u,f;if(t[3]!==s?(u=()=>{if(!s)return;const x=p=>{const y=o.current;y&&(y.style.transform=`translate(${p.clientX+12}px, ${p.clientY+12}px)`)};return window.addEventListener("pointermove",x),()=>window.removeEventListener("pointermove",x)},f=[s],t[3]=s,t[4]=u,t[5]=f):(u=t[4],f=t[5]),c.useEffect(u,f),!s)return null;const h=i?"opacity-100":"opacity-0";let m;t[6]!==h?(m=ve("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",h),t[6]=h,t[7]=m):m=t[7];let g;t[8]!==m?(g=n.jsx("div",{className:m}),t[8]=m,t[9]=g):g=t[9];let b;t[10]!==s.frames||t[11]!==r||t[12]!==e?(b=pm.map(x=>{const p=s.frames[x];if(p.width<=0||p.height<=0)return null;const y=r===x;return n.jsx("div",{className:ve("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",y?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:p.left,top:p.top,width:p.width,height:p.height},children:n.jsx("span",{className:"typography-ui-label",children:e(Uk[x])})},x)}),t[10]=s.frames,t[11]=r,t[12]=e,t[13]=b):b=t[13];let v;t[14]!==s.label?(v=n.jsx("div",{ref:o,className:"absolute left-0 top-0 rounded-md border border-border bg-background px-2 py-1 typography-meta text-foreground shadow-sm",children:s.label}),t[14]=s.label,t[15]=v):v=t[15];let S;return t[16]!==g||t[17]!==b||t[18]!==v?(S=ga.createPortal(n.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[g,b,v]}),document.body),t[16]=g,t[17]=b,t[18]=v,t[19]=S):S=t[19],S};function Yk(t){return t.drag}function Xk(t){return t.hovered}const Vc=400,Qk=({rowWidth:t,leftWidth:e,rightWidth:s,sidebarWidth:r,opening:o})=>{let i=t-e-s;if(i>=Vc)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Vc)return{collapseSidebar:a,displace:null};const l=o==="left"?"right":"left";return{collapseSidebar:a,displace:(l==="left"?e:s)>0?l:null}},Zk=()=>{const t=He.c(5),e=vn();let s;t[0]!==e?(s=e?vs(e):"",t[0]=e,t[1]=s):s=t[1];const r=s,o=c.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(!r)return;const l=S=>{const x=S.contextPanelByDirectory[r];return{left:hr(x,S.contextSurfaceZones,"left"),right:hr(x,S.contextSurfaceZones,"right")}},d=(S,x,p)=>{const y=S.contextPanelByDirectory[r],w=p&&y?ao(y,S.contextSurfaceZones,x):null;return w?y?.widthByMode[w.mode]??Li(w.mode):0};let u=null,f=!1,h=l(de.getState());const m=S=>{f=!0,de.getState().setSidebarOpen(S),f=!1},g=o.current;g&&!h[g]&&(o.current=null,de.getState().isSidebarOpen||m(!0));const b=(S,x,p)=>{const y=document.querySelector("[data-workspace-row]")?.clientWidth;if(!y)return;const w=Qk({rowWidth:y,leftWidth:d(S,"left",p.left),rightWidth:d(S,"right",p.right),sidebarWidth:S.isSidebarOpen?S.sidebarWidth:null,opening:x});if(w.displace){const j=Io(S.contextPanelByDirectory[r],w.displace).activeTabId;j&&(u={side:w.displace,by:x,tabId:j})}w.collapseSidebar&&(o.current=x,m(!1)),w.displace&&S.closeContextZone(r,w.displace)},v=S=>{if(u?.side===S){o.current===S&&(o.current=u.by);return}const x=u?.by===S?u:null;x&&(u=null),o.current===S&&(x?o.current=x.side:(o.current=null,de.getState().isSidebarOpen||m(!0))),x&&de.getState().setActiveContextPanelTab(r,x.tabId)};return de.subscribe((S,x)=>{S.isSidebarOpen!==x.isSidebarOpen&&!f&&(o.current=null);const p=l(S),y=h;h=p;const w=["left","right"],j=w.filter(P=>p[P]&&!y[P]),k=w.filter(P=>!p[P]&&y[P]);for(const P of k){const A=P==="left"?"right":"left";j.includes(A)&&(o.current===P&&(o.current=A),u?.by===P&&(u=null))}for(const P of k)v(P);for(const P of j)b(S,P,p)})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),c.useEffect(i,a),null},Jk=t=>{const e=He.c(43),{open:s,onOpenChange:r}=t,{t:o}=wt(),i=de(ej),a=de(tj),l=de(sj),d=de(nj),u=Ba();let f;e[0]!==i||e[1]!==u?(f=qu(i,u),e[0]=i,e[1]=u,e[2]=f):f=e[2];const h=f,m=a.length===0;let g;if(e[3]!==a||e[4]!==h){let B;e[6]!==a?(B=R=>a.includes(R.id),e[6]=a,e[7]=B):B=e[7],g=h.every(B),e[3]=a,e[4]=h,e[5]=g}else g=e[5];const b=g;let v;e[8]!==o?(v=o("contextRail.configure.dialogTitle"),e[8]=o,e[9]=v):v=e[9];let S;e[10]!==v?(S=n.jsx(Gs,{children:v}),e[10]=v,e[11]=S):S=e[11];let x;e[12]!==o?(x=o("contextRail.configure.dialogDescription"),e[12]=o,e[13]=x):x=e[13];let p;e[14]!==x?(p=n.jsx(Us,{children:x}),e[14]=x,e[15]=p):p=e[15];let y;e[16]!==S||e[17]!==p?(y=n.jsxs(qs,{children:[S,p]}),e[16]=S,e[17]=p,e[18]=y):y=e[18];let w;if(e[19]!==a||e[20]!==l||e[21]!==h||e[22]!==o){let B;e[24]!==a||e[25]!==l||e[26]!==o?(B=R=>n.jsx(jy,{settingsItem:`layout.context-rail.surface.${R.id}`,checked:!a.includes(R.id),onChange:E=>l(R.id,E),label:R.label??o(R.labelKey),ariaLabel:R.label??o(R.labelKey)},R.id),e[24]=a,e[25]=l,e[26]=o,e[27]=B):B=e[27],w=h.map(B),e[19]=a,e[20]=l,e[21]=h,e[22]=o,e[23]=w}else w=e[23];let j;e[28]!==w?(j=n.jsx("div",{className:"flex flex-col",children:w}),e[28]=w,e[29]=j):j=e[29];let k;e[30]!==m||e[31]!==b||e[32]!==d||e[33]!==o?(k=m?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[b?n.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(Ct,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[30]=m,e[31]=b,e[32]=d,e[33]=o,e[34]=k):k=e[34];let P;e[35]!==k||e[36]!==y||e[37]!==j?(P=n.jsxs($s,{className:"max-w-md",children:[y,j,k]}),e[35]=k,e[36]=y,e[37]=j,e[38]=P):P=e[38];let A;return e[39]!==r||e[40]!==s||e[41]!==P?(A=n.jsx(zs,{open:s,onOpenChange:r,children:P}),e[39]=r,e[40]=s,e[41]=P,e[42]=A):A=e[42],A};function ej(t){return t.contextRailOrder}function tj(t){return t.contextRailHiddenSurfaces}function sj(t){return t.setContextRailSurfaceVisible}function nj(t){return t.setContextRailHiddenSurfaces}const rj=t=>{const e=zu(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},oj=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,jh=()=>{const t=He.c(4),e=nt(lj),s=nt(cj)??void 0,r=Py(e??"",s,rj,oj),{context:o}=Ey(e,s),i=o>0?o:Ny;let a;return t[0]!==r||t[1]!==i||t[2]!==e?(a={sessionId:e,fill:r,limit:i},t[0]=r,t[1]=i,t[2]=e,t[3]=a):a=t[3],a},Gc=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),Zs=18,oa=2,ia=(Zs-oa)/2,Uc=2*Math.PI*ia,ij=t=>{const e=He.c(8),{className:s}=t,{fill:r,limit:o}=jh(),i=r?.state==="measured"?Math.min(100,r.totalTokens/o*100):0;let a;e[0]!==s?(a=ve("shrink-0",s),e[0]=s,e[1]=a):a=e[1];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("circle",{cx:Zs/2,cy:Zs/2,r:ia,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:oa}),e[2]=l):l=e[2];let d;e[3]!==i?(d=i>0?n.jsx("circle",{cx:Zs/2,cy:Zs/2,r:ia,fill:"none",stroke:"currentColor",strokeWidth:oa,strokeLinecap:"round",strokeDasharray:Uc,strokeDashoffset:Uc*(1-i/100),transform:`rotate(-90 ${Zs/2} ${Zs/2})`}):null,e[3]=i,e[4]=d):d=e[4];let u;return e[5]!==a||e[6]!==d?(u=n.jsxs("svg",{viewBox:`0 0 ${Zs} ${Zs}`,className:a,"aria-hidden":"true",children:[l,d]}),e[5]=a,e[6]=d,e[7]=u):u=e[7],u},aj=()=>{const t=He.c(16),{t:e}=wt(),{sessionId:s,fill:r,limit:o}=jh(),{totalCost:i}=Cy(s);if(!s||!r)return null;let a;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(a=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:Gc(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=a):a=t[3];let l;t[4]!==o||t[5]!==e?(l=e("contextUsage.tooltip.contextLimit",{tokens:Gc(o)}),t[4]=o,t[5]=e,t[6]=l):l=t[6];let d;t[7]!==e||t[8]!==i?(d=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:kf(i)})]:[],t[7]=e,t[8]=i,t[9]=d):d=t[9];let u;t[10]!==a||t[11]!==l||t[12]!==d?(u=[a,l,...d],t[10]=a,t[11]=l,t[12]=d,t[13]=u):u=t[13];const f=u;let h;return t[14]!==f?(h=n.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-border/60 pt-1 tabular-nums",children:f.map(dj)}),t[14]=f,t[15]=h):h=t[15],h};function lj(t){return t.currentSessionId}function cj(t){return t.currentSessionDirectory}function dj(t){return n.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const Ch=150,uj=500,fj=[],hj=t=>t>99?"99+":String(t),pj=t=>{const e=He.c(62),{surface:s,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:l,badgeAriaLabel:d,badgeDescription:u,orderNumber:f,showOrderNumber:h,onSelect:m}=t;let g;e[0]!==s.id?(g={id:s.id},e[0]=s.id,e[1]=g):g=e[1];const{attributes:b,listeners:v,setNodeRef:S,transform:x,transition:p,isDragging:y}=Ho(g);let w;e[2]!==l?(w=l!=null&&l>0?hj(l):null,e[2]=l,e[3]=w):w=e[3];const j=w;let k;e[4]!==x?(k=Vo.Translate.toString(x),e[4]=x,e[5]=k):k=e[5];let P;e[6]!==k||e[7]!==p?(P={transform:k,transition:p},e[6]=k,e[7]=p,e[8]=P):P=e[8];const A=y&&"z-10 opacity-70";let B;e[9]!==A?(B=ve("relative",A),e[9]=A,e[10]=B):B=e[10];let R;e[11]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("div",{}),e[11]=R):R=e[11];let E;e[12]!==m||e[13]!==s?(E=()=>m(s),e[12]=m,e[13]=s,e[14]=E):E=e[14];const T=d??i,z=s.id,O=r?"text-primary":"text-muted-foreground hover:text-foreground";let W;e[15]!==O?(W=ve("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",O),e[15]=O,e[16]=W):W=e[16];let D;e[17]!==s.icon||e[18]!==s.iconSrc||e[19]!==s.id?(D=s.id==="diff"?n.jsx(ru,{className:"h-[18px] w-[18px]"}):s.id==="context"?n.jsx(ij,{className:"h-[18px] w-[18px]"}):n.jsx(sr,{icon:s.icon,iconSrc:s.iconSrc,className:"h-[18px] w-[18px]"}),e[17]=s.icon,e[18]=s.iconSrc,e[19]=s.id,e[20]=D):D=e[20];let Q;e[21]!==j||e[22]!==f||e[23]!==o||e[24]!==h?(Q=h&&f!=null?n.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-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 -inset-e-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:j}):o?n.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[21]=j,e[22]=f,e[23]=o,e[24]=h,e[25]=Q):Q=e[25];let N;e[26]!==b||e[27]!==r||e[28]!==v||e[29]!==s.id||e[30]!==W||e[31]!==D||e[32]!==Q||e[33]!==E||e[34]!==T?(N=n.jsx(At,{asChild:!0,children:n.jsxs("button",{type:"button",...b,...v,onClick:E,"aria-label":T,"aria-pressed":r,"data-context-surface":z,className:W,children:[D,Q]})}),e[26]=b,e[27]=r,e[28]=v,e[29]=s.id,e[30]=W,e[31]=D,e[32]=Q,e[33]=E,e[34]=T,e[35]=N):N=e[35];let C;e[36]!==i?(C=n.jsx("span",{children:i}),e[36]=i,e[37]=C):C=e[37];let I;e[38]!==a?(I=n.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[38]=a,e[39]=I):I=e[39];let H;e[40]!==u?(H=u?n.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[40]=u,e[41]=H):H=e[41];let M;e[42]!==s.id?(M=s.id==="context"?n.jsx(aj,{}):null,e[42]=s.id,e[43]=M):M=e[43];let _;e[44]!==C||e[45]!==I||e[46]!==H||e[47]!==M?(_=n.jsx(Tt,{side:"left",sideOffset:8,children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[C,I,H,M]})}),e[44]=C,e[45]=I,e[46]=H,e[47]=M,e[48]=_):_=e[48];let F;e[49]!==N||e[50]!==_?(F=n.jsx(La,{render:R,children:n.jsxs(Ot,{delayDuration:Ch,children:[N,_]})}),e[49]=N,e[50]=_,e[51]=F):F=e[51];let ee;e[52]!==s.mode?(ee=n.jsx(Fa,{children:n.jsx(nu,{mode:s.mode})}),e[52]=s.mode,e[53]=ee):ee=e[53];let ne;e[54]!==F||e[55]!==ee?(ne=n.jsxs(_a,{children:[F,ee]}),e[54]=F,e[55]=ee,e[56]=ne):ne=e[56];let re;return e[57]!==S||e[58]!==ne||e[59]!==P||e[60]!==B?(re=n.jsx("div",{ref:S,style:P,className:B,children:ne}),e[57]=S,e[58]=ne,e[59]=P,e[60]=B,e[61]=re):re=e[61],re},mj=()=>{const t=He.c(99),{t:e}=wt(),s=vn();let r;t[0]!==s?(r=s?vs(s):"",t[0]=s,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=he=>o?he.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=de(i),l=de(gj),d=de(bj),u=de(yj),f=de(xj),h=de(Sj),m=de(vj),g=de(wj),b=de(kj),v=Ra(jj),S=Mu(Au)?.hasChecked??!1,x=mn(Pj),p=Hu(o||null),{screenWidth:y}=Mn(),w=Aa(o||null);let j;t[4]!==b?(j=Iy("switch_context_surface",b),t[4]=b,t[5]=j):j=t[5];const k=j,[P,A]=c.useState(!1);let B,R;t[6]!==k?(B=()=>{const he=new Set;let se=null,Ne=!1;const Ue=Ej,We=()=>{Ql(k,he)?!Ne&&se===null&&(se=setTimeout(()=>A(!0),uj)):(Ne=!1,se!==null&&(clearTimeout(se),se=null),A(!1))},Ke=Me=>{if(he.add(Me.key.toLowerCase()),Ue(Me.key)&&Ql(k,he)){Ne=!0,se!==null&&(clearTimeout(se),se=null),A(!1);return}We()},Be=Me=>{he.delete(Me.key.toLowerCase()),We()},U=()=>{he.clear(),Ne=!1,se!==null&&(clearTimeout(se),se=null),A(!1)};return window.addEventListener("keydown",Ke,!0),window.addEventListener("keyup",Be,!0),window.addEventListener("blur",U),()=>{window.removeEventListener("keydown",Ke,!0),window.removeEventListener("keyup",Be,!0),window.removeEventListener("blur",U),se!==null&&clearTimeout(se)}},R=[k],t[6]=k,t[7]=B,t[8]=R):(B=t[7],R=t[8]),c.useEffect(B,R);let E;t[9]===Symbol.for("react.memo_cache_sentinel")?(E={activationConstraint:{distance:8}},t[9]=E):E=t[9];let T;t[10]===Symbol.for("react.memo_cache_sentinel")?(T={activationConstraint:{delay:200,tolerance:6}},t[10]=T):T=t[10];const z=_o(sn(zo,E),sn($o,T)),O=Ba(),W=Xl(Nj),D=Xl(Ij),Q=a?.tabs??fj;let N;t[11]!==g||t[12]!==a?(N=ya(a,g),t[11]=g,t[12]=a,t[13]=N):N=t[13];const C=N,I=w?.files.length??0;let H;if(t[14]!==u||t[15]!==d||t[16]!==O||t[17]!==v||t[18]!==p||t[19]!==y||t[20]!==x||t[21]!==Q){let he;t[23]!==p?(he=se=>se.id==="pr"&&p==="gitlab"?{...se,icon:"gitlab"}:se,t[23]=p,t[24]=he):he=t[24],H=Ry({railOrder:d,hiddenSurfaces:u,planModeEnabled:v,isVSCode:Sn(),screenWidth:y,tabs:Q,sourceControlConnected:x,extras:O}).map(he),t[14]=u,t[15]=d,t[16]=O,t[17]=v,t[18]=p,t[19]=y,t[20]=x,t[21]=Q,t[22]=H}else H=t[22];const M=H;let _,F;t[25]!==m||t[26]!==g||t[27]!==o||t[28]!==S||t[29]!==C||t[30]!==x?(F=()=>{!o||!S||x||!C.has("pr")||m(o,uo(g,"pr"))},_=[m,g,o,S,C,x],t[25]=m,t[26]=g,t[27]=o,t[28]=S,t[29]=C,t[30]=x,t[31]=_,t[32]=F):(_=t[31],F=t[32]),c.useEffect(F,_);const[ee,ne]=c.useState(!1),re=c.useRef(null),te=c.useRef(null);let K;t[33]!==p||t[34]!==M||t[35]!==e?(K=he=>{const se=M.find(Ue=>Ue.id===he.active.id),Ne=re.current?.getBoundingClientRect().left;!se||Ne===void 0||(te.current?.cancel(),te.current=Qa({mode:se.mode,label:se.label??e(en(se.labelKey,p)),from:uo(de.getState().contextSurfaceZones,se.mode)},Ue=>Ue.x<Ne-16))},t[33]=p,t[34]=M,t[35]=e,t[36]=K):K=t[36];const q=K;let oe;t[37]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>{te.current?.cancel(),te.current=null},t[37]=oe):oe=t[37];const fe=oe;let ce,ke;t[38]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>()=>te.current?.cancel(),ke=[],t[38]=ce,t[39]=ke):(ce=t[38],ke=t[39]),c.useEffect(ce,ke);let De;t[40]!==o||t[41]!==O||t[42]!==f?(De=he=>{const se=te.current;if(te.current=null,se?.finish(o))return;const{active:Ne,over:Ue}=he;if(!Ue||Ne.id===Ue.id)return;const We=qu(de.getState().contextRailOrder,O).map(Rj),Ke=We.indexOf(Ne.id),Be=We.indexOf(Ue.id);Ke===-1||Be===-1||f(jf(We,Ke,Be))},t[40]=o,t[41]=O,t[42]=f,t[43]=De):De=t[43];const Ce=De;if(!o)return null;let Y;t[44]!==e?(Y=e("contextRail.aria.rail"),t[44]=e,t[45]=Y):Y=t[45];let je;t[46]!==M?(je=M.map(Dj),t[46]=M,t[47]=je):je=t[47];let we;if(t[48]!==I||t[49]!==D||t[50]!==o||t[51]!==W||t[52]!==h||t[53]!==p||t[54]!==P||t[55]!==C||t[56]!==M||t[57]!==e||t[58]!==l){let he;t[60]!==I||t[61]!==D||t[62]!==o||t[63]!==W||t[64]!==h||t[65]!==p||t[66]!==P||t[67]!==C||t[68]!==e||t[69]!==l?(he=(se,Ne)=>{const Ue=se.label??e(en(se.labelKey,p)),We=se.id==="git"&&!l?I:0,Ke=Yn(se.mode)&&!C.has(se.mode)?W[lo(se.mode)]??0:0,Be=We>0?We:Ke>0?Ke:null,U=Be!==null&&We===0;return n.jsx(pj,{surface:se,isActive:C.has(se.mode),showActivityDot:!1,label:Ue,description:e(en(se.descriptionKey,p)),badgeCount:Be,badgeAriaLabel:Be!==null?e(U?Be===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":Be===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:Ue,count:Be}):null,badgeDescription:Be!==null?e(U?Be===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":Be===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:Be}):null,orderNumber:Ne+1,showOrderNumber:P,onSelect:Me=>{Yn(Me.mode)&&D(lo(Me.mode)),h(o,Me.mode)}},se.id)},t[60]=I,t[61]=D,t[62]=o,t[63]=W,t[64]=h,t[65]=p,t[66]=P,t[67]=C,t[68]=e,t[69]=l,t[70]=he):he=t[70],we=M.map(he),t[48]=I,t[49]=D,t[50]=o,t[51]=W,t[52]=h,t[53]=p,t[54]=P,t[55]=C,t[56]=M,t[57]=e,t[58]=l,t[59]=we}else we=t[59];let Pe;t[71]!==je||t[72]!==we?(Pe=n.jsx(Ga,{items:je,strategy:Cf,children:we}),t[71]=je,t[72]=we,t[73]=Pe):Pe=t[73];let L;t[74]!==Ce||t[75]!==q||t[76]!==z||t[77]!==Pe?(L=n.jsx(Wo,{sensors:z,collisionDetection:Ko,onDragStart:q,onDragCancel:fe,onDragEnd:Ce,children:Pe}),t[74]=Ce,t[75]=q,t[76]=z,t[77]=Pe,t[78]=L):L=t[78];let ie;t[79]!==e?(ie=e("contextRail.configure.open"),t[79]=e,t[80]=ie):ie=t[80];let G;t[81]===Symbol.for("react.memo_cache_sentinel")?(G=()=>ne(!0),t[81]=G):G=t[81];let ae;t[82]===Symbol.for("react.memo_cache_sentinel")?(ae=n.jsx(Z,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[82]=ae):ae=t[82];let ge;t[83]!==ie?(ge=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":ie,onClick:G,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:ae})}),t[83]=ie,t[84]=ge):ge=t[84];let me;t[85]!==e?(me=e("contextRail.configure.open"),t[85]=e,t[86]=me):me=t[86];let be;t[87]!==me?(be=n.jsx(Tt,{side:"left",sideOffset:8,children:me}),t[87]=me,t[88]=be):be=t[88];let ye;t[89]!==ge||t[90]!==be?(ye=n.jsxs(Ot,{delayDuration:Ch,children:[ge,be]}),t[89]=ge,t[90]=be,t[91]=ye):ye=t[91];let Te;t[92]!==ee?(Te=n.jsx(Jk,{open:ee,onOpenChange:ne}),t[92]=ee,t[93]=Te):Te=t[93];let $;return t[94]!==Y||t[95]!==L||t[96]!==ye||t[97]!==Te?($=n.jsxs("nav",{ref:re,"aria-label":Y,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",children:[L,ye,Te]}),t[94]=Y,t[95]=L,t[96]=ye,t[97]=Te,t[98]=$):$=t[98],$};function gj(t){return t.workStatusPanelVisible}function bj(t){return t.contextRailOrder}function yj(t){return t.contextRailHiddenSurfaces}function xj(t){return t.setContextRailOrder}function Sj(t){return t.openContextSurface}function vj(t){return t.closeContextZone}function wj(t){return t.contextSurfaceZones}function kj(t){return t.shortcutOverrides}function jj(t){return t.planModeEnabled}function Cj(t){return t.status?.status==="connected"}function Pj(t){return Object.values(t.entries).some(Cj)}function Ej(t){return t.length===1&&t>="0"&&t<="9"}function Nj(t){return t.countByGuest}function Ij(t){return t.clearBadge}function Rj(t){return t.id}function Dj(t){return t.id}const Tj=t=>{const e=He.c(16),{enabled:s,isSessionSearchOpen:r,openSessionSearch:o,closeSessionSearch:i,sessionSearchInputRef:a,sessionSearchContainerRef:l}=t,d=s===void 0?!0:s;let u,f;e[0]!==d||e[1]!==r||e[2]!==a?(u=()=>{if(!d||!r||typeof window>"u")return;const v=window.requestAnimationFrame(()=>{a.current?.focus(),a.current?.select()});return()=>window.cancelAnimationFrame(v)},f=[d,r,a],e[0]=d,e[1]=r,e[2]=a,e[3]=u,e[4]=f):(u=e[3],f=e[4]),c.useEffect(u,f);let h,m;e[5]!==d||e[6]!==o||e[7]!==a?(h=()=>{if(!d||typeof window>"u")return;const v=()=>{o(),a.current?.focus(),a.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",v),()=>window.removeEventListener("openchamber:sidebar-session-search",v)},m=[d,o,a],e[5]=d,e[6]=o,e[7]=a,e[8]=h,e[9]=m):(h=e[8],m=e[9]),c.useEffect(h,m);let g,b;e[10]!==i||e[11]!==d||e[12]!==r||e[13]!==l?(g=()=>{if(!d||!r||typeof document>"u")return;const v=S=>{l.current&&(l.current.contains(S.target)||i())};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},b=[d,r,i,l],e[10]=i,e[11]=d,e[12]=r,e[13]=l,e[14]=g,e[15]=b):(g=e[14],b=e[15]),c.useEffect(g,b)},Mj=t=>{const e=He.c(4);let s;e[0]!==t?(s=(i,a)=>{const l=t.get(i);if(!l||l.length===0)return a;const d=new Map(a.map(Aj)),u=[];l.forEach(m=>{const g=d.get(m);g&&(u.push(g),d.delete(m))});const f=[],h=[];return a.forEach(m=>{d.has(m.id)&&(m.isArchivedBucket?h.push(m):f.push(m))}),[...f,...u,...h]},e[0]=t,e[1]=s):s=e[1];const r=s;let o;return e[2]!==r?(o={getOrderedGroups:r},e[2]=r,e[3]=o):o=e[3],o};function Aj(t){return[t.id,t]}const Oj=(t,e)=>{const s=t.groups.find(i=>i.isMain&&i.sessions.length>0)??t.groups.find(i=>i.sessions.length>0)??t.groups.find(i=>i.isMain)??t.groups[0];if(!s)return[];const r=t.groups.find(i=>i.isArchivedBucket&&i.id!==s.id);return(e.mainWorkspaceOnly?[s,...r?[r]:[]]:[...t.groups.find(i=>i.isMain)?[t.groups.find(i=>i.isMain)]:[],...t.groups.filter(i=>!i.isMain)]).map(i=>({group:i,groupKey:`${t.project.id}:${i.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?i.id===s.id:i.isMain}))},qc=(t,e,s)=>{if(!e)return;const r=o=>{let i=o.session.id===e;for(const a of o.children)i=r(a)||i;return i&&s.add(o.session.id),i};for(const o of t)r(o)},Jn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const s of t.children)if(Jn(s,e))return!0;return!1},Bj=({isSubtaskSession:t,archivedBucket:e,isVSCode:s,sessionDirectory:r})=>!t&&!e&&!s&&!xa(r),Fj=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:s})=>!t||e||s,aa=(t,e,s)=>{const r=new Map,o=i=>{const a=Xn(i.session)??ot(i.worktree?.path)??s;if(a){const l=r.get(a)??[];l.push(i.session.id),r.set(a,l)}if(!(i===t&&e))for(const l of i.children)o(l)};return o(t),[...r].map(([i,a])=>({directory:i,sessionIDs:a}))},la=(t,e)=>{const s=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const o=new Set;let i=r.session.parentID??null;for(;i&&!o.has(i);){if(s.has(i)&&e.has(i))return!1;o.add(i),i=e.get(i)?.session?.parentID??null}return!0})},Ph=t=>{const e=new Map(t.map(a=>[a.id,a])),s=new Map;for(const a of t){if(!a.parentId||!e.has(a.parentId))continue;const l=s.get(a.parentId)??[];l.push(a),s.set(a.parentId,l)}const r=new Set,o=[],i=a=>{if(r.has(a.id))return;o.push(a);const l=[a.id];for(;l.length>0;){const d=l.pop();if(!(!d||r.has(d))){r.add(d);for(const u of s.get(d)??[])l.push(u.id)}}};return t.forEach(a=>{(!a.parentId||!e.has(a.parentId))&&i(a)}),t.forEach(i),o},Eh=(t,e)=>{const s=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),o=new Map,i=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){i.add(u.id);continue}if(u.parentId){const m=o.get(u.parentId)??[];m.push(u.id),o.set(u.parentId,m)}const f=new Set;let h=u.id;for(;h;){if(f.has(h)){i.add(u.id);break}f.add(h),h=r.get(h)?.parentId}}const a=new Set,l=new Set,d=u=>{if(a.has(u))return!0;if(l.has(u))return!1;const f=r.get(u);if(!f)return!1;l.add(u);let h=i.has(u);return!h&&e.archivedBucket&&f.nodeCount===0?h=(o.get(u)??[]).some(d):(!h&&!e.searchQuery&&(h=!0),!h&&(f.nodeCount>0||!s&&po([f.name],e.searchQuery))&&(h=!0),h||(h=(o.get(u)??[]).some(d))),l.delete(u),h&&a.add(u),h};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>a.has(u.id)).map(u=>u.id))},Yc=new WeakMap;let Xc=1;const Lj=t=>{const e=Yc.get(t);if(e!==void 0)return e;const s=Xc;return Xc+=1,Yc.set(t,s),s},kr=t=>t.children.length===0?"":t.children.map(s=>{const r=Lj(s.session);return s.children.length===0?`${s.session.id}@${r}`:`${s.session.id}@${r}:${kr(s)}`}).join("|"),Nh=(t,e,s,r,o,i)=>{const a=Yt(),l=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const f=d.session.directory??o,h=u.session.directory??i,m=Zl(a,f??"",d.session.id),g=Zl(a,h??"",u.session.id);return(m?s.has(m):!1)!==(g?r.has(g):!1)?!0:d.children.some((b,v)=>l(b,u.children[v]))};return l(t,e)},_j=(t,e)=>t?t.branchLabel??null:e??null,$j=(t,e)=>{if(e)return null;const s=t?.branch?.trim(),r=ot(t?.path??null);return s&&r?{directory:r,branch:s}:null},wo=(t,e,s,r)=>{if(!e)return null;const o=r?"archived":"active";let i=null;const a=l=>{if(`${s}:${o}:${l.session.id}`===e)return i=l.session.id,!0;for(const u of l.children)if(a(u))return!0;return!1};return t.forEach(l=>a(l)),i},In=(t,e)=>`${t}\0${e}`,Gn=(t,e)=>t??Sa(e)??ot(e??null),er=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??ot(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},ol=t=>t.startsWith("__archived__:"),il=(t,e)=>{const s=e.trim().toLowerCase();return s?s.startsWith("ses_")?t.id.toLowerCase()===s:(typeof t.title=="string"?t.title.toLowerCase():"").includes(e):!0},Ih=(t,e)=>il(t.session,e)||t.children.some(s=>Ih(s,e)),Rh=(t,e)=>(il(t.session,e)?1:0)+t.children.reduce((s,r)=>s+Rh(r,e),0),Qc=({sessions:t,getSessionLocation:e,getSessionNode:s,query:r})=>t.flatMap(o=>{if(!il(o,r))return[];const i=e(o.id);return[{node:s(o),projectId:i?.projectId??null,groupDirectory:i?.groupDirectory??o.directory??null,secondaryMeta:{projectLabel:i?.projectLabel??null,branchLabel:i?.branchLabel??null,inSpace:i?.inSpace??!1}}]}),Dh=["chats","work"],Un=t=>t==="timeline"||t==="timeline-mixed",$r=t=>"run"in t,zj=(t,e)=>`${t}:active:run:${e}`,vi=(t,e,s)=>{if(s||e.runKeyBySessionId.size===0)return[...t];const r=[],o=new Map;for(const i of t){const a=e.runKeyBySessionId.get(i.session.id),l=a?e.runs.get(a):void 0;if(!l){r.push(i);continue}const d=o.get(l.key);if(d){d.lanes.push(i);continue}const u={run:l,lanes:[i]};o.set(l.key,u),r.push(u)}for(const i of o.values()){const a=new Map(i.run.memberIds.map((l,d)=>[l,d]));i.lanes.sort((l,d)=>(a.get(l.session.id)??0)-(a.get(d.session.id)??0))}return r},Th=(t,e)=>{const s=e.trim().toLowerCase(),r=s.startsWith("ses_"),o=i=>i.reduce((a,l)=>a+(!r||l.session.id.toLowerCase()===s?1:0)+o(l.children),0);return o(t)},Zc=[],Wj=new Set,Jc=32,ed=52,Kj=3,Hj=7,td=7,sd=7,Mh=t=>`timeline-project:${t}`,lr=32,cn=28,nd=(t,e,s,r)=>{const o=r.get(t.session.id),i=r.get(e.session.id);if(o!==void 0||i!==void 0){if(o===void 0)return 1;if(i===void 0)return-1;if(o!==i)return o-i}return $a(t.session,e.session,s,Yu)},wi=t=>{const e=new Map,s=new Map,r=[],o=new WeakMap,i=t.map(a=>({node:a,visited:!1})).reverse();for(;i.length>0;){const a=i.pop();if(!a)continue;if(!a.visited){e.set(a.node.session.id,a.node),s.set(a.node.session.id,a.node.session);const d=r.length;r.push(a.node.session.id),o.set(a.node,[d,d+1]),i.push({node:a.node,visited:!0});for(let u=a.node.children.length-1;u>=0;u-=1){const f=a.node.children[u];f&&i.push({node:f,visited:!1})}continue}const l=o.get(a.node);l&&o.set(a.node,Object.freeze([l[0],r.length]))}return{byId:e,sessionsById:s,preorderIds:Object.freeze(r),subtreeRangeByNode:o}},Vj=(t,e,s)=>`${t}:${e?"archived":"active"}:${s}`,Gj=(t,e)=>{let s=null;for(const r of t){if(r.rowIndex>e)break;s=r}return s},Uj=t=>{const e=[],s=[],r=[],o=[],i=[],a=new Map,l=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds),f=t.workSessionIds??Wj,h=N=>d&&f.has(N);let m=0;const b=[...[...t.authoritativeSections.flatMap(N=>N.groups.flatMap(C=>C.sessions)),...t.chatGroup?.sessions??[]]];for(;b.length>0;){const N=b.pop();N&&(a.set(N.session.id,N.session),b.push(...N.children))}const v=N=>{const C=l.get(N)??0;return l.set(N,C+1),C===0?N:`${N}:${C}`},S=N=>{e.push(Object.freeze(N))},x=t.runIndex??Dy,p=(N,C)=>{const I=zj(C.renderContext,N.run.key),H=!Un(C.renderContext)&&(d||t.expandedParents.has(I)),M=N.lanes[0]?.session.id,_=M&&C.getSecondaryMeta?C.getSecondaryMeta(M):C.secondaryMeta,F=Object.freeze([...new Set(N.lanes.flatMap(ee=>(C.getBlockingBadgeSessionScopes?.(ee.session.id)??[]).flatMap(ne=>ne.sessionIDs)))]);S({kind:"run",key:v(`${C.containerKey}:run:${N.run.key}`),estimateSize:Un(C.renderContext)?ed:Jc,run:N.run,depth:C.baseDepth??0,laneNodes:Object.freeze([...N.lanes]),blockingSessionIds:F,projectId:C.projectId,projectLabel:_?.projectLabel??null,groupDirectory:C.groupDirectory,renderContext:C.renderContext,expansionKey:I,expanded:H,forceExpanded:d}),H&&w(N.lanes,(C.baseDepth??0)+1,C)},y=N=>{for(const C of vi(N.nodes,x,N.archived))$r(C)?p(C,N):w([C],N.baseDepth??0,N)},w=(N,C,I)=>{const H=[...N].reverse().map(M=>({node:M,depth:C,directory:I.groupDirectory}));for(;H.length>0;){const M=H.pop();if(!M)continue;const _=v(`${I.containerKey}:session:${M.node.session.id}`),F=M.node.session.directory??M.directory;a.set(M.node.session.id,M.node.session),S({kind:"session",key:_,estimateSize:Un(I.renderContext)?ed:Jc,node:M.node,blockingBadgeSessionScopes:M.depth===C?I.getBlockingBadgeSessionScopes?.(M.node.session.id)??I.blockingBadgeSessionScopes:void 0,depth:M.depth,projectId:I.projectId,groupDirectory:M.directory,ownerKey:I.ownerKey,selectionScopeKey:I.selectionScopeKey,archived:I.archived,renderContext:I.renderContext,secondaryMeta:I.getSecondaryMeta?I.getSecondaryMeta(M.node.session.id):I.secondaryMeta??null});const ee=I.indexedNodes?.subtreeRangeByNode.get(M.node),ne=ee&&ee[1]>ee[0]+1?Object.freeze([(I.selectionPoolOffset??0)+ee[0]+1,(I.selectionPoolOffset??0)+ee[1]]):void 0;if(s.push(Object.freeze({id:M.node.session.id,rowKey:_,scopeKey:I.selectionScopeKey,archived:I.archived,descendantRange:ne})),!(!d&&!t.expandedParents.has(Vj(I.renderContext,I.archived,M.node.session.id))))for(let re=M.node.children.length-1;re>=0;re-=1){const te=M.node.children[re];te&&H.push({node:te,depth:M.depth+1,directory:F})}}},j=N=>{const C=t.groupSearchDataByGroup.get(N);if(C?.hasMatch!==!0)return 0;const I=f.size>0?C.filteredNodes.filter(M=>h(M.session.id)):[];return Math.max(0,C.matchedSessionCount-Th(I,t.normalizedQuery))+C.folderNameMatchCount+(C.groupMatches?1:0)},k=(N,C,I,H,M)=>{const _=t.groupSearchDataByGroup.get(N);if(d){const U=j(N);if(U===0)return;m+=U}const F=(d?_?.filteredNodes??[]:N.sessions).filter(U=>!h(U.session.id)).sort((U,Me)=>nd(U,Me,u,t.sessionOrderIndex)),ee=wi(F),ne=r.length;r.push(...ee.preorderIds);for(const[U,Me]of ee.sessionsById)a.set(U,Me);const re=Gn(I,N.directory),te=!d&&t.collapsedGroups.has(C),K=H?0:1,q=M!==void 0&&M.renderContext!=="project",oe=t.groupStatusByKey.get(C),fe=F.length===0&&(!oe||oe.state==="ready")&&er(N).every(({scopeKey:U})=>(t.foldersMap[U]??Zc).length===0);if(!H){const U=ee.preorderIds.flatMap(Me=>ee.sessionsById.get(Me)??[]);S({kind:"group-header",key:`${C}:header`,estimateSize:lr,group:N,groupKey:C,projectId:I,collapsed:te&&!fe,forceExpanded:d,empty:fe,allSessions:Object.freeze(U)})}if(te&&!fe)return;const ce=er(N).flatMap(({scopeKey:U,directory:Me})=>(t.foldersMap[U]??Zc).map(Ge=>({folder:Ge,scopeKey:U,scopeDirectory:Me,ownerKey:re,nodes:la(Ge.sessionIds,ee.byId).sort((Ve,dt)=>nd(Ve,dt,u,t.sessionOrderIndex))}))),ke=Eh(ce.map(U=>({id:U.folder.id,name:U.folder.name,parentId:U.folder.parentId,nodeCount:U.nodes.length})),{archivedBucket:N.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),De=ce.filter(U=>ke.has(U.folder.id)),Ce=new Map(De.map(U=>[In(U.scopeKey,U.folder.id),U])),Y=new Map;for(const U of De){if(!U.folder.parentId)continue;const Me=In(U.scopeKey,U.folder.parentId),Ge=Y.get(Me)??[];Ge.push(U),Y.set(Me,Ge)}const je=Ph(De.map(U=>({...U.folder,scopeKey:U.scopeKey}))).map(U=>Ce.get(In(U.scopeKey??"",U.id))).filter(U=>!!U),we=new Set(De.flatMap(U=>U.folder.sessionIds)),Pe=F.filter(U=>!we.has(U.session.id)),L=new Map,ie=je.map(U=>({folder:U,visited:!1})),G=new Set;for(;ie.length>0;){const U=ie.pop();if(!U)continue;const Me=In(U.folder.scopeKey,U.folder.folder.id);if(!U.visited){if(G.has(Me))continue;G.add(Me),ie.push({folder:U.folder,visited:!0});for(const Ve of Y.get(Me)??[])ie.push({folder:Ve,visited:!1});continue}const Ge=U.folder.nodes.flatMap(Ve=>{const dt=ee.subtreeRangeByNode.get(Ve);return dt?ee.preorderIds.slice(dt[0],dt[1]).flatMap(et=>ee.sessionsById.get(et)??[]):[Ve.session]});for(const Ve of Y.get(Me)??[])Ge.push(...L.get(In(Ve.scopeKey,Ve.folder.id))??[]);L.set(Me,Object.freeze(Ge))}const ae=new Set,ge=(U,Me)=>{const Ge=In(U.scopeKey,U.folder.id);if(ae.has(Ge))return;ae.add(Ge);const Ve=Me?`${Me} / ${U.folder.name}`:U.folder.name,dt=`${C}:folder:${Ge}`,et=U.nodes.length===0&&(Y.get(Ge)?.length??0)===0,ct=!d&&!et&&t.collapsedFolders.has(U.folder.id),pe=L.get(Ge)??[],Ee=ct&&!N.isArchivedBucket?la([...new Set(pe.map($e=>$e.id))],ee.byId):[],qe=re?t.folderAuthorityByOwner.get(re):void 0,Ye=!!re&&!N.isArchivedBucket&&!ol(U.scopeKey)&&qe?.complete===!0&&qe.scopeKeys.includes(U.scopeKey);if(S({kind:"folder-header",key:dt,estimateSize:lr,depth:K,group:N,folder:U.folder,displayName:Ve,scopeKey:U.scopeKey,scopeDirectory:U.scopeDirectory,ownerKey:re,nodes:U.nodes,activityNodes:Ee,projectId:I,archived:N.isArchivedBucket===!0,collapsed:ct,forceExpanded:d,deleteSessions:pe,subFolderCount:Y.get(Ge)?.length??0,dropEnabled:Ye}),re&&i.push(Object.freeze({rowKey:dt,scopeKey:U.scopeKey,folderId:U.folder.id,ownerKey:re,enabled:Ye})),!ct){y({nodes:U.nodes,containerKey:dt,projectId:I,groupDirectory:U.scopeDirectory??N.directory,ownerKey:re,selectionScopeKey:re,archived:N.isArchivedBucket===!0,renderContext:"project",indexedNodes:ee,selectionPoolOffset:ne,baseDepth:K+1});for(const $e of Y.get(Ge)??[])ge($e,Ve)}};for(const U of je)ge(U,"");const me=I?t.sessionBatchSize:void 0,be=M?.initial??me??(t.hideDirectoryControls?10:td),ye=M?.increment??me??sd,Te=Math.max(be,t.visibleCountByContainer.get(C)??be),$=U=>!$r(U)&&M?.pinnedAlwaysVisible===!0&&za(u,U.session.directory??N.directory,U.session.id),he=vi(Pe,x,N.isArchivedBucket===!0),se=he.filter(U=>!$(U));let Ne=Te;const Ue=N.isArchivedBucket||d?he:he.filter(U=>$(U)?!0:Ne<=0?!1:(Ne-=1,!0)),We=Ue.flatMap(U=>$r(U)?U.lanes:[U]);y({nodes:We,containerKey:C,projectId:I,groupDirectory:N.directory,ownerKey:re,selectionScopeKey:re,archived:N.isArchivedBucket===!0,renderContext:M?.renderContext??"project",indexedNodes:ee,selectionPoolOffset:ne,baseDepth:K});const Ke=he.length-Ue.length,Be=Te-Ne;!d&&!N.isArchivedBucket&&Ke>0?S({kind:"show-control",key:`${C}:more`,estimateSize:cn,control:"more",containerKey:C,currentCount:Be,increment:ye,depth:K,flat:q}):!d&&!N.isArchivedBucket&&se.length>be&&Ke===0&&S({kind:"show-control",key:`${C}:fewer`,estimateSize:cn,control:"fewer",containerKey:C,currentCount:Be,increment:ye,depth:K,flat:q}),F.length===0&&De.length===0?oe&&oe.state!=="ready"?S({kind:"status",key:`${C}:status`,estimateSize:cn,status:oe,group:N,groupKey:C,depth:K,flat:q}):N.isArchivedBucket&&S({kind:"empty",key:`${C}:empty`,estimateSize:cn,emptyKind:"archived",depth:K}):oe&&oe.state!=="ready"&&oe.state!=="loading"&&S({kind:"status",key:`${C}:status`,estimateSize:cn,status:oe,group:N,groupKey:C,depth:K,flat:q})},P=N=>{const C=!d&&t.collapsedActivities.has(N),I=e.length;return S({kind:"activity-header",key:`activity:${N}:header`,estimateSize:lr,activityKey:N,collapsed:C,forceExpanded:d}),o.push(Object.freeze({rowIndex:I,kind:"activity",id:N})),C},A=t.viewMode==="timeline",B=N=>"run"in N,R=N=>{const C=vi(N.map(H=>H.node),x,!1),I=new Map(N.map(H=>[H.node,H]));return C.flatMap(H=>{if(!$r(H)){const M=I.get(H);return M?[M]:[]}return[{run:H.run,items:H.lanes.flatMap(M=>I.get(M)??[])}]})},E=(N,C,I)=>{const H=N.items[0];if(!H)return;const M=N.items.map(te=>te.node),_=wi(M),F=r.length;r.push(..._.preorderIds);const ee=Gn(H.projectId,H.groupDirectory),ne=new Map(N.items.map(te=>[te.node.session.id,te.getSecondaryMeta?te.getSecondaryMeta(te.node.session.id):te.secondaryMeta])),re=new Map(N.items.map(te=>[te.node.session.id,te.blockingBadgeSessionScopes]));p({run:N.run,lanes:M},{nodes:M,containerKey:C,projectId:H.projectId,groupDirectory:H.groupDirectory,ownerKey:ee,selectionScopeKey:null,archived:!1,renderContext:I,getSecondaryMeta:te=>ne.get(te)??null,getBlockingBadgeSessionScopes:te=>re.get(te),indexedNodes:_,selectionPoolOffset:F})},T=(N,C,I,H=()=>1)=>{for(const M of R(N)){if(B(M)){E(M,C,I),d&&(m+=M.items.reduce((re,te)=>re+H(te),0));continue}const _=M,F=wi([_.node]),ee=r.length;r.push(...F.preorderIds);const ne=Gn(_.projectId,_.groupDirectory);y({nodes:[_.node],containerKey:C,projectId:_.projectId,groupDirectory:_.groupDirectory,ownerKey:ne,selectionScopeKey:null,archived:!1,renderContext:I,blockingBadgeSessionScopes:_.blockingBadgeSessionScopes,secondaryMeta:_.secondaryMeta,getSecondaryMeta:_.getSecondaryMeta,indexedNodes:F,selectionPoolOffset:ee}),d&&(m+=H(_))}};t.chatGroup&&(!d||j(t.chatGroup)>0)&&(P("chats")||k(t.chatGroup,"activity:chats",null,!0,{initial:Kj,increment:Hj,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}));const z="timeline-mixed",O=(N,C,I,H,M)=>{const _=Math.max(H,t.visibleCountByContainer.get(C)??H),F=R(N),ee=d?F:F.slice(0,_);T(ee.flatMap(ne=>B(ne)?ne.items:[ne]),C,I),!d&&(F.length>ee.length?S({kind:"show-control",key:`${C}:more`,estimateSize:cn,control:"more",containerKey:C,currentCount:ee.length,increment:M,flat:!0}):F.length>H&&S({kind:"show-control",key:`${C}:fewer`,estimateSize:cn,control:"fewer",containerKey:C,currentCount:ee.length,increment:M,flat:!0}))},W=t.workItems??[];if(W.length>0&&(P("work")||T(W,"activity:work",z,C=>Rh(C.node,t.normalizedQuery))),A){const N=new Map;for(const C of t.timelineItems??[]){if(!C.projectId||h(C.node.session.id))continue;const I=N.get(C.projectId);I?I.push(C):N.set(C.projectId,[C])}for(const C of t.sections){const I=C.project.id,H=N.get(I)??[];if(d&&H.length===0)continue;const M=!d&&t.collapsedProjects.has(I),_=e.length;if(S({kind:"project-header",key:`project:${I}:header`,estimateSize:lr,section:C,collapsed:M,forceExpanded:d}),o.push(Object.freeze({rowIndex:_,kind:"project",id:I})),M)continue;if(H.length>0){O(H,Mh(I),"timeline",td,sd);continue}const F=C.groups.find(re=>re.isMain);if(!F)continue;const ee=`${I}:${F.id}`,ne=t.groupStatusByKey.get(ee);ne&&ne.state!=="ready"&&S({kind:"status",key:`${ee}:status`,estimateSize:cn,status:ne,group:F,groupKey:ee,flat:!0})}}let D=A?[]:t.singleProjectMode?t.sections.filter(N=>N.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const N=D.find(C=>C.project.id===t.activeProjectId)??D[0];D=N?[N]:[]}for(const N of D){const C=Oj(N,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(d&&!C.some(H=>j(H.group)>0))continue;const I=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(N.project.id);if(!t.showOnlyMainWorkspace){const H=e.length;S({kind:"project-header",key:`project:${N.project.id}:header`,estimateSize:lr,section:N,collapsed:I,forceExpanded:d}),o.push(Object.freeze({rowIndex:H,kind:"project",id:N.project.id}))}if(!I)for(const H of C)k(H.group,H.groupKey,H.projectId,H.hideGroupLabel)}e.length===0&&S({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const Q=new Map;return e.forEach((N,C)=>Q.set(N.key,C)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(s),selectionDescendantIds:Object.freeze(r),rowIndexByKey:Q,stickyHeaders:Object.freeze(o),folderDropTargets:Object.freeze(i),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:a,searchMatchCount:d?m:0})},zr="oc.sessions.projectCollapse",rd="oc.sessions.groupOrder",od="oc.sessions.groupCollapse",id=t=>{if(!t)return new Set;try{const e=Go(rn()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},qj=t=>{if(!t)return new Map;try{const e=Ua(rn(),Go(rn())).safeParse(JSON.parse(t));if(!e.success)return new Map;const s=new Map;for(const[r,o]of Object.entries(e.data))s.set(r,o);return s}catch{return new Map}},Yj=t=>{const e=He.c(40),{isVSCode:s,projects:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=fo(),e[0]=o):o=e[0];const i=o;let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=()=>id(i.getItem(zr)),e[1]=a):a=e[1];const[l,d]=c.useState(a);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>id(i.getItem(od)),e[2]=u):u=e[2];const[f,h]=c.useState(u),[m,g]=c.useState(Xj);let b;e[3]===Symbol.for("react.memo_cache_sentinel")?(b=()=>qj(i.getItem(rd)),e[3]=b):b=e[3];const[v,S]=c.useState(b),x=c.useRef(0),p=c.useRef(!1),y=c.useRef(!1),w=c.useRef(null),j=c.useRef(null);let k;e[4]!==s?(k=()=>{if(s)return;const fe=j.current;if(j.current=null,w.current=null,!fe)return;const{projects:ce}=Zt.getState(),ke=ce.map(De=>({...De,sidebarCollapsed:fe.has(De.id)}));En({projects:ke}).catch(Qj)},e[4]=s,e[5]=k):k=e[5];const P=k;let A;e[6]!==P||e[7]!==s?(A=fe=>{!globalThis.window||s||(j.current=fe,w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{P()},700))},e[6]=P,e[7]=s,e[8]=A):A=e[8];const B=A;let R,E;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=()=>()=>{globalThis.window&&w.current!==null&&window.clearTimeout(w.current),w.current=null,j.current=null},E=[],e[9]=R,e[10]=E):(R=e[9],E=e[10]),c.useEffect(R,E);let T,z;e[11]!==v?(z=()=>{if(y.current)try{i.setItem(rd,JSON.stringify(Object.fromEntries(v.entries())))}catch{}},T=[v,i],e[11]=v,e[12]=T,e[13]=z):(T=e[12],z=e[13]),c.useEffect(z,T);let O,W;e[14]!==f?(O=()=>{if(p.current)try{i.setItem(od,JSON.stringify(Array.from(f)))}catch{}},W=[f,i],e[14]=f,e[15]=O,e[16]=W):(O=e[15],W=e[16]),c.useEffect(O,W);let D;e[17]!==r||e[18]!==B?(D=()=>{x.current=Date.now()+150,p.current=!0,h(new Set),g(Zj),d(()=>{const fe=new Set(r.map(Jj));try{i.setItem(zr,JSON.stringify(Array.from(fe)))}catch{}return B(fe),fe})},e[17]=r,e[18]=B,e[19]=D):D=e[19];const Q=D;let N;e[20]!==B?(N=()=>{x.current=Date.now()+150,p.current=!0,h(new Set),g(e2),d(()=>{const fe=new Set;try{i.setItem(zr,JSON.stringify([]))}catch{}return B(fe),fe})},e[20]=B,e[21]=N):N=e[21];const C=N;let I;e[22]!==B?(I=fe=>{x.current=Date.now()+150,d(ce=>{const ke=new Set(ce);ke.has(fe)?ke.delete(fe):ke.add(fe);try{i.setItem(zr,JSON.stringify(Array.from(ke)))}catch{}return B(ke),ke})},e[22]=B,e[23]=I):I=e[23];const H=I;let M;e[24]===Symbol.for("react.memo_cache_sentinel")?(M=fe=>{p.current=!0,h(ce=>{const ke=new Set(ce);return ke.has(fe)?ke.delete(fe):ke.add(fe),ke})},e[24]=M):M=e[24];const _=M;let F;e[25]===Symbol.for("react.memo_cache_sentinel")?(F=fe=>{y.current=!0,S(fe)},e[25]=F):F=e[25];const ee=F,{getOrderedGroups:ne}=Mj(v);let re;e[26]!==m||e[27]!==f||e[28]!==l||e[29]!==v?(re={collapsedProjects:l,collapsedGroups:f,collapsedActivities:m,groupOrderByProject:v},e[26]=m,e[27]=f,e[28]=l,e[29]=v,e[30]=re):re=e[30];const te=re;let K;e[31]!==Q||e[32]!==C||e[33]!==ne||e[34]!==B||e[35]!==H?(K={setCollapsedProjects:d,toggleProject:H,collapseAll:Q,expandAll:C,scheduleCollapsedProjectsPersist:B,setCollapsedGroups:h,setCollapsedActivities:g,toggleGroup:_,setGroupOrderByProject:ee,getOrderedGroups:ne},e[31]=Q,e[32]=C,e[33]=ne,e[34]=B,e[35]=H,e[36]=K):K=e[36];const q=K;let oe;return e[37]!==q||e[38]!==te?(oe={state:te,actions:q},e[37]=q,e[38]=te,e[39]=oe):oe=e[39],oe};function Xj(){return new Set}function Qj(){}function Zj(t){return new Set([...t,...Dh])}function Jj(t){return t.id}function e2(t){const e=new Set(t);for(const s of Dh)e.delete(s);return e}const t2=5*6e4,s2=t=>{const e=He.c(38),{normalizedProjects:s,enabled:r,gitRepoStatus:o,setProjectRepoStatus:i,setProjectRootBranches:a}=t,l=r===void 0?!0:r,{git:d}=Ws(),u=gn(n2),f=gn(r2),h=c.useRef(null),m=c.useRef(l);let g,b;e[0]!==l||e[1]!==u||e[2]!==d||e[3]!==f?(g=()=>{const E=l&&!m.current;m.current=l;const T=h.current;if(!(!E||!d||!T||T.git!==d||T.runtimeKey!==f))for(const z of T.paths)mr(()=>u(z,d))},b=[l,u,d,f],e[0]=l,e[1]=u,e[2]=d,e[3]=f,e[4]=g,e[5]=b):(g=e[4],b=e[5]),c.useEffect(g,b);let v,S;e[6]!==l||e[7]!==u||e[8]!==d||e[9]!==f||e[10]!==s||e[11]!==i?(v=()=>{if(!l)return;if(!d||s.length===0){h.current=null,i(new Map);return}let E=h.current;(!E||E.runtimeKey!==f||E.git!==d)&&(E={runtimeKey:f,git:d,paths:new Set},h.current=E);const{paths:T}=E,z=new Set(s.map(o2));for(const D of T)z.has(D)||T.delete(D);const O=[...z].filter(D=>!T.has(D));if(O.length===0)return;for(const D of O)T.add(D);const W=D=>{const Q=gn.getState().directories.get(D);Q?.isGitRepo!==!1&&!Q?.status&&T.delete(D)};mr(async()=>{await d.prefetchProjectStatuses?.(O),await Promise.all(O.map(D=>u(D,d).then(()=>W(D),()=>W(D))))})},S=[l,s,d,f,u,i],e[6]=l,e[7]=u,e[8]=d,e[9]=f,e[10]=s,e[11]=i,e[12]=v,e[13]=S):(v=e[12],S=e[13]),c.useEffect(v,S);let x,p;e[14]!==l||e[15]!==o||e[16]!==s||e[17]!==i?(x=()=>{if(!l)return;const E=new Map;s.forEach(T=>{E.set(T.id,o.get(T.normalizedPath)?.isGitRepo??null)}),i(E)},p=[l,s,o,i],e[14]=l,e[15]=o,e[16]=s,e[17]=i,e[18]=x,e[19]=p):(x=e[18],p=e[19]),c.useEffect(x,p);let y;if(e[20]!==o||e[21]!==s){let E;e[23]!==o?(E=T=>{const z=o.get(T.normalizedPath)?.branch??"";return`${T.id}:${z}`},e[23]=o,e[24]=E):E=e[24],y=s.map(E).join("|"),e[20]=o,e[21]=s,e[22]=y}else y=e[22];const w=y;let j;e[25]===Symbol.for("react.memo_cache_sentinel")?(j=new Map,e[25]=j):j=e[25];const k=c.useRef(j);let P;e[26]===Symbol.for("react.memo_cache_sentinel")?(P=new Map,e[26]=P):P=e[26];const A=c.useRef(P);let B;e[27]!==l||e[28]!==o||e[29]!==s||e[30]!==a?(B=()=>{if(!l)return;let E=!1;const T=setTimeout(()=>{(async()=>{const O=new Set(s.map(i2));for(const I of k.current.keys())O.has(I)||(k.current.delete(I),A.current.delete(I));const W=Date.now(),D=s.filter(I=>{const H=o.get(I.normalizedPath);if(H?.isGitRepo===!1)return k.current.delete(I.id),A.current.delete(I.id),!1;if(H?.isGitRepo!==!0||H.branch===null)return!1;const M=H.branch.trim(),_=`${I.normalizedPath}\0${M}`,F=k.current.get(I.id);if(F===_){const ee=A.current.get(I.id);return ee&&(ee.at=W),!1}return!(F!==void 0&&W-(A.current.get(I.id)?.at??0)<t2)});if(D.length===0)return;const Q=await mr(()=>Promise.all(D.map(async I=>{const H=o.get(I.normalizedPath)?.branch?.trim()??"",M=`${I.normalizedPath}\0${H}`,_=await $u(I.normalizedPath,H?{knownBranch:H}:void 0).catch(a2);return{id:I.id,inputKey:M,branch:_}})));if(E)return;const N=Q.filter(l2);if(N.length===0)return;const C=Date.now();a(I=>{const H=new Map(I);return N.forEach(M=>{const{id:_,branch:F}=M;F&&H.set(_,F)}),H}),N.forEach(I=>{const{id:H,inputKey:M,branch:_}=I;k.current.set(H,M),_&&A.current.set(H,{branch:_,at:C})})})()},150);return()=>{E=!0,clearTimeout(T)}},e[27]=l,e[28]=o,e[29]=s,e[30]=a,e[31]=B):B=e[31];let R;e[32]!==l||e[33]!==o||e[34]!==s||e[35]!==w||e[36]!==a?(R=[l,s,w,o,a],e[32]=l,e[33]=o,e[34]=s,e[35]=w,e[36]=a,e[37]=R):R=e[37],c.useEffect(B,R)};function n2(t){return t.ensureStatus}function r2(t){return t.runtimeKey}function o2(t){return t.normalizedPath}function i2(t){return t.id}function a2(){return null}function l2(t){return t.branch}const c2=t=>{const e=He.c(19),{open:s,onOpenChange:r,project:o,onSave:i}=t,a=de(d2),[l,d]=c.useState("general");let u,f;e[0]!==s?(u=()=>{s&&d("general")},f=[s],e[0]=s,e[1]=u,e[2]=f):(u=e[1],f=e[2]),c.useEffect(u,f);const h=o?.id??null;let m;e:{if(!h){m=void 0;break e}let x;e[3]!==r||e[4]!==h||e[5]!==a?(x=()=>{r(!1),a(h)},e[3]=r,e[4]=h,e[5]=a,e[6]=x):x=e[6],m=x}const g=m;let b;e[7]!==g||e[8]!==i||e[9]!==s||e[10]!==o||e[11]!==l?(b=s&&o?n.jsx(Sg,{frame:"dialog",project:o,onIdentitySave:i,tab:l,onTabChange:d,onOpenWorktrees:g}):null,e[7]=g,e[8]=i,e[9]=s,e[10]=o,e[11]=l,e[12]=b):b=e[12];let v;e[13]!==b?(v=n.jsx($s,{className:"flex h-[min(85vh,40rem)] w-full max-w-2xl flex-col gap-0 overflow-hidden p-0",children:b}),e[13]=b,e[14]=v):v=e[14];let S;return e[15]!==r||e[16]!==s||e[17]!==v?(S=n.jsx(zs,{open:s,onOpenChange:r,children:v}),e[15]=r,e[16]=s,e[17]=v,e[18]=S):S=e[18],S};function d2(t){return t.setWorktreesPageProjectId}function u2(t,e,s,r){const o=He.c(6),[i,a]=c.useState(!0);let l,d;return o[0]!==e||o[1]!==r||o[2]!==s||o[3]!==t?(l=()=>{const u=t.current,f=e.current,h=s.current;if(!u||!f||!h||r===0)return;const m=()=>{const b=f.lastElementChild,v=b?b.getBoundingClientRect().width:0,S=Number.parseFloat(getComputedStyle(f).columnGap)||0,x=Number.parseFloat(getComputedStyle(u).columnGap)||0,p=f.getBoundingClientRect().width+r*(S+v),y=u.getBoundingClientRect().right-f.getBoundingClientRect().left-h.getBoundingClientRect().width-x;a(p<=y)};m();const g=new ResizeObserver(m);return g.observe(u),g.observe(f),g.observe(h),()=>g.disconnect()},d=[t,e,s,r],o[0]=e,o[1]=r,o[2]=s,o[3]=t,o[4]=l,o[5]=d):(l=o[4],d=o[5]),c.useLayoutEffect(l,d),i}const Ah="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground",Oh="text-muted-foreground hover:text-foreground hover:bg-transparent";function Wr(t){const e=He.c(14),{label:s,pressed:r,onClick:o,className:i,children:a}=t,l=r?Ah:Oh;let d;e[0]!==i||e[1]!==l?(d=ve(i,l),e[0]=i,e[1]=l,e[2]=d):d=e[2];let u;e[3]!==a||e[4]!==s||e[5]!==o||e[6]!==r||e[7]!==d?(u=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:d,"aria-label":s,"aria-pressed":r,children:a})}),e[3]=a,e[4]=s,e[5]=o,e[6]=r,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==s?(f=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:s})}),e[9]=s,e[10]=f):f=e[10];let h;return e[11]!==u||e[12]!==f?(h=n.jsxs(Ot,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=h):h=e[13],h}function f2(t){const e=He.c(245),{t:s}=wt(),r=Xu(),{hideDirectoryControls:o,showProjectDisplayControls:i,showSectionControls:a,handleOpenDirectoryDialog:l,showSourceBoard:d,headerActionIconClass:u,headerActionButtonClass:f,isSessionSearchOpen:h,openSessionSearch:m,closeSessionSearch:g,sessionSearchInputRef:b,sessionSearchQuery:v,setSessionSearchQuery:S,hasSessionSearchQuery:x,searchMatchCount:p,collapseAll:y,expandAll:w}=t,j=c.useRef(null),k=c.useRef(null),P=c.useRef(null),A=u2(j,k,P,r.length),B=cs(M2),R=cs(T2),E=de(D2),T=de(R2),z=de(I2),O=de(N2),W=os(E2),D=os(P2),Q=os(C2),N=os(j2),C=de(k2),I=os(w2),H=os(v2),M=os(S2),_=os(x2),F=os(y2),ee=os(b2),ne=os(g2),re=os(m2),te=i&&F==="timeline",K=i&&!te&&ne==="single";let q;e[0]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx(Z,{name:"check",className:"h-4 w-4 text-primary"}),e[0]=q):q=e[0];const oe=q;let fe;e[1]!==s?(fe=(rt,ut,pt,ue)=>{const lt=ut.find(ft=>{const[mt]=ft;return mt===pt})?.[1];return n.jsxs(Ju,{children:[n.jsxs(ef,{children:[n.jsx("span",{className:"flex-1",children:s(rt)}),lt?n.jsx("span",{className:"ms-4 text-muted-foreground",children:s(lt)}):null]}),n.jsx(tf,{className:"min-w-[160px]",children:ut.map(ft=>{const[mt,It]=ft;return n.jsxs(qt,{onClick:()=>ue(mt),className:"flex items-center justify-between",children:[n.jsx("span",{children:s(It)}),pt===mt?oe:null]},mt)})})]})},e[1]=s,e[2]=fe):fe=e[2];const ce=fe;let ke;e[3]!==s?(ke=(rt,ut,pt)=>n.jsxs(qt,{onClick:pt,className:"flex items-center justify-between",children:[n.jsx("span",{children:s(rt)}),ut?oe:null]}),e[3]=s,e[4]=ke):ke=e[4];const De=ke;let Ce;e[5]===Symbol.for("react.memo_cache_sentinel")?(Ce=n.jsx(Z,{name:"checkbox-multiple",className:"h-4 w-4"}),e[5]=Ce):Ce=e[5];let Y;e[6]!==B||e[7]!==s?(Y=s(B?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[6]=B,e[7]=s,e[8]=Y):Y=e[8];let je;e[9]!==Y?(je=n.jsx("span",{children:Y}),e[9]=Y,e[10]=je):je=e[10];let we;e[11]!==je||e[12]!==R?(we=n.jsxs(qt,{onClick:R,className:"flex items-center gap-2",children:[Ce,je]},"select"),e[11]=je,e[12]=R,e[13]=we):we=e[13];let Pe;if(e[14]!==ce||e[15]!==y||e[16]!==w||e[17]!==K||e[18]!==ne||e[19]!==I||e[20]!==C||e[21]!==re||e[22]!==H||e[23]!==D||e[24]!==N||e[25]!==ee||e[26]!==_||e[27]!==W||e[28]!==i||e[29]!==a||e[30]!==Q||e[31]!==F||e[32]!==s||e[33]!==we||e[34]!==te||e[35]!==De||e[36]!==M){if(Pe=[we],i){let rt;e[38]!==s?(rt=s("sessions.sidebar.header.viewMode.label"),e[38]=s,e[39]=rt):rt=e[39];let ut;e[40]!==rt?(ut=n.jsx(Oi,{children:rt}),e[40]=rt,e[41]=ut):ut=e[41];let pt;e[42]!==ee||e[43]!==F||e[44]!==s?(pt=[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(lt=>{const[ft,mt]=lt;return n.jsxs(qt,{onClick:()=>{ee(ft),En({sidebarViewMode:ft})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(mt)}),F===ft?oe:null]},ft)}),e[42]=ee,e[43]=F,e[44]=s,e[45]=pt):pt=e[45];let ue;e[46]!==ut||e[47]!==pt?(ue=n.jsxs(n.Fragment,{children:[ut,pt]}),e[46]=ut,e[47]=pt,e[48]=ue):ue=e[48],Pe.push(ue)}if(!te){let rt;if(e[49]!==ce||e[50]!==I||e[51]!==H){let lt;e[53]!==H?(lt=ft=>{H(ft),En({sidebarProjectSortOrder:ft})},e[53]=H,e[54]=lt):lt=e[54],rt=ce("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"]],I,lt),e[49]=ce,e[50]=I,e[51]=H,e[52]=rt}else rt=e[52];let ut;e[55]!==ce||e[56]!==_||e[57]!==i||e[58]!==M?(ut=i?ce("sessions.sidebar.header.actions.sortWorktrees",[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]],M,lt=>{_(lt),En({sidebarWorktreeSortOrder:lt})}):null,e[55]=ce,e[56]=_,e[57]=i,e[58]=M,e[59]=ut):ut=e[59];let pt;e[60]!==ce||e[61]!==ne||e[62]!==re||e[63]!==i?(pt=i?ce("sessions.sidebar.header.projectDisplay.label",[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]],ne,lt=>{re(lt),En({sidebarProjectDisplayMode:lt})}):null,e[60]=ce,e[61]=ne,e[62]=re,e[63]=i,e[64]=pt):pt=e[64];let ue;e[65]!==rt||e[66]!==ut||e[67]!==pt?(ue=n.jsxs(n.Fragment,{children:[rt,ut,pt]}),e[65]=rt,e[66]=ut,e[67]=pt,e[68]=ue):ue=e[68],Pe.push(ue)}if(a){let rt;e[69]!==D||e[70]!==W?(rt=()=>{D(!W),En({sidebarShowChatsSection:!W})},e[69]=D,e[70]=W,e[71]=rt):rt=e[71];let ut;e[72]!==W||e[73]!==rt||e[74]!==De?(ut=De("sessions.sidebar.header.displayMode.showChats",W,rt),e[72]=W,e[73]=rt,e[74]=De,e[75]=ut):ut=e[75];let pt;e[76]!==C||e[77]!==N||e[78]!==Q||e[79]!==De?(pt=C?De("sessions.sidebar.header.displayMode.showWork",Q,()=>{N(!Q),En({sidebarShowWorkSection:!Q})}):null,e[76]=C,e[77]=N,e[78]=Q,e[79]=De,e[80]=pt):pt=e[80];let ue;e[81]!==ut||e[82]!==pt?(ue=n.jsxs(n.Fragment,{children:[ut,pt]}),e[81]=ut,e[82]=pt,e[83]=ue):ue=e[83],Pe.push(ue)}if(!K){let rt;e[84]===Symbol.for("react.memo_cache_sentinel")?(rt=n.jsx(Z,{name:"contract-up-down",className:"h-4 w-4"}),e[84]=rt):rt=e[84];let ut;e[85]!==s?(ut=s("sessions.sidebar.header.displayMode.collapseAll"),e[85]=s,e[86]=ut):ut=e[86];let pt;e[87]!==ut?(pt=n.jsx("span",{children:ut}),e[87]=ut,e[88]=pt):pt=e[88];let ue;e[89]!==y||e[90]!==pt?(ue=n.jsxs(qt,{onClick:y,className:"flex items-center gap-2",children:[rt,pt]}),e[89]=y,e[90]=pt,e[91]=ue):ue=e[91];let lt;e[92]===Symbol.for("react.memo_cache_sentinel")?(lt=n.jsx(Z,{name:"expand-up-down",className:"h-4 w-4"}),e[92]=lt):lt=e[92];let ft;e[93]!==s?(ft=s("sessions.sidebar.header.displayMode.expandAll"),e[93]=s,e[94]=ft):ft=e[94];let mt;e[95]!==ft?(mt=n.jsx("span",{children:ft}),e[95]=ft,e[96]=mt):mt=e[96];let It;e[97]!==w||e[98]!==mt?(It=n.jsxs(qt,{onClick:w,className:"flex items-center gap-2",children:[lt,mt]}),e[97]=w,e[98]=mt,e[99]=It):It=e[99];let xe;e[100]!==ue||e[101]!==It?(xe=n.jsxs(n.Fragment,{children:[ue,It]}),e[100]=ue,e[101]=It,e[102]=xe):xe=e[102],Pe.push(xe)}e[14]=ce,e[15]=y,e[16]=w,e[17]=K,e[18]=ne,e[19]=I,e[20]=C,e[21]=re,e[22]=H,e[23]=D,e[24]=N,e[25]=ee,e[26]=_,e[27]=W,e[28]=i,e[29]=a,e[30]=Q,e[31]=F,e[32]=s,e[33]=we,e[34]=te,e[35]=De,e[36]=M,e[37]=Pe}else Pe=e[37];if(o){let rt;e[103]!==s?(rt=s("sessions.sidebar.header.search.placeholder"),e[103]=s,e[104]=rt):rt=e[104];let ut;e[105]!==s?(ut=s("sessions.sidebar.header.search.clear"),e[105]=s,e[106]=ut):ut=e[106];let pt;e[107]!==x||e[108]!==p||e[109]!==s?(pt=x?p===1?s("sessions.sidebar.header.search.matchCountSingle",{count:p}):s("sessions.sidebar.header.search.matchCountPlural",{count:p}):void 0,e[107]=x,e[108]=p,e[109]=s,e[110]=pt):pt=e[110];let ue;e[111]!==s?(ue=s("sessions.sidebar.header.search.escapeHint"),e[111]=s,e[112]=ue):ue=e[112];let lt;return e[113]!==g||e[114]!==b||e[115]!==v||e[116]!==S||e[117]!==ue||e[118]!==rt||e[119]!==ut||e[120]!==pt?(lt=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1.5",children:n.jsx(Ll,{inputRef:b,value:v,onSearch:S,onClose:g,placeholder:rt,clearLabel:ut,leadingHint:pt,trailingHint:ue})}),e[113]=g,e[114]=b,e[115]=v,e[116]=S,e[117]=ue,e[118]=rt,e[119]=ut,e[120]=pt,e[121]=lt):lt=e[121],lt}let L;e[122]!==f||e[123]!==u||e[124]!==E||e[125]!==d||e[126]!==s?(L=d?n.jsx(Wr,{label:s("sourceBoard.title"),pressed:E,onClick:()=>de.getState().setSourceBoardOpen(!E),className:f,children:n.jsx(Z,{name:"todo",className:u})}):null,e[122]=f,e[123]=u,e[124]=E,e[125]=d,e[126]=s,e[127]=L):L=e[127];let ie;e[128]!==s?(ie=s("sessions.sidebar.header.actions.scheduledTasks"),e[128]=s,e[129]=ie):ie=e[129];let G;e[130]!==T?(G=()=>de.getState().setScheduledTasksDialogOpen(!T),e[130]=T,e[131]=G):G=e[131];let ae;e[132]!==u?(ae=n.jsx(Z,{name:"calendar-schedule",className:u}),e[132]=u,e[133]=ae):ae=e[133];let ge;e[134]!==f||e[135]!==T||e[136]!==ae||e[137]!==ie||e[138]!==G?(ge=n.jsx(Wr,{label:ie,pressed:T,onClick:G,className:f,children:ae}),e[134]=f,e[135]=T,e[136]=ae,e[137]=ie,e[138]=G,e[139]=ge):ge=e[139];let me;e[140]!==s?(me=s("sessions.sidebar.nav.archive"),e[140]=s,e[141]=me):me=e[141];let be;e[142]!==z?(be=()=>de.getState().setArchivePageOpen(!z),e[142]=z,e[143]=be):be=e[143];let ye;e[144]!==u?(ye=n.jsx(Z,{name:"archive",className:u}),e[144]=u,e[145]=ye):ye=e[145];let Te;e[146]!==f||e[147]!==z||e[148]!==me||e[149]!==be||e[150]!==ye?(Te=n.jsx(Wr,{label:me,pressed:z,onClick:be,className:f,children:ye}),e[146]=f,e[147]=z,e[148]=me,e[149]=be,e[150]=ye,e[151]=Te):Te=e[151];let $;e[152]!==ge||e[153]!==Te||e[154]!==L?($=n.jsxs("div",{ref:k,className:"flex items-center gap-1.5",children:[L,ge,Te]}),e[152]=ge,e[153]=Te,e[154]=L,e[155]=$):$=e[155];let he;e[156]!==r||e[157]!==A||e[158]!==f||e[159]!==u||e[160]!==O||e[161]!==s?(he=A?r.map(rt=>{const ut=O===rt.id;return n.jsx(Wr,{label:rt.pageTitle??rt.name,pressed:ut,onClick:()=>de.getState().setOpenGuestPage(ut?null:rt.id),className:f,children:n.jsx(sr,{icon:Zu(rt.icon),iconSrc:Qu(rt.id,rt.icon,Yd().authenticatedAsset),className:u})},rt.id)}):r.length>0&&n.jsxs(js,{children:[n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":s("sessions.sidebar.header.actions.extensionPages"),children:n.jsx(Z,{name:"puzzle",className:u})})}),n.jsxs(Ps,{align:"start",children:[n.jsx(Oi,{children:s("sessions.sidebar.header.actions.extensionPages")}),r.map(p2)]})]}),e[156]=r,e[157]=A,e[158]=f,e[159]=u,e[160]=O,e[161]=s,e[162]=he):he=e[162];let se;e[163]!==$||e[164]!==he?(se=n.jsxs("div",{className:"ms-[3px] flex min-w-0 items-center gap-1.5",children:[$,he]}),e[163]=$,e[164]=he,e[165]=se):se=e[165];const Ne=h?g:m,Ue=h?Ah:Oh;let We;e[166]!==f||e[167]!==Ue?(We=ve(f,Ue),e[166]=f,e[167]=Ue,e[168]=We):We=e[168];let Ke;e[169]!==s?(Ke=s("sessions.sidebar.header.actions.searchSessions"),e[169]=s,e[170]=Ke):Ke=e[170];let Be;e[171]!==u?(Be=n.jsx(Z,{name:"search",className:u}),e[171]=u,e[172]=Be):Be=e[172];let U;e[173]!==h||e[174]!==Ne||e[175]!==We||e[176]!==Ke||e[177]!==Be?(U=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ne,className:We,"aria-label":Ke,"aria-expanded":h,children:Be})}),e[173]=h,e[174]=Ne,e[175]=We,e[176]=Ke,e[177]=Be,e[178]=U):U=e[178];let Me;e[179]!==s?(Me=s("sessions.sidebar.header.actions.searchSessions"),e[179]=s,e[180]=Me):Me=e[180];let Ge;e[181]!==Me?(Ge=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Me})}),e[181]=Me,e[182]=Ge):Ge=e[182];let Ve;e[183]!==U||e[184]!==Ge?(Ve=n.jsxs(Ot,{children:[U,Ge]}),e[183]=U,e[184]=Ge,e[185]=Ve):Ve=e[185];let dt;e[186]!==f?(dt=ve(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[186]=f,e[187]=dt):dt=e[187];let et;e[188]!==s?(et=s("sessions.sidebar.header.actions.addProject"),e[188]=s,e[189]=et):et=e[189];let ct;e[190]!==u?(ct=n.jsx(Z,{name:"folder-add",className:u}),e[190]=u,e[191]=ct):ct=e[191];let pe;e[192]!==l||e[193]!==dt||e[194]!==et||e[195]!==ct?(pe=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:l,className:dt,"aria-label":et,children:ct})}),e[192]=l,e[193]=dt,e[194]=et,e[195]=ct,e[196]=pe):pe=e[196];let Ee;e[197]!==s?(Ee=s("sessions.sidebar.header.actions.addProject"),e[197]=s,e[198]=Ee):Ee=e[198];let qe;e[199]!==Ee?(qe=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Ee})}),e[199]=Ee,e[200]=qe):qe=e[200];let Ye;e[201]!==pe||e[202]!==qe?(Ye=n.jsxs(Ot,{children:[pe,qe]}),e[201]=pe,e[202]=qe,e[203]=Ye):Ye=e[203];let $e;e[204]!==f?($e=ve(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[204]=f,e[205]=$e):$e=e[205];let tt;e[206]!==s?(tt=s("sessions.sidebar.header.displayMode.label"),e[206]=s,e[207]=tt):tt=e[207];let ht;e[208]!==u?(ht=n.jsx(Z,{name:"equalizer-2",className:u}),e[208]=u,e[209]=ht):ht=e[209];let vt;e[210]!==$e||e[211]!==tt||e[212]!==ht?(vt=n.jsx(At,{asChild:!0,children:n.jsx(Cs,{asChild:!0,children:n.jsx("button",{type:"button",className:$e,"aria-label":tt,children:ht})})}),e[210]=$e,e[211]=tt,e[212]=ht,e[213]=vt):vt=e[213];let Bt;e[214]!==s?(Bt=s("sessions.sidebar.header.displayMode.label"),e[214]=s,e[215]=Bt):Bt=e[215];let kt;e[216]!==Bt?(kt=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Bt})}),e[216]=Bt,e[217]=kt):kt=e[217];let St;e[218]!==vt||e[219]!==kt?(St=n.jsxs(Ot,{children:[vt,kt]}),e[218]=vt,e[219]=kt,e[220]=St):St=e[220];let xt;e[221]!==Pe?(xt=n.jsx(Ps,{align:"end",className:"min-w-[200px]",children:Pe.map(h2)}),e[221]=Pe,e[222]=xt):xt=e[222];let Mt;e[223]!==St||e[224]!==xt?(Mt=n.jsxs(js,{children:[St,xt]}),e[223]=St,e[224]=xt,e[225]=Mt):Mt=e[225];let jt;e[226]!==Ve||e[227]!==Ye||e[228]!==Mt?(jt=n.jsxs("div",{ref:P,className:"flex min-w-0 items-center gap-1.5",children:[Ve,Ye,Mt]}),e[226]=Ve,e[227]=Ye,e[228]=Mt,e[229]=jt):jt=e[229];let $t;e[230]!==se||e[231]!==jt?($t=n.jsxs("div",{ref:j,className:"flex min-h-8 flex-wrap items-center justify-between gap-2",children:[se,jt]}),e[230]=se,e[231]=jt,e[232]=$t):$t=e[232];let Wt;e[233]!==g||e[234]!==x||e[235]!==h||e[236]!==p||e[237]!==b||e[238]!==v||e[239]!==S||e[240]!==s?(Wt=h?n.jsx("div",{className:"pb-1",children:n.jsx(Ll,{inputRef:b,value:v,onSearch:S,onClose:g,placeholder:s("sessions.sidebar.header.search.placeholder"),clearLabel:s("sessions.sidebar.header.search.clear"),leadingHint:x?p===1?s("sessions.sidebar.header.search.matchCountSingle",{count:p}):s("sessions.sidebar.header.search.matchCountPlural",{count:p}):void 0,trailingHint:s("sessions.sidebar.header.search.escapeHint")})}):null,e[233]=g,e[234]=x,e[235]=h,e[236]=p,e[237]=b,e[238]=v,e[239]=S,e[240]=s,e[241]=Wt):Wt=e[241];let Kt;return e[242]!==$t||e[243]!==Wt?(Kt=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:[$t,Wt]})}),e[242]=$t,e[243]=Wt,e[244]=Kt):Kt=e[244],Kt}function h2(t,e){return n.jsxs(c.Fragment,{children:[e>0?n.jsx(bn,{}):null,t]},e)}function p2(t){return n.jsxs(qt,{onSelect:()=>de.getState().setOpenGuestPage(t.id),children:[n.jsx(sr,{icon:Zu(t.icon),iconSrc:Qu(t.id,t.icon,Yd().authenticatedAsset),className:"size-4"}),n.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function m2(t){return t.setProjectDisplayMode}function g2(t){return t.projectDisplayMode}function b2(t){return t.setSidebarViewMode}function y2(t){return t.sidebarViewMode}function x2(t){return t.setWorktreeSortOrder}function S2(t){return t.worktreeSortOrder}function v2(t){return t.setProjectSortOrder}function w2(t){return t.projectSortOrder}function k2(t){return t.sessionWorkEnabled}function j2(t){return t.setShowWorkSection}function C2(t){return t.showWorkSection}function P2(t){return t.setShowChatsSection}function E2(t){return t.showChatsSection}function N2(t){return t.openGuestPageId}function I2(t){return t.isArchivePageOpen}function R2(t){return t.isScheduledTasksDialogOpen}function D2(t){return t.isSourceBoardOpen}function T2(t){return t.toggleMode}function M2(t){return t.enabled}function A2(t){const e=He.c(2),{className:s}=t,[r]=c.useState(O2);if(!r)return null;let o;return e[0]!==s?(o=n.jsx(B2,{className:s}),e[0]=s,e[1]=o):o=e[1],o}function O2(){return pn()}function B2({className:t}){const{t:e}=wt(),s=de(k=>k.shortcutOverrides),[r,o]=c.useState(!1),[i,a]=c.useState("Local"),[l,d]=c.useState(!0),[u,f]=c.useState(!1),[h,m]=c.useState(null),[g,b]=c.useState(!1),[v,S]=c.useState(null),x=c.useCallback(async()=>{try{if(Do()){a("Local"),d(!0);return}d(!1);const k=await To(),P=mm(gm(k.hosts,k.localOrigin));if(P.id===bm){a("Local"),d(!0);return}a(Xd(P.label.trim()||"Instance"))}catch{a("Local"),d(!0)}},[]);c.useEffect(()=>(x(),No(()=>{x()})),[x]);const p=c.useCallback(async()=>{if(l){m(null),S(null);return}b(!0),S(null);try{const k=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),P=await an(`/api/openchamber/update-check?${k.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!P.ok)throw new Error(`Server responded with ${P.status}`);m(vg(await P.json()))}catch(k){m(null),S(k instanceof Error?k.message:e("header.services.remoteUpdate.error"))}finally{b(!1)}},[l,e]);c.useEffect(()=>{m(null),S(null),f(!1)},[l,i]),c.useEffect(()=>{if(l)return;const k=3e3,P=3600*1e3;let A=!1,B=null;const R=E=>{B=window.setTimeout(()=>{if(A||typeof document<"u"&&document.visibilityState!=="visible"){R(P);return}p().finally(()=>{A||R(P)})},E)};return R(k),()=>{A=!0,B!==null&&window.clearTimeout(B)}},[p,l,i]);const y=c.useCallback(()=>{if(h?.available){f(!0);return}p()},[p,h?.available]),w=c.useCallback(k=>{o(k),k&&x()},[x]);Iu({toggle_services_menu:()=>{if(r){o(!1);return}const k=de.getState();k.isSidebarOpen||k.setSidebarOpen(!0),w(!0)}});const j=Du(Tu("toggle_services_menu",s));return n.jsxs(n.Fragment,{children:[n.jsxs(js,{open:r,onOpenChange:w,children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx(Cs,{asChild:!0,children:n.jsxs("button",{type:"button","aria-label":e("header.services.openWithCurrent",{current:i}),className:t,children:[n.jsx(Z,{name:"server",className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate typography-ui-label",children:i})]})})}),n.jsx(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:e("header.services.tooltip.currentInstance",{current:i,toggle:j})})})]}),n.jsxs(Ps,{side:"top",align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:[l?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:e("header.services.remoteUpdate.title")}),n.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?e("header.services.remoteUpdate.available",{version:h.version||""}):g?e("header.services.remoteUpdate.checking"):v||e("header.services.remoteUpdate.upToDate")})]}),h?.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:y,children:e("header.services.remoteUpdate.actions.open")}):null]})}),n.jsx(Ty,{embedded:!0,open:r,onOpenChange:()=>{},onHostSwitched:()=>o(!1)})]})]}),n.jsx(ka,{open:u,onOpenChange:f,info:h,downloading:!1,downloaded:!1,progress:null,error:v,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const cr="inline-flex h-6 w-6 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",F2="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground";function L2(t){const e=He.c(28),{onOpenSettings:s,onOpenShortcuts:r,onOpenAbout:o,onOpenUpdate:i,showRuntimeButtons:a,showUpdateButton:l}=t,d=a===void 0?!0:a,u=l===void 0?!0:l,{t:f}=wt(),h=wg(),m=de(_2);if(!d&&!u)return null;let g;e[0]!==h||e[1]!==f?(g=f(h?"sessions.sidebar.footer.actions.updateApp":"sessions.sidebar.footer.actions.update"),e[0]=h,e[1]=f,e[2]=g):g=e[2];const b=g;let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=ve(cr,"text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]"),e[3]=v):v=e[3];let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Z,{name:"download",className:"h-4 w-4"}),e[4]=S):S=e[4];let x;e[5]!==i||e[6]!==b?(x=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:i,className:v,"aria-label":b,children:S})}),e[5]=i,e[6]=b,e[7]=x):x=e[7];let p;e[8]!==b?(p=n.jsx(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:b})}),e[8]=b,e[9]=p):p=e[9];let y;e[10]!==x||e[11]!==p?(y=n.jsxs(Ot,{children:[x,p]}),e[10]=x,e[11]=p,e[12]=y):y=e[12];const w=y;let j;e[13]!==m||e[14]!==o||e[15]!==s||e[16]!==r||e[17]!==d||e[18]!==u||e[19]!==f||e[20]!==w?(j=d?n.jsxs(n.Fragment,{children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:s,className:cr,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:n.jsx(Z,{name:"settings-3",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>de.getState().setUsageStatsPageOpen(!m),className:ve(cr,m&&F2),"aria-label":f("usageStats.openAction"),"aria-pressed":m,children:n.jsx(Z,{name:"bar-chart",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("usageStats.openAction")})})]}),n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:r,className:cr,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:n.jsx(Z,{name:"command",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),u?w:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:cr,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:n.jsx(Z,{name:"information",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[13]=m,e[14]=o,e[15]=s,e[16]=r,e[17]=d,e[18]=u,e[19]=f,e[20]=w,e[21]=j):j=e[21];const k=!d&&u?w:null;let P;e[22]!==d?(P=d?n.jsx(A2,{className:"ms-auto inline-flex h-6 min-w-0 max-w-[12rem] items-center gap-1.5 rounded-md px-2 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}):null,e[22]=d,e[23]=P):P=e[23];let A;return e[24]!==k||e[25]!==P||e[26]!==j?(A=n.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[j,k,P]}),e[24]=k,e[25]=P,e[26]=j,e[27]=A):A=e[27],A}function _2(t){return t.isUsageStatsPageOpen}function $2(t){const e=He.c(19),{query:s,showArchive:r,resetSessionSearch:o}=t,{t:i}=wt();let a;e[0]!==s||e[1]!==o?(a=()=>{de.getState().setArchivePageOpen(!0,s),o()},e[0]=s,e[1]=o,e[2]=a):a=e[2];const l=a;let d;e[3]!==i?(d=i("sessions.sidebar.empty.noMatches.title"),e[3]=i,e[4]=d):d=e[4];let u;e[5]!==d?(u=n.jsx("p",{className:"typography-ui-label font-semibold",children:d}),e[5]=d,e[6]=u):u=e[6];let f;e[7]!==i?(f=i("sessions.sidebar.empty.noMatches.description"),e[7]=i,e[8]=f):f=e[8];let h;e[9]!==f?(h=n.jsx("p",{className:"typography-meta mt-1",children:f}),e[9]=f,e[10]=h):h=e[10];let m;e[11]!==l||e[12]!==r||e[13]!==i?(m=r?n.jsx(Ct,{variant:"link",size:"xs",className:"mt-2 h-auto p-0 typography-meta",onClick:l,children:i("sessions.sidebar.empty.noMatches.searchArchive")}):null,e[11]=l,e[12]=r,e[13]=i,e[14]=m):m=e[14];let g;return e[15]!==u||e[16]!==h||e[17]!==m?(g=n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[u,h,m]}),e[15]=u,e[16]=h,e[17]=m,e[18]=g):g=e[18],g}const z2=t=>{for(const e of t.sessions.values())if(e.tabs.some(Qd))return!0;return!1},W2=()=>{const t=He.c(4),{terminal:e}=Ws(),s=Mo(z2);let r,o;return t[0]!==s||t[1]!==e?(r=()=>{const i=K2,a=H2;if(s)return Jl(e,"",a,i);let l=V2;return l=Jl(e,"",a,d=>{i(d),l()}),()=>l()},o=[e,s],t[0]=s,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),c.useEffect(r,o),null};function K2(t){const e=Mo.getState(),s=My(t.sessions),r=new Set([...e.sessions.keys(),...s.keys()]);for(const o of r)e.reconcileServerSessions(o,s.get(o)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function H2(){return new Map(Mo.getState().actionMutationRevisions)}function V2(){}const G2=50,U2=t=>{const e=new Map;for(const s of t){const r=ot(s.directory),o=s.branch.trim();if(!(!r||!o||e.has(r))&&(e.set(r,{directory:r,branch:o}),e.size===G2))break}return[...e.values()]},q2=t=>{const e=He.c(12),{normalizedProjects:s,enabled:r,ownership:o,isSessionsLoading:i,hasAuthoritativeGlobalSessions:a,isWorktreeTopologyLoading:l,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:f,addSessionToFolder:h}=t,m=r===void 0?!0:r;let g,b;e[0]!==h||e[1]!==f||e[2]!==m||e[3]!==u||e[4]!==a||e[5]!==i||e[6]!==l||e[7]!==s||e[8]!==o||e[9]!==d?(g=()=>{!m||i||!a||l||s.forEach(v=>{if(d.has(v.normalizedPath))return;const S=sf(v.normalizedPath),x=o.archivedSessionsByProject.get(v.id)??[],p=u[S]??[],y=new Map(p.map(Y2));x.forEach(w=>{const j=Ay(w,v.normalizedPath),k=j.toLowerCase();let P=y.get(k);P||(P=f(S,j),y.set(k,P)),P.sessionIds.includes(w.id)||h(S,P.id,w.id)})})},b=[s,m,o,i,a,l,d,u,f,h],e[0]=h,e[1]=f,e[2]=m,e[3]=u,e[4]=a,e[5]=i,e[6]=l,e[7]=s,e[8]=o,e[9]=d,e[10]=g,e[11]=b):(g=e[10],b=e[11]),c.useEffect(g,b)};function Y2(t){return[t.name.toLowerCase(),t]}function X2({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:s,projectMap:r,metaByProject:o,rememberedSessionId:i,fallbackSessionId:a}){if(e&&s===t)return{kind:"preserve-current"};if(s==null){const u=!!(e&&Array.from(o.entries()).some(([f,h])=>f!==t&&h.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(i&&r.has(i)?i:null)??a;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const Q2=t=>{const e=He.c(26),{projectSections:s,activeProjectId:r,activeSessionByProject:o,setActiveSessionByProject:i,currentSessionId:a,currentSessionOwnerProjectId:l,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:f,openNewSessionDraft:h,setSessionSwitcherOpen:m}=t;let g,b;if(e[0]!==s){b=new Map,g=new Map;const k=(P,A,B,R)=>{b.has(P)||b.set(P,new Map);const E=b.get(P);R.forEach(T=>{const z=ot(T.worktree?.path??T.session.directory??B??A);E.set(T.session.id,{directory:z}),g.has(P)||g.set(P,{id:T.session.id,directory:z}),T.children.length>0&&k(P,A,z,T.children)})};s.forEach(P=>{P.groups.forEach(A=>{k(P.project.id,P.project.normalizedPath,A.directory,A.sessions)})}),e[0]=s,e[1]=g,e[2]=b}else g=e[1],b=e[2];let v;e[3]!==g||e[4]!==b?(v={metaByProject:b,firstSessionByProject:g},e[3]=g,e[4]=b,e[5]=v):v=e[5];const S=v,x=c.useRef(null);let p,y;e[6]!==r||e[7]!==o||e[8]!==a||e[9]!==l||e[10]!==d||e[11]!==f||e[12]!==u||e[13]!==h||e[14]!==s||e[15]!==S||e[16]!==i||e[17]!==m?(p=()=>{if(!r||u||de.getState().isNewWorktreeDialogOpen||x.current===r)return;const k=s.find(R=>R.project.id===r);if(!k)return;if(x.current===null){x.current=r;return}const P=S.metaByProject.get(r);if(a&&P&&P.has(a)){x.current=r,i(R=>{if(R.get(r)===a)return R;const E=new Map(R);return E.set(r,a),E});return}const A=X2({activeProjectId:r,currentSessionId:a,currentSessionOwnerProjectId:l,projectMap:P,metaByProject:S.metaByProject,rememberedSessionId:o.get(r),fallbackSessionId:S.firstSessionByProject.get(r)?.id??null});if(A.kind==="preserve-current"){l===r&&(x.current=r);return}if(x.current=r,A.kind==="open-draft"){f&&m(!1),h({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(A.kind!=="select-session")return;const B=P?.get(A.sessionId)?.directory??null;d(A.sessionId,B)},y=[r,o,a,l,d,u,f,h,s,S,m,i],e[6]=r,e[7]=o,e[8]=a,e[9]=l,e[10]=d,e[11]=f,e[12]=u,e[13]=h,e[14]=s,e[15]=S,e[16]=i,e[17]=m,e[18]=p,e[19]=y):(p=e[18],y=e[19]),c.useLayoutEffect(p,y);let w,j;e[20]!==r||e[21]!==a||e[22]!==S||e[23]!==i?(w=()=>{if(!r||!a)return;const k=S.metaByProject.get(r);!k||!k.has(a)||i(P=>{if(P.get(r)===a)return P;const A=new Map(P);return A.set(r,a),A})},j=[r,a,S,i],e[20]=r,e[21]=a,e[22]=S,e[23]=i,e[24]=w,e[25]=j):(w=e[24],j=e[25]),c.useEffect(w,j)},Z2=t=>{const e=He.c(20);let s,r,o,i;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:o,sessionOwnerBySessionId:i,...s}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i):(s=e[1],r=e[2],o=e[3],i=e[4]);const a=nt(J2),l=nt(eC);let d;e[5]!==a||e[6]!==i?(d=a?i?.get(a)?.projectId??null:null,e[5]=a,e[6]=i,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[h,m]=c.useState(f);let g;e[10]!==h||e[11]!==s||e[12]!==a||e[13]!==u||e[14]!==l?(g={...s,activeSessionByProject:h,setActiveSessionByProject:m,currentSessionId:a,currentSessionOwnerProjectId:u,newSessionDraftOpen:l},e[10]=h,e[11]=s,e[12]=a,e[13]=u,e[14]=l,e[15]=g):g=e[15],Q2(g);let b,v;return e[16]!==h||e[17]!==o?(b=()=>{o(h)},v=[h,o],e[16]=h,e[17]=o,e[18]=b,e[19]=v):(b=e[18],v=e[19]),c.useEffect(b,v),null};function J2(t){return t.currentSessionId}function eC(t){return!!t.newSessionDraft?.open}const tC=t=>{const e=He.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 o=r;let i;e[2]!==s?(i=d=>s.archivedSessionsByProject.get(d)??[],e[2]=s,e[3]=i):i=e[3];const a=i;let l;return e[4]!==a||e[5]!==o?(l={getSessionsForProject:o,getArchivedSessionsForProject:a},e[4]=a,e[5]=o,e[6]=l):l=e[6],l},sC=(t,e)=>t.map(s=>{const r=ot(s.path)??s.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
1045
|
-
`),nC=(t,e,s)=>e.length===0?"":t.map(r=>s.get(r.id)??"").join(","),rC=[],oC=new WeakMap,iC=t=>{const{normalizedProjects:e,getSessionsForProject:s,getArchivedSessionsForProject:r,availableWorktreesByProject:o,projectRepoStatus:i,projectRootBranches:a,gitBranches:l,sessionOrderRanks:d,lastRepoStatus:u,buildGroupedSessions:f,hasSessionSearchQuery:h,normalizedSessionSearchQuery:m,filterSessionNodesForSearch:g,buildGroupSearchText:b,foldersMap:v,standaloneGroups:S}=t,x=c.useRef(new Map),p=c.useMemo(()=>{const R=x.current,E=new Map;let T=0,z=0;const O=(D,Q)=>D.length===Q.length&&D.every((N,C)=>N===Q[C]),W=e.map(D=>{const Q=s(D.id),N=r(D.id),C=o.get(D.normalizedPath)??rC,I=i.has(D.id)?!!i.get(D.id):u,H=a.get(D.id)??null,M=sC(C,l),_=nC(Q,C,d),F=R.get(D.id);if(F&&F.project===D&&O(F.activeSessions,Q)&&O(F.archivedSessions,N)&&F.availableWorktrees===C&&F.rootBranch===H&&F.worktreeBranchesKey===M&&F.worktreeRanksKey===_&&F.isRepo===I&&F.buildGroupedSessions===f)return T+=1,E.set(D.id,F),F.section;if(z+=1,F){const te=F.project!==D?"project":O(F.activeSessions,Q)?O(F.archivedSessions,N)?F.availableWorktrees!==C?"worktrees":F.rootBranch!==H?"branch":F.worktreeBranchesKey!==M?"worktreeBranches":F.worktreeRanksKey!==_?"worktreeRanks":F.isRepo!==I?"repo":"builder":"archived":"sessions";Ss(`ui.sidebar.project_section.rebuilt_reason.${te}`)}const ee=nf([...Q,...N]),ne=f(ee,D.normalizedPath,C,H,I),re={project:D,groups:ne};return E.set(D.id,{project:D,activeSessions:Q,archivedSessions:N,availableWorktrees:C,rootBranch:H,worktreeBranchesKey:M,worktreeRanksKey:_,isRepo:I,buildGroupedSessions:f,section:re}),re});return x.current=E,T>0&&Ss("ui.sidebar.project_section.reused",T),z>0&&Ss("ui.sidebar.project_section.rebuilt",z),W},[e,s,r,o,i,u,f,a,l,d]),y=c.useMemo(()=>p,[p]),w=c.useMemo(()=>{if(!h)return oC;const R=new WeakMap,T=m.trim().toLowerCase().startsWith("ses_"),z=O=>{const W=g(O.sessions,m),D=Th(W,m),Q=!T&&po([b(O)],m),N=er(O).flatMap(({scopeKey:I})=>v[I]??[]),C=T?0:N.filter(I=>po([I.name],m)).length;R.set(O,{filteredNodes:W,matchedSessionCount:D,folderNameMatchCount:C,groupMatches:Q,hasMatch:Q||D>0||C>0})};return y.forEach(O=>{O.groups.forEach(z)}),S.forEach(z),R},[h,y,S,g,m,b,v]),j=c.useMemo(()=>h?y.map(R=>({...R,groups:R.groups.filter(E=>w.get(E)?.hasMatch===!0)})).filter(R=>R.groups.length>0):y,[h,y,w]),k=h?j:y,P=c.useRef(new WeakMap),A=c.useMemo(()=>{const R=P.current;return k.map(E=>{const T=R.get(E);if(T&&T.query===m)return T.section;const z=E.groups.filter(I=>!I.isArchivedBucket),O=E.groups.filter(I=>I.isArchivedBucket),W=z.flatMap(I=>h?w.get(I)?.filteredNodes??[]:I.sessions),D=z.map(I=>({scopeKey:I.folderScopeKey??ot(I.directory??null),directory:I.directory??null})).filter(I=>!!I.scopeKey),Q=z.find(I=>I.isMain)??null,N={id:"flat",label:Q?.label??"",branch:Q?.branch??null,description:Q?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:Q?.directory??E.project.normalizedPath,folderScopeKey:Q?.folderScopeKey??E.project.normalizedPath,folderScopes:D,sessions:W};if(h){const I=z.map(H=>w.get(H)).filter(H=>!!H);w.set(N,{filteredNodes:W,matchedSessionCount:I.reduce((H,M)=>H+M.matchedSessionCount,0),folderNameMatchCount:I.reduce((H,M)=>H+M.folderNameMatchCount,0),groupMatches:I.some(H=>H.groupMatches),hasMatch:I.some(H=>H.hasMatch)})}const C={project:E.project,groups:[N,...O]};return R.set(E,{query:m,section:C}),C})},[w,h,m,k]),B=c.useMemo(()=>{if(!h)return 0;const R=(T,z)=>{const O=w.get(z);if(!O)return T;const W=O.folderNameMatchCount+(O.groupMatches?1:0);return T+O.matchedSessionCount+W},E=k.reduce((T,z)=>z.groups.reduce(R,T),0);return S.reduce(R,E)},[h,k,S,w]);return{projectSections:p,visibleProjectSections:y,groupSearchDataByGroup:w,searchableProjectSections:j,sectionsForRender:k,flatSectionsForRender:A,searchMatchCount:B}},aC=180,ad=150,lC=2,cC=8,ld=[-1,1],Kr=t=>`${t.directory}
|
|
1046
|
-
${t.sessionId}`,cd=t=>t?.directory?.trim()||null,Bh=c.createContext(null),dC=()=>c.useContext(Bh),uC=({enabled:t=!0,currentSessionId:e,sortedSessions:s,workSessions:r=[],prefetchSession:o})=>{const i=c.useRef(new Map),a=c.useRef(new Set),l=c.useRef([]),d=c.useRef(new Set),u=c.useRef(0),f=c.useMemo(()=>Sn(),[]),h=c.useCallback(()=>{u.current+=1,l.current=[],i.current.forEach(x=>window.clearTimeout(x)),i.current.clear(),a.current.clear()},[]),m=c.useCallback(()=>{if(!(!t||f))for(;d.current.size<lC&&l.current.length>0;){const x=l.current.shift();if(!x)break;if(x.generation!==u.current||nt.getState().currentSessionId===x.sessionId||_i(x.sessionId,x.directory).renderable)continue;const y=Kr(x);d.current.add(y),o({directory:x.directory,sessionID:x.sessionId}).catch(()=>{}).finally(()=>{d.current.delete(y),m()})}},[t,f,o]),g=c.useCallback((x,p="neighbor")=>{const y=x?.id,w=cd(x);if(!t||f||!y||!w||y===e)return;const j={sessionId:y,directory:w,generation:u.current},k=Kr(j);if(_i(y,w).renderable||d.current.has(k)||l.current.some(B=>Kr(B)===k))return;const P=i.current.get(k);if(P!==void 0){if(p==="hover"&&!a.current.has(k))return;window.clearTimeout(P)}p==="hover"?a.current.add(k):a.current.delete(k);const A=window.setTimeout(()=>{if(i.current.delete(k),a.current.delete(k),j.generation!==u.current)return;const B=l.current;B.length>=cC&&B.shift(),B.push(j),m()},aC);i.current.set(k,A)},[e,t,f,m]),b=c.useCallback(x=>{const p=cd(x);if(!p)return;const y=Kr({sessionId:x.id,directory:p}),w=i.current.get(y);w===void 0||!a.current.has(y)||(window.clearTimeout(w),i.current.delete(y),a.current.delete(y))},[]),v=c.useRef(g);v.current=g;const[S]=c.useState(()=>({schedule:x=>v.current(x,"hover"),cancel:b}));return c.useEffect(()=>{h()},[h,e,t,f]),c.useEffect(()=>{if(!t||f||!e||s.length===0)return;const x=window.setTimeout(()=>{const p=s.findIndex(y=>y.id===e);if(!(p<0))for(const y of ld)g(s[p+y])},ad);return()=>window.clearTimeout(x)},[e,t,f,g,s]),c.useEffect(()=>{if(!t||f||!e||r.length===0)return;const x=window.setTimeout(()=>{const p=r.findIndex(y=>y.id===e);if(!(p<0))for(const y of ld)g(r[p+y])},ad);return()=>window.clearTimeout(x)},[e,t,f,r,g]),c.useEffect(()=>h,[h]),S},fC=t=>{const e=He.c(11);let s,r;e[0]!==t?({children:r,...s}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=nt(hC);let i;e[3]!==s||e[4]!==o?(i={...s,currentSessionId:o},e[3]=s,e[4]=o,e[5]=i):i=e[5];const a=uC(i);let l;if(e[6]!==r||e[7]!==a){let d;e[9]!==a?(d={value:a},e[9]=a,e[10]=d):d=e[10],l=c.createElement(Bh.Provider,d,r),e[6]=r,e[7]=a,e[8]=l}else l=e[8];return l};function hC(t){return t.currentSessionId}const pC=6,tr=t=>wa(t,pC),dd=t=>`calc(${tr(t)} + 20px)`,mC=t=>{const e=He.c(92),{folder:s,displayName:r,sessions:o,subFolderItems:i,isCollapsed:a,collapsedActivityState:l,onToggle:d,onRename:u,onDelete:f,children:h,renderBody:m,mobileVariant:g,alwaysShowActions:b,isRenaming:v,renameDraft:S,onRenameDraftChange:x,onRenameSave:p,onRenameCancel:y,droppableRef:w,isDropTarget:j,onNewSession:k,depth:P,canExpand:A,hideActions:B,archivedBucket:R}=t,E=l===void 0?null:l,T=m===void 0?!0:m,O=b===void 0?g===void 0?!1:g:b,W=v===void 0?!1:v,D=S===void 0?"":S,Q=j===void 0?!1:j,N=P===void 0?0:P,C=A===void 0?!0:A,I=B===void 0?!1:B,H=R===void 0?!1:R,{t:M}=wt(),[_,F]=c.useState(!1),[ee,ne]=c.useState(""),re=c.useRef(null),te=W||_,K=W?D:ee;let q;e[0]!==s.name?(q=()=>{ne(s.name),F(!0)},e[0]=s.name,e[1]=q):q=e[1];const oe=q;let fe;e[2]!==K||e[3]!==s.name||e[4]!==W||e[5]!==u||e[6]!==p?(fe=()=>{const et=K.trim();et&&et!==s.name&&u(et),W&&p&&p(),F(!1),ne("")},e[2]=K,e[3]=s.name,e[4]=W,e[5]=u,e[6]=p,e[7]=fe):fe=e[7];const ce=fe;let ke;e[8]!==W||e[9]!==y?(ke=()=>{W&&y&&y(),F(!1),ne("")},e[8]=W,e[9]=y,e[10]=ke):ke=e[10];const De=ke;let Ce;e[11]!==W||e[12]!==x?(Ce=et=>{W&&x?x(et):ne(et)},e[11]=W,e[12]=x,e[13]=Ce):Ce=e[13];const Y=Ce;let je,we;e[14]!==W?(je=()=>{if(!W)return;const et=()=>{const Ee=re.current;Ee&&(Ee.focus(),Ee.select())},ct=requestAnimationFrame(et),pe=window.setTimeout(et,0);return()=>{cancelAnimationFrame(ct),window.clearTimeout(pe)}},we=[W],e[14]=W,e[15]=je,e[16]=we):(je=e[15],we=e[16]),c.useEffect(je,we);const Pe=a?"folder":"folder-open",L=!te&&C;let ie;e[17]!==N?(ie=tr(N),e[17]=N,e[18]=ie):ie=e[18];let G;e[19]!==ie?(G={paddingInlineStart:ie},e[19]=ie,e[20]=G):G=e[20];const ae=Q?"bg-primary/10 ring-1 ring-inset ring-primary/30":"hover:bg-interactive-hover/60";let ge;e[21]!==ae?(ge=ve("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",ae),e[21]=ae,e[22]=ge):ge=e[22];let me;e[23]!==d||e[24]!==L?(me=L?et=>{et.currentTarget.blur(),d()}:void 0,e[23]=d,e[24]=L,e[25]=me):me=e[25];const be=L?"button":void 0,ye=L?0:void 0;let Te;e[26]!==d||e[27]!==L?(Te=L?et=>{(et.key==="Enter"||et.key===" ")&&(et.preventDefault(),d())}:void 0,e[26]=d,e[27]=L,e[28]=Te):Te=e[28];let $;e[29]!==s.name||e[30]!==a||e[31]!==M||e[32]!==L?($=L?a?M("sessions.sidebar.folderItem.expandAria",{folderName:s.name}):M("sessions.sidebar.folderItem.collapseAria",{folderName:s.name}):void 0,e[29]=s.name,e[30]=a,e[31]=M,e[32]=L,e[33]=$):$=e[33];const he=H?O?"pe-7":"group-hover/folder:pe-7 group-focus-within/folder:pe-7":O?"pe-20":"group-hover/folder:pe-20 group-focus-within/folder:pe-20";let se;e[34]!==he?(se=ve("min-w-0 flex items-center gap-0.5 flex-1",he),e[34]=he,e[35]=se):se=e[35];let Ne;e[36]!==C||e[37]!==a?(Ne=C?n.jsx(jr,{expanded:!a}):n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}),e[36]=C,e[37]=a,e[38]=Ne):Ne=e[38];const Ue=Q?"text-primary":"text-muted-foreground";let We;e[39]!==Ue?(We=ve("mx-px h-3 w-3 flex-shrink-0",Ue),e[39]=Ue,e[40]=We):We=e[40];let Ke;e[41]!==Pe||e[42]!==We?(Ke=n.jsx(Z,{name:Pe,className:We}),e[41]=Pe,e[42]=We,e[43]=Ke):Ke=e[43];let Be;e[44]!==E||e[45]!==r||e[46]!==K||e[47]!==s.name||e[48]!==De||e[49]!==Y||e[50]!==ce||e[51]!==Q||e[52]!==te||e[53]!==o||e[54]!==M?(Be=te?n.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:gC,onMouseDown:bC,onSubmit:et=>{et.preventDefault(),ce()},children:[n.jsx("input",{ref:re,value:K,onChange:et=>Y(et.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:M("sessions.sidebar.folderItem.namePlaceholder"),onClick:yC,onPointerDown:xC,onMouseDown:SC,onKeyDown:et=>{if(et.key==="Escape"){et.stopPropagation(),De();return}(et.key===" "||et.key==="Enter")&&et.stopPropagation()}}),n.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:vC,onPointerDown:wC,onMouseDown:kC,children:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:et=>{et.stopPropagation(),De()},onPointerDown:jC,onMouseDown:CC,className:"shrink-0 text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"close",className:"size-4"})})]}):n.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("span",{className:ve("typography-ui-label font-medium truncate",Q?"text-primary":"text-foreground"),children:r??s.name})}),n.jsx(Tt,{side:"top",sideOffset:6,className:"max-w-xs",children:r??s.name})]}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",o.length]}),E?n.jsx(kg,{state:E}):null]}),e[44]=E,e[45]=r,e[46]=K,e[47]=s.name,e[48]=De,e[49]=Y,e[50]=ce,e[51]=Q,e[52]=te,e[53]=o,e[54]=M,e[55]=Be):Be=e[55];let U;e[56]!==se||e[57]!==Ne||e[58]!==Ke||e[59]!==Be?(U=n.jsxs("div",{className:se,children:[Ne,Ke,Be]}),e[56]=se,e[57]=Ne,e[58]=Ke,e[59]=Be,e[60]=U):U=e[60];let Me;e[61]!==O||e[62]!==H||e[63]!==s.name||e[64]!==oe||e[65]!==I||e[66]!==f||e[67]!==k||e[68]!==te||e[69]!==M?(Me=!te&&(!I||H)?n.jsx("div",{className:ve("absolute inset-e-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",O?"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:[!H&&k?n.jsx("button",{type:"button",onClick:et=>{et.stopPropagation(),k()},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":M("sessions.sidebar.folderItem.newSessionAria",{folderName:s.name}),title:M("sessions.sidebar.project.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-3.5 w-3.5"})}):null,H?null:n.jsx("button",{type:"button",onClick:et=>{et.stopPropagation(),oe()},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":M("sessions.sidebar.folderItem.renameAria",{folderName:s.name}),children:n.jsx(Z,{name:"pencil-ai",className:"h-3 w-3"})}),n.jsx("button",{type:"button",onClick:et=>{et.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":H?M("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:s.name}):M("sessions.sidebar.folderItem.deleteFolderAria",{folderName:s.name}),children:n.jsx(Z,{name:"delete-bin",className:"h-3 w-3"})})]})}):null,e[61]=O,e[62]=H,e[63]=s.name,e[64]=oe,e[65]=I,e[66]=f,e[67]=k,e[68]=te,e[69]=M,e[70]=Me):Me=e[70];let Ge;e[71]!==w||e[72]!==G||e[73]!==ge||e[74]!==me||e[75]!==be||e[76]!==ye||e[77]!==Te||e[78]!==$||e[79]!==U||e[80]!==Me?(Ge=n.jsxs("div",{ref:w,style:G,className:ge,onClick:me,role:be,tabIndex:ye,onKeyDown:Te,"aria-label":$,children:[U,Me]}),e[71]=w,e[72]=G,e[73]=ge,e[74]=me,e[75]=be,e[76]=ye,e[77]=Te,e[78]=$,e[79]=U,e[80]=Me,e[81]=Ge):Ge=e[81];let Ve;e[82]!==h||e[83]!==a||e[84]!==T||e[85]!==o||e[86]!==i||e[87]!==M?(Ve=!a&&T?n.jsxs("div",{className:"pb-1",children:[i,o.length>0?h:i?null:n.jsx("div",{className:"py-1 ps-1.5 text-start typography-micro text-muted-foreground/70",children:M("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[82]=h,e[83]=a,e[84]=T,e[85]=o,e[86]=i,e[87]=M,e[88]=Ve):Ve=e[88];let dt;return e[89]!==Ge||e[90]!==Ve?(dt=n.jsxs("div",{className:"oc-folder",children:[Ge,Ve]}),e[89]=Ge,e[90]=Ve,e[91]=dt):dt=e[91],dt},Fh=c.memo(mC);function gC(t){return t.stopPropagation()}function bC(t){return t.stopPropagation()}function yC(t){return t.stopPropagation()}function xC(t){return t.stopPropagation()}function SC(t){return t.stopPropagation()}function vC(t){return t.stopPropagation()}function wC(t){return t.stopPropagation()}function kC(t){return t.stopPropagation()}function jC(t){return t.stopPropagation()}function CC(t){return t.stopPropagation()}function PC(t){const e=He.c(11);let s,r,o;e[0]!==t?({notifyOnSubtasks:r,activityNodes:s,...o}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o):(s=e[1],r=e[2],o=e[3]);const i=o.isCollapsed&&!o.archivedBucket;let a;e[4]!==s||e[5]!==r||e[6]!==i?(a={nodes:s,includeUnreadSubtasks:r,enabled:i},e[4]=s,e[5]=r,e[6]=i,e[7]=a):a=e[7];const l=lu(a);let d;return e[8]!==l||e[9]!==o?(d=n.jsx(Fh,{...o,collapsedActivityState:l}),e[8]=l,e[9]=o,e[10]=d):d=e[10],d}const ko=t=>{const e=He.c(16),{directory:s,className:r}=t,{t:o}=wt();let i;e[0]!==s?(i=ym(s),e[0]=s,e[1]=i):i=e[1];const a=i;let l;if(e[2]!==a?(l=S=>S.sessions.get(a),e[2]=a,e[3]=l):l=e[3],!Mo(l)?.tabs.some(Qd))return null;let f;e[4]!==o?(f=o("sessions.sidebar.projectAction.active"),e[4]=o,e[5]=f):f=e[5];const h=f;let m;e[6]!==r?(m=ve("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=m):m=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Z,{name:"pulse",className:"size-3.5"}),e[8]=g):g=e[8];let b;e[9]!==a||e[10]!==h||e[11]!==m?(b=n.jsx("span",{className:m,role:"img","aria-label":h,"data-action-directory":a,children:g}),e[9]=a,e[10]=h,e[11]=m,e[12]=b):b=e[12];let v;return e[13]!==h||e[14]!==b?(v=n.jsx(Rn,{label:h,children:b}),e[13]=h,e[14]=b,e[15]=v):v=e[15],v},EC=t=>{const e=He.c(19),{sessionId:s,dragKey:r,ownerKey:o,sessionDirectory:i,sessionTitle:a,archivedBucket:l,children:d}=t,u=o===void 0?null:o,f=l===void 0?!1:l,h=`session-drag:${r??s}`;let m;e[0]!==f||e[1]!==u||e[2]!==i||e[3]!==s||e[4]!==a?(m={type:"session",sessionId:s,ownerKey:u,sessionDirectory:i,sessionTitle:a,archivedBucket:f},e[0]=f,e[1]=u,e[2]=i,e[3]=s,e[4]=a,e[5]=m):m=e[5];let g;e[6]!==f||e[7]!==h||e[8]!==m?(g={id:h,disabled:f,data:m},e[6]=f,e[7]=h,e[8]=m,e[9]=g):g=e[9];const{attributes:b,listeners:v,setNodeRef:S,isDragging:x}=m1(g);let p;e[10]!==v?(p=k=>{k.stopPropagation(),v?.onPointerDown&&v.onPointerDown(k)},e[10]=v,e[11]=p):p=e[11];const y=p,w=`touch-pan-y select-none${x?" opacity-30":""}`;let j;return e[12]!==b||e[13]!==d||e[14]!==y||e[15]!==v||e[16]!==S||e[17]!==w?(j=n.jsx("div",{ref:S,...b,...v,onPointerDown:y,className:w,children:d}),e[12]=b,e[13]=d,e[14]=y,e[15]=v,e[16]=S,e[17]=w,e[18]=j):j=e[18],j},Lh=t=>{const e=He.c(20),{folderId:s,scopeKey:r,ownerKey:o,disabled:i,children:a}=t,l=i===void 0?!1:i;let d;e[0]!==s||e[1]!==r?(d=In(r,s),e[0]=s,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let f;e[3]!==l||e[4]!==r?(f=l||ol(r),e[3]=l,e[4]=r,e[5]=f):f=e[5];let h;e[6]!==s||e[7]!==o||e[8]!==r?(h={type:"folder",folderId:s,scopeKey:r,ownerKey:o},e[6]=s,e[7]=o,e[8]=r,e[9]=h):h=e[9];let m;e[10]!==u||e[11]!==f||e[12]!==h?(m={id:u,disabled:f,data:h},e[10]=u,e[11]=f,e[12]=h,e[13]=m):m=e[13];const{setNodeRef:g,isOver:b}=g1(m);let v;e[14]!==a||e[15]!==b||e[16]!==g?(v=a(g,b),e[14]=a,e[15]=b,e[16]=g,e[17]=v):v=e[17];let S;return e[18]!==v?(S=n.jsx(n.Fragment,{children:v}),e[18]=v,e[19]=S):S=e[19],S},NC=t=>{const e=He.c(22),{scopeKey:s,ownerKey:r,hasFolders:o,onSessionDroppedOnFolder:i,children:a}=t,l=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=_o(sn(zo,d),sn($o,u)),[h,m]=c.useState(null),[g,b]=c.useState("Session"),[v,S]=c.useState(null),[x,p]=c.useState(null);if(!s){let R;return e[2]!==a?(R=n.jsx(n.Fragment,{children:a}),e[2]=a,e[3]=R):R=e[3],R}let y;e[4]!==i||e[5]!==l?(y=R=>{m(null),S(null),p(null);const{active:E,over:T}=R;if(!T)return;const z=E.data.current,O=T.data.current;z?.type!=="session"||!z.sessionId||!z.ownerKey||z.archivedBucket===!0||l&&z.ownerKey!==l||O?.type!=="folder"||!O.folderId||!O.scopeKey||!O.ownerKey||ol(O.scopeKey)||O.ownerKey!==z.ownerKey||i(z.sessionId,{folderId:O.folderId,scopeKey:O.scopeKey,ownerKey:O.ownerKey},z.ownerKey)},e[4]=i,e[5]=l,e[6]=y):y=e[6];const w=y;let j,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=R=>{const E=R.active.data.current;if(E?.type==="session"&&E.sessionId){m(E.sessionId),b(E.sessionTitle??"Session");const T=R.active.rect.current.initial?.width,z=R.active.rect.current.initial?.height;S(T??null),p(z??null)}},k=()=>{m(null),S(null),p(null)},e[7]=j,e[8]=k):(j=e[7],k=e[8]);let P;e[9]!==x||e[10]!==h||e[11]!==g||e[12]!==v||e[13]!==o?(P=h&&o?n.jsxs("div",{style:{width:v?`${v}px`:"auto",height:x?`${x}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(Z,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground me-2 flex-shrink-0"}),n.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:g})]}):null,e[9]=x,e[10]=h,e[11]=g,e[12]=v,e[13]=o,e[14]=P):P=e[14];let A;e[15]!==P?(A=n.jsx(b1,{children:P}),e[15]=P,e[16]=A):A=e[16];let B;return e[17]!==a||e[18]!==w||e[19]!==f||e[20]!==A?(B=n.jsxs(Wo,{sensors:f,collisionDetection:Ko,onDragStart:j,onDragCancel:k,onDragEnd:w,children:[a,A]}),e[17]=a,e[18]=w,e[19]=f,e[20]=A,e[21]=B):B=e[21],B},_h=c.createContext(null),IC=({entries:t,descendantIds:e,sessionsById:s,children:r})=>{const o=c.useRef(t),i=c.useRef(e),a=c.useRef(s);o.current=t,i.current=e,a.current=s;const l=c.useRef(null);return l.current===null&&(l.current={getEntries:()=>o.current,getDescendantIds:()=>i.current,getSessionsById:()=>a.current}),n.jsx(_h.Provider,{value:l.current,children:r})},$h=()=>c.useContext(_h),RC=(t,e,s)=>{const r=t[0];if(!r)return null;const o=s??r.scopeKey,i=[],a=new Set;for(const l of t){if(o&&l.scopeKey!==o)continue;const d=l.descendantRange,u=d?[l.id,...e.slice(d[0],d[1])]:[l.id];for(const f of u)a.has(f)||(a.add(f),i.push(f))}return i.length>0?{ids:i,scopeKey:o}:null},zh=(t,e)=>{if(t.size===0)return!1;for(const s of t)if(!e.get(s)?.time?.archived)return!1;return!0},DC=({menuInstanceKey:t,contextMenuInstanceKey:e,openSidebarMenuKey:s,setOpenSidebarMenuKey:r,hasDeferredCloseWork:o,onCloseComplete:i})=>{const[a,l]=c.useState(!1),[d,u]=c.useState(!1),f=s===t&&!d,h=e?s===e&&!d:a,m=p=>{if(s===p){if(o()){u(!0);return}r(null)}},g=p=>{if(p){l(!1),u(!1),r(t);return}m(t)},b=p=>{if(!e){l(p);return}if(p){u(!1),r(e);return}m(e)},v=p=>{p||(i(),u(!1),(s===t||s===e)&&r(null))},S=()=>{u(!1),r(f?null:t)},x=c.useRef({menu:g,contextMenu:b});return x.current={menu:g,contextMenu:b},c.useEffect(()=>{if(!f&&!h)return;const p=()=>{h&&x.current.contextMenu(!1),f&&x.current.menu(!1)};return window.addEventListener("blur",p),()=>window.removeEventListener("blur",p)},[f,h]),{isMenuOpen:f,isContextMenuOpen:h,handleMenuOpenChange:g,handleContextMenuOpenChange:b,handleMenuOpenChangeComplete:v,toggleMenu:S}},TC=t=>{const e=He.c(10),{project:s,fallback:r}=t,{currentTheme:o}=Cr(),i=s.iconImage??null;let a;e[0]!==s.id||e[1]!==i?(a={id:s.id,iconImage:i},e[0]=s.id,e[1]=i,e[2]=a):a=e[2];let l;e[3]!==o.colors.surface.foreground||e[4]!==o.metadata.variant?(l={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[3]=o.colors.surface.foreground,e[4]=o.metadata.variant,e[5]=l):l=e[5];let d;return e[6]!==r||e[7]!==a||e[8]!==l?(d=n.jsx(Pa,{project:a,options:l,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=a,e[8]=l,e[9]=d):d=e[9],d},MC=t=>{const e=He.c(14),{project:s,label:r}=t,o=s.icon?ja[s.icon]:null;let i;e[0]!==s.color?(i=Ca(s.color),e[0]=s.color,e[1]=i):i=e[1];const a=i;let l;e[2]!==a||e[3]!==o?(l=o?n.jsx(Z,{name:o,className:ve("h-3 w-3",!a&&"text-muted-foreground/75"),style:a?{color:a}:void 0}):n.jsx(Z,{name:"folder",className:"h-3 w-3 text-muted-foreground/75",style:a?{color:a}:void 0}),e[2]=a,e[3]=o,e[4]=l):l=e[4];const d=l;let u;e[5]!==r?(u=r?{role:"img","aria-label":r}:{},e[5]=r,e[6]=u):u=e[6];const f=u;let h;e[7]!==d||e[8]!==f||e[9]!==s?(h=s.iconImage?n.jsx("span",{className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:s.iconBackground?{backgroundColor:s.iconBackground}:void 0,...f,children:n.jsx(TC,{project:s,fallback:d})}):n.jsx("span",{className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center",...f,children:d}),e[7]=d,e[8]=f,e[9]=s,e[10]=h):h=e[10];const m=h;let g;return e[11]!==r||e[12]!==m?(g=r?n.jsx(Rn,{label:r,children:m}):m,e[11]=r,e[12]=m,e[13]=g):g=e[13],g},ca=t=>{const e=He.c(53),{compact:s,project:r,projectLabel:o,title:i,titleClassName:a,branchLabel:l,spaceMark:d,metaLineLead:u,statusDot:f,pinnedMarker:h,timeSlot:m,directoryIndicator:g,prBadge:b,zombieIndicator:v,goal:S,badges:x,doneHint:p,providerId:y,metaPaddingClass:w,hideMetaOnHoverClass:j,actionsReserveClass:k,actionsMaskClass:P}=t,A=s===void 0?!1:s,B=d===void 0?null:d,R=u===void 0?null:u,E=S===void 0?null:S,T=p===void 0?null:p;let z;e[0]!==j||e[1]!==w?(z=ve("ms-auto flex flex-shrink-0 items-center gap-1 transition-opacity",w,j),e[0]=j,e[1]=w,e[2]=z):z=e[2];const O=A?E:null,W=A?x:null;let D;e[3]!==m?(D=n.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:m}),e[3]=m,e[4]=D):D=e[4];let Q;e[5]!==g||e[6]!==T||e[7]!==h||e[8]!==f||e[9]!==z||e[10]!==O||e[11]!==W||e[12]!==D?(Q=n.jsxs("span",{className:z,children:[O,W,g,h,T,f,D]}),e[5]=g,e[6]=T,e[7]=h,e[8]=f,e[9]=z,e[10]=O,e[11]=W,e[12]=D,e[13]=Q):Q=e[13];const N=Q;let C;e[14]!==P||e[15]!==a?(C=ve("oc-ui-start-align min-w-0 flex-1 truncate typography-ui-label font-normal",P,a),e[14]=P,e[15]=a,e[16]=C):C=e[16];let I;e[17]!==C||e[18]!==i?(I=n.jsx("div",{dir:"auto",className:C,children:i}),e[17]=C,e[18]=i,e[19]=I):I=e[19];const H=I;if(A){let oe;e[20]!==k?(oe=ve("@container relative flex w-full min-w-0 items-center gap-1",k),e[20]=k,e[21]=oe):oe=e[21];let fe;return e[22]!==N||e[23]!==oe||e[24]!==H?(fe=n.jsxs("div",{className:oe,children:[H,N]}),e[22]=N,e[23]=oe,e[24]=H,e[25]=fe):fe=e[25],fe}let M;e[26]!==k?(M=ve("@container relative flex h-5 w-full min-w-0 items-center gap-1",k),e[26]=k,e[27]=M):M=e[27];let _;e[28]!==N||e[29]!==M||e[30]!==H?(_=n.jsxs("div",{className:M,children:[H,N]}),e[28]=N,e[29]=M,e[30]=H,e[31]=_):_=e[31];let F;e[32]!==r||e[33]!==o?(F=r?n.jsx(MC,{project:r,label:o}):null,e[32]=r,e[33]=o,e[34]=F):F=e[34];let ee;e[35]!==l||e[36]!==R||e[37]!==B?(ee=R??(l?n.jsxs(n.Fragment,{children:[B?n.jsx(Z,{name:"box-3",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":!1,role:"img","aria-label":B}):n.jsx(Z,{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:l})]}):null),e[35]=l,e[36]=R,e[37]=B,e[38]=ee):ee=e[38];const ne=v??b;let re;e[39]!==y?(re=y?n.jsx(rf,{providerId:y,className:"h-3 w-3 flex-shrink-0 opacity-45"}):null,e[39]=y,e[40]=re):re=e[40];let te;e[41]!==x||e[42]!==E||e[43]!==ne||e[44]!==re?(te=n.jsxs("span",{className:"ms-auto flex flex-shrink-0 items-center gap-1",children:[E,ne,x,re]}),e[41]=x,e[42]=E,e[43]=ne,e[44]=re,e[45]=te):te=e[45];let K;e[46]!==F||e[47]!==ee||e[48]!==te?(K=n.jsxs("div",{className:"flex h-4 w-full min-w-0 items-center gap-1",children:[F,ee,te]}),e[46]=F,e[47]=ee,e[48]=te,e[49]=K):K=e[49];let q;return e[50]!==_||e[51]!==K?(q=n.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[_,K]}),e[50]=_,e[51]=K,e[52]=q):q=e[52],q},Wh=750,jo=t=>{const e=He.c(9),{items:s,directory:r}=t,o=Wa();let i;if(e[0]!==r||e[1]!==s||e[2]!==o){let l;e[4]!==r||e[5]!==o?(l=d=>n.jsxs("button",{type:"button",className:ve("group/ref flex min-w-0 flex-col rounded text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default",!d.color&&"text-muted-foreground"),style:d.color?{color:d.color}:void 0,disabled:!d.url,onPointerDown:AC,onMouseDown:OC,onKeyDown:BC,onClick:u=>{u.stopPropagation(),d.url&&o(d.url,r,u)},children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 group-hover/ref:underline group-disabled/ref:no-underline",children:[n.jsx(Z,{name:d.icon,className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:d.text})]}),d.title?n.jsx("span",{className:"min-w-0 truncate ps-[18px] text-muted-foreground",children:d.title}):null]},d.key),e[4]=r,e[5]=o,e[6]=l):l=e[6],i=s.map(l),e[0]=r,e[1]=s,e[2]=o,e[3]=i}else i=e[3];let a;return e[7]!==i?(a=n.jsx("div",{className:"flex min-w-0 flex-col gap-1",children:i}),e[7]=i,e[8]=a):a=e[8],a};function AC(t){return t.stopPropagation()}function OC(t){return t.stopPropagation()}function BC(t){return t.stopPropagation()}const FC=150,ki={capture:!0,passive:!0};let oo=null;const ud=new WeakSet,LC=t=>{oo={target:t.target,at:performance.now()}},fd=(t,e)=>t instanceof Node&&t.contains(e);function _C(){const t=He.c(4),e=c.useRef(null),s=c.useRef(null);let r,o;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>(ud.has(document)||(ud.add(document),document.addEventListener("scroll",LC,ki)),()=>s.current?.()),o=[],t[0]=r,t[1]=o):(r=t[0],o=t[1]),c.useEffect(r,o);let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=(d,u)=>{s.current?.(),s.current=null;const f=u.trigger;if(!d||!f)return;if(oo&&performance.now()-oo.at<FC&&fd(oo.target,f)){u.cancel();return}const h=m=>{fd(m.target,f)&&e.current?.close()};document.addEventListener("scroll",h,ki),s.current=()=>document.removeEventListener("scroll",h,ki)},t[2]=i):i=t[2];const a=i;let l;return t[3]===Symbol.for("react.memo_cache_sentinel")?(l={actionsRef:e,onOpenChange:a},t[3]=l):l=t[3],l}let da=!1;const ua=new Set;let hd=!1;function $C(){for(const t of ua)t()}function Kh(t){da!==t&&(da=t,$C())}function Hr(t){Kh(t.shiftKey)}function zC(){Kh(!1)}function WC(){if(hd||typeof window>"u")return;hd=!0;const t={capture:!0,passive:!0};window.addEventListener("keydown",Hr,t),window.addEventListener("keyup",Hr,t),window.addEventListener("pointermove",Hr,t),window.addEventListener("pointerdown",Hr,t),window.addEventListener("blur",zC)}function KC(t){return WC(),ua.add(t),()=>{ua.delete(t)}}function HC(){return da}function VC(){return!1}function Hh(){return ds.useSyncExternalStore(KC,HC,VC)}const Vh=async(t,e,s)=>{const r=s.getRuntimeKey(),o=ot(t.path);if(!o)throw new Error("Unable to resolve worktree project");const i=await s.listProjectWorktrees(t,{force:!0});if(s.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const a=s.getCurrentProjects(),l=a.find(b=>b.id===t.id)??null;if(!l||ot(l.path??null)!==o)throw new Error("Project removed during worktree refresh");const d=al({rawWorktreesByProjectRef:s.rawWorktreesByProjectRef,publishedWorktreesByProject:s.getPublishedWorktreesByProject(),runtimeKey:r}),u=i.map(b=>Co(b));u.sort((b,v)=>Gh({metadata:b},{metadata:v}));const f=Oy(d.worktreesByProject,o,u,e?.projectDirectory);GC(s.rawWorktreesByProjectRef,r),s.rawWorktreesByProjectRef.current={runtimeKey:r,revision:s.rawWorktreesByProjectRef.current.revision,worktreesByProject:f};const h=s.getPublishedWorktreesByProject(),m=By(s.partitionWorktreesByRegisteredProject(a,f),h),g=[...m.values()].flat();return s.recordWorktreesSeen(g.map(b=>b.path),s.now()),s.worktreeMapsEqual(m,h)||s.publishTopology({availableWorktrees:g,availableWorktreesByProject:m}),u},GC=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),UC=t=>new Map([...t.entries()].map(([e,s])=>[e,s.map(r=>Co(r))])),al=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:UC(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),Gh=(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,o=s.localeCompare(r,void 0,{sensitivity:"base"});return o!==0?o:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},pd=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Co=t=>({...t,path:ot(t.path)??t.path,projectDirectory:ot(t.projectDirectory)??t.projectDirectory,worktreeRoot:ot(t.worktreeRoot??t.path)??t.worktreeRoot}),md=t=>{const{currentWorktree:e,path:s,projectDirectory:r,projectRootBranch:o}=t,a=ot(e?.path??null)===s,l=a?e?.branch??"":o??"",d={path:s,projectDirectory:r,branch:l,label:a?e?.label||e?.branch||e?.name||pd(s):o||pd(s),name:a?e?.name:void 0,worktreeRoot:a?ot(e?.worktreeRoot??s)??s:s,worktreeStatus:a?e?.worktreeStatus??"ready":"ready",worktreeSource:a?e?.worktreeSource??"existing":"existing",headState:a?e?.headState:o?"branch":void 0};return a&&e?{...e,...d}:d},gd=t=>{const e=ot(t.projectPath??null),s=ot(t.sourceDirectory??null)??ot(t.currentWorktree?.path??null),r=ot(t.discoveredWorktrees.find(f=>ot(f.projectDirectory??null))?.projectDirectory??null),o=ot(t.currentWorktree?.projectDirectory??null),i=r??o??e,a=new Map,l=f=>{const h=ot(f.metadata.path??null);!h||a.has(h)||e&&h!==s&&Fy(h,e)||a.set(h,{...f,metadata:Co({...f.metadata,path:h})})};for(const f of t.discoveredWorktrees){const h=ot(f.path??null);h&&l({metadata:Co({...f,path:h,projectDirectory:ot(f.projectDirectory??null)??i??e??h}),isPrimary:i===h,isCurrent:s===h})}i&&!a.has(i)&&l({metadata:md({path:i,projectDirectory:i,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:s===i}),s&&!a.has(s)&&l({metadata:md({path:s,projectDirectory:i??e??s,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:i===s,isCurrent:!0});const d=[],u=[];for(const f of a.values()){if(f.isPrimary){d.push(f);continue}u.push(f)}return d.sort((f,h)=>f.metadata.path.localeCompare(h.metadata.path,void 0,{sensitivity:"base"})),u.sort(Gh),[...d,...u]},Uh=(t,e)=>{const s=t.projectId?e.projects.find(i=>i.id===t.projectId)??null:null;if(s)return s;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const o=t.currentWorktree?.projectDirectory??null;return o?e.resolveProject(o):null},qC=(t,e)=>{const s=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),o=al({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:s}),i=Uh(t,e),a=ot(i?.path??null);return{cachedTargets:gd({projectPath:a,discoveredWorktrees:a?o.worktreesByProject.get(a)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!i||!a)throw new Error("Unable to resolve worktree project");const d=await Vh(i,t.currentWorktree,e);return gd({projectPath:a,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},YC=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},XC=t=>({refreshState:t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),QC=(t,e)=>ot(t.worktree?.path??null)===ot(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,ZC=[],JC=[],e3=[],bd=10,ji=new WeakMap,t3=t=>{const e=t.closest("[data-session-row]"),s=e?.closest(".overlay-scrollbar-container");if(!e||!s)return;ji.get(s)?.();const r=e.getBoundingClientRect().top;let o=3,i=!1,a=null;const l=()=>{i=!0,a!==null&&window.cancelAnimationFrame(a),a=null,ji.delete(s),s.removeEventListener("wheel",l),s.removeEventListener("touchstart",l)},d=()=>{if(i||!e.isConnected||!s.isConnected){l();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(s.scrollTop+=u,Ss("ui.sidebar.selection_scroll_anchor_adjustment")),o-=1,o<=0){l();return}a=window.requestAnimationFrame(d)};s.addEventListener("wheel",l,{passive:!0}),s.addEventListener("touchstart",l,{passive:!0}),ji.set(s,l),a=window.requestAnimationFrame(d)},s3=c.memo(function(e){const s=He.c(22),{archiveLabel:r,deleteLabel:o,buttonSizeClass:i,iconSizeClass:a,onPointerDown:l,onMouseDown:d,onArchive:u,onDelete:f}=e,h=Hh(),m=h?o:r;let g;s[0]!==u||s[1]!==f||s[2]!==h?(g=k=>{if(h||k.shiftKey){f(k);return}u(k)},s[0]=u,s[1]=f,s[2]=h,s[3]=g):g=s[3];const b=g,v=h?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let S;s[4]!==i||s[5]!==v?(S=ve("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",v,i),s[4]=i,s[5]=v,s[6]=S):S=s[6];const x=h?"delete-bin":"archive";let p;s[7]!==a||s[8]!==x?(p=n.jsx(Z,{name:x,className:a}),s[7]=a,s[8]=x,s[9]=p):p=s[9];let y;s[10]!==b||s[11]!==m||s[12]!==d||s[13]!==l||s[14]!==S||s[15]!==p?(y=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",className:S,"aria-label":m,onPointerDown:l,onMouseDown:d,onClick:b,onKeyDown:u3,children:p})}),s[10]=b,s[11]=m,s[12]=d,s[13]=l,s[14]=S,s[15]=p,s[16]=y):y=s[16];let w;s[17]!==m?(w=n.jsx(Tt,{side:"top",sideOffset:6,children:m}),s[17]=m,s[18]=w):w=s[18];let j;return s[19]!==y||s[20]!==w?(j=n.jsxs(Ot,{children:[y,w]}),s[19]=y,s[20]=w,s[21]=j):j=s[21],j});function n3(t){Ss("ui.sidebar_session_node.render");const{t:e}=wt(),{node:s,depth:r=0,groupDirectory:o,projectId:i,folderOwnerKey:a,selectionScopeKey:l,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:f,hasSessionSearchQuery:h,normalizedSessionSearchQuery:m,notifyOnSubtasks:g,editingId:b,editingRowKey:v,setEditingId:S,setEditingRowKey:x,editTitle:p,setEditTitle:y,handleSaveEdit:w,handleCancelEdit:j,toggleParent:k,handleSessionSelect:P,handleSessionDoubleClick:A,handleCopySessionId:B,openSidebarMenuKey:R,setOpenSidebarMenuKey:E,createFolderAndStartRename:T,handleDeleteSession:z,handleRestoreSession:O,startSessionWorktreeMenuLoad:W,mobileVariant:D,alwaysShowActions:Q,secondaryMeta:N,renderContext:C="project",blockingBadgeSessionScopes:I,rowKey:H,dragKey:M,children:_}=t,F=Fo(J=>J.toggle),ee=Xt(J=>J.getFoldersForScope),ne=Xt(J=>J.getSessionFolderId),re=Xt(J=>J.removeSessionFromFolder),te=Xt(J=>J.addSessionToFolder),K=de(J=>J.openContextPanelTab),q=c.useMemo(()=>Sn(),[]),oe=c.useMemo(()=>io(),[]),fe=c.useContext(Ly),ce=q?"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",ke=q?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",De=q,Ce=!d&&!D,Y=de(J=>J.sessionWorkEnabled),je=de(J=>J.sessionRecapEnabled),we=Y&&!d&&!s.session.parentID&&!xa(s.session.directory),Pe=we&&!Q,L=(Pe?1:0)+(Ce?1:0)+(De?1:0),ie=["group-hover:pe-8","group-hover:pe-14","group-hover:pe-18","group-hover:pe-22"][L],G=Ce?"pe-13":"pe-7",ae=c.useRef(!1),[ge,me]=c.useState(!1),be=c.useRef(b);be.current=b;const ye=c.useRef(null),Te=c.useRef(!1),$=c.useRef(w);$.current=w;const he=p,se=c.useRef(he);se.current=he;const Ne=c.useRef(null),Ue=c.useRef(!1),We=c.useRef(null),Ke=c.useRef(null),Be=_C(),U=s.session,Me=U,Ge=Zt(c.useCallback(J=>{if(N?.projectLabel||!i)return null;const Pt=J.projects.find(Gt=>Gt.id===i);return Pt?Pt.label?.trim()||Ao(ot(Pt.path)??Pt.path,null)||Pt.path:null},[i,N?.projectLabel])),Ve=Un(C)||C==="timeline-chat",dt=C==="timeline-chat",et=Zt(c.useCallback(J=>C!=="timeline-mixed"||!i?null:J.projects.find(Pt=>Pt.id===i)??null,[C,i])),ct=N?.projectLabel??(Ge?of(Ge):null),pe=_j(N,s.worktree?.branch??null),Ee=N?.inSpace===!0,qe=c.useMemo(()=>$j(s.worktree,q),[q,s.worktree]),Ye=af(qe?.directory??null,qe?.branch??null),$e=c.useMemo(()=>q?ZC:lf(U),[q,U]),tt=c.useMemo(()=>$e.map(J=>({item:xr("pull",J),url:J.url,title:J.title})),[$e]),ht=ec(tt),vt=c.useMemo(()=>ht.filter(J=>J!==null),[ht]),Bt=c.useMemo(()=>q?e3:_y(U),[q,U]),kt=c.useMemo(()=>Bt.flatMap(J=>J.gitlab?[{item:Sr("pull",J.gitlab),url:J.url,title:J.title}]:[]),[Bt]),St=ec(kt),xt=c.useMemo(()=>$y(Ye,[...vt,...St.filter(J=>J!==null)]),[Ye,St,vt]),Mt=c.useMemo(()=>{let J=0;return Bt.filter(Pt=>{if(!Pt.gitlab)return!0;const Gt=St[J]!==null;return J+=1,!Gt})},[St,Bt]),jt=c.useMemo(()=>zy($e,xt),[$e,xt]),$t=Ye?`var(--pr-${Ye.visualState})`:void 0,Wt=c.useMemo(()=>q?JC:Ka(U),[q,U]),Kt=c.useMemo(()=>Wt.flatMap(J=>J.source==="github"?[xr("issue",J)]:[]),[Wt]),rt=mo(Kt),ut=c.useMemo(()=>Wt.flatMap(J=>J.source==="gitlab"?[Sr("issue",J.ref)]:[]),[Wt]),pt=mo(ut),ue=c.useMemo(()=>Wt.flatMap(J=>J.source==="linear"?[Ha(J.identifier)]:[]),[Wt]),lt=cf(ue),ft=c.useMemo(()=>{if(xt.length>0||jt.length>0||Mt.length>0){const J=xt.map(Lt=>{const as=df(Lt,e),Ut=Ta(Lt.provider,Lt.number);return{key:`${Lt.provider??""}:${Lt.repo?.owner??""}/${Lt.repo?.repo??""}#${Lt.number}`,icon:"git-pull-request",label:Ut,color:`var(--pr-${Lt.visualState})`,url:Lt.url,title:Lt.title,text:as?`${Ut} · ${as}`:Ut}}),Pt=jt.map(Lt=>({key:`${Lt.owner}/${Lt.repo}#${Lt.number}`,icon:"git-pull-request",label:`#${Lt.number}`,url:Lt.url,title:Lt.title,text:`#${Lt.number}`})),Gt=Mt.map(Lt=>({key:Lt.key,icon:"git-pull-request",label:Lt.identifier,url:Lt.url,title:Lt.title,text:Lt.identifier}));return[...J,...Pt,...Gt]}return uf(Wt,rt,lt,pt).map(J=>({key:J.key,icon:J.icon,label:J.label,color:J.color??void 0,url:J.url,title:J.title,text:J.statusKey?`${J.label} · ${e(J.statusKey)}`:J.statusText?`${J.label} · ${J.statusText}`:J.label}))},[pt,rt,Wt,lt,jt,xt,e,Mt]),mt=ft[0]??null,It=Math.max(0,ft.length-1),xe=Wa(),it=ft.map(J=>J.text).join(", "),X=nt(J=>J.currentSessionId===U.id),le=ot(U.directory??null)??ot(o??null),Xe=l!==void 0?l:i??le??null,Ae=wu(),Je=ff(),Fe=q,gt=dC(),bt=cs(J=>J.enabled),Et=cs(c.useCallback(J=>J.selectedIds.has(U.id),[U.id])),Ft=cs(J=>J.toggleSelected),es=cs(J=>J.setRange),Re=$h(),Ze=H??U.id,at=b===U.id&&v===Ze,_t=c.useCallback(J=>{const Pt=[],Gt=Lt=>{Lt.children.forEach(as=>{Pt.push(as.session.id),Gt(as)})};return Gt(J),Pt},[]),Vt=c.useCallback(J=>{const Pt=[],Gt=Lt=>{Lt.children.forEach(as=>{Pt.push(as.session),Gt(as)})};return Gt(J),Pt},[]),[Ht,Oe]=c.useState(!1),[ze,st]=c.useState(!0),Nt=`${C}:${d?"archived":"active"}:${U.id}`,Dt=H?`session-menu:${H}`:Nt,ts=H?`session-context:${H}`:null,fs=Wy(c.useCallback(J=>!!J.sessionMemoryState.get(Ky(U.id))?.isZombie,[U.id])),us=fu(U.id),Se=us!==null,V=Hy(U.id,Se),Ie=Tf(U.id),Le=va(U.id,le),Qe=Ie||Le,yt=s.worktree??nt.getState().getWorktreeMetadata(U.id)??null,[Rt,zt]=c.useState([]),[Jt,Rs]=c.useState(!1),ys=c.useRef(!1),Ds=c.useRef(0),Ks=Vy(Me),is=we&&Va(Me),Xo=is&&!Se&&Gy(Me),Rr=e(is?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),ll=async()=>{try{await rx(U.id,le,is?"done":"open")}catch{_e.error(e("sessions.sidebar.session.work.updateFailed"))}},cl=Ks?e(Uy[Ks.status]):"",dl=Ks?n.jsx(Rn,{label:cl,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":cl,children:n.jsx(Z,{name:"target",className:"h-3 w-3",style:{color:qy[Ks.status]}})})}):null,ln=Me.title||e("sessions.sidebar.session.untitled"),ul=!Ve&&s.children.length>0,Dr=za(u,le,U.id),Qo=Nt,An=h?!0:f.has(Qo),cp=c.useMemo(()=>I??aa(s,An,le),[An,s,le,I]),{hasPermission:fl,hasForm:hl}=Yy(cp),pl=!!Me.parentID,ml=hu(U.id)>0&&(!pl||g),gl=Xy(Me)||Date.now(),dp=Qy(gl),Zo=hf(gl),{isMenuOpen:bl,isContextMenuOpen:yl,handleMenuOpenChange:up,handleContextMenuOpenChange:fp,handleMenuOpenChangeComplete:xl,toggleMenu:hp}=DC({menuInstanceKey:Dt,contextMenuInstanceKey:ts,openSidebarMenuKey:R,setOpenSidebarMenuKey:E,hasDeferredCloseWork:()=>ye.current!==null,onCloseComplete:()=>{if(!ye.current)return;const{id:J,title:Pt}=ye.current;ye.current=null,S(J),x(Ze),y(Pt)}}),rr=bl||yl,Sl=c.useMemo(()=>Zy(Me)?.key??null,[Me]),Jo=c.useMemo(()=>_t(s).length,[_t,s]),ei=c.useCallback(async J=>{const Pt=[];let Gt=0;for(const Lt of J)try{if(!le)throw new Error("Session directory is required for export");const as=await Ae({directory:le,sessionID:Lt.session.id});if(!as)throw new Error("Session runtime changed during export");const Ut=Lt.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Bs=Lt.session.agent,xs=await ei(Lt.children);Gt+=xs.skipped,Pt.push({title:Ut,agent:Bs,records:as,children:xs.children})}catch{Gt+=_t(Lt).length+1}return{children:Pt,skipped:Gt}},[_t,Ae,le,e]),ti=c.useCallback(J=>{J<=0||_e.warning(J===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:J}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:J}))},[e]),si=c.useCallback(async J=>{if(!le){_e.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Pt=await Ae({directory:le,sessionID:U.id}).catch(()=>null);if(!Pt){_e.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Pt.length===0){_e.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Gt,Lt=0;if(J&&s.children.length>0){const xs=await ei(s.children);Gt=xs.children,Lt=xs.skipped}const as=ku(Pt,Me.title??null,Gt),Ut=ju(Me.title??null),Bs=await Cu(as,Ut);if(Bs){_e.success(e("sessions.sidebar.session.export.success"),{action:{label:e(ex()),onClick:()=>{Jy(Bs).then(xs=>{xs||_e.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),ti(Lt);return}Pu(as,Ut),_e.success(e("sessions.sidebar.session.export.success")),ti(Lt)},[ei,Ae,s.children,Me.title,U.id,le,ti,e]),vl=Eu(),pp=c.useMemo(()=>Nu(vl),[vl]),mp=c.useCallback(J=>{Rf({entry:J,t:e,session:{id:U.id,title:Me.title,directory:le},loadRecords:()=>le?Ae({directory:le,sessionID:U.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>_e.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[Ae,Me.title,U.id,le,e]),gp=c.useCallback(async()=>{if(s.children.length>0){st(!0),Oe(!0);return}await si(!1)},[si,s.children.length]),bp=c.useCallback(()=>{le&&hn("desktop_open_session_mini_chat_window",{sessionId:U.id,directory:le,apiBaseUrl:fr(),clientToken:Ur()}).catch(J=>{console.warn("[session-sidebar] failed to open mini chat window",J)})},[U.id,le]),wl=()=>{if(!le)return;const J=ox()??le;K(J,{mode:"chat",dedupeKey:`session:${U.id}`,label:ln,sessionTitleFallback:ln,targetDirectory:le})};if(c.useEffect(()=>{if(!at)return;const J=Pt=>{const Lt=(Pt.target instanceof HTMLElement?Pt.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Ze)}"]`);Ke.current&&!Lt&&$.current(se.current)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[at,Ze]),c.useLayoutEffect(()=>{if(!at){Ne.current===Ze&&(Ne.current=null);return}Ne.current!==Ze&&(Ne.current=Ze,Ue.current=!0)},[p,at,Ze]),c.useLayoutEffect(()=>{if(!at||!Ue.current)return;const J=We.current;!J||J.value!==p||(Ue.current=!1,J.focus(),J.select())},[p,at,he]),at){const J=n.jsxs("form",{ref:Ke,"data-session-rename-form":Ze,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:Pt=>{Pt.preventDefault(),w(he)},children:[n.jsx("input",{ref:We,value:he,onChange:Pt=>y(Pt.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:Pt=>Di(Pt,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(Z,{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(Z,{name:"close",className:"size-3.5"})})]});return Ve?n.jsx("div",{style:{paddingInlineStart:bd},className:ve("oc-ref-tint-scope group relative my-0.5 flex items-center rounded-md pe-2.5",dt?"py-1":"py-1.5",X&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:n.jsx(ca,{compact:dt,project:et,projectLabel:ct,title:J,titleClassName:"text-foreground",branchLabel:pe,spaceMark:Ee?e("sessions.sidebar.group.space"):null,statusDot:null,pinnedMarker:null,timeSlot:Zo,directoryIndicator:null,prBadge:mt?n.jsxs("span",{className:ve("inline-flex flex-shrink-0 items-center gap-1 typography-micro",mt.color?"oc-ref-tint":"text-muted-foreground"),style:mt.color?Kn(mt.color):void 0,children:[n.jsx(Z,{name:mt.icon,className:"h-3 w-3"}),n.jsx("span",{className:"leading-none tabular-nums",children:mt.label}),It>0?n.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",It]}):null]}):null,zombieIndicator:null,goal:dl,badges:null,hideMetaOnHoverClass:""})},U.id):n.jsxs("div",{style:{paddingInlineStart:tr(r)},className:"group relative my-0.5 flex items-center gap-1.5 rounded-md py-[3px] pe-2.5",children:[n.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:J})]},U.id)}const kl=e("sessions.sidebar.session.status.questionPending"),jl=!Qe&&!Se&&ml&&!X,yp=Se||jl,xp=n.jsx(gu,{state:us??"unread",tooltip:!0}),Sp=(Se||jl)&&V,vp=Ve&&!dt?["[--oc-actions-reserve:14px]","[--oc-actions-reserve:36px]","[--oc-actions-reserve:58px]","[--oc-actions-reserve:80px]"][L]:["[--oc-actions-reserve:10px]","[--oc-actions-reserve:28px]","[--oc-actions-reserve:46px]","[--oc-actions-reserve:64px]"][L],wp=Q?void 0:rr?"oc-actions-mask":q?"group-hover:oc-actions-mask":"group-hover:oc-actions-mask group-has-[:focus-visible]:oc-actions-mask",kp=rr?"opacity-0":ke,Cl=e("sessions.sidebar.session.status.pinned"),jp=n.jsx(Rn,{label:Cl,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":Cl,children:n.jsx(Z,{name:"pushpin",className:"h-3 w-3 text-primary"})})}),Cp=n.jsx(Z,{name:"loader-4",className:"h-3 w-3 flex-shrink-0 animate-spin text-primary","aria-label":e(Le?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}),Pp=Ve?null:ul?n.jsx("span",{role:"button",tabIndex:0,onClick:J=>{J.stopPropagation(),J.currentTarget.blur(),k(Qo)},onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),J.stopPropagation(),k(Qo))},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 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-label":e(An?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":An,children:n.jsx(jr,{expanded:An})}):n.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0"}),ni=fs?n.jsx(Z,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Ep=J=>{J.preventDefault(),J.stopPropagation(),hp()},Np=J=>{J.preventDefault(),J.stopPropagation()},Ip=J=>{J.preventDefault(),J.stopPropagation()},ri=J=>{J.preventDefault(),J.stopPropagation()},oi=J=>{J.preventDefault(),J.stopPropagation()},Rp=J=>{J.preventDefault(),J.stopPropagation(),E(null),z(U,{archivedBucket:d})},Dp=J=>{J.preventDefault(),J.stopPropagation(),E(null),z(U,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},Tp=J=>{J.preventDefault(),J.stopPropagation()},Mp=J=>{J.preventDefault(),J.stopPropagation()},Ap=J=>{J.preventDefault(),J.stopPropagation(),fe?.vscode?.executeCommand("openchamber.openSessionInEditor",U.id,ln)},Pl=J=>{if(ae.current){ae.current=!1;return}if(bt){if(J?.preventDefault(),J?.stopPropagation(),J?.shiftKey){const Pt=Re?.getEntries(),Gt=Pt??Array.from(document.querySelectorAll("[data-session-row]")).map(Ut=>Ut.getAttribute("data-session-row")).filter(Ut=>!!Ut).map(Ut=>({id:Ut,rowKey:Ut,scopeKey:Xe,archived:d})),Lt=Pt?cs.getState().anchorRowKey:cs.getState().anchorId,as=new Map;as.set(U.id,_t(s)),es(Lt,Ze,Gt,Re?.getDescendantIds()??[],Xe,as);return}Ft(U.id,Xe,_t(s),Ze);return}if(J?.shiftKey&&!q&&le){wl();return}J?.currentTarget&&t3(J.currentTarget),P(U.id,le)},Op=J=>{J.defaultPrevented||(J.target instanceof HTMLElement?J.target:null)?.closest('button, a, input, [data-session-row-main], [role="menuitem"], [role="menu"]')||Pl(J)},Bp=J=>{(J.button===2||J.button===0&&J.ctrlKey&&!bt)&&(ae.current=!0),J.button===0&&J.shiftKey&&!bt&&J.preventDefault()},Fp=J=>{D&&J.pointerType==="touch"&&me(!0),J.button===0&&!X&&!bt&&!Fe&&le&&!_i(U.id,le).renderable&&Je({directory:le,sessionID:U.id}).catch(()=>{})},On=!X&&!bt&&le?{id:U.id,directory:le}:null,Lp=J=>{J.pointerType!=="mouse"||!On||gt?.schedule(On)},_p=()=>{On&>?.schedule(On)},El=()=>{On&>?.cancel(On)},Nl=J=>{D&&J.pointerType==="touch"&&me(!1)},$p=J=>{ys.current=J,Ds.current+=1;const Pt=Ds.current;if(!J){Rs(!1);return}const Gt=W({projectId:i??null,sourceDirectory:le,currentWorktree:yt});zt(Gt.cachedTargets),Rs(!1),Gt.refreshTargets.then(Lt=>{!ys.current||Ds.current!==Pt||(zt(Lt),Rs(!1))}).catch(()=>{!ys.current||Ds.current!==Pt||Rs(!0)})},Il=({Item:J,Separator:Pt,Sub:Gt,SubTrigger:Lt,SubContent:as})=>n.jsxs(n.Fragment,{children:[n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(J,{onClick:()=>{ye.current={id:U.id,title:ln}},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]})}),n.jsx(Ui,{sessionID:U.id,directory:le,open:rr,Item:J}),n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(J,{onClick:()=>B(U.id),className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"file-copy",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]})}),n.jsx(Qt,{hint:e(Dr?"sessions.sidebar.session.menuHint.unpin":"sessions.sidebar.session.menuHint.pin"),children:n.jsxs(J,{onClick:()=>le&&F({directory:le,sessionId:U.id}),className:"[&>svg]:me-1",children:[Dr?n.jsx(Z,{name:"unpin",className:"me-1 h-4 w-4"}):n.jsx(Z,{name:"pushpin",className:"me-1 h-4 w-4"}),e(Dr?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]})}),we?n.jsx(Qt,{hint:e(is?"sessions.sidebar.session.menuHint.markDone":"sessions.sidebar.session.menuHint.track"),children:n.jsxs(J,{onClick:()=>{ll()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:is?"check":"eye",className:"me-1 h-4 w-4"}),e(is?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]})}):null,n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(J,{onClick:()=>{gp()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"download",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]})}),pp.map(Ut=>n.jsxs(J,{onClick:()=>mp(Ut),className:"[&>svg]:me-1",children:[n.jsx(sr,{icon:Ut.icon,iconSrc:Ut.iconSrc,className:"me-1 size-4"}),Ut.action.label]},`${Ut.guest.id}:${Ut.action.id}`)),Bj({isSubtaskSession:pl,archivedBucket:!!d,isVSCode:q,sessionDirectory:le})?(()=>{const Ut=Fj({sessionDirectory:le,isStreaming:Se,isMovingToWorktree:Ie}),Bs=XC({targets:Rt,loadFailed:Jt}),xs=n.jsxs(Lt,{disabled:Ut,className:"w-full [&>svg]:me-1","data-session-worktree-submenu-trigger":U.id,children:[n.jsx(Z,{name:"folder-shared",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]}),Ts=Ie?e("sessions.sidebar.session.moveToWorktree.tooltipMoving"):Se?e("sessions.sidebar.session.moveToWorktree.tooltipBusy"):null;return n.jsxs(Gt,{onOpenChange:$p,children:[Ts?n.jsx(Qt,{hint:Ts,children:xs}):xs,n.jsxs(as,{className:"min-w-[220px]","data-session-worktree-submenu":U.id,children:[Rt.map(ms=>{const hs=ot(ms.metadata.path??null)??ms.metadata.path,ps=ms.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):ms.metadata.label||ms.metadata.branch||ms.metadata.name||ms.metadata.path,Xs=ms.isCurrent||ms.metadata.worktreeStatus!=="ready";return n.jsxs(J,{disabled:Xs,title:ms.metadata.path,"data-session-worktree-target":hs,onClick:()=>{Xs||!le||bo({kind:"existing",root:Me,descendants:Vt(s),sourceDirectory:le,destination:ms.metadata,messages:go(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:ps}),ms.isCurrent?n.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),ms.isCurrent?n.jsx(Z,{name:"check",className:"ms-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},hs)}),Bs.refreshState==="error"?n.jsx(J,{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(Pt,{}),n.jsxs(J,{disabled:Ut,"data-session-worktree-new-action":"true",onClick:()=>{Ut||!le||bo({kind:"quick",root:Me,descendants:Vt(s),sourceDirectory:le,messages:go(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,Sl?n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.openRunOverview"),children:n.jsxs(J,{onClick:()=>de.getState().setRunOverviewKey(Sl),className:"[&>svg]:me-1",children:[n.jsx($i,{className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]})}):null,le&&!d&&!Ve?(()=>{const Ut=[],Bs=hs=>{const ps=ot(hs??null);ps&&!Ut.includes(ps)&&Ut.push(ps)};if(i&&!q){const hs=Zt.getState().projects.find(Xs=>Xs.id===i),ps=ot(hs?.path??null);Bs(ps),ps&&(nt.getState().availableWorktreesByProject.get(ps)??[]).forEach(Xs=>Bs(Xs.path))}Bs(Sa(le)),Bs(le);const xs=Ut.flatMap(hs=>ee(hs).map(ps=>({scope:hs,folder:ps}))),Ts=xs.find(({scope:hs,folder:ps})=>ne(hs,U.id)===ps.id)??null,ms=Ut[0]??le;return n.jsxs(n.Fragment,{children:[n.jsx(Pt,{}),n.jsxs(Gt,{children:[n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.moveToFolder"),children:n.jsxs(Lt,{className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]})}),n.jsxs(as,{className:"min-w-[180px]",children:[xs.length===0?n.jsx(J,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):xs.map(({scope:hs,folder:ps})=>{const Xs=Ts?.folder.id===ps.id;return n.jsxs(J,{onClick:()=>{if(Xs){re(hs,U.id);return}Ts&&Ts.scope!==hs&&re(Ts.scope,U.id),te(hs,ps.id,U.id)},children:[n.jsx("span",{className:"flex-1 truncate",children:ps.name}),Xs?n.jsx(Z,{name:"check",className:"ms-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ps.id)}),n.jsx(Pt,{}),n.jsxs(J,{onClick:()=>{const hs=T(ms);hs&&(Te.current=!0,Ts&&Ts.scope!==ms&&re(Ts.scope,U.id),te(ms,hs.id,U.id))},children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Ts?n.jsxs(J,{onClick:()=>{re(Ts.scope,U.id)},className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,q?null:n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.openInSidePanel"),children:n.jsxs(J,{disabled:!le,onClick:wl,className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"chat-4",className:"me-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")})]})}),oe?n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.openMiniChatWindow"),children:n.jsxs(J,{disabled:!le,onClick:bp,className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"window",className:"me-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]})}):null,n.jsx(Pt,{}),d?null:n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.archive"),children:n.jsxs(J,{className:"[&>svg]:me-1",onClick:()=>z(U,{archivedBucket:d}),children:[n.jsx(Z,{name:"inbox-archive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]})}),d?n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.restore"),children:n.jsxs(J,{className:"[&>svg]:me-1",onClick:()=>O(U),children:[n.jsx(Z,{name:"inbox-unarchive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]})}):null,n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(J,{className:"text-destructive focus:text-destructive [&>svg]:me-1",onClick:()=>z(U,{archivedBucket:d,hardDelete:!0}),children:[n.jsx(Z,{name:"delete-bin",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})})]}),zp=J=>{J.preventDefault(),J.stopPropagation(),ll()},ii=Q?"h-6 w-6":Ve&&!dt?"h-5 w-5":"h-4 w-4",Tr=Q?"h-3.5 w-3.5":Ve&&!dt?"h-3 w-3":"h-2.5 w-2.5",Wp=Q?"h-4 w-4":Ve&&!dt?"h-3.5 w-3.5":"h-3 w-3",Rl=je&&!Se&&tx(Me)?.recap||null,Dl=e("sessions.sidebar.session.work.doneSuggested"),Kp=J=>Xo?n.jsx(Rn,{label:Dl,children:n.jsx("span",{className:ve("inline-flex flex-shrink-0 items-center text-muted-foreground/75",J),"aria-label":Dl,children:n.jsx(Z,{name:"check",className:"h-3.5 w-3.5"})})}):null,Tl=e("sessions.sidebar.session.status.permissionRequired"),Hp=fl||hl?n.jsxs(n.Fragment,{children:[fl?n.jsx(Rn,{label:Tl,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded bg-destructive/10 px-1 py-0.5 text-destructive","aria-label":Tl,children:n.jsx(Z,{name:"shield",className:"h-3 w-3"})})}):null,hl?n.jsx(Rn,{label:kl,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded bg-status-info/10 px-1 py-0.5 text-status-info","aria-label":kl,children:n.jsx(Z,{name:"question",className:"h-3 w-3"})})}):null]}):null,Vp=Ve&&mt?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,closeDelay:Wh,children:n.jsxs("button",{type:"button",className:ve("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",mt.color?"oc-ref-tint":"text-muted-foreground"),style:mt.color?Kn(mt.color):void 0,disabled:!mt.url,"aria-label":it,onPointerDown:ri,onMouseDown:oi,onClick:J=>{J.preventDefault(),J.stopPropagation(),!(J.target instanceof Element&&J.target.closest("[data-ref-more]"))&&mt.url&&xe(mt.url,le,J)},onKeyDown:J=>J.stopPropagation(),children:[n.jsx(Z,{name:mt.icon,className:"h-3 w-3"}),n.jsx("span",{className:"leading-none tabular-nums",children:mt.label}),It>0?n.jsxs("span",{"data-ref-more":!0,className:"leading-none tabular-nums text-muted-foreground",children:["+",It]}):null]})}),n.jsx(Tt,{side:"top",sideOffset:6,className:"max-w-xs",children:n.jsx(jo,{items:ft,directory:le})})]}):null,Gp=n.jsx(ca,{compact:!Un(C),project:et,projectLabel:ct,title:Yr(ln,m),titleClassName:X||Et?"text-interactive-selection-foreground":ml?"text-foreground":"text-foreground/80",branchLabel:pe,spaceMark:Ee?e("sessions.sidebar.group.space"):null,statusDot:Qe?Cp:yp?xp:null,pinnedMarker:Dr&&!Qe?jp:null,timeSlot:Sp?n.jsx(sx,{sessionId:U.id,running:Se,className:"typography-micro"}):Zo,directoryIndicator:!d&&le&&C!=="project"?n.jsx(ko,{directory:le}):null,prBadge:Vp,zombieIndicator:Ve?ni:null,goal:dl,badges:Hp,doneHint:Kp(),providerId:Ve?Me.model?.providerID??null:null,metaPaddingClass:Ve&&Q?Ce?"pe-13":"pe-7":void 0,hideMetaOnHoverClass:Q&&!q?"":kp,actionsReserveClass:vp,actionsMaskClass:wp}),Up=n.jsx(Ps,{align:"end",className:"min-w-[180px]",finalFocus:()=>Te.current?(Te.current=!1,!1):!be.current,children:Il({Item:qt,Separator:bn,Sub:Ju,SubTrigger:ef,SubContent:tf})}),qp=n.jsx(Ki,{children:n.jsx(Hi,{className:"app-region-no-drag z-50",children:n.jsx(Vi,{"data-slot":"dropdown-menu-content",finalFocus:()=>Te.current?(Te.current=!1,!1):!be.current,style:{color:"var(--surface-elevated-foreground)"},className:ve(Ti,"min-w-[180px]"),children:Il({Item:({className:J,...Pt})=>n.jsx(Ef,{className:ve(mu,J),...Pt}),Separator:({className:J,...Pt})=>n.jsx(Pf,{className:ve(pu,J),...Pt}),Sub:w1,SubTrigger:({className:J,children:Pt,...Gt})=>n.jsxs(k1,{className:ve(nx,J),...Gt,children:[Pt,n.jsx(Z,{name:"arrow-right-s",className:"ms-auto size-3.5"})]}),SubContent:({className:J,children:Pt,...Gt})=>n.jsx(Ki,{children:n.jsx(Hi,{className:"app-region-no-drag z-50",children:n.jsx(Vi,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:ve(Ti,J),...Gt,children:Pt})})})})})})});return n.jsxs(c.Fragment,{children:[n.jsx(EC,{sessionId:U.id,dragKey:M??Ze,ownerKey:a??Xe,sessionDirectory:le??null,sessionTitle:ln,archivedBucket:d,children:n.jsxs(If,{open:yl,onOpenChange:fp,onOpenChangeComplete:xl,children:[n.jsxs(Nf,{render:n.jsx("div",{"data-session-row":U.id,"data-session-scope":Xe??"","data-session-archived":d?"1":"0","aria-current":X?"page":void 0,onClick:Op,style:{paddingInlineStart:Ve?bd:tr(r)},className:ve("oc-ref-tint-scope group relative my-0.5 flex cursor-pointer items-center rounded-md pe-2.5",!Ve&&"gap-1.5",Ve?dt?"py-1":"py-1.5":"py-[3px]",!(X||Et)&&"hover:bg-interactive-hover/60",(X||Et)&&"bg-interactive-selection/70 text-interactive-selection-foreground",Et&&"ring-1 ring-inset ring-border")}),children:[Pp,n.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:n.jsxs(Ot,{actionsRef:Be.actionsRef,onOpenChange:Be.onOpenChange,children:[n.jsx(At,{asChild:!0,closeDelay:0,disabled:q,children:n.jsx("div",{role:"button",tabIndex:0,"data-session-row-main":"",onKeyDown:J=>{J.target!==J.currentTarget||J.key!=="Enter"&&J.key!==" "||(J.preventDefault(),J.currentTarget.click())},"aria-pressed":bt?Et:void 0,onPointerDown:Fp,onPointerUp:Nl,onPointerCancel:Nl,onPointerEnter:Lp,onPointerLeave:El,onFocus:_p,onBlur:El,onMouseDown:Bp,onClick:J=>Pl(J),onDoubleClick:J=>{J.stopPropagation(),A(U.id,ln)},className:ve("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none",ge&&"bg-interactive-hover/70",Ve||!Q?void 0:q?ie:G),children:Gp})}),q?null:n.jsx(Tt,{side:"right",sideOffset:8,className:"max-w-xs text-start",children:n.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-start text-xs",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{dir:"auto",className:"oc-ui-start-align min-w-0 truncate font-medium text-foreground",children:ln}),n.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:dp,children:Zo})]}),ct?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[n.jsx(Z,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:ct})]}):null,pe?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[Ee?n.jsx(Z,{name:"box-3",className:"h-3 w-3 flex-shrink-0","aria-hidden":!1,role:"img","aria-label":e("sessions.sidebar.group.space")}):n.jsx(Z,{name:"git-branch",className:ve("h-3 w-3 flex-shrink-0",$t&&"oc-ref-tint"),style:$t?Kn($t):void 0}),n.jsx("span",{className:"min-w-0 truncate",children:pe})]}):null,ft.length>0?n.jsx(jo,{items:ft,directory:le}):null,Rl?n.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:Rl}):null]})})]})}),ni&&!D&&!Ve?n.jsx("div",{className:"absolute inset-e-1 top-1/2 -translate-y-1/2 z-10",children:ni}):null,n.jsx("div",{className:ve("absolute inset-e-1 z-10 flex items-center gap-0.5 transition-opacity",Ve&&!dt?"top-1.5 h-5":"top-1/2 -translate-y-1/2",rr||Q&&!q?"opacity-100":ve("opacity-0",ce)),children:n.jsxs(Lo,{delayDuration:400,children:[Pe?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",className:ve("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",ii,is?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":Rr,onPointerDown:ri,onMouseDown:oi,onClick:zp,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:is?"check":"eye",className:is?Wp:Tr})})}),n.jsx(Tt,{side:"top",sideOffset:6,children:Rr})]}):null,Ce?n.jsx(s3,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:ii,iconSizeClass:Tr,onPointerDown:ri,onMouseDown:oi,onArchive:Rp,onDelete:Dp}):null,De?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",className:ve("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:Tp,onMouseDown:Mp,onClick:Ap,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:"external-link",className:Tr})})}),n.jsx(Tt,{side:"top",sideOffset:6,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,n.jsxs(js,{open:bl,onOpenChange:up,onOpenChangeComplete:xl,children:[n.jsx(Cs,{asChild:!0,children:n.jsx("button",{type:"button",className:ve("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",Q?"h-6 w-6 opacity-100":rr?"h-4 w-4 opacity-100":ve("h-4 w-4 opacity-0",ce)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Np,onMouseDown:Ip,onClick:Ep,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:"more-2",className:Tr})})}),Up]})]})})]}),qp]})}),ul&&An?_:null,n.jsx(zs,{open:Ht,onOpenChange:Oe,children:n.jsxs($s,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(qs,{children:[n.jsx(Gs,{children:e("sessions.sidebar.session.export.dialog.title")}),n.jsx(Us,{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:ze,onChange:J=>st(J.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),n.jsxs(yn,{children:[n.jsx(Ct,{type:"button",onClick:()=>Oe(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),n.jsx(Ct,{type:"button",onClick:()=>{Oe(!1),si(ze)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},U.id)}const yd=t=>ot(t.session.directory??null),r3=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null)&&(t?.inSpace??!1)===(e?.inSpace??!1),o3=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},xd=t=>t.menuOpenSessionId??o3(t),Vr=(t,e,s)=>e?s.has(t.node.session.id)?!0:Jn(t.node,e):!1,fa=(t,e,s,r,o)=>{if(t.session.id!==e.session.id)return!0;const i=o(t);if(s.has(i)!==r.has(i)||t.children.length!==e.children.length)return!0;for(let a=0;a<t.children.length;a+=1)if(fa(t.children[a],e.children[a],s,r,o))return!0;return!1},i3=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const s=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return fa(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${t.renderContext??"project"}:${s}:${o.session.id}`)||fa(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${e.renderContext??"project"}:${r}:${o.session.id}`)},a3=(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&&pf(t,e),l3=(t,e)=>{if(t.node.session.id!==e.node.session.id||!a3(t.node.session,e.node.session)||!QC(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(yd(t.node)!==yd(e.node))return"nodeDirectory";if(!r3(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&Nh(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&i3(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(Vr(t,t.editingId,t.subtreeContainsEditing)||Vr(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&&(Vr(t,t.editingId,t.subtreeContainsEditing)||Vr(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=xd(t),o=xd(e);if(Jn(t.node,r)||Jn(e.node,o))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.handleCopySessionId===e.handleCopySessionId&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.children===e.children?null:"callbacks"},c3=(t,e)=>{const s=l3(t,e);return s===null?!0:(Ss(`ui.sidebar_session_node.props_changed.${s}`),!1)},d3=c.memo(n3,c3);function u3(t){return t.stopPropagation()}const f3=t=>{const{t:e}=wt(),s=c.useRef(t.editingId),r=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);s.current=t.editingId,r.current=t.editTitle,o.current=t.deleteSessionConfirm;const i=de(N=>N.setSessionSwitcherOpen),a=nt(N=>N.setCurrentSession),l=nt(N=>N.updateSessionTitle),d=nt(N=>N.deleteSession),u=nt(N=>N.deleteSessions),f=nt(N=>N.archiveSession),h=nt(N=>N.archiveSessions),m=nt(N=>N.unarchiveSession),{mobileVariant:g,allowReselect:b,onSessionSelected:v,resetSessionSearch:S,descendantIds:x,showDeletionDialog:p,setDeleteSessionConfirm:y,setEditingId:w,setEditingRowKey:j,editingSessionId:k,editingOccurrenceKey:P,setEditTitle:A}=t,B=c.useCallback((N,C)=>{if(Ri("navigation.session_select"),de.getState().closeMainSurfaces(),g&&i(!1),N===nt.getState().currentSessionId){b&&v?.(N),S();return}Ri("navigation.session_state_set"),a(N,C??null),v?.(N),S()},[b,g,v,S,a,i]),R=c.useCallback((N,C)=>{w(N),j(P),A(C)},[P,A,w,j]),E=c.useCallback(async N=>{if(!s.current)return;const I=(N??r.current).trim();if(I)try{await l(k,I)}catch(H){console.error("[session-actions] rename failed",H),_e.error(e("sessions.sidebar.session.rename.error",{detail:cu(H instanceof Error?H:new Error(String(H)),e)}))}w(null),j(null),A("")},[k,A,w,j,e,l]),T=c.useCallback(()=>{w(null),j(null),A("")},[A,w,j]),z=c.useCallback(N=>{Oo(N).then(C=>{if(C.ok){_e.success(e("sessions.sidebar.session.copyId.success"));return}_e.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(e("sessions.sidebar.session.copyId.error")))},[e]),O=c.useCallback(async(N,C,I)=>{const H=C?.archivedBucket===!0||C?.hardDelete===!0,M=I?.descendantIds??x;await jg(H?"delete":"archive",N,M,{archiveSession:f,archiveSessions:h,deleteSession:d,deleteSessions:u},e)},[f,h,d,u,x,e]),W=c.useCallback((N,C)=>{const I=C?.archivedBucket===!0||C?.hardDelete===!0,H=su(N.id,x,I);if(!p||C?.skipConfirm===!0){O(N,C,{descendantIds:H});return}y({session:N,descendantCount:H.length,descendantIds:H,archivedBucket:I})},[x,O,y,p]),D=c.useCallback(async()=>{const N=o.current;if(!N)return;const{session:C,archivedBucket:I,descendantIds:H}=N;y(null),await O(C,{archivedBucket:I},{descendantIds:H})},[O,y]),Q=c.useCallback(async N=>{await m(N.id)?_e.success(e("sessions.sidebar.session.restore.success")):_e.error(e("sessions.sidebar.session.restore.error"))},[e,m]);return c.useMemo(()=>({handleSessionSelect:B,handleSessionDoubleClick:R,handleSaveEdit:E,handleCancelEdit:T,handleCopySessionId:z,handleDeleteSession:W,handleRestoreSession:Q,confirmDeleteSession:D}),[T,z,W,Q,E,R,B,D])};function h3(t){const e=He.c(71),{t:s}=wt(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:a,onConfirm:l}=t;let d,u,f,h,m,g,b,v,S,x;if(e[0]!==o||e[1]!==s||e[2]!==r){const C=s("sessions.sidebar.session.untitled");h=zs,S=!!r,e[13]!==o?(x=H=>{H||o(null)},e[13]=o,e[14]=x):x=e[14],f=$s,b=!1,v="max-w-sm gap-5",u=qs;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?(g=n.jsx(Gs,{children:I}),e[18]=I,e[19]=g):g=e[19],d=Us,m=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?s("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||C,count:r.descendantCount}):s("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||C,count:r.descendantCount}):r.descendantCount===1?s("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||C,count:r.descendantCount}):s("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||C,count:r.descendantCount}):r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||C}):s("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||C}),e[0]=o,e[1]=s,e[2]=r,e[3]=d,e[4]=u,e[5]=f,e[6]=h,e[7]=m,e[8]=g,e[9]=b,e[10]=v,e[11]=S,e[12]=x}else d=e[3],u=e[4],f=e[5],h=e[6],m=e[7],g=e[8],b=e[9],v=e[10],S=e[11],x=e[12];let p;e[20]!==d||e[21]!==m?(p=n.jsx(d,{children:m}),e[20]=d,e[21]=m,e[22]=p):p=e[22];let y;e[23]!==u||e[24]!==g||e[25]!==p?(y=n.jsxs(u,{children:[g,p]}),e[23]=u,e[24]=g,e[25]=p,e[26]=y):y=e[26];let w;e[27]!==a||e[28]!==i?(w=()=>a(!i),e[27]=a,e[28]=i,e[29]=w):w=e[29];const j=!i;let k;e[30]!==i?(k=i?n.jsx(Z,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(Z,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=i,e[31]=k):k=e[31];let P;e[32]!==s?(P=s("sessions.sidebar.dialogs.neverAsk"),e[32]=s,e[33]=P):P=e[33];let A;e[34]!==k||e[35]!==P||e[36]!==w||e[37]!==j?(A=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":j,children:[k,P]}),e[34]=k,e[35]=P,e[36]=w,e[37]=j,e[38]=A):A=e[38];let B;e[39]!==o?(B=()=>o(null),e[39]=o,e[40]=B):B=e[40];let R;e[41]!==s?(R=s("sessions.sidebar.dialogs.cancel"),e[41]=s,e[42]=R):R=e[42];let E;e[43]!==B||e[44]!==R?(E=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:R}),e[43]=B,e[44]=R,e[45]=E):E=e[45];let T;e[46]!==l?(T=()=>{l()},e[46]=l,e[47]=T):T=e[47];let z;e[48]!==s||e[49]!==r?.archivedBucket?(z=r?.archivedBucket?s("sessions.sidebar.bulkActions.delete"):s("sessions.sidebar.bulkActions.archive"),e[48]=s,e[49]=r?.archivedBucket,e[50]=z):z=e[50];let O;e[51]!==T||e[52]!==z?(O=n.jsx("button",{type:"button",onClick:T,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:z}),e[51]=T,e[52]=z,e[53]=O):O=e[53];let W;e[54]!==E||e[55]!==O?(W=n.jsxs("div",{className:"flex items-center gap-2",children:[E,O]}),e[54]=E,e[55]=O,e[56]=W):W=e[56];let D;e[57]!==A||e[58]!==W?(D=n.jsxs(yn,{className:"w-full sm:items-center sm:justify-between",children:[A,W]}),e[57]=A,e[58]=W,e[59]=D):D=e[59];let Q;e[60]!==f||e[61]!==b||e[62]!==D||e[63]!==v||e[64]!==y?(Q=n.jsxs(f,{showCloseButton:b,className:v,children:[y,D]}),e[60]=f,e[61]=b,e[62]=D,e[63]=v,e[64]=y,e[65]=Q):Q=e[65];let N;return e[66]!==h||e[67]!==Q||e[68]!==S||e[69]!==x?(N=n.jsx(h,{open:S,onOpenChange:x,children:Q}),e[66]=h,e[67]=Q,e[68]=S,e[69]=x,e[70]=N):N=e[70],N}function p3(t){const e=He.c(57),{t:s}=wt(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:a,onConfirm:l}=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 h=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 g=m,b=!!r;let v;e[8]!==o?(v=N=>{N||o(null)},e[8]=o,e[9]=v):v=e[9];let S;e[10]!==h?(S=n.jsx(Gs,{children:h}),e[10]=h,e[11]=S):S=e[11];let x;e[12]!==g?(x=n.jsx(Us,{children:g}),e[12]=g,e[13]=x):x=e[13];let p;e[14]!==S||e[15]!==x?(p=n.jsxs(qs,{children:[S,x]}),e[14]=S,e[15]=x,e[16]=p):p=e[16];let y;e[17]!==a||e[18]!==i?(y=()=>a(!i),e[17]=a,e[18]=i,e[19]=y):y=e[19];const w=!i;let j;e[20]!==i?(j=i?n.jsx(Z,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(Z,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=i,e[21]=j):j=e[21];let k;e[22]!==s?(k=s("sessions.sidebar.dialogs.neverAsk"),e[22]=s,e[23]=k):k=e[23];let P;e[24]!==k||e[25]!==y||e[26]!==w||e[27]!==j?(P=n.jsxs("button",{type:"button",onClick:y,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":w,children:[j,k]}),e[24]=k,e[25]=y,e[26]=w,e[27]=j,e[28]=P):P=e[28];let A;e[29]!==o?(A=()=>o(null),e[29]=o,e[30]=A):A=e[30];let B;e[31]!==s?(B=s("sessions.sidebar.dialogs.cancel"),e[31]=s,e[32]=B):B=e[32];let R;e[33]!==A||e[34]!==B?(R=n.jsx("button",{type:"button",onClick:A,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:B}),e[33]=A,e[34]=B,e[35]=R):R=e[35];let E;e[36]!==l?(E=()=>{l()},e[36]=l,e[37]=E):E=e[37];let T;e[38]!==d||e[39]!==s?(T=s(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=s,e[40]=T):T=e[40];let z;e[41]!==E||e[42]!==T?(z=n.jsx("button",{type:"button",onClick:E,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:T}),e[41]=E,e[42]=T,e[43]=z):z=e[43];let O;e[44]!==R||e[45]!==z?(O=n.jsxs("div",{className:"flex items-center gap-2",children:[R,z]}),e[44]=R,e[45]=z,e[46]=O):O=e[46];let W;e[47]!==P||e[48]!==O?(W=n.jsxs(yn,{className:"w-full sm:items-center sm:justify-between",children:[P,O]}),e[47]=P,e[48]=O,e[49]=W):W=e[49];let D;e[50]!==W||e[51]!==p?(D=n.jsxs($s,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,W]}),e[50]=W,e[51]=p,e[52]=D):D=e[52];let Q;return e[53]!==b||e[54]!==D||e[55]!==v?(Q=n.jsx(zs,{open:b,onOpenChange:v,children:D}),e[53]=b,e[54]=D,e[55]=v,e[56]=Q):Q=e[56],Q}function qh(t){const e=He.c(36),{t:s}=wt(),{value:r,setValue:o,onConfirm:i}=t,a=!!r;let l;e[0]!==o?(l=j=>{j||o(null)},e[0]=o,e[1]=l):l=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(Gs,{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 h;e[9]!==f?(h=n.jsx(Us,{children:f}),e[9]=f,e[10]=h):h=e[10];let m;e[11]!==u||e[12]!==h?(m=n.jsxs(qs,{children:[u,h]}),e[11]=u,e[12]=h,e[13]=m):m=e[13];let g;e[14]!==o?(g=()=>o(null),e[14]=o,e[15]=g):g=e[15];let b;e[16]!==s?(b=s("sessions.sidebar.dialogs.cancel"),e[16]=s,e[17]=b):b=e[17];let v;e[18]!==g||e[19]!==b?(v=n.jsx("button",{type:"button",onClick:g,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:b}),e[18]=g,e[19]=b,e[20]=v):v=e[20];let S;e[21]!==s?(S=s("sessions.sidebar.bulkActions.delete"),e[21]=s,e[22]=S):S=e[22];let x;e[23]!==i||e[24]!==S?(x=n.jsx("button",{type:"button",onClick:i,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:S}),e[23]=i,e[24]=S,e[25]=x):x=e[25];let p;e[26]!==x||e[27]!==v?(p=n.jsxs(yn,{children:[v,x]}),e[26]=x,e[27]=v,e[28]=p):p=e[28];let y;e[29]!==p||e[30]!==m?(y=n.jsxs($s,{showCloseButton:!1,className:"max-w-sm gap-5",children:[m,p]}),e[29]=p,e[30]=m,e[31]=y):y=e[31];let w;return e[32]!==a||e[33]!==l||e[34]!==y?(w=n.jsx(zs,{open:a,onOpenChange:l,children:y}),e[32]=a,e[33]=l,e[34]=y,e[35]=w):w=e[35],w}const m3=new Set;function g3(t){const e=He.c(113),{node:s,depth:r,groupDirectory:o,projectId:i,folderOwnerKey:a,selectionScopeKey:l,archivedBucket:d,secondaryMeta:u,renderContext:f,rowKey:h,dragKey:m,renderExtras:g,pinnedSessionIds:b,expandedParents:v,hasSessionSearchQuery:S,normalizedSessionSearchQuery:x,notifyOnSubtasks:p,editingId:y,editingRowKey:w,setEditingId:j,setEditingRowKey:k,editTitle:P,setEditTitle:A,toggleParent:B,openSidebarMenuKey:R,setOpenSidebarMenuKey:E,allowReselect:T,onSessionSelected:z,resetSessionSearch:O,deleteSessionConfirm:W,setDeleteSessionConfirm:D,startFolderRename:Q,startSessionWorktreeMenuLoad:N,mobileVariant:C,alwaysShowActions:I,renderChildren:H}=t,M=r===void 0?0:r,_=d===void 0?!1:d,F=f===void 0?"project":f,ee=H===void 0?!0:H;Ss("ui.sidebar_tree_item.render");const ne=h??`${F}:${_?"archived":"active"}:${s.session.id}`,re=Xt(S3),te=Xt(x3),K=de(y3),q=de(b3);let oe;if(e[0]!==s){oe=[];const Ne=Ue=>Ue.children.forEach(We=>{oe.push(We.session.id),Ne(We)});Ne(s),e[0]=s,e[1]=oe}else oe=e[1];const fe=oe.join(`
|
|
1047
|
-
`);let ce;e[2]!==fe?(ce=fe?fe.split(`
|
|
1048
|
-
`):[],e[2]=fe,e[3]=ce):ce=e[3];const ke=ce;let De;e[4]!==re||e[5]!==Q||e[6]!==te?(De=(Ne,Ue)=>{if(!Ne)return null;Ue&&Xt.getState().collapsedFolderIds.has(Ue)&&te(Ue);const We=re(Ne,"New folder",Ue);return Q(Ne,We),We},e[4]=re,e[5]=Q,e[6]=te,e[7]=De):De=e[7];const Ce=De;let Y;e[8]!==T||e[9]!==W||e[10]!==ke||e[11]!==P||e[12]!==y||e[13]!==ne||e[14]!==C||e[15]!==s.session.id||e[16]!==z||e[17]!==O||e[18]!==D||e[19]!==A||e[20]!==j||e[21]!==k||e[22]!==K?(Y={mobileVariant:C,allowReselect:T,onSessionSelected:z,resetSessionSearch:O,descendantIds:ke,showDeletionDialog:K,setDeleteSessionConfirm:D,deleteSessionConfirm:W,editingId:y,setEditingId:j,setEditingRowKey:k,editingSessionId:s.session.id,editingOccurrenceKey:ne,editTitle:P,setEditTitle:A},e[8]=T,e[9]=W,e[10]=ke,e[11]=P,e[12]=y,e[13]=ne,e[14]=C,e[15]=s.session.id,e[16]=z,e[17]=O,e[18]=D,e[19]=A,e[20]=j,e[21]=k,e[22]=K,e[23]=Y):Y=e[23];const je=f3(Y),we=g?.childRenderExtrasFor,Pe=s.session.directory??o;let L;e[24]!==_||e[25]!==i||e[26]!==F||e[27]!==Pe?(L={groupDirectory:Pe,projectId:i,archivedBucket:_,renderContext:F},e[24]=_,e[25]=i,e[26]=F,e[27]=Pe,e[28]=L):L=e[28];const ie=L,G=m??h??s.session.id,ae=g?.subtreeContainsEditing??m3,ge=g?.menuOpenSessionId??null,me=g?.nodeStructureKey??"",be=g?.blockingBadgeSessionScopes,ye=g?.relativeTimeTick;let Te;e[29]!==T||e[30]!==I||e[31]!==ie||e[32]!==we||e[33]!==W||e[34]!==M||e[35]!==P||e[36]!==y||e[37]!==w||e[38]!==v||e[39]!==a||e[40]!==S||e[41]!==C||e[42]!==s.children||e[43]!==x||e[44]!==p||e[45]!==z||e[46]!==R||e[47]!==b||e[48]!==ee||e[49]!==O||e[50]!==l||e[51]!==D||e[52]!==A||e[53]!==j||e[54]!==k||e[55]!==E||e[56]!==Q||e[57]!==N||e[58]!==B?(Te=ee?s.children.map(Ne=>n.jsx(Po,{node:Ne,pinnedSessionIds:b,expandedParents:v,hasSessionSearchQuery:S,normalizedSessionSearchQuery:x,notifyOnSubtasks:p,editingId:y,editingRowKey:w,setEditingId:j,setEditingRowKey:k,editTitle:P,setEditTitle:A,toggleParent:B,openSidebarMenuKey:R,setOpenSidebarMenuKey:E,allowReselect:T,onSessionSelected:z,resetSessionSearch:O,deleteSessionConfirm:W,setDeleteSessionConfirm:D,startFolderRename:Q,startSessionWorktreeMenuLoad:N,mobileVariant:C,alwaysShowActions:I,depth:M+1,folderOwnerKey:a,selectionScopeKey:l,...ie,renderExtras:we?.(Ne)},Ne.session.id)):null,e[29]=T,e[30]=I,e[31]=ie,e[32]=we,e[33]=W,e[34]=M,e[35]=P,e[36]=y,e[37]=w,e[38]=v,e[39]=a,e[40]=S,e[41]=C,e[42]=s.children,e[43]=x,e[44]=p,e[45]=z,e[46]=R,e[47]=b,e[48]=ee,e[49]=O,e[50]=l,e[51]=D,e[52]=A,e[53]=j,e[54]=k,e[55]=E,e[56]=Q,e[57]=N,e[58]=B,e[59]=Te):Te=e[59];let $;e[60]!==I||e[61]!==_||e[62]!==Ce||e[63]!==M||e[64]!==P||e[65]!==y||e[66]!==w||e[67]!==ne||e[68]!==v||e[69]!==a||e[70]!==o||e[71]!==S||e[72]!==C||e[73]!==s||e[74]!==x||e[75]!==p||e[76]!==R||e[77]!==b||e[78]!==i||e[79]!==F||e[80]!==u||e[81]!==l||e[82]!==je.handleCancelEdit||e[83]!==je.handleCopySessionId||e[84]!==je.handleDeleteSession||e[85]!==je.handleRestoreSession||e[86]!==je.handleSaveEdit||e[87]!==je.handleSessionDoubleClick||e[88]!==je.handleSessionSelect||e[89]!==A||e[90]!==j||e[91]!==k||e[92]!==E||e[93]!==N||e[94]!==G||e[95]!==ae||e[96]!==ge||e[97]!==me||e[98]!==be||e[99]!==ye||e[100]!==Te||e[101]!==B?($=n.jsx(d3,{expandedParents:v,hasSessionSearchQuery:S,normalizedSessionSearchQuery:x,notifyOnSubtasks:p,editingId:y,editingRowKey:w,setEditingId:j,setEditingRowKey:k,editTitle:P,setEditTitle:A,handleSaveEdit:je.handleSaveEdit,handleCancelEdit:je.handleCancelEdit,toggleParent:B,handleSessionSelect:je.handleSessionSelect,handleSessionDoubleClick:je.handleSessionDoubleClick,handleCopySessionId:je.handleCopySessionId,openSidebarMenuKey:R,setOpenSidebarMenuKey:E,createFolderAndStartRename:Ce,handleDeleteSession:je.handleDeleteSession,handleRestoreSession:je.handleRestoreSession,startSessionWorktreeMenuLoad:N,mobileVariant:C,alwaysShowActions:I,pinnedSessionIds:b,node:s,depth:M,groupDirectory:o,projectId:i,folderOwnerKey:a,selectionScopeKey:l,archivedBucket:_,secondaryMeta:u,renderContext:F,rowKey:ne,dragKey:G,subtreeContainsEditing:ae,menuOpenSessionId:ge,nodeStructureKey:me,blockingBadgeSessionScopes:be,relativeTimeTick:ye,children:Te}),e[60]=I,e[61]=_,e[62]=Ce,e[63]=M,e[64]=P,e[65]=y,e[66]=w,e[67]=ne,e[68]=v,e[69]=a,e[70]=o,e[71]=S,e[72]=C,e[73]=s,e[74]=x,e[75]=p,e[76]=R,e[77]=b,e[78]=i,e[79]=F,e[80]=u,e[81]=l,e[82]=je.handleCancelEdit,e[83]=je.handleCopySessionId,e[84]=je.handleDeleteSession,e[85]=je.handleRestoreSession,e[86]=je.handleSaveEdit,e[87]=je.handleSessionDoubleClick,e[88]=je.handleSessionSelect,e[89]=A,e[90]=j,e[91]=k,e[92]=E,e[93]=N,e[94]=G,e[95]=ae,e[96]=ge,e[97]=me,e[98]=be,e[99]=ye,e[100]=Te,e[101]=B,e[102]=$):$=e[102];let he;e[103]!==W||e[104]!==s.session.id||e[105]!==je.confirmDeleteSession||e[106]!==D||e[107]!==q||e[108]!==K?(he=W?.session.id===s.session.id?n.jsx(h3,{value:W,setValue:D,showDeletionDialog:K,setShowDeletionDialog:q,onConfirm:je.confirmDeleteSession}):null,e[103]=W,e[104]=s.session.id,e[105]=je.confirmDeleteSession,e[106]=D,e[107]=q,e[108]=K,e[109]=he):he=e[109];let se;return e[110]!==$||e[111]!==he?(se=n.jsxs(n.Fragment,{children:[$,he]}),e[110]=$,e[111]=he,e[112]=se):se=e[112],se}function b3(t){return t.setShowDeletionDialog}function y3(t){return t.showDeletionDialog}function x3(t){return t.toggleFolderCollapse}function S3(t){return t.createFolder}const v3=(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&&pf(t.session,e.session)&&ot(t.worktree?.path??null)===ot(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,w3=(t,e)=>{if(t.node!==e.node&&!v3(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)||(t.secondaryMeta?.inSpace??!1)!==(e.secondaryMeta?.inSpace??!1))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","onSessionSelected","resetSessionSearch","setDeleteSessionConfirm","startFolderRename"];for(const o of r)if(t[o]!==e[o])return!1;return!0},Po=c.memo(g3,w3),k3=10,j3=4;function Sd(t){const e=He.c(7),{providerIDs:s,ringClass:r}=t;let o;if(e[0]!==s||e[1]!==r){let a;e[3]!==r?(a=l=>n.jsx("span",{className:ve("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:n.jsx(rf,{providerId:l,className:"h-3 w-3"})},l),e[3]=r,e[4]=a):a=e[4],o=s.slice(0,j3).map(a),e[0]=s,e[1]=r,e[2]=o}else o=e[2];let i;return e[5]!==o?(i=n.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:o}),e[5]=o,e[6]=i):i=e[6],i}function C3(t){const e=He.c(95),{run:s,depth:r,laneNodes:o,blockingSessionIds:i,renderContext:a,projectId:l,projectLabel:d,expansionKey:u,expanded:f,forceExpanded:h,notifyOnSubtasks:m,toggleParent:g}=t,{t:b}=wt();let v;e[0]!==s.key?(v=ke=>ke.runOverviewKey===s.key,e[0]=s.key,e[1]=v):v=e[1];const S=de(v),x=Un(a);let p;e[2]!==l||e[3]!==a?(p=ke=>a==="timeline-mixed"&&l?ke.projects.find(De=>De.id===l)??null:null,e[2]=l,e[3]=a,e[4]=p):p=e[4];const y=Zt(p),w=s.lanes.length;let j;e[5]!==w||e[6]!==b?(j=w===1?b("sessions.sidebar.run.laneCountSingle",{count:w}):b("sessions.sidebar.run.laneCountPlural",{count:w}),e[5]=w,e[6]=b,e[7]=j):j=e[7];const k=j;let P;e[8]!==o?(P=[...o],e[8]=o,e[9]=P):P=e[9];const A=P;let B;e[10]!==A||e[11]!==i||e[12]!==m?(B=n.jsx(du,{nodes:A,blockingSessionIds:i,includeUnreadSubtasks:m}),e[10]=A,e[11]=i,e[12]=m,e[13]=B):B=e[13];const R=B,E=S?"text-interactive-selection-foreground":"text-foreground/80";let T;e[14]!==s.key?(T=()=>de.getState().setRunOverviewKey(s.key),e[14]=s.key,e[15]=T):T=e[15];const z=T;if(x){const ke=s.key,De=S?"page":void 0;let Ce;e[16]!==s.title||e[17]!==b?(Ce=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[16]=s.title,e[17]=b,e[18]=Ce):Ce=e[18];let Y;e[19]===Symbol.for("react.memo_cache_sentinel")?(Y={paddingInlineStart:k3},e[19]=Y):Y=e[19];const je=S?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let we;e[20]!==je?(we=ve("group relative my-0.5 flex w-full cursor-pointer items-center rounded-md py-1.5 pe-2.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",je),e[20]=je,e[21]=we):we=e[21];const Pe=s.title;let L;e[22]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx($i,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[22]=L):L=e[22];let ie;e[23]!==k?(ie=n.jsxs(n.Fragment,{children:[L,n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:k})]}),e[23]=k,e[24]=ie):ie=e[24];let G;e[25]!==s.lastActivity?(G=hf(s.lastActivity),e[25]=s.lastActivity,e[26]=G):G=e[26];let ae;e[27]!==s.providerIDs?(ae=n.jsx(Sd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[27]=s.providerIDs,e[28]=ae):ae=e[28];let ge;e[29]!==R||e[30]!==d||e[31]!==s.title||e[32]!==ie||e[33]!==G||e[34]!==ae||e[35]!==y||e[36]!==E?(ge=n.jsx(ca,{project:y,projectLabel:d,title:Pe,titleClassName:E,branchLabel:null,metaLineLead:ie,statusDot:R,pinnedMarker:null,timeSlot:G,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:ae,hideMetaOnHoverClass:""}),e[29]=R,e[30]=d,e[31]=s.title,e[32]=ie,e[33]=G,e[34]=ae,e[35]=y,e[36]=E,e[37]=ge):ge=e[37];let me;return e[38]!==z||e[39]!==s.key||e[40]!==we||e[41]!==ge||e[42]!==De||e[43]!==Ce?(me=n.jsx("button",{type:"button","data-run-row":ke,"aria-current":De,"aria-label":Ce,onClick:z,style:Y,className:we,children:ge}),e[38]=z,e[39]=s.key,e[40]=we,e[41]=ge,e[42]=De,e[43]=Ce,e[44]=me):me=e[44],me}let O;e[45]!==u||e[46]!==h||e[47]!==g?(O=ke=>{ke.stopPropagation(),h||g(u)},e[45]=u,e[46]=h,e[47]=g,e[48]=O):O=e[48];const W=O,D=s.key,Q=S?"page":void 0;let N;e[49]!==r?(N=tr(r),e[49]=r,e[50]=N):N=e[50];let C;e[51]!==N?(C={paddingInlineStart:N},e[51]=N,e[52]=C):C=e[52];const I=S?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let H;e[53]!==I?(H=ve("group relative my-0.5 flex cursor-pointer items-center gap-1.5 rounded-md py-[3px] pe-2.5",I),e[53]=I,e[54]=H):H=e[54];let M;e[55]!==W?(M=ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),W(ke))},e[55]=W,e[56]=M):M=e[56];let _;e[57]!==f||e[58]!==b?(_=b(f?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[57]=f,e[58]=b,e[59]=_):_=e[59];let F;e[60]!==f?(F=n.jsx(jr,{expanded:f}),e[60]=f,e[61]=F):F=e[61];let ee;e[62]!==f||e[63]!==M||e[64]!==_||e[65]!==F||e[66]!==W?(ee=n.jsx("button",{type:"button",onClick:W,onKeyDown:M,className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-expanded":f,"aria-label":_,children:F}),e[62]=f,e[63]=M,e[64]=_,e[65]=F,e[66]=W,e[67]=ee):ee=e[67];let ne;e[68]!==z?(ne=ke=>{ke.stopPropagation(),z()},e[68]=z,e[69]=ne):ne=e[69];let re;e[70]!==s.title||e[71]!==b?(re=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[70]=s.title,e[71]=b,e[72]=re):re=e[72];let te;e[73]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx($i,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[73]=te):te=e[73];let K;e[74]!==E?(K=ve("oc-ui-start-align block min-w-0 flex-1 truncate typography-ui-label font-normal",E),e[74]=E,e[75]=K):K=e[75];let q;e[76]!==s.title||e[77]!==K?(q=n.jsx("span",{dir:"auto",className:K,children:s.title}),e[76]=s.title,e[77]=K,e[78]=q):q=e[78];let oe;e[79]!==s.providerIDs?(oe=n.jsx(Sd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar"}),e[79]=s.providerIDs,e[80]=oe):oe=e[80];let fe;e[81]!==R||e[82]!==ne||e[83]!==re||e[84]!==q||e[85]!==oe?(fe=n.jsxs("button",{type:"button",onClick:ne,className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":re,children:[te,q,oe,R]}),e[81]=R,e[82]=ne,e[83]=re,e[84]=q,e[85]=oe,e[86]=fe):fe=e[86];let ce;return e[87]!==z||e[88]!==s.key||e[89]!==C||e[90]!==H||e[91]!==ee||e[92]!==fe||e[93]!==Q?(ce=n.jsxs("div",{"data-run-row":D,"aria-current":Q,onClick:z,style:C,className:H,children:[ee,fe]}),e[87]=z,e[88]=s.key,e[89]=C,e[90]=H,e[91]=ee,e[92]=fe,e[93]=Q,e[94]=ce):ce=e[94],ce}const P3=c.memo(C3),E3=24,N3=t=>Array.from({length:Math.min(t,E3)},(e,s)=>s),I3=(t,e,s)=>{const r=new Set(t);for(const o of e)o>=0&&o<s&&r.add(o);return[...r].sort((o,i)=>o-i)},R3=(t,e)=>t.find(s=>s.end>e)?.index??0,D3={"pb-2":8,"pb-1.5":6},vd=t=>`${t.kind}:${"renderContext"in t?t.renderContext:""}`,T3=(t,e)=>`${t.key}|${zn(t,e)??""}`,M3=(t,e,s={})=>{const r=zn(t,e),o=r?s.gapBySpacing?.get(r)??D3[r]:0;return(s.height??t.estimateSize)+o},zn=(t,e)=>e?.kind==="activity-header"||e?.kind==="project-header"?"pb-2":e?.kind==="group-header"&&t.kind!=="project-header"?"pb-1.5":void 0,A3=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function O3({model:t,scrollElement:e,pinnedRowIndexes:s,renderRow:r,onFirstVisibleIndexChange:o}){const i=t.rows,a=c.useCallback(()=>e,[e]),l=c.useRef(new Map),d=c.useRef(new Map),u=c.useCallback(R=>{const E=i[R];if(!E)return 32;const T=i[R+1];return M3(E,T,{height:l.current.get(vd(E)),gapBySpacing:d.current})},[i]),f=c.useCallback((R,E,T)=>{const z=D1(R,E,T),O=T.indexFromElement(R),W=i[O];if(W){const D=zn(W,i[O+1]),Q=D&&Number.parseFloat(getComputedStyle(R).paddingBottom)||0;D&&d.current.set(D,Q),l.current.set(vd(W),z-Q)}return z},[i]),h=c.useCallback(R=>{const E=i[R];return E?T3(E,i[R+1]):R},[i]),m=c.useRef(0),[g,b]=c.useState(null),v=g?.slidingIndexes,S=c.useCallback(R=>{const E=T1(R),T=v?.length?new Set([...s,...v]):s;return I3(E,T,i.length)},[s,i.length,v]),x=R1({count:i.length,enabled:e!==null,getScrollElement:a,estimateSize:u,measureElement:f,getItemKey:h,overscan:8,rangeExtractor:S}),p=x.getVirtualItems(),y=e?x.getTotalSize():0,w=e?Math.max(y-e.clientHeight,0):0,j=e?Math.min(e.scrollTop,w):0,k=R3(p,j);c.useLayoutEffect(()=>{o(k)},[k,o]);const P=c.useRef(null),A=c.useRef(null);if(c.useLayoutEffect(()=>{const R=A.current;if(!R||R.rows===i||!e||A3())return;const E=Cg(R.rows,i);if(!E)return;const T=R.measurements,z=x.measurementsCache,O=T[E.previousHeaderIndex],W=z[E.nextHeaderIndex];if(!O||!W)return;const D=W.start-O.start,Q=E.opened?T[E.previousHeaderIndex+1]:T[E.blockEnd],N=E.opened?E.blockEnd:E.nextHeaderIndex+1,C=z[N],I=(Q?.start??O.end)+D,H=C?.start??W.end,M=e.scrollTop-e.clientHeight,_=e.scrollTop+e.clientHeight*2,F=new Set,ee=[],ne=[];if(E.opened){for(let re=E.blockStart;re<E.blockEnd;re+=1)F.add(i[re].key);for(let re=N;re<z.length&&z[re].start+I-H<_;re+=1)ne.push(re)}else for(let re=E.blockStart;re<E.blockEnd;re+=1){const te=T[re];!te||te.end+D<M||te.start+D>_||ee.push({row:R.rows[re],nextRow:R.rows[re+1],start:te.start+D,end:te.end+D})}m.current+=1,b({id:m.current,revealKeys:F,ghosts:ee,followingIndex:N,from:I,to:H,slidingIndexes:ne})},[i,e,x]),c.useLayoutEffect(()=>{A.current={rows:i,measurements:x.measurementsCache}}),c.useLayoutEffect(()=>{const R=P.current;if(!g||!R)return;const E={duration:Eg,easing:Pg},T=g.from-g.to,z=[];for(const W of R.children){if(!(W instanceof HTMLElement))continue;const D=W.dataset.sidebarRowKey??"",Q=Number(W.dataset.sidebarVirtualStart);W.dataset.sidebarGhost==="true"?z.push(W.animate(_l(Q,W.offsetHeight,g.from,g.to),{...E,fill:"forwards"})):g.revealKeys.has(D)?z.push(W.animate(_l(Q,W.offsetHeight,g.from,g.to),E)):Number(W.dataset.index)>=g.followingIndex&&T!==0&&z.push(W.animate([{transform:`translateY(${Q+T}px)`},{transform:`translateY(${Q}px)`}],E))}let O=!1;return Promise.all(z.map(W=>W.finished)).then(()=>{O||b(W=>W?.id===g.id?null:W)},()=>{}),()=>{O=!0;for(const W of z)W.cancel()}},[g]),!e){const R=N3(i.length),E=R.reduce((z,O)=>z+(i[O]?.estimateSize??0),0),T=i.reduce((z,O)=>z+O.estimateSize,0);return n.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[R.map(z=>{const O=i[z];return O?n.jsx("div",{className:zn(O,i[z+1]),children:r(O,z)},O.key):null}),T>E?n.jsx("div",{"aria-hidden":"true",style:{height:T-E}}):null]})}const B=g?.ghosts.reduce((R,E)=>Math.max(R,E.end),0)??0;return n.jsxs("div",{ref:P,"data-sidebar-virtual-ready":"true",style:{height:Math.max(y,B),position:"relative"},children:[g?.ghosts.map(R=>n.jsx("div",{"aria-hidden":"true",inert:!0,className:`[&_[data-session-row]]:my-px ${zn(R.row,R.nextRow)??""}`,"data-sidebar-ghost":"true","data-sidebar-row-key":R.row.key,"data-sidebar-virtual-start":R.start,style:{position:"absolute",top:0,left:0,width:"100%",pointerEvents:"none",transform:`translateY(${R.start}px)`},children:r(R.row,-1)},R.row.key)),p.map(R=>{const E=i[R.index];return E?n.jsx("div",{className:`[&_[data-session-row]]:my-px ${zn(E,i[R.index+1])??""}`,"data-index":R.index,"data-sidebar-row-key":E.key,"data-sidebar-virtual-start":R.start,ref:x.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${R.start}px)`},children:r(E,R.index)},E.key):null})]})}const B3={work:"eye",chats:"chat-4"},F3={work:"sessions.sidebar.work.title",chats:"sessions.sidebar.activity.chatsTitle"},L3=t=>{const e=He.c(33),{activityKey:s,collapsed:r,forceExpanded:o,alwaysShowActions:i,onToggle:a,onNewChat:l}=t,{t:d}=wt(),u=s==="chats",f=o?void 0:a,h=u?"pe-10":"pe-3.5";let m;e[0]!==h?(m=ve("group flex w-full items-center gap-1.5 py-1 ps-4 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",h),e[0]=h,e[1]=m):m=e[1];const g=!r,b=B3[s],v=!o&&"group-hover:hidden";let S;e[2]!==v?(S=ve("h-3.5 w-3.5 text-muted-foreground/80",v),e[2]=v,e[3]=S):S=e[3];let x;e[4]!==b||e[5]!==S?(x=n.jsx(Z,{name:b,className:S}),e[4]=b,e[5]=S,e[6]=x):x=e[6];let p;e[7]!==r||e[8]!==o?(p=o?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(Z,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[7]=r,e[8]=o,e[9]=p):p=e[9];let y;e[10]!==x||e[11]!==p?(y=n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[x,p]}),e[10]=x,e[11]=p,e[12]=y):y=e[12];const w=F3[s];let j;e[13]!==d||e[14]!==w?(j=d(w),e[13]=d,e[14]=w,e[15]=j):j=e[15];let k;e[16]!==j?(k=n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:j}),e[16]=j,e[17]=k):k=e[17];let P;e[18]!==o||e[19]!==f||e[20]!==y||e[21]!==k||e[22]!==m||e[23]!==g?(P=n.jsxs("button",{type:"button",onClick:f,disabled:o,className:m,"aria-expanded":g,children:[y,k]}),e[18]=o,e[19]=f,e[20]=y,e[21]=k,e[22]=m,e[23]=g,e[24]=P):P=e[24];let A;e[25]!==i||e[26]!==u||e[27]!==l||e[28]!==d?(A=u?n.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),l()},className:ve("absolute inset-e-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",i?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":d("sessions.sidebar.header.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})}):null,e[25]=i,e[26]=u,e[27]=l,e[28]=d,e[29]=A):A=e[29];let B;return e[30]!==P||e[31]!==A?(B=n.jsxs("div",{className:"relative group/chats -ms-2.5 -me-2",children:[P,A]}),e[30]=P,e[31]=A,e[32]=B):B=e[32],B},Yh=c.createContext(null);function wd(t){let e=0,s=t;for(;s;){e+=s.offsetTop;const i=s.offsetParent;s=i instanceof HTMLElement?i:null}const r=t.closest("[data-sidebar-virtual-start]"),o=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(o)?o:0)}function _3(t){const e=He.c(11),{suspended:s,layoutKey:r,scrollRef:o,children:i}=t,a=s===void 0?!1:s,l=r===void 0?"":r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[0]=d):d=e[0];const u=c.useRef(d),f=c.useRef(null);let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=S=>(u.current.add(S),f.current?.(),()=>{u.current.delete(S),f.current?.()}),e[1]=h):h=e[1];const m=h;let g;e[2]!==o||e[3]!==a?(g=()=>{const S=o.current;if(a||!S)return;const x=document.createElement("div");x.dataset.sidebarCrossfadeLayer="true",x.className="pointer-events-none sticky top-0 z-30 h-0",x.style.marginBlock="0px",S.prepend(x);let p=null,y=null,w=null,j=0;const k=new Set;let P=[];const A=window.matchMedia("(prefers-reduced-motion: reduce)"),B=(D,Q)=>{const N=document.activeElement,C=N instanceof HTMLElement&&D.host.contains(N),I=C?S.scrollTop:null;Q.moveBefore&&Q.isConnected&&D.host.isConnected?Q.moveBefore(D.host,null):Q.append(D.host),C&&N.focus({preventScroll:!0}),I!==null&&S.scrollTop!==I&&(S.scrollTop=I)},R=()=>{w?.cancel(),w=null,y?.remove(),y=null},E=()=>{let D=null,Q=-1/0;for(const{entry:N,top:C}of P)C<=S.scrollTop&&C>=Q&&(Q=C,D=N);if(p!==D){if(R(),p&&D&&!A.matches){const N=p.host.cloneNode(!0);N instanceof HTMLElement&&(N.inert=!0,N.setAttribute("aria-hidden","true"),N.querySelectorAll("[id]").forEach($3),N.className="pointer-events-none absolute inset-x-0 top-0 z-30",y=N)}p&&(B(p,p.slot),p.slot.style.removeProperty("height")),p=D,x.hidden=!D,D&&(D.slot.style.height=`${D.host.getBoundingClientRect().height}px`,B(D,x),y&&(x.append(y),w=y.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),w.onfinish=R))}},T=()=>{p&&(p.slot.style.height=`${p.host.getBoundingClientRect().height}px`);const D=wd(S)+S.clientTop;P=Array.from(u.current,Q=>({entry:Q,top:wd(Q.slot)-D})),E()},z=new ResizeObserver(T),O=new MutationObserver(()=>{cancelAnimationFrame(j),j=requestAnimationFrame(T)});z.observe(S);const W=()=>{O.disconnect();for(const D of k)u.current.has(D)||(z.unobserve(D.host),D.slot.parentElement&&z.unobserve(D.slot.parentElement),k.delete(D));for(const D of u.current){const Q=D.slot.closest("[data-sidebar-virtual-start]");Q&&O.observe(Q,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),k.has(D)||(z.observe(D.host),D.slot.parentElement&&z.observe(D.slot.parentElement),k.add(D))}cancelAnimationFrame(j),j=requestAnimationFrame(T)};return f.current=W,S.addEventListener("scroll",E,{passive:!0}),W(),T(),()=>{f.current=null,cancelAnimationFrame(j),S.removeEventListener("scroll",E),z.disconnect(),O.disconnect(),R(),x.hidden=!0,p&&(B(p,p.slot),p.slot.style.removeProperty("height")),x.remove()}},e[2]=o,e[3]=a,e[4]=g):g=e[4];let b;e[5]!==l||e[6]!==o||e[7]!==a?(b=[a,l,o],e[5]=l,e[6]=o,e[7]=a,e[8]=b):b=e[8],c.useLayoutEffect(g,b);let v;return e[9]!==i?(v=n.jsx(Yh.Provider,{value:m,children:i}),e[9]=i,e[10]=v):v=e[10],v}function $3(t){return t.removeAttribute("id")}function z3(t){const e=He.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 o=c.useRef(null),[i]=c.useState(W3);let a,l;e[3]!==i||e[4]!==r?(a=()=>{const m=o.current;if(!m)return;m.append(i);const g=r({slot:m,host:i});return()=>{g(),i.remove()}},l=[i,r],e[3]=i,e[4]=r,e[5]=a,e[6]=l):(a=e[5],l=e[6]),c.useLayoutEffect(a,l);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{ref:o}),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]!==i||e[11]!==u?(f=ga.createPortal(u,i),e[10]=i,e[11]=u,e[12]=f):f=e[12];let h;return e[13]!==f?(h=n.jsxs(n.Fragment,{children:[d,f]}),e[13]=f,e[14]=h):h=e[14],h}function W3(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function Xh(t){const e=He.c(3),s=c.useContext(Yh);let r;return e[0]!==t||e[1]!==s?(r=s?n.jsx(z3,{...t,register:s}):n.jsx("div",{...t}),e[0]=t,e[1]=s,e[2]=r):r=e[2],r}const K3=t=>{const e=He.c(3),[s,r]=c.useState(!1);let o,i;return e[0]!==t?(o=()=>{if(!t){r(!1);return}let a=!0;const l=()=>{co.getDirectoryAvailability(t).then(d=>{a&&d!=="unknown"&&r(d==="missing")})};return l(),window.addEventListener("focus",l),()=>{a=!1,window.removeEventListener("focus",l)}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),c.useEffect(o,i),s},Ci=t=>{const e=He.c(27),{id:s,projectLabel:r,projectIcon:o,projectColor:i,projectIconImage:a,projectIconBackground:l,isCollapsed:d,alwaysShowActions:u,labelClassName:f}=t,h=u===void 0?!1:u,{currentTheme:m}=Cr(),g=o?ja[o]:null;let b;e[0]!==i?(b=Ca(i),e[0]=i,e[1]=b):b=e[1];const v=b,S=d!==void 0,x=S?h?"hidden":"transition-opacity group-hover/project:opacity-0 group-focus-within/project:opacity-0":void 0;let p;e[2]!==h||e[3]!==S||e[4]!==d?(p=S?n.jsx("span",{className:ve("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"absolute inset-0 inline-flex opacity-0 transition-opacity group-hover/project:opacity-100 group-focus-within/project:opacity-100"),children:n.jsx(Z,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[2]=h,e[3]=S,e[4]=d,e[5]=p):p=e[5];let y;e[6]!==h||e[7]!==m||e[8]!==S||e[9]!==v||e[10]!==x||e[11]!==s||e[12]!==l||e[13]!==a||e[14]!==g?(y=a?n.jsx("span",{className:ve("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",S&&h?"hidden":"inline-flex",x),style:l?{backgroundColor:l}:void 0,children:n.jsx(Pa,{project:{id:s,iconImage:a},options:{themeVariant:m.metadata.variant,iconColor:m.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?n.jsx(Z,{name:g,className:"h-3.5 w-3.5",style:v?{color:v}:void 0}):n.jsx(Z,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:v?{color:v}:void 0})})}):g?n.jsx(Z,{name:g,className:ve("h-3.5 w-3.5",x),style:v?{color:v}:void 0}):n.jsx(Z,{name:"folder",className:ve("h-3.5 w-3.5 text-muted-foreground/80",x),style:v?{color:v}:void 0}),e[6]=h,e[7]=m,e[8]=S,e[9]=v,e[10]=x,e[11]=s,e[12]=l,e[13]=a,e[14]=g,e[15]=y):y=e[15];let w;e[16]!==p||e[17]!==y?(w=n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[p,y]}),e[16]=p,e[17]=y,e[18]=w):w=e[18];let j;e[19]!==f?(j=ve("truncate typography-ui-header font-semibold text-foreground",f),e[19]=f,e[20]=j):j=e[20];let k;e[21]!==r||e[22]!==j?(k=n.jsx("span",{className:j,children:r}),e[21]=r,e[22]=j,e[23]=k):k=e[23];let P;return e[24]!==w||e[25]!==k?(P=n.jsxs(n.Fragment,{children:[w,k]}),e[24]=w,e[25]=k,e[26]=P):P=e[26],P},H3=t=>{const e=He.c(67),{id:s,disabled:r,projectLabel:o,projectDescription:i,projectDirectory:a,projectIcon:l,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:h,isRepo:m,hideDirectoryControls:g,alwaysShowActions:b,onToggle:v,onNewSession:S,onNewWorktreeSession:x,onManageWorktrees:p,onManageSpaces:y,onOpenFolder:w,onRenameStart:j,onArchiveAll:k,onClose:P,children:A,showCreateButtons:B,hideHeader:R,statusIndicator:E,openSidebarMenuKey:T,setOpenSidebarMenuKey:z,projectPickerOptions:O,onProjectSelect:W}=t,D=r===void 0?!1:r,Q=B===void 0?!0:B,N=R===void 0?!1:R,C=E===void 0?null:E,{t:I}=wt(),H=K3(a);let M;e[0]!==D||e[1]!==s?(M={id:s,disabled:D},e[0]=D,e[1]=s,e[2]=M):M=e[2];const{attributes:_,listeners:F,setNodeRef:ee,transform:ne,transition:re,isDragging:te}=Ho(M),K=c.useRef(!1),q=`project:${s}`,oe=T===q,[fe,ce]=c.useState(!1),ke=!!(O&&W);let De;e[3]!==q||e[4]!==z?(De=Be=>{Be&&ce(!1),z(Be?q:null)},e[3]=q,e[4]=z,e[5]=De):De=e[5];const Ce=De;let Y;e[6]!==g||e[7]!==m||e[8]!==k||e[9]!==P||e[10]!==y||e[11]!==p||e[12]!==S||e[13]!==w||e[14]!==j||e[15]!==Q||e[16]!==I?(Y=Be=>n.jsxs(n.Fragment,{children:[Q&&!m&&!g&&S&&n.jsxs(Be,{onClick:S,children:[n.jsx(Z,{name:"add",className:"me-1.5 h-4 w-4"}),I("sessions.sidebar.project.actions.newSession")]}),m&&!g&&p&&n.jsxs(Be,{onClick:p,children:[n.jsx(Z,{name:"node-tree",className:"me-1.5 h-4 w-4"}),I("sessions.sidebar.project.actions.manageWorktrees")]}),m&&!g&&y&&n.jsxs(Be,{onClick:y,children:[n.jsx(Z,{name:"box-3",className:"me-1.5 h-4 w-4"}),I("spaces.page.menuItem")]}),w&&n.jsxs(Be,{onClick:w,children:[n.jsx(Z,{name:"folder-received",className:"me-1.5 h-4 w-4"}),I(Gu())]}),n.jsxs(Be,{onClick:j,children:[n.jsx(Z,{name:"pencil-ai",className:"me-1.5 h-4 w-4"}),I("sessions.sidebar.project.actions.edit")]}),k&&n.jsxs(Be,{onClick:k,children:[n.jsx(Z,{name:"archive",className:"me-1.5 h-4 w-4"}),I("sessions.sidebar.project.actions.archiveAll")]}),n.jsxs(Be,{onClick:P,className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1.5 h-4 w-4"}),I("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=g,e[7]=m,e[8]=k,e[9]=P,e[10]=y,e[11]=p,e[12]=S,e[13]=w,e[14]=j,e[15]=Q,e[16]=I,e[17]=Y):Y=e[17];const je=Y,we=U3,Pe=q3,L=Y3;let ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=Be=>{(Be.button===2||Be.button===0&&Be.ctrlKey)&&(K.current=!0)},e[18]=ie):ie=e[18];const G=ie;let ae;e[19]!==v?(ae=Be=>{if(Be.currentTarget.blur(),K.current){K.current=!1;return}v()},e[19]=v,e[20]=ae):ae=e[20];const ge=ae,be=(Q&&m&&!g&&!!x?1:0)+(g?0:1),ye=be===2?"[--oc-actions-reserve:66px]":be===1&&Q?"[--oc-actions-reserve:38px]":Q||be===1?"[--oc-actions-reserve:12px]":void 0,Te=b?void 0:oe?"oc-actions-mask":"group-hover/project:oc-actions-mask group-focus-within/project:oc-actions-mask",$=b?void 0:oe?"opacity-0":"transition-opacity group-hover/project:opacity-0 group-focus-within/project:opacity-0";let he;e[21]!==ne?(he=Vo.Transform.toString(ne),e[21]=ne,e[22]=he):he=e[22];let se;e[23]!==he||e[24]!==re?(se={transform:he,transition:re},e[23]=he,e[24]=re,e[25]=se):se=e[25];const Ne=te&&"opacity-30";let Ue;e[26]!==Ne?(Ue=ve("relative",Ne),e[26]=Ne,e[27]=Ue):Ue=e[27];let We;e[28]!==b||e[29]!==_||e[30]!==H||e[31]!==Ce||e[32]!==ge||e[33]!==ye||e[34]!==$||e[35]!==Te||e[36]!==g||e[37]!==N||e[38]!==s||e[39]!==h||e[40]!==fe||e[41]!==oe||e[42]!==ke||e[43]!==m||e[44]!==F||e[45]!==S||e[46]!==x||e[47]!==W||e[48]!==d||e[49]!==i||e[50]!==a||e[51]!==l||e[52]!==f||e[53]!==u||e[54]!==o||e[55]!==O||e[56]!==je||e[57]!==Q||e[58]!==C||e[59]!==I?(We=N?null:n.jsx(n.Fragment,{children:n.jsxs(_a,{open:fe,onOpenChange:ce,children:[n.jsx(La,{render:n.jsx(Xh,{className:ve("-ms-2.5 -me-2 text-start group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:Be=>{g||(Be.preventDefault(),ce(!0))}}),children:n.jsxs("div",{className:"relative flex items-center gap-1 py-1 ps-4 pe-3.5",..._,children:[ke?n.jsxs(js,{children:[n.jsx(Cs,{asChild:!0,children:n.jsxs("button",{type:"button",className:ve("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",m&&!g?b||oe?"pe-20":"pe-0 group-hover/project:pe-20 group-focus-within/project:pe-20":b||oe?"pe-14":"pe-0 group-hover/project:pe-14 group-focus-within/project:pe-14"),"aria-label":I("sessions.sidebar.project.selectAria",{project:o}),children:[n.jsx(Ci,{id:s,projectLabel:o,projectIcon:l,projectColor:d,projectIconImage:u,projectIconBackground:f}),n.jsx(Z,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),a?n.jsx(ko,{directory:a,className:"ms-auto"}):null]})}),n.jsx(Ps,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:O?.map(Be=>n.jsxs(qt,{onClick:()=>W?.(Be.id),className:"flex items-center justify-between gap-3",title:Be.projectDescription,children:[n.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:n.jsx(Ci,{...Be})}),Be.id===s?n.jsx(Z,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},Be.id))})]}):n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsxs("button",{type:"button",onMouseDown:G,onClick:ge,...F,className:ve("@container flex-1 min-w-0 flex items-center gap-1.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing",b?m&&!g?"pe-20":"pe-14":ye),children:[n.jsx(Ci,{id:s,projectLabel:o,projectIcon:l,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:h,alwaysShowActions:b,labelClassName:ve("[--oc-actions-inset:20px]",Te)}),H?n.jsx("span",{className:ve("inline-flex flex-shrink-0 items-center text-status-warning",$),title:I("sessions.sidebar.project.folderMissing"),"aria-label":I("sessions.sidebar.project.folderMissing"),children:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,C?n.jsx("span",{className:ve("ms-1 inline-flex flex-shrink-0 items-center",$),children:C}):null,a?n.jsx(ko,{directory:a,className:ve("ms-auto",$)}):null]})}),n.jsx(Tt,{side:"right",sideOffset:8,children:i})]}),n.jsxs("div",{className:ve("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",Q?"inset-e-7":"inset-e-0.5"),children:[Q&&m&&!g&&x?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Be=>{Be.stopPropagation(),x()},className:ve("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",b?"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":I("sessions.sidebar.project.actions.newWorktree"),children:n.jsx(Z,{name:"node-tree",className:"h-3.5 w-3.5"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:I("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,g?null:n.jsxs(js,{open:oe,onOpenChange:Ce,children:[n.jsx(Cs,{asChild:!0,children:n.jsx("button",{type:"button",className:ve("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",oe?"opacity-100 pointer-events-auto":b?"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":I("sessions.sidebar.project.actions.projectMenu"),onPointerDown:Pe,onMouseDown:L,onClick:we,children:n.jsx(Z,{name:"more-2",className:"h-3 w-3"})})}),n.jsx(Ps,{align:"end",className:"min-w-[180px]",children:je(qt)})]})]}),Q&&S?n.jsx("div",{className:"absolute inset-e-0.5 top-1/2 z-10 -translate-y-1/2",children:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Be=>{Be.stopPropagation(),S()},className:ve("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",b?"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":I(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:I(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),n.jsx(Fa,{className:"min-w-[180px]",children:je(Dn)})]})}),e[28]=b,e[29]=_,e[30]=H,e[31]=Ce,e[32]=ge,e[33]=ye,e[34]=$,e[35]=Te,e[36]=g,e[37]=N,e[38]=s,e[39]=h,e[40]=fe,e[41]=oe,e[42]=ke,e[43]=m,e[44]=F,e[45]=S,e[46]=x,e[47]=W,e[48]=d,e[49]=i,e[50]=a,e[51]=l,e[52]=f,e[53]=u,e[54]=o,e[55]=O,e[56]=je,e[57]=Q,e[58]=C,e[59]=I,e[60]=We):We=e[60];let Ke;return e[61]!==A||e[62]!==ee||e[63]!==se||e[64]!==Ue||e[65]!==We?(Ke=n.jsxs("div",{ref:ee,style:se,className:Ue,children:[We,A]}),e[61]=A,e[62]=ee,e[63]=se,e[64]=Ue,e[65]=We,e[66]=Ke):Ke=e[66],Ke},V3=t=>{const e=He.c(21),{id:s,disabled:r,children:o}=t,i=r===void 0?!1:r;let a;e[0]!==i||e[1]!==s?(a={id:s,disabled:i},e[0]=i,e[1]=s,e[2]=a):a=e[2];const{listeners:l,setNodeRef:d,setActivatorNodeRef:u,transform:f,transition:h,isDragging:m}=Ho(a);let g;e[3]!==l||e[4]!==u?(g={listeners:l,setActivatorNodeRef:u},e[3]=l,e[4]=u,e[5]=g):g=e[5];const b=g;let v;e[6]!==f?(v=Vo.Transform.toString(f),e[6]=f,e[7]=v):v=e[7];let S;e[8]!==v||e[9]!==h?(S={transform:v,transition:h},e[8]=v,e[9]=h,e[10]=S):S=e[10];const x=m&&"opacity-50";let p;e[11]!==x?(p=ve("space-y-0.5 rounded-md",x),e[11]=x,e[12]=p):p=e[12];let y;e[13]!==o||e[14]!==b?(y=o(b),e[13]=o,e[14]=b,e[15]=y):y=e[15];let w;return e[16]!==d||e[17]!==S||e[18]!==p||e[19]!==y?(w=n.jsx("div",{ref:d,style:S,className:p,children:y}),e[16]=d,e[17]=S,e[18]=p,e[19]=y,e[20]=w):w=e[20],w},G3=c.memo(V3);function U3(t){t.stopPropagation()}function q3(t){t.stopPropagation()}function Y3(t){t.stopPropagation()}const kd=[],X3=t=>{const e=He.c(6),{nodes:s,includeUnreadSubtasks:r,children:o}=t;let i;e[0]!==r||e[1]!==s?(i={nodes:s,includeUnreadSubtasks:r},e[0]=r,e[1]=s,e[2]=i):i=e[2];const a=lu(i);let l;return e[3]!==o||e[4]!==a?(l=o(a),e[3]=o,e[4]=a,e[5]=l):l=e[5],l},Pi=(t,e)=>e?t.sessions.some(s=>Jn(s,e)):!1,Q3=(t,e,s)=>t.sessions.some(r=>Nh(r,r,e,s,t.directory,t.directory)),Z3=(t,e,s)=>{const r=o=>{const i=o.session.id;return e.get(i)!==s.get(i)?!0:o.children.some(r)};return t.sessions.some(r)},J3=(t,e,s)=>{const r=t.isArchivedBucket?"archived":"active",o=i=>{const a=`project:${r}:${i.session.id}`;return e.has(a)!==s.has(a)?!0:i.children.some(o)};return t.sessions.some(o)},e4=(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&&Q3(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&Z3(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&J3(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Pi(e.group,t.editingId)||Pi(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Pi(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const s=e.group.isArchivedBucket===!0,r=wo(e.group.sessions,t.openSidebarMenuKey,"project",s),o=wo(e.group.sessions,e.openSidebarMenuKey,"project",s);if(r||o)return!1}if(t.folderRename!==e.folderRename){const s=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??ot(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},t4=c.memo(function(e){const s=He.c(23),{label:r,sessions:o,worktree:i}=e,{t:a}=wt(),l=Hh();let d;s[0]!==o||s[1]!==l||s[2]!==i?(d=x=>{x.stopPropagation(),xn.requestDelete({sessions:o,mode:"worktree",worktree:i,skipDialogIfSafe:l||x.shiftKey})},s[0]=o,s[1]=l,s[2]=i,s[3]=d):d=s[3];const u=l?"text-destructive":"text-muted-foreground";let f;s[4]!==u?(f=ve("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 h;s[6]!==r||s[7]!==l||s[8]!==a?(h=l?a("sessions.sidebar.group.actions.deleteGroupAndBranchAria",{label:r}):a("sessions.sidebar.group.actions.deleteGroupAria",{label:r}),s[6]=r,s[7]=l,s[8]=a,s[9]=h):h=s[9];let m;s[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Z,{name:"delete-bin",className:"h-3.5 w-3.5"}),s[10]=m):m=s[10];let g;s[11]!==d||s[12]!==f||s[13]!==h?(g=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,className:f,"aria-label":h,children:m})}),s[11]=d,s[12]=f,s[13]=h,s[14]=g):g=s[14];let b;s[15]!==l||s[16]!==a?(b=a(l?"sessions.sidebar.group.actions.deleteWorktreeAndBranch":"sessions.sidebar.group.actions.deleteWorktree"),s[15]=l,s[16]=a,s[17]=b):b=s[17];let v;s[18]!==b?(v=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b})}),s[18]=b,s[19]=v):v=s[19];let S;return s[20]!==g||s[21]!==v?(S=n.jsxs(Ot,{children:[g,v]}),s[20]=g,s[21]=v,s[22]=S):S=s[22],S}),jd=[];function s4(t){const{t:e}=wt(),s=Wa(),r=xm(t.group.space?.id),{group:o,groupKey:i,projectId:a,hideGroupLabel:l,renderBody:d=!0,isEmpty:u=!1,hasSessionSearchQuery:f,normalizedSessionSearchQuery:h,groupSearchDataByGroup:m,visibleSessionCount:g,sessionBatchSize:b,collapsedGroups:v,hideDirectoryControls:S,showMoreGroupSessions:x,resetGroupSessionLimit:p,mobileVariant:y,alwaysShowActions:w,activeProjectId:j,setActiveProjectIdOnly:k,setSessionSwitcherOpen:P,openNewSessionDraft:A,pinnedSessionIds:B,sessionOrderIndex:R,notifyOnSubtasks:E,onToggleCollapsedGroup:T,dragHandleProps:z,compactBodyPadding:O=!1,expandedParents:W,editingId:D,editingRowKey:Q,openSidebarMenuKey:N,editTitle:C,folderRename:I,setFolderRenameDraft:H,clearFolderRename:M}=t,_=Xt(Se=>Se.toggleFolderCollapse),F=Xt(Se=>Se.renameFolder),ee=Xt(Se=>Se.deleteFolder),ne=Xt(Se=>Se.addSessionToFolder),re=de(Se=>Se.showDeletionDialog),[te,K]=c.useState(null),q=c.useCallback((Se,V)=>{const Ie=R.get(Se.session.id),Le=R.get(V.session.id);if(Ie!==void 0||Le!==void 0){if(Ie===void 0)return 1;if(Le===void 0)return-1;if(Ie!==Le)return Ie-Le}return $a(Se.session,V.session,B,Yu)},[B,R]),oe=f?m.get(o):null,fe=f?!1:v.has(i),ce=ix(!o.isMain&&o.worktree?o.worktree.path:null),ke=o.isMain||o.isArchivedBucket||l?null:ot(o.directory??null),De=o.isMain||o.isArchivedBucket||l?null:o.branch?.trim()||null,Ce=af(ke,De),Y=Ce?`var(--pr-${Ce.visualState})`:void 0,je=df(Ce,e),we=Ce?Ta(Ce.provider,Ce.number):"",Pe=Ce?je?`${we} · ${je}`:we:void 0,L=Er(),ie=c.useMemo(()=>{const Se=o.folderScopes?.map(V=>ot(V.directory))??[ot(o.directory??null)];return[...new Set(Se.filter(V=>!!V))]},[o.directory,o.folderScopes]);c.useSyncExternalStore(c.useCallback(Se=>ie.length>0?L.subscribeBootstrap(Se):()=>{},[ie.length,L]),c.useCallback(()=>ie.map(Se=>`${Se}\0${L.getBootstrapState(Se)??""}\0${L.getBootstrapFailure(Se)??""}\0${L.getInitializationState(Se)??""}\0${L.getInitializationFailure(Se)??""}`).join(""),[ie,L]),c.useCallback(()=>"",[]));const G=ie.some(Se=>{const V=L.getBootstrapState(Se);return V==="queued"||V==="running"}),ae=ie.find(Se=>L.getBootstrapState(Se)==="failed"||L.getInitializationState(Se)==="failed")??null,ge=ae!==null&&L.getBootstrapState(ae)==="failed",me=ae?ge?L.getBootstrapFailure(ae):L.getInitializationFailure(ae):void 0,be=me==="os-permission"&&Zd(),[ye,Te]=c.useState(!1),$=c.useCallback(()=>{ae&&L.requestBootstrap({directory:ae,priority:fe?"visible":"expanded",reason:o.isMain?"project-expanded":"worktree-expanded",force:!0})},[L,ae,o.isMain,fe]),he=c.useCallback(async()=>{if(!(!ae||!be||ye)){Te(!0);try{(await Jd(ae)).success&&$()}finally{Te(!1)}}},[be,ae,ye,$]),se=b??(S?10:7),Ne=Math.max(se,g??se),Ue=f?oe?.groupMatches===!0:!1,We=f,Ke=c.useMemo(()=>[...We?oe?.filteredNodes??[]:o.sessions].sort(q),[q,o.sessions,oe?.filteredNodes,We]),Be=o.folderScopeKey??ot(o.directory??null),U=Gn(a,o.directory),Me=c.useMemo(()=>o.folderScopes&&o.folderScopes.length>0?o.folderScopes:Be?[{scopeKey:Be,directory:o.directory??null}]:[],[Be,o.directory,o.folderScopes]),Ge=Xt(Zn(c.useCallback(Se=>Me.map(({scopeKey:V})=>Se.foldersMap[V]??kd),[Me]))),Ve=c.useMemo(()=>Me.flatMap(({scopeKey:Se,directory:V},Ie)=>(Ge[Ie]??kd).map(Qe=>({folder:Qe,scopeKey:Se,scopeDirectory:V}))),[Ge,Me]),dt=Xt(Zn(c.useCallback(Se=>new Set(Ge.flatMap(V=>V.filter(Ie=>Se.collapsedFolderIds.has(Ie.id)).map(Ie=>Ie.id))),[Ge]))),et=c.useMemo(()=>{const Se=new Map,V=Ie=>{Ie.forEach(Le=>{Se.set(Le.session.id,Le),Le.children.length>0&&V(Le.children)})};return V(Ke),Se},[Ke]),ct=c.useMemo(()=>Ve.map(({folder:Se,scopeKey:V,scopeDirectory:Ie})=>{const Le=la(Se.sessionIds,et).sort(q);return{folder:Se,scopeKey:V,scopeDirectory:Ie,nodes:Le}}),[Ve,et,q]),pe=c.useMemo(()=>{const Se=Eh(ct.map(({folder:V,nodes:Ie})=>({id:V.id,name:V.name,parentId:V.parentId,nodeCount:Ie.length})),{archivedBucket:o.isArchivedBucket===!0,searchQuery:f?h:""});return ct.filter(({folder:V})=>Se.has(V.id))},[ct,o.isArchivedBucket,f,h]),Ee=D,qe=N,Ye=c.useMemo(()=>new Set(pe.flatMap(Se=>Se.folder.sessionIds)),[pe]),$e=c.useMemo(()=>Ke.filter(Se=>!Ye.has(Se.session.id)),[Ke,Ye]),tt=c.useMemo(()=>{const Se=new Map(pe.map(V=>[V.folder.id,V]));return Ph(pe.map(V=>V.folder)).map(V=>Se.get(V.id)).filter(V=>!!V)},[pe]),ht=c.useMemo(()=>{const Se=new Map;return pe.forEach(V=>{if(!V.folder.parentId)return;const Ie=Se.get(V.folder.parentId)??[];Ie.push(V),Se.set(V.folder.parentId,Ie)}),Se},[pe]),vt=c.useMemo(()=>{const Se=new Map(pe.map(Le=>[Le.folder.id,Le])),V=new Map,Ie=(Le,Qe)=>{const yt=V.get(Le);if(yt!==void 0)return yt;if(Qe.has(Le))return[];Qe.add(Le);const Rt=Se.get(Le),zt=Rt?[...Rt.nodes]:[];for(const Jt of ht.get(Le)??[])zt.push(...Ie(Jt.folder.id,Qe));return V.set(Le,zt),zt};return pe.forEach(({folder:Le})=>Ie(Le.id,new Set)),V},[pe,ht]),Bt="project",kt=c.useMemo(()=>{const Se=new Set;return qc(Ke,Ee,Se),pe.forEach(({nodes:V})=>{qc(V,Ee,Se)}),Se},[Ke,pe,Ee]),St=c.useMemo(()=>{if(!qe)return null;const Se=wo(Ke,qe,Bt,!!o.isArchivedBucket);if(Se)return Se;for(const{nodes:V}of pe){const Ie=wo(V,qe,Bt,!!o.isArchivedBucket);if(Ie)return Ie}return null},[qe,Ke,pe,o.isArchivedBucket]),xt=c.useCallback(Se=>{const V=new WeakMap,Ie=Le=>{V.set(Le,kr(Le));for(const Qe of Le.children)Ie(Qe)};return Se.forEach(Ie),V},[]),Mt=c.useMemo(()=>xt(Ke),[xt,Ke]),jt=c.useMemo(()=>{const Se=new WeakMap;return pe.forEach(({nodes:V})=>{V.forEach(Ie=>Se.set(Ie,kr(Ie)))}),Se},[pe]),$t=c.useCallback(Se=>Mt.get(Se)??jt.get(Se)??"",[Mt,jt]),Wt=c.useCallback(Se=>({subtreeContainsEditing:kt,menuOpenSessionId:St,nodeStructureKey:$t(Se)}),[kt,St,$t]),Kt=$e.length,rt=o.isArchivedBucket||f?$e:$e.slice(0,Ne),ut=Kt-rt.length,pt=!o.isArchivedBucket&&!f&&Kt>se&&ut===0,ue=c.useCallback(Se=>{const V=[],Ie=Le=>{Le.forEach(Qe=>{V.push(Qe.session),Qe.children.length>0&&Ie(Qe.children)})};return Ie(Se),V},[]),lt=c.useMemo(()=>ue(Ke),[ue,Ke]),ft=c.useMemo(()=>{if(Ce||o.isMain||o.isArchivedBucket||l)return jd;const Se=new Map;for(const V of lt)for(const Ie of Ka(V))Se.has(Ie.key)||Se.set(Ie.key,Ie);return Se.size>0?[...Se.values()]:jd},[lt,o.isArchivedBucket,o.isMain,Ce,l]),mt=c.useMemo(()=>ft.flatMap(Se=>Se.source==="github"?[xr("issue",Se)]:[]),[ft]),It=mo(mt),xe=c.useMemo(()=>ft.flatMap(Se=>Se.source==="linear"?[Ha(Se.identifier)]:[]),[ft]),it=cf(xe),X=c.useMemo(()=>ft.flatMap(Se=>Se.source==="gitlab"?[Sr("issue",Se.ref)]:[]),[ft]),le=mo(X),Xe=c.useMemo(()=>uf(ft,It,it,le).map(Se=>({...Se,text:Se.statusKey?`${Se.label} · ${e(Se.statusKey)}`:Se.statusText?`${Se.label} · ${Se.statusText}`:Se.label})),[le,It,ft,it,e]),Ae=Xe[0]??null,Je=c.useMemo(()=>{if(!o.isArchivedBucket)return new Map;const Se=new Map,V=new Map;for(const{folder:Le}of pe){if(!Le.parentId)continue;const Qe=V.get(Le.parentId)??[];Qe.push(Le.id),V.set(Le.parentId,Qe)}const Ie=(Le,Qe)=>{if(Qe.has(Le))return[];Qe.add(Le);const yt=pe.find(({folder:Jt})=>Jt.id===Le),Rt=yt?ue(yt.nodes):[],zt=V.get(Le)??[];for(const Jt of zt)Rt.push(...Ie(Jt,Qe));return Rt};for(const{folder:Le}of pe)Se.set(Le.id,Ie(Le.id,new Set));return Se},[pe,ue,o.isArchivedBucket]);if(f&&!Ue&&tt.length===0&&$e.length===0)return null;const Fe=!o.isMain&&!!o.branch,gt=o.branch&&ax(o.branch,o.label)?{label:o.branch}:null,bt=fe?n.jsx(du,{nodes:Ke,includeUnreadSubtasks:E}):null,Et=(Se,V)=>{const{folder:Ie,scopeKey:Le,scopeDirectory:Qe,nodes:yt}=Se,Rt=Je.get(Ie.id)??[],zt=I?.folderId===Ie.id&&I?.scopeKey===Le,Jt=f?!1:dt.has(Ie.id),Rs=ys=>n.jsx(Lh,{folderId:Ie.id,scopeKey:Le,ownerKey:U,children:(Ds,Ks)=>n.jsx(Fh,{folder:Ie,displayName:V,sessions:yt,isCollapsed:Jt,collapsedActivityState:ys,onToggle:()=>_(Ie.id),onRename:is=>{F(Le,Ie.id,is)},onDelete:()=>{if(o.isArchivedBucket){xn.requestDelete({sessions:Rt,mode:"session"});return}if(!re){ee(Le,Ie.id);return}const is=pe.filter(({folder:Rr})=>Rr.parentId===Ie.id).length,Xo=yt.length;K({scopeKey:Le,folderId:Ie.id,folderName:Ie.name,subFolderCount:is,sessionCount:Xo})},groupDirectory:Qe??o.directory,projectId:a,mobileVariant:y,alwaysShowActions:w,isRenaming:zt,renameDraft:zt?I?.draft:void 0,onRenameDraftChange:H,onRenameSave:()=>{const is=I?.draft.trim()??"";is&&F(Le,Ie.id,is),M()},onRenameCancel:M,droppableRef:Ds,isDropTarget:Ks,depth:0,onNewSession:()=>{a&&a!==j&&k(a),y&&P(!1),A({selectedProjectId:a,directoryOverride:Qe??o.directory,targetFolderId:Ie.id,target:o.draftTarget})},hideActions:!1,archivedBucket:o.isArchivedBucket===!0,children:yt.map(is=>n.jsx(Po,{node:is,pinnedSessionIds:B,expandedParents:W,hasSessionSearchQuery:f,normalizedSessionSearchQuery:h,notifyOnSubtasks:E,editingId:D,editingRowKey:Q,editTitle:C,openSidebarMenuKey:N,mobileVariant:y,alwaysShowActions:w,groupDirectory:Qe??o.directory,projectId:a,folderOwnerKey:U,selectionScopeKey:U,archivedBucket:o.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:kt,menuOpenSessionId:St,nodeStructureKey:$t(is),childRenderExtrasFor:Wt},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},is.session.id))})},Ie.id);return Jt?n.jsx(X3,{nodes:vt.get(Ie.id)??yt,includeUnreadSubtasks:E,children:Rs},Ie.id):Rs(null)},Ft=()=>{const Se=new Map;for(const Qe of pe){const yt=Qe.folder.parentId;if(!yt)continue;const Rt=Se.get(yt);Rt?Rt.push(Qe):Se.set(yt,[Qe])}const V=[],Ie=new Set,Le=(Qe,yt)=>{if(Ie.has(Qe.folder.id))return;Ie.add(Qe.folder.id);const Rt=yt?`${yt} / ${Qe.folder.name}`:Qe.folder.name;V.push(Et(Qe,Rt)),!(!f&&dt.has(Qe.folder.id))&&(Se.get(Qe.folder.id)??[]).forEach(Jt=>Le(Jt,Rt))};return tt.forEach(Qe=>Le(Qe,"")),V},es=!!(!o.isMain&&o.worktree&&!ce),Re=o.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(Z,{name:"alert",className:"h-3 w-3"})}):null,Ze=o.space&&o.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(Z,{name:"alert",className:"h-3 w-3"})}):null,at=es||!!o.space,_t=!!o.space,Vt=w?_t?"pe-20":at?"pe-14":"pe-7":ve("pe-2",_t?"[--oc-actions-reserve:68px]":at?"[--oc-actions-reserve:44px]":"[--oc-actions-reserve:18px]"),Ht=w?void 0:"group-hover/gh:oc-actions-mask group-focus-within/gh:oc-actions-mask",Oe=w?void 0:"transition-opacity group-hover/gh:opacity-0 group-focus-within/gh:opacity-0",ze=u?n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}):n.jsx(jr,{expanded:!fe}),st=Ce&&je?[{key:`pr:${Ce.number}`,icon:"git-pull-request",text:`${we} · ${je}`,title:Ce.title,color:Y,url:Ce.url}]:[],Nt=ae?n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(me==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":ge?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),be?n.jsx(Ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:ye,onClick:()=>{he()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,n.jsx(Ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:$,children:e("sessions.sidebar.group.empty.retry")})]}):null,Dt=Se=>n.jsx(Po,{node:Se,pinnedSessionIds:B,expandedParents:W,hasSessionSearchQuery:f,normalizedSessionSearchQuery:h,notifyOnSubtasks:E,editingId:D,editingRowKey:Q,editTitle:C,openSidebarMenuKey:N,mobileVariant:y,alwaysShowActions:w,groupDirectory:o.directory,projectId:a,folderOwnerKey:U,selectionScopeKey:U,archivedBucket:o.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:kt,menuOpenSessionId:St,nodeStructureKey:$t(Se),childRenderExtrasFor:Wt},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},Se.session.id),ts=n.jsxs(NC,{scopeKey:Me[0]?.scopeKey??Be,ownerKey:U,hasFolders:pe.length>0,onSessionDroppedOnFolder:(Se,V)=>{const Ie=pe.find(({folder:Qe,scopeKey:yt})=>Qe.id===V.folderId&&yt===V.scopeKey);if(!Ie)return;const Le=Xt.getState();for(const{scopeKey:Qe}of Me)Qe!==Ie.scopeKey&&Le.getSessionFolderId(Qe,Se)&&Le.removeSessionFromFolder(Qe,Se);ne(Ie.scopeKey,V.folderId,Se)},children:[Ft(),rt.map(Dt),Kt===0&&pe.length===0&&!r?!o.isArchivedBucket&&!G&&!Nt&&o.directory&&!o.emptyMessage?n.jsx(Ct,{variant:"link",size:"xs",className:"w-full justify-start ps-[26px] text-start font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{a&&a!==j&&k(a),y&&P(!1),A({selectedProjectId:a,directoryOverride:o.directory,target:o.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-muted-foreground",children:o.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):G?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Z,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Nt||(o.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,Kt>0&&Nt?n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-status-error",children:Nt}):null,ut>0?n.jsx("button",{type:"button",onClick:()=>x(i,rt.length,b??7),className:"mt-0.5 flex items-center justify-start rounded-md ps-[26px] pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,pt?n.jsx("button",{type:"button",onClick:()=>p(i),className:"mt-0.5 flex items-center justify-start rounded-md ps-[26px] pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),fs="pb-2",us=n.jsx(qh,{value:te,setValue:K,onConfirm:()=>{const Se=te;Se&&(ee(Se.scopeKey,Se.folderId),K(null))}});return l?d?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"oc-group",children:n.jsx("div",{className:ve("oc-group-body",fs),children:ts})}),us]}):null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:ve("oc-group",ce&&"opacity-60"),"aria-busy":ce||void 0,children:[n.jsxs("div",{className:ve("oc-ref-tint-scope group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md hover:bg-interactive-hover/60","cursor-pointer"),children:[n.jsxs(Ot,{disabled:Ce?!je:!Ae,children:[n.jsx(At,{asChild:!0,closeDelay:Wh,children:n.jsx("div",{className:"min-w-0 flex-1",...u?{}:{onClick:()=>T(i),role:"button",tabIndex:0,onKeyDown:Se=>{(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),T(i))},"aria-label":fe?e("sessions.sidebar.group.expandAria",{label:o.label}):e("sessions.sidebar.group.collapseAria",{label:o.label}),"aria-expanded":!fe},children:n.jsxs("div",{ref:z?.setActivatorNodeRef,style:{paddingInlineStart:tr(0)},className:ve("@container min-w-0 flex flex-1 items-start gap-1 overflow-hidden",Vt),...z?.listeners??{},children:[n.jsxs("div",{className:ve("min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",Ht),children:[n.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:o.isArchivedBucket?n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-0.5",children:[ze,n.jsx(Z,{name:"archive",className:"mx-px h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:Yr(o.label,h)}),Re,bt]}):!o.isMain||o.worktree?n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-0.5",children:[ze,ce?n.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-muted-foreground",title:e("sessions.sidebar.group.worktreeRemoving"),role:"status","aria-label":e("sessions.sidebar.group.worktreeRemoving"),children:n.jsx(Z,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"})}):n.jsx(Z,{name:o.space?"box-3":"git-branch",className:ve("mx-px h-3 w-3 shrink-0",Y?"oc-ref-tint":"text-muted-foreground"),style:Y?Kn(Y):void 0,"aria-label":o.space?e("sessions.sidebar.group.space"):void 0}),n.jsx("span",{className:"min-w-0 truncate typography-ui-label font-medium text-foreground",children:Yr(o.label,h)}),Re,Ze,bt,Ce?n.jsx("button",{type:"button",className:ve("ms-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",Y&&"oc-ref-tint",Oe),style:Y?Kn(Y):void 0,disabled:!Ce.url,"aria-label":Pe,onPointerDown:Se=>Se.stopPropagation(),onKeyDown:Se=>Se.stopPropagation(),onClick:Se=>{Se.stopPropagation(),Ce.url&&s(Ce.url,o.directory??null,Se)},children:we}):Ae?n.jsxs("button",{type:"button",className:ve("ms-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",Ae.color?"oc-ref-tint":"text-muted-foreground",Oe),style:Ae.color?Kn(Ae.color):void 0,"aria-label":Xe.map(Se=>Se.text).join(", "),onPointerDown:Se=>Se.stopPropagation(),onKeyDown:Se=>Se.stopPropagation(),onClick:Se=>{Se.stopPropagation(),!(Se.target instanceof Element&&Se.target.closest("[data-ref-more]"))&&s(Ae.url,o.directory??null,Se)},children:[n.jsx(Z,{name:Ae.icon,className:"h-3 w-3"}),Ae.label,Xe.length>1?n.jsxs("span",{"data-ref-more":!0,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:[ze,n.jsx("span",{className:"min-w-0 truncate",children:Yr(o.label,h)}),bt]})}),Fe&>?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[o.isArchivedBucket?n.jsx(Z,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):n.jsx(Z,{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:gt.label})]}):null]}),!o.isArchivedBucket&&o.directory?n.jsx(ko,{directory:o.directory,className:ve("self-center",Oe)}):null]})})}),st.length>0?n.jsx(Tt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(jo,{items:st,directory:o.directory??null})}):!Ce&&Ae?n.jsx(Tt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(jo,{items:Xe,directory:o.directory??null})}):null]}),n.jsxs(Lo,{delayDuration:400,children:[o.isArchivedBucket&<.length>0?n.jsx("div",{className:ve("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),xn.requestDelete({sessions:lt,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:o.label}),children:n.jsx(Z,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,o.directory&&!o.isMain&&o.worktree&&!ce?n.jsx("div",{className:ve("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsx(t4,{label:o.label,sessions:lt,worktree:o.worktree})}):null,o.space?n.jsx("div",{className:ve("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),o.space&&_s.getState().openAccessDialog(o.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:o.label}),children:n.jsx(Z,{name:"key",className:"h-3.5 w-3.5"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,o.space?n.jsx("div",{className:ve("absolute inset-e-[3.25rem] top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100 has-[[data-popup-open]]:opacity-100"),children:n.jsx(Ng,{spaceId:o.space.id,label:o.label})}):null,o.directory?n.jsx("div",{className:ve("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),a&&a!==j&&k(a),y&&P(!1),A({selectedProjectId:a,directoryOverride:o.directory,preserveDirectoryOverride:!!o.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:o.label}),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]})]}),o.space?n.jsx(Ig,{spaceId:o.space.id,className:"pb-1 ps-5"}):null,!fe&&d?n.jsx("div",{className:ve("oc-group-body",fs),children:ts}):null]}),us]})}const n4=c.memo(s4,e4),Ei=({projectId:t,mobileVariant:e,closeMobileSwitcher:s,setActiveProjectIdOnly:r,setSessionSwitcherOpen:o})=>{t&&r(t),e&&s&&o(!1)},r4=(t,e)=>{const s=new Set;for(const r of t)if(!r.isArchivedBucket)for(const o of r.sessions){const{session:i}=o;i.time?.archived||e(i)||s.add(i.id)}return[...s]},Cd=10,Pd=(t,e)=>of(t.label?.trim()||Ao(t.normalizedPath,e)||t.normalizedPath);function o4(t){const e=He.c(103),{model:s,view:r,actions:o}=t;Ss("ui.sidebar_projects_list.render");const{t:i}=wt(),a=Er(),{files:l}=Ws(),d=Xt(g4),u=Xt(m4),f=Xt(p4),h=Xt(h4),m=de(f4),g=de(u4)&&!Sn(),[b,v]=c.useState(null),[S,x]=c.useState(null),[p,y]=c.useState(null),[w,j]=c.useState(null),[k,P]=c.useState(null),A=k?.kind==="project",B=c.useRef(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={activationConstraint:{distance:8}},e[0]=R):R=e[0];let E;e[1]===Symbol.for("react.memo_cache_sentinel")?(E={activationConstraint:{delay:200,tolerance:6}},e[1]=E):E=e[1];let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T={coordinateGetter:v1},e[2]=T):T=e[2];const z=_o(sn(zo,R),sn($o,E),sn(y1,T));let O;e[3]===Symbol.for("react.memo_cache_sentinel")?(O=$=>{B.current=$,j($)},e[3]=O):O=e[3];const W=O;let D;if(e[4]!==s.projectSections||e[5]!==r.homeDirectory){let $;e[7]!==r.homeDirectory?($=he=>({id:he.project.id,projectLabel:Pd(he.project,r.homeDirectory),projectDescription:Qn(he.project.normalizedPath,r.homeDirectory),projectIcon:he.project.icon,projectColor:he.project.color,projectIconImage:he.project.iconImage,projectIconBackground:he.project.iconBackground}),e[7]=r.homeDirectory,e[8]=$):$=e[8],D=s.projectSections.map($),e[4]=s.projectSections,e[5]=r.homeDirectory,e[6]=D}else D=e[6];const Q=D,N=lx(),{confirm:C}=N;let I;e[9]!==C||e[10]!==i?(I=async($,he)=>{const se=Fo.getState().ids,Ne=r4(he,Be=>za(se,Be.directory,Be.id)||yu(Be.id)||Va(Be));if(Ne.length===0){_e.info(i("sessions.sidebar.project.archiveAll.nothing"));return}if(!await C({title:i("sessions.sidebar.project.archiveAll.title",{project:$}),message:Ne.length===1?i("sessions.sidebar.project.archiveAll.descriptionSingle",{count:Ne.length}):i("sessions.sidebar.project.archiveAll.descriptionPlural",{count:Ne.length}),action:i("sessions.sidebar.bulkActions.archive")}))return;const{archivedIds:We,failedIds:Ke}=await nt.getState().archiveSessions(Ne);We.length>0&&_e.success(We.length===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:We.length}):i("sessions.sidebar.bulkActions.archivedPlural",{count:We.length})),Ke.length>0&&_e.error(Ke.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Ke.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:Ke.length}))},e[9]=C,e[10]=i,e[11]=I):I=e[11];const H=I;let M;e[12]!==l||e[13]!==i?(M=$=>{l.revealPath&&l.revealPath($).catch(()=>{_e.error(i("sidebarFilesTree.toast.revealFailed"))})},e[12]=l,e[13]=i,e[14]=M):M=e[14];const _=M;let F;e[15]!==S?(F=$=>`${$.kind}:${$.id}`===S,e[15]=S,e[16]=F):F=e[16];const ee=s.rowModel.stickyHeaders.findIndex(F);let ne;if(e[17]!==p||e[18]!==s.groupProps.editingRowKey||e[19]!==s.rowModel.rowIndexByKey||e[20]!==s.rowModel.rows||e[21]!==s.rowModel.stickyHeaders||e[22]!==s.state.openSidebarMenuKey||e[23]!==ee){if(ne=new Set,p){let $;e[25]!==p||e[26]!==s.rowModel.rowIndexByKey?($=s.rowModel.rowIndexByKey.get(p),e[25]=p,e[26]=s.rowModel.rowIndexByKey,e[27]=$):$=e[27];const he=$;he!==void 0&&ne.add(he)}for(let $=0;$<s.rowModel.rows.length;$=$+1,$){const he=s.rowModel.rows[$];he?.kind==="session"&&(s.groupProps.editingRowKey===he.key||s.state.openSidebarMenuKey===`session-menu:${he.key}`||s.state.openSidebarMenuKey===`session-context:${he.key}`)&&ne.add($)}if(ee>=0){const $=Math.max(0,ee-1),he=Math.min(s.rowModel.stickyHeaders.length-1,ee+1);for(let se=$;se<=he;se=se+1,se){const Ne=s.rowModel.stickyHeaders[se];Ne&&ne.add(Ne.rowIndex)}}e[17]=p,e[18]=s.groupProps.editingRowKey,e[19]=s.rowModel.rowIndexByKey,e[20]=s.rowModel.rows,e[21]=s.rowModel.stickyHeaders,e[22]=s.state.openSidebarMenuKey,e[23]=ee,e[24]=ne}else ne=e[24];const re=ne;let te;e[28]!==s.rowModel.stickyHeaders?(te=$=>{const he=Gj(s.rowModel.stickyHeaders,$),se=he?`${he.kind}:${he.id}`:null;x(Ne=>Ne===se?Ne:se)},e[28]=s.rowModel.stickyHeaders,e[29]=te):te=e[29];const K=te;let q;e[30]!==a||e[31]!==i?(q=$=>{const he=()=>{if(!$.status.directory){mf();return}a.requestBootstrap({directory:$.status.directory,priority:"expanded",reason:$.group.isMain?"project-expanded":"worktree-expanded",force:!0})},se=async()=>{if(!$.status.directory)return;(await Jd($.status.directory)).success&&he()};let Ne;e:switch($.status.state){case"permission-denied":{Ne=i("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Ne=i("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Ne=i("sessions.sidebar.group.empty.initializationFailed");break e}default:Ne=i("sessions.sidebar.group.empty.loadingSessions")}return n.jsx("div",{className:"relative py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:$.flat?Cd:dd($.depth??0)},children:n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[$.status.state==="loading"?n.jsx(Z,{name:"loader-4",className:"size-3 animate-spin"}):null,Ne,$.status.canGrantAccess?n.jsx(Ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{se()},children:i("sessions.sidebar.group.empty.grantAccess")}):null,$.status.state!=="loading"?n.jsx(Ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:he,children:i("sessions.sidebar.group.empty.retry")}):null]})})},e[30]=a,e[31]=i,e[32]=q):q=e[32];const oe=q;let fe;e[33]!==o||e[34]!==f||e[35]!==l||e[36]!==s.emptyState||e[37]!==s.groupProps||e[38]!==s.projectRepoStatus||e[39]!==s.searchEmptyState||e[40]!==s.singleProjectMode||e[41]!==s.state||e[42]!==_||e[43]!==Q||e[44]!==u||e[45]!==oe||e[46]!==H||e[47]!==m||e[48]!==g||e[49]!==i||e[50]!==d||e[51]!==r?(fe=$=>{if($.kind==="activity-header")return n.jsx(Xh,{className:"sticky top-0 z-20 bg-sidebar","data-sidebar-sticky-header":"true",children:n.jsx(L3,{activityKey:$.activityKey,collapsed:$.collapsed,forceExpanded:$.forceExpanded,alwaysShowActions:r.alwaysShowActions,onToggle:()=>{if(!$.collapsed){const se=`activity:${$.activityKey}`;o.group.resetGroupSessionLimit(se),s.state.setVisibleActivityCountByKey(Ne=>{if(!Ne.has(se))return Ne;const Ue=new Map(Ne);return Ue.delete(se),Ue})}s.state.setCollapsedActivityKeys(se=>{const Ne=new Set(se);return Ne.has($.activityKey)?Ne.delete($.activityKey):Ne.add($.activityKey),Ne})},onNewChat:()=>{de.getState().closeMainSurfaces(),r.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:Sm,directoryOverride:null})}})});if($.kind==="project-header"){const se=$.section.project,Ne=Pd(se,r.homeDirectory);return n.jsx(H3,{id:se.id,disabled:s.singleProjectMode||$.forceExpanded||s.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:Ne,projectDescription:Qn(se.normalizedPath,r.homeDirectory),projectDirectory:se.normalizedPath,projectIcon:se.icon,projectColor:se.color,projectIconImage:se.iconImage,projectIconBackground:se.iconBackground,isCollapsed:$.collapsed,isRepo:!!s.projectRepoStatus.get(se.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:$.collapsed?o.renderProjectStatusIndicator?.(se.id,$.section.groups):null,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,projectPickerOptions:s.singleProjectMode?Q:void 0,onProjectSelect:s.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{!$.forceExpanded&&!s.singleProjectMode&&o.toggleProject(se.id)},onNewSession:()=>{Ei({projectId:se.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:se.id,directoryOverride:se.normalizedPath})},onNewWorktreeSession:()=>{Ei({projectId:se.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(se.id),onManageSpaces:g?()=>de.getState().setSpacesPageProjectId(se.id):void 0,onOpenFolder:se.normalizedPath&&l.revealPath?()=>_(se.normalizedPath):void 0,onRenameStart:()=>o.openProjectEditDialog(se.id),onArchiveAll:()=>{H(Ne,$.section.groups)},onClose:()=>o.removeProject(se.id),showCreateButtons:!0})}if($.kind==="group-header")return n.jsx(G3,{id:$.groupKey,disabled:$.forceExpanded||s.state.editingId!==null||r.worktreeSortOrder!=="manual",children:se=>n.jsx(n4,{...s.groupProps,...o.group,group:$.group,groupKey:$.groupKey,projectId:$.projectId,isEmpty:$.empty,visibleSessionCount:s.state.visibleSessionCountByGroup.get($.groupKey),editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,dragHandleProps:se,renderBody:!1})});if($.kind==="folder-header"){const se=s.groupProps.folderRename?.folderId===$.folder.id&&s.groupProps.folderRename.scopeKey===$.scopeKey;return n.jsx(Lh,{folderId:$.folder.id,scopeKey:$.scopeKey,ownerKey:$.ownerKey,disabled:!$.dropEnabled,children:(Ne,Ue)=>n.jsx(PC,{notifyOnSubtasks:s.groupProps.notifyOnSubtasks,activityNodes:$.activityNodes,folder:$.folder,displayName:$.displayName,sessions:$.nodes,depth:$.depth,canExpand:$.nodes.length>0||$.subFolderCount>0,isCollapsed:$.collapsed,onToggle:$.forceExpanded?d4:()=>d($.folder.id),onRename:We=>u($.scopeKey,$.folder.id,We),onDelete:()=>{$.archived?xn.requestDelete({sessions:[...$.deleteSessions],mode:"session"}):m?v({scopeKey:$.scopeKey,folderId:$.folder.id,folderName:$.folder.name,subFolderCount:$.subFolderCount,sessionCount:$.nodes.length}):f($.scopeKey,$.folder.id)},renderBody:!1,groupDirectory:$.scopeDirectory??$.group.directory,projectId:$.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:se,renameDraft:se?s.groupProps.folderRename?.draft:void 0,onRenameDraftChange:s.groupProps.setFolderRenameDraft,onRenameSave:()=>{const We=s.groupProps.folderRename?.draft.trim();We&&u($.scopeKey,$.folder.id,We),s.groupProps.clearFolderRename()},onRenameCancel:s.groupProps.clearFolderRename,droppableRef:Ne,isDropTarget:Ue,onNewSession:()=>{Ei({projectId:$.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:$.projectId,directoryOverride:$.scopeDirectory??$.group.directory,targetFolderId:$.folder.id,target:$.group.draftTarget})},archivedBucket:$.archived})})}if($.kind==="session"){const se=new Set;return Jn($.node,s.state.editingId)&&se.add($.node.session.id),n.jsx("div",{onFocusCapture:()=>y($.key),onBlurCapture:()=>y(Ne=>Ne===$.key?null:Ne),children:n.jsx(Po,{...s.groupProps,node:$.node,depth:$.depth,groupDirectory:$.groupDirectory,projectId:$.projectId,folderOwnerKey:$.ownerKey,selectionScopeKey:$.selectionScopeKey,archivedBucket:$.archived,renderContext:$.renderContext,rowKey:$.key,dragKey:$.key,secondaryMeta:$.secondaryMeta,renderChildren:!1,editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:se,menuOpenSessionId:s.state.openSidebarMenuKey===`session-menu:${$.key}`||s.state.openSidebarMenuKey===`session-context:${$.key}`?$.node.session.id:null,nodeStructureKey:$.blockingBadgeSessionScopes?`${kr($.node)}:${JSON.stringify($.blockingBadgeSessionScopes)}`:kr($.node),blockingBadgeSessionScopes:$.blockingBadgeSessionScopes}})})}if($.kind==="run")return n.jsx(P3,{run:$.run,depth:$.depth,laneNodes:$.laneNodes,blockingSessionIds:$.blockingSessionIds,renderContext:$.renderContext,projectId:$.projectId,projectLabel:$.projectLabel,expansionKey:$.expansionKey,expanded:$.expanded,forceExpanded:$.forceExpanded,notifyOnSubtasks:s.groupProps.notifyOnSubtasks,toggleParent:s.groupProps.toggleParent});const he=$.kind==="show-control"&&$.flat===!0?Cd:dd($.kind==="show-control"||$.kind==="empty"?$.depth??0:0);return $.kind==="show-control"?n.jsx("div",{children:n.jsx("button",{type:"button",className:"mt-0.5 flex items-center justify-start rounded-md pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",style:{paddingInlineStart:he},onClick:()=>{$.containerKey.startsWith("activity:")?s.state.setVisibleActivityCountByKey(se=>{const Ne=new Map(se);return $.control==="more"?Ne.set($.containerKey,$.currentCount+$.increment):Ne.delete($.containerKey),Ne}):$.control==="more"?o.group.showMoreGroupSessions($.containerKey,$.currentCount,$.increment):o.group.resetGroupSessionLimit($.containerKey)},children:i($.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")})}):$.kind==="status"?oe($):$.emptyKind==="sidebar"?s.emptyState:$.emptyKind==="search"?s.searchEmptyState:n.jsx("div",{className:"py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:he},children:i("sessions.sidebar.group.empty.noArchivedSessions")})},e[33]=o,e[34]=f,e[35]=l,e[36]=s.emptyState,e[37]=s.groupProps,e[38]=s.projectRepoStatus,e[39]=s.searchEmptyState,e[40]=s.singleProjectMode,e[41]=s.state,e[42]=_,e[43]=Q,e[44]=u,e[45]=oe,e[46]=H,e[47]=m,e[48]=g,e[49]=i,e[50]=d,e[51]=r,e[52]=fe):fe=e[52];const ce=fe;let ke;if(e[53]!==k||e[54]!==s.rowModel.rows){let $;e[56]!==k?($=he=>he.kind==="project-header"?k?.kind==="group"?[]:[he.section.project.id]:he.kind!=="group-header"?[]:k?.kind==="project"?[]:k?.kind==="group"&&he.projectId!==k.projectId?[]:[he.groupKey],e[56]=k,e[57]=$):$=e[57],ke=s.rowModel.rows.flatMap($),e[53]=k,e[54]=s.rowModel.rows,e[55]=ke}else ke=e[55];const De=ke;let Ce;e[58]!==s.sectionsForRender?(Ce=new Set(s.sectionsForRender.map(c4)),e[58]=s.sectionsForRender,e[59]=Ce):Ce=e[59];const Y=Ce;let je;e[60]!==s.rowModel.stickyHeaders?(je=s.rowModel.stickyHeaders.map(l4).join(""),e[60]=s.rowModel.stickyHeaders,e[61]=je):je=e[61];const we=je;let Pe;e[62]!==s.rowModel.rows||e[63]!==Y?(Pe=$=>{const he=String($.active.id);if(Y.has(he)){P({kind:"project"});return}const se=s.rowModel.rows.find(Ne=>Ne.kind==="group-header"&&Ne.groupKey===he);P(se?{kind:"group",projectId:se.projectId}:null)},e[62]=s.rowModel.rows,e[63]=Y,e[64]=Pe):Pe=e[64];let L;e[65]===Symbol.for("react.memo_cache_sentinel")?(L=()=>P(null),e[65]=L):L=e[65];let ie;e[66]!==o||e[67]!==h||e[68]!==s.rowModel.folderAuthorityByOwner||e[69]!==s.rowModel.folderDropTargets||e[70]!==s.rowModel.rows||e[71]!==s.sectionsForRender||e[72]!==s.state||e[73]!==r?(ie=$=>{if(P(null),!$.over)return;const he=$.active.data.current,se=$.over.data.current;if(he?.type==="session"&&he.sessionId&&he.ownerKey&&he.archivedBucket!==!0&&se?.type==="folder"&&se.folderId&&se.scopeKey&&se.ownerKey===he.ownerKey){const ct=s.rowModel.folderDropTargets.find(qe=>qe.folderId===se.folderId&&qe.scopeKey===se.scopeKey&&qe.ownerKey===he.ownerKey),pe=s.rowModel.folderAuthorityByOwner.get(he.ownerKey);if(!ct?.enabled||pe?.complete!==!0)return;const Ee=Xt.getState();for(const qe of pe.scopeKeys)qe!==se.scopeKey&&Ee.removeSessionFromFolder(qe,he.sessionId);h(se.scopeKey,se.folderId,he.sessionId);return}if(r.hasSessionSearchQuery||s.state.editingId!==null||$.active.id===$.over.id)return;const Ne=String($.active.id),Ue=String($.over.id),We=s.sectionsForRender.map(a4),Ke=We.indexOf(Ne),Be=We.indexOf(Ue);if(Ke>=0&&Be>=0&&r.projectSortOrder==="manual"){o.reorderProjects(Ke,Be);return}const U=s.rowModel.rows.find(ct=>ct.kind==="group-header"&&ct.groupKey===Ne),Me=s.rowModel.rows.find(ct=>ct.kind==="group-header"&&ct.groupKey===Ue);if(!U||!Me||U.projectId!==Me.projectId||!U.projectId)return;const Ge=U.projectId,Ve=s.sectionsForRender.find(ct=>ct.project.id===Ge);if(!Ve)return;const dt=Ve.groups.findIndex(ct=>ct.id===U.group.id),et=Ve.groups.findIndex(ct=>ct.id===Me.group.id);dt<0||et<0||o.setGroupOrderByProject(ct=>new Map(ct).set(Ge,jf(Ve.groups,dt,et).map(i4)))},e[66]=o,e[67]=h,e[68]=s.rowModel.folderAuthorityByOwner,e[69]=s.rowModel.folderDropTargets,e[70]=s.rowModel.rows,e[71]=s.sectionsForRender,e[72]=s.state,e[73]=r,e[74]=ie):ie=e[74];let G;e[75]!==K||e[76]!==s.rowModel||e[77]!==re||e[78]!==ce||e[79]!==w?(G=n.jsx(O3,{model:s.rowModel,scrollElement:w,pinnedRowIndexes:re,renderRow:ce,onFirstVisibleIndexChange:K}),e[75]=K,e[76]=s.rowModel,e[77]=re,e[78]=ce,e[79]=w,e[80]=G):G=e[80];let ae;e[81]!==De||e[82]!==G?(ae=n.jsx(Ga,{items:De,strategy:Cf,children:G}),e[81]=De,e[82]=G,e[83]=ae):ae=e[83];let ge;e[84]!==z||e[85]!==Pe||e[86]!==ie||e[87]!==ae?(ge=n.jsx(Pr,{ref:W,useScrollShadow:!0,hideTopScrollShadow:!0,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 ps-2.5 pe-2 [overflow-anchor:none]",children:n.jsx(Wo,{sensors:z,collisionDetection:Ko,onDragStart:Pe,onDragCancel:L,onDragEnd:ie,children:ae})}),e[84]=z,e[85]=Pe,e[86]=ie,e[87]=ae,e[88]=ge):ge=e[88];let me;e[89]!==A||e[90]!==ge||e[91]!==we?(me=n.jsx(_3,{suspended:A,layoutKey:we,scrollRef:B,children:ge}),e[89]=A,e[90]=ge,e[91]=we,e[92]=me):me=e[92];let be;e[93]!==f||e[94]!==b?(be=()=>{b&&(f(b.scopeKey,b.folderId),v(null))},e[93]=f,e[94]=b,e[95]=be):be=e[95];let ye;e[96]!==b||e[97]!==be?(ye=n.jsx(qh,{value:b,setValue:v,onConfirm:be}),e[96]=b,e[97]=be,e[98]=ye):ye=e[98];let Te;return e[99]!==N.dialog||e[100]!==me||e[101]!==ye?(Te=n.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[me,ye,N.dialog]}),e[99]=N.dialog,e[100]=me,e[101]=ye,e[102]=Te):Te=e[102],Te}function i4(t){return t.id}function a4(t){return t.project.id}function l4(t){const{kind:e,id:s,rowIndex:r}=t;return`${e}:${s}:${r}`}function c4(t){return t.project.id}function d4(){}function u4(t){return t.isolatedSpacesEnabled}function f4(t){return t.showDeletionDialog}function h4(t){return t.addSessionToFolder}function p4(t){return t.deleteFolder}function m4(t){return t.renameFolder}function g4(t){return t.toggleFolderCollapse}const b4=c.memo(o4),ha=new Map,Ed=(t,e)=>{for(const s of t){const r=ot(s??null);r&&!ha.has(r)&&ha.set(r,e)}},Nd=t=>{const e=ot(t??null);return e?ha.get(e)??0:0},dr=t=>!!t.time?.archived,y4=(t,e)=>{if(t===e)return!0;if(!t||!e||t.size!==e.size)return!1;for(const[s,r]of e)if(t.get(s)?.scopeDirectory!==r.scopeDirectory)return!1;return!0},x4=t=>{const{t:e}=wt(),s=c.useRef(t.gitBranches);s.current=t.gitBranches;const r=c.useRef(t.sessionOrderRanks);r.current=t.sessionOrderRanks;const o=c.useRef(t.sessionOwners),i=c.useMemo(()=>(y4(o.current,t.sessionOwners)||(o.current=t.sessionOwners),o.current),[t.sessionOwners]),a=c.useCallback(f=>[f.label,f.branch??"",f.description??"",f.directory??""].join(" ").toLowerCase(),[]),l=c.useCallback(f=>{const h=ot(f.directory??null)??"";return`${(f.title||e("sessions.sidebar.session.untitled")).trim()} ${h}`.toLowerCase()},[e]),d=c.useCallback((f,h)=>{if(!h)return f;const m=h.trim().toLowerCase(),g=m.startsWith("ses_");return f.flatMap(b=>{if(g&&dr(b.session))return[];if(g?b.session.id.toLowerCase()===m:po([l(b.session)],h))return[b];const S=d(b.children,h);return S.length===0?[]:[{...b,children:S}]})},[l]),u=c.useCallback((f,h,m,g,b)=>{const v=ot(h??null),S=nf(f),x=new Map(S.map(_=>[_.id,_])),p=new Map;S.forEach(_=>{const F=_.parentID;if(!F)return;const ee=x.get(F);if(!ee||dr(ee)||dr(_))return;const ne=p.get(F)??[];ne.push(_),p.set(F,ne)});const y=cx(m,v),w=(v&&!t.isVSCode?t.spacesByProject?.get(v):void 0)??[],j=new Map;for(const _ of w){const F=ot(_.directory);F&&j.set(F,_)}const k=_=>{const F=ot(_.directory??null),ee=t.worktreeMetadata.get(_.id)??null;if(ee)return ee;if(F){const ne=y.get(F)??null;if(ne&&F!==v)return ne}return null},P=new Set,A=_=>{P.add(_.id);const F=p.get(_.id)??[],ee=[];for(const ne of F)P.has(ne.id)||ee.push(A(ne));return{session:_,children:ee,worktree:k(_)}},B=_=>{const F=_.parentID;if(!F)return!1;if(dr(_))return!0;const ee=x.get(F);return!!(ee&&dr(ee))},R=S.filter(_=>{const F=_.parentID;return F?!x.has(F)&&!B(_):!0}),E=[],T=_=>{P.has(_.id)||E.push(A(_))};R.forEach(T),S.forEach(_=>{B(_)||T(_)});const z=new Map,O="__archived__",W=_=>{if(_.time?.archived)return O;if(t.isVSCode||t.runKeyBySessionId?.has(_.id))return v??"__project_root__";const F=i?.get(_.id)?.scopeDirectory;if(F){if(F===v)return v??"__project_root__";if(y.has(F)||j.has(F))return F}const ne=ot(t.worktreeMetadata.get(_.id)?.path??null)??Xn(_);return ne&&ne!==v&&y.has(ne)?ne:v??"__project_root__"};E.forEach(_=>{const F=W(_.session);z.has(F)||z.set(F,[]),z.get(F)?.push(_)});const D=v??"__project_root__",Q=[{id:"root",label:b&&g&&g!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:g}):e("sessions.sidebar.grouping.projectRoot"),branch:g??null,description:v?Qn(v,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:v,folderScopeKey:v,sessions:z.get(D)??[]}],N=new Map;m.forEach(_=>{const F=ot(_.path)??_.path,ee=z.get(F)??[],ne=ee.length>0,re=ee.reduce((te,K)=>{const q=dx(K.session,r.current);return Number.isFinite(q)?Math.max(te,q):te},0);N.set(F,{hasActiveSession:ne,lastUpdatedAt:re})});const C=(_,F)=>{const ee=(_.label||_.branch||_.name||_.path||"").toLowerCase(),ne=(F.label||F.branch||F.name||F.path||"").toLowerCase();return ee.localeCompare(ne)},I=t.worktreeSortOrder!=="recent"?[...m].sort(C):[...m].sort((_,F)=>{const ee=ot(_.path)??_.path,ne=ot(F.path)??F.path,re=N.get(ee)??{hasActiveSession:!1,lastUpdatedAt:0},te=N.get(ne)??{hasActiveSession:!1,lastUpdatedAt:0};if(re.hasActiveSession!==te.hasActiveSession)return re.hasActiveSession?-1:1;if(re.hasActiveSession&&te.hasActiveSession)return te.lastUpdatedAt-re.lastUpdatedAt;const K=Nd(_.path),q=Nd(F.path);return K!==q?q-K:C(_,F)});(t.isVSCode?[]:I).forEach(_=>{const F=ot(_.path)??_.path,ee=s.current.get(F)?.trim()||null,ne=_.branch?.trim()||null,te=!!(ee&&ne&&_.label&&tc(_.label)===tc(ne))?ee:_.label||_.name||Ao(F,t.homeDirectory)||F;Q.push({id:`worktree:${F}`,label:te,branch:ee||ne,description:Qn(F,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:_,directory:F,folderScopeKey:F,sessions:z.get(F)??[]})});for(const[_,F]of j)Q.push({id:`space:${F.id}`,label:F.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:F,directory:_,folderScopeKey:_,sessions:z.get(_)??[]});const M=z.get(O)??[];return M.length>0&&Q.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&&v?sf(v):null,sessions:M}),Q},[t.homeDirectory,t.worktreeMetadata,t.isVSCode,t.worktreeSortOrder,i,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:a,buildSessionSearchText:l,filterSessionNodesForSearch:d,buildGroupedSessions:u}},S4=t=>{const e=He.c(60),{selectedCount:s,scopeKey:r,scopeFolders:o,archivedBucket:i,onMoveToFolder:a,onCreateFolderAndMove:l,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:f,onArchive:h,onDelete:m,onDone:g}=t,{t:b}=wt(),v=s>0,S=v&&!!r&&!i;let x;e[0]!==s||e[1]!==b?(x=b("sessions.sidebar.bulkActions.selectedCount",{count:s}),e[0]=s,e[1]=b,e[2]=x):x=e[2];let p;e[3]!==x?(p=n.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:x}),e[3]=x,e[4]=p):p=e[4];let y;e[5]!==S||e[6]!==u||e[7]!==l||e[8]!==a||e[9]!==d||e[10]!==o||e[11]!==b?(y=S?n.jsxs(js,{children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx(Cs,{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":b("sessions.sidebar.bulkActions.moveToFolder"),children:n.jsx(Z,{name:"folder",className:"h-4 w-4"})})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),n.jsxs(Ps,{align:"end",className:"min-w-[180px]",children:[o.length===0?n.jsx(qt,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):o.map(M=>n.jsx(qt,{onClick:()=>a(M.id),children:n.jsx("span",{className:"flex-1 truncate",children:M.name})},M.id)),n.jsx(bn,{}),n.jsxs(qt,{onClick:l,children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?n.jsxs(qt,{onClick:d,className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1 h-4 w-4"}),b("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=S,e[6]=u,e[7]=l,e[8]=a,e[9]=d,e[10]=o,e[11]=b,e[12]=y):y=e[12];let w;e[13]!==i||e[14]!==v||e[15]!==f||e[16]!==b?(w=i?n.jsxs(Ot,{children:[n.jsx(At,{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":b("sessions.sidebar.bulkActions.restore"),children:n.jsx(Z,{name:"inbox-unarchive",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=i,e[14]=v,e[15]=f,e[16]=b,e[17]=w):w=e[17];let j;e[18]!==i||e[19]!==v||e[20]!==h||e[21]!==b?(j=i?null:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:h,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":b("sessions.sidebar.bulkActions.archive"),children:n.jsx(Z,{name:"archive",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.archive")})})]}),e[18]=i,e[19]=v,e[20]=h,e[21]=b,e[22]=j):j=e[22];const k=!v;let P;e[23]===Symbol.for("react.memo_cache_sentinel")?(P=ve("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]=P):P=e[23];let A;e[24]!==b?(A=b("sessions.sidebar.bulkActions.delete"),e[24]=b,e[25]=A):A=e[25];let B;e[26]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(Z,{name:"delete-bin",className:"h-4 w-4"}),e[26]=B):B=e[26];let R;e[27]!==m||e[28]!==k||e[29]!==A?(R=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:m,disabled:k,className:P,"aria-label":A,children:B})}),e[27]=m,e[28]=k,e[29]=A,e[30]=R):R=e[30];let E;e[31]!==b?(E=b("sessions.sidebar.bulkActions.delete"),e[31]=b,e[32]=E):E=e[32];let T;e[33]!==E?(T=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:E})}),e[33]=E,e[34]=T):T=e[34];let z;e[35]!==R||e[36]!==T?(z=n.jsxs(Ot,{children:[R,T]}),e[35]=R,e[36]=T,e[37]=z):z=e[37];let O;e[38]!==b?(O=b("sessions.sidebar.header.actions.exitSelection"),e[38]=b,e[39]=O):O=e[39];let W;e[40]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(Z,{name:"close",className:"h-4 w-4"}),e[40]=W):W=e[40];let D;e[41]!==g||e[42]!==O?(D=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:g,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":O,children:W})}),e[41]=g,e[42]=O,e[43]=D):D=e[43];let Q;e[44]!==b?(Q=b("sessions.sidebar.header.actions.exitSelection"),e[44]=b,e[45]=Q):Q=e[45];let N;e[46]!==Q?(N=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Q})}),e[46]=Q,e[47]=N):N=e[47];let C;e[48]!==D||e[49]!==N?(C=n.jsxs(Ot,{children:[D,N]}),e[48]=D,e[49]=N,e[50]=C):C=e[50];let I;e[51]!==z||e[52]!==C||e[53]!==y||e[54]!==w||e[55]!==j?(I=n.jsxs("div",{className:"ms-auto flex items-center gap-0.5",children:[y,w,j,z,C]}),e[51]=z,e[52]=C,e[53]=y,e[54]=w,e[55]=j,e[56]=I):I=e[56];let H;return e[57]!==p||e[58]!==I?(H=n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[p,I]}),e[57]=p,e[58]=I,e[59]=H):H=e[59],H},Id=new Map,v4=(t,e)=>{if(!t)return[];const s=e(t);return s.length>0?s.map(r=>r.scopeKey):[t]},w4=(t,e)=>{const s=t.sessionIds.filter(i=>e.has(i));if(s.length===0)return{ready:!1,value:null};const r=t.archivedBucket||zh(new Set(s),e),o={sessionIds:s,sessionCount:s.length,archivedBucket:r};return{ready:s.length===t.sessionIds.length&&r===t.archivedBucket,value:o}},k4=t=>{const e=He.c(89),{t:s}=wt();let r;e[0]!==s?(r=me=>{const be=ux(me);return be?{description:cu(be,s)}:void 0},e[0]=s,e[1]=r):r=e[1];const o=r,{isInlineEditing:i,showDeletionDialog:a,foldersMap:l,getFolderScopesForProject:d,addSessionsToFolder:u,removeSessionsFromFolders:f,createFolderAndStartRename:h,archiveSessions:m,unarchiveSessions:g,deleteSessions:b,bulkDeleteConfirm:v,setBulkDeleteConfirm:S}=t,x=cs(j4),p=cs(C4),y=p>0,w=cs(P4),j=cs(E4),k=$h(),P=N4,A=I4;let B;e[2]!==y||e[3]!==k||e[4]!==w?(B=y&&zh(w,k?.getSessionsById()??Id),e[2]=y,e[3]=k,e[4]=w,e[5]=B):B=e[5];const R=B;let E;e:{if(j){E=j;break e}E=null}const T=E;let z;e[6]!==T||e[7]!==d?(z=v4(T,d),e[6]=T,e[7]=d,e[8]=z):z=e[8];const O=z;let W;if(e[9]!==l||e[10]!==O){let me;e[12]!==l?(me=be=>l[be]??[],e[12]=l,e[13]=me):me=e[13],W=O.flatMap(me),e[9]=l,e[10]=O,e[11]=W}else W=e[11];const D=W;let Q;e[14]!==l||e[15]!==O?(Q=me=>{for(const be of O)if((l[be]??[]).some(ye=>ye.id===me))return be;return null},e[14]=l,e[15]=O,e[16]=Q):Q=e[16];const N=Q;let C;e:{if(!y){C=!1;break e}for(const me of O)for(const be of l[me]??[])for(const ye of be.sessionIds)if(w.has(ye)){C=!0;break e}C=!1}const I=C;let H;e[17]!==u||e[18]!==f||e[19]!==w||e[20]!==O?(H=(me,be)=>{const ye=Array.from(w);for(const Te of O)Te!==me&&f(Te,ye);u(me,be,ye)},e[17]=u,e[18]=f,e[19]=w,e[20]=O,e[21]=H):H=e[21];const M=H;let _;e[22]!==y||e[23]!==M||e[24]!==N?(_=me=>{if(!y)return;const be=N(me);be&&M(be,me)},e[22]=y,e[23]=M,e[24]=N,e[25]=_):_=e[25];const F=_;let ee;e[26]!==h||e[27]!==y||e[28]!==M||e[29]!==O?(ee=()=>{const me=O[0];if(!me||!y)return;const be=h(me);be&&M(me,be.id)},e[26]=h,e[27]=y,e[28]=M,e[29]=O,e[30]=ee):ee=e[30];const ne=ee;let re;e[31]!==y||e[32]!==f||e[33]!==w||e[34]!==O?(re=()=>{if(!y)return;const me=Array.from(w);for(const be of O)f(be,me)},e[31]=y,e[32]=f,e[33]=w,e[34]=O,e[35]=re):re=e[35];const te=re;let K;e[36]!==m||e[37]!==b||e[38]!==o||e[39]!==s?(K=async(me,be)=>{if(me.length!==0)if(be){const{deletedIds:ye,failedIds:Te}=await b(me);ye.length>0&&_e.success(ye.length===1?s("sessions.sidebar.bulkActions.deletedSingle",{count:ye.length}):s("sessions.sidebar.bulkActions.deletedPlural",{count:ye.length})),Te.length>0&&_e.error(Te.length===1?s("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Te.length}):s("sessions.sidebar.bulkActions.failedDeletePlural",{count:Te.length}),o(Te)),cs.getState().removeMany(ye)}else{const{archivedIds:ye,failedIds:Te}=await m(me);ye.length>0&&_e.success(ye.length===1?s("sessions.sidebar.bulkActions.archivedSingle",{count:ye.length}):s("sessions.sidebar.bulkActions.archivedPlural",{count:ye.length})),Te.length>0&&_e.error(Te.length===1?s("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Te.length}):s("sessions.sidebar.bulkActions.failedArchivePlural",{count:Te.length}),o(Te)),cs.getState().removeMany(ye)}},e[36]=m,e[37]=b,e[38]=o,e[39]=s,e[40]=K):K=e[40];const q=K;let oe;e[41]!==q||e[42]!==y||e[43]!==w||e[44]!==S||e[45]!==a?(oe=me=>{if(!y)return;const be=Array.from(w);if(!a){q(be,me);return}S({sessionIds:be,sessionCount:be.length,archivedBucket:me})},e[41]=q,e[42]=y,e[43]=w,e[44]=S,e[45]=a,e[46]=oe):oe=e[46];const fe=oe;let ce;e[47]!==R||e[48]!==fe?(ce=()=>fe(R),e[47]=R,e[48]=fe,e[49]=ce):ce=e[49];const ke=ce;let De;e[50]!==fe?(De=()=>fe(!1),e[50]=fe,e[51]=De):De=e[51];const Ce=De;let Y;e[52]!==fe?(Y=()=>fe(!0),e[52]=fe,e[53]=Y):Y=e[53];const je=Y;let we;e[54]!==R||e[55]!==o||e[56]!==y||e[57]!==w||e[58]!==s||e[59]!==g?(we=async()=>{if(!y||!R)return;const me=Array.from(w),{restoredIds:be,failedIds:ye}=await g(me);be.length>0&&_e.success(be.length===1?s("sessions.sidebar.bulkActions.restoredSingle",{count:be.length}):s("sessions.sidebar.bulkActions.restoredPlural",{count:be.length})),ye.length>0&&_e.error(ye.length===1?s("sessions.sidebar.bulkActions.failedRestoreSingle",{count:ye.length}):s("sessions.sidebar.bulkActions.failedRestorePlural",{count:ye.length}),o(ye)),cs.getState().removeMany(be)},e[54]=R,e[55]=o,e[56]=y,e[57]=w,e[58]=s,e[59]=g,e[60]=we):we=e[60];const Pe=we;let L;e[61]!==v||e[62]!==q||e[63]!==k||e[64]!==S?(L=async()=>{if(!v)return;const me=k?.getSessionsById()??Id,be=w4(v,me);if(!be.ready){S(be.value);return}S(null),await q(be.value.sessionIds,be.value.archivedBucket)},e[61]=v,e[62]=q,e[63]=k,e[64]=S,e[65]=L):L=e[65];const ie=L;let G,ae;e[66]!==v||e[67]!==ke||e[68]!==i||e[69]!==k||e[70]!==x?(G=()=>{if(!x)return;const me=/Macintosh|Mac OS X/.test(navigator.userAgent||""),be=ye=>{if(v||i)return;const Te=ye.target instanceof HTMLElement?ye.target:null;if(Te&&(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.isContentEditable))return;const $=me?ye.metaKey:ye.ctrlKey;if(ye.key==="Escape"){ye.preventDefault(),cs.getState().disable();return}if($&&ye.key==="Backspace"){ye.preventDefault(),ke();return}if($&&(ye.key==="a"||ye.key==="A")){const he=RC(k?.getEntries()??[],k?.getDescendantIds()??[],cs.getState().scopeKey);if(!he)return;ye.preventDefault(),cs.getState().replaceAll(he.ids,he.scopeKey)}};return window.addEventListener("keydown",be),()=>window.removeEventListener("keydown",be)},ae=[v,ke,i,k,x],e[66]=v,e[67]=ke,e[68]=i,e[69]=k,e[70]=x,e[71]=G,e[72]=ae):(G=e[71],ae=e[72]),c.useEffect(G,ae);let ge;return e[73]!==I||e[74]!==D||e[75]!==R||e[76]!==ie||e[77]!==T||e[78]!==Ce||e[79]!==ne||e[80]!==ke||e[81]!==je||e[82]!==F||e[83]!==te||e[84]!==Pe||e[85]!==y||e[86]!==p||e[87]!==x?(ge={selectionModeEnabled:x,hasSelection:y,selectedIdsSize:p,bulkScopeIsArchived:R,derivedSelectionScope:T,bulkScopeFolders:D,bulkCanRemoveFromFolder:I,handleToggleSelectionMode:P,handleExitSelectionMode:A,handleBulkMoveToFolder:F,handleBulkCreateFolderAndMove:ne,handleBulkRemoveFromFolder:te,handleBulkDelete:ke,handleBulkArchive:Ce,handleBulkHardDelete:je,handleBulkRestore:Pe,confirmBulkDelete:ie},e[73]=I,e[74]=D,e[75]=R,e[76]=ie,e[77]=T,e[78]=Ce,e[79]=ne,e[80]=ke,e[81]=je,e[82]=F,e[83]=te,e[84]=Pe,e[85]=y,e[86]=p,e[87]=x,e[88]=ge):ge=e[88],ge};function j4(t){return t.enabled}function C4(t){return t.selectedIds.size}function P4(t){return t.selectedIds}function E4(t){return t.scopeKey}function N4(){cs.getState().toggleMode()}function I4(){cs.getState().disable()}function R4(t){const e=He.c(37),{getFolderScopesForProject:s,isInlineEditing:r,startFolderRename:o}=t,[i,a]=c.useState(null),l=de(_4),d=de(L4),u=Xt(F4),f=Xt(B4),h=Xt(O4),m=Xt(A4),g=nt(M4),b=nt(T4),v=nt(D4);let S;e[0]!==f||e[1]!==o?(S=k=>{const P=f(k,"New folder");return o(k,P),P},e[0]=f,e[1]=o,e[2]=S):S=e[2];let x;e[3]!==h||e[4]!==g||e[5]!==i||e[6]!==v||e[7]!==u||e[8]!==s||e[9]!==r||e[10]!==m||e[11]!==l||e[12]!==S||e[13]!==b?(x={isInlineEditing:r,showDeletionDialog:l,foldersMap:u,getFolderScopesForProject:s,addSessionsToFolder:h,removeSessionsFromFolders:m,createFolderAndStartRename:S,archiveSessions:g,unarchiveSessions:b,deleteSessions:v,bulkDeleteConfirm:i,setBulkDeleteConfirm:a},e[3]=h,e[4]=g,e[5]=i,e[6]=v,e[7]=u,e[8]=s,e[9]=r,e[10]=m,e[11]=l,e[12]=S,e[13]=b,e[14]=x):x=e[14];const p=k4(x);let y;e[15]!==p.bulkCanRemoveFromFolder||e[16]!==p.bulkScopeFolders||e[17]!==p.bulkScopeIsArchived||e[18]!==p.derivedSelectionScope||e[19]!==p.handleBulkArchive||e[20]!==p.handleBulkCreateFolderAndMove||e[21]!==p.handleBulkHardDelete||e[22]!==p.handleBulkMoveToFolder||e[23]!==p.handleBulkRemoveFromFolder||e[24]!==p.handleBulkRestore||e[25]!==p.handleExitSelectionMode||e[26]!==p.selectedIdsSize||e[27]!==p.selectionModeEnabled?(y=p.selectionModeEnabled?n.jsx(S4,{selectedCount:p.selectedIdsSize,scopeKey:p.derivedSelectionScope,scopeFolders:p.bulkScopeFolders,archivedBucket:p.bulkScopeIsArchived,onMoveToFolder:p.handleBulkMoveToFolder,onCreateFolderAndMove:p.handleBulkCreateFolderAndMove,onRemoveFromFolder:p.handleBulkRemoveFromFolder,canRemoveFromFolder:p.bulkCanRemoveFromFolder,onRestore:p.handleBulkRestore,onArchive:p.handleBulkArchive,onDelete:p.handleBulkHardDelete,onDone:p.handleExitSelectionMode}):null,e[15]=p.bulkCanRemoveFromFolder,e[16]=p.bulkScopeFolders,e[17]=p.bulkScopeIsArchived,e[18]=p.derivedSelectionScope,e[19]=p.handleBulkArchive,e[20]=p.handleBulkCreateFolderAndMove,e[21]=p.handleBulkHardDelete,e[22]=p.handleBulkMoveToFolder,e[23]=p.handleBulkRemoveFromFolder,e[24]=p.handleBulkRestore,e[25]=p.handleExitSelectionMode,e[26]=p.selectedIdsSize,e[27]=p.selectionModeEnabled,e[28]=y):y=e[28];let w;e[29]!==p.confirmBulkDelete||e[30]!==i||e[31]!==d||e[32]!==l?(w=n.jsx(p3,{value:i,setValue:a,showDeletionDialog:l,setShowDeletionDialog:d,onConfirm:p.confirmBulkDelete}),e[29]=p.confirmBulkDelete,e[30]=i,e[31]=d,e[32]=l,e[33]=w):w=e[33];let j;return e[34]!==y||e[35]!==w?(j=n.jsxs(n.Fragment,{children:[y,w]}),e[34]=y,e[35]=w,e[36]=j):j=e[36],j}function D4(t){return t.deleteSessions}function T4(t){return t.unarchiveSessions}function M4(t){return t.archiveSessions}function A4(t){return t.removeSessionsFromFolders}function O4(t){return t.addSessionsToFolder}function B4(t){return t.createFolder}function F4(t){return t.foldersMap}function L4(t){return t.setShowDeletionDialog}function _4(t){return t.showDeletionDialog}const Qh="oc.sessions.expandedParents.v3",$4=Go(rn()),z4=()=>{try{const t=globalThis.localStorage.getItem(Qh);if(t===null)return new Set;const e=$4.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},W4=()=>{const[t,e]=c.useState(z4),s=c.useRef(t);s.current=t;const r=c.useCallback(o=>{const i=fx(s.current,o);s.current=i,e(i);try{globalThis.localStorage.setItem(Qh,JSON.stringify([...i]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},K4=t=>{const e=He.c(22),{childStores:s,sections:r,chatGroup:o,canGrantAccess:i}=t,a=ws(H4),l=ws(V4);let d;e[0]!==o||e[1]!==r?(d=[...r.flatMap(G4),...o?[{key:"activity:chats",group:o}]:[]].map(Y4),e[0]=o,e[1]=r,e[2]=d):d=e[2];const u=d;let f;e[3]!==u?(f=new Set(u.flatMap(X4)),e[3]=u,e[4]=f):f=e[4];let h;e[5]!==f?(h=[...f],e[5]=f,e[6]=h):h=e[6];const m=h;let g;e[7]!==s||e[8]!==m.length?(g=y=>m.length>0?s.subscribeBootstrap(y):Q4,e[7]=s,e[8]=m.length,e[9]=g):g=e[9];let b;e[10]!==s||e[11]!==m?(b=()=>m.map(y=>`${y}\0${s.getBootstrapState(y)??""}\0${s.getBootstrapFailure(y)??""}\0${s.getInitializationState(y)??""}\0${s.getInitializationFailure(y)??""}`).join(""),e[10]=s,e[11]=m,e[12]=b):b=e[12];const v=c.useSyncExternalStore(g,b,Z4);let S;if(e[13]!==i||e[14]!==s||e[15]!==a||e[16]!==u||e[17]!==l){S=new Map;for(const{key:y,archived:w,directories:j}of u){const k=j.find(P=>s.getBootstrapState(P)==="failed"||s.getInitializationState(P)==="failed");if(k){const P=s.getBootstrapState(k)==="failed",A=P?s.getBootstrapFailure(k):s.getInitializationFailure(k);S.set(y,{state:A==="os-permission"?"permission-denied":P?"load-failed":"initialization-failed",directory:k,canGrantAccess:A==="os-permission"&&i})}else{const P=l||!w&&j.length>0&&j.every(A=>s.getBootstrapState(A)==="complete");S.set(y,{state:P?"ready":a==="error"?"load-failed":"loading",directory:P?j[0]??null:null,canGrantAccess:!1})}}e[13]=i,e[14]=s,e[15]=a,e[16]=u,e[17]=l,e[18]=S}else S=e[18];const x=S;let p;return e[19]!==v||e[20]!==x?(p={groupStatusByKey:x,bootstrapSnapshot:v},e[19]=v,e[20]=x,e[21]=p):p=e[21],p};function H4(t){return t.status}function V4(t){return t.hasLoaded}function G4(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function U4(t){return ot(t.directory)}function q4(t){return!!t}function Y4(t){const{key:e,group:s}=t;return{key:e,archived:s.isArchivedBucket===!0,directories:er(s).map(U4).filter(q4)}}function X4(t){return t.directories}function Q4(){}function Z4(){return""}const J4=6e4,e5=[],Rd=[],Dd=[],t5=t=>!t.parentID,s5=({topology:t,view:e,actions:s})=>{const{alwaysShowActions:r,notifyOnSubtasks:o,projectViewActions:i,rowActions:a,...l}=s,d=Xt(Re=>Re.foldersMap),u=Xt(Re=>Re.collapsedFolderIds),f=Xt(Re=>Re.createFolder),h=Xt(Re=>Re.addSessionToFolder),m=e.projectView,{getOrderedGroups:g,setGroupOrderByProject:b,toggleGroup:v,toggleProject:S,setCollapsedActivities:x}=i,p=Rg({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),y=hx(Re=>Re.projects),w=vm(),j=c.useMemo(()=>new Map(w.map(Re=>[Re.id,Re.name])),[w]),k=c.useMemo(()=>{const Re=new Map;for(const Ze of w){const at=ot(Ze.projectDirectory);if(!at)continue;const _t=Re.get(at);_t?_t.push(Ze):Re.set(at,[Ze])}return Re},[w]),P=c.useMemo(()=>I1(p.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,p.archivedSessions,y,w),[y,p.archivedSessions,p.sessions,w,t.availableWorktreesByProject,t.isVSCode,t.projects]),[A,B]=c.useState(new Map),[R,E]=c.useState(new Map),T=c.useCallback((Re,Ze,at=7)=>{B(_t=>new Map(_t).set(Re,Ze+at))},[]),z=c.useCallback(Re=>{B(Ze=>{if(!Ze.has(Re))return Ze;const at=new Map(Ze);return at.delete(Re),at})},[]);c.useEffect(()=>{B(Re=>{if(Re.size===0)return Re;const Ze=Vt=>m.collapsedGroups.has(Vt)||[...m.collapsedProjects].some(Ht=>Vt===Mh(Ht)||Vt.startsWith(`${Ht}:`)),at=[...Re.keys()].filter(Ze);if(at.length===0)return Re;const _t=new Map(Re);for(const Vt of at)_t.delete(Vt);return _t})},[m.collapsedGroups,m.collapsedProjects]);const O=os(Re=>Re.showChatsSection),W=os(Re=>Re.projectDisplayMode),D=os(Re=>Re.singleProjectId),Q=os(Re=>Re.setSingleProjectId),C=!t.isVSCode&&!wm()&&W==="single",I=e.sidebarViewMode==="timeline"&&!t.isVSCode,H=c.useMemo(()=>px(p.rootSessions,Re=>ot(t.worktreeMetadata.get(Re.id)?.projectDirectory??Re.directory??null)),[p.rootSessions,t.worktreeMetadata]),M=c.useRef(null),_=c.useMemo(()=>{const Re=Array.from(H.runKeyBySessionId,([Ze,at])=>`${Ze}\0${at}`).sort().join("");return M.current?.signature!==Re&&(M.current={signature:Re,map:H.runKeyBySessionId}),M.current.map},[H]),[F,ee]=c.useState(null),[ne,re]=c.useState(null),[te,K]=c.useState(""),[q,oe]=c.useState(null),[fe,ce]=c.useState(null),[ke,De]=c.useState(null),Ce=c.useCallback((Re,Ze)=>{De({scopeKey:Re,folderId:Ze.id,draft:Ze.name})},[]),Y=c.useCallback(Re=>{De(Ze=>Ze?{...Ze,draft:Re}:null)},[]),je=c.useCallback(()=>De(null),[]),{expandedParents:we,toggleParent:Pe}=W4(),L=nt(Re=>Re.setCurrentSession),ie=c.useCallback((Re,Ze)=>{Re!==nt.getState().currentSessionId&&L(Re,Ze)},[L]),G=ff(),ae=os(Re=>Re.worktreeSortOrder),{buildGroupedSessions:ge,filterSessionNodesForSearch:me,buildGroupSearchText:be}=x4({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:p.pinnedSessionIds,sessionOrderRanks:p.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:ae,sessionOwners:P.bySessionId,spacesByProject:k,runKeyBySessionId:_}),{getSessionsForProject:ye,getArchivedSessionsForProject:Te}=tC({ownership:P}),$=mx(),he=c.useMemo(()=>{if(t.isVSCode)return null;const Re=$??p.chatSessions.map(at=>Sa(at.directory)).find(Boolean)??null;if(!Re)return null;const Ze=Array.from(new Set([Re,...p.chatSessions.map(at=>ot(at.directory??null)).filter(Boolean)])).filter(at=>!!at).map(at=>({scopeKey:at,directory:at}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Re,folderScopeKey:Re,folderScopes:Ze,draftTarget:"chat",sessions:p.chatSessions.filter(at=>!at.time?.archived&&t5(at)).map(at=>or(p.childrenMap,at))}},[p.chatSessions,p.childrenMap,$,t.isVSCode]),se=c.useMemo(()=>he?[he]:e5,[he]),{projectSections:Ne,groupSearchDataByGroup:Ue,sectionsForRender:We,flatSectionsForRender:Ke}=iC({normalizedProjects:t.projects,getSessionsForProject:ye,getArchivedSessionsForProject:Te,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,sessionOrderRanks:p.sessionOrderRanks,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:ge,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:me,buildGroupSearchText:be,foldersMap:d,standaloneGroups:se}),Be=e.onSearchMatchCountChange;c.useEffect(()=>()=>Be(0),[Be]);const U=Er(),Me=e.useGroupedSections?We:Ke,Ge=c.useMemo(()=>e.showInlineArchived?Me:Me.map(Re=>Re.groups.some(Ze=>Ze.isArchivedBucket)?{...Re,groups:Re.groups.filter(Ze=>!Ze.isArchivedBucket)}:Re),[Me,e.showInlineArchived]),Ve=c.useCallback(Re=>Ke.find(at=>at.project.id===Re)?.groups.find(at=>!at.isArchivedBucket)?.folderScopes??[],[Ke]);q2({enabled:!0,normalizedProjects:t.projects,ownership:P,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:p.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:d,createFolder:f,addSessionToFolder:h});const{sourceControl:dt}=Ws(),et=ls(Re=>Re.ensureEntry),ct=ls(Re=>Re.setParams),pe=ls(Re=>Re.refreshTargets),Ee=ls(Re=>Re.clearDirectoryStatus),qe=ls(Re=>Re.beginActiveContextsLoad),Ye=ls(Re=>Re.commitActiveContexts),$e=ls(Re=>Re.releaseActiveContexts),tt=ls(Re=>Re.activeContextRegistrations),ht=c.useId(),vt=c.useRef(new Set),Bt=c.useMemo(()=>new Map(p.orderedSessions.map((Re,Ze)=>[Re.id,Ze])),[p.orderedSessions]),[kt,St]=c.useState(null),xt=c.useRef([]),Mt=e.projectSortOrder==="recent";c.useEffect(()=>{Mt||St(null)},[Mt]);const jt=c.useMemo(()=>{const Re=ae!=="manual"?Ge:Ge.map(at=>{const _t=g(at.project.id,at.groups);return _t===at.groups?at:{...at,groups:_t}}),Ze=Dg(Re,e.projectSortOrder,at=>at.project.id,P.sessionsByProject);return[...kt&&Mt?Tg(Ze,kt,at=>at.project.id):Ze]},[g,kt,Mt,P.sessionsByProject,Ge,e.projectSortOrder,ae]);c.useEffect(()=>{xt.current=jt.map(Re=>Re.project.id)},[jt]);const $t=c.useMemo(()=>{if(!I)return Rd;const Re=new Set(p.rootSessions.map(Ht=>Ht.id)),Ze=p.orderedSessions.filter(Ht=>Re.has(Ht.id)&&!Ht.time?.archived),at=new Map,_t=$l({sessions:Ze,projects:t.projects,ownerBySessionId:P.bySessionId,spaceLabelById:j,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return Qc({sessions:Ze,getSessionLocation:Ht=>_t.get(Ht)??null,getSessionNode:Ht=>{const Oe=or(p.childrenMap,Ht),ze=_t.get(Ht.id);return at.set(Ht.id,aa(Oe,!1,ze?.groupDirectory??Ht.directory??null)),{...Oe,children:[],worktree:ze?.worktree??null}},query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""}).map(Ht=>({...Ht,blockingBadgeSessionScopes:at.get(Ht.node.session.id)}))},[p.childrenMap,p.orderedSessions,p.rootSessions,P.bySessionId,j,I,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),Wt=de(Re=>Re.sessionWorkEnabled),Kt=os(Re=>Re.showWorkSection),rt=c.useMemo(()=>{if(!Wt||!Kt)return Dd;const Re=p.orderedSessions.filter(Ze=>!Ze.parentID&&!Ze.time?.archived&&!xa(Ze.directory)&&Va(Ze));return Re.length>0?Re:Dd},[p.orderedSessions,Wt,Kt]),ut=c.useMemo(()=>new Set(rt.map(Re=>Re.id)),[rt]),pt=c.useMemo(()=>{if(rt.length===0)return Rd;const Re=$l({sessions:[...rt],projects:t.projects,ownerBySessionId:P.bySessionId,spaceLabelById:j,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1}),Ze=new Map,at=new Map(rt.map(ze=>[ze.id,or(p.childrenMap,ze)])),_t=new Map(rt.map(ze=>{const st=at.get(ze.id)??or(p.childrenMap,ze);Ze.set(ze.id,aa(st,!1,Re.get(ze.id)?.groupDirectory??ze.directory??null));const Nt={...st,children:[],worktree:Re.get(ze.id)?.worktree??null};return[ze.id,Nt]})),Vt=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",Ht=Vt?rt.filter(ze=>{const st=at.get(ze.id);return st?Ih(st,Vt):!1}):[...rt];return Qc({sessions:Ht,getSessionLocation:ze=>Re.get(ze)??null,getSessionNode:ze=>_t.get(ze.id)??or(p.childrenMap,ze),query:""}).map(ze=>({...ze,blockingBadgeSessionScopes:Ze.get(ze.node.session.id)}))},[p.childrenMap,P.bySessionId,j,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery,rt]),ue=c.useMemo(()=>{const Re=new Map,Ze=new Map,at=new Map,_t=new Map,Vt=new Set,Ht=(ze,st)=>{const Nt=st?.trim();ze&&Nt&&Re.set(yx(ze,Nt),{directory:ze,branch:Nt})},Oe=ze=>{if(Ht(ot(ze.worktree?.path??null),ze.worktree?.branch),!t.isVSCode){for(const st of lf(ze.session))Ze.set(`${st.owner.toLowerCase()}/${st.repo.toLowerCase()}#${st.number}`,{owner:st.owner,repo:st.repo,number:st.number});for(const st of Ka(ze.session))st.source==="github"?at.set(`${st.owner.toLowerCase()}/${st.repo.toLowerCase()}#${st.number}`,{owner:st.owner,repo:st.repo,number:st.number}):st.source==="linear"&&Vt.add(st.identifier.toUpperCase());for(const st of bx(ze.session))_t.set(st.key,st)}ze.children.forEach(Oe)};return pt.forEach(ze=>Oe(ze.node)),I?($t.forEach(ze=>{(!ze.projectId||!m.collapsedProjects.has(ze.projectId))&&Oe(ze.node)}),{targets:Re,linkedRefs:[...Ze.values()],linkedIssueRefs:[...at.values()],linearIdentifiers:[...Vt],gitlabRefs:[..._t.values()]}):(Ne.forEach(ze=>{m.collapsedProjects.has(ze.project.id)||ze.groups.forEach(st=>{if(st.isArchivedBucket||(st.sessions.forEach(Oe),st.isMain))return;const Nt=ot(st.directory??null);Ht(Nt,st.branch?.trim()||t.gitBranches.get(Nt||""))})}),{targets:Re,linkedRefs:[...Ze.values()],linkedIssueRefs:[...at.values()],linearIdentifiers:[...Vt],gitlabRefs:[..._t.values()]})},[Ne,m.collapsedProjects,$t,I,t.gitBranches,t.isVSCode,pt]),lt=ue.targets,ft=c.useRef(null),mt=c.useMemo(()=>{const Re=U2(lt.values()),Ze=JSON.stringify(Re);return ft.current?.signature!==Ze&&(ft.current={signature:Ze,candidates:Re}),ft.current.candidates},[lt]);c.useEffect(()=>{const Re=mt;if(Re.length===0)return;let Ze=!1;const at=Yt(),_t=async(Dt,ts=J4)=>{const fs=Date.now(),us=new Map,Se=Qe=>{const yt=us.get(Qe);if(yt)return yt;const Rt=qe(at,Qe,ht),zt=kn.scope(Qe),Jt=mr(()=>kn.read(zt,dt)).then(Rs=>{if(Ze||at!==Yt())return null;const ys=Rs.contexts[0],Ds=ys&&Bi(mn.getState().entries[_n(ys)],ys).connected?[ys]:[];return Ye(at,Qe,ht,Rt,Ds)?(Ds.length===0&&Ee(Qe),Ds):null});return us.set(Qe,Jt),Jt},V=await Promise.all(Re.filter(Qe=>!Dt||Qe.directory===Dt).map(async Qe=>(await Se(Qe.directory)??[]).map(Rt=>({...Qe,context:Rt}))));if(Ze||at!==Yt())return;const Ie=new Map,Le=new Map;for(const Qe of V.flat()){const yt=Fu(Qe.context,Qe.branch);Le.set(yt,{context:Qe.context,branch:Qe.branch});const Rt=ls.getState().entries[yt],zt=Rt?.status?.changeRequest??Rt?.status?.pr,Jt=zt?.state,ys=!!zt&&!(Jt==="closed"||Jt==="merged"),Ds=Math.max(Rt?.lastRefreshAt??0,Rt?.lastDiscoveryPollAt??0),Ks=!!(Rt?.isInitialStatusResolved&&!ys&&(!vt.current.has(yt)||fs-Ds>=ts));(!Rt||!Rt.isInitialStatusResolved||Ks)&&(Ks&&vt.current.add(yt),Ie.has(yt)||Ie.set(yt,{context:Qe.context,branch:Qe.branch}))}Le.forEach((Qe,yt)=>{et(yt),ct(yt,{directory:Qe.context.directory,branch:Qe.branch,remoteName:Qe.context.primaryRemote,canShow:!0,identity:Qe.context,readContext:Qe.context,sourceControl:dt,authChecked:!0,connected:!0})}),Ie.size!==0&&await pe([...Ie.values()],{silent:!0,markInitialResolved:!0})},Vt=[...new Set(Re.map(Dt=>Dt.directory))].map(Dt=>kn.scope(Dt)),Ht=Vt.map(Dt=>{let ts=kn.snapshot(Dt);return kn.subscribe(Dt,()=>{const fs=kn.snapshot(Dt),us=ts.read!==null&&ts!==fs;ts=fs,us&&!Ze&&_t(Dt.directory)})}),Oe=mn.subscribe((Dt,ts)=>{if(!(Ze||at!==Yt()||Dt.entries===ts.entries))for(const fs of Vt){const us=kn.snapshot(fs).contexts[0];if(!us)continue;const Se=_n(us);Dt.entries[Se]!==ts.entries[Se]&&_t(fs.directory)}});_t();const ze=new Set(Re.map(Dt=>Dt.directory)),st=wn(Dt=>{!Ze&&Dt.type==="source-control-activity"&&ze.has(Dt.directory)&&_t(Dt.directory,0)}),Nt=()=>{!Ze&&document.visibilityState==="visible"&&_t()};return document.addEventListener("visibilitychange",Nt),()=>{Ze=!0,Oe(),Ht.forEach(Dt=>Dt()),st(),document.removeEventListener("visibilitychange",Nt);for(const Dt of Re)$e(at,Dt.directory,ht)}},[qe,Ee,Ye,mt,et,pe,$e,ct,dt,ht]);const It=c.useMemo(()=>gx(tt,lt.values()),[tt,lt]),xe=_u(It),it=c.useMemo(()=>[...xe,...ue.linkedRefs.map(Re=>xr("pull",Re)),...ue.linkedIssueRefs.map(Re=>xr("issue",Re)),...ue.gitlabRefs.map(Re=>Re.thread==="pull"?Sr("pull",Re):Sr("issue",Re)),...ue.linearIdentifiers.map(Ha)],[xe,ue]);Lu(it);const{groupStatusByKey:X,bootstrapSnapshot:le}=K4({childStores:U,sections:jt,chatGroup:he,canGrantAccess:Zd()});let Xe=null;C&&(Ne.some(Re=>Re.project.id===D)?Xe=D:Ne.some(Re=>Re.project.id===e.activeProjectId)?Xe=e.activeProjectId:Xe=Ne[0]?.project.id??null);const Ae=c.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:Ue,collapsedGroups:m.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:o,pinnedSessionIds:p.pinnedSessionIds,sessionOrderIndex:Bt,expandedParents:we,editingId:F,editingRowKey:ne,editTitle:te,sessionBatchSize:C&&!e.useGroupedSections?20:void 0,setEditingId:ee,setEditingRowKey:re,setEditTitle:K,toggleParent:Pe,allowReselect:a.allowReselect,onSessionSelected:a.onSessionSelected,resetSessionSearch:a.resetSessionSearch,deleteSessionConfirm:fe,setDeleteSessionConfirm:ce,startFolderRename:Ce,startSessionWorktreeMenuLoad:s.startSessionWorktreeMenuLoad,folderRename:ke,setFolderRenameDraft:Y,clearFolderRename:je}),[p.pinnedSessionIds,r,o,m.collapsedGroups,Ue,Bt,te,F,ne,we,ke,Y,je,Ce,fe,s.startSessionWorktreeMenuLoad,a,Pe,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,C]),Je=c.useMemo(()=>({showMoreGroupSessions:T,resetGroupSessionLimit:z,setActiveProjectIdOnly:l.setActiveProjectIdOnly,setSessionSwitcherOpen:l.setSessionSwitcherOpen,openNewSessionDraft:l.openNewSessionDraft,onToggleCollapsedGroup:v}),[z,T,v,l.openNewSessionDraft,l.setActiveProjectIdOnly,l.setSessionSwitcherOpen]),Fe=c.useMemo(()=>{const Re=new Map;for(const Ze of jt)for(const at of Ze.groups){const _t=Gn(Ze.project.id,at.directory);if(!_t)continue;const Vt=er(at),Ht=Re.get(_t),Oe=[...new Set([...Ht?.scopeKeys??[],...Vt.map(st=>st.scopeKey)])],ze=p.hasAuthoritativeGlobalSessions&&Vt.every(st=>{const Nt=ot(st.directory);return!Nt||U.getBootstrapState(Nt)==="complete"});Re.set(_t,{scopeKeys:Oe,complete:(Ht?.complete??!0)&&ze})}if(he){const Ze=Gn(null,he.directory);Ze&&Re.set(Ze,{scopeKeys:er(he).map(at=>at.scopeKey),complete:p.hasAuthoritativeGlobalSessions})}return Re},[le,he,U,p.hasAuthoritativeGlobalSessions,jt]),gt=c.useMemo(()=>new Map([...A,...R]),[R,A]),bt=c.useMemo(()=>Uj({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:I?"timeline":"projects",sections:jt,authoritativeSections:Ne,chatGroup:O?he:null,timelineItems:$t,workItems:pt,workSessionIds:ut,foldersMap:d,groupSearchDataByGroup:Ue,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:m.collapsedProjects,collapsedGroups:m.collapsedGroups,collapsedFolders:u,collapsedActivities:m.collapsedActivities,expandedParents:we,visibleCountByContainer:gt,pinnedSessionIds:p.pinnedSessionIds,sessionOrderIndex:Bt,groupStatusByKey:X,folderAuthorityByOwner:Fe,activeProjectId:e.activeProjectId,singleProjectMode:C&&!I,singleProjectId:Xe,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:C&&!e.useGroupedSections?20:void 0,runIndex:H}),[H,he,O,m.collapsedActivities,$t,I,pt,ut,u,p.pinnedSessionIds,we,Fe,d,Ue,X,jt,Ne,m.collapsedGroups,m.collapsedProjects,Xe,Bt,C,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,gt]);c.useEffect(()=>{Be(bt.searchMatchCount)},[Be,bt.searchMatchCount]),c.useEffect(()=>{if(e.hasSessionSearchQuery)return;const Re=Xt.getState().toggleFolderCollapse;for(const Ze of bt.rows)Ze.kind==="group-header"&&Ze.empty&&m.collapsedGroups.has(Ze.groupKey)?v(Ze.groupKey):Ze.kind==="folder-header"&&Ze.nodes.length===0&&Ze.subFolderCount===0&&u.has(Ze.folder.id)&&Re(Ze.folder.id)},[u,m.collapsedGroups,bt.rows,v,e.hasSessionSearchQuery]);const Et=c.useMemo(()=>({rowModel:bt,sectionsForRender:jt,projectSections:Ne,singleProjectMode:C,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:F,openSidebarMenuKey:q,setOpenSidebarMenuKey:oe,visibleSessionCountByGroup:A,collapsedActivityKeys:m.collapsedActivities,setCollapsedActivityKeys:x,visibleActivityCountByKey:R,setVisibleActivityCountByKey:E},groupProps:Ae}),[Ae,F,q,Ne,jt,bt,t.projectRepoStatus,e.emptyState,e.searchEmptyState,A,R,m.collapsedActivities,x,C]),Ft=c.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:ae}),[ae,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder]),es=c.useMemo(()=>({group:Je,toggleProject:S,setActiveProjectIdOnly:l.setActiveProjectIdOnly,setSessionSwitcherOpen:l.setSessionSwitcherOpen,openNewSessionDraft:l.openNewSessionDraft,openNewWorktreeDialog:l.openNewWorktreeDialog,openWorktreesPage:l.openWorktreesPage,openProjectEditDialog:l.openProjectEditDialog,removeProject:l.removeProject,reorderProjects:l.reorderProjects,setGroupOrderByProject:b,renderProjectStatusIndicator:l.renderProjectStatusIndicator,setSingleProjectId:Q}),[Je,l.openNewSessionDraft,l.openNewWorktreeDialog,l.openProjectEditDialog,l.openWorktreesPage,l.removeProject,l.reorderProjects,l.setActiveProjectIdOnly,l.setSessionSwitcherOpen,b,S,l.renderProjectStatusIndicator,Q]);return n.jsxs(n.Fragment,{children:[n.jsx(W2,{}),n.jsx(Z2,{projectSections:Ne,activeProjectId:e.activeProjectId,initialActiveSessionByProject:s.initialActiveSessionByProject,persistActiveSessionByProject:s.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:s.openNewSessionDraft,setSessionSwitcherOpen:s.setSessionSwitcherOpen,sessionOwnerBySessionId:P.bySessionId,handleSessionSelect:ie}),n.jsx(fC,{sortedSessions:p.orderedSessions,workSessions:rt,prefetchSession:G,children:n.jsxs(IC,{entries:bt.selectionEntries,descendantIds:bt.selectionDescendantIds,sessionsById:bt.sessionById,children:[n.jsx(R4,{getFolderScopesForProject:Ve,isInlineEditing:F!==null,startFolderRename:Ce}),n.jsx("div",{className:"contents",onPointerEnter:Re=>{Mt&&Re.pointerType==="mouse"&&St(xt.current)},onPointerLeave:()=>St(null),children:n.jsx(b4,{model:Et,view:Ft,actions:es})})]})})]})},n5=t=>{const e=He.c(3),[s,r]=c.useState(t.view.isVisible);t.view.isVisible&&!s&&r(!0);let o;return e[0]!==t||e[1]!==s?(o=s?n.jsx(s5,{...t}):null,e[0]=t,e[1]=s,e[2]=o):o=e[2],o},Zh=(t,e,s)=>{const r=new Set;for(const o of t){const i=ot(o.path);i&&r.add(i)}if(s?.includeWorktrees===!1)return r;for(const o of e.values())for(const i of o){const a=ot(i.path);a&&r.add(a)}return r},Td="oc.sessions.activeSessionByProject",r5=Ua(rn(),rn().min(1).catch("")),o5=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:s,allowReselect:r=!1,hideDirectoryControls:o=!1,showOnlyMainWorkspace:i=!1})=>{Ri("react.session_sidebar_render"),Ss("ui.session_sidebar.render"),Ss(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Ss(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:a}=wt(),[l,d]=c.useState(!1),[u,f]=c.useState(""),h=c.useCallback(()=>d(!0),[]),m=c.useCallback(()=>{f(""),d(!1)},[]),[g,b]=c.useState(0),v=c.useRef(null),S=c.useRef(null),[x,p]=c.useState(null),y=c.useMemo(()=>fo(),[]),[w,j]=c.useState(new Map),k=de(ue=>ue.isNewWorktreeDialogOpen),P=de(ue=>ue.setNewWorktreeDialogOpen),[A,B]=c.useState(!1),R=c.useMemo(()=>{try{const ue=y.getItem(Td);if(!ue)return new Map;const lt=r5.safeParse(JSON.parse(ue));if(!lt.success)return new Map;const ft=new Map;return Object.entries(lt.data).forEach(([mt,It])=>{It&&ft.set(mt,It)}),ft}catch{return new Map}},[y]),E=c.useCallback(ue=>{try{y.setItem(Td,JSON.stringify(Object.fromEntries(ue.entries())))}catch{}},[y]),[T,z]=c.useState(new Map),O=gs(ue=>ue.homeDirectory),W=Zt(ue=>ue.projects),D=Zt(ue=>ue.activeProjectId),Q=Zt(ue=>ue.removeProject),N=Zt(ue=>ue.setActiveProjectIdOnly),C=Zt(ue=>ue.updateProjectMeta),I=Zt(ue=>ue.reorderProjects),H=de(ue=>ue.setSettingsDialogOpen),M=de(ue=>ue.toggleHelpDialog),_=de(ue=>ue.setAboutDialogOpen),F=de(ue=>ue.setSessionSwitcherOpen),ee=de(ue=>ue.setWorktreesPageProjectId),ne=de(ue=>ue.notifyOnSubtasks),re=c.useMemo(()=>u.trim().toLowerCase(),[u]),te=re.length>0;Tj({enabled:t,isSessionSearchOpen:l,openSessionSearch:h,closeSessionSearch:m,sessionSearchInputRef:S,sessionSearchContainerRef:v});const K=xx(t),q=c.useMemo(()=>Sn(),[]),oe=nt(ue=>ue.worktreeMetadata),fe=nt(ue=>ue.availableWorktreesByProject),ce=nt(ue=>ue.openNewSessionDraft),ke=c.useMemo(()=>Zh(W,fe,{includeWorktrees:!q}),[fe,q,W]),De=c.useCallback(ue=>{de.getState().closeMainSurfaces(),ce(ue),q&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[q,ce]),Ce=pr(Zn(ue=>({checkForUpdates:ue.checkForUpdates,available:ue.available,runtimeType:ue.runtimeType,info:ue.info,downloading:ue.downloading,downloaded:ue.downloaded,installing:ue.installing,progress:ue.progress,error:ue.error,downloadUpdate:ue.downloadUpdate,restartToUpdate:ue.restartToUpdate}))),Y=Yt(),je=c.useMemo(()=>`${Y}|${W.map(ue=>`${ue.id}:${ot(ue.path)??""}`).join("|")}`,[W,Y]),[we,Pe]=c.useState(q?je:null),[L,ie]=c.useReducer(ue=>ue+1,0),G=!q&&we!==je,[ae,ge]=c.useState(new Set),me=c.useRef(ae);me.current=ae;const be=ns(ue=>ue.isConnected),ye=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let ue=!1;return(async()=>{const ft=Y,mt=ns.getState().isConnected,It=Zt.getState().projects;if(nt.setState({worktreeDiscoveryByProject:new Map(It.map(Fe=>[ot(Fe.path)??Fe.path,"loading"]))}),It.length===0||q){ue||(ye.current={runtimeKey:null,revision:0,worktreesByProject:new Map},ge(new Set),Pe(je));return}const xe=nt.getState().availableWorktreesByProject,it=al({rawWorktreesByProjectRef:ye,publishedWorktreesByProject:xe,runtimeKey:ft}),X=it.revision,le=new Map(it.worktreesByProject),Xe=new Set;if(await mr(()=>Promise.all(It.map(async Fe=>{const gt=ot(Fe.path);if(gt)try{if(!(gn.getState().directories.get(gt)?.isGitRepo??await xu(gt))){le.delete(gt);return}const Ft=await rc({id:Fe.id,path:gt});if(ue)return;Ft.length===0?le.delete(gt):le.set(gt,Ft)}catch{Xe.add(gt)}}))),ue||Yt()!==ft)return;const Ae=new Set(It.map(Fe=>ot(Fe.path)).filter(Boolean));for(const Fe of le.keys())Ae.has(Fe)||le.delete(Fe);YC({rawWorktreesByProjectRef:ye,runtimeKey:ft,capturedRevision:X,nextRawWorktreesByProject:le,publishedWorktreesByProject:xe,partitionWorktreesByRegisteredProject:nc,projects:It,worktreeMapsEqual:sc,recordWorktreesSeen:Ed,publishTopology:Fe=>{nt.setState(Fe)},requestRediscovery:()=>{ie()},now:()=>Date.now()})&&(ge(Xe),nt.setState({worktreeDiscoveryByProject:new Map(It.map(Fe=>{const gt=ot(Fe.path)??Fe.path;return[gt,Xe.has(gt)?"error":"ready"]}))}),Pe(je),Xe.size>0&&!mt&&ns.getState().isConnected&&ie())})(),()=>{ue=!0}},[q,je,Y,L]),c.useEffect(()=>{be&&me.current.size>0&&ie()},[be]);const Te=c.useMemo(()=>pn(),[]),{isTablet:$}=Mn(),he=e||$,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:a("sessions.sidebar.empty.noSessions.title")}),n.jsx("p",{className:"typography-meta mt-1",children:a("sessions.sidebar.empty.noSessions.description")})]}),[a]),Ne=c.useMemo(()=>W.find(ue=>ue.id===x)??null,[W,x]),Ue=c.useCallback(ue=>{x&&C(x,{label:ue.label,icon:ue.icon,color:ue.color,iconBackground:ue.iconBackground,defaultAgent:ue.defaultAgent??null,defaultModel:ue.defaultModel??null,defaultVariant:ue.defaultVariant??null})},[x,C]),We=c.useCallback(()=>{P(!0)},[P]),Ke=c.useCallback(()=>{const ue=pr.getState();if(ue.available&&ue.info){B(!0);return}Ce.checkForUpdates().then(()=>{const{available:lt,error:ft}=pr.getState();if(ft){_e.error(a("sessions.sidebar.updateCheck.errorTitle"),{description:ft});return}if(!lt){_e.success(a("sessions.sidebar.updateCheck.latestVersion"));return}B(!0)})},[a,Ce]),Be=c.useCallback(()=>{e&&F(!1),H(!0)},[e,F,H]),U=Ce.available&&(Ce.runtimeType==="desktop"||Ce.runtimeType==="web"),Me=c.useCallback(()=>{xn.requestDirectoryDialog()},[]),Ge=c.useMemo(()=>W.flatMap(ue=>{const lt=ot(ue.path);return lt?[{id:ue.id,path:ue.path,label:ue.label,normalizedPath:lt,icon:ue.icon??void 0,color:ue.color??void 0,iconImage:ue.iconImage??void 0,iconBackground:ue.iconBackground??void 0,addedAt:ue.addedAt,lastOpenedAt:ue.lastOpenedAt,sidebarCollapsed:ue.sidebarCollapsed}]:[]}),[W]),Ve=c.useMemo(()=>Ge.map(ue=>ue.normalizedPath),[Ge]),dt=Sx(Ve,t);s2({enabled:t,normalizedProjects:Ge,gitRepoStatus:dt,setProjectRepoStatus:j,setProjectRootBranches:z});const et=nt(ue=>ue.isLoading),ct=c.useRef(!1);D&&w.has(D)&&(ct.current=!!w.get(D));const pe=os(ue=>ue.showArchivedSessions),Ee=os(ue=>ue.projectSortOrder),qe=os(ue=>ue.sidebarViewMode),Ye=q?"projects":qe,$e=Ye==="timeline"?"manual":Ee,tt=Zt(ue=>ue.manualProjectOrder),ht={isVisible:t,mobileVariant:e,onSessionSelected:s,allowReselect:r,hideDirectoryControls:o,showOnlyMainWorkspace:i,t:a,isTablet:$,projects:W,activeProjectId:D,manualProjectOrder:tt,worktreeMetadata:oe,availableWorktreesByProject:fe,gitBranches:K,gitRepoStatus:dt,updateStore:Ce,showArchivedSessions:pe,projectSortOrder:$e,projectRepoStatus:w,projectRootBranches:T,resolvedWorktreeTopologyKey:we,unresolvedWorktreeProjectPaths:ae,isSessionSearchOpen:l,sessionSearchQuery:u,editingProjectDialogId:x,updateDialogOpen:A},vt=c.useRef(null),Bt=vt.current;if(Bt){let ue=!1;for(const lt of Object.keys(ht))Object.is(Bt[lt],ht[lt])||(Ss(`ui.session_sidebar.source.${lt}`),ue=!0);ue||Ss("ui.session_sidebar.source.parent_or_context")}vt.current=ht;const kt=c.useMemo(()=>Mg(Ge,$e,tt),[Ge,$e,tt]),St=Yj({isVSCode:q,projects:kt}),xt=c.useMemo(()=>n.jsx($2,{query:u,showArchive:!q,resetSessionSearch:m}),[q,m,u]),Mt=q&&pe,jt=!q,Kt=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",rt="h-4 w-4",ut=c.useMemo(()=>({projects:W,getCurrentProjects:()=>Zt.getState().projects,rawWorktreesByProjectRef:ye,getPublishedWorktreesByProject:()=>nt.getState().availableWorktreesByProject,resolveProject:ue=>Mi(ue),listProjectWorktrees:rc,partitionWorktreesByRegisteredProject:nc,worktreeMapsEqual:sc,recordWorktreesSeen:Ed,publishTopology:ue=>{nt.setState(ue)},getRuntimeKey:Yt,now:()=>Date.now()}),[W]),pt=c.useCallback(ue=>{const lt=Uh(ue,{projects:W,resolveProject:Mi});return qC(ue,{...ut,projectRootBranch:lt?T.get(lt.id)??null:null})},[T,W,ut]);return c.useEffect(()=>{if(q)return;const ue=lt=>{for(const ft of lt){const mt=ot(ft.path),It=Yt(),xe=it=>{!mt||Yt()!==It||nt.setState(X=>({worktreeDiscoveryByProject:new Map(X.worktreeDiscoveryByProject).set(mt,it)}))};xe("loading"),Vh(ft,null,ut).then(()=>{!mt||Yt()!==It||(xe("ready"),ge(it=>{if(!it.has(mt))return it;const X=new Set(it);return X.delete(mt),X}))}).catch(()=>{!mt||Yt()!==It||(xe("error"),ge(it=>new Set(it).add(mt)))})}};return wn(lt=>{if(lt.type==="session-created"){const ft=vx(lt.directory,Zt.getState().projects);if(!ft){ie();return}ue([ft]);return}lt.type==="worktree-changed"&&ue(wx(lt.directories))})},[q,ut]),n.jsx(Lo,{delay:400,closeDelay:0,timeout:300,children:n.jsxs("div",{ref:v,className:ve("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[n.jsx(f2,{hideDirectoryControls:o,showProjectDisplayControls:!q,showSectionControls:!q,handleOpenDirectoryDialog:Me,showSourceBoard:!e&&!q,headerActionIconClass:rt,headerActionButtonClass:Kt,isSessionSearchOpen:l,openSessionSearch:h,closeSessionSearch:m,sessionSearchInputRef:S,sessionSearchQuery:u,setSessionSearchQuery:f,hasSessionSearchQuery:te,searchMatchCount:g,collapseAll:St.actions.collapseAll,expandAll:St.actions.expandAll}),n.jsx(n5,{topology:{projects:kt,availableWorktreesByProject:fe,knownDirectories:ke,isVSCode:q,worktreeMetadata:oe,gitBranches:K,projectRepoStatus:w,projectRootBranches:T,lastRepoStatus:ct.current},view:{isVisible:t,hasSessionSearchQuery:te,normalizedSessionSearchQuery:re,activeProjectId:D,showInlineArchived:Mt,useGroupedSections:jt,homeDirectory:O,mobileVariant:e,hideDirectoryControls:o,showOnlyMainWorkspace:i,isDesktopShellRuntime:Te,projectSortOrder:$e,sidebarViewMode:Ye,emptyState:se,searchEmptyState:xt,isSessionsLoading:et,isWorktreeTopologyLoading:G,unresolvedWorktreeProjectPaths:ae,projectView:St.state,onSearchMatchCountChange:b},actions:{rowActions:{allowReselect:r,onSessionSelected:s,resetSessionSearch:m},alwaysShowActions:he,notifyOnSubtasks:ne,setActiveProjectIdOnly:N,setSessionSwitcherOpen:F,openNewSessionDraft:De,openNewWorktreeDialog:We,openWorktreesPage:ue=>{e&&F(!1),ee(ue)},openProjectEditDialog:p,removeProject:Q,reorderProjects:I,startSessionWorktreeMenuLoad:pt,initialActiveSessionByProject:R,persistActiveSessionByProject:E,projectViewActions:St.actions}}),n.jsx(L2,{onOpenSettings:Be,onOpenShortcuts:M,onOpenAbout:()=>_(!0),onOpenUpdate:Ke,showRuntimeButtons:!q,showUpdateButton:U}),n.jsx(ka,{open:A,onOpenChange:B,info:Ce.info,downloading:Ce.downloading,downloaded:Ce.downloaded,installing:Ce.installing,progress:Ce.progress,error:Ce.error,onDownload:Ce.downloadUpdate,onRestart:Ce.restartToUpdate,runtimeType:Ce.runtimeType}),n.jsx(c2,{open:!!Ne,onOpenChange:ue=>{ue||p(null)},project:Ne,onSave:Ue}),n.jsx(kx,{open:k,onOpenChange:P,onWorktreeCreated:ue=>{de.getState().closeMainSurfaces(),e&&F(!1),ce({directoryOverride:ue,preserveDirectoryOverride:!0})}})]})})},i5=c.memo(o5),Qs=t=>t?n.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,Os=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},a5=()=>{const{t}=wt(),{git:e,sourceControl:s}=Ws(),[r,o]=c.useState(!1),[i,a]=c.useState(null),[l,d]=c.useState([]),[u,f]=c.useState(!1),[h,m]=c.useState(!1),[g,b]=c.useState(!1),[v,S]=c.useState(!1),[x,p]=c.useState(new Set),y=nt(G=>G.getWorktreeMetadata),w=nt(G=>G.newSessionDraft),j=nt(G=>G.setNewSessionDraftTarget),k=nt(G=>G.setDraftBootstrapPendingDirectory),P=jx,A=Px,B=nt(G=>G.deleteSessions),R=nt(G=>G.archiveSessions),E=de(G=>G.showDeletionDialog),T=de(G=>G.setShowDeletionDialog),z=gs(G=>G.currentDirectory),O=gs(G=>G.homeDirectory),W=Zt(G=>G.projects),D=Zt(G=>G.activeProjectId),{isMobile:Q,isTablet:N,hasTouchInput:C}=Mn(),I=Q||N||C,H=c.useMemo(()=>{const ae=(D?W.find(ge=>ge.id===D)??null:null)?.path??z;return Os(ae)},[D,z,W]),M=c.useCallback(G=>{const ge=Os(G.projectDirectory)||H;return{id:(W.find(be=>Os(be.path)===ge)??null)?.id??`path:${ge}`,path:ge}},[H,W]),_=v&&x.size>0,F=c.useMemo(()=>{const G=i?.worktree;return G&&typeof G.branch=="string"&&G.branch.trim().length>0?!!G.status?.upstream?.split("/")[0]?.trim():l.length>0&&l.every(({metadata:ae})=>typeof ae.branch=="string"&&ae.branch.trim().length>0&&!!ae.status?.upstream?.split("/")[0]?.trim())},[i?.worktree,l]),ee=i?.mode==="worktree",ne=g||!ee||!F,re=g||!ee,te=c.useCallback(G=>{a({sessions:G.sessions,dateLabel:G.dateLabel,mode:G.mode??"session",worktree:G.worktree??null})},[]),K=c.useCallback(()=>{a(null),d([]),f(!1),m(!1),b(!1),S(!1),p(new Set)},[]),q=c.useCallback(async G=>{if(G.sessions.length===0)return;if(G.sessions.length===1){const be=G.sessions[0];await P(be.id)?_e.success(t("sessions.sidebar.session.delete.success")):_e.error(t("sessions.sidebar.session.delete.error"));return}const ae=G.sessions.map(be=>be.id),{deletedIds:ge,failedIds:me}=await B(ae);if(ge.length>0){const be=me.length>0?me.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:me.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:me.length}):G.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:G.dateLabel}):void 0;_e.success(ge.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ge.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ge.length}),{description:Qs(be)})}me.length>0&&_e.error(me.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:me.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:me.length}),{description:Qs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[P,B,t]);c.useEffect(()=>xn.onDirectoryRequest(()=>{o(!0)}),[]),c.useEffect(()=>{if(!i){d([]),f(!1),m(!1),S(!1),p(new Set);return}const G=i.sessions.map(me=>{const be=y(me.id);return be?{session:me,metadata:be}:null}).filter(me=>!!me);d(G),f(!1),S(!1),p(new Set);const ae=new Map;if(i.worktree?.path&&ae.set(Os(i.worktree.path),i.worktree),G.forEach(({metadata:me})=>{me.path&&ae.set(Os(me.path),me)}),ae.size===0){S(!0);return}let ge=!1;return(async()=>{const me=new Map,be=new Set;await Promise.all(Array.from(ae.entries()).map(async([ye,Te])=>{try{const $=await oc(Te.path);me.set(ye,$),$?.isDirty&&be.add(ye)}catch{Te.status&&(me.set(ye,Te.status),Te.status.isDirty&&be.add(ye))}})).catch(ye=>{console.warn("Failed to inspect worktree status before deletion:",ye)}),!ge&&(p(be),S(!0),a(ye=>{if(!ye?.worktree?.path)return ye;const Te=Os(ye.worktree.path),$=me.get(Te);if(!$)return ye;const he=ye.worktree.status;return he?.isDirty===$.isDirty&&he?.ahead===$.ahead&&he?.behind===$.behind&&he?.upstream===$.upstream?ye:{...ye,worktree:{...ye.worktree,status:$}}}),d(ye=>ye.map(Te=>{const $=Os(Te.metadata.path),he=me.get($);return he?{session:Te.session,metadata:{...Te.metadata,status:he}}:Te})))})(),()=>{ge=!0}},[i,y]),c.useEffect(()=>{F||f(!1)},[F]);const oe=c.useCallback(async(G,ae,ge)=>{const me=u&&F,be=M(G),ye=Os(G.path),Te=Os(be.path);try{await Su(be,G,{deleteRemoteBranch:me,deleteLocalBranch:ae,remoteName:G.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s}});const $=Os(w?.directoryOverride);return w?.open&&ye&&$===ye&&Te&&(k(null),j({projectId:be.id,directoryOverride:Te},{force:!0})),Os(z)===ye&&Te&&gs.getState().setDirectory(Te,{showOverlay:!1}),!0}catch($){return _e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:di(G)}),{id:ge,description:Qs($ instanceof Error?$.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[F,z,u,M,e,w?.directoryOverride,w?.open,k,j,s,t]),fe=c.useCallback((G,ae,ge)=>{const me=u&&F,be=_e.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:di(G)}));return Cx(G.path),(async()=>{try{const ye=await Ag({sessionIds:ae,removeWorktree:()=>oe(G,ge,be),archiveSessions:async he=>he.length===1?await A(he[0])?{archivedIds:he,failedIds:[]}:{archivedIds:[],failedIds:he}:R(he)});if(!ye.removed)return;const Te=t(me?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");_e.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:di(G)}),{id:be,description:Qs(Te)});const{failedIds:$}=ye.archive;$.length>0&&_e.error($.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:$.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:$.length}),{description:Qs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(ye){_e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:be,description:Qs(ye instanceof Error?ye.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{Ex(G.path)}})()},[A,R,F,u,oe,t]),ce=c.useRef(new Set),ke=c.useCallback(async(G,ae)=>{const ge=Os(G.path);if(!ce.current.has(ge)){ce.current.add(ge);try{const me=await oc(G.path).catch(()=>{});if(!Nx(me)){te({sessions:ae,mode:"worktree",worktree:G});return}await fe(G,ae.map(be=>be.id),!0)}finally{ce.current.delete(ge)}}},[te,fe]);c.useEffect(()=>xn.onDeleteRequest(G=>{if(!E&&(G.mode??"session")==="session"){q(G);return}if(G.mode==="worktree"&&G.skipDialogIfSafe&&G.worktree){ke(G.worktree,G.sessions);return}te(G)}),[te,E,q,ke]);const De=c.useCallback(async()=>{if(i){b(!0);try{if(ee){const G=i.worktree??l[0]?.metadata;if(!G){_e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Qs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),b(!1);return}fe(G,i.sessions.map(ae=>ae.id),h),K();return}if(i.sessions.length===1){const G=i.sessions[0];if(!await P(G.id)){_e.error(t("sessions.sidebar.session.delete.error")),b(!1);return}_e.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const G=i.sessions.map(me=>me.id),{deletedIds:ae,failedIds:ge}=await B(G);if(ae.length>0){const me=ge.length>0?ge.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ge.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ge.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;_e.success(ae.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ae.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ae.length}),{description:Qs(me),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(ge.length>0&&(_e.error(ge.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ge.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ge.length}),{description:Qs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ae.length===0)){b(!1);return}}K()}finally{b(!1)}}},[i,l,h,P,B,K,ee,fe,t]),Ce=i?.worktree??l[0]?.metadata??null;let Y="";if(i?.mode==="worktree"){const G=i.sessions.length;G===0?Y=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):G===1?Y=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:G}):Y=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:G})}else if(i){const G=i.sessions.length;G===1?Y=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):Y=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:G,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:G})}const je=i?n.jsxs("div",{className:ve(ee?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&n.jsxs("div",{className:ve(ee?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[ee&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:i.sessions.length})]}),n.jsxs("ul",{className:ve(ee?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(G=>n.jsxs("li",{className:ve(ee?"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:ve(!ee&&"hidden"),children:"•"}),n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:G.title||t("sessions.sidebar.session.untitled")})]},G.id)),i.sessions.length>5&&n.jsx("li",{className:ve(ee?"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:i.sessions.length-5})})]})]}),ee?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(Z,{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")}),Ce?.label?n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:Ce.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:Ce?Qn(Ce.path,O):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),_&&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,we=ee?F?n.jsxs("button",{type:"button",onClick:()=>{ne||f(G=>!G)},disabled:ne,"aria-pressed":u,className:ve("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ne?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[u?n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(Z,{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,Pe=ee?n.jsxs("button",{type:"button",onClick:()=>{re||m(G=>!G)},disabled:re,"aria-pressed":h,className:ve("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",re?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[h?n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(Z,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,L=ee?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:[Pe,we]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ct,{variant:"ghost",onClick:K,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Ct,{variant:"destructive",onClick:De,disabled:g,children:t(g?"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:()=>T(!E),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":!E,children:[E?n.jsx(Z,{name:"checkbox-blank",className:"size-4"}):n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ct,{variant:"ghost",onClick:K,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Ct,{variant:"destructive",onClick:De,disabled:g,children:g?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),ie=ee?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[I?n.jsx(Ix,{open:!!i,onClose:()=>{g||K()},title:ie,footer:n.jsx("div",{className:"flex justify-end gap-2",children:L}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[Y&&n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:Y}),je]})}):n.jsx(zs,{open:!!i,onOpenChange:G=>{if(!G){if(g)return;K()}},children:n.jsxs($s,{className:ve(ee?"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(qs,{children:[n.jsxs(Gs,{className:ve(ee&&"flex items-center gap-2"),children:[ee&&n.jsx(Z,{name:"delete-bin",className:"h-5 w-5"}),ie]}),Y&&n.jsx(Us,{children:Y})]}),n.jsx("div",{className:ve(ee&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:je}),n.jsx(yn,{className:"mt-2 gap-2 pt-1 pb-1",children:L})]})}),n.jsx(Og,{open:r,onOpenChange:o})]})};function Yo(t,e,s){const[r,o]=c.useState(null),i=c.useRef(s);return i.current=s,c.useEffect(()=>{if(!t||r)return;let a=!1;return Rx(e).then(l=>{a||o(()=>l)},l=>{console.error("[on-demand] failed to load component",l),a||i.current()}),()=>{a=!0}},[r,e,t]),r}function l5(t){const e=[],s=(r,o)=>{const i=ot(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const c5=new Map,d5=t=>{const e=He.c(23),{isVSCode:s}=t,r=Er(),o=Zt(u5),i=gs(f5),a=nt(h5);let l;e[0]!==s?(l=B=>s?c5:B.availableWorktreesByProject,e[0]=s,e[1]=l):l=e[1];const d=nt(l),u=!s;let f;e[2]!==d||e[3]!==o||e[4]!==u?(f=Zh(o,d,{includeWorktrees:u}),e[2]=d,e[3]=o,e[4]=u,e[5]=f):f=e[5];const h=f,m=ws(p5),g=ws(m5),b=ws(g5),v=`session-list-sync:${c.useId()}`;let S,x;e[6]!==v||e[7]!==r||e[8]!==i||e[9]!==a?(S=()=>(r.setBootstrapDemand(v,l5({currentDirectory:i,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(v)),x=[v,r,i,a],e[6]=v,e[7]=r,e[8]=i,e[9]=a,e[10]=S,e[11]=x):(S=e[10],x=e[11]),c.useEffect(S,x);const p=c.useRef(null);let y,w;e[12]!==s||e[13]!==h?(y=()=>{const B=new Set(h),R=p.current;p.current=B;const E=R?[...B].filter(T=>!R.has(T)):s?[...B]:[];E.length&&Ea(E,zi())},w=[s,h],e[12]=s,e[13]=h,e[14]=y,e[15]=w):(y=e[14],w=e[15]),c.useEffect(y,w);let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[16]=j):j=e[16],c.useEffect(b5,j);let k;e[17]!==g||e[18]!==m?(k=[...m,...g],e[17]=g,e[18]=m,e[19]=k):k=e[19];const P=k;let A;e[20]!==P||e[21]!==b?(A={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:P},e[20]=P,e[21]=b,e[22]=A):A=e[22],Bg(A)};function u5(t){return t.projects}function f5(t){return t.currentDirectory}function h5(t){return t.currentSessionDirectory}function p5(t){return t.activeSessions}function m5(t){return t.archivedSessions}function g5(t){return t.status==="ready"}function b5(){let t=null,e=!1;const s=new Set,r=wn(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")s.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,s.clear(),mf(zi());return}const i=[...s];s.clear(),i.length&&Ea(i,zi())},500)});return()=>{t&&clearTimeout(t),r()}}const y5=()=>ss(()=>import("./SettingsWindow-X74FIkdo.js"),__vite__mapDeps([142,1,2,9,3,4,5,6,7,8,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,143,83,144,125,126,127,128,119,120,105,106,90,91,92,93,94,95,96,97,98,99,100,101,102,103,145,146,147,132,148])).then(t=>t.SettingsWindow),x5=()=>ss(()=>import("./CommandPalette-1VlA7PbL.js"),__vite__mapDeps([149,1,2,9,3,4,5,6,7,8,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,148,83,121,122,123])).then(t=>t.CommandPalette),S5=()=>ss(()=>import("./HelpDialog-CITMqPDK.js"),__vite__mapDeps([150,1,2,9,3,4,5,6,7,8,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=>t.HelpDialog),v5=()=>ss(()=>import("./OpenCodeStatusDialog-YMHuJzwt.js"),__vite__mapDeps([151,1,2,9,3,4,5,6,7,8,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=>t.OpenCodeStatusDialog),w5=()=>ss(()=>import("./RunOverview-CHkGSW1x.js"),__vite__mapDeps([152,1,2,9,3,4,5,6,7,8,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])).then(t=>t.RunOverview),k5=()=>ss(()=>import("./ScheduledTasksDialog-77SO8zdJ.js"),__vite__mapDeps([153,1,2,9,3,4,5,6,7,8,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,140,154,155])).then(t=>t.ScheduledTasksDialog),j5=()=>ss(()=>import("./ArchiveView-CjF4_TFg.js"),__vite__mapDeps([156,1,2,9,3,4,5,6,7,8,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])).then(t=>t.ArchiveView),C5=()=>ss(()=>import("./UsageStatsView-DwTt9zIz.js"),__vite__mapDeps([157,1,2,9,3,4,5,6,7,8,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=>t.UsageStatsView),P5=()=>ss(()=>import("./SourceBoardView-Cff2ejOW.js"),__vite__mapDeps([158,1,2,9,3,4,5,6,7,8,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])).then(t=>t.SourceBoardView),E5=()=>ss(()=>import("./WorktreesView-Bh7GLvrR.js"),__vite__mapDeps([159,1,2,9,3,4,5,6,7,8,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=>t.WorktreesView),N5=()=>ss(()=>import("./SpacesView-I3HaRKtW.js"),__vite__mapDeps([160,1,2,9,3,4,5,6,7,8,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,161,83])).then(t=>t.SpacesView),I5=()=>ss(()=>import("./SpaceAccessDialog-BXMZNRei.js"),__vite__mapDeps([162,1,2,9,3,4,5,6,7,8,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,163])).then(t=>t.SpaceAccessDialog),R5=()=>ss(()=>import("./SpaceApplyDialog-BEJd2ryu.js"),__vite__mapDeps([164,1,2,9,3,4,5,6,7,8,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,165])).then(t=>t.SpaceApplyDialog),D5=()=>ss(()=>import("./SpaceSetupOutput-Cb3XcIII.js"),__vite__mapDeps([166,1,2,9,3,4,5,6,7,8,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,163])).then(t=>t.SpaceSetupOutputDialog),Pn=()=>de.getState().closeMainSurfaces(),Es=t=>{const e=He.c(2),{needed:s,load:r,onFailure:o}=t,i=Yo(s,r,o);let a;return e[0]!==i?(a=i?n.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},Jh=c.memo(t=>{const e=He.c(7),{isMobile:s}=t,r=de(M5);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(xS,{}),e[0]=o):o=e[0];let i;e[1]!==r?(i=n.jsx(i5,{isVisible:r}),e[1]=r,e[2]=i):i=e[2];let a;return e[3]!==s||e[4]!==r||e[5]!==i?(a=n.jsx(yS,{isOpen:r,isMobile:s,className:"border-border",topBar:o,children:i}),e[3]=s,e[4]=r,e[5]=i,e[6]=a):a=e[6],a});Jh.displayName="LeftSidebar";const T5=()=>{const t=He.c(101);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],d5(e),Fg();const s=de(A5),r=de(O5),o=de(B5),i=de(F5);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const l=Yo(o,y5,a),d=de(L5),u=de(_5),f=de($5),h=de(z5),m=de(W5),g=de(K5),b=de(H5),v=de(V5),S=de(G5),x=de(U5),p=_s(q5),y=_s(Y5),w=_s(X5),j=de(Q5),k=Xu();let P;if(t[3]!==k||t[4]!==j){let Me;t[6]!==j?(Me=Ge=>Ge.id===j,t[6]=j,t[7]=Me):Me=t[7],P=k.find(Me),t[3]=k,t[4]=j,t[5]=P}else P=t[5];const A=P;let B,R;t[8]!==A||t[9]!==j?(B=()=>{j&&!A&&de.getState().setOpenGuestPage(null)},R=[j,A],t[8]=A,t[9]=j,t[10]=B,t[11]=R):(B=t[10],R=t[11]),c.useEffect(B,R);let E;t[12]===Symbol.for("react.memo_cache_sentinel")?(E=[],t[12]=E):E=t[12],c.useEffect(J5,E);let T;t[13]===Symbol.for("react.memo_cache_sentinel")?(T=[],t[13]=T):T=t[13],c.useEffect(eP,T);const z=u||f||h||m||!!g||b||d||!!A;let O,W;t[14]!==z?(O=()=>{gf(z)},W=[z],t[14]=z,t[15]=O,t[16]=W):(O=t[15],W=t[16]),c.useLayoutEffect(O,W);let D;t[17]===Symbol.for("react.memo_cache_sentinel")?(D=[],t[17]=D):D=t[17],c.useEffect(sP,D);let Q;t[18]===Symbol.for("react.memo_cache_sentinel")?(Q=[],t[18]=Q):Q=t[18],c.useEffect(rP,Q);const{isMobile:N}=Mn();Lg();let C,I;t[19]!==N||t[20]!==r?(C=()=>{de.getState().isMobile!==N&&r(N)},I=[N,r],t[19]=N,t[20]=r,t[21]=C,t[22]=I):(C=t[21],I=t[22]),c.useEffect(C,I);let H;t[23]!==v?(H=n.jsx(Es,{needed:v,load:x5,onFailure:oP}),t[23]=v,t[24]=H):H=t[24];let M;t[25]!==S?(M=n.jsx(Es,{needed:S,load:S5,onFailure:iP}),t[25]=S,t[26]=M):M=t[26];let _;t[27]!==x?(_=n.jsx(Es,{needed:x,load:v5,onFailure:aP}),t[27]=x,t[28]=_):_=t[28];let F,ee;t[29]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(_g,{}),ee=n.jsx(a5,{}),t[29]=F,t[30]=ee):(F=t[29],ee=t[30]);let ne;t[31]!==p||t[32]!==y||t[33]!==w||t[34]!==s?(ne=s?n.jsxs(n.Fragment,{children:[n.jsx(Es,{needed:p,load:I5,onFailure:lP}),n.jsx($g,{}),n.jsx(Es,{needed:y,load:R5,onFailure:cP}),n.jsx(zg,{}),n.jsx(Es,{needed:w,load:D5,onFailure:dP})]}):null,t[31]=p,t[32]=y,t[33]=w,t[34]=s,t[35]=ne):ne=t[35];let re;t[36]===Symbol.for("react.memo_cache_sentinel")?(re=n.jsx(SS,{}),t[36]=re):re=t[36];let te;t[37]!==N?(te=n.jsx(Jh,{isMobile:N}),t[37]=N,t[38]=te):te=t[38];let K;t[39]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(bS,{}),t[39]=K):K=t[39];let q;t[40]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx(yi,{zone:"left"}),t[40]=q):q=t[40];const oe=z&&"invisible";let fe;t[41]!==oe?(fe=ve("absolute inset-0",oe),t[41]=oe,t[42]=fe):fe=t[42];const ce=!o&&!z;let ke;t[43]!==ce?(ke=n.jsx(bs,{children:n.jsx(au,{active:ce})}),t[43]=ce,t[44]=ke):ke=t[44];let De;t[45]!==fe||t[46]!==ke?(De=n.jsx("div",{className:fe,children:ke}),t[45]=fe,t[46]=ke,t[47]=De):De=t[47];let Ce;t[48]!==d?(Ce=n.jsx(bs,{children:n.jsx(Es,{needed:d,load:w5,onFailure:Pn})}),t[48]=d,t[49]=Ce):Ce=t[49];let Y;t[50]!==u?(Y=n.jsx(bs,{children:n.jsx(Es,{needed:u,load:k5,onFailure:Pn})}),t[50]=u,t[51]=Y):Y=t[51];let je;t[52]!==f?(je=n.jsx(bs,{children:n.jsx(Es,{needed:f,load:j5,onFailure:Pn})}),t[52]=f,t[53]=je):je=t[53];let we;t[54]!==h?(we=h&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(bs,{children:n.jsx(Es,{needed:!0,load:C5,onFailure:Pn})})}),t[54]=h,t[55]=we):we=t[55];let Pe;t[56]!==m?(Pe=n.jsx(Es,{needed:m,load:P5,onFailure:Pn}),t[56]=m,t[57]=Pe):Pe=t[57];const L=!!g;let ie;t[58]!==L?(ie=n.jsx(bs,{children:n.jsx(Es,{needed:L,load:E5,onFailure:Pn})}),t[58]=L,t[59]=ie):ie=t[59];let G;t[60]!==b?(G=b?n.jsx(bs,{children:n.jsx(Es,{needed:!0,load:N5,onFailure:Pn})}):null,t[60]=b,t[61]=G):G=t[61];let ae;t[62]!==A?(ae=A&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(bs,{children:n.jsx(Dx,{mode:`plugin:${A.id}`,surface:"page",item:null,onDismiss:uP})})}),t[62]=A,t[63]=ae):ae=t[63];let ge;t[64]!==De||t[65]!==Ce||t[66]!==Y||t[67]!==je||t[68]!==we||t[69]!==Pe||t[70]!==ie||t[71]!==G||t[72]!==ae?(ge=n.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[De,Ce,Y,je,we,Pe,ie,G,ae]}),t[64]=De,t[65]=Ce,t[66]=Y,t[67]=je,t[68]=we,t[69]=Pe,t[70]=ie,t[71]=G,t[72]=ae,t[73]=ge):ge=t[73];let me;t[74]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx(yi,{zone:"bottom"}),t[74]=me):me=t[74];let be;t[75]!==ge?(be=n.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[ge,me]}),t[75]=ge,t[76]=be):be=t[76];let ye,Te,$,he;t[77]===Symbol.for("react.memo_cache_sentinel")?(ye=n.jsx(yi,{zone:"right"}),Te=n.jsx(Vk,{}),$=n.jsx(qk,{}),he=n.jsx(Zk,{}),t[77]=ye,t[78]=Te,t[79]=$,t[80]=he):(ye=t[77],Te=t[78],$=t[79],he=t[80]);let se;t[81]!==be?(se=n.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[q,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:[be,ye,Te,$,he]})]})}),t[81]=be,t[82]=se):se=t[82];let Ne;t[83]===Symbol.for("react.memo_cache_sentinel")?(Ne=n.jsx("div",{"data-page-scroll-lock":"true",children:n.jsx(bs,{children:n.jsx(mj,{})})}),t[83]=Ne):Ne=t[83];let Ue;t[84]===Symbol.for("react.memo_cache_sentinel")?(Ue=n.jsx(bs,{children:n.jsx(f1,{})}),t[84]=Ue):Ue=t[84];let We;t[85]!==se?(We=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[K,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[se,Ne,Ue]})]}),t[85]=se,t[86]=We):We=t[86];let Ke;t[87]!==te||t[88]!==We?(Ke=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[te,We]}),t[87]=te,t[88]=We,t[89]=Ke):Ke=t[89];let Be;t[90]!==l||t[91]!==o||t[92]!==i?(Be=l?n.jsx(l,{open:o,onOpenChange:i}):null,t[90]=l,t[91]=o,t[92]=i,t[93]=Be):Be=t[93];let U;return t[94]!==H||t[95]!==M||t[96]!==_||t[97]!==ne||t[98]!==Ke||t[99]!==Be?(U=n.jsx(Wg,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[H,M,_,F,ee,ne,re,Ke,Be]})}),t[94]=H,t[95]=M,t[96]=_,t[97]=ne,t[98]=Ke,t[99]=Be,t[100]=U):U=t[100],U};function M5(t){return t.isSidebarOpen}function A5(t){return t.isolatedSpacesEnabled}function O5(t){return t.setIsMobile}function B5(t){return t.isSettingsDialogOpen}function F5(t){return t.setSettingsDialogOpen}function L5(t){return t.runOverviewKey!==null}function _5(t){return t.isScheduledTasksDialogOpen}function $5(t){return t.isArchivePageOpen}function z5(t){return t.isUsageStatsPageOpen}function W5(t){return t.isSourceBoardOpen}function K5(t){return t.worktreesPageProjectId}function H5(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function V5(t){return t.isCommandPaletteOpen}function G5(t){return t.isHelpDialogOpen}function U5(t){return t.isOpenCodeStatusDialogOpen}function q5(t){return t.accessDialog!==null}function Y5(t){return t.applyDialog!==null}function X5(t){return t.setupOutputDialog!==null}function Q5(t){return t.openGuestPageId}function Z5(){return de.getState().setOpenGuestPage(null)}function J5(){return No(Z5)}function eP(){return u1()}function tP(){return gf(!1)}function sP(){return tP}function nP(){return de.getState().closeMainSurfaces()}function rP(){const t=nP,e=nt.subscribe((s,r)=>{const o=!!s.currentSessionId&&s.currentSessionId!==r.currentSessionId,i=!!s.newSessionDraft?.open&&s.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function oP(){return de.getState().setCommandPaletteOpen(!1)}function iP(){return de.getState().setHelpDialogOpen(!1)}function aP(){return de.getState().setOpenCodeStatusDialogOpen(!1)}function lP(){return _s.getState().closeAccessDialog()}function cP(){return _s.getState().closeApplyDialog()}function dP(){return _s.getState().closeSetupOutputDialog()}function uP(){return de.getState().setOpenGuestPage(null)}const ep=12,fP=[{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"}],hP=t=>{const e=He.c(18),{isActive:s,burstKey:r,className:o,durationMs:i,bursts:a,onComplete:l}=t,d=r===void 0?0:r,u=i===void 0?900:i,f=a===void 0?fP:a,h=ds.useRef(!1);let m,g;e[0]!==s||e[1]!==l?(m=()=>{!s&&h.current&&l?.(),s&&(h.current=!0)},g=[s,l],e[0]=s,e[1]=l,e[2]=m,e[3]=g):(m=e[2],g=e[3]),ds.useEffect(m,g);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:ep},pP),e[4]=b):b=e[4];const v=b;if(!s)return null;let S;e[5]!==o?(S=ve("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=S):S=e[6];let x;if(e[7]!==d||e[8]!==f||e[9]!==u){let y;e[11]!==d||e[12]!==u?(y=w=>{const j={"--burst-delay":`${w.delay}ms`,"--burst-x":`${w.x}%`,"--burst-y":`${w.y}%`,"--firework-color":`var(${w.colorVar})`,"--firework-duration":`${u}ms`};return n.jsx("div",{className:"firework-burst",style:j,children:v.map((k,P)=>{const A=k.x*w.radius,B=k.y*w.radius,R={"--translate-x":`${A}px`,"--translate-y":`${B}px`,"--particle-delay":`${k.delay}ms`,color:`var(${w.colorVar})`};return n.jsx("span",{className:"firework-particle",style:R},`${w.id}-${P}-${d}`)})},`${w.id}-${d}`)},e[11]=d,e[12]=u,e[13]=y):y=e[13],x=f.map(y),e[7]=d,e[8]=f,e[9]=u,e[10]=x}else x=e[10];let p;return e[14]!==d||e[15]!==S||e[16]!==x?(p=n.jsx("div",{className:S,"aria-hidden":"true","data-burst-key":d,children:x}),e[14]=d,e[15]=S,e[16]=x,e[17]=p):p=e[17],p};function pP(t,e){const s=Math.PI*2*e/ep;return{x:Math.cos(s),y:Math.sin(s),delay:e*18}}const mP=t=>{const e=He.c(13);let s;e[0]!==t?(s={},e[0]=t,e[1]=s):s=e[1];const{durationMs:r}=s,o=r===void 0?3400:r;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={isActive:!1,cycle:0},e[2]=i):i=e[2];const[a,l]=ds.useState(i),d=ds.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 h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{f(),l(gP)},e[4]=h):h=e[4];const m=h;let g;e[5]!==o?(g=()=>{f(),l(bP),d.current=window.setTimeout(()=>{l(yP),d.current=null},o)},e[5]=o,e[6]=g):g=e[6];const b=g;let v,S;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>f(),S=[f],e[7]=v,e[8]=S):(v=e[7],S=e[8]),ds.useEffect(v,S);let x;return e[9]!==a.cycle||e[10]!==a.isActive||e[11]!==b?(x={isActive:a.isActive,burstKey:a.cycle,triggerFireworks:b,dismissFireworks:m},e[9]=a.cycle,e[10]=a.isActive,e[11]=b,e[12]=x):x=e[12],x};function gP(t){return t.isActive?{...t,isActive:!1}:t}function bP(t){return{isActive:!0,cycle:t.cycle+1}}function yP(t){return t.isActive?{...t,isActive:!1}:t}const tp=c.createContext(void 0),xP=t=>{const e=He.c(10),{children:s}=t,{isActive:r,burstKey:o,triggerFireworks:i,dismissFireworks:a}=mP();let l;e[0]!==a||e[1]!==i?(l={triggerFireworks:i,dismissFireworks:a},e[0]=a,e[1]=i,e[2]=l):l=e[2];const d=l;let u;e[3]!==o||e[4]!==r?(u=n.jsx(hP,{isActive:r,burstKey:o}),e[3]=o,e[4]=r,e[5]=u):u=e[5];let f;return e[6]!==s||e[7]!==u||e[8]!==d?(f=n.jsxs(tp.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f},YE=()=>{const t=c.useContext(tp);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},pa="openchamber_requests_in_flight",sp=1e3,SP=300*1e3,Eo=Math.ceil(SP/sp),vP=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(pa)==="1"}catch{return!1}},np=()=>({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 wP=1;const kP=(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))},jP=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},rp=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,o)=>r-o),s},qn=(t,e)=>{const s=t.length;if(s===0)return 0;if(s===1)return t[0];const r=e/100*(s-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},CP=()=>{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,o)=>{const i=wP++;kP(i,Date.now());try{return await e(r,o)}finally{jP(i)}};window.fetch=s},Md=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},ur=t=>{t.length>Eo&&t.splice(0,t.length-Eo)},PP=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=rp(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(qn(e,50)),t.p90Samples.push(qn(e,90)),t.p99Samples.push(qn(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,ur(t.samples),ur(t.p50Samples),ur(t.p90Samples),ur(t.p99Samples),ur(t.maxSamples),t.lastSampleAt=Date.now()},EP=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(PP,sp))},Ad=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Od=t=>{if(!(typeof window>"u"))try{if(t){Ad(),Md(),window.localStorage.setItem(pa,"1"),window.__openchamberRequestsInFlight__=np(),CP(),EP();return}window.localStorage.removeItem(pa),Ad(),Md(),delete window.__openchamberRequestsInFlight__}catch{}},XE=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=np();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},QE=()=>{if(typeof window>"u")return Bd();const t=window.__openchamberRequestsInFlight__;if(!vP()||!t)return Bd();const e=rp(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:qn(e,50),ageP90:qn(e,90),ageP99:qn(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:Eo}},Bd=()=>({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:Eo}),NP=()=>{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()??"":""},IP=async()=>{const t=NP()||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")},Fd="openchamber:menu-action",Ni="openchamber:check-for-updates",RP=t=>{const e=nt(x=>x.openNewSessionDraft),s=de(x=>x.toggleCommandPalette),r=de(x=>x.setCommandPaletteOpen),o=de(x=>x.toggleHelpDialog),i=de(x=>x.toggleSidebar),a=de(x=>x.setSessionSwitcherOpen),l=de(x=>x.setSettingsDialogOpen),d=de(x=>x.setAboutDialogOpen),u=pr(x=>x.checkForUpdates),{setThemeMode:f}=Cr(),h=c.useRef(!1),m=c.useCallback(()=>{h.current||(h.current=!0,u().then(()=>{const{available:x,error:p}=pr.getState();if(p){_e.error("Failed to check for updates",{description:p});return}x||_e.success("You are on the latest version")}).finally(()=>{h.current=!1}))},[u]),g=c.useCallback(()=>{xn.requestDirectoryDialog()},[]),b=c.useCallback(x=>{const p=Tx();if(p.length===0)return;const y=nt.getState().currentSessionId,w=p.findIndex(P=>P.id===y);let j=x>0?0:p.length-1;w>=0&&(j=(w+x+p.length)%p.length);const k=p[j];k&&(a(!1),nt.getState().setCurrentSession(k.id))},[a]),v=c.useCallback(x=>{const{activeProjectId:p,projects:y,setActiveProject:w}=Zt.getState();if(y.length===0)return;const j=y.findIndex(A=>A.id===p);let k=x>0?0:y.length-1;j>=0&&(k=(j+x+y.length)%y.length);const P=y[k];P&&w(P.id)},[]),S=c.useCallback(x=>{switch(x){case"about":d(!0);break;case"settings":l(!0);break;case"command-palette":s();break;case"quick-open":r(!0);break;case"new-session":a(!1);{const p=nt.getState(),y=gs.getState().currentDirectory;e(p.currentSessionId&&y?{directoryOverride:y}:void 0)}break;case"new-worktree-session":a(!1),Ox();break;case"change-workspace":g();break;case"toggle-right-sidebar":{const p=gs.getState().currentDirectory;if(!p)break;const y=de.getState(),w=vs(p),j=y.contextPanelByDirectory[w],k=j?km(j.tabs,y.contextSurfaceZones,"right",Io(j,"right").activeTabId):null;j?.isOpen?y.closeContextPanel(w):k?y.setActiveContextPanelTab(w,k):y.openContextSurface(w,"git");break}case"open-right-sidebar-git":{const p=gs.getState().currentDirectory;if(!p)break;de.getState().openContextSurface(vs(p),"git");break}case"open-right-sidebar-files":{const p=gs.getState().currentDirectory;if(!p)break;de.getState().openContextSurface(vs(p),"file");break}case"toggle-terminal":{const p=gs.getState().currentDirectory;if(!p)break;de.getState().openContextSurface(vs(p),"terminal");break}case"toggle-terminal-expanded":{const p=gs.getState().currentDirectory;if(!p)break;const y=vs(p),w=de.getState(),j=w.contextPanelByDirectory[y];ya(j,w.contextSurfaceZones).has("terminal")||w.openContextSurface(y,"terminal"),w.toggleContextPanelExpanded(y,uo(w.contextSurfaceZones,"terminal"));break}case"copy":{const p=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(p)||IP();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":Ax();break;case"toggle-sidebar":i();break;case"toggle-memory-debug":t?.();break;case"go-back":ic(-1);break;case"go-forward":ic(1);break;case"previous-session":b(-1);break;case"next-session":b(1);break;case"previous-project":v(-1);break;case"next-project":v(1);break;case"help-dialog":o();break;case"download-logs":{Mx().catch(()=>{_e.error("Failed to collect OpenCode status")});break}}},[g,v,b,t,e,d,a,r,l,f,s,o,i]);c.useEffect(()=>{const x=y=>{const w=y.detail;w&&S(w)},p=()=>{m()};return window.addEventListener(Fd,x),window.addEventListener(Ni,p),()=>{window.removeEventListener(Fd,x),window.removeEventListener(Ni,p)}},[S,m]),c.useEffect(()=>{if(typeof window>"u")return;const p=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof p!="function")return;let y=null,w=null;return p("openchamber:menu-action",j=>{const k=j?.payload;typeof k=="string"&&S(k)}).then(j=>{y=j}).catch(()=>{}),p("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Ni))}).then(j=>{w=j}).catch(()=>{}),()=>{(async()=>{try{const k=y?.();k instanceof Promise&&await k}catch{}try{const k=w?.();k instanceof Promise&&await k}catch{}})()}},[S])},DP="openchamber:tray-action",TP=5e3,MP=500,AP=20,Ld=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},_d=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,op=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},ip=t=>t.title.trim()||"Question",OP=(t,e)=>$a(t,e,Fo.getState().ids,Sf.getState().rankById),BP=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},FP=(t,e,s,r,o)=>{if(!t)return"";const i=uu(s,r,t),a=e.project?.name,l=i?.label?.trim()||a?.trim()||BP(t),d=Xr(t);let u=d&&o.get(d)||"";if(!u){for(const[f,h]of gn.getState().directories)if(Xr(f)===d){u=h.status?.current??"";break}}if(!u)for(const f of r.values()){const h=f.find(m=>Xr(m.path)===d);if(h?.branch){u=h.branch;break}}return u?`${l} · ${u}`:l},LP=()=>{const{results:t,dropdownProviderIds:e,displayMode:s}=Ln.getState(),r=s==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(a=>[a.providerId,a])),i=[];for(const a of Fx){if(!e.includes(a.id))continue;const l=o.get(a.id);if(!l||l.configured!==!0)continue;const d=[];for(const[f,h]of Object.entries(l.usage?.windows??{})){const m=r==="remaining"?h.remainingPercent:h.usedPercent;d.push({label:_x(f),value:Lx(h.valueLabel,m)})}const u=!l.ok&&l.error?l.error:d.length===0?"No rate limits reported":null;i.push({provider:a.name,rows:d,status:u})}return{mode:r,groups:i}},_P=async()=>{try{if(Do())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=fr();if(e&&Ml(e,t))return"Local OpenChamber";const r=(await To()).hosts.find(o=>e?Ml(e,eu(o)):!1);return r?.label?.trim()?Xd(r.label.trim()):"Instance"}catch{return""}},$P=()=>{const t=new Map,e=new Map,s=[],r=new Map;let o;try{o=Wi()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[i,a]of o.children.entries()){const l=a.getState();l.vcs?.branch&&e.set(Xr(i)??i,l.vcs.branch);for(const d of l.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(l.session_status??{})){const f=u?.type,h=f==="busy"?"busy":f==="retry"?"retry":"idle",m=t.get(d);(!m||m==="idle")&&t.set(d,h)}for(const[d,u]of Object.entries(l.permission??{}))for(const f of u??[]){if(!f?.id)continue;const h=f.sessionID||d;s.push({kind:"permission",id:f.id,sessionId:h,sessionTitle:"",label:op(f),directory:i})}for(const[d,u]of Object.entries(l.form??{}))for(const f of u??[]){if(!f?.id)continue;const h=f.sessionID||d;s.push({kind:"form",id:f.id,sessionId:h,sessionTitle:"",label:ip(f),directory:i})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},zP=(t,e)=>{const s=bf.getState().index.session,r=ws.getState().activeSessions,o=new Map;for(const p of r)if(p?.id&&p.parentID){const y=o.get(p.parentID)??[];y.push(p.id),o.set(p.parentID,y)}const i=p=>{const y=[],w=[...o.get(p)??[]],j=new Set;for(;w.length;){const k=w.pop();j.has(k)||(j.add(k),y.push(k),w.push(...o.get(k)??[]))}return y},a=de.getState();let l=0;if(a.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let y=s.unseenCount[p.id]??0;y===0&&a.notifyOnSubtasks&&(y=i(p.id).reduce((w,j)=>w+(s.unseenCount[j]??0),0)),y>0&&(l+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:l};const d=$P(),u=new Map(d.titleById);for(const p of r)p?.id&&p.title&&u.set(p.id,p.title);const f=yf.getState().statusById,h=p=>{const y=d.statusById.get(p);return y&&y!=="idle"?y:f.get(p)?.status.type??y??"idle"},m=p=>{const y=p.map(w=>h(w));return y.includes("busy")?"busy":y.includes("retry")?"retry":"idle"},g=Zt.getState().projects,b=nt.getState().availableWorktreesByProject,v=r.filter(p=>p?.id&&!p.parentID).slice().sort(OP).slice(0,AP).map(p=>{const y=[p.id,...i(p.id)],w=Xn(p)??"";return{id:p.id,title:p.title||"Untitled session",status:m(y),branch:w?d.branchByDirectory.get(w)??"":"",unseen:y.reduce((j,k)=>j+(s.unseenCount[k]??0),0),hasError:y.some(j=>s.unseenHasError[j]??!1),directory:w,subtitle:FP(w,p,g,b,d.branchByDirectory)}}),S=d.approvals.map(p=>({...p,sessionTitle:u.get(p.sessionId)||""})),x=new Set(S.map(p=>p.id));for(const[p,y]of xf.getState().bySession){const w=u.get(p)||"";for(const j of y.permissions)x.has(j.id)||(x.add(j.id),S.push({kind:"permission",id:j.id,sessionId:p,sessionTitle:w,label:op(j),directory:y.directory}));for(const j of y.forms)x.has(j.id)||(x.add(j.id),S.push({kind:"form",id:j.id,sessionId:p,sessionTitle:w,label:ip(j),directory:y.directory}))}return{sessions:v,approvals:S,instanceName:t,usage:LP(),dockBadgeCount:l}},WP=()=>{c.useEffect(()=>{if(!Ld()||!io())return;const t=_d();let e=!1,s="",r=null,o="";const i=()=>{if(e)return;const P=zP(o,t),A=JSON.stringify(P);A!==s&&(s=A,hn("desktop_tray_update",P))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},MP))},l=bf.subscribe(()=>a()),d=ws.subscribe(()=>a()),u=de.subscribe((P,A)=>{(P.dockBadgeEnabled!==A.dockBadgeEnabled||P.notifyOnSubtasks!==A.notifyOnSubtasks)&&a()}),f=()=>{e=!0,r!==null&&window.clearTimeout(r),l(),d(),u()};if(!t)return i(),f;_P().then(P=>{e||(o=P,i())});const h=new Map,m=()=>{if(e)return;let P;try{P=Wi()}catch{return}const A=new Set;for(const[B,R]of P.children.entries())A.add(B),h.has(B)||h.set(B,R.subscribe(()=>a()));for(const[B,R]of h)A.has(B)||(R(),h.delete(B))};let g=null;try{g=Wi().subscribeRegistry(()=>{m(),a()})}catch{}m();const b=Zt.subscribe(()=>a()),v=nt.subscribe(()=>a()),S=gn.subscribe(()=>a()),x=yf.subscribe(()=>a()),p=xf.subscribe(()=>a()),y=Sf.subscribe(()=>a()),w=Fo.subscribe(()=>a()),j=Ln.subscribe(()=>a());Ln.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:P,results:A}=Ln.getState();P.length>0&&P.some(R=>!A.some(E=>E.providerId===R))&&Ln.getState().fetchQuotas(P)});const k=window.setInterval(()=>{m(),i()},TP);return i(),()=>{f(),window.clearInterval(k),b(),v(),S(),x(),p(),y(),w(),j(),g?.();for(const P of h.values())P();h.clear()}},[]),c.useEffect(()=>{if(!Ld()||!_d()||!io())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=o=>{o.type==="respond-permission"&&Bx(o.sessionId,o.id,o.response).catch(()=>{_e.error("Failed to respond to permission request")})};let r=null;return e(DP,o=>{const i=o?.payload;!i||typeof i!="object"||typeof i.type!="string"||s(i)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},KP=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,HP=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,VP=t=>{t.kind!=="plugin"||!t.title||_e.info(t.title,{id:HP(t.kind,t.title,t.body,t.tag),description:t.body})},GP=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,UP=t=>{const e=He.c(3),s=!0;let r,o;e[0]!==s?(r=()=>{if(!(pn()||!tu()||!globalThis.window))return wn(qP)},o=[s],e[0]=s,e[1]=r,e[2]=o):(r=e[1],o=e[2]),c.useEffect(r,o)};function qP(t){if(t.type!=="notification")return;const e=de.getState();if(!e.nativeNotificationsEnabled)return;const s=KP();if(GP(t.payload,s)){VP(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&s)return;jm()?.notifications?.notifyAgentCompletion(t.payload)}const YP=6e4,XP=t=>{const e=He.c(10),s=de(QP),r=$x(ZP),i=Kg(t)?.path??null;let a,l;e[0]!==s||e[1]!==r||e[2]!==i?(a=()=>{s&&r(i,{maxAgeMs:YP})},l=[s,r,i],e[0]=s,e[1]=r,e[2]=i,e[3]=a,e[4]=l):(a=e[3],l=e[4]),c.useEffect(a,l);let d,u;e[5]!==s||e[6]!==r||e[7]!==i?(d=()=>{if(s)return wn(f=>{f.type==="agent-memory-changed"&&r(i)})},u=[s,r,i],e[5]=s,e[6]=r,e[7]=i,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function QP(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function ZP(t){return t.load}const JP=()=>{const t=He.c(4),{t:e}=wt(),s=de(eE);let r,o;t[0]!==s||t[1]!==e?(r=()=>wn(i=>{i.type==="browser-provider-reset"&&(s("builtin"),_e.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[s,e],t[0]=s,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),c.useEffect(r,o)};function eE(t){return t.setBrowserProvider}const $d=()=>{Cm()||(Hg(),zx(Vg.map(t=>t.id)))},tE=(t,e)=>{const s=He.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback($d,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout($d,3e3);return()=>clearTimeout(i)},s[0]=t,s[1]=r):r=s[1];let o;s[2]!==e||s[3]!==t?(o=[t,e],s[2]=e,s[3]=t,s[4]=o):o=s[4],c.useEffect(r,o)},zd="pwa-install-toast-shown",Wd="pwa-install-toast-dismissed",sE=()=>{const t=He.c(6),{browserTab:e}=Gg(),{t:s}=wt(),r=c.useRef(s);let o,i;t[0]!==s?(o=()=>{r.current=s},i=[s],t[0]=s,t[1]=o,t[2]=i):(o=t[1],i=t[2]),c.useEffect(o,i);let a,l;t[3]!==e?(a=()=>{if(typeof window>"u"||!tu()||!e)return;let d=null,u=null;const f=()=>{u!==null&&(_e.dismiss(u),u=null)},h=async()=>{if(!d)return;const b=d;d=null,f(),await b.prompt();const{outcome:v}=await b.userChoice;v==="accepted"&&_e.success(r.current("pwa.installPrompt.started"))},m=b=>{const v=b;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const S=fo(),x=Pm();Ug({dismissed:S.getItem(Wd),sessionShown:x.getItem(zd),hasActiveToast:u!==null})&&(x.setItem(zd,"true"),u=_e.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{h()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{fo().setItem(Wd,"true"),f()}}}))},g=()=>{d=null,f(),_e.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",m),window.addEventListener("appinstalled",g),()=>{f(),window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",g)}},l=[e],t[3]=e,t[4]=a,t[5]=l):(a=t[4],l=t[5]),c.useEffect(a,l)},nE=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",ap=async(t,e)=>{const s=(await To()).hosts.find(o=>o.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await Rm(s.id,e);return}const r=Dm(eu(s));if(!r)throw new Error("host-not-found");Tm({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:Mm(s),sshForwarded:s.sshForwarded===!0})},rE=async t=>{const e=await To(),s=await Nm(t,e.hosts);await Im({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:!0}),await ap(s.hostId,{reconnectActive:!0})},oE=async t=>{const e=await Em();for(const s of e)try{s.type==="pairing"?await rE(s.link):await ap(s.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,o),t(nE(o))}},ma="project-config-invalid",iE=()=>{const t=He.c(9),{t:e}=wt(),s=ns(aE);let r;t[0]!==s?(r=m=>m.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const o=ns(r),[i,a]=ds.useState(!1);let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const m=ns.getState(),g=m.activeDirectoryKey;a(!0),Promise.all([m.loadProviders({directory:g,source:"projectConfigError:retry"}),m.loadAgents({directory:g,source:"projectConfigError:retry"})]).finally(()=>a(!1))},t[2]=l):l=t[2];const d=l;let u,f;t[3]!==o||t[4]!==i||t[5]!==e?(u=()=>{if(!o){_e.dismiss(ma);return}_e.error(e("projectConfigError.toast.title"),{id:ma,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:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&n.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:o.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:m=>{m.preventDefault(),i||d()}}})},f=[o,i,d,e],t[3]=o,t[4]=i,t[5]=e,t[6]=u,t[7]=f):(u=t[6],f=t[7]),ds.useEffect(u,f);let h;return t[8]===Symbol.for("react.memo_cache_sentinel")?(h=[],t[8]=h):h=t[8],ds.useEffect(cE,h),null};function aE(t){return t.activeDirectoryKey}function lE(){_e.dismiss(ma)}function cE(){return lE}const dE="\x1B",uE=new RegExp(`${dE}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Gr=rn().transform(t=>t.replace(uE,"").trim()).nullish(),fE=Gi({isOpenCodeReady:cc().optional(),openCodeRunning:cc().optional(),lastOpenCodeError:Gr,opencodeBinaryResolved:Gr,lastOpenCodeLaunchDiagnostics:Gi({sourceBinary:Gr,binary:Gr}).nullish()}),hE=async(t,e=an)=>{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=fE.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}},pE=(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"}},mE=Gi({openchamberVersion:rn()}),gE=async(t,e=an)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=mE.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},bE=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function yE({version:t}){const{t:e}=wt(),[s,r]=c.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const l=await qg();r(l.available&&!l.installBlocked?{kind:"available",info:l}:{kind:"manual",info:l,error:null})}catch(l){r({kind:"manual",info:null,error:l instanceof Error?l.message:null})}},i=s.kind==="manual"?s:null,a=i?.info?.updateCommand||"openchamber update";return n.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("h1",{className:"typography-title text-foreground",children:e("startup.serverOutdated.title")}),n.jsx("p",{className:"typography-body text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),n.jsxs(Ct,{type:"button",onClick:()=>{o()},disabled:s.kind==="checking",children:[n.jsx(Z,{name:s.kind==="checking"?"loader":"download",className:s.kind==="checking"?"size-4 animate-spin":"size-4"}),s.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&n.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&n.jsx("p",{className:"typography-meta text-muted-foreground",children:i.error}),n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),n.jsx("code",{className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]}),n.jsx(ka,{open:s.kind==="available",onOpenChange:l=>{l||r({kind:"idle"})},info:s.kind==="available"?s.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Kd=nr(()=>ss(()=>import("./OnboardingScreen-Cy6ARiMS.js"),__vite__mapDeps([167,1,2,9,3,4,5,6,7,8,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}))),xE=()=>ss(()=>import("./AboutDialog-e8ek_kPI.js"),__vite__mapDeps([168,1,2,9,3,4,5,6,7,8,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=>t.AboutDialog),SE=()=>ss(()=>import("./MemoryDebugPanel-CBk8QW-M.js"),__vite__mapDeps([169,1,2,9,3,4,5,6,7,8,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,121,122,123])).then(t=>t.MemoryDebugPanel),vE=()=>{const t=He.c(6),e=de(PE),s=de(EE);let r;t[0]!==s?(r=()=>s(!1),t[0]=s,t[1]=r):r=t[1];const o=Yo(e,xE,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==s?(i=n.jsx(o,{open:e,onOpenChange:s}),t[2]=o,t[3]=e,t[4]=s,t[5]=i):i=t[5],i},wE=t=>{const e=He.c(3),{onClose:s}=t,r=Yo(!0,SE,s);let o;return e[0]!==r||e[1]!==s?(o=r?n.jsx(r,{onClose:s}):null,e[0]=r,e[1]=s,e[2]=o):o=e[2],o},kE=t=>{const e=He.c(47),{onRetry:s,isRetrying:r}=t,{t:o}=wt(),[i,a]=c.useState(null);let l,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const B=new AbortController,R=Yt(),E=setTimeout(()=>B.abort(),5e3);return hE(B.signal).then(T=>{!B.signal.aborted&&Yt()===R&&a(T)}).catch(NE).finally(()=>clearTimeout(E)),()=>{B.abort(),clearTimeout(E)}},d=[],e[0]=l,e[1]=d):(l=e[0],d=e[1]),c.useEffect(l,d);const[u,f]=c.useState(null);let h,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{const B=new AbortController,R=Yt(),E=setTimeout(()=>B.abort(),5e3);return gE(B.signal).then(T=>{B.signal.aborted||Yt()!==R||f(T&&bE(T)?T:null)}).catch(IE).finally(()=>clearTimeout(E)),()=>{B.abort(),clearTimeout(E)}},m=[],e[2]=h,e[3]=m):(h=e[2],m=e[3]),c.useEffect(h,m);const g=ns(RE),b=i?null:g?.message??null;if(u){let B;e[4]!==u?(B=n.jsx(yE,{version:u}),e[4]=u,e[5]=B):B=e[5];let R;e[6]!==r||e[7]!==o?(R=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=R):R=e[8];let E;e[9]!==r||e[10]!==s||e[11]!==R?(E=n.jsx(Ct,{type:"button",variant:"outline",onClick:s,disabled:r,children:R}),e[9]=r,e[10]=s,e[11]=R,e[12]=E):E=e[12];let T;return e[13]!==B||e[14]!==E?(T=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:[B,E]})}),e[13]=B,e[14]=E,e[15]=T):T=e[15],T}let v;e[16]!==o?(v=o("startup.initRecovery.title"),e[16]=o,e[17]=v):v=e[17];let S;e[18]!==v?(S=n.jsx("h1",{className:"typography-title text-foreground",children:v}),e[18]=v,e[19]=S):S=e[19];let x;e[20]!==i||e[21]!==g||e[22]!==o?(x=o(pE(i,g)),e[20]=i,e[21]=g,e[22]=o,e[23]=x):x=e[23];let p;e[24]!==x?(p=n.jsx("p",{className:"typography-body text-muted-foreground",children:x}),e[24]=x,e[25]=p):p=e[25];let y;e[26]!==S||e[27]!==p?(y=n.jsxs("div",{className:"flex flex-col gap-2",children:[S,p]}),e[26]=S,e[27]=p,e[28]=y):y=e[28];let w;e[29]!==b||e[30]!==o?(w=b&&n.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("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:b})]}),e[29]=b,e[30]=o,e[31]=w):w=e[31];let j;e[32]!==i||e[33]!==o?(j=i&&n.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),n.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("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:i.error})]})]}),e[32]=i,e[33]=o,e[34]=j):j=e[34];let k;e[35]!==r||e[36]!==o?(k=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=k):k=e[37];let P;e[38]!==r||e[39]!==s||e[40]!==k?(P=n.jsx(Ct,{type:"button",onClick:s,disabled:r,children:k}),e[38]=r,e[39]=s,e[40]=k,e[41]=P):P=e[41];let A;return e[42]!==w||e[43]!==j||e[44]!==P||e[45]!==y?(A=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:[y,w,j,P]})}),e[42]=w,e[43]=j,e[44]=P,e[45]=y,e[46]=A):A=e[46],A};function jE({apis:t}){c.useEffect(()=>{Am("App:mounted"),Om()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=ns(K=>K.initializeApp),s=ns(K=>K.isInitialized),r=ns(K=>K.isConnected),o=ns(K=>K.providersLoaded),i=ns(K=>K.agentsLoaded),a=ns(K=>K.loadProviders),l=ns(K=>K.loadAgents),d=nt(K=>K.error),u=nt(K=>K.clearError),f=gs(K=>K.currentDirectory),h=gs(K=>K.isSwitchingDirectory),[m,g]=c.useState(!1),b=mn(K=>K.refreshAll),v=Wx(K=>K.refreshStatus),[S,x]=c.useState(()=>t.runtime.isVSCode),[p,y]=c.useState(!1),[w,j]=c.useState(0),[k,P]=c.useState(0),[A,B]=c.useState(!1),R=de(K=>K.wideChatLayoutEnabled),E=de(K=>K.mobileKeyboardMode),T=c.useMemo(()=>pn(),[]),z=Ra(K=>K.setPlanModeEnabled),[O,W]=c.useState(()=>Al()),[D,Q]=c.useState(()=>{const K=ai();return K!==null?Ol({isDesktopShell:!0,bootOutcome:K}):null}),N=c.useRef(!1),{t:C}=wt(),I=c.useRef(!1);c.useEffect(()=>{if(!s||O!=="valid"||I.current)return;const K=ai();K?.target!=="local"||K.status!=="ok"||!K.sshStartupFallbackHostId||(I.current=!0,_e.error(C("desktopHostSwitcher.startup.title"),{description:C("desktopHostSwitcher.startup.fellBackToLocal")}))},[O,s,C]),c.useEffect(()=>(Bl(m),Od(m),()=>{Bl(!1),Od(!1)}),[m]),c.useEffect(()=>{Bm(E)},[E]),c.useEffect(()=>{x(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>No(K=>{Xg(K)&&Qg(K),P(q=>q+1),y(!1),j(q=>q+1)}),[]);const H=ac(K=>{const q=Yt();return Object.values(K.runsByOriginalSessionID).filter(oe=>oe.status==="running"&&oe.runtimeKey===q).map(oe=>`${oe.originalSessionID}:${oe.phase}:${oe.lastForwardedMessageID??""}:${oe.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{const K=Yt(),q=Object.values(ac.getState().runsByOriginalSessionID).filter(oe=>oe.status==="running"&&oe.runtimeKey===K);for(const oe of q)Kx(oe.originalSessionID)},[H,k]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",R),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[R]),c.useEffect(()=>(Fl(t),()=>Fl(null)),[t]),c.useEffect(()=>{r&&(b(t.sourceControl,{force:!0}),v(t.linear,{force:!0}))},[t.sourceControl,t.linear,r,b,v,k]),Hx();const M=O==="valid",_=D?.screen==="main";c.useEffect(()=>{if(!Fm({isDesktopShell:T,bootOutcomeKnown:M}))return;Vx();const K=setTimeout(()=>{const q=document.getElementById("initial-loading");q&&(q.classList.add("fade-out"),setTimeout(()=>{q.remove()},300))},150);return()=>clearTimeout(K)},[T,M]),c.useEffect(()=>{if(!T||O!=="malformed")return;const K=document.getElementById("initial-loading");K&&(K.textContent="Desktop startup failed — please restart the app.")},[T,O]),c.useEffect(()=>{let K=!1;return(async()=>{const oe=await an("/health",{method:"GET"}).catch(()=>null);if(!oe||!oe.ok||K)return;const fe=await oe.json().catch(()=>null);if(!fe||K)return;const ce=fe.planModeExperimentalEnabled;z(ce===!0||ce===1||ce==="1"||ce==="true")})(),()=>{K=!0}},[z]),c.useEffect(()=>{S||e()},[e,S]),c.useEffect(()=>{if(S||s)return;let K=!0,q,oe=0;const fe=10,ce=1e3,ke=async()=>{if(!K)return;if(oe>=fe){y(!0);return}const De=ns.getState();if(De.isInitialized){y(!1);return}oe+=1,await De.initializeApp();const Ce=ns.getState();if(!K)return;if(Ce.isInitialized){y(!1);return}if(oe>=fe){y(!0);return}const Y=Math.min(ce*Math.pow(2,oe-1),4e3);q=setTimeout(ke,Y)};return q=setTimeout(ke,ce),()=>{K=!1,q&&clearTimeout(q)}},[w,s,S]),c.useEffect(()=>{s&&y(!1)},[s]),c.useEffect(()=>{if(!p)return;const K=document.getElementById("initial-loading");K&&(K.classList.add("fade-out"),setTimeout(()=>{K.remove()},300))},[p]),c.useEffect(()=>{if(S||!r||o&&i)return;let K=!0,q=0;const oe=15,fe=async()=>{const ke=ns.getState();if(!(ke.providersLoaded&&ke.agentsLoaded))try{ke.providersLoaded||await a({source:"startupRecovery"}),ns.getState().agentsLoaded||await l({source:"startupRecovery"})}catch{}};fe();const ce=setInterval(()=>{if(K){if(++q>=oe){clearInterval(ce);return}fe()}},2e3);return()=>{K=!1,clearInterval(ce)}},[r,S,l,a,o,i]),c.useEffect(()=>{h||S||r&&co.setDirectory(f)},[f,h,r,S]),c.useEffect(()=>{if(typeof window>"u")return;const K=q=>{const oe=q.detail,fe=typeof oe?.sessionId=="string"?oe.sessionId.trim():"";if(!fe)return;const ce=typeof oe?.directory=="string"&&oe.directory.trim().length>0?oe.directory.trim():null,ke=String(oe?.runtimeKey??"").trim();if(!(ke&&ke!==Yt()&&zm(ke,fe))){if(!ce){lc(fe,typeof oe?.messageId=="string"?oe.messageId.trim():null);return}nt.getState().setCurrentSession(fe,ce)}};return window.addEventListener("openchamber:open-session",K),Lm().then(q=>{for(const oe of q)lc(oe.sessionId,oe.messageId)}),()=>window.removeEventListener("openchamber:open-session",K)},[]),c.useEffect(()=>{if(!pn())return;const K=()=>{oE(q=>{_e.error(C(q==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":q==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",K),K(),()=>window.removeEventListener("openchamber:host-actions-ready",K)},[C]);const F=c.useRef({attempt:null,running:!1,done:!1});c.useLayoutEffect(()=>{const K=F.current;K.attempt||(K.attempt=Zg({selectNow:!Jg().sessionId}))},[]),c.useEffect(()=>{const K=F.current,q=()=>{const oe=K.attempt;if(!oe||K.running||K.done)return;const fe=ns.getState().isInitialized;K.running=!0,oe().then(ce=>{if(K.running=!1,ce!=="failed"||fe){K.done=!0;return}ns.getState().isInitialized&&q()})};q()},[s]),c.useEffect(()=>{if(typeof window>"u")return;const K=()=>{hn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",K),()=>window.removeEventListener("openchamber:open-mini-chat",K)},[]),c.useEffect(()=>{if(typeof window>"u")return;const K=()=>{const q=nt.getState().currentSessionId;q&&Uu(q)};return window.addEventListener("focus",K),()=>window.removeEventListener("focus",K)},[]),c.useEffect(()=>{if(typeof window>"u")return;const K=q=>{const oe=q.detail,fe=typeof oe?.directory=="string"&&oe.directory.trim().length>0?oe.directory.trim():null,ce=typeof oe?.projectId=="string"&&oe.projectId.trim().length>0?oe.projectId.trim():null,ke=!!(fe||ce);de.getState().setSessionSwitcherOpen(!1),nt.getState().openNewSessionDraft({target:ke?"project":"chat",selectedProjectId:ke?ce:null,directoryOverride:ke?fe:null,preserveDirectoryOverride:!!fe})};return window.addEventListener("openchamber:open-draft-session",K),()=>window.removeEventListener("openchamber:open-draft-session",K)},[]),c.useEffect(()=>{typeof window>"u"||!s||h||N.current||(N.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,h]),Gx(),UP(),XP(f||null),JP(),Ux(),eb(),tE(s&&r,k),sE(),qx(),h1(),tb();const ee=c.useCallback(()=>{g(K=>!K)},[]);RP(ee),WP(),p1(!0),c.useEffect(()=>{const K=()=>g(q=>!q);return window.addEventListener("openchamber:memory-debug-toggle",K),()=>window.removeEventListener("openchamber:memory-debug-toggle",K)},[]),c.useEffect(()=>{d&&setTimeout(()=>u(),5e3)},[u,d]),c.useEffect(()=>{if(!T||O!=="not-injected")return;let K=!1,q=0;const oe=200,fe=2e3,ce=50,ke=()=>{if(K)return;q++;const De=Al();if(De!=="not-injected"){if(K=!0,W(De),De==="valid"){const Y=ai();Y&&Q(Ol({isDesktopShell:!0,bootOutcome:Y}))}return}const Ce=Math.min(oe*Math.pow(1.1,q),fe);if(q>=ce){const Y=document.getElementById("initial-loading");Y&&!Y.textContent?.includes("taking longer")&&(Y.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(ke,Ce)};return window.setTimeout(ke,oe),()=>{K=!0}},[T,O]);const ne=c.useCallback(async()=>{if(_m({isDesktopShell:pn(),isDesktopLocalOriginActive:Do()})){await $m();return}window.location.reload()},[]),re=c.useCallback(async()=>{if(!A){y(!1),B(!0);try{await ns.getState().initializeApp()}finally{B(!1)}ns.getState().isInitialized||j(K=>K+1)}},[A]),te=K=>{if(K.screen==="recovery")return K.variant};if(T&&D&&D.screen!=="main"){if(D.screen==="chooser")return n.jsx(bs,{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(Kd,{mode:"first-launch",localAvailable:D.localAvailable!==!1,onCliAvailable:ne,onChooseRemote:()=>{}})})})});const K=te(D),q=D.screen==="recovery"&&"url"in D?D.url:void 0,oe=D.screen==="recovery"&&"hostId"in D?D.hostId:void 0;return n.jsx(bs,{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(Kd,{mode:"recovery",recoveryVariant:K,recoveryHostUrl:q,recoveryHostLabel:void 0,recoveryHostId:oe,localAvailable:D.localAvailable!==!1,onCliAvailable:ne})})})})}return p&&!s&&!S?n.jsx(bs,{children:n.jsx(kE,{onRetry:()=>{re()},isRetrying:A},k)}):n.jsx(bs,{children:n.jsx(Yx,{sdk:co.getSdkClient(),directory:f||"",children:n.jsx(Xx,{apis:t,children:n.jsx(xP,{children:n.jsx(Lo,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:T?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(Qx,{backgroundWorkEnabled:!0}),n.jsx(sb,{}),n.jsx(iE,{}),n.jsx(T5,{}),T?n.jsx(nb,{ready:M&&_}):null,n.jsx(Zx,{}),n.jsx(Jx,{}),n.jsx(e1,{}),n.jsx(rb,{}),n.jsx(vE,{}),m&&n.jsx(wE,{onClose:()=>g(!1)})]})})})})},k)})}function CE(t){const e=He.c(2);let s;return e[0]!==t?(s=n.jsx(Yg,{children:n.jsx(jE,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function PE(t){return t.isAboutDialogOpen}function EE(t){return t.setAboutDialogOpen}function NE(){}function IE(){}function RE(t){return t.lastInitFailure}const DE=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Wm();ob();ib();Km().then(()=>{t1().catch(t=>{console.error("[main] settings init failed:",t)}),s1(),n1(),r1()}).catch(t=>{console.error("[main] appearance init failed:",t)});const lp=document.getElementById("root");if(!lp)throw new Error("Root element not found");o1();Yp.createRoot(lp).render(n.jsx(ds.StrictMode,{children:n.jsx(i1,{children:n.jsx(a1,{children:n.jsx(l1,{children:n.jsx(c1,{children:n.jsx(CE,{apis:DE})})})})})}));const ZE=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{DS as W,jk as a,YE as b,QE as g,ZE as m,XE as r,PS as u,kk as v};
|