@openchamber/web 2.3.2 → 2.3.3
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-MZbHWRua.js → AboutDialog-Ctk2zvrv.js} +1 -1
- package/dist/assets/{ArchiveView-CkeSWPcI.js → ArchiveView-sbNreasJ.js} +1 -1
- package/dist/assets/{CommandPalette-CtKzNzwW.js → CommandPalette-BICwnwAZ.js} +2 -2
- package/dist/assets/{DiffView-DaXjHTAq.js → DiffView-B5yeuxv8.js} +1 -1
- package/dist/assets/{FilesView-DMNYEydF.js → FilesView-ni2zfAwL.js} +7 -7
- package/dist/assets/{GitView-HXttTpUw.js → GitView-C0QgeC9O.js} +3 -3
- package/dist/assets/{GuestSurfacePane-KzguENQG.js → GuestSurfacePane-D1gLktSj.js} +1 -1
- package/dist/assets/{HelpDialog-9YZGhBgT.js → HelpDialog-CxC6qTaS.js} +1 -1
- package/dist/assets/{InProgressOperationBanner-DzGIwGH2.js → InProgressOperationBanner-JFV70YFh.js} +1 -1
- package/dist/assets/{JsonTreeView-D9rP8jM8.js → JsonTreeView-RsbV4Usa.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-CZK5DoOX.js +1 -0
- package/dist/assets/{MemoryDebugPanel-Ct0h3RWh.js → MemoryDebugPanel-caUWOKiz.js} +1 -1
- package/dist/assets/{OnboardingScreen-B5Zzb1Mp.js → OnboardingScreen-BDT-J2JP.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-CXBWWRh8.js → OpenCodeStatusDialog-Cxa2yqOB.js} +1 -1
- package/dist/assets/{PatchDiff-DhDAQ5em.js → PatchDiff-C1pnbAsJ.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DPa08AmN.js → PierreDiffViewer-D0zX2Msu.js} +1 -1
- package/dist/assets/PlanView-BxRCMuGe.js +5 -0
- package/dist/assets/{ProjectActionsDialog-DATu0aBc.js → ProjectActionsDialog-D660By4K.js} +1 -1
- package/dist/assets/{RunOverview-D6xy_vME.js → RunOverview-C1uTMnQS.js} +2 -2
- package/dist/assets/{ScheduledTasksDialog-BWXVnfrf.js → ScheduledTasksDialog-S-gAgo7Z.js} +5 -5
- package/dist/assets/SettingsView-CVpfbdob.js +30 -0
- package/dist/assets/{SettingsWindow-Cx6TrtY0.js → SettingsWindow-Dd1hHvgh.js} +1 -1
- package/dist/assets/SourceBoardView-DbGWAxtS.js +1 -0
- package/dist/assets/SpaceAccessDialog-muTSsEJ9.js +1 -0
- package/dist/assets/{SpaceApplyDialog-BtuwtlaG.js → SpaceApplyDialog-Dsf6MNGm.js} +1 -1
- package/dist/assets/{SpaceRow-MXqvd-dr.js → SpaceRow-7Z6ebRtm.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-Uo5LS7Jy.js → SpaceSetupOutput-BytPfCOC.js} +1 -1
- package/dist/assets/{SpacesView-DvoOh4sM.js → SpacesView-CYCrlp0D.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-CyMwDeoP.js → SubmoduleDiffSummary-VrNUbIqF.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BaUZIVzc.js → ToolOutputDialog-DHORjBND.js} +7 -7
- package/dist/assets/{ToolPartDiffPreview-DmMwdcF4.js → ToolPartDiffPreview-BLAXe7C5.js} +1 -1
- package/dist/assets/{UsageStatsView-D7WrDBTC.js → UsageStatsView-BxtYEAa0.js} +1 -1
- package/dist/assets/{Virtualizer-CnU8pYMb.js → Virtualizer-Bl4Cf-H-.js} +1 -1
- package/dist/assets/{WalkthroughView-r0Ho9F4Z.js → WalkthroughView-B2BJJ4u5.js} +2 -2
- package/dist/assets/{WorktreesView-C-t7uxq1.js → WorktreesView-Dv0AO9dF.js} +1 -1
- package/dist/assets/{appThemeRegistry-BUY7Ge9i.js → appThemeRegistry-xm_W0svA.js} +1 -1
- package/dist/assets/{ar-HauNhDvN.js → ar-Cj8UF12m.js} +4 -4
- package/dist/assets/{computeVirtualFileMetrics-CUof18z3.js → computeVirtualFileMetrics-Cx05cmWI.js} +2 -2
- package/dist/assets/{de-fEoJ_Yyp.js → de-fSQ1ho01.js} +4 -4
- package/dist/assets/{decorate-BkTSGAlD.js → decorate-jpF7GA6t.js} +2 -2
- package/dist/assets/{es-CKNTBsZW.js → es-DrdzhSlK.js} +5 -5
- package/dist/assets/{fileContentPoller-BJWgy1fX.js → fileContentPoller-C0f20jNG.js} +3 -3
- package/dist/assets/{flexokiTheme-BArobfXV.js → flexokiTheme-DKNCYSqL.js} +1 -1
- package/dist/assets/{fr-C23655Pi.js → fr-Cmz6Da4q.js} +4 -4
- package/dist/assets/{he-CphXS_Fv.js → he-COJRUNy4.js} +4 -4
- package/dist/assets/{index-B27cSA9V.js → index-C8Mw8uvl.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-CucsmDMw.js → initializeSharedPreferences-U9-v9mfq.js} +1 -1
- package/dist/assets/{isDiffPlainText-DSCjvV0m.js → isDiffPlainText-DW43IghW.js} +1 -1
- package/dist/assets/{isFilePlainText-C7g4UPox.js → isFilePlainText-Duq5CiuG.js} +1 -1
- package/dist/assets/{ja-BmsU2iQe.js → ja-Ce0NvDHZ.js} +4 -4
- package/dist/assets/katex-BZNCT55U.css +1 -0
- package/dist/assets/katex.min-EZjpSwGK.js +65 -0
- package/dist/assets/{ko-CxISpkje.js → ko-BGFcCLLq.js} +4 -4
- package/dist/assets/main-BUetg9hg.js +1048 -0
- package/dist/assets/{main-CGPiw9fS.js → main-Be_jmIlF.js} +2 -2
- package/dist/assets/markdownCore-BkTeS4gA.js +10 -0
- package/dist/assets/{miniChat-DVEKVYKe.js → miniChat-g1RgiLLS.js} +2 -2
- package/dist/assets/{mobile-Q_FVBe4I.js → mobile-DBli3U-T.js} +2 -2
- package/dist/assets/{moveWorkspacePath-CyZJ-2aD.js → moveWorkspacePath-CnYc96Xo.js} +1 -1
- package/dist/assets/{nl-jnTBQ_gU.js → nl-Cu1nxo5t.js} +4 -4
- package/dist/assets/{parseDiffFromFile-OHXXXyzL.js → parseDiffFromFile-DEjkjYod.js} +3 -3
- package/dist/assets/{patchFileDiff-BZrb6h2u.js → patchFileDiff-D__42sau.js} +5 -5
- package/dist/assets/{pierreDiffTint-DHf2xvyt.js → pierreDiffTint-3oatL635.js} +4 -4
- package/dist/assets/pl-4LdEMgWI.js +20 -0
- package/dist/assets/{pt-BR-BfpsFrHv.js → pt-BR-2UbEBNgC.js} +5 -5
- package/dist/assets/{relocateRestoredSession-DInneXVI.js → relocateRestoredSession-pkxyd_lV.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-D0tKJFBB.js +2 -0
- package/dist/assets/renderMobileApp-D6bOYHuP.js +25 -0
- package/dist/assets/{restartOpenCode-DwBaMPJK.js → restartOpenCode-FYqjpaWc.js} +1 -1
- package/dist/assets/runtimeEndpointReset-6CNNzem4.js +74 -0
- package/dist/assets/{scheduledTasksApi-ClJplEhR.js → scheduledTasksApi-BbnQ4W-W.js} +1 -1
- package/dist/assets/{selectionMarkdown-BuveYuup.js → selectionMarkdown-D8QAxC44.js} +1 -1
- package/dist/assets/sessionOwnership-BBuf0UCB.js +1 -0
- package/dist/assets/{shikiHighlight-DJAESrna.js → shikiHighlight-CweIj1cL.js} +1 -1
- package/dist/assets/{space-apply-DWFLwXbI.js → space-apply-CEi013sa.js} +1 -1
- package/dist/assets/{space-close-BYDbwdWc.js → space-close-BuStkLrZ.js} +1 -1
- package/dist/assets/{spaceNetwork-DHrhfbKM.js → spaceNetwork-tH2d5Mgs.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-DcAZmUlv.js → textMateThemeFromAppTheme-DLJBL6al.js} +1 -1
- package/dist/assets/tr-Bg0Qt-mG.js +11 -0
- package/dist/assets/{uk-C82aEtvs.js → uk-vcnOugr0.js} +5 -5
- package/dist/assets/useAppFontEffects-Cs6k0JKv.js +773 -0
- package/dist/assets/{useCallableModelProviders-BU_455MN.js → useCallableModelProviders-BsGEzsl2.js} +1 -1
- package/dist/assets/{useInlineCommentController-AuUrVz9U.js → useInlineCommentController-CVYaPzfO.js} +2 -2
- package/dist/assets/{useRootScrollLock-Cpk7NmBa.js → useRootScrollLock-Dov-44ov.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-BYGweLoh.js → vendor-codemirror-language-data-DBekkZIx.js} +2 -2
- package/dist/assets/vendor-tanstack-react-virtual-Dozz-7fb.js +1 -0
- package/dist/assets/vendor-tanstack-virtual-core-DKBj55Em.js +1 -0
- package/dist/assets/{vendor-yaml-3778uTud.js → vendor-yaml-CE-D_49-.js} +1 -1
- package/dist/assets/{zh-CN-DEq7j9I5.js → zh-CN-C3UhwFsk.js} +5 -5
- package/dist/assets/{zh-TW-DgCN99T-.js → zh-TW-D0CmmMvp.js} +5 -5
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +5 -5
- package/server/index.js +13 -1
- package/server/lib/agent-memory/actions.js +22 -9
- package/server/lib/agent-memory/actions.test.js +57 -0
- package/server/lib/agent-memory/runtime.js +8 -5
- package/server/lib/agent-tool/DOCUMENTATION.md +17 -1
- package/server/lib/agent-tool/runtime.js +41 -7
- package/server/lib/agent-tool/runtime.test.js +11 -0
- package/server/lib/git/DOCUMENTATION.md +17 -5
- package/server/lib/git/lfs-discovery.js +7 -4
- package/server/lib/git/lfs-discovery.test.js +60 -0
- package/server/lib/git/network-operations.js +9 -3
- package/server/lib/git/network-operations.test.js +31 -2
- package/server/lib/git/service.js +72 -12
- package/server/lib/git/service.test.js +65 -0
- package/server/lib/github/DOCUMENTATION.md +1 -0
- package/server/lib/github/reference-search.js +49 -18
- package/server/lib/github/reference-search.test.js +28 -6
- package/server/lib/github/routes.js +87 -1
- package/server/lib/github/routes.mutations.test.js +38 -0
- package/server/lib/github/routes.test.js +1 -0
- package/server/lib/gitlab/DOCUMENTATION.md +4 -0
- package/server/lib/gitlab/client.js +23 -0
- package/server/lib/gitlab/client.test.js +28 -1
- package/server/lib/gitlab/mappers.js +9 -0
- package/server/lib/gitlab/resources.js +153 -4
- package/server/lib/gitlab/resources.test.js +107 -0
- package/server/lib/gitlab/routes.js +120 -1
- package/server/lib/gitlab/routes.test.js +59 -0
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
- package/server/lib/markdown-image-grants/routes.js +14 -2
- package/server/lib/markdown-image-grants/routes.test.js +23 -0
- package/server/lib/notifications/APNS.md +24 -23
- package/server/lib/notifications/DOCUMENTATION.md +2 -2
- package/server/lib/notifications/apns-runtime.js +8 -5
- package/server/lib/notifications/apns-runtime.test.js +26 -0
- package/server/lib/notifications/message.js +5 -3
- package/server/lib/notifications/message.test.js +9 -0
- package/server/lib/notifications/runtime.js +44 -9
- package/server/lib/notifications/trigger-runtime.test.js +84 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
- package/server/lib/openchamber-control/actions.js +18 -2
- package/server/lib/openchamber-control/project-knowledge.js +17 -3
- package/server/lib/openchamber-control/project-knowledge.test.js +14 -0
- package/server/lib/openchamber-control/render-page.js +58 -0
- package/server/lib/openchamber-control/service.js +9 -0
- package/server/lib/openchamber-control/service.test.js +43 -0
- package/server/lib/openchamber-sessions/routes.js +1 -0
- package/server/lib/openchamber-sessions/worktree-move.js +26 -10
- package/server/lib/openchamber-sessions/worktree-move.test.js +36 -0
- package/server/lib/opencode/DOCUMENTATION.md +1 -1
- package/server/lib/opencode/managed-config-file.js +3 -2
- package/server/lib/opencode/managed-config-file.test.js +20 -6
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +3 -0
- package/server/lib/opencode/settings-runtime.js +1 -0
- package/server/lib/project-context/DOCUMENTATION.md +25 -1
- package/server/lib/project-context/plan-progress.js +69 -0
- package/server/lib/project-context/plan-progress.test.js +58 -0
- package/server/lib/project-context/routes.http.test.js +22 -0
- package/server/lib/project-context/routes.js +20 -0
- package/server/lib/project-context/runtime.js +132 -18
- package/server/lib/project-context/runtime.test.js +58 -0
- package/server/lib/provider-read-cache/index.js +7 -1
- package/server/lib/provider-read-cache/index.test.js +12 -0
- package/server/lib/relay/DOCUMENTATION.md +17 -1
- package/server/lib/session-knowledge/DOCUMENTATION.md +17 -0
- package/server/lib/session-knowledge/runtime.js +29 -6
- package/server/lib/session-knowledge/runtime.test.js +26 -1
- package/server/lib/source-control/audit-storage.js +1 -0
- package/server/lib/source-control/mutation-storage.js +3 -0
- package/server/lib/spaces/DOCUMENTATION.md +14 -9
- package/server/lib/spaces/code-out.js +13 -4
- package/server/lib/spaces/code-out.test.js +5 -3
- package/server/lib/spaces/dispatcher.js +12 -5
- package/server/lib/spaces/dispatcher.test.js +19 -1
- package/server/lib/spaces/gatekeeper-channel.js +8 -7
- package/server/lib/spaces/gatekeeper-channel.test.js +10 -0
- package/server/lib/spaces/gatekeeper-program.cjs +38 -3
- package/server/lib/spaces/gatekeeper-program.test.js +20 -0
- package/server/lib/spaces/hardening.js +14 -1
- package/server/lib/spaces/hardening.test.js +5 -0
- package/server/lib/spaces/host-providers.js +165 -0
- package/server/lib/spaces/host-providers.test.js +100 -0
- package/server/lib/spaces/host.js +16 -4
- package/server/lib/spaces/journey.js +87 -17
- package/server/lib/spaces/journey.test.js +90 -2
- package/server/lib/spaces/layout.js +15 -5
- package/server/lib/spaces/places/docker-live-support.js +2 -0
- package/server/lib/spaces/places/docker.test.js +2 -0
- package/server/lib/spaces/places/fake-docker.js +3 -0
- package/server/lib/spaces/places/grants.docker.live.test.js +71 -7
- package/server/lib/spaces/routes.js +9 -0
- package/server/lib/spaces/routes.test.js +4 -2
- package/server/lib/spaces/space-opencode.js +31 -14
- package/server/lib/spaces/space-opencode.test.js +15 -2
- package/server/lib/spaces/space-records.js +8 -0
- package/server/lib/spaces/space-records.test.js +7 -3
- package/server/lib/spaces/websocket.test.js +13 -1
- package/server/lib/ui-auth/ui-auth.js +28 -3
- package/server/lib/ui-auth/ui-auth.test.js +31 -0
- package/dist/assets/MarkdownRendererImpl-B2LsA09C.js +0 -1
- package/dist/assets/PlanView-Dt5EN_JK.js +0 -5
- package/dist/assets/SettingsView-BolP_tuu.js +0 -30
- package/dist/assets/SourceBoardView-yca1qvgB.js +0 -1
- package/dist/assets/SpaceAccessDialog-CZ-u75py.js +0 -1
- package/dist/assets/katex-rNcbfUj4.css +0 -1
- package/dist/assets/katex.min-DQ8qF6NR.js +0 -65
- package/dist/assets/main-CVHM3_8W.js +0 -1048
- package/dist/assets/markdownCore-D5ZOJXeO.js +0 -9
- package/dist/assets/pl-Bj-Hy0X5.js +0 -20
- package/dist/assets/renderElectronMiniChatApp-B_5BeSF6.js +0 -2
- package/dist/assets/renderMobileApp-DGEXUTk-.js +0 -25
- package/dist/assets/runtimeEndpointReset-CIpvn8QG.js +0 -59
- package/dist/assets/sessionOwnership-BZoGed9N.js +0 -1
- package/dist/assets/tr-qMRMBQ8r.js +0 -11
- package/dist/assets/useAppFontEffects-Bih1DxXi.js +0 -745
- package/dist/assets/vendor-tanstack-react-virtual-CvuLsk7D.js +0 -1
- package/dist/assets/vendor-tanstack-virtual-core-DPaNcJcT.js +0 -1
|
@@ -0,0 +1,1048 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-C0QgeC9O.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-Cs6k0JKv.js","assets/katex.min-EZjpSwGK.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-BZNCT55U.css","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-Dozz-7fb.js","assets/vendor-tanstack-virtual-core-DKBj55Em.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-dar6chwA.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-B66jUSmE.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DyL0aCoH.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-Cem6LjJ8.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-CIqXJolH.js","assets/vendor-codemirror-lang-json-C9rLLO0q.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-9qjxcVkg.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-D7VQUxeE.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-Cikh4w2I.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-DBekkZIx.js","assets/vendor-codemirror-lang-python-DVl8-2Op.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-6CNNzem4.js","assets/InProgressOperationBanner-JFV70YFh.js","assets/changesTree-CePHbFcj.js","assets/PierreDiffViewer-D0zX2Msu.js","assets/parseDiffFromFile-DEjkjYod.js","assets/computeVirtualFileMetrics-Cx05cmWI.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-DW43IghW.js","assets/pierreDiffTint-3oatL635.js","assets/Virtualizer-Bl4Cf-H-.js","assets/useInlineCommentController-CVYaPzfO.js","assets/appThemeRegistry-xm_W0svA.js","assets/textMateThemeFromAppTheme-DLJBL6al.js","assets/useRootScrollLock-Dov-44ov.js","assets/moveWorkspacePath-CnYc96Xo.js","assets/sessionOwnership-BBuf0UCB.js","assets/WalkthroughView-B2BJJ4u5.js","assets/patchFileDiff-D__42sau.js","assets/useCallableModelProviders-BsGEzsl2.js","assets/DiffView-B5yeuxv8.js","assets/SubmoduleDiffSummary-VrNUbIqF.js","assets/FilesView-ni2zfAwL.js","assets/flexokiTheme-DKNCYSqL.js","assets/vendor-codemirror-search-BKAwkhkm.js","assets/vendor-replit-codemirror-vim-CKWqK1yR.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/fileContentPoller-C0f20jNG.js","assets/JsonTreeView-RsbV4Usa.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-Duq5CiuG.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/shikiHighlight-CweIj1cL.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/scheduledTasksApi-BbnQ4W-W.js","assets/GuestSurfacePane-D1gLktSj.js","assets/SettingsWindow-Dd1hHvgh.js","assets/SettingsView-CVpfbdob.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/restartOpenCode-FYqjpaWc.js","assets/CommandPalette-BICwnwAZ.js","assets/HelpDialog-CxC6qTaS.js","assets/ProjectActionsDialog-D660By4K.js","assets/OpenCodeStatusDialog-Cxa2yqOB.js","assets/RunOverview-C1uTMnQS.js","assets/ScheduledTasksDialog-S-gAgo7Z.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/ArchiveView-sbNreasJ.js","assets/UsageStatsView-BxtYEAa0.js","assets/SourceBoardView-DbGWAxtS.js","assets/WorktreesView-Dv0AO9dF.js","assets/SpacesView-CYCrlp0D.js","assets/SpaceRow-7Z6ebRtm.js","assets/SpaceAccessDialog-muTSsEJ9.js","assets/spaceNetwork-tH2d5Mgs.js","assets/SpaceApplyDialog-Dsf6MNGm.js","assets/space-apply-CEi013sa.js","assets/SpaceSetupOutput-BytPfCOC.js","assets/OnboardingScreen-BDT-J2JP.js","assets/AboutDialog-Ctk2zvrv.js","assets/MemoryDebugPanel-caUWOKiz.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as Xe,j as n,R as l,r as fs,c as Wa,h as Nm}from"./vendor-react-BUCujlKS.js";import{u as de,cu as Us,b as $s,m as In,e as xs,cJ as mu,aq as Uo,$ as Xt,a1 as Go,n as vt,aX as Cs,ao as un,al as wo,am as vn,an as Sr,aF as Mm,as as gu,cK as Am,b8 as Ps,cL as Ha,cM as ko,cN as qo,cO as Om,cP as vr,cQ as ta,cR as Yo,cS as rr,a6 as jo,l as Gs,cT as Qn,aT as Bm,cU as Xo,cV as Fm,cW as Lm,cX as Sn,cY as _m,cZ as bu,c_ as $m,c$ as zm,cA as yu,d0 as Km,q as Wm,t as Hm,bc as Vm,a$ as Qo,b0 as Um,b2 as Gm,b3 as qm,ag as Ym,ak as Xm,af as Vs,v as Co,aQ as Po,d1 as Qm,ar as Va,ct as Ua,be as Eo,aH as on,bq as Jt,a5 as xu,ay as Zo,d2 as Zm,d3 as Jm,d4 as eg,aI as Su,cr as Bt,d5 as vu,cE as tg,d6 as sa,d7 as sg,bO as wu,bP as ku,a0 as ng,br as rg,bf as og,bs as ju,cG as Jl,d8 as ig,a_ as ag,d9 as ec,bD as Cu,ap as Pu,bi as tc,bj as Eu,bu as lg,bh as cg,da as dg,db as ug,aD as fg,aB as pg,dc as hg,aJ as mg,bg as gg,bG as bg,dd as yg,de as xg,df as sc,dg as Ei,dh as nc,di as rc,dj as Sg,au as oc,dk as vg,dl as wg,dm as kg,aC as jg,dn as Cg,i as Pg,a as Eg}from"./katex.min-EZjpSwGK.js";import{_ as os}from"./vendor-vite-runtime-DD1OZmLC.js";import{bc as Ig,bd as Ga,a9 as Tg,ak as Iu,be as Dg,a4 as Rg,a5 as Ng,a7 as na,i as Mg,k as Ag,p as Og,j as Bg,h as Fg,m as Lg,n as _g,q as $g,R as zg,U as Kg,M as Wg,Y as Hg,Z as Vg,V as Ug,I as Gg,y as qg,u as Yg,C as Xg,bf as Zn,as as Qg,bg as Tu,bh as Du,bi as Zg,bj as Ru,bk as Wn,bl as ic,bm as ac,bn as Ii,bo as lc,G as Nu,D as Ar,F as Mu,B as qa,a1 as Jg,a2 as eb,ap as tb,aq as sb,$ as nb,aH as rb,aI as Au,bp as ob,ar as ib,a_ as ab,S as cc,bq as lb,aM as Ya,aL as cb,br as ra,bs as db,aa as ub,a8 as Ou,bt as Fn,bu as Bu,aj as fb,bv as Fu,bw as pb,bx as dc,ab as hb,ac as mb,b as gb,a as bb,by as yb,bz as pr,ag as xb,bA as Sb,ah as uc,a3 as wr,ad as vb,a6 as wb,ai as kb,a$ as fc,bB as jb,bC as Cb,bD as Pb,bE as Eb,bF as Ib,bG as Tb,bH as pc,bI as Db,at as Rb,aG as Nb,ax as Mb,bJ as Ab,aD as Ob,aE as Bb,aK as Fb,bK as Lb,bL as _b,b4 as $b,bM as zb,aN as Kb,aJ as Wb,bN as Hb,av as Vb,bO as Ub,bP as Gb,az as qb,ay as Yb,aA as Xb,aC as Qb,aB as Zb,aF as Jb,bQ as ey,bR as ty}from"./runtimeEndpointReset-6CNNzem4.js";import{u as Ct,k0 as sy,I as Q,U as zt,V as Ft,T as Kt,aB as dr,a3 as ns,F as xt,cZ as Lu,L as De,c4 as Xa,c5 as Qa,c6 as Za,lq as Xr,G as Es,J as or,el as _u,ek as $u,aX as oa,lr as ny,ls as zu,aY as Ku,dE as Wu,aM as Ts,aN as Ds,aO as Rs,cG as jn,aP as Zt,l as Zs,E as Js,D as en,Q as Jo,_ as ir,q as qs,t as Ys,z as ze,lt as ry,lu as oy,lv as hc,lw as mc,a2 as Hu,lx as iy,ly as gc,lz as ay,lA as Vu,lB as Ja,lC as ia,bG as Uu,lD as ly,lE as cy,lF as dy,gz as Gu,lG as ei,lH as uy,gq as Gn,aA as Tn,lI as fy,gr as py,d8 as qu,lJ as hy,d9 as my,lK as Yu,av as ti,lL as Xu,lM as Qu,lN as Zu,lO as Ju,lP as ef,lQ as tf,iq as ur,a$ as el,dd as sf,o as Cn,B as It,lR as nf,fa as tl,lS as Io,n as Or,aQ as ws,lT as gy,b5 as sl,ah as rf,ak as of,lU as by,lV as yy,ci as Ws,iC as af,iB as lf,eD as wn,cF as aa,im as xy,dV as Sy,az as hn,lW as vy,lX as wy,cV as ky,cU as jy,fx as Cy,f4 as Py,fN as Ey,eC as cf,dW as cn,e4 as Iy,ad as ds,e3 as df,eF as la,eE as qn,eG as uf,lY as ff,lZ as pf,l_ as Ty,l$ as Dy,jZ as Ry,eI as nl,bR as Ny,bP as My,bO as Ay,bQ as Oy,bJ as By,y as To,b_ as bc,cA as Fy,cC as yc,m0 as Ly,m1 as _y,j_ as $y,cY as si,e2 as zy,e6 as rl,eQ as Ky,e5 as Wy,ay as kn,fE as hf,c3 as Hy,l4 as Un,ab as Vy,m2 as Uy,$ as is,gt as mf,m3 as Gy,bL as qy,x as gf,by as Yy,m4 as Xy,m5 as Qy,f9 as bf,m6 as Br,m7 as yf,m8 as ca,m9 as da,ma as Ti,gf as Ln,ge as uo,d2 as Zy,mb as Jy,mc as Fr,cx as ol,md as il,me as ex,c7 as Pn,mf as tx,a8 as sx,b6 as nx,eS as rx,b9 as ox,fY as ix,f$ as ax,e9 as lx,g0 as cx,f8 as dx,gd as al,gg as xf,mg as ni,gh as ll,gi as cl,cj as ux,C as fx,aC as px,mh as Di,mi as hx,mj as mx,mk as Sf,ml as gx,mm as vf,hy as bx,mn as yx,mo as xx,mp as Sx,mq as vx,ai as wx,mr as xc,ms as kx,mt as Sc,mu as vc,gO as Do,gn as dl,ch as wf,mv as jx,gM as ri,gP as kr,mw as kf,li as us,ip as jf,ir as Cf,ga as Pf,gb as Ef,gc as If,mx as Cx,my as Tf,mz as Px,mA as Df,mB as ua,bN as Rf,mC as ul,mD as Ex,mE as Ix,mF as Tx,cf as Nf,lp as es,mG as Dx,kw as Mf,mH as Af,mI as Of,mJ as Ir,mK as wc,mL as Rx,mM as Tr,mN as Nx,mO as Mx,mP as fl,mQ as Ro,mR as pl,mS as Bf,mT as Ff,mU as Lf,mV as _f,aa as Ax,mW as Ox,gv as Bx,gD as Fx,gH as hl,gQ as Lx,gE as _x,gF as $x,mX as zx,em as Kx,N as Wx,en as $f,kf as Hx,mY as Vx,mZ as Ux,m_ as Jn,m$ as Gx,gw as qx,n0 as fo,dk as oi,gG as fa,n1 as Yx,gR as Xx,n2 as Qx,n3 as zf,O as En,n4 as Zx,gK as Jx,n5 as eS,eb as tS,bT as Kf,n6 as sS,n7 as nS,n8 as rS,ku as oS,n9 as iS,a4 as aS,gN as lS,kh as cS,f5 as Dn,na as dS,nb as uS,nc as fS,ct as pS,nd as hS,dv as kc,du as jc,bI as Cc,ne as mS,nf as gS,d1 as bS,ng as yS,gy as Pc,gA as Ri,gB as xS,nh as SS,gC as vS,ni as wS,k as kS,nj as Ec,nk as Ni,nl as Rn,nm as Hn,jU as Ic,nn as jS,no as CS,jP as PS,np as ES,nq as IS,nr as TS,eu as pa,fU as DS,ns as Wf,nt as RS,cm as NS,nu as Tc,nv as MS,ck as AS,dG as Hf,nw as ha,W as Vf,dF as Uf,cg as Gf,nx as OS,ny as qf,cM as po,i5 as BS,go as FS,i6 as LS,gs as _S,cE as $S,le as Dc,nz as zS,dg as KS,nA as WS,cv as Rc,dh as HS,dj as VS,di as US,dq as GS,dp as qS,h6 as YS,dn as XS,dl as QS,dm as ZS,a as JS,s as e1,b as t1,c as s1,hd as n1,dw as r1,dx as o1,dy as i1,dz as a1}from"./useAppFontEffects-Cs6k0JKv.js";import{u as Yf,S as l1,W as Xf,f as Qf,a as c1,G as d1,b as u1,c as f1}from"./useRootScrollLock-Dov-44ov.js";import{f as Lr,h as zs,T as _r,M as $r,D as zr,j as Kr,i as Zf,d as p1,b as h1,k as m1}from"./vendor-dnd-kit-core-BZknOX2w.js";import{r as g1,h as b1,u as Wr,S as ii,s as Jf,a as ml,v as gl}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Hr}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as ep,M as tp,k as sp,l as ma,m as ga,n as ba,o as np,p as y1,q as x1}from"./vendor-base-ui-CXFyogip.js";import{c as Vr,u as ar,p as S1}from"./vendor-zustand-BAGL70zf.js";import{r as Dr,a as ai,n as v1,s as Ks,o as ya,b as Nc}from"./vendor-zod-CVhJ1Zpv.js";import{D as w1,a as k1,m as Mc,G as j1}from"./moveWorkspacePath-CnYc96Xo.js";import{c as C1}from"./sessionOwnership-BBuf0UCB.js";import{u as P1}from"./vendor-tanstack-react-virtual-Dozz-7fb.js";import{m as E1,d as I1}from"./vendor-tanstack-virtual-core-DKBj55Em.js";const T1=t=>{const e=Xe.c(23),{directory:s,className:r,iconClassName:i}=t,{t:o}=Ct(),c=de(D1);let a;e[0]!==s?(a=Us(s),e[0]=s,e[1]=a):a=e[1];const d=a;let u;e[2]!==d?(u=w=>sy(d?w.journey?.get(d):void 0),e[2]=d,e[3]=u):u=e[3];const f=$s(u);let p;e[4]!==d?(p=w=>d?w.actions.get(d)?.kind==="running":!1,e[4]=d,e[5]=p):p=e[5];const m=$s(p);if(!c||!d||!f||In())return null;let g;e[6]!==o?(g=o("spaces.header.apply"),e[6]=o,e[7]=g):g=e[7];const y=g;let v;e[8]!==d?(v=()=>$s.getState().openApplyDialog(d),e[8]=d,e[9]=v):v=e[9];let x;e[10]!==i?(x=n.jsx(Q,{name:"git-merge",className:i}),e[10]=i,e[11]=x):x=e[11];let b;e[12]!==m||e[13]!==r||e[14]!==y||e[15]!==v||e[16]!==x?(b=n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":y,disabled:m,onClick:v,className:r,children:x})}),e[12]=m,e[13]=r,e[14]=y,e[15]=v,e[16]=x,e[17]=b):b=e[17];let h;e[18]!==y?(h=n.jsx(Ft,{side:"bottom",children:y}),e[18]=y,e[19]=h):h=e[19];let S;return e[20]!==b||e[21]!==h?(S=n.jsxs(Kt,{children:[b,h]}),e[20]=b,e[21]=h,e[22]=S):S=e[22],S};function D1(t){return t.isolatedSpacesEnabled}function R1(t){const e=Xe.c(36),{directory:s,className:r}=t,{currentTheme:i}=dr(),o=ns(A1),c=xt(M1),a=xs(N1);let d;e[0]!==s||e[1]!==a?(d=mu(s,a),e[0]=s,e[1]=a,e[2]=d):d=e[2];const u=d;let f;e[3]!==s||e[4]!==u||e[5]!==o||e[6]!==c?(f=u||!s?null:Lu(o,c,s),e[3]=s,e[4]=u,e[5]=o,e[6]=c,e[7]=f):f=e[7];const p=f;if(u){let T;e[8]!==r?(T=De("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),e[8]=r,e[9]=T):T=e[9];let O;return e[10]!==T?(O=n.jsx(Q,{name:"chat-4",className:T}),e[10]=T,e[11]=O):O=e[11],O}if(!p)return null;const m=p.icon?Xa[p.icon]:null;let g;e[12]!==p.color?(g=Qa(p.color)??void 0,e[12]=p.color,e[13]=g):g=e[13];const y=g;let v;e[14]!==r||e[15]!==y||e[16]!==m?(v=m?n.jsx(Q,{name:m,className:De("h-3.5 w-3.5 shrink-0",r),style:y?{color:y}:void 0}):n.jsx(Q,{name:"folder",className:De("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),style:y?{color:y}:void 0}),e[14]=r,e[15]=y,e[16]=m,e[17]=v):v=e[17];const x=v;if(!p.iconImage)return x;let b;e[18]!==r?(b=De("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[18]=r,e[19]=b):b=e[19];let h;e[20]!==p.iconBackground?(h=p.iconBackground?{backgroundColor:p.iconBackground}:void 0,e[20]=p.iconBackground,e[21]=h):h=e[21];let S;e[22]!==p.iconImage||e[23]!==p.id?(S={id:p.id,iconImage:p.iconImage},e[22]=p.iconImage,e[23]=p.id,e[24]=S):S=e[24];let w;e[25]!==i.colors.surface.foreground||e[26]!==i.metadata.variant?(w={themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},e[25]=i.colors.surface.foreground,e[26]=i.metadata.variant,e[27]=w):w=e[27];let j;e[28]!==x||e[29]!==S||e[30]!==w?(j=n.jsx(Za,{project:S,options:w,className:"h-full w-full object-contain",fallback:x}),e[28]=x,e[29]=S,e[30]=w,e[31]=j):j=e[31];let k;return e[32]!==b||e[33]!==h||e[34]!==j?(k=n.jsx("span",{className:b,style:h,children:j}),e[32]=b,e[33]=h,e[34]=j,e[35]=k):k=e[35],k}function N1(t){return t.homeDirectory}function M1(t){return t.availableWorktreesByProject}function A1(t){return t.projects}const xr=24,O1=(t,e,s=xr)=>{const r=e.right-(t.right-s);if(r>0)return r;const i=e.left-(t.left+s);return i<0?i:0},B1=({transform:t})=>({...t,y:0}),F1=16,L1=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*F1:t.deltaY;t.currentTarget.scrollLeft+=Uo(t.currentTarget)?-e:e},_1={Item:Zt,Separator:jn},$1={Item:({className:t,...e})=>n.jsx(tp,{className:De(Ku,t),...e}),Separator:({className:t,...e})=>n.jsx(ep,{className:De(zu,t),...e})},z1=t=>{const e=Xe.c(63),{tab:s,isActive:r,suppressControls:i,onSelect:o,onClose:c,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:f}=t,{t:p}=Ct(),[m,g]=l.useState(!1),[y,v]=l.useState(!1),[x,b]=l.useState(!1);let h;e[0]!==s.id?(h={id:s.id},e[0]=s.id,e[1]=h):h=e[1];const{attributes:S,listeners:w,setNodeRef:j,transform:k,transition:T,isDragging:O}=Wr(h);let $;e[2]!==p||e[3]!==s.session.title?($=s.session.title?.trim()||p("sessions.sidebar.session.untitled"),e[2]=p,e[3]=s.session.title,e[4]=$):$=e[4];const D=$,E=!i&&(m||y),R=s.id;let z;e[5]!==s.session?(z=or(s.session),e[5]=s.session,e[6]=z):z=e[6];const _=Ga(R,z),W=_u(s.id),N=W!==null,C=$u(s.id)>0&&!r&&!N,P=N||C;let I;e[7]!==d||e[8]!==x||e[9]!==r||e[10]!==m||e[11]!==o||e[12]!==s?(I=he=>({session:s.session,open:m||x,isActive:r,select:()=>o(s),closeOtherTabs:()=>d(s.id),components:he}),e[7]=d,e[8]=x,e[9]=r,e[10]=m,e[11]=o,e[12]=s,e[13]=I):I=e[13];const H=I;let A;e[14]!==k?(A=Hr.Translate.toString(k),e[14]=k,e[15]=A):A=e[15];let F;e[16]!==A||e[17]!==T?(F={transform:A,transition:T},e[16]=A,e[17]=T,e[18]=F):F=e[18];const L=O&&"z-10 opacity-60";let X;e[19]!==L?(X=De("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",L),e[19]=L,e[20]=X):X=e[20];const re=r?"true":"false";let te;e[21]!==r?(te=r?{"data-active-session-tab":!0}:{},e[21]=r,e[22]=te):te=e[22];let M;e[23]!==u?(M=he=>u?.(he),e[23]=u,e[24]=M):M=e[24];let ee;e[25]!==f||e[26]!==r||e[27]!==_||e[28]!==H||e[29]!==m||e[30]!==c||e[31]!==u||e[32]!==o||e[33]!==E||e[34]!==a||e[35]!==P||e[36]!==i||e[37]!==p||e[38]!==s||e[39]!==D||e[40]!==W?(ee=n.jsx(sp,{render:he=>n.jsxs("div",{...he,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(s),onKeyDown:r?void 0:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),o(s))},onAuxClick:G=>{G.button===1&&(G.preventDefault(),c(s.id))},"data-controls-open":E?"true":"false",className:De("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":De("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",E&&"bg-interactive-hover text-foreground")),children:[n.jsxs("div",{className:De("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pe-10",E&&"pe-10"),children:[n.jsx(R1,{directory:or(s.session),className:"me-1.5"}),n.jsx("div",{className:De("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?f:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:n.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[13px] font-medium leading-4",children:D})})}),_?n.jsx(Q,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":p("sessions.aiRename.generating")}):P?n.jsx(Wu,{state:W??"unread",className:De("ms-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",E&&"opacity-0")}):null]}),i?null:n.jsxs("div",{onClick:W1,onPointerDown:H1,className:De("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(Ts,{open:m,onOpenChange:G=>{g(G),G&&v(!0)},onOpenChangeComplete:G=>{G||v(!1),u?.(G)},children:[n.jsx(Ds,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":p("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(Q,{name:"more",className:"size-4"})})}),n.jsx(Rs,{align:"start",className:"min-w-[190px]",children:a(H(_1))})]}),n.jsx("button",{type:"button","aria-label":p("header.sessionTabs.closeTab"),onClick:()=>c(s.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(Q,{name:"close",className:"size-4"})})]})]})}),e[25]=f,e[26]=r,e[27]=_,e[28]=H,e[29]=m,e[30]=c,e[31]=u,e[32]=o,e[33]=E,e[34]=a,e[35]=P,e[36]=i,e[37]=p,e[38]=s,e[39]=D,e[40]=W,e[41]=ee):ee=e[41];let V,Ee;e[42]===Symbol.for("react.memo_cache_sentinel")?(V={color:"var(--surface-elevated-foreground)"},Ee=De(oa,"min-w-[190px]"),e[42]=V,e[43]=Ee):(V=e[42],Ee=e[43]);let ve;e[44]!==H||e[45]!==a?(ve=a(H($1)),e[44]=H,e[45]=a,e[46]=ve):ve=e[46];let ce;e[47]!==ve?(ce=n.jsx(ma,{children:n.jsx(ga,{className:"app-region-no-drag z-50",children:n.jsx(ba,{"data-slot":"dropdown-menu-content",style:V,className:Ee,children:ve})})}),e[47]=ve,e[48]=ce):ce=e[48];let Be;e[49]!==x||e[50]!==M||e[51]!==ee||e[52]!==ce?(Be=n.jsxs(np,{open:x,onOpenChange:b,onOpenChangeComplete:M,children:[ee,ce]}),e[49]=x,e[50]=M,e[51]=ee,e[52]=ce,e[53]=Be):Be=e[53];let me;return e[54]!==S||e[55]!==w||e[56]!==j||e[57]!==re||e[58]!==te||e[59]!==Be||e[60]!==F||e[61]!==X?(me=n.jsx("div",{ref:j,style:F,className:X,"data-active":re,...te,...S,...w,children:Be}),e[54]=S,e[55]=w,e[56]=j,e[57]=re,e[58]=te,e[59]=Be,e[60]=F,e[61]=X,e[62]=me):me=e[62],me},K1=t=>{const e=Xe.c(66),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,c=i===void 0?!1:i,{t:a,direction:d}=Ct(),u=d==="rtl",f=Xr(V1),p=Xr(U1),m=Xr(G1),g=Xr(q1),y=xt(Y1),v=xt(X1),x=Es(Q1),b=Ig(y);let h,S;e[0]!==b||e[1]!==y||e[2]!==p?(h=()=>{y&&p(y,b)},S=[y,b,p],e[0]=b,e[1]=y,e[2]=p,e[3]=h,e[4]=S):(h=e[3],S=e[4]),l.useEffect(h,S);let w;if(e[5]!==x){w=new Map;for(const U of x)w.set(U.id,U);e[5]=x,e[6]=w}else w=e[6];const j=w;let k;if(e[7]!==j||e[8]!==f){k=[];for(const U of f){const ie=j.get(U);ie&&k.push({id:U,session:ie})}e[7]=j,e[8]=f,e[9]=k}else k=e[9];const T=k;let O;e[10]!==v?(O=U=>{v(U.id,or(U.session))},e[10]=v,e[11]=O):O=e[11];const $=O,D=Z1;let E;e[12]!==m||e[13]!==y||e[14]!==$||e[15]!==T?(E=U=>{if(m(U),y&&y!==U){const ie=T.find(we=>we.id===U);ie&&$(ie)}},e[12]=m,e[13]=y,e[14]=$,e[15]=T,e[16]=E):E=e[16];const R=E;let z;e[17]===Symbol.for("react.memo_cache_sentinel")?(z={activationConstraint:{distance:8}},e[17]=z):z=e[17];let _;e[18]===Symbol.for("react.memo_cache_sentinel")?(_={activationConstraint:{delay:200,tolerance:6}},e[18]=_):_=e[18];const W=Lr(zs($r,z),zs(_r,_));let N;e[19]!==g?(N=U=>{const{active:ie,over:we}=U;we&&ie.id!==we.id&&g(String(ie.id),String(we.id))},e[19]=g,e[20]=N):N=e[20];const Y=N,C=l.useRef(null);let P;e[21]===Symbol.for("react.memo_cache_sentinel")?(P={left:!1,right:!1},e[21]=P):P=e[21];const[I,H]=l.useState(P);let A;e[22]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const U=C.current;if(!U)return;const ie=U.scrollWidth-U.clientWidth,we=Uo(U)?ie+U.scrollLeft:U.scrollLeft,pe=we>2,Se=we<ie-2;H(Ce=>Ce.left===pe&&Ce.right===Se?Ce:{left:pe,right:Se})},e[22]=A):A=e[22];const F=A;let L;e[23]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{F();const U=C.current;if(!U||!globalThis.ResizeObserver)return;const ie=new ResizeObserver(F);return ie.observe(U),()=>ie.disconnect()},e[23]=L):L=e[23];let X;e[24]!==T.length?(X=[F,T.length],e[24]=T.length,e[25]=X):X=e[25],l.useEffect(L,X);let re;e[26]===Symbol.for("react.memo_cache_sentinel")?(re=()=>{const U=C.current,ie=U?.querySelector("[data-active-session-tab]");if(!U||!ie)return;const we=O1(U.getBoundingClientRect(),ie.getBoundingClientRect());we!==0&&(U.scrollLeft=U.scrollLeft+we,F())},e[26]=re):re=e[26];let te;e[27]!==y?(te=[y,F],e[27]=y,e[28]=te):te=e[28],l.useEffect(re,te);const M=I.left&&I.right?`linear-gradient(to right, transparent, black ${xr}px, black calc(100% - ${xr}px), transparent)`:I.left?`linear-gradient(to right, transparent, black ${xr}px)`:I.right?`linear-gradient(to right, black calc(100% - ${xr}px), transparent)`:void 0;let ee;e[29]!==T?(ee=T.map(J1),e[29]=T,e[30]=ee):ee=e[30];const V=ee;let Ee;e[31]!==y||e[32]!==T?(Ee=!!y&&!T.some(U=>U.id===y),e[31]=y,e[32]=T,e[33]=Ee):Ee=e[33];const ve=Ee;let ce;e[34]!==a?(ce=a("header.sessionTabs.stripAria"),e[34]=a,e[35]=ce):ce=e[35];let Be;e[36]!==M?(Be=M?{maskImage:M,WebkitMaskImage:M}:void 0,e[36]=M,e[37]=Be):Be=e[37];let me;e[38]===Symbol.for("react.memo_cache_sentinel")?(me=[B1],e[38]=me):me=e[38];const he=u?g1:b1;let G;e[39]!==o||e[40]!==y||e[41]!==R||e[42]!==$||e[43]!==r||e[44]!==s||e[45]!==c||e[46]!==T?(G=T.map(U=>n.jsx(z1,{tab:U,isActive:U.id===y,suppressControls:U.id===y&&c,onSelect:$,onClose:D,renderMenu:s,closeOtherTabs:R,onMenuOpenChangeComplete:r,children:U.id===y?o:null},U.id)),e[39]=o,e[40]=y,e[41]=R,e[42]=$,e[43]=r,e[44]=s,e[45]=c,e[46]=T,e[47]=G):G=e[47];let le;e[48]!==he||e[49]!==G||e[50]!==V?(le=n.jsx(ii,{items:V,strategy:he,children:G}),e[48]=he,e[49]=G,e[50]=V,e[51]=le):le=e[51];let ye;e[52]!==Y||e[53]!==W||e[54]!==le?(ye=n.jsx(zr,{sensors:W,collisionDetection:Kr,modifiers:me,onDragEnd:Y,children:le}),e[52]=Y,e[53]=W,e[54]=le,e[55]=ye):ye=e[55];let Ie;e[56]!==o||e[57]!==ve?(Ie=ve?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:o})}):null,e[56]=o,e[57]=ve,e[58]=Ie):Ie=e[58];let K;e[59]!==Be||e[60]!==ye||e[61]!==Ie?(K=n.jsxs("div",{ref:C,onScroll:F,onWheel:L1,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Be,children:[ye,Ie]}),e[59]=Be,e[60]=ye,e[61]=Ie,e[62]=K):K=e[62];let se;return e[63]!==ce||e[64]!==K?(se=n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ce,children:K}),e[63]=ce,e[64]=K,e[65]=se):se=e[65],se};function W1(t){return t.stopPropagation()}function H1(t){return t.stopPropagation()}function V1(t){return t.tabIds}function U1(t){return t.ensureTab}function G1(t){return t.closeOtherTabs}function q1(t){return t.reorderTabs}function Y1(t){return t.currentSessionId}function X1(t){return t.setCurrentSession}function Q1(t){return t.activeSessions}function Z1(t){ny(t)}function J1(t){return t.id}const ev=500;function ss(t){const e=Xe.c(9),{hint:s,children:r}=t,[i,o]=l.useState(!1);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(f,p)=>{f&&p.reason==="trigger-focus"||o(f)},e[0]=c):c=e[0];let a;e[1]!==r?(a=n.jsx(zt,{asChild:!0,children:r}),e[1]=r,e[2]=a):a=e[2];let d;e[3]!==s?(d=n.jsx(Ft,{side:"right",sideOffset:8,className:"max-w-64",children:s}),e[3]=s,e[4]=d):d=e[4];let u;return e[5]!==i||e[6]!==a||e[7]!==d?(u=n.jsxs(Kt,{delayDuration:ev,open:i,onOpenChange:c,children:[a,d]}),e[5]=i,e[6]=a,e[7]=d,e[8]=u):u=e[8],u}const tv=t=>{const e=Xe.c(29),{open:s,onOpenChange:r,onPick:i}=t,{t:o}=Ct(),c=ns(sv),a=xs(nv);let d;e[0]!==o?(d=o("sessions.moveChatToProject.title"),e[0]=o,e[1]=d):d=e[1];let u;e[2]!==d?(u=n.jsx(Zs,{children:d}),e[2]=d,e[3]=u):u=e[3];let f;e[4]!==o?(f=o("sessions.moveChatToProject.description"),e[4]=o,e[5]=f):f=e[5];let p;e[6]!==f?(p=n.jsx(Js,{children:f}),e[6]=f,e[7]=p):p=e[7];let m;e[8]!==u||e[9]!==p?(m=n.jsxs(en,{children:[u,p]}),e[8]=u,e[9]=p,e[10]=m):m=e[10];let g;if(e[11]!==a||e[12]!==r||e[13]!==i||e[14]!==c){let b;e[16]!==a||e[17]!==r||e[18]!==i?(b=h=>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),i(h.path)},children:[n.jsx(Q,{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:h.label?.trim()||Jo(h.path)}),n.jsx("span",{className:"min-w-0 max-w-[45%] truncate typography-micro text-muted-foreground",children:ir(h.path,a)})]},h.id),e[16]=a,e[17]=r,e[18]=i,e[19]=b):b=e[19],g=c.map(b),e[11]=a,e[12]=r,e[13]=i,e[14]=c,e[15]=g}else g=e[15];let y;e[20]!==g?(y=n.jsx("div",{className:"flex max-h-[50vh] flex-col gap-0.5 overflow-y-auto",children:g}),e[20]=g,e[21]=y):y=e[21];let v;e[22]!==m||e[23]!==y?(v=n.jsxs(qs,{className:"max-w-md",children:[m,y]}),e[22]=m,e[23]=y,e[24]=v):v=e[24];let x;return e[25]!==r||e[26]!==s||e[27]!==v?(x=n.jsx(Ys,{open:s,onOpenChange:r,children:v}),e[25]=r,e[26]=s,e[27]=v,e[28]=x):x=e[28],x};function sv(t){return t.projects}function nv(t){return t.homeDirectory}function Ac(t){const e=Xe.c(28),{sessionId:s,onArchive:r,Item:i}=t,{t:o}=Ct();let c;e[0]!==s?(c=k=>!!k.entityById.get(s)?.time.archived,e[0]=s,e[1]=c):c=e[1];const a=Es(c);let d;e[2]!==s?(d=k=>!!k.entityById.get(s)?.parentID,e[2]=s,e[3]=d):d=e[3];const u=Es(d),f=xt(rv);let p;e[4]!==s||e[5]!==o||e[6]!==f?(p=async()=>{await f(s)?ze.success(o("sessions.sidebar.session.restore.success")):ze.error(o("sessions.sidebar.session.restore.error"))},e[4]=s,e[5]=o,e[6]=f,e[7]=p):p=e[7];const m=p;if(a&&u)return null;const g=a?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let y;e[8]!==o||e[9]!==g?(y=o(g),e[8]=o,e[9]=g,e[10]=y):y=e[10];let v;e[11]!==a||e[12]!==r||e[13]!==m?(v=a?()=>{m()}:r,e[11]=a,e[12]=r,e[13]=m,e[14]=v):v=e[14];const x=a?"inbox-unarchive":"inbox-archive";let b;e[15]!==x?(b=n.jsx(Q,{name:x,className:"me-1 size-4"}),e[15]=x,e[16]=b):b=e[16];const h=a?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let S;e[17]!==o||e[18]!==h?(S=o(h),e[17]=o,e[18]=h,e[19]=S):S=e[19];let w;e[20]!==i||e[21]!==S||e[22]!==v||e[23]!==b?(w=n.jsxs(i,{onClick:v,children:[b,S]}),e[20]=i,e[21]=S,e[22]=v,e[23]=b,e[24]=w):w=e[24];let j;return e[25]!==w||e[26]!==y?(j=n.jsx(ss,{hint:y,children:w}),e[25]=w,e[26]=y,e[27]=j):j=e[27],j}function rv(t){return t.unarchiveSession}const rp=async t=>{const{entry:e,session:s}=t,r=Xt(),i={sessionId:s.id,sessionTitle:s.title,directory:s.directory};if(!(ry(e.action)&&oy(e.guest,"conversation"))){await hc(e,mc(e.action.id,i),t.t,r);return}let c=!1;const a=Go(()=>{c=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!c){if(!d){t.onLoadFailed();return}await hc(e,mc(e.action.id,i,d),t.t,r)}};function xa(t){const e=Xe.c(14),{sessionID:s,directory:r,open:i,Item:o}=t,{t:c}=Ct(),{pending:a,disabled:d,hint:u,run:f}=Tg(s,r,i),p=a?"loader-4":"ai-generate-2",m=a?"me-1 size-4 animate-spin":"me-1 size-[15px]";let g;e[0]!==p||e[1]!==m?(g=n.jsx(Q,{name:p,className:m}),e[0]=p,e[1]=m,e[2]=g):g=e[2];let y;e[3]!==c?(y=c("sessions.aiRename.action"),e[3]=c,e[4]=y):y=e[4];let v;e[5]!==o||e[6]!==d||e[7]!==f||e[8]!==g||e[9]!==y?(v=n.jsx("span",{className:"block",children:n.jsxs(o,{disabled:d,onClick:f,className:"w-full",children:[g,y]})}),e[5]=o,e[6]=d,e[7]=f,e[8]=g,e[9]=y,e[10]=v):v=e[10];let x;return e[11]!==u||e[12]!==v?(x=n.jsx(ss,{hint:u,children:v}),e[11]=u,e[12]=v,e[13]=x):x=e[13],x}const No=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class op extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const li=Vr(()=>({pendingSessionIds:new Set})),ip=t=>{const e=Xe.c(2);let s;return e[0]!==t?(s=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=s):s=e[1],li(s)},Oc=(t,e)=>{li.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}})},ov=async(t,e)=>{try{const d=(await dy(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const s=vt(t),r=vt(e)??e,i=xt.getState().availableWorktreesByProject,c=(i.get(r)??i.get(e)??[]).find(a=>vt(a.path)===s)?.branch?.trim();if(c)return c;throw new Error("Unable to determine the current branch")},Bc=t=>{for(const e of t){const s=ay(e.id);if(s==="unknown")throw new Error("Session status is unavailable");if(s==="active")throw new Error("Session is not idle")}};class iv extends Error{constructor(e,s){super(e,{cause:s}),this.name="IncompleteRollbackError"}}const av=(t,e)=>{const s=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new iv(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${s}`,{moveError:t,rollbackFailures:e})},lv=async(t,e,s,r)=>{const i=[];for(const o of[...t].reverse()){if(Vu(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await Hu(o,s,e),xt.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(c){i.push({sessionId:o.id,error:c instanceof Error?c:new Error(String(c))})}}return i},Fc=async(t,e,s)=>{try{await Gu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${s.message}`)}throw s},Lc=async(t,e)=>{const s=e?[t,e]:[t];try{await Ja(s)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},bl=async(t,e)=>{if(li.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Oc(t.root.id,!0);try{const s=[...t.descendants,t.root],r=new Map(s.map(a=>[a.id,xt.getState().getWorktreeMetadata(a.id)]));Bc(s);let i=null;const o=[];let c=!1;try{i=await e();for(const[a,d]of s.entries()){Bc(s.slice(a));try{await Hu(d,t.sourceDirectory,i.directory)}catch(u){throw iy(u)&&(c=!0),u}o.push(d),d.id!==t.root.id&&xt.getState().setWorktreeMetadata(d.id,i.metadata?gc(i.metadata):null)}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await lv(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(c&&await Lc(t.sourceDirectory,i?.directory),u.length>0)throw av(d,u);if(i?.onMoveFailure&&!c)return i.onMoveFailure(d);throw i?.onMoveFailure&&c?new op(d):d}return xt.getState().setWorktreeMetadata(t.root.id,i.metadata?gc(i.metadata):null),await Lc(t.sourceDirectory,i.directory),i.directory}finally{Oc(t.root.id,!1)}},cv=async t=>{const e=vt(t.sourceDirectory)??t.sourceDirectory,s=vt(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 bl(t,async()=>({directory:t.destination.path,metadata:t.destination}))},dv=async t=>{if((vt(t.sourceDirectory)??t.sourceDirectory)===(vt(t.projectDirectory)??t.projectDirectory))throw new Error("Source and destination are the same");return bl(t,async()=>({directory:t.projectDirectory,metadata:null}))},uv=async t=>bl(t,async()=>{const e=ia(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const s=await Uu(t.sourceDirectory)?await ov(t.sourceDirectory,e.path):null,r=await ly(e,s?{startRef:s}:{});try{await cy(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return Fc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>Fc(e,r,i)}}),fv=t=>{(t.kind==="existing"?cv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):t.kind==="project"?dv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,projectDirectory:t.projectDirectory}):uv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>ze.success(t.messages.success)).catch(s=>{const r=s instanceof Error?s:new Error(String(s));ze.error(t.messages.failure,{description:r instanceof op?t.messages.outcomeUnknown:r.message})})},Mo=t=>{li.getState().pendingSessionIds.has(t.root.id)||fv(t)},Mi="--oc-titlebar-controls-width",Sa=new Set;let jr=null;const ap=t=>{jr===null?t.style.removeProperty(Mi):t.style.getPropertyValue(Mi)!==jr&&t.style.setProperty(Mi,jr)},pv=t=>{const e=`${Math.round(t)}px`;e!==jr&&(jr=e,Sa.forEach(ap))},lp=t=>{if(t)return Sa.add(t),ap(t),()=>{Sa.delete(t)}},hr="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",Nn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},hv=()=>{Cs("ui.header.render");const{t,direction:e}=Ct(),s=de(ne=>ne.isSidebarOpen),r=ei(),i=de(ne=>ne.sessionTabsEnabled),o=xt(ne=>!!ne.newSessionDraft?.open),c=xt(ne=>ne.currentSessionId),a=uy(c??""),d=ip(c??""),u=Es(ar(l.useCallback(ne=>{if(!c)return null;const Ye=[...ne.activeSessions,...ne.archivedSessions].find(Pt=>Pt.id===c);if(!Ye)return null;const qe=Ye;return{title:Ye.title??null,directory:qe.directory??null,created:Ye.time?.created??null,slug:qe.slug??null,parentId:Ye.parentID??null}},[c]))),f=ns(ar(ne=>{if(!ne.activeProjectId)return null;const Ye=ne.projects.find(qe=>qe.id===ne.activeProjectId);return Ye?{id:Ye.id,path:Ye.path,label:Ye.label}:null})),p=l.useMemo(()=>{if(!f)return null;const ne=f.label?.trim();if(ne)return ne;const Ye=f.path.split(/[\\/]/).filter(Boolean);return Ye[Ye.length-1]??null},[f]),m=Gn(ne=>ne.loadSettings),{isMobile:g}=Tn(),y=l.useRef(null),[v,x]=l.useState(()=>typeof window>"u"?!1:un()),b=l.useMemo(()=>wo(),[]),h=fy(),[S,w]=l.useState(!1),j=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:k,side:T}=Yf(),O=l.useMemo(()=>{if(typeof window>"u")return null;const ne=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof ne=="number"&&Number.isFinite(ne)&&ne>0)return ne;if(typeof navigator>"u")return null;const Ye=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Ye)return null;const qe=Number.parseInt(Ye[1],10),Pt=Number.parseInt(Ye[2],10);return Number.isNaN(qe)?null:qe===10?Pt:qe},[]);fs.useEffect(()=>{typeof window>"u"||x(un())},[]);const $=l.useMemo(()=>In(),[]),D=de(ne=>ne.workStatusPanelVisible),E=de(ne=>ne.workStatusPanelEnabled),R=de(ne=>ne.setWorkStatusPanelEnabled),z=de(ne=>ne.workStatusPanelFits),_=de(ne=>ne.workStatusOverlayOpen),W=de(ne=>ne.setWorkStatusOverlayOpen),Y=E&&z||_,C=l.useCallback(()=>{if(E&&!z){W(!_);return}R(!E)},[W,R,_,E,z]);py(),l.useEffect(()=>{m()},[m]);const P=c?u??null:null,I=l.useRef(null),[H,A]=l.useState(0);l.useEffect(()=>{if(!c){I.current&&(I.current=null,A(Pt=>Pt+1));return}if(P){I.current={sessionId:c,session:P,expiresAt:Date.now()+2e3};return}const ne=I.current;if(!ne||ne.sessionId!==c)return;const Ye=ne.expiresAt-Date.now();if(Ye<=0){I.current=null,A(Pt=>Pt+1);return}const qe=window.setTimeout(()=>{I.current?.sessionId===c&&(I.current=null),A(Pt=>Pt+1)},Ye);return()=>{window.clearTimeout(qe)}},[c,P]);const F=(()=>{if(P)return P;if(!c)return null;const ne=I.current;return ne&&ne.sessionId===c&&ne.expiresAt>Date.now()?ne.session:null})(),L=xt(ne=>c?ne.worktreeMetadata.get(c)?.path??"":""),X=xt(ne=>c?ne.worktreeMetadata.get(c)?.branch?.trim()??null:null),re=qu(ne=>c?ne.getAttachment(c):void 0),te=l.useMemo(()=>re?hy(re,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,re]),M=l.useMemo(()=>re?re.legacy?"legacy":re.degraded?"degraded":re.worktreeStatus==="pending"?"pending":re.worktreeStatus==="missing"?"missing":re.worktreeStatus==="invalid"?"invalid":re.attentionReason?"attention":null:null,[re]),ee=l.useMemo(()=>Nn(L||""),[L]),V=l.useMemo(()=>{const ne=typeof F?.directory=="string"?F.directory:"";return Nn(ne||"")},[F?.directory]),Ee=Ga(c??"",V),ve=xt(ne=>ne.newSessionDraft?.open?Nn(ne.newSessionDraft.bootstrapPendingDirectory??ne.newSessionDraft.directoryOverride??""):""),ce=xt(ne=>ne.newSessionDraft.target),Be=xt(ne=>ne.newSessionDraft.selectedProjectId),me=xt(ne=>ne.currentSessionDirectory),he=xs(ne=>ne.homeDirectory),G=l.useMemo(()=>ee||V||ve,[ve,V,ee]),le=xt(ne=>{const Ye=Nn(ee||V||"");if(!Ye)return null;for(const qe of ne.availableWorktreesByProject.values()){const Rt=qe.find(je=>Nn(je.path)===Ye)?.branch?.trim();if(Rt)return Rt}return null}),Ie=my(G||null)||X||le,K=o?ce==="chat":mu(V||me,he),se=!K&&!D&&!!(p||Ie||!o&&M),U=l.useMemo(()=>{if(!c)return p??"OpenChamber";const ne=F?.title?.trim();return ne&&ne.length>0?ne:"Untitled Session"},[p,F?.title,c]),ie=Yu(),we=xt(ne=>ne.updateSessionTitle),pe=xt(ne=>ne.archiveSessions),Se=xt(ne=>ne.deleteSessions),[Ce,Oe]=l.useState(!1),[B,ae]=l.useState(!1),xe=l.useRef(null),[Te,Ge]=l.useState(""),[st,rt]=l.useState(!1),Ke=ns(ne=>ne.projects.length>0),[ke,ge]=l.useState(null),Ve=l.useRef(null),Ue=l.useCallback(()=>{c&&(Ge(F?.title?.trim()||U),Oe(!0))},[F?.title,c,U]),ft=l.useRef(Ue);ft.current=Ue;const Qe=l.useCallback(ne=>{ne&&(ne.focus(),ne.select())},[]);l.useEffect(()=>{if(ae(!1),ge(null),c&&xe.current===c){xe.current=null,ft.current();return}Oe(!1),Ge("")},[c]);const wt=l.useCallback(async()=>{if(!c)return;const ne=Te.trim();ne&&ne!==F?.title?.trim()&&await we(c,ne),Oe(!1)},[F?.title,c,Te,we]);l.useEffect(()=>{if(!Ce)return;const ne=Ye=>{const qe=Ye.target;(!qe||!Ve.current?.contains(qe))&&wt()};return document.addEventListener("mousedown",ne),()=>document.removeEventListener("mousedown",ne)},[Ce,wt]);const Me=l.useCallback(ne=>{ne&&ti(ne).then(Ye=>{ze[Ye.ok?"success":"error"](t(Ye.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(t("sessions.sidebar.session.copyId.error")))},[t]),Pe=l.useCallback(async()=>{if(!c||!G){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ne=await ie({sessionID:c,directory:G}).catch(()=>null);if(!ne){ze.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(ne.length===0){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Ye=Xu(ne,F?.title??null),qe=Qu(F?.title??null);await Zu(Ye,qe)||Ju(Ye,qe),ze.success(t("sessions.sidebar.session.export.success"))},[F?.title,c,ie,G,t]),ot=ef(),et=l.useMemo(()=>tf(ot),[ot]),Ze=l.useCallback(ne=>{c&&rp({entry:ne,t,session:{id:c,title:F?.title,directory:V??G},loadRecords:async()=>{if(!G)return null;try{return await ie({sessionID:c,directory:G})}catch{return null}},onLoadFailed:()=>ze.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[F?.title,c,ie,G,V,t]),dt=l.useCallback(ne=>et.map(Ye=>n.jsxs(ne,{onClick:()=>Ze(Ye),children:[n.jsx(ur,{icon:Ye.icon,iconSrc:Ye.iconSrc,className:"me-1 size-4"}),Ye.action.label]},`${Ye.guest.id}:${Ye.action.id}`)),[et,Ze]),J=a?.type==="busy"||a?.type==="retry",_e=l.useCallback(()=>{if(!c||!V||J||d)return;const ne=Es.getState().activeSessions,Ye=ne.find(Rt=>Rt.id===c);if(!Ye)return;const qe=[],Pt=[c];for(let Rt=0;Rt<Pt.length;Rt+=1){const je=Pt[Rt];for(const Je of ne)Je.parentID===je&&(qe.push(Je),Pt.push(Je.id))}Mo({kind:"quick",root:Ye,descendants:qe,sourceDirectory:V,messages:No(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[c,J,d,V,t]),Le=l.useCallback(ne=>{if(!c||!V||J||d)return;const Ye=Es.getState().activeSessions,qe=Ye.find(je=>je.id===c);if(!qe)return;const Pt=[],Rt=[c];for(let je=0;je<Rt.length;je+=1)for(const Je of Ye)Je.parentID===Rt[je]&&(Pt.push(Je),Rt.push(Je.id));Mo({kind:"project",root:qe,descendants:Pt,sourceDirectory:V,projectDirectory:ne,messages:No(t,{success:"sessions.moveChatToProject.success",failure:"sessions.moveChatToProject.failed"})})},[c,J,d,V,t]),He=l.useCallback(async(ne,Ye)=>{const qe=[Ye,...Iu(Ye,[],ne==="delete")],Pt=xt.getState().currentSessionId===Ye?Ye:null;if(ne==="delete"){const{failedIds:Je}=await Se(qe);Je.length>0?ze.error(t("sessions.sidebar.session.delete.error")):ze.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:Rt,failedIds:je}=await pe(qe);if(je.length>0){ze.error(t("sessions.sidebar.session.archive.error"));return}ze.success(t("sessions.sidebar.session.archive.success"),Dg(Rt,Pt,t))},[pe,Se,t]),$e=l.useCallback(async()=>{if(!ke)return;const{action:ne,sessionId:Ye}=ke;ge(null),await He(ne,Ye)},[ke,He]),tt=de(ne=>ne.openGuestPageId),bt=el(ne=>ne.guests.find(Ye=>Ye.id===tt)),ht=de(ne=>ne.isScheduledTasksDialogOpen),it=de(ne=>ne.isArchivePageOpen),Mt=de(ne=>ne.isUsageStatsPageOpen),nt=de(ne=>ne.isSourceBoardOpen),Lt=de(ne=>ne.worktreesPageProjectId),_t=de(ne=>ne.isolatedSpacesEnabled?ne.spacesPageProjectId:null),Tt=de(ne=>ne.runOverviewKey),Ae=Rg(Tt),at=Lt??_t,ut=ns(ne=>{if(!at)return null;const Ye=ne.projects.find(qe=>qe.id===at);return Ye?.label?.trim()||Ye?.path?.split("/").pop()||null}),pt=l.useMemo(()=>bt?{title:bt.pageTitle??bt.name,subtitle:null}:ht?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:it?{title:t("sessions.archivePage.title"),subtitle:null}:Mt?{title:t("usageStats.title"),subtitle:null}:nt?{title:t("sourceBoard.title"),subtitle:null}:Lt?{title:t("sessions.worktreesPage.title",{project:ut??""}),subtitle:null}:_t?{title:t("spaces.page.title",{project:ut??""}),subtitle:null}:Tt?{title:Ae??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[bt,it,Ae,Tt,ht,nt,Mt,_t,ut,t,Lt]),lt=V||Nn(me||"")||ee,St=l.useCallback(()=>{vn("desktop_open_draft_mini_chat_window",{directory:K?"":ve,projectId:K?null:Be,...Sr()}).catch(ne=>{console.warn("[header] failed to open draft mini chat window",ne)})},[ve,Be,K]),ct=l.useCallback(()=>{if(o){St();return}c&&vn("desktop_open_session_mini_chat_window",{sessionId:c,directory:V||Nn(me||"")||ee,...Sr()}).catch(ne=>{console.warn("[header] failed to open session mini chat window",ne)})},[c,St,o,me,V,ee]),oe=b&&(o||!!c),q=l.useCallback((ne,Ye)=>{vn("desktop_open_session_mini_chat_window",{sessionId:ne,directory:Ye,...Sr()}).catch(qe=>{console.warn("[header] failed to open session mini chat window",qe)})},[]),fe=hr,We=l.useMemo(()=>v&&j&&!S?"88px":h?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!v||k)&&!$?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[v,S,j,h,$,k]),be=(!v||k)&&!$?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",Ne=e==="rtl",mt=Ne?be:We,jt=Ne?We:be,At=k&&T!==gu(e);fs.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",mt)},[mt]);const Ot=s?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",Wt=s?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";fs.useEffect(()=>{if(!v||!j){w(!1);return}let ne=!1;const Ye=async()=>{try{const Pt=await vn("desktop_is_window_fullscreen");ne||w(Pt===!0)}catch{ne||w(!1)}},qe=()=>{Ye()};return Ye(),window.addEventListener("openchamber:window-resized",qe),()=>{ne=!0,window.removeEventListener("openchamber:window-resized",qe)}},[v,j]);const Qt=l.useMemo(()=>!v||!j||O===null?"":O>=26?"h-11":O<=15?"h-14":"",[v,j,O]),Ut=l.useMemo(()=>v&&j&&!S?O!==null&&O<=15?"56px":"44px":"0px",[v,S,j,O]),Ss=l.useMemo(()=>{const Ye=`max(${v&&j?"2.75rem":"3rem"}, ${Ut}, var(--oc-wco-titlebar-height, 0px))`,qe=v&&!k||$;if(qe&&Ut==="0px")return{};const Pt={minHeight:Ye,height:Ye};return!At&&(!qe||Ne)&&(Pt.paddingInlineEnd=jt),Pt},[At,v,j,Ne,$,jt,Ut,k]),bs=l.useRef(null),ys=l.useCallback(ne=>{!ne||ne===bs.current||(bs.current=ne,document.documentElement.style.setProperty("--oc-header-height",`${ne}px`))},[]),Re=l.useCallback(()=>{typeof document>"u"||ys(y.current?.getBoundingClientRect().height)},[ys]);fs.useEffect(()=>{if(typeof window>"u")return;Re();const ne=y.current;if(!ne||typeof ResizeObserver>"u")return()=>{};let Ye=0;const qe=()=>{Ye||(Ye=requestAnimationFrame(()=>{Ye=0,Re()}))},Pt=new ResizeObserver(Rt=>{const je=Rt[Rt.length-1];ys(je?.borderBoxSize?.[0]?.blockSize??je?.target.getBoundingClientRect().height)});return Pt.observe(ne),window.addEventListener("resize",qe),window.addEventListener("orientationchange",qe),()=>{Ye&&cancelAnimationFrame(Ye),Pt.disconnect(),window.removeEventListener("resize",qe),window.removeEventListener("orientationchange",qe)}},[ys,Re]),fs.useEffect(()=>{Re()},[Re,g,Qt]);const ue=l.useCallback(async ne=>{const Ye=ne.target;Ye.closest(".app-region-no-drag")||Ye.closest("button, a, input, select, textarea")||ne.button===0&&v&&await Mm()},[v]);sf({rename_current_session:()=>{if(!c||g)return!1;Ue()},archive_current_session:()=>{if(!c||g||Es.getState().entityById.get(c)?.time.archived)return!1;if(de.getState().showDeletionDialog){ge({action:"archive",sessionId:c});return}He("archive",c)}});const Fe=n.jsxs(n.Fragment,{children:[n.jsx(T1,{directory:G,className:De(hr,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"}),n.jsx(Ng,{directory:G,className:De(hr,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"})]}),yt=l.useCallback(({session:ne,open:Ye,isActive:qe,select:Pt,closeOtherTabs:Rt,components:je})=>{const{Item:Je,Separator:gt}=je,kt=qe&&!$&&!K&&F&&!F.parentId,Dt=qe&&!$&&K&&F&&!F.parentId&&Ke;return n.jsxs(n.Fragment,{children:[n.jsx(ss,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(Je,{onClick:()=>{qe||Pt(),xe.current=ne.id},children:[n.jsx(Q,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(xa,{sessionID:ne.id,directory:ne.directory,open:Ye,Item:Je}),n.jsx(ss,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(Je,{onClick:()=>Me(ne.id),children:[n.jsx(Q,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(gt,{}),qe?n.jsx(ss,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(Je,{onClick:()=>{Pe()},children:[n.jsx(Q,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,b?n.jsxs(Je,{onClick:()=>q(ne.id,qe?lt:ne.directory??""),children:[n.jsx(Q,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,qe?dt(Je):null,kt?n.jsx(ss,{hint:t(d?"sessions.sidebar.session.moveToWorktree.tooltipMoving":J?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(Je,{disabled:!V||J||d,onClick:_e,className:"w-full",children:[n.jsx(Q,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,Dt?n.jsx(ss,{hint:t(J?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:n.jsx("span",{className:"block",children:n.jsxs(Je,{disabled:!V||J||d,onClick:()=>rt(!0),className:"w-full",children:[n.jsx(Q,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,n.jsx(gt,{}),n.jsx(ss,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(Je,{onClick:Rt,children:[n.jsx(Q,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(gt,{}),n.jsx(Ac,{sessionId:ne.id,Item:Je,onArchive:()=>ge({action:"archive",sessionId:ne.id})}),n.jsx(ss,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(Je,{className:"text-destructive focus:text-destructive",onClick:()=>ge({action:"delete",sessionId:ne.id}),children:[n.jsx(Q,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[Me,F,lt,Pe,b,Ke,K,J,d,$,_e,q,dt,V,t]),$t=()=>n.jsxs("div",{onMouseDown:ue,className:De("app-region-drag relative flex h-12 select-none items-center",At?"pe-0":"pe-2.5",Qt),style:Ss,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:Ot,transitionDuration:`${r}ms`}}),n.jsx("div",{ref:lp,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] ease-out motion-reduce:transition-none",style:{width:Wt,transitionDuration:`${r}ms`}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[pt?n.jsxs(n.Fragment,{children:[n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx(It,{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(Q,{name:"arrow-left",className:"size-4"})})}),n.jsx(Ft,{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:pt.title}),pt.subtitle?n.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:pt.subtitle}):null]})]}):$||!i?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:[Ee?n.jsx(Q,{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(l1,{align:"start",children:n.jsx("button",{type:"button",className:fe,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(Q,{name:"history",className:"h-4 w-4"})})}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[Ce?n.jsxs("form",{ref:Ve,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:ne=>ne.stopPropagation(),onSubmit:ne=>{ne.preventDefault(),wt()},children:[n.jsx("input",{ref:Qe,value:Te,onChange:ne=>Ge(ne.target.value),onKeyDown:ne=>na(ne,()=>Oe(!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(Q,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Oe(!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(Q,{name:"close",className:"size-4"})})]}):o?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:U}),se?n.jsxs("span",{className:De("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",o?"typography-ui-label text-[14px] text-foreground":"typography-micro text-[10.5px] text-muted-foreground/75"),children:[p?n.jsx("span",{className:"truncate",children:p}):null,Ie?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(Q,{name:"git-branch",className:De("flex-shrink-0 text-muted-foreground/70",o?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{className:De("truncate",o&&"text-muted-foreground"),children:Ie})]}):null,!o&&M?n.jsxs("span",{className:De("inline-flex min-w-0 items-center gap-0.5",M==="attention"||M==="invalid"||M==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[n.jsx(Q,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:te})]}):null]}):null]}),n.jsx("div",{className:De("flex h-[18px] shrink-0 items-center justify-center",se?"self-start":"self-center"),children:c&&!o&&!Ce?n.jsxs(Ts,{open:B,onOpenChange:ae,onOpenChangeComplete:ne=>{!ne&&xe.current&&xe.current===c&&(xe.current=null,Ue())},children:[n.jsx(Ds,{asChild:!0,children:n.jsx(It,{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(Q,{name:"more",className:"size-4"})})}),n.jsxs(Rs,{align:"end",className:"min-w-[190px]",children:[n.jsx(ss,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(Zt,{onClick:()=>{xe.current=c},children:[n.jsx(Q,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(xa,{sessionID:c,directory:V,open:B,Item:Zt}),n.jsx(ss,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(Zt,{onClick:()=>c&&Me(c),children:[n.jsx(Q,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(jn,{}),n.jsx(ss,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(Zt,{onClick:()=>{Pe()},children:[n.jsx(Q,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),b?n.jsxs(Zt,{onClick:()=>q(c,lt),children:[n.jsx(Q,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,dt(Zt),!$&&!K&&F&&!F.parentId?n.jsx(ss,{hint:t(d?"sessions.sidebar.session.moveToWorktree.tooltipMoving":J?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(Zt,{disabled:!V||J||d,onClick:_e,className:"w-full",children:[n.jsx(Q,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,n.jsx(jn,{}),n.jsx(Ac,{sessionId:c,Item:Zt,onArchive:()=>ge({action:"archive",sessionId:c})}),n.jsx(ss,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(Zt,{className:"text-destructive focus:text-destructive",onClick:()=>{c&&ge({action:"delete",sessionId:c})},children:[n.jsx(Q,{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(K1,{renderMenu:yt,suppressActiveTabControls:Ce,onMenuOpenChangeComplete:ne=>{!ne&&xe.current&&xe.current===c&&(xe.current=null,Ue())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:Ce?n.jsxs("form",{ref:Ve,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:ne=>ne.stopPropagation(),onSubmit:ne=>{ne.preventDefault(),wt()},children:[n.jsx("input",{ref:Qe,value:Te,onChange:ne=>Ge(ne.target.value),onKeyDown:ne=>na(ne,()=>Oe(!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(Q,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Oe(!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(Q,{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:o?t("sessions.switcher.draftTitle"):U})})})}),pt||$||!i?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[oe?n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":t(o?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:ct,className:hr,children:n.jsx(Q,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),n.jsx(Ft,{side:"bottom",children:t(o?"header.actions.newMiniChat":"header.actions.openSessionMiniChat")})]}):null,$?null:n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":Y,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:C,className:De(hr,Y&&"text-foreground"),children:n.jsx(Q,{name:"list-indefinite",className:"h-4 w-4"})})}),n.jsx(Ft,{side:"bottom",children:t(E&&!z?_?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":E?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),Fe,n.jsx(Xf,{visible:At,position:T})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:y,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:$t()}),n.jsx(tv,{open:st,onOpenChange:rt,onPick:Le}),n.jsx(Ys,{open:ke!==null,onOpenChange:ne=>{ne||ge(null)},children:n.jsxs(qs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(en,{children:[n.jsx(Zs,{children:ke?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),n.jsx(Js,{children:ke?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:U}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:U})})]}),n.jsxs(Cn,{children:[n.jsx(It,{variant:"outline",size:"sm",onClick:()=>ge(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(It,{variant:"destructive",size:"sm",onClick:()=>{$e()},children:ke?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})})]})},_c=280,$c=264,zc=500,mv=({isOpen:t,isMobile:e,children:s,className:r,topBar:i,peek:o})=>{const{t:c,direction:a}=Ct(),d=de(C=>C.sidebarWidth),u=de(C=>C.setSidebarWidth),[f,p]=l.useState(!1),m=l.useRef(0),g=l.useRef(d||_c),y=l.useRef(null),v=l.useRef(null),x=l.useRef(null),b=l.useCallback(C=>Math.min(zc,Math.max($c,C)),[]),h=l.useCallback(C=>{const P=x.current;P&&(P.style.width=`${C}px`,P.style.minWidth=`${C}px`,P.style.maxWidth=`${C}px`,P.style.setProperty("--oc-left-sidebar-width",`${C}px`),document.documentElement.style.setProperty("--oc-left-sidebar-width",`${C}px`))},[]);l.useEffect(()=>{e&&f&&p(!1)},[e,f]),l.useEffect(()=>{f||(y.current=null,v.current=null)},[f]);const S=Math.min(zc,Math.max($c,d||_c)),w=t?S:0,j=f?y.current??w:w,k=f?j:S;l.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${k}px`)},[k]);const[T,O]=l.useState(!t);t&&T&&O(!1);const $=ei(),D=l.useRef(t),E=l.useRef(t);if(l.useLayoutEffect(()=>{D.current=t,E.current!==t&&(E.current=t,nf($),t||tl(()=>{D.current||O(!0)}))},[t,$]),e)return null;const R=C=>{if(t){try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}v.current=C.pointerId,p(!0),m.current=C.clientX,g.current=w,y.current=w,h(w),C.preventDefault()}},z=C=>{if(e||!f||v.current!==C.pointerId)return;const P=(C.clientX-m.current)*(a==="rtl"?-1:1),I=b(g.current+P);y.current!==I&&(y.current=I,h(I))},_=C=>{if(v.current!==C.pointerId||e)return;try{C.currentTarget.releasePointerCapture(C.pointerId)}catch{}const P=b(y.current??w);v.current=null,y.current=null,p(!1),u(P)},W=!t&&o?o.state:!1,N=W!==!1,Y=N&&o&&o.animationMs>0?`${W==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${o.animationMs}ms ${Io} forwards`:void 0;return n.jsxs("div",{ref:x,"data-left-sidebar":"",className:De("relative flex h-full border-e border-border",!N&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",!t&&"border-e-0",r),style:{width:`${j}px`,minWidth:`${j}px`,maxWidth:`${j}px`,"--oc-left-sidebar-width":`${k}px`,overflowX:N?void 0:"clip",transitionDuration:`${$}ms`,transitionTimingFunction:Io},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:De("absolute inset-e-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",f&&"bg-[var(--interactive-border)]"),onPointerDown:R,onPointerMove:z,onPointerUp:_,onPointerCancel:_,role:"separator","aria-orientation":"vertical","aria-label":c("sidebar.resize.leftPanelAria")}),n.jsxs("aside",{ref:o?.overlayRef,"data-sidebar-peek":N?W:void 0,className:De("flex h-full shrink-0 flex-col",N?"absolute inset-s-0 top-0 z-[25] border-e border-border bg-sidebar shadow-xl":"relative z-10 transition-opacity ease-out motion-reduce:transition-none",f&&"pointer-events-none",!t&&!N&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${$}ms`,overflowX:"hidden",contentVisibility:T&&!N?"hidden":void 0,animation:Y,"--oc-peek-offset":a==="rtl"?"100%":"-100%"},inert:!t&&!N||void 0,onPointerEnter:N?o?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:N?o?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:N?o?.overlayHandlers.onAnimationEnd:void 0,children:[i,n.jsx(Or,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:n.jsx(ws,{children:s})})]})]})},gv=()=>{const t=Xe.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:lp,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},bv=50,yv=18,xv=300,Sv='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',cp=t=>!document.getElementById("root")?.contains(t),vv=t=>{if((Uo(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>yv)return!1;const s=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=s},Kc=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?!0:Array.from(document.querySelectorAll(Sv)).some(s=>cp(s)&&s.getClientRects().length>0)},wv=({enabled:t,layoutAnimationMs:e})=>{const[s,r]=l.useState(!1),i=gy()?0:e,o=i>0,c=l.useRef(null),a=l.useRef(null),d=l.useRef(null),u=l.useCallback(()=>{a.current!==null&&clearTimeout(a.current),d.current!==null&&clearTimeout(d.current),a.current=null,d.current=null},[]),f=l.useCallback(()=>{u(),r(y=>y==="in"&&o?"out":!1)},[o,u]),p=l.useCallback(()=>{d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{if(d.current=null,Kc(c.current)){p();return}f()},xv)},[f]),m=l.useCallback(()=>{d.current!==null&&clearTimeout(d.current),d.current=null},[]);l.useEffect(()=>{t||(u(),r(!1))},[u,t]),l.useEffect(()=>u,[u]),l.useEffect(()=>{if(s!=="in")return;const y=b=>{const h=b.target;h instanceof Element&&(c.current?.contains(h)||cp(h)||f())},v=b=>{sl(b)||b.key!=="Escape"||b.defaultPrevented||Kc(c.current)||f()},x=b=>{b.relatedTarget===null&&p()};return document.addEventListener("pointerdown",y,!0),document.addEventListener("keydown",v),document.addEventListener("pointerout",x),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",v),document.removeEventListener("pointerout",x)}},[f,p,s]),l.useEffect(()=>{if(!t||s!==!1)return;const y=()=>{a.current!==null&&clearTimeout(a.current),a.current=null},v=b=>{if(b.pointerType!=="mouse"||b.buttons!==0||!vv(b)){y();return}a.current===null&&(a.current=setTimeout(()=>{a.current=null,r("in")},bv))},x=b=>{b.relatedTarget===null&&y()};return document.addEventListener("pointermove",v,{passive:!0}),document.addEventListener("pointerout",x),()=>{document.removeEventListener("pointermove",v),document.removeEventListener("pointerout",x),y()}},[t,s]);const g=l.useMemo(()=>({onPointerEnter:()=>{m(),r(y=>y==="out"?"in":y)},onPointerLeave:()=>{s==="in"&&p()},onAnimationEnd:y=>{y.target===y.currentTarget&&r(v=>v==="out"?!1:v)}}),[m,p,s]);return{state:t?s:!1,animationMs:i,overlayRef:c,overlayHandlers:g}},Qr="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",kv=()=>{const t=Xe.c(45),{t:e,locale:s,direction:r}=Ct(),i=de(jv),o=de(Cv),c=de(Pv),a=l.useRef(null),d=rf(of("toggle_sidebar",c)),u=Ev,{usesFramelessChrome:f,side:p}=Yf();let m;t[0]!==s?(m=I=>{const H=I.currentTarget.getBoundingClientRect();vn("desktop_show_app_menu",{x:H.left,y:H.bottom,locale:s}).catch(Iv)},t[0]=s,t[1]=m):m=t[1];const g=m;let y,v;t[2]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{if(typeof document>"u")return;const I=a.current;if(!I)return;const H=()=>{const F=Math.max(I.getBoundingClientRect().width,I.scrollWidth);pv(F)};if(H(),typeof ResizeObserver>"u")return;const A=new ResizeObserver(H);return A.observe(I),()=>{A.disconnect()}},v=[],t[2]=y,t[3]=v):(y=t[2],v=t[3]),l.useEffect(y,v);const x="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",b=o?"var(--oc-left-sidebar-width, 100%)":void 0;let h;t[4]!==b?(h={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:b},t[4]=b,t[5]=h):h=t[5];const S="flex min-w-0 items-center gap-2";let w;t[6]!==r||t[7]!==f||t[8]!==p?(w=f&&p===gu(r)?n.jsx(Xf,{visible:!0,position:p}):null,t[6]=r,t[7]=f,t[8]=p,t[9]=w):w=t[9];let j;t[10]!==g||t[11]!==e||t[12]!==f?(j=f?n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:g,"aria-label":e("header.actions.openAppMenuAria"),className:De(Qr,"shrink-0"),children:n.jsx(Q,{name:"menu-2",className:"h-4 w-4"})})}),n.jsx(Ft,{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=Kt;let T;t[14]!==e?(T=e("header.actions.openSessionsAria"),t[14]=e,t[15]=T):T=t[15];const O=o&&"text-foreground";let $;t[16]!==O?($=De(Qr,"shrink-0",O),t[16]=O,t[17]=$):$=t[17];let D;t[18]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Q,{name:"layout-left",className:"h-4 w-4"}),t[18]=D):D=t[18];let E;t[19]!==o||t[20]!==$||t[21]!==T||t[22]!==i?(E=n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:i,"data-sidebar-toggle":"","aria-label":T,"aria-pressed":o,className:$,children:D})}),t[19]=o,t[20]=$,t[21]=T,t[22]=i,t[23]=E):E=t[23];const R=Ft,z=e("header.actions.openSessionsWithShortcut",{shortcut:d});let _;t[24]!==z?(_=n.jsx("p",{children:z}),t[24]=z,t[25]=_):_=t[25];let W;t[26]!==R||t[27]!==_?(W=n.jsx(R,{children:_}),t[26]=R,t[27]=_,t[28]=W):W=t[28];let N;t[29]!==k||t[30]!==E||t[31]!==W?(N=n.jsxs(k,{children:[E,W]}),t[29]=k,t[30]=E,t[31]=W,t[32]=N):N=t[32];let Y;t[33]!==u||t[34]!==o||t[35]!==e?(Y=o?n.jsxs("button",{type:"button",onClick:u,className:De(Qr,"-ms-1 w-auto min-w-0 px-1.5 font-normal"),children:[n.jsx(Q,{name:"chat-new",className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:u,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:De(Qr,"-ms-1 shrink-0"),children:n.jsx(Q,{name:"chat-new",className:"h-4 w-4"})})}),n.jsx(Ft,{children:n.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[33]=u,t[34]=o,t[35]=e,t[36]=Y):Y=t[36];let C;t[37]!==N||t[38]!==Y||t[39]!==w||t[40]!==j?(C=n.jsxs("div",{ref:a,className:S,children:[w,j,N,Y]}),t[37]=N,t[38]=Y,t[39]=w,t[40]=j,t[41]=C):C=t[41];let P;return t[42]!==C||t[43]!==h?(P=n.jsx("div",{className:x,style:h,children:C}),t[42]=C,t[43]=h,t[44]=P):P=t[44],P};function jv(t){return t.toggleSidebar}function Cv(t){return t.isSidebarOpen}function Pv(t){return t.shortcutOverrides}function Ev(){de.getState().closeMainSurfaces(),xt.getState().openNewSessionDraft()}function Iv(t){console.warn("[titlebar] failed to open app menu",t)}function Tv(t,e,s){const r=Xe.c(5),[i,o]=l.useState();let c,a;return r[0]!==s||r[1]!==t||r[2]!==e?(c=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,f]=await Promise.all([by(t),yy(t)]).catch(Dv);if(d)return;const p=vt(u),m=vt(f);if(!p||!m||m===p)return;const g=s||"",y=m.split("/").filter(Boolean).pop()||m;o({source:"sdk",path:m,projectDirectory:p,branch:g,label:g||y,name:y,worktreeRoot:m,worktreeStatus:"ready",headState:g?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=c,r[4]=a):(c=r[3],a=r[4]),l.useEffect(c,a),e??i}function Dv(){return["",""]}const Rv=()=>{const t=Xe.c(3),e=de(Nv),s=de(Mv);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 Nv(t){return t.setSettingsDialogOpen}function Mv(t){return t.setSettingsPage}const Av="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)]",Wc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Ov=({className:t,identity:e=lf})=>{const{t:s}=Ct(),{sourceControl:r}=Ws(),i=af(e),o=e.provider==="gitlab",c=o?"gitlab":"github-fill",a=i?.status??null,d=wn(b=>b.setStatus),[u,f]=l.useState(!1),p=l.useCallback(async b=>{if(!(!b||u)){f(!0);try{d(e,await r.authActivate(e,b))}catch(h){console.error("Failed to switch source control account:",h)}finally{f(!1)}}},[e,u,d,r]);if(a?.status!=="connected")return null;const m=a.user.username||null,g=a.user.avatarUrl??null,y=a.accounts,v=o?m?s("header.gitlab.connectedWithLogin",{login:m}):s("header.gitlab.connected"):m?s("header.github.connectedWithLogin",{login:m}):s("header.github.connected"),x=g?n.jsx("img",{src:g,alt:m?s("header.github.avatarWithLogin",{login:m}):s(o?"header.gitlab.avatar":"header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(Q,{name:c,className:"h-3.5 w-3.5 text-foreground"});return y.length<=1?n.jsx("div",{className:De(Wc,t),title:v,children:x}):n.jsxs(Ts,{children:[n.jsx(Ds,{asChild:!0,children:n.jsx("button",{type:"button",className:De(Wc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:v,disabled:u,children:x})}),n.jsxs(Rs,{align:"end",className:"w-64",children:[n.jsx(aa,{className:"typography-ui-header font-semibold text-foreground",children:s(o?"header.gitlab.accountsTitle":"header.github.accountsTitle")}),n.jsx(jn,{}),y.map(b=>{const h=b.user,S=!!b.current,w=s(xy(b.source??"oauth"));return n.jsxs(Zt,{className:"gap-2",disabled:u,onSelect:()=>{S||p(b.id)},children:[h?.avatarUrl?n.jsx("img",{src:h.avatarUrl,alt:h.username?s("header.github.avatarWithLogin",{login:h.username}):s(o?"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(Q,{name:c,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:h?.name?.trim()||h.username||(o?"GitLab":"GitHub")}),h.username?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:h.username}),n.jsx("span",{className:"mx-1 opacity-50",children:"·"}),n.jsx("span",{children:w})]}):null]}),S?n.jsx(Q,{name:"check",className:"h-4 w-4 text-primary"}):null]},b.id)})]})]})},Bv=t=>JSON.stringify(Sy(t)),Fv=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}},dp=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function Lv(t){if(!dp(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function _v(t,e,s){const r=Xe.c(16),{sourceControl:i}=Ws(),[o,c]=fs.useState(null);let a;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(a=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]=a):a=r[4];const d=a;let u;r[5]!==t||r[6]!==d||r[7]!==e||r[8]!==i?(u=()=>{if(t.provider!=="github")return;let p=!1;return i.githubReferences(t,{kind:"pull",query:`#${e}`}).then(m=>{if(p||!m.connected)return;const g=m.items.find(y=>y.kind==="pull"&&y.number===e);g&&c({key:d,pull:g})}).catch($v),()=>{p=!0}},r[5]=t,r[6]=d,r[7]=e,r[8]=i,r[9]=u):u=r[9];let f;return r[10]!==t||r[11]!==d||r[12]!==e||r[13]!==s||r[14]!==i?(f=[t,d,e,s,i],r[10]=t,r[11]=d,r[12]=e,r[13]=s,r[14]=i,r[15]=f):f=r[15],fs.useEffect(u,f),o?.key===d?o.pull:null}function $v(){}const zv=t=>{const e=Xe.c(60),{directory:s,context:r,changeRequest:i,onChanged:o}=t,c=hn(),a=ns(Kv),[d,u]=fs.useState(0),[f,p]=fs.useState(!1),[m]=fs.useState(Wv),g=_v(r,i.number,d);let y;e[0]!==i?(y=vy(i),e[0]=i,e[1]=y):y=e[1];const v=y;let x;e[2]!==g||e[3]!==v?(x=g?{...v,labels:g.labels,commentCount:g.commentCount}:v,e[2]=g,e[3]=v,e[4]=x):x=e[4];const b=x,{detail:h,refresh:S}=wy(s,b,!0),w=Mg(b);let j;e[5]!==o||e[6]!==S?(j=()=>{S(),u(Hv),o()},e[5]=o,e[6]=S,e[7]=j):j=e[7];const k=j,T=Ag(b,r,k);let O;e[8]!==b?(O={source:"github",reference:b},e[8]=b,e[9]=O):O=e[9];const $=O,D=c??s;let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E={status:"idle"},e[10]=E):E=e[10];let R;e[11]!==r||e[12]!==$||e[13]!==k?(R=n.jsx(Fg,{item:$,project:null,context:r,onStartWorktree:Uv,onChanged:k}),e[11]=r,e[12]=$,e[13]=k,e[14]=R):R=e[14];let z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=()=>p(!0),e[15]=z):z=e[15];let _;e[16]!==w.attachComment||e[17]!==w.attachComments?(_={onAttach:w.attachComment,onAttachAll:w.attachComments},e[16]=w.attachComment,e[17]=w.attachComments,e[18]=_):_=e[18];let W;e[19]!==r||e[20]!==b||e[21]!==k?(W=n.jsx(Lg,{reference:b,context:r,onChanged:k}),e[19]=r,e[20]=b,e[21]=k,e[22]=W):W=e[22];let N;e[23]!==r||e[24]!==h||e[25]!==b||e[26]!==k?(N=n.jsx(_g,{pull:b,detail:h,context:r,onChanged:k}),e[23]=r,e[24]=h,e[25]=b,e[26]=k,e[27]=N):N=e[27];let Y;e[28]!==r||e[29]!==b||e[30]!==k?(Y=n.jsx(Og,{reference:b,context:r,onRefresh:k},b.number),e[28]=r,e[29]=b,e[30]=k,e[31]=Y):Y=e[31];const C=a??"";let P;e[32]!==D||e[33]!==C?(P={id:C,path:D},e[32]=D,e[33]=C,e[34]=P):P=e[34];let I;e[35]!==r||e[36]!==D||e[37]!==b||e[38]!==P?(I=n.jsx($g,{pull:b,project:P,context:r,projectOwnsDirectory:Gv,currentDirectory:D}),e[35]=r,e[36]=D,e[37]=b,e[38]=P,e[39]=I):I=e[39];let H;e[40]!==h||e[41]!==s||e[42]!==$||e[43]!==m||e[44]!==N||e[45]!==Y||e[46]!==I||e[47]!==R||e[48]!==_||e[49]!==W||e[50]!==T?(H=n.jsx(ky,{item:$,directory:s,pullStatus:jy,linearDetail:E,githubDetail:h,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:Vv,now:m,footer:R,onOpenChecks:z,commentAttachments:_,threadActions:T,labelsControl:W,reviewersControl:N,reply:Y,pullLinks:I}),e[40]=h,e[41]=s,e[42]=$,e[43]=m,e[44]=N,e[45]=Y,e[46]=I,e[47]=R,e[48]=_,e[49]=W,e[50]=T,e[51]=H):H=e[51];let A;e[52]!==w.attachFailedChecks||e[53]!==f||e[54]!==r||e[55]!==b?(A=n.jsx(Bg,{pull:b,context:r,open:f,onOpenChange:p,onAttachFailed:w.attachFailedChecks}),e[52]=w.attachFailedChecks,e[53]=f,e[54]=r,e[55]=b,e[56]=A):A=e[56];let F;return e[57]!==H||e[58]!==A?(F=n.jsxs(n.Fragment,{children:[H,A]}),e[57]=H,e[58]=A,e[59]=F):F=e[59],F};function Kv(t){return t.activeProjectId}function Wv(){return Date.now()}function Hv(t){return t+1}function Vv(){}function Uv(){}function Gv(){return!0}function qv(t,e){const{git:s,sourceControl:r}=Ws(),{t:i}=Ct(),o=zg(),c=Kg({directory:t,branch:e,chooseContributor:o.choose}),a=Wg(t,s,r),d=async()=>{const f=a.start();if(!f)return ze.info(i("gitView.pr.toast.gitBusy")),!1;const p=i("gitView.toast.syncActionFailed",{action:i("gitView.publish.title")});try{return await(await c.prepare("push",{onOperation:f.onOperation}))(),f.isCurrent()}catch(m){if(m instanceof Cy){if(m.code==="stale-runtime")return!1;const g=c.errorMessage(m);return g?ze.info(g):ze.error(p),!1}return m instanceof Py||m instanceof Ey?(ze.error(p,{description:m.message||void 0}),!1):(ze.error(p,{description:m instanceof Error?m.message:String(m)}),!1)}finally{f.finish()}},u=n.jsxs(n.Fragment,{children:[c.context?n.jsx(Hg,{context:c.context,onSelect:c.settle}):null,c.confirmDialog,n.jsx(Vg,{candidates:o.candidates,onSelect:o.settle})]});return{push:d,dialogs:u}}const Yv=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"}},Xv=(t,e)=>{const{currentSessionId:s,getDirectoryForSession:r}=xt.getState(),i=s?r(s):null;!s||!i||vt(i)!==vt(t)||Ly(s,i,_y({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},Qv=t=>{const e=t?.changeRequest??t?.pr;return e?$y({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},Zv=[2e3,5e3];let Hc=0;const Jv=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(Hc+=1,`source-control-${Date.now().toString(36)}-${Hc.toString(36)}`)},ew=(t,e,s)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...s]),up="openchamber:pr-create-as-draft:v1",Vc=()=>{try{return localStorage.getItem(up)==="true"}catch{return!1}},tw=t=>{try{localStorage.setItem(up,String(t))}catch{}},Ai=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),yn=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):""},sw=(t,e)=>{const s=yn(t);if(!s||s.includes("->"))return"";if(e){const i=`${e}/`;return s.startsWith(i)?s.slice(i.length).trim():""}const r=s.indexOf("/");return r>0?s.slice(r+1).trim():s},nw=(t,e)=>`${t}::${e}`,Oi=new Map,Uc=si;function rw(t,e,s){const r=Xe.c(14);let i;r[0]!==s?(i=s?Bv(s):null,r[0]=s,r[1]=i):i=r[1];const o=i;let c;r[2]===Symbol.for("react.memo_cache_sentinel")?(c={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=c):c=r[2];const[a,d]=l.useState(c);let u,f;r[3]!==o||r[4]!==t||r[5]!==s||r[6]!==e?(u=()=>{if(!t||!s||!o)return;let m=!1;return(async()=>{try{const g=await Fv(e,s);m||d({contextKey:o,detectedUpstream:g.upstream,upstreamBranches:g.branches})}catch{}})(),()=>{m=!0}},f=[o,t,s,e],r[3]=o,r[4]=t,r[5]=s,r[6]=e,r[7]=u,r[8]=f):(u=r[7],f=r[8]),l.useEffect(u,f);let p;return r[9]!==o||r[10]!==a.contextKey||r[11]!==a.detectedUpstream||r[12]!==a.upstreamBranches?(p=a.contextKey===o?{detectedUpstream:a.detectedUpstream,upstreamBranches:a.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=o,r[10]=a.contextKey,r[11]=a.detectedUpstream,r[12]=a.upstreamBranches,r[13]=p):p=r[13],p}const ow=({directory:t,branch:e,baseBranch:s,trackingBranch:r,ahead:i=0,remoteBranches:o=[],onGeneratedDescription:c})=>{const{t:a}=Ct(),d=cf(t),u=l.useCallback((ue,Fe)=>a(cn(ue,d?.provider),Fe),[d?.provider,a]),f=Rv(),{sourceControl:p}=Ws(),m=wn(ue=>ue.entries),{isMobile:g,hasTouchInput:y,screenWidth:v}=Tn(),x=de(ue=>ue.openContextSurface),b=Iy(ue=>ue.requestTarget),h=!g&&v>=768&&!In(),S=l.useMemo(()=>nw(t,e),[t,e]),w=l.useMemo(()=>Oi.get(S)??null,[S]),j=ds(ue=>ue.ensureEntry),k=ds(ue=>ue.setParams),T=ds(ue=>ue.beginActiveContextsLoad),O=ds(ue=>ue.commitActiveContexts),$=ds(ue=>ue.releaseActiveContexts),D=l.useId(),E=ds(ue=>ue.startWatching),R=ds(ue=>ue.stopWatching),z=ds(ue=>ue.refresh),[_,W]=l.useState(()=>w?.title??Ai(e)),[N,Y]=l.useState(()=>w?.body??""),[C,P]=l.useState(()=>w?.draft??Vc()),[I,H]=l.useState(()=>w?.additionalContext??""),[A,F]=l.useState(()=>{const ue=typeof w?.targetBaseBranch=="string"?yn(w.targetBaseBranch):"";return ue||yn(s)}),[L,X]=l.useState(!1),[re,te]=l.useState(!1),[M,ee]=l.useState(!1),V=df(t,p),Ee=V.scope.runtimeKey;l.useEffect(()=>{if(!t)return;const ue=V.scope.runtimeKey,Fe=T(ue,t,D),yt=V.contexts.filter($t=>la(m[qn($t)],$t).connected);return O(ue,t,D,Fe,yt),()=>{$(ue,t,D)}},[T,V.contexts,V.scope.runtimeKey,O,t,$,m,D]);const ce=V.contexts[0]??null,Be=wn(ue=>d?ue.entries[qn(d)]?.hasChecked===!0:!1),me=ce?.primaryRemote??null,he=l.useMemo(()=>ce?qn(ce):"",[ce]),G=wn(ue=>ue.entries[he]),le=ce?la(G,ce):{authChecked:G?.hasChecked??!1,connected:!1},ye=le.authChecked,[Ie,K]=l.useState(0),[se,U]=l.useState({key:"",status:"loading",capabilities:null}),[ie,we]=l.useState(!1),{detectedUpstream:pe,upstreamBranches:Se}=rw(t,p,ce);l.useEffect(()=>{if(!ce)return;let ue=!1;const Fe=qn(ce);return U({key:Fe,status:"loading",capabilities:null}),p.capabilities(ce).then(yt=>{ue||U({key:Fe,status:"ready",capabilities:yt})}).catch(()=>{ue||U({key:Fe,status:"error",capabilities:null})}),()=>{ue=!0}},[Ie,ce,p]);const Ce=se.key===he?se:null,Oe=Ce?.status==="ready"?Ce.capabilities:null;l.useEffect(()=>{we(!1)},[t]);const ae=!!(t&&e&&s&&(e!==s||pe!==null)),xe=l.useMemo(()=>ce?uf(ce,e):"",[e,ce]),Te=l.useRef(xe);Te.current=xe;const Ge=l.useCallback((ue,Fe)=>ue===Xt()&&Fe===Te.current,[]),st=ds(ue=>ue.entries[xe]),rt=l.useMemo(()=>xe?[xe]:[],[xe]);ff(pf(rt));const Ke=st?.isLoading??!1,ke=le.connected?st?.status??null:null,ge=V.error?u("settings.gitlab.status.operationFailed"):st?.error??null,Ve=st?.isInitialStatusResolved??!1,Ue=l.useMemo(()=>{const ue=ie?null:me,Fe=new Set;for(const Et of o){const ne=sw(Et,ue);!ne||ne==="HEAD"||Fe.add(ne)}if(ie)for(const Et of Se)Et&&Et!=="HEAD"&&Fe.add(Et);const yt=yn(s);yt&&yt!=="HEAD"&&Fe.add(yt);const $t=yn(A);return $t&&$t!=="HEAD"&&Fe.add($t),Array.from(Fe).sort((Et,ne)=>Et.localeCompare(ne))},[s,o,me,A,Se,ie]);l.useEffect(()=>{const ue=yn(s);if(!A&&ue){F(ue);return}if(Ue.length!==0&&!Ue.includes(A)){const Fe=Ue.includes(ue)?ue:Ue[0];Fe&&F(Fe)}},[Ue,s,A]);const ft=l.useRef([]),Qe=l.useRef(new Map),wt=l.useCallback(ue=>{const Fe=Qe.current.get(ue);if(Fe?.inFlight)return null;if(Fe)return Fe.inFlight=!0,Fe.key;const yt=Jv();return Qe.current.set(ue,{key:yt,inFlight:!0}),yt},[]),Me=l.useCallback((ue,Fe,yt)=>{const $t=Qe.current.get(ue);!$t||$t.key!==Fe||(yt?$t.inFlight=!1:Qe.current.delete(ue))},[]);l.useEffect(()=>{pe&&we(!0)},[pe]),l.useEffect(()=>{ie&&pe?.defaultBranch&&F(pe.defaultBranch)},[ie,pe?.defaultBranch]);const Pe=ke?.changeRequest??ke?.pr??null,ot=ke?.identity??ce,et=l.useMemo(()=>ke?.project??(ke?.repo&&ot?{...ke.repo,...ot,id:`${ke.repo.owner}/${ke.repo.repo}`,name:ke.repo.repo}:null),[ke?.project,ke?.repo,ot]),Ze=Pe?.state==="merged"||Pe?.state==="closed",dt=Ze?null:Pe,J=ke?.ci?.summary??ke?.checks??null,[_e,Le]=l.useState(!1),He=l.useRef(!0);l.useEffect(()=>(He.current=!0,()=>{He.current=!1}),[]);const $e=l.useCallback(async ue=>{await z(xe,ue)},[xe,z]),tt=l.useCallback((ue,Fe)=>{ft.current.forEach(yt=>{window.clearTimeout(yt)}),ft.current=Zv.map(yt=>window.setTimeout(()=>{Ge(ue,Fe)&&z(Fe,{force:!0,silent:!0,markInitialResolved:!0})},yt))},[Ge,z]),bt=l.useCallback(async(ue,Fe,yt)=>{await Lv({error:ue,isCurrent:()=>Ge(Fe,yt),refresh:()=>z(yt,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>tt(Fe,yt)})},[Ge,z,tt]);l.useEffect(()=>{!ce||!xe||(j(xe),k(xe,{directory:t,branch:e,remoteName:ce.primaryRemote,canShow:ae,identity:ce,readContext:ce,sourceControl:p,authChecked:le.authChecked,connected:le.connected}))},[e,ae,t,j,xe,ce,p,le.authChecked,le.connected,k]);const ht=600,it=l.useCallback(async()=>{if(_e)return;Le(!0);const ue=Date.now();try{await $e({force:!0})}finally{const Fe=ht-(Date.now()-ue);Fe>0&&await new Promise(yt=>window.setTimeout(yt,Fe)),He.current&&Le(!1)}},[_e,$e]);l.useEffect(()=>{if(!(!ce||!xe))return E(xe),()=>{R(xe)}},[xe,ce,E,R]),l.useEffect(()=>{const ue=Oi.get(S)??null;W(ue?.title??Ai(e)),Y(ue?.body??""),P(ue?.draft??Vc()),F(ue?.targetBaseBranch?yn(ue.targetBaseBranch):yn(s))},[s,e,S]),l.useEffect(()=>{!ce||!xe||!le.connected||$e({markInitialResolved:!0})},[xe,ce,$e,le.connected]),l.useEffect(()=>{!ae||!ce||!le.connected||$e({force:!0,silent:!0,markInitialResolved:!0})},[ae,ce,$e,le.connected]),l.useEffect(()=>{const ue=()=>{const yt=ds.getState().entries[xe]?.lastRefreshAt??0;Date.now()-yt>6e4&&$e({force:!0,silent:!0})},Fe=()=>{document.visibilityState==="visible"&&ue()};return window.addEventListener("focus",ue),document.addEventListener("visibilitychange",Fe),()=>{window.removeEventListener("focus",ue),document.removeEventListener("visibilitychange",Fe)}},[xe,$e]),l.useEffect(()=>{ye&&!le.connected&&$e({force:!0,silent:!0,markInitialResolved:!0})},[$e,le.connected,ye]),l.useEffect(()=>{!t||!e||Oi.set(S,{title:_,body:N,draft:C,additionalContext:I,targetBaseBranch:A})},[S,_,N,C,I,A,t,e]),l.useEffect(()=>()=>{ft.current.forEach(ue=>{window.clearTimeout(ue)}),ft.current=[]},[xe,Ee]),l.useEffect(()=>()=>{Qe.current.clear()},[]);const Mt=ie&&pe?.defaultBranchSha?pe.defaultBranchSha:ce?`${ce.primaryRemote}/${A}`:A;l.useEffect(()=>{if(!t||!e||!Mt)return;let ue=!1;return Ty(t,{from:Mt,to:e,maxCount:2}).then(Fe=>{const yt=Fe.all.length===1?Fe.all[0]?.message.trim():"";ue||!yt||W($t=>$t===Ai(e)?yt:$t)}).catch(()=>{}),()=>{ue=!0}},[e,Mt,t]);const nt=!r||i>0,Lt=qv(t,e),_t=l.useId(),Tt=ue=>{P(ue),tw(ue)},Ae=l.useCallback(async()=>{if(!L&&t){X(!0);try{const Fe={base:Mt,head:e,...ce?.provider?{changeRequestProvider:ce.provider}:{}};I&&(Fe.context=I);const yt=await Dy(t,Fe);yt.title?.trim()&&W(yt.title.trim()),yt.body?.trim()&&Y(yt.body.trim()),c?.()}catch(ue){const Fe=ue instanceof Error?ue.message:String(ue);ze.error(u("gitView.pr.toast.generateDescriptionFailed"),{description:Fe})}finally{X(!1)}}},[I,e,Mt,t,L,c,ce,u]),at=l.useCallback(async()=>{if(Oe?.changeRequests!==!0){ze.error(u("gitView.pr.toast.createPrFailed"),{description:u("gitView.pr.capabilitiesUnavailable")});return}const ue=_.trim();if(!ue){ze.error(u("gitView.pr.toast.titleRequired"));return}const Fe=A.trim();if(!Fe){ze.error(u("gitView.pr.toast.baseBranchRequired"));return}if(!ie&&Fe===e){ze.error(u("gitView.pr.toast.baseMustDifferFromHead"));return}const yt=ie?pe:et;if(!ce||!yt){ze.error(u("gitView.pr.toast.createPrFailed"),{description:ge??u("gitView.pr.statusUnavailable")});return}if(nt&&(te(!0),!await Lt.push())){te(!1);return}const $t=Xt(),Et=xe,ne={owner:yt.owner,name:yt.name},Ye=N.trim()?N:void 0,qe=ie?void 0:ce.primaryRemote,Pt=ie?ce.primaryRemote:void 0,Rt=ew($t,ce,[ne.owner,ne.name,e,Fe,ue,Ye,C,qe,Pt]),je=wt(Rt);if(!je){te(!1);return}te(!0);let Je=!1,gt=!1;try{const kt={...ce,idempotencyKey:je,target:{project:ne,head:e,base:Fe},title:ue,draft:C};Ye!==void 0&&(kt.body=Ye),qe&&(kt.remote=qe),Pt&&(kt.headRemote=Pt);const Dt=await p.changeRequestCreate(kt);if(gt=!0,Me(Rt,je,!1),!Ge($t,Et)||(ze.success(u("gitView.pr.toast.prCreated")),await $e({force:!0}),!Ge($t,Et)))return;const Gt=ds.getState().entries[Et]?.status,rs=Gt?.changeRequest??Gt?.pr;rs&&rs.number===Dt.target.number&&Xv(t,rs),tt($t,Et)}catch(kt){const Dt=kt instanceof Error?kt:new Error(String(kt));Je=dp(Dt);const Gt=Dt.message;ze.error(u("gitView.pr.toast.createPrFailed"),{description:Gt}),Je&&await bt(Dt,$t,Et)}finally{gt||Me(Rt,je,Je),te(!1)}},[wt,N,e,Lt,pe,t,C,ge,Me,Ge,nt,xe,ce,bt,$e,tt,p,Oe?.changeRequests,et,A,_,ie,u]),ut="border-0 bg-transparent rounded-none px-4 py-3";if(!ae)return n.jsx("section",{className:ut,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(Ov,{identity:d??void 0})]})});const pt=ke?.changeRequest&&ke.changeRequest.state==="open"?ke.changeRequest:dt&&et&&ot?{...ot,id:`${et.owner}/${et.name}#${dt.number}`,number:dt.number,project:{...ot,id:et.id,owner:et.owner,name:et.name,url:et.url??""},title:dt.title,body:dt.body,url:dt.url,state:dt.state,draft:dt.draft,base:dt.base,head:dt.head,headSha:dt.headSha,mergeable:dt.mergeable,mergeableState:dt.mergeableState}:null;if(pt&&ce)return n.jsx("div",{className:"h-full min-h-0",children:n.jsx(zv,{directory:t,context:ce,changeRequest:pt,onChanged:()=>{$e({force:!0,silent:!0,markInitialResolved:!0})}})});const lt=et?.url||null,St=ie&&pe?.url?pe.url:lt,ct=Ce?.status==="error",oe=!!ke?.connected,q=!!(!ce&&d&&V.status==="ready"&&Be),fe=!!(ot&&ye&&ke?.connected===!1)||q,We=ot??d,be=We?Ry(We.provider):null,Ne=Qv(ke),mt=Ne?`var(--pr-${Ne})`:"var(--status-info)",jt=Ne==="draft"?"git-pr-draft":Ne==="merged"?"git-merge":Ne==="closed"?"git-close-pull-request":"git-pull-request",At=Pe?[`${Pe.state}${Pe.draft?" (draft)":""}`,Pe.state==="open"&&Pe.mergeable===!1?u("gitView.pr.notMergeable"):null,Pe.state==="open"&&typeof Pe.mergeableState=="string"&&Pe.mergeableState&&Pe.mergeableState!=="unknown"?Pe.mergeableState:null].filter(Boolean).join(" · "):"",Ot=J?J.total>0?`${J.success}/${J.total} ${u("gitView.pr.checks.label")}`:`${J.state} ${u("gitView.pr.checks.label")}`:"",Wt="px-0 py-3 border-b border-border/40 flex flex-col gap-1",Qt="flex flex-col gap-3 py-3",Ut=n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Ke||_e,onClick:()=>{it()},"aria-label":u("gitView.pr.actions.refreshAria"),children:n.jsx(Q,{name:Ke||_e?"loader-4":"refresh",className:De("size-4 text-muted-foreground",(Ke||_e)&&"animate-spin")})})}),n.jsx(Ft,{children:n.jsx("p",{children:u("gitView.pr.actions.refresh")})})]}),Ss=M||I.trim().length>0,bs=nt?r?i===1?u("gitView.pr.unpushed.one"):u("gitView.pr.unpushed.many",{count:i}):u("gitView.pr.unpushed.unpublished"):null,ys=u(nt?C?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":C?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),Re=re||!oe||Oe?.changeRequests!==!0||!A.trim()||!ie&&A.trim()===e;return n.jsxs("section",{className:ut,children:[Pe?n.jsxs("div",{className:Wt,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(It,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Uc(Pe.url)},"aria-label":be?u("gitView.pr.actions.openOnProviderAria",{provider:be}):u("gitView.header.openPullRequest"),children:[n.jsx(Q,{name:jt,className:"size-4 shrink-0",style:{color:mt}}),be?u("gitView.pr.actions.openOnProvider",{provider:be}):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:nl(ot?.provider,Pe.number)})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:Ut})]}),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:mt},children:At}),J?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${Yv(J.state)}`}),Ot]}):null,r&&me&&r.split("/")[0]!==me?n.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",me]}):null]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:h&&(ce?.provider==="github"||ce?.provider==="gitlab")?n.jsxs(It,{variant:"outline",size:"sm",className:De("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Av),onClick:()=>{b(t,{source:{kind:"pr",number:Pe.number,...et?{sourceRepo:{owner:et.owner,repo:et.name}}:{}},context:ce}),x(t,"walkthrough")},"aria-label":u("walkthrough.action.open"),children:[n.jsx(Q,{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:Qt,children:[ct?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(It,{variant:"outline",size:"sm",onClick:()=>K(ue=>ue+1),children:u("settings.sourceControl.transport.retry")})]}):null,fe&&be?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-meta text-muted-foreground",children:u("gitView.pr.providerNotConnected",{provider:be})}),n.jsx(It,{variant:"outline",size:"sm",onClick:f,className:"w-fit",children:u("gitView.pr.actions.openSettings")})]}):null,ge?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:ge}),V.error?n.jsx(It,{variant:"outline",size:"sm",onClick:()=>{V.retry()},disabled:V.status==="loading",children:u("settings.sourceControl.transport.retry")}):null,St?n.jsx(It,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:n.jsxs("a",{href:St,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(Q,{name:"external-link",className:"size-4"}),u("gitView.pr.actions.repo")]})}):null]}):null,(dt||!Pe&&!Ve)&&!ge&&!fe&&(V.status==="loading"||ce)?n.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[n.jsx(Q,{name:"loader-4",className:"size-4 animate-spin"}),u("gitView.pr.checkingStatus")]}):n.jsxs("div",{className:"flex flex-col gap-3",children:[Pe&&Ze?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(Q,{name:Pe.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:mt}}),n.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Pe.state==="merged"?u("gitView.pr.history.merged",{number:Pe.number,base:Pe.base||A}):u("gitView.pr.history.closed",{number:Pe.number})}),n.jsx(It,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Uc(Pe.url)},"aria-label":u("gitView.pr.actions.openOnProviderAria",{provider:be}),children:n.jsx(Q,{name:"external-link",className:"size-3.5"})})]}):null,n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx(Q,{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(Q,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),ie&&pe?n.jsxs("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:[pe.owner,"/",pe.name]}):null,Ue.length>0?n.jsxs(Ny,{value:A,onValueChange:F,children:[n.jsx(My,{className:"w-auto min-w-0","aria-label":u("gitView.pr.field.baseBranch"),children:n.jsx(Ay,{placeholder:u("gitView.pr.placeholder.selectBaseBranch")})}),n.jsx(Oy,{children:Ue.map(ue=>n.jsx(By,{value:ue,children:ue},ue))})]}):n.jsx(To,{value:A,onChange:ue=>F(ue.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:[St?n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:n.jsx("a",{href:St,target:"_blank",rel:"noopener noreferrer","aria-label":u("gitView.pr.actions.repo"),children:n.jsx(Q,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),n.jsx(Ft,{children:n.jsx("p",{children:u("gitView.pr.actions.repo")})})]}):null,Ut]})]}),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(To,{value:_,onChange:ue=>W(ue.target.value),placeholder:u("gitView.pr.placeholder.title"),autoCorrect:y?"on":"off",autoCapitalize:y?"sentences":"off",spellCheck:y})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("label",{htmlFor:_t,className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.description")}),n.jsxs("div",{className:"flex items-center",children:[n.jsxs(It,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:Ae,disabled:L||re,children:[L?n.jsx(Q,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(Q,{name:"ai-generate-2",className:"size-3.5 text-primary"}),u("gitView.commit.generate")]}),n.jsxs(Ts,{children:[n.jsx(Ds,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:L||re,"aria-label":u("gitView.pr.generate.optionsAria"),children:n.jsx(Q,{name:"arrow-down-s",className:"size-3.5"})})}),n.jsx(Rs,{align:"end",className:"w-60",children:n.jsxs(Zt,{onSelect:()=>ee(!0),children:[n.jsx(Q,{name:"sticky-note",className:"size-4 shrink-0"}),u("gitView.pr.generate.withNotes")]})})]})]})]}),Ss?n.jsxs("div",{className:"relative",children:[n.jsx(bc,{value:I,onChange:ue=>H(ue.target.value),className:"min-h-[72px] pe-9",placeholder:u("gitView.pr.placeholder.additionalContext"),"aria-label":u("gitView.pr.generate.notesAria"),autoFocus:M&&!I}),n.jsx(It,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{H(""),ee(!1)},"aria-label":u("gitView.pr.generate.removeNotesAria"),children:n.jsx(Q,{name:"close",className:"size-3.5"})})]}):null,n.jsx(bc,{id:_t,value:N,onChange:ue=>Y(ue.target.value),className:"min-h-[140px]",placeholder:u("gitView.pr.placeholder.whatChanged"),autoCorrect:y?"on":"off",autoCapitalize:y?"sentences":"off",spellCheck:y})]}),bs?n.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[n.jsx(Q,{name:"arrow-up",className:"size-3.5 shrink-0"}),bs]}):null,n.jsx("div",{className:"flex justify-end",children:n.jsxs("div",{className:"flex items-center",children:[n.jsxs(It,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:at,disabled:Re,children:[re?n.jsx(Q,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(Q,{name:C?"git-pr-draft":"git-pull-request",className:"size-4"}),n.jsx("span",{children:ys})]}),n.jsxs(Ts,{children:[n.jsx(Ds,{asChild:!0,children:n.jsx(It,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:re,"aria-label":u("gitView.pr.createKindAria"),children:n.jsx(Q,{name:"arrow-down-s",className:"size-4"})})}),n.jsx(Rs,{align:"end",className:"w-56",children:n.jsxs(Fy,{value:C?"draft":"ready",onValueChange:ue=>Tt(ue==="draft"),children:[n.jsx(yc,{value:"ready",children:u("gitView.pr.actions.createPr")}),n.jsx(yc,{value:"draft",children:u("gitView.pr.actions.createDraftPr")})]})})]})]})}),Lt.dialogs]})]})]})},iw=()=>{const t=Xe.c(100),{t:e}=Ct(),{git:s,sourceControl:r}=Ws(),i=hn(),{rootIsGitRepo:o,gitDirectory:c,nestedRepos:a}=zy(i??null),d=rl(c??null),u=Ky(c??null),f=Wy(c??null),p=df(c,r),{ensureAll:m,ensureNestedRepos:g,selectNestedRepo:y}=kn(ar(aw)),v=xt(lw),x=xt(cw),b=xt(dw),h=xt(uw);let S;t[0]!==i?(S=vt(i),t[0]=i,t[1]=S):S=t[1];const w=S;let j;if(t[2]!==h||t[3]!==w||t[4]!==b){e:{if(!w){j=void 0;break e}let ye;if(t[6]!==h||t[7]!==w){let K;t[9]!==w?(K=se=>vt(se.path)===w,t[9]=w,t[10]=K):K=t[10],ye=h.find(K),t[6]=h,t[7]=w,t[8]=ye}else ye=t[8];const Ie=ye;if(Ie){j=Ie;break e}for(const K of b.values())if(vt(K.path)===w){j=K;break e}j=void 0}t[2]=h,t[3]=w,t[4]=b,t[5]=j}else j=t[5];const k=j;let T;t[11]!==v||t[12]!==k||t[13]!==x?.open||t[14]!==b?(T=()=>{if(v)return b.get(v)??k;if(x?.open)return k},t[11]=v,t[12]=k,t[13]=x?.open,t[14]=b,t[15]=T):T=t[15],x?.open;let O;t[16]!==T?(O=T(),t[16]=T,t[17]=O):O=t[17];const $=O;let D;t[18]!==v?(D=ye=>v?ye.getAttachment(v):void 0,t[18]=v,t[19]=D):D=t[19];const E=qu(D),R=E&&!E.degraded&&!E.legacy?E.worktreeRoot??void 0:void 0,z=Tv(i,$,d?.current??void 0);let _,W;t[20]!==m||t[21]!==s||t[22]!==c?(_=()=>{!c||!s||m(c,s)},W=[c,m,s],t[20]=m,t[21]=s,t[22]=c,t[23]=_,t[24]=W):(_=t[23],W=t[24]),l.useEffect(_,W);const[N,Y]=l.useState(null);let C;t[25]!==R||t[26]!==z?.projectDirectory?(C=()=>{const ye=R||z?.projectDirectory;if(!ye){Y(null);return}let Ie=!1;return hf(ye).then(K=>{if(Ie)return;const se=K.trim();Y(se&&se!=="HEAD"?se:null)}).catch(()=>{Ie||Y(null)}),()=>{Ie=!0}},t[25]=R,t[26]=z?.projectDirectory,t[27]=C):C=t[27];const P=z?.projectDirectory;let I;t[28]!==R||t[29]!==P?(I=[R,P],t[28]=R,t[29]=P,t[30]=I):I=t[30],l.useEffect(C,I);let H;e:{if(!u?.all){let Ie;t[31]===Symbol.for("react.memo_cache_sentinel")?(Ie=[],t[31]=Ie):Ie=t[31],H=Ie;break e}let ye;t[32]!==u.all?(ye=u.all.filter(fw).sort(),t[32]=u.all,t[33]=ye):ye=t[33],H=ye}const A=H;let F;e:{if(!u?.all){let Ie;t[34]===Symbol.for("react.memo_cache_sentinel")?(Ie=[],t[34]=Ie):Ie=t[34],F=Ie;break e}let ye;t[35]!==u.all?(ye=u.all.filter(pw).map(hw).sort(),t[35]=u.all,t[36]=ye):ye=t[36],F=ye}const L=F,X=d?.current??null,re=p.contexts[0]?.primaryRemote,te=re?u?.defaultBranches?.[re]:void 0;let M;t[37]!==p.contexts[0]||t[38]!==p.read?.repository.remotes||t[39]!==X||t[40]!==te||t[41]!==A||t[42]!==N||t[43]!==z?.createdFromBranch?(M=()=>Ug({remoteNames:new Set(p.contexts[0]?.primaryRemote?[p.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(p.read?.repository.remotes.map(mw)??[]),localBranches:A,worktreeCreatedFromBranch:z?.createdFromBranch,rootBranchHint:N,defaultBranch:te,headBranch:X,fallbackToConventional:!1}),t[37]=p.contexts[0],t[38]=p.read?.repository.remotes,t[39]=X,t[40]=te,t[41]=A,t[42]=N,t[43]=z?.createdFromBranch,t[44]=M):M=t[44],z?.createdFromBranch;let ee;t[45]!==M?(ee=M(),t[45]=M,t[46]=ee):ee=t[46];const V=ee,Ee=cf(i??null)?.provider;if(!i){let ye;t[47]===Symbol.for("react.memo_cache_sentinel")?(ye=n.jsx(Q,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[47]=ye):ye=t[47];let Ie;t[48]!==Ee||t[49]!==e?(Ie=e(cn("gitView.pullRequest.title",Ee)),t[48]=Ee,t[49]=e,t[50]=Ie):Ie=t[50];let K;t[51]!==Ie?(K=n.jsx("div",{className:"typography-ui-header text-foreground",children:Ie}),t[51]=Ie,t[52]=K):K=t[52];let se;t[53]!==Ee||t[54]!==e?(se=e(cn("gitView.pullRequest.createHint",Ee)),t[53]=Ee,t[54]=e,t[55]=se):se=t[55];let U;t[56]!==se?(U=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:se}),t[56]=se,t[57]=U):U=t[57];let ie;return t[58]!==K||t[59]!==U?(ie=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[ye,K,U]}),t[58]=K,t[59]=U,t[60]=ie):ie=t[60],ie}if(o===!1&&f!==!0){let ye;t[61]!==i||t[62]!==g?(ye=()=>{g(i,{force:!0})},t[61]=i,t[62]=g,t[63]=ye):ye=t[63];let Ie;return t[64]!==i||t[65]!==f||t[66]!==a||t[67]!==o||t[68]!==ye?(Ie=n.jsx(Gg,{root:i,rootIsGitRepo:o,resolvedIsGitRepo:f,nestedRepos:a,onRetryDiscovery:ye}),t[64]=i,t[65]=f,t[66]=a,t[67]=o,t[68]=ye,t[69]=Ie):Ie=t[69],Ie}if(!X){let ye;t[70]===Symbol.for("react.memo_cache_sentinel")?(ye=n.jsx(Q,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[70]=ye):ye=t[70];let Ie;t[71]!==Ee||t[72]!==e?(Ie=e(cn("gitView.pullRequest.title",Ee)),t[71]=Ee,t[72]=e,t[73]=Ie):Ie=t[73];let K;t[74]!==Ie?(K=n.jsx("div",{className:"typography-ui-header text-foreground",children:Ie}),t[74]=Ie,t[75]=K):K=t[75];let se;t[76]!==Ee||t[77]!==e?(se=e(cn("gitView.pullRequest.createHint",Ee)),t[76]=Ee,t[77]=e,t[78]=se):se=t[78];let U;t[79]!==se?(U=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:se}),t[79]=se,t[80]=U):U=t[80];let ie;return t[81]!==K||t[82]!==U?(ie=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[ye,K,U]}),t[81]=K,t[82]=U,t[83]=ie):ie=t[83],ie}const ve=o===!1&&Array.isArray(a)&&a.length>0;let ce;t[84]!==i||t[85]!==c||t[86]!==a||t[87]!==y||t[88]!==ve?(ce=ve?n.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:n.jsx(qg,{repositories:a,selectedRepository:c??null,onSelectRepository:ye=>{i&&y(i,ye)},repositoryRoot:i??void 0})}):null,t[84]=i,t[85]=c,t[86]=a,t[87]=y,t[88]=ve,t[89]=ce):ce=t[89];const Be=c??i,me=d?.tracking??void 0,he=d?.ahead??0;let G;t[90]!==V||t[91]!==X||t[92]!==L||t[93]!==Be||t[94]!==me||t[95]!==he?(G=n.jsx(Or,{as:Hy,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:n.jsx(ow,{directory:Be,branch:X,baseBranch:V,trackingBranch:me,ahead:he,remoteBranches:L})}),t[90]=V,t[91]=X,t[92]=L,t[93]=Be,t[94]=me,t[95]=he,t[96]=G):G=t[96];let le;return t[97]!==ce||t[98]!==G?(le=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ce,G]}),t[97]=ce,t[98]=G,t[99]=le):le=t[99],le};function aw(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function lw(t){return t.currentSessionId}function cw(t){return t.newSessionDraft}function dw(t){return t.worktreeMetadata}function uw(t){return t.availableWorktrees}function fw(t){return!t.startsWith("remotes/")}function pw(t){return t.startsWith("remotes/")}function hw(t){return t.replace(/^remotes\//,"")}function mw(t){return t.name}const Ao=new Map,gw=(t,e)=>{if(t.size!==e.size)return!1;for(const[s,r]of t)if(e.get(s)!==r)return!1;return!0},bw=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},yw=(t,e)=>{if(e.length===0)return Ao;const s=new Set(e),r=new Map,i=new Map;for(const o of t)for(const c of o.session){if(!s.has(c.id))continue;const a=c.title?.trim();if(!a)continue;const d=bw(c),u=r.get(c.id);u!==void 0&&u>d||(r.set(c.id,d),i.set(c.id,a))}return i.size===0?Ao:i},yl=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Gc=60,xw=t=>{try{return new URL(t).origin}catch{return""}},Bi=new Set,fp=Vr()((t,e)=>({byOrigin:{},resolve:(s,r,i)=>{const o=xw(s);!o||!r||e().byOrigin[o]||Bi.has(o)||(Bi.add(o),Un("desktop_browser_fetch_favicon",{url:r,webContentsId:i}).then(c=>{const a=typeof c?.dataUrl=="string"?c.dataUrl:"";a&&t(d=>{const u={...d.byOrigin,[o]:a},f=Object.keys(u);if(f.length<=Gc)return{byOrigin:u};for(const p of f.slice(0,f.length-Gc))delete u[p];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{Bi.delete(o)}))}})),xl=t=>t,va=t=>{const e=xl(t).type;return typeof e=="string"?e:""},Sw=t=>{const e=xl(t).tool;return typeof e=="string"?e:""},vw=t=>{const e=xl(t).text;return typeof e=="string"?e:""},ww=t=>{const e=va(t);return e==="tool"?Sw(t).trim().toLowerCase()||"tool":e||"unknown"},kw=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=ww(s);e.includes(r)||e.push(r)}return e.join(" + ")},jw=t=>t.replace(/\s+/g," ").trim(),Cw=t=>{for(const s of t)if(va(s)==="text"){const r=jw(vw(s));if(r.length===0)continue;return r}const e=t.filter(s=>va(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Pw=(t,e,s)=>`${s(t)} / ${s(e)}`,Ew=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Iw=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=Ew(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}})},wa={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},ho={user:0,assistant:0,tool:0,other:0},xn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,qc=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{...wa,total:xn(s)};if(!s||typeof s!="object")return wa;const r=s,i=xn(r.input),o=xn(r.output),c=xn(r.reasoning),a=xn(r.cache?.read),d=xn(r.cache?.write),u=xn(r.total);return{input:i,output:o,reasoning:c,cacheRead:a,cacheWrite:d,total:u>0?u:i+o+c+a+d}},Tw=(...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,Dw=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...ho,assistant:Ns(s.text)+Ns(s.content)};const i=Tw(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((Am(t)??0)*.1),other:0}:e==="user"?{user:i.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},Yc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),Rw=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",Nw=(t,e)=>{if(t.length===0)return{...ho};const s=t.reduce((r,i)=>{const o=Rw(i);let c={...ho};for(const a of i.parts)c=Yc(c,Dw(a,o));return Yc(r,c)},{...ho});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)}},On=t=>t.toLocaleString(gf()),Mw=(t,e)=>!t||!Number.isFinite(t)?"-":qy(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Aw=(t,e,s)=>{const r=t.find(o=>o.id===e),i=r?.models?.find(o=>o.id===s);return{providerName:r?.name||e||"-",modelName:i?.name||s||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},Ow=()=>{const t=Xe.c(219),{t:e}=Ct(),s=Yg(),r=de(Bw);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={},t[0]=i):i=t[0];const[o,c]=l.useState(i),[a,d]=l.useState(null),u=l.useRef(null),f=xt(Fw),p=xt(Lw),m=Vy(p??void 0),g=Uy(f??"",p??void 0),y=is(_w);let v;t[1]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),c($w),d(null)},t[1]=v):v=t[1];let x;t[2]!==p||t[3]!==f?(x=[p,f],t[2]=p,t[3]=f,t[4]=x):x=t[4],l.useEffect(v,x);let b,h;t[5]===Symbol.for("react.memo_cache_sentinel")?(b=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},h=[],t[5]=b,t[6]=h):(b=t[5],h=t[6]),l.useEffect(b,h);let S;t[7]===Symbol.for("react.memo_cache_sentinel")?(S=async(be,Ne)=>{(await ti(Ne)).ok?(d(be),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{d(jt=>jt===be?null:jt),u.current=null},2e3)):d(null)},t[7]=S):S=t[7];const w=S;let j;t[8]!==f||t[9]!==m?(j=f?m.find(be=>be.id===f)??null:null,t[8]=f,t[9]=m,t[10]=j):j=t[10];const k=j;let T,O,$,D,E,R,z;if(t[11]!==g){T=g.filter(zw),z=g.filter(Kw);const be=mf(g.map(Ww));$=be?g[be.index]??null:null,D=be?.state==="compacted";let Ne;t[19]!==$?(R=$?qc($):wa,Ne=Gy({input:R.input,cache:{read:R.cacheRead,write:R.cacheWrite}}),t[19]=$,t[20]=Ne,t[21]=R):(Ne=t[20],R=t[21]),O=Ne,E=T.reduce(Hw,0),t[11]=g,t[12]=T,t[13]=O,t[14]=$,t[15]=D,t[16]=E,t[17]=R,t[18]=z}else T=t[12],O=t[13],$=t[14],D=t[15],E=t[16],R=t[17],z=t[18];const _=E,W=$?.info??null,N=y,Y=W?.providerID||"",C=W?.modelID||"";let P;t[22]!==C||t[23]!==N||t[24]!==Y?(P=Aw(N,Y,C),t[22]=C,t[23]=N,t[24]=Y,t[25]=P):P=t[25];const I=P,H=I.contextLimit,A=D?null:H&&H>0?Math.min(999,R.total/H*100):0;let F;if(t[26]!==g){const be=[...g].reverse().find(Vw),Ne=be?.info.role==="system"?be.info.text:"";F=Nw(g,Ne),t[26]=g,t[27]=F}else F=t[27];const L=F,X=L.user,re=L.assistant,te=L.tool,M=Math.max(0,R.input-X-re-te),ee=X+re+te+M,V=g[0]?.info?.time?.created,Ee=g.length>0?g[g.length-1]?.info?.time?.created:null;let ve;t[28]!==k?.title||t[29]!==e?(ve=k?.title||e("contextSidebar.session.untitled"),t[28]=k?.title,t[29]=e,t[30]=ve):ve=t[30];const ce=k?.time?.created??V??null,Be=Ee??k?.time?.created??null;let me;t[31]!==re||t[32]!==M||t[33]!==te||t[34]!==X?(me={user:X,assistant:re,tool:te,other:M},t[31]=re,t[32]=M,t[33]=te,t[34]=X,t[35]=me):me=t[35];let he;t[36]!==T.length||t[37]!==ee||t[38]!==O||t[39]!==H||t[40]!==I||t[41]!==g.length||t[42]!==ve||t[43]!==ce||t[44]!==Be||t[45]!==me||t[46]!==R||t[47]!==_||t[48]!==A||t[49]!==z.length?(he={sessionTitle:ve,messagesCount:g.length,userMessagesCount:z.length,assistantMessagesCount:T.length,createdAt:ce,lastActivityAt:Be,providerModel:I,tokenBreakdown:R,usagePercent:A,cacheHitRate:O,totalAssistantCost:_,contextLimit:H,breakdown:me,breakdownTotal:ee},t[36]=T.length,t[37]=ee,t[38]=O,t[39]=H,t[40]=I,t[41]=g.length,t[42]=ve,t[43]=ce,t[44]=Be,t[45]=me,t[46]=R,t[47]=_,t[48]=A,t[49]=z.length,t[50]=he):he=t[50];const G=he;if(!f){let be;t[51]!==e?(be=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=be):be=t[52];let Ne;return t[53]!==be?(Ne=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:be}),t[53]=be,t[54]=Ne):Ne=t[54],Ne}let le;t[55]!==e?(le=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=le):le=t[56];let ye;t[57]!==le||t[58]!==G.breakdown.user?(ye={key:"user",label:le,value:G.breakdown.user,color:"var(--status-success)"},t[57]=le,t[58]=G.breakdown.user,t[59]=ye):ye=t[59];let Ie;t[60]!==e?(Ie=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=Ie):Ie=t[61];let K;t[62]!==Ie||t[63]!==G.breakdown.assistant?(K={key:"assistant",label:Ie,value:G.breakdown.assistant,color:"var(--primary-base)"},t[62]=Ie,t[63]=G.breakdown.assistant,t[64]=K):K=t[64];let se;t[65]!==e?(se=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=se):se=t[66];let U;t[67]!==se||t[68]!==G.breakdown.tool?(U={key:"tool",label:se,value:G.breakdown.tool,color:"var(--status-warning)"},t[67]=se,t[68]=G.breakdown.tool,t[69]=U):U=t[69];let ie;t[70]!==e?(ie=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=ie):ie=t[71];let we;t[72]!==ie||t[73]!==G.breakdown.other?(we={key:"other",label:ie,value:G.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=ie,t[73]=G.breakdown.other,t[74]=we):we=t[74];let pe;t[75]!==ye||t[76]!==K||t[77]!==U||t[78]!==we?(pe=[ye,K,U,we],t[75]=ye,t[76]=K,t[77]=U,t[78]=we,t[79]=pe):pe=t[79];const Se=pe;let Ce;t[80]!==s||t[81]!==G.sessionTitle?(Ce=s?n.jsx(Xg,{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:G.sessionTitle,children:G.sessionTitle})})}):null,t[80]=s,t[81]=G.sessionTitle,t[82]=Ce):Ce=t[82];let Oe;t[83]!==s||t[84]!==G.sessionTitle?(Oe=s?null:n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:G.sessionTitle}),t[83]=s,t[84]=G.sessionTitle,t[85]=Oe):Oe=t[85];const B=!s&&"mt-1";let ae;t[86]!==B?(ae=De(B,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70"),t[86]=B,t[87]=ae):ae=t[87];let xe;t[88]!==G.providerModel.modelName||t[89]!==G.providerModel.providerName?(xe=n.jsxs("span",{children:[G.providerModel.providerName," / ",G.providerModel.modelName]}),t[88]=G.providerModel.modelName,t[89]=G.providerModel.providerName,t[90]=xe):xe=t[90];let Te;t[91]!==r||t[92]!==G.createdAt?(Te=G.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:Mw(G.createdAt,r)})]}),t[91]=r,t[92]=G.createdAt,t[93]=Te):Te=t[93];let Ge;t[94]!==ae||t[95]!==xe||t[96]!==Te?(Ge=n.jsxs("div",{className:ae,children:[xe,Te]}),t[94]=ae,t[95]=xe,t[96]=Te,t[97]=Ge):Ge=t[97];let st;t[98]!==Oe||t[99]!==Ge?(st=n.jsxs("div",{className:"mb-6",children:[Oe,Ge]}),t[98]=Oe,t[99]=Ge,t[100]=st):st=t[100];let rt;t[101]!==e?(rt=e("contextSidebar.section.context"),t[101]=e,t[102]=rt):rt=t[102];let Ke;t[103]!==rt?(Ke=n.jsx("span",{className:"typography-micro text-muted-foreground",children:rt}),t[103]=rt,t[104]=Ke):Ke=t[104];let ke;t[105]!==G.tokenBreakdown.total||t[106]!==G.usagePercent?(ke=G.usagePercent===null?"—":On(G.tokenBreakdown.total),t[105]=G.tokenBreakdown.total,t[106]=G.usagePercent,t[107]=ke):ke=t[107];let ge;t[108]!==G.contextLimit?(ge=G.contextLimit?` / ${On(G.contextLimit)}`:"",t[108]=G.contextLimit,t[109]=ge):ge=t[109];let Ve;t[110]!==ke||t[111]!==ge?(Ve=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[ke,ge]}),t[110]=ke,t[111]=ge,t[112]=Ve):Ve=t[112];let Ue;t[113]!==Ke||t[114]!==Ve?(Ue=n.jsxs("div",{className:"flex items-baseline justify-between",children:[Ke,Ve]}),t[113]=Ke,t[114]=Ve,t[115]=Ue):Ue=t[115];let ft;t[116]!==G.usagePercent?(ft=G.usagePercent!==null&&G.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,G.usagePercent)}%`,backgroundColor:G.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[116]=G.usagePercent,t[117]=ft):ft=t[117];let Qe;t[118]!==ft?(Qe=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ft}),t[118]=ft,t[119]=Qe):Qe=t[119];let wt;t[120]!==e||t[121]!==G.usagePercent?(wt=G.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:G.usagePercent.toFixed(1)}),t[120]=e,t[121]=G.usagePercent,t[122]=wt):wt=t[122];let Me;t[123]!==wt?(Me=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:wt}),t[123]=wt,t[124]=Me):Me=t[124];let Pe;t[125]!==Ue||t[126]!==Qe||t[127]!==Me?(Pe=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Ue,Qe,Me]}),t[125]=Ue,t[126]=Qe,t[127]=Me,t[128]=Pe):Pe=t[128];let ot;t[129]!==e?(ot=e("contextSidebar.stats.messages"),t[129]=e,t[130]=ot):ot=t[130];let et;t[131]!==G.messagesCount?(et=On(G.messagesCount),t[131]=G.messagesCount,t[132]=et):et=t[132];let Ze;t[133]!==ot||t[134]!==et?(Ze={label:ot,value:et},t[133]=ot,t[134]=et,t[135]=Ze):Ze=t[135];let dt;t[136]!==e?(dt=e("contextSidebar.stats.user"),t[136]=e,t[137]=dt):dt=t[137];let J;t[138]!==G.userMessagesCount?(J=On(G.userMessagesCount),t[138]=G.userMessagesCount,t[139]=J):J=t[139];let _e;t[140]!==dt||t[141]!==J?(_e={label:dt,value:J},t[140]=dt,t[141]=J,t[142]=_e):_e=t[142];let Le;t[143]!==e?(Le=e("contextSidebar.stats.assistant"),t[143]=e,t[144]=Le):Le=t[144];let He;t[145]!==G.assistantMessagesCount?(He=On(G.assistantMessagesCount),t[145]=G.assistantMessagesCount,t[146]=He):He=t[146];let $e;t[147]!==Le||t[148]!==He?($e={label:Le,value:He},t[147]=Le,t[148]=He,t[149]=$e):$e=t[149];let tt;t[150]!==e?(tt=e("contextSidebar.stats.cost"),t[150]=e,t[151]=tt):tt=t[151];let bt;t[152]!==G.totalAssistantCost?(bt=Qf(G.totalAssistantCost),t[152]=G.totalAssistantCost,t[153]=bt):bt=t[153];let ht;t[154]!==tt||t[155]!==bt?(ht={label:tt,value:bt},t[154]=tt,t[155]=bt,t[156]=ht):ht=t[156];let it;t[157]!==Ze||t[158]!==_e||t[159]!==$e||t[160]!==ht?(it=[Ze,_e,$e,ht],t[157]=Ze,t[158]=_e,t[159]=$e,t[160]=ht,t[161]=it):it=t[161];const Mt=it;let nt;t[162]!==Mt?(nt=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:Mt.map(Uw)}),t[162]=Mt,t[163]=nt):nt=t[163];let Lt;t[164]!==e?(Lt=e("contextSidebar.section.lastAssistantMessage"),t[164]=e,t[165]=Lt):Lt=t[165];let _t;t[166]!==Lt?(_t=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:Lt}),t[166]=Lt,t[167]=_t):_t=t[167];let Tt;t[168]!==e||t[169]!==G.cacheHitRate.hasInput||t[170]!==G.cacheHitRate.percent||t[171]!==G.tokenBreakdown.cacheRead||t[172]!==G.tokenBreakdown.cacheWrite||t[173]!==G.tokenBreakdown.input||t[174]!==G.tokenBreakdown.output||t[175]!==G.tokenBreakdown.reasoning?(Tt=n.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:G.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:G.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:G.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:G.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:G.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:G.cacheHitRate.hasInput?G.cacheHitRate.percent:null,format:"percent"}].map(Gw)}),t[168]=e,t[169]=G.cacheHitRate.hasInput,t[170]=G.cacheHitRate.percent,t[171]=G.tokenBreakdown.cacheRead,t[172]=G.tokenBreakdown.cacheWrite,t[173]=G.tokenBreakdown.input,t[174]=G.tokenBreakdown.output,t[175]=G.tokenBreakdown.reasoning,t[176]=Tt):Tt=t[176];let Ae;t[177]!==_t||t[178]!==Tt?(Ae=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[_t,Tt]}),t[177]=_t,t[178]=Tt,t[179]=Ae):Ae=t[179];let at;t[180]!==Se||t[181]!==G.breakdownTotal?(at=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Se.map(be=>be.value<=0||G.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${be.value/G.breakdownTotal*100}%`,backgroundColor:be.color}},be.key))}),t[180]=Se,t[181]=G.breakdownTotal,t[182]=at):at=t[182];let ut;t[183]!==Se||t[184]!==G.breakdownTotal?(ut=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:Se.map(be=>{const Ne=G.breakdownTotal>0?be.value/G.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:be.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[be.label," ",n.jsxs("span",{className:"tabular-nums",children:[Ne.toFixed(0),"%"]})]})]},be.key)})}),t[183]=Se,t[184]=G.breakdownTotal,t[185]=ut):ut=t[185];let pt;t[186]!==at||t[187]!==ut?(pt=n.jsxs("div",{className:"mb-6",children:[at,ut]}),t[186]=at,t[187]=ut,t[188]=pt):pt=t[188];let lt;t[189]!==e?(lt=e("contextSidebar.section.rawMessages"),t[189]=e,t[190]=lt):lt=t[190];let St;t[191]!==lt?(St=n.jsx("div",{className:"typography-micro text-muted-foreground",children:lt}),t[191]=lt,t[192]=St):St=t[192];let ct;if(t[193]!==a||t[194]!==o||t[195]!==g||t[196]!==e||t[197]!==r){let be;t[199]!==a||t[200]!==o||t[201]!==e||t[202]!==r?(be=Ne=>{const mt=Ne.info.role,jt=mt==="assistant",At=mt==="user",Ot=o[Ne.info.id]===!0,Wt=a===Ne.info.id,Qt=Ne.info.time?.created??null,Ut=kw(Ne.parts),Ss=jt?qc({info:Ne.info,parts:Ne.parts}):null,bs=At?Cw(Ne.parts):"",ys=Iw(Qt,r),Re=Ut||"—",ue=Ss?Pw(Ss.input,Ss.output,On):"",Fe=mt||"unknown",yt=Ut?`${Fe}: ${Ut}`:Fe,$t=Ot?JSON.stringify({info:Ne.info,parts:Ne.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":Ot,onClick:()=>{c(Et=>({...Et,[Ne.info.id]:Et[Ne.info.id]!==!0}))},children:n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:jt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[At?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",bs]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:jt?Re:yt}),jt&&n.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:ue})]}),n.jsx("span",{className:"text-end text-muted-foreground",children:ys})]})}),Ot&&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:Et=>{Et.stopPropagation(),w(Ne.info.id,$t)},"aria-label":e(Wt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(Wt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:Wt?n.jsx(Q,{name:"check",className:"size-3.5"}):n.jsx(Q,{name:"file-copy",className:"size-3.5"})})}),n.jsx(Yy,{language:"json",code:$t,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Ne.info.id)},t[199]=a,t[200]=o,t[201]=e,t[202]=r,t[203]=be):be=t[203],ct=[...g].reverse().map(be),t[193]=a,t[194]=o,t[195]=g,t[196]=e,t[197]=r,t[198]=ct}else ct=t[198];let oe;t[204]!==ct?(oe=n.jsx("div",{className:"mt-2.5 space-y-1",children:ct}),t[204]=ct,t[205]=oe):oe=t[205];let q;t[206]!==St||t[207]!==oe?(q=n.jsxs("div",{children:[St,oe]}),t[206]=St,t[207]=oe,t[208]=q):q=t[208];let fe;t[209]!==st||t[210]!==Pe||t[211]!==nt||t[212]!==Ae||t[213]!==pt||t[214]!==q?(fe=n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[st,Pe,nt,Ae,pt,q]}),t[209]=st,t[210]=Pe,t[211]=nt,t[212]=Ae,t[213]=pt,t[214]=q,t[215]=fe):fe=t[215];let We;return t[216]!==Ce||t[217]!==fe?(We=n.jsxs(Or,{outerClassName:"h-full",className:"bg-background",children:[Ce,fe]}),t[216]=Ce,t[217]=fe,t[218]=We):We=t[218],We};function Bw(t){return t.timeFormatPreference}function Fw(t){return t.currentSessionId}function Lw(t){return t.currentSessionDirectory}function _w(t){return t.providers}function $w(t){return Object.keys(t).length>0?{}:t}function zw(t){return t.info.role==="assistant"}function Kw(t){return t.info.role==="user"}function Ww(t){return t.info}function Hw(t,e){const s=xn(e.info.cost);return t+s}function Vw(t){return t.info.role==="system"}function Uw(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 Gw(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)}%`:On(t.value):"—"})]},t.label)}const pp=(t,e,s,r=t.currentTarget)=>{t.key!=="Escape"||!e||t.target instanceof Node&&!(r??t.currentTarget).contains(t.target)||Xy(t.target)||Qy(t.target)||sl(t)||t.defaultPrevented||(t.preventDefault(),t.stopPropagation(),s())},qw=280,Yw=.28,Xw=240,Qw=.35,Zw=(t,e,s=null)=>{const r=t.left+t.width,i=e.left+e.width,o=e.top+e.height,c=s?s.top:o-Math.min(Xw,e.height*Qw),a=Math.min(qw,t.width*Yw,e.width/4),d=e.left-t.left>=1,u=r-i>=1,f=Math.max(0,c-t.top),p=d?e.left:t.left+a,m=u?i:r-a;return{left:{left:t.left,top:t.top,width:p-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:c,width:e.width,height:Math.max(0,o-c)}}},Fi=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,Jw=(t,e)=>Fi(t.bottom,e)?"bottom":Fi(t.left,e)?"left":Fi(t.right,e)?"right":null,pn=Vr(()=>({drag:null,hovered:null})),mo=t=>{if(!t)return null;const{left:e,top:s,width:r,height:i}=t.getBoundingClientRect();return r>0&&i>0?{left:e,top:s,width:r,height:i}:null},Li=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),_i=t=>mo(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),hp=t=>{const e=mo(document.querySelector("[data-workspace-row]")),s=mo(document.querySelector("[data-workspace-chat]"));if(!e||!s)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),i=Zw(e,s,mo(r)),o={left:_i("left")??Li(i.left),right:_i("right")??Li(i.right),bottom:_i("bottom")??Li(i.bottom)};return pn.setState({drag:{...t,targets:i,frames:o},hovered:null}),!0},mp=t=>{const{drag:e,hovered:s}=pn.getState();if(!e)return;const r=Jw(e.targets,t);r!==s&&pn.setState({hovered:r})},ka=()=>{pn.getState().drag&&pn.setState({drag:null,hovered:null})},gp=t=>{const{drag:e,hovered:s}=pn.getState();if(pn.setState({drag:null,hovered:null}),!e||!s)return!1;const r=de.getState();s!==e.from&&r.moveContextSurfaceToZone(e.mode,s);const i=t?Ps(t):"";if(i){const o=de.getState();Ha(o.contextPanelByDirectory[i],o.contextSurfaceZones).has(e.mode)||o.openContextSurface(i,e.mode)}return!0},Sl=(t,e)=>{let s=!1;const r=o=>{const c={x:o.clientX,y:o.clientY};e(c)?(s||(s=hp(t)),s&&mp(c)):s&&(ka(),s=!1)};window.addEventListener("pointermove",r);const i=()=>window.removeEventListener("pointermove",r);return{finish:o=>(i(),s?(gp(o),!0):!1),cancel:()=>{i(),s&&ka()}}},Xc={left:null,right:null,bottom:null},Rr=Vr(()=>({body:Xc,headerSlot:Xc})),bp=(t,e,s)=>{const r=Rr.getState()[t];r[e]!==s&&Rr.setState({[t]:{...r,[e]:s}})},e0=(t,e)=>bp("body",t,e),t0=(t,e)=>bp("headerSlot",t,e),Cr=t=>{const e=l.useRef(t);e.current=t;const[s,r]=l.useState(t),i=l.useCallback(()=>r(e.current),[]);return l.useLayoutEffect(()=>{tl(i)},[t,i]),l.useEffect(()=>()=>bf(i),[i]),t||s},s0=Br(()=>os(()=>import("./GitView-C0QgeC9O.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124])).then(t=>({default:t.GitView}))),yp=320,xp=600,Sp=400,n0=100,r0=24,o0=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},Qc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(yp,Math.round(t))):xp,i0=t=>t===null?Number.POSITIVE_INFINITY:Math.max(yp,t-Sp),a0=(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},go=(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==="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"):rr(t)?el.getState().guests.find(r=>r.id===jo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),l0=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},c0=(t,e,s)=>{if(t.mode==="chat"){const r=yl(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||s("contextPanel.mode.chat")}return t.mode==="browser"?Yo(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?l0(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):go(t.mode,s)},d0=t=>{const e=Xe.c(8),{mode:s}=t,r=il();let i;if(e[0]!==s||e[1]!==r){let u;e[3]!==s?(u=f=>f.mode===s,e[3]=s,e[4]=u):u=e[4],i=r.find(u),e[0]=s,e[1]=r,e[2]=i}else i=e[2];const o=i,c=o?.icon??ex,a=o?.iconSrc;let d;return e[5]!==c||e[6]!==a?(d=n.jsx(ur,{icon:c,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=c,e[6]=a,e[7]=d):d=e[7],d},Zc=(t,e={})=>{if(t.mode==="file")return t.targetPath?n.jsx(ol,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(Du,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx(Q,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx(Q,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx(Q,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="notes")return n.jsx(Q,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx(Q,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx(Q,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return n.jsx(Q,{name:"chat-4",className:"h-3.5 w-3.5"});if(rr(t.mode))return n.jsx(d0,{mode:t.mode});if(t.mode==="browser"){const s=u0(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(Q,{name:"global",className:"h-3.5 w-3.5"})}},u0=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},f0=t=>{const e=Fr(),s=l.useRef(Ao),r=l.useRef(t);r.current=t;const i=t.length>0;return l.useSyncExternalStore(l.useCallback(o=>i?e.subscribeAllSelected(c=>c.session,o):()=>{},[e,i]),l.useCallback(()=>{const o=Array.from(e.children.values(),a=>a.getState()),c=yw(o,r.current);return gw(s.current,c)?s.current:(s.current=c,c)},[e]),()=>Ao)},p0=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,h0=8,m0='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',g0=t=>t==="context"||t==="git"||t==="pr"||t==="notes",vp=320,wp=160,kp=200,b0={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"}},Jc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(wp,Math.round(t))):vp,y0=t=>t===null?Number.POSITIVE_INFINITY:Math.max(wp,t-kp),$i=({zone:t="right"})=>{const e=b0[t],s=ei(),r=e.axis==="y",{t:i,direction:o}=Ct(),c=o==="rtl",a=hn()??"",d=yf(a||null),u=l.useCallback((oe,q)=>i(cn(oe,d),q),[d,i]),f=l.useMemo(()=>o0(a),[a]),p=de(oe=>f?oe.contextPanelByDirectory[f]:void 0),m=de(oe=>oe.contextSurfaceZones),g=de(oe=>oe.closeContextZone),y=de(oe=>oe.closeContextPanelTab),v=de(oe=>oe.pinContextPanelTab),x=de(oe=>oe.toggleContextPanelExpanded),b=de(oe=>oe.setContextPanelWidth),h=de(oe=>oe.setContextPanelHeight),S=de(oe=>oe.setActiveContextPanelTab),w=de(oe=>oe.reorderContextPanelTabs),j=de(oe=>oe.contextEditorTreeVisible),k=de(oe=>oe.contextEditorTreeWidth),T=de(oe=>oe.setContextEditorTreeWidth),O=de(oe=>oe.toggleContextEditorTree),$=de(oe=>oe.contextEditorVisible),D=de(oe=>oe.toggleContextEditor),E=de(oe=>oe.fileTreeSide),R=de(oe=>oe.openNewContextBrowserTab),z=fp(oe=>oe.byOrigin),[_,W]=l.useState(null),N=l.useCallback(oe=>{W(oe),t0(t,oe)},[t]),Y=l.useCallback(oe=>{e0(t,oe)},[t]),C=l.useMemo(()=>p?.tabs??[],[p?.tabs]),P=p?ko(p,m,t):null,I=p?qo(p,t):Om,H=ca(oe=>oe.workStatusReserved),A=ca(oe=>oe.chatCovered),F=t==="bottom"&&A,L=!!(I.isOpen&&P)&&!F,X=l.useMemo(()=>C.some(oe=>oe.mode==="file"&&oe.targetPath),[C]),re=X&&($||!j),te=P?.mode??null,M=!r&&te==="file"&&!re,ee=!!(L&&I.expanded&&!M),V=te?r?p?.heightByMode?.[te]:p?.widthByMode?.[te]:void 0,Ee=M?k:r?Jc(V??vp,Number.POSITIVE_INFINITY):Qc(V??(te?da(te):xp),Number.POSITIVE_INFINITY),ve=l.useCallback((oe,q)=>r?Jc(oe,y0(q)):Qc(oe,i0(q)),[r]),ce=r?kp:Sp,Be=t==="right"?"left":t==="left"?"right":null,me=de(oe=>{if(!Be||!f)return 0;const q=oe.contextPanelByDirectory[f],fe=q&&vr(q,oe.contextSurfaceZones,Be)?ko(q,oe.contextSurfaceZones,Be):null;if(!q||!fe)return 0;const We=q.tabs.some(be=>be.mode==="file"&&be.targetPath)&&(oe.contextEditorVisible||!oe.contextEditorTreeVisible);return fe.mode==="file"&&!We?oe.contextEditorTreeWidth:q.widthByMode[fe.mode]??da(fe.mode)}),he=Be==="right"&&H&&!A&&me===0?Ti:me,[G,le]=l.useState(null),ye=l.useRef(null),Ie=l.useRef(he);Ie.current=he;const K=l.useRef(()=>!1);K.current=oe=>ee||!M&&oe-Ie.current-ce<Ee;const se=l.useCallback(()=>{const oe=ye.current;le(oe!==null&&K.current(oe)?oe:null)},[]),U=G!==null?G-he:null,ie=t==="left"?G:U,we=M?Ee:ve(Ee,U),pe=L&&P?.mode==="chat",Se=l.useMemo(()=>{const oe=[];if(!pe)return oe;for(const q of C){if(q.mode!=="chat")continue;const fe=yl(q.dedupeKey);fe&&!oe.includes(fe)&&oe.push(fe)}return oe},[pe,C]),Ce=f0(Se),[Oe,B]=l.useState(!1),ae=l.useRef(0),xe=l.useRef(we),Te=l.useRef(null),Ge=l.useRef(null),st=l.useRef(null),rt=l.useRef(!1);l.useLayoutEffect(()=>{const oe=r?st.current?.parentElement:st.current?.closest("[data-workspace-row]");if(!oe||typeof ResizeObserver>"u")return;const q=new ResizeObserver(fe=>{const We=fe[fe.length-1]?.contentRect,be=r?We?.height:We?.width;ye.current=be?Math.round(be):null,tl(se)});return q.observe(oe),ye.current=(r?oe.clientHeight:oe.clientWidth)||null,se(),()=>{q.disconnect(),bf(se)}},[se,r]),l.useLayoutEffect(()=>{se()},[se,Ee,ee,he]),l.useEffect(()=>{if(!L||rt.current){rt.current=L;return}const oe=window.requestAnimationFrame(()=>{st.current?.focus({preventScroll:!0})});return rt.current=!0,()=>window.cancelAnimationFrame(oe)},[L]);const Ke=l.useRef(null),ke=l.useRef(null),ge=l.useCallback(()=>{ke.current=null;const oe=st.current,q=Te.current;!oe||q===null||oe.style.setProperty(e.sizeVariable,`${q}px`)},[e.sizeVariable]);l.useEffect(()=>()=>{ke.current!==null&&clearTimeout(ke.current)},[]);const Ve=l.useCallback(oe=>{const q=Ke.current,fe=M?ta(oe):ve(oe,q);return q===null?fe:Math.min(fe,Math.max(1,q))},[ve,M]),Ue=l.useCallback(oe=>{if(!L||ee||!f)return;Ge.current=oe.pointerId,B(!0),ae.current=r?oe.clientY:oe.clientX,xe.current=we,Te.current=we;const q=r?st.current?.parentElement?.clientHeight:(st.current?.closest("[data-workspace-row]")?.clientWidth??0)-Ie.current;Ke.current=q&&q>0?q:null,document.documentElement.style.cursor=r?"row-resize":"col-resize",oe.preventDefault()},[f,ee,L,r,we]),ft=l.useCallback(()=>{const oe=Ve(Te.current??we);Te.current=null,Ke.current=null,ke.current!==null&&(clearTimeout(ke.current),ke.current=null),document.documentElement.style.cursor="",M?T(oe):f&&te&&(r?h(f,te,oe):b(f,te,oe)),B(!1),Ge.current=null},[te,Ve,f,M,r,T,h,b,we]);l.useEffect(()=>{if(!Oe)return;const oe=We=>{if(Ge.current!==We.pointerId)return;const be=r?We.clientY:We.clientX,Ne=t==="left"?be-ae.current:ae.current-be,mt=!r&&c?-Ne:Ne,jt=Ve(xe.current+mt);Te.current!==jt&&(Te.current=jt,ke.current===null&&(ke.current=setTimeout(ge,n0)))},q=We=>{Ge.current===We.pointerId&&ft()},fe=()=>{ft()};return window.addEventListener("pointermove",oe),window.addEventListener("pointerup",q),window.addEventListener("pointercancel",q),window.addEventListener("blur",fe),()=>{window.removeEventListener("pointermove",oe),window.removeEventListener("pointerup",q),window.removeEventListener("pointercancel",q),window.removeEventListener("blur",fe)}},[ge,Ve,ft,Oe,c,r,t]),l.useEffect(()=>{Oe||(Te.current=null,document.documentElement.style.cursor="")},[Oe]);const Qe=l.useCallback(()=>{f&&g(f,t)},[g,f,t]),wt=l.useCallback(()=>{f&&x(f,t)},[f,x,t]),Me=l.useCallback(oe=>{pp(oe,L,Qe)},[Qe,L]),Pe=P?.mode==="file"||P?.mode==="chat"||P?.mode==="browser",ot=l.useMemo(()=>P?C.filter(oe=>oe.mode===P.mode):[],[P,C]),et=l.useMemo(()=>ot.map(oe=>{const q=c0(oe,Ce,u),fe=p0(q,r0),We=a0(oe.targetPath,a);return{id:oe.id,label:fe,icon:Zc(oe,z),title:We?`${q}: ${We}`:q,closeLabel:i("contextPanel.tab.closeTabAria",{label:fe}),preview:oe.preview}}),[ot,a,z,Ce,i,u]),Ze=P?.mode==="context"?n.jsx(Zn,{value:_,children:n.jsx(Ow,{})}):P?.mode==="git"?n.jsx(l.Suspense,{fallback:null,children:n.jsx(Zn,{value:_,children:n.jsx(s0,{isActive:L})})}):P?.mode==="pr"?n.jsx(iw,{}):P?.mode==="notes"?n.jsx(Zn,{value:_,children:n.jsx(Qg,{visible:L})}):null,dt=P?.mode==="file",J=de(oe=>oe.closeContextPanelTabs),_e=l.useCallback(oe=>{if(!f)return null;const{id:q,index:fe,allIds:We,close:be}=oe,Ne=()=>J(f,We.filter(bs=>bs!==q)),mt=We.slice(0,fe),jt=We.slice(fe+1),At=()=>J(f,c?jt:mt),Ot=()=>J(f,c?mt:jt),Wt=()=>J(f,We),Qt=We.length>1,Ut=c?fe===We.length-1:fe===0,Ss=c?fe===0:fe===We.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs(Ln,{onClick:be,children:[n.jsx(Q,{name:"close",className:"me-2 size-4"}),i("contextPanel.tab.menu.close")]}),n.jsx(uo,{}),n.jsxs(Ln,{onClick:Ne,disabled:!Qt,children:[n.jsx(Q,{name:"expand-horizontal",className:"me-2 size-4"}),i("contextPanel.tab.menu.closeOthers")]}),n.jsxs(Ln,{onClick:At,disabled:Ut,children:[n.jsx(Q,{name:"expand-left",className:"me-2 size-4"}),i("contextPanel.tab.menu.closeToLeft")]}),n.jsxs(Ln,{onClick:Ot,disabled:Ss,children:[n.jsx(Q,{name:"expand-right",className:"me-2 size-4"}),i("contextPanel.tab.menu.closeToRight")]}),n.jsx(uo,{}),n.jsxs(Ln,{onClick:Wt,disabled:!Qt,children:[n.jsx(Q,{name:"close-circle",className:"me-2 size-4"}),i("contextPanel.tab.menu.closeAll")]}),P?n.jsxs(n.Fragment,{children:[n.jsx(uo,{}),n.jsx(Tu,{mode:P.mode})]}):null]})},[P,J,f,c,i]),Le=l.useCallback((oe,q)=>{const fe=C.find(be=>be.id===oe);if(!fe)return null;const We=Sl({mode:fe.mode,label:go(fe.mode,u),from:t},q);return{finish:()=>We.finish(f),cancel:We.cancel}},[f,u,C,t]),[He,$e]=l.useState(null),tt=l.useCallback(oe=>{if(!P||oe.button!==0||oe.pointerType==="touch"||oe.target instanceof Element&&oe.target.closest(m0))return;const q=P.mode,fe=go(q,u),We={x:oe.clientX,y:oe.clientY};let be=!1;const Ne=Ot=>{const Wt={x:Ot.clientX,y:Ot.clientY};!be&&(Math.hypot(Wt.x-We.x,Wt.y-We.y)<h0||(be=hp({mode:q,label:fe,from:t}),!be))||mp(Wt)},mt=()=>{window.removeEventListener("pointermove",Ne),window.removeEventListener("pointerup",jt),window.removeEventListener("pointercancel",At),window.removeEventListener("blur",At)},jt=()=>{mt(),be&&gp(f)},At=()=>{mt(),be&&ka()};window.addEventListener("pointermove",Ne),window.addEventListener("pointerup",jt),window.addEventListener("pointercancel",At),window.addEventListener("blur",At)},[P,f,u,t]);l.useEffect(()=>{if(He)return He.addEventListener("pointerdown",tt),()=>He.removeEventListener("pointerdown",tt)},[tt,He]);const bt=n.jsxs("header",{ref:$e,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[Pe?n.jsx(Zy,{items:et,activeId:P?.id??null,onSelect:oe=>{f&&S(f,oe)},onClose:oe=>{f&&y(f,oe)},onReorder:(oe,q)=>{f&&w(f,oe,q)},onDoubleClickTab:oe=>{f&&v(f,oe)},layoutMode:"scrollable",variant:"default",tabContextMenu:_e,onTabDragOut:Le}):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:[P?.mode==="pr"&&d==="gitlab"?n.jsx(Q,{name:"gitlab",className:"h-3.5 w-3.5"}):P?Zc(P,z):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:P?.mode==="pr"&&d==="gitlab"?i("contextPanel.mode.mr"):P?go(P.mode,u):null})]}),n.jsx("div",{ref:N,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:[P?.mode==="browser"?n.jsx(It,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&R(f)},className:"h-7 w-7 p-0",title:i("contextPanel.browser.newTab"),"aria-label":i("contextPanel.browser.newTab"),children:n.jsx(Q,{name:"add",className:"h-3.5 w-3.5"})}):null,dt?["left","right"].map(oe=>{const q=oe===E;if(!q&&!X)return null;const fe=i(q?"contextRail.editorTree.toggle":"contextRail.editor.toggle");return n.jsx(It,{type:"button",variant:"ghost",size:"sm",onClick:q?O:D,className:"h-7 w-7 p-0",title:fe,"aria-label":fe,"aria-pressed":q?j:re,children:n.jsx(Q,{name:oe==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})},oe)}):null,M?null:n.jsx(It,{type:"button",variant:"ghost",size:"sm",onClick:wt,className:"h-7 w-7 p-0",title:i(ee?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":i(ee?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:ee?n.jsx(Q,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx(Q,{name:"fullscreen",className:"h-3.5 w-3.5"})}),n.jsx(It,{type:"button",variant:"ghost",size:"sm",onClick:Qe,className:"h-7 w-7 p-0",title:i("contextPanel.actions.closePanel"),"aria-label":i("contextPanel.actions.closePanel"),children:n.jsx(Q,{name:"close",className:"h-3.5 w-3.5"})})]})]}),ht=t==="right"&&H&&!A,it=ie!==null?`${ie}px`:"100%",Mt=L?ee?it:`min(var(${e.sizeVariable}), 100%)`:ht?`${Ti}px`:"0px",nt=t==="bottom"&&vr(p,m,"left"),Lt=t==="bottom"&&(H&&!A||vr(p,m,"right")),_t=`${L}|${ee}|${ht}|${L?Ee:""}`,Tt=l.useRef(_t),Ae=l.useRef(A),at=Ae.current!==A;l.useLayoutEffect(()=>{Ae.current=A},[A]),l.useLayoutEffect(()=>{Tt.current!==_t&&(Tt.current=_t,at||nf(s))},[_t,at,s]);const ut=!Cr(L),pt=Cr(ee),lt=L?`${we}px`:ht?`${Ti}px`:"0px",St={[e.sizeVariable]:L&&ee?it:`${we}px`,...r?{height:Mt,maxHeight:"100%"}:{width:Mt,maxWidth:"100%"},transitionDuration:at?"0ms":`${s}ms`,transitionTimingFunction:Io},ct=ee?ie!==null?`calc(${ie}px - ${e.gutterSize})`:"100%":`calc(var(${e.sizeVariable}) - ${e.gutterSize})`;return n.jsxs(n.Fragment,{children:[pt?n.jsx("div",{"aria-hidden":"true",className:"flex-shrink-0",style:r?{height:lt,maxHeight:"100%"}:{width:lt,maxWidth:"100%"}}):null,n.jsxs("aside",{ref:st,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":L?"true":"false",tabIndex:-1,className:De("flex min-h-0 flex-col overflow-clip bg-background","isolate",pt?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:Me,style:St,children:[t==="right"?n.jsx("div",{ref:Jy,className:De("absolute inset-y-0 inset-e-0 z-0 flex",A&&"invisible")}):null,L&&!ee&&n.jsx("div",{className:e.handle,onPointerDown:Ue,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":i("contextPanel.actions.resizePanelAria")}),n.jsxs("div",{"data-zone-card":"",className:De("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(nt?"ms-0":"ms-2"),t==="bottom"&&(Lt?"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]",!L&&"pointer-events-none select-none opacity-0"),style:{...r?{height:ct,width:`calc(100% - ${(nt?0:.5)+(Lt?0:.375)}rem)`}:{width:ct},transitionDuration:`${s}ms`,transitionTimingFunction:Io},inert:ut||void 0,children:[bt,n.jsx("div",{ref:Y,className:De("relative min-h-0 flex-1 overflow-hidden",Oe&&"pointer-events-none"),children:P&&g0(P.mode)?Ze:null})]})]})]})},x0=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"},S0=async(t,e)=>{try{const s=await Gs("/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 i=r.servers;return Array.isArray(i)?{kind:"ready",servers:i.filter(x0)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},v0=async t=>{try{const e=await Gs("/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}},w0=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}},k0=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const i=w0(r);i!==null&&!s.has(i)&&s.set(i,r)}return e?e.map(r=>{const i=s.get(r.port);return{url:i??r.url,port:r.port,announced:i!==void 0}}).sort((r,i)=>r.announced!==i.announced?r.announced?-1:1:r.port-i.port):[...s.entries()].map(([r,i])=>({url:i,port:r,announced:!0})).sort((r,i)=>r.port-i.port)},ja="__openchamberBrowserAnnotationActive",j0=`(() => {
|
|
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['${ja}']; } catch (error) { /* non-configurable */ }
|
|
12
|
+
})();`,C0=(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['${ja}'] = 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['${ja}']; } 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
|
+
});`},P0={kind:"idle"},tn=t=>typeof t=="object"&&t!==null,dn=t=>typeof t=="number"&&Number.isFinite(t),ed=t=>tn(t)&&Object.values(t).every(e=>typeof e=="string"),vl=t=>tn(t)&&dn(t.x)&&dn(t.y)&&dn(t.width)&&dn(t.height),jp=t=>tn(t)&&dn(t.x)&&dn(t.y),E0=t=>tn(t)&&typeof t.tag=="string"&&typeof t.selectorPart=="string"&&(t.id===void 0||typeof t.id=="string")&&(t.className===void 0||typeof t.className=="string"),I0=t=>tn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&vl(t.bounds)&&jp(t.center)&&ed(t.attributes)&&ed(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(E0),T0=t=>tn(t)&&typeof t.id=="string"&&I0(t.element),D0=t=>tn(t)&&typeof t.id=="string"&&vl(t.rect),R0=t=>tn(t)&&typeof t.id=="string"&&vl(t.bounds)&&Array.isArray(t.points)&&t.points.every(jp),N0=t=>tn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&tn(t.viewport)&&dn(t.viewport.width)&&dn(t.viewport.height)&&dn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(T0)&&Array.isArray(t.regions)&&t.regions.every(D0)&&Array.isArray(t.strokes)&&t.strokes.every(R0),M0=1600,A0=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}),O0=async({base64:t,mime:e,captureWidth:s,captureHeight:r,cssWidth:i,cssHeight:o,payload:c,accentColor:a,accentFill:d})=>{if(!t)return null;try{const u=await A0(`data:${e};base64,${t}`),f=Math.max(1,u.naturalWidth||s),p=Math.max(1,u.naturalHeight||r),m=f/Math.max(1,i||f),g=p/Math.max(1,o||p),y=Math.min(1,M0/f),v=document.createElement("canvas");v.width=Math.max(1,Math.floor(f*y)),v.height=Math.max(1,Math.floor(p*y));const x=v.getContext("2d");if(!x)return null;x.scale(y,y),x.drawImage(u,0,0,f,p);const b=j=>({x:j.x*m,y:j.y*g,width:j.width*m,height:j.height*g}),h=Math.max(2,2.5*m/Math.max(y,.2));x.strokeStyle=a,x.fillStyle=d;const S=j=>{const k=b(j);x.lineWidth=h,x.fillRect(k.x,k.y,k.width,k.height),x.strokeRect(k.x,k.y,k.width,k.height)};for(const j of c.elements)S(j.element.bounds);for(const j of c.regions)S(j.rect);for(const j of c.strokes)j.points.length<2||(x.beginPath(),j.points.forEach((k,T)=>{const O=k.x*m,$=k.y*g;T===0?x.moveTo(O,$):x.lineTo(O,$)}),x.lineCap="round",x.lineJoin="round",x.lineWidth=h*1.4,x.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}},B0="({ width: window.innerWidth, height: window.innerHeight })",F0=async t=>{try{const e=await t.executeJavaScript(B0,!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}},bo=async t=>{try{await t.executeJavaScript(j0,!1)}catch{}},L0=async({host:t,theme:e,labels:s})=>{const r=C0(e,s),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!N0(i))return await bo(t),null;const o=i;try{const c=await F0(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const d=await O0({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:c.width,cssHeight:c.height,payload:o,accentColor:e.primary,accentFill:e.primarySoft});return{payload:o,screenshot:d}}catch{return{payload:o,screenshot:null}}},Fs={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)"},_0=()=>{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()}},$0=t=>{const e=_0();if(!e)return{...Fs,colorScheme:t};try{const s=(a,d)=>e.read(`var(${a})`)||d,r=(a,d,u)=>e.read(`color-mix(in srgb, var(${a}) ${d}%, transparent)`)||u,i=e.readVariable("--oc-glass-tooltip-opacity")||"62%",o=e.readVariable("--oc-glass-blur")||"26px",c=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${i}, transparent)`)||Fs.glassSurface,glassFilter:`blur(${o}) saturate(${c})`,primary:s("--primary",Fs.primary),primarySoft:r("--primary",16,Fs.primarySoft),primaryFaint:r("--primary",10,Fs.primaryFaint),primaryContrast:s("--primary-foreground",Fs.primaryContrast),surface:s("--surface-background",Fs.surface),surfaceElevated:s("--surface-elevated",Fs.surfaceElevated),border:s("--border",Fs.border),text:s("--foreground",Fs.text),mutedText:s("--muted-foreground",Fs.mutedText)}}catch{return{...Fs,colorScheme:t}}finally{e.dispose()}},z0=t=>({sessionId:t.sessionId,directory:t.directory?Ps(t.directory):null}),K0=2e3,W0=50,zi=400,Ms=new Map,fn=new Map;let Ca=null,Pa=null;const wl=new Map;let ln=null,Pr=null;const yo=async t=>{try{const e=await Gs("/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}},H0=async(t,e)=>{try{const s=await Gs("/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)}},Cp=async(t,e=K0)=>{const s=Date.now()+e;for(;!Ms.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,W0));return Ms.get(t)??null},td=t=>Ms.has(t)||fn.has(t),Oo=t=>Ms.get(t)??fn.get(t)??null,Ea=()=>[...Ms.values(),...[...fn.values()].filter(t=>!Ms.has(t.tabId))],Pp=t=>{const e=Pa?Oo(Pa):null,s=e?.directory===Ca?e:null;if(!t.sessionId){if(s)return s.tabId;const o=Ea().filter(d=>d.directory===Ca),c=o.filter(d=>Ms.has(d.tabId)),a=c.length>0?c:o;return a.length>0?a[a.length-1].tabId:null}if(s?.ownerSessionId===t.sessionId)return s.tabId;const r=wl.get(t.sessionId);if(r&&Oo(r)?.ownerSessionId===t.sessionId)return r;const i=Ea().filter(o=>o.ownerSessionId===t.sessionId);return i.length>0?i[i.length-1].tabId:s&&s.ownerSessionId===null&&(!t.directory||s.directory===t.directory)?s.tabId:null},V0=(t,e)=>{t.sessionId&&Oo(e)?.ownerSessionId===t.sessionId&&wl.set(t.sessionId,e)},Ep=async t=>{const e=Ms.get(t);if(e)return e;const s=fn.get(t);return s?(s.wake(),Cp(t)):null},Ip=t=>{const e=Pp(t);return Ea().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 i=s.ownerSessionId===null?"user":s.ownerSessionId===t.sessionId?"you":"another session";return{id:s.tabId,title:r.title,url:r.url,owner:i,active:s.tabId===e}})},Tp=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,U0=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.`,G0=t=>{const e=Ip(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
|
+
`)}`:"")},Xs=(t,e)=>H0(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:tx()})}:e),q0=async t=>{const e=t.action==="browser.open",s=z0(t.context),{tabId:r,...i}=t.parameters,o=r===void 0?null:String(r);if(o!==null){if(!td(o)){if(Ms.size===0&&fn.size===0&&!ln)return;if(await new Promise(d=>setTimeout(d,zi)),td(o)){await sd(t,s,o,i);return}if(!await yo(t.requestId))return;await Xs(t,{ok:!1,error:U0(o)});return}await sd(t,s,o,i);return}const c=Pp(s);if(!c&&!(e&&ln)){if(!s.sessionId||(await new Promise(d=>setTimeout(d,zi)),!await yo(t.requestId)))return;await Xs(t,{ok:!1,error:G0(s)});return}if(!(e&&ln!==null)&&s.sessionId&&Oo(c)?.ownerSessionId!==s.sessionId&&await new Promise(d=>setTimeout(d,zi)),!!await yo(t.requestId))try{const d=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!d){await Xs(t,{ok:!1,error:"url is required"});return}const u=e&&ln?ln(d,t.context):null;if(e&&!u&&!c){await Xs(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(u){s.sessionId&&wl.set(s.sessionId,u);const p=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!p||p==="fill"){await Xs(t,{ok:!0,data:{url:d,opened:!0,tabId:u}});return}const m=await Cp(u);if(!m){await Xs(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:p}),y=g&&typeof g=="object"?g.viewport??null:null;await Xs(t,{ok:!0,data:{url:d,opened:!0,tabId:u,viewportApplied:!0,viewport:y}});return}const f=await Ep(c);await Xs(t,f?await Dp(f,s,t.action,i):{ok:!1,error:Tp(c)})}catch(d){await Xs(t,{ok:!1,error:d instanceof Error?d.message:String(d)})}},sd=async(t,e,s,r)=>{if(!await yo(t.requestId))return;V0(e,s);const i=await Ep(s);await Xs(t,i?await Dp(i,e,t.action,r):{ok:!1,error:Tp(s)})},Dp=async(t,e,s,r)=>{try{const i=await t.run(s,r);return s==="browser.snapshot"&&Object(i)===i?{ok:!0,data:{...Object(i),tabs:Ip(e)}}:{ok:!0,data:i}}catch(i){return{ok:!1,error:i instanceof Error?i.message:String(i)}}},kl=()=>{Pr||(Pr=Pn(t=>{t.type==="browser-control-request"&&q0({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},jl=()=>{Ms.size>0||fn.size>0||ln||!Pr||(Pr(),Pr=null)},Y0=t=>(Ms.set(t.tabId,t),kl(),()=>{Ms.get(t.tabId)===t&&Ms.delete(t.tabId),jl()}),X0=t=>(fn.set(t.tabId,t),kl(),()=>{fn.get(t.tabId)===t&&fn.delete(t.tabId),jl()}),Q0=(t,e)=>{Ca=t,e&&(Pa=e)},Z0=t=>(ln=t,kl(),()=>{ln===t&&(ln=null),jl()}),J0=50,ek=6,tk=2048,sk=200,Rp=t=>{const e=Qn(String(t??"").trim());if(!e||e.length>tk)return"";try{const s=new URL(e);return s.protocol!=="http:"&&s.protocol!=="https:"?"":s.toString()}catch{return""}},nk=(t,e)=>{const s=Rp(e.url);if(!s)return t;const r=t.find(c=>c.url===s),i=String(e.title??"").trim().slice(0,sk)||r?.title||"";return[{url:s,title:i,lastVisitedAt:e.at},...t.filter(c=>c.url!==s)].slice(0,J0)},rk=(t,e)=>{const s=Rp(e);return t.filter(r=>r.url!==s)},ok=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Np=(t,e,s=ek)=>{const r=String(e??"").trim().toLowerCase(),i=[...t].sort((c,a)=>a.lastVisitedAt-c.lastVisitedAt);if(!r)return i.slice(0,s);const o=r.replace(/^https?:\/\//,"");return i.filter(c=>{const a=ok(c);return c.url===r||a===o?!1:a.includes(o)}).slice(0,s)},nd=20,xo=t=>{const e=vt((t||"").trim());return e?JSON.stringify([Xt(),e]):""},ik=t=>{const e=Object.keys(t);if(e.length<=nd)return t;const s=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,nd);return Object.fromEntries(s.map(([r])=>[r,t[r]??[]]))},er=Vr()(S1(t=>({byProject:{},recordVisit:(e,s)=>{const r=xo(e);r&&t(i=>{const o=i.byProject[r]??[],c=nk(o,{...s,at:Date.now()});return c===o?i:{byProject:ik({...i.byProject,[r]:c})}})},forget:(e,s)=>{const r=xo(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:rk(o,s)}}:i})},clear:e=>{const s=xo(e);s&&t(r=>{if(!(s in r.byProject))return r;const i={...r.byProject};return delete i[s],{byProject:i}})}}),{name:"openchamber-browser-history",version:1,storage:Bm(),partialize:t=>({byProject:t.byProject})})),ak=[],Mp=t=>e=>{const s=xo(t);return(s?e.byProject[s]:void 0)??ak},Cl=t=>{const e=Xe.c(10),{t:s}=Ct();let r;e[0]!==t?(r=Us(t),e[0]=t,e[1]=r):r=e[1];const i=r;let o;e[2]!==i?(o=u=>i?u.journey?.get(i):void 0,e[2]=i,e[3]=o):o=e[3];const c=$s(o);if(i===null)return null;if(!c){let u;return e[4]!==s?(u=s("contextPanel.browser.spaceAddress"),e[4]=s,e[5]=u):u=e[5],u}let a;e[6]!==c.machine||e[7]!==c.placeId||e[8]!==s?(a=c.machine??(c.placeId==="docker"?s("spaces.create.place.localDocker"):c.placeId),e[6]=c.machine,e[7]=c.placeId,e[8]=s,e[9]=a):a=e[9];const d=a;return`${c.name} · ${d}`},rd=6e3,lk=120,ck=80,dk=100,uk=`
|
|
683
|
+
var MAX_ELEMENTS = ${lk};
|
|
684
|
+
var MAX_LABEL_CHARS = ${ck};
|
|
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
|
+
`,Ur=t=>`(() => {
|
|
798
|
+
${uk}
|
|
799
|
+
${t}
|
|
800
|
+
})()`,fk=({selector:t}={})=>Ur(`
|
|
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, ${rd}),
|
|
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 > ${rd}) {
|
|
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
|
+
`),pk=({selector:t,text:e})=>Ur(`
|
|
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
|
+
`),hk=({selector:t,value:e,submit:s})=>Ur(`
|
|
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
|
+
`),mk=({selector:t,direction:e})=>Ur(`
|
|
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, ${dk});
|
|
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
|
+
`),gk=["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"],bk=({selector:t})=>Ur(`
|
|
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(gk)};
|
|
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
|
+
`),yk=t=>{const e=Xe.c(18),{entries:s,activeIndex:r,onSelect:i,onForget:o,onHighlight:c}=t,{t:a}=Ct();if(s.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==s||e[4]!==o||e[5]!==c||e[6]!==i||e[7]!==a){let p;e[9]!==r||e[10]!==o||e[11]!==c||e[12]!==i||e[13]!==a?(p=(m,g)=>n.jsxs("div",{role:"option","aria-selected":g===r,className:De("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",g===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:y=>{y.preventDefault(),i(m.url)},onPointerEnter:()=>c(g),children:[n.jsx(Q,{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||Yo(m.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.url})]}),n.jsx("button",{type:"button",className:De("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:y=>{y.preventDefault(),y.stopPropagation(),o(m.url)},children:n.jsx(Q,{name:"close",className:"size-3","aria-hidden":"true"})})]},m.url),e[9]=r,e[10]=o,e[11]=c,e[12]=i,e[13]=a,e[14]=p):p=e[14],u=s.map(p),e[2]=r,e[3]=s,e[4]=o,e[5]=c,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let f;return e[15]!==d||e[16]!==u?(f=n.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=f):f=e[17],f},Ls=t=>{const e=Xe.c(17),{icon:s,label:r,onClick:i,disabled:o,pressed:c}=t,a=c?"secondary":"ghost",d=c&&"text-foreground";let u;e[0]!==d?(u=De("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let f;e[2]!==s?(f=n.jsx(Q,{name:s,className:"size-3.5","aria-hidden":"true"}),e[2]=s,e[3]=f):f=e[3];let p;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==c||e[8]!==a||e[9]!==u||e[10]!==f?(p=n.jsx(zt,{asChild:!0,children:n.jsx(It,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":c,children:f})}),e[4]=o,e[5]=r,e[6]=i,e[7]=c,e[8]=a,e[9]=u,e[10]=f,e[11]=p):p=e[11];let m;e[12]!==r?(m=n.jsx(Ft,{sideOffset:6,children:r}),e[12]=r,e[13]=m):m=e[13];let g;return e[14]!==p||e[15]!==m?(g=n.jsxs(Kt,{children:[p,m]}),e[14]=p,e[15]=m,e[16]=g):g=e[16],g},Ap=t=>{const e=Xe.c(110),{address:s,addressMark:r,suggestions:i,onForgetSuggestion:o,onAddressChange:c,onSubmit:a,onBack:d,onForward:u,onReload:f,onOpenExternal:p,canOpenExternal:m,canGoBack:g,canGoForward:y,isLoading:v,onAnnotate:x,onOpenDevTools:b,isAnnotating:h,onHardReload:S,onZoomIn:w,onZoomOut:j,onZoomReset:k,zoomPercent:T,onClearCookies:O,onClearCache:$,onToggleDeviceBar:D,isDeviceBarOpen:E}=t;let R;e[0]!==i?(R=i===void 0?[]:i,e[0]=i,e[1]=R):R=e[1];const z=R,_=m===void 0?!0:m,W=T===void 0?100:T,{t:N}=Ct(),[Y,C]=l.useState(!1),[P,I]=l.useState(-1);let H;e[2]!==Y||e[3]!==z?(H=Y?z:[],e[2]=Y,e[3]=z,e[4]=H):H=e[4];const A=H;let F;e[5]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{I(-1)},e[5]=F):F=e[5];let L;e[6]!==s||e[7]!==Y?(L=[s,Y],e[6]=s,e[7]=Y,e[8]=L):L=e[8],l.useEffect(F,L);let X;e[9]!==a?(X=Ue=>{C(!1),I(-1),a(Ue)},e[9]=a,e[10]=X):X=e[10];const re=X;let te;e[11]!==P||e[12]!==re||e[13]!==A?(te=Ue=>{if(A.length!==0){if(Ue.key==="ArrowDown"||Ue.key==="ArrowUp"){Ue.preventDefault();const ft=Ue.key==="ArrowDown"?1:-1,Qe=A.length;I(wt=>{const Me=wt+ft;return Me<-1?Qe-1:Me>=Qe?-1:Me});return}if(Ue.key==="Escape"&&P>=0){Ue.preventDefault(),I(-1);return}if(Ue.key==="Enter"&&P>=0){Ue.preventDefault();const ft=A[P];ft&&re(ft.url)}}},e[11]=P,e[12]=re,e[13]=A,e[14]=te):te=e[14];const M=te;let ee;e[15]!==N?(ee=N("contextPanel.browser.back"),e[15]=N,e[16]=ee):ee=e[16];const V=!g;let Ee;e[17]!==d||e[18]!==ee||e[19]!==V?(Ee=n.jsx(Ls,{icon:"arrow-left",label:ee,onClick:d,disabled:V}),e[17]=d,e[18]=ee,e[19]=V,e[20]=Ee):Ee=e[20];let ve;e[21]!==N?(ve=N("contextPanel.browser.forward"),e[21]=N,e[22]=ve):ve=e[22];const ce=!y;let Be;e[23]!==u||e[24]!==ve||e[25]!==ce?(Be=n.jsx(Ls,{icon:"arrow-right",label:ve,onClick:u,disabled:ce}),e[23]=u,e[24]=ve,e[25]=ce,e[26]=Be):Be=e[26];let me;e[27]!==v||e[28]!==N?(me=N(v?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=v,e[28]=N,e[29]=me):me=e[29];let he;e[30]!==f||e[31]!==me?(he=n.jsx(Ls,{icon:"refresh",label:me,onClick:f}),e[30]=f,e[31]=me,e[32]=he):he=e[32];let G;e[33]!==S||e[34]!==N?(G=S?n.jsx(Ls,{icon:"restart",label:N("contextPanel.browser.hardReload"),onClick:S}):null,e[33]=S,e[34]=N,e[35]=G):G=e[35];let le;e[36]!==s||e[37]!==re?(le=Ue=>{Ue.preventDefault(),re(s)},e[36]=s,e[37]=re,e[38]=le):le=e[38];let ye;e[39]!==r?(ye=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(Q,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=ye):ye=e[40];let Ie;e[41]!==c?(Ie=Ue=>c(Ue.target.value),e[41]=c,e[42]=Ie):Ie=e[42];let K,se;e[43]===Symbol.for("react.memo_cache_sentinel")?(K=()=>C(!0),se=()=>C(!1),e[43]=K,e[44]=se):(K=e[43],se=e[44]);const U=A.length>0,ie=r&&"ps-8";let we;e[45]!==ie?(we=De("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3",ie,"typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[45]=ie,e[46]=we):we=e[46];let pe;e[47]!==N?(pe=N("contextPanel.browser.addressAria"),e[47]=N,e[48]=pe):pe=e[48];let Se;e[49]!==s||e[50]!==M||e[51]!==Ie||e[52]!==U||e[53]!==we||e[54]!==pe?(Se=n.jsx("input",{value:s,onChange:Ie,onFocus:K,onBlur:se,onKeyDown:M,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":U,"aria-controls":"openchamber-browser-address-suggestions",className:we,"aria-label":pe}),e[49]=s,e[50]=M,e[51]=Ie,e[52]=U,e[53]=we,e[54]=pe,e[55]=Se):Se=e[55];let Ce;e[56]!==o?(Ce=Ue=>o?.(Ue),e[56]=o,e[57]=Ce):Ce=e[57];let Oe;e[58]!==P||e[59]!==re||e[60]!==Ce||e[61]!==A?(Oe=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(yk,{entries:A,activeIndex:P,onSelect:re,onForget:Ce,onHighlight:I})}),e[58]=P,e[59]=re,e[60]=Ce,e[61]=A,e[62]=Oe):Oe=e[62];let B;e[63]!==le||e[64]!==ye||e[65]!==Se||e[66]!==Oe?(B=n.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:le,children:[ye,Se,Oe]}),e[63]=le,e[64]=ye,e[65]=Se,e[66]=Oe,e[67]=B):B=e[67];let ae;e[68]!==w||e[69]!==j||e[70]!==k||e[71]!==N||e[72]!==W?(ae=j&&w?n.jsxs("div",{className:"flex shrink-0 items-center",children:[n.jsx(Ls,{icon:"subtract",label:N("contextPanel.browser.zoomOut"),onClick:j}),W!==100&&k?n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsxs(It,{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":N("contextPanel.browser.zoomReset"),children:[W,"%"]})}),n.jsx(Ft,{sideOffset:6,children:N("contextPanel.browser.zoomReset")})]}):null,n.jsx(Ls,{icon:"add",label:N("contextPanel.browser.zoomIn"),onClick:w})]}):null,e[68]=w,e[69]=j,e[70]=k,e[71]=N,e[72]=W,e[73]=ae):ae=e[73];let xe;e[74]!==O||e[75]!==N?(xe=O?n.jsx(Ls,{icon:"delete-bin",label:N("contextPanel.browser.clearCookies"),onClick:O}):null,e[74]=O,e[75]=N,e[76]=xe):xe=e[76];let Te;e[77]!==$||e[78]!==N?(Te=$?n.jsx(Ls,{icon:"database-2",label:N("contextPanel.browser.clearCache"),onClick:$}):null,e[77]=$,e[78]=N,e[79]=Te):Te=e[79];let Ge;e[80]!==E||e[81]!==D||e[82]!==N?(Ge=D?n.jsx(Ls,{icon:"smartphone",label:N("contextPanel.browser.deviceToolbar"),onClick:D,pressed:E}):null,e[80]=E,e[81]=D,e[82]=N,e[83]=Ge):Ge=e[83];let st;e[84]!==h||e[85]!==x||e[86]!==N?(st=x?n.jsx(Ls,{icon:"markup",label:N("contextPanel.browser.annotate.toggle"),onClick:x,pressed:h}):null,e[84]=h,e[85]=x,e[86]=N,e[87]=st):st=e[87];let rt;e[88]!==b||e[89]!==N?(rt=b?n.jsx(Ls,{icon:"terminal-box",label:N("contextPanel.browser.devTools"),onClick:b}):null,e[88]=b,e[89]=N,e[90]=rt):rt=e[90];let Ke;e[91]!==N?(Ke=N("contextPanel.browser.openExternal"),e[91]=N,e[92]=Ke):Ke=e[92];const ke=!_;let ge;e[93]!==p||e[94]!==Ke||e[95]!==ke?(ge=n.jsx(Ls,{icon:"external-link",label:Ke,onClick:p,disabled:ke}),e[93]=p,e[94]=Ke,e[95]=ke,e[96]=ge):ge=e[96];let Ve;return e[97]!==Ee||e[98]!==Be||e[99]!==he||e[100]!==G||e[101]!==B||e[102]!==ae||e[103]!==xe||e[104]!==Te||e[105]!==Ge||e[106]!==st||e[107]!==rt||e[108]!==ge?(Ve=n.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Ee,Be,he,G,B,ae,xe,Te,Ge,st,rt,ge]}),e[97]=Ee,e[98]=Be,e[99]=he,e[100]=G,e[101]=B,e[102]=ae,e[103]=xe,e[104]=Te,e[105]=Ge,e[106]=st,e[107]=rt,e[108]=ge,e[109]=Ve):Ve=e[109],Ve},Bo={kind:"fill"},od=240,xk=3840,Op=[{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}],id=t=>Number.isFinite(t)?Math.round(Math.min(xk,Math.max(od,t))):od,Fo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Bp=t=>{const e=Op.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Sk=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},vk=(t,e)=>{const s=Fo(t);if(!s)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/s.width,i/s.height);return{width:s.width,height:s.height,scale:o}},wk=["mobile","tablet","desktop","fill"],kk={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},ad=t=>typeof t=="string"&&wk.includes(t),Ia=t=>t==="fill"?Bo:Bp(kk[t])??Bo,Zr=t=>{const e=Fo(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=Ia(s),i=Fo(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:s,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},jk=t=>{const e=Xe.c(70),{viewport:s,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:c}=t,{t:a}=Ct();let d;e[0]!==s?(d=Fo(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=s.kind==="preset"?s.id:"";let p;e[2]!==r||e[3]!==u?(p=(te,M)=>{const ee=Number.parseInt(M,10);if(!Number.isFinite(ee))return;const V=u??{width:1280,height:800};r({kind:"custom",width:id(te==="width"?ee:V.width),height:id(te==="height"?ee:V.height)})},e[2]=r,e[3]=u,e[4]=p):p=e[4];const m=p;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=De("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=g):g=e[5];const y=g;let v;e[6]!==r?(v=te=>{const M=Bp(te.target.value);r(M??Bo)},e[6]=r,e[7]=v):v=e[7];let x;e[8]!==a?(x=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=x):x=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=De("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=b):b=e[10];let h;e[11]!==a?(h=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=h):h=e[12];let S;e[13]!==h?(S=n.jsx("option",{value:"",children:h}),e[13]=h,e[14]=S):S=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=Op.map(Ck),e[15]=w):w=e[15];let j;e[16]!==f||e[17]!==v||e[18]!==x||e[19]!==S?(j=n.jsxs("select",{value:f,onChange:v,"aria-label":x,className:b,children:[S,w]}),e[16]=f,e[17]=v,e[18]=x,e[19]=S,e[20]=j):j=e[20];const k=u?String(u.width):"";let T;e[21]!==m?(T=te=>m("width",te.target.value),e[21]=m,e[22]=T):T=e[22];let O;e[23]!==a?(O=a("contextPanel.browser.device.width"),e[23]=a,e[24]=O):O=e[24];let $;e[25]!==k||e[26]!==T||e[27]!==O?($=n.jsx("input",{value:k,onChange:T,placeholder:"—",inputMode:"numeric","aria-label":O,className:y}),e[25]=k,e[26]=T,e[27]=O,e[28]=$):$=e[28];let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=D):D=e[29];const E=u?String(u.height):"";let R;e[30]!==m?(R=te=>m("height",te.target.value),e[30]=m,e[31]=R):R=e[31];let z;e[32]!==a?(z=a("contextPanel.browser.device.height"),e[32]=a,e[33]=z):z=e[33];let _;e[34]!==E||e[35]!==R||e[36]!==z?(_=n.jsx("input",{value:E,onChange:R,placeholder:"—",inputMode:"numeric","aria-label":z,className:y}),e[34]=E,e[35]=R,e[36]=z,e[37]=_):_=e[37];let W;e[38]!==r||e[39]!==s?(W=()=>r(Sk(s)),e[38]=r,e[39]=s,e[40]=W):W=e[40];const N=!u;let Y;e[41]!==a?(Y=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=Y):Y=e[42];let C;e[43]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Q,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=C):C=e[43];let P;e[44]!==W||e[45]!==N||e[46]!==Y?(P=n.jsx(zt,{asChild:!0,children:n.jsx(It,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:W,disabled:N,"aria-label":Y,children:C})}),e[44]=W,e[45]=N,e[46]=Y,e[47]=P):P=e[47];let I;e[48]!==a?(I=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=I):I=e[49];let H;e[50]!==I?(H=n.jsx(Ft,{sideOffset:6,children:I}),e[50]=I,e[51]=H):H=e[51];let A;e[52]!==P||e[53]!==H?(A=n.jsxs(Kt,{children:[P,H]}),e[52]=P,e[53]=H,e[54]=A):A=e[54];let F;e[55]!==c||e[56]!==u?(F=u&&c<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(c*100),"%"]}):null,e[55]=c,e[56]=u,e[57]=F):F=e[57];let L;e[58]===Symbol.for("react.memo_cache_sentinel")?(L=["system","light","dark"],e[58]=L):L=e[58];let X;e[59]!==i||e[60]!==o||e[61]!==a?(X=n.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:L.map(te=>n.jsx(It,{type:"button",variant:i===te?"secondary":"ghost",size:"xs",className:De("shrink-0 rounded-full px-2.5 typography-micro",i===te?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(te),"aria-pressed":i===te,children:a(te==="system"?"contextPanel.browser.device.schemeSystem":te==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},te))}),e[59]=i,e[60]=o,e[61]=a,e[62]=X):X=e[62];let re;return e[63]!==j||e[64]!==$||e[65]!==_||e[66]!==A||e[67]!==F||e[68]!==X?(re=n.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[j,$,D,_,A,F,X]}),e[63]=j,e[64]=$,e[65]=_,e[66]=A,e[67]=F,e[68]=X,e[69]=re):re=e[69],re};function Ck(t){return n.jsx("option",{value:t.id,children:t.label},t.id)}const Lo=new Map,Ta=new Set,Fp=()=>{for(const t of Ta)t()},Ki=(t,e)=>{const s=t.trim();s&&(e.length===0?Lo.delete(s):Lo.set(s,[...e]),Fp())},Pk=t=>{Lo.delete(t.trim())&&Fp()},Lp=[],Ek=t=>Lo.get(t.trim())??Lp,Ik=t=>(Ta.add(t),()=>{Ta.delete(t)}),Tk=t=>{const e=Xe.c(2);let s;return e[0]!==t?(s=()=>Ek(t),e[0]=t,e[1]=s):s=e[1],l.useSyncExternalStore(Ik,s,Dk)};function Dk(){return Lp}const _p="oc.browser.hiddenDevServerPorts.v1",Rk=Dr(Ks(),ai(v1().int().positive())),Da=new Set,$p=[];let Jr=null;const Pl=()=>{const t=Xo().getItem(_p);if(Jr&&Jr.raw===t)return Jr.value;let e={};if(t!==null)try{const s=Rk.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return Jr={raw:t,value:e},e},zp=t=>{Xo().setItem(_p,JSON.stringify(t));for(const e of Da)e()},Nk=(t=Xt())=>Pl()[t]??$p,Mk=t=>{const e=Xt(),s=Pl(),r=s[e]??[];r.includes(t)||zp({...s,[e]:[...r,t].sort((i,o)=>i-o)})},Ak=()=>{const t=Xt(),e=Pl();if(!e[t])return;const s={...e};delete s[t],zp(s)},Ok=t=>(Da.add(t),()=>{Da.delete(t)}),Bk=()=>l.useSyncExternalStore(Ok,Fk,Lk);function Fk(){return Nk()}function Lk(){return $p}const _k=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},$k=2e3,zk=t=>Ru("http://localhost",t),Kp=t=>{const e=Xe.c(51),{onOpen:s,directory:r}=t,i=r===void 0?"":r,{t:o}=Ct();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={kind:"loading"},e[0]=c):c=e[0];const[a,d]=l.useState(c),u=Tk(i);let f;e[1]!==i?(f=()=>zk(i),e[1]=i,e[2]=f):f=e[2];const[p]=l.useState(f);let m;e[3]!==i?(m=()=>Zg(i),e[3]=i,e[4]=m):m=e[4];const[g]=l.useState(m);let y;e[5]!==i?(y=Fm(i),e[5]=i,e[6]=y):y=e[6];const v=y,x=Cl(i),b=Lm(i);let h,S;e[7]!==i||e[8]!==b?(h=()=>{if(b){d({kind:"ready",servers:[]});return}let I=!0,H=null;const A=new AbortController,F=()=>{S0(A.signal,i).then(L=>{I&&(d(L),H=setTimeout(F,$k))})};return F(),()=>{I=!1,H&&clearTimeout(H),A.abort()}},S=[i,b],e[7]=i,e[8]=b,e[9]=h,e[10]=S):(h=e[9],S=e[10]),l.useEffect(h,S);const w=a.kind==="ready"?a.servers:null;let j;e[11]!==u||e[12]!==w?(j=k0({announced:u,discovered:w}),e[11]=u,e[12]=w,e[13]=j):j=e[13];const k=j,T=Bk();let O;if(e[14]!==k||e[15]!==T){let I;e[17]!==T?(I=H=>H.announced||!T.includes(H.port),e[17]=T,e[18]=I):I=e[18],O=k.filter(I),e[14]=k,e[15]=T,e[16]=O}else O=e[16];const $=O,D=k.length-$.length;let E;e[19]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(sx,{width:110,height:110,className:"shrink-0 opacity-20"}),e[19]=E):E=e[19];let R;e[20]!==o?(R=o("contextPanel.browser.empty"),e[20]=o,e[21]=R):R=e[21];let z;e[22]!==R?(z=n.jsx("span",{className:"typography-ui-header text-foreground",children:R}),e[22]=R,e[23]=z):z=e[23];let _;e[24]!==o?(_=o("contextPanel.browser.emptyHint"),e[24]=o,e[25]=_):_=e[25];let W;e[26]!==_?(W=n.jsx("span",{className:"typography-micro text-muted-foreground",children:_}),e[26]=_,e[27]=W):W=e[27];let N;e[28]!==z||e[29]!==W?(N=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[z,W]}),e[28]=z,e[29]=W,e[30]=N):N=e[30];let Y;e[31]!==u||e[32]!==k.length||e[33]!==i||e[34]!==D||e[35]!==v||e[36]!==s||e[37]!==p||e[38]!==x||e[39]!==g||e[40]!==o||e[41]!==$?(Y=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?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),p&&!g?n.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,n.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pe-0.5",children:$.map(I=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(It,{type:"button",variant:"outline",size:"sm",className:De("min-w-0 flex-1 justify-start gap-2",p&&"cursor-default opacity-60"),"aria-disabled":p||void 0,onClick:()=>{p||(Pk(i),s(I.url))},children:[v?n.jsx("span",{className:"shrink-0",role:"img","aria-label":x??o("contextPanel.browser.spaceAddress"),title:x??o("contextPanel.browser.spaceAddress"),children:n.jsx(Q,{name:"box-3",className:"size-3.5","aria-hidden":"true"})}):n.jsx(Q,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",children:Yo(I.url)||I.url}),g?n.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":o("contextPanel.browser.devServers.spaceOnlyDesktop"),title:o("contextPanel.browser.devServers.spaceOnlyDesktop"),children:n.jsx(Q,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):n.jsx("span",{className:"ms-auto truncate typography-micro text-muted-foreground",children:_k(I.url)})]}),I.announced?null:n.jsx(It,{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:()=>Mk(I.port),"aria-label":o("contextPanel.browser.devServers.hide",{port:I.port}),title:o("contextPanel.browser.devServers.hide",{port:I.port}),children:n.jsx(Q,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},I.port))}),D>0?n.jsx(It,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:Ak,children:D===1?o("contextPanel.browser.devServers.showHiddenSingle",{count:D}):o("contextPanel.browser.devServers.showHiddenPlural",{count:D})}):null]}):null,e[31]=u,e[32]=k.length,e[33]=i,e[34]=D,e[35]=v,e[36]=s,e[37]=p,e[38]=x,e[39]=g,e[40]=o,e[41]=$,e[42]=Y):Y=e[42];let C;e[43]!==k.length||e[44]!==a.kind||e[45]!==o?(C=k.length===0&&a.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[43]=k.length,e[44]=a.kind,e[45]=o,e[46]=C):C=e[46];let P;return e[47]!==N||e[48]!==Y||e[49]!==C?(P=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,N,Y,C]}),e[47]=N,e[48]=Y,e[49]=C,e[50]=P):P=e[50],P},Is=t=>Math.round(t),Kk=(t,e)=>{const s=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,c=t.bounds;return[`Element ${e+1}: ${t.tag}`,s?`- Text: ${s}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Is(c.x)}, y=${Is(c.y)}, width=${Is(c.width)}, height=${Is(c.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},Wk=(t,e)=>{const s=t.rect;return`Region ${e+1}: x=${Is(s.x)}, y=${Is(s.y)}, width=${Is(s.width)}, height=${Is(s.height)}`},Hk=(t,e)=>{const s=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Is(s.x)}, y=${Is(s.y)}, width=${Is(s.width)}, height=${Is(s.height)}`},Vk=({payload:t,screenshotAttached:e,intro:s})=>{const r=s.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Is(t.viewport.width)}x${Is(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[c,a]of t.elements.entries())o.push("",...Kk(a.element,c));return t.regions.length>0&&(o.push(""),t.regions.forEach((c,a)=>o.push(Wk(c,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((c,a)=>o.push(Hk(c,a)))),o.filter(c=>typeof c=="string").join(`
|
|
1044
|
+
`)},Uk=t=>{const e=Xe.c(7),{t:s}=Ct(),r=xt(qk),i=xt(Yk),o=nx(Xk),c=rx(Qk);let a;return e[0]!==c||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==s?(a=async d=>{const u=r??(i?"draft":null);if(!u){ze.error(s("contextPanel.browser.annotate.noSession"));return}let f=!1;if(d.screenshot)try{await c(d.screenshot),f=!0}catch{f=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:Vk({payload:d.payload,screenshotAttached:f,intro:s("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),ze.success(s("contextPanel.browser.annotate.attached")),requestAnimationFrame(ox)},e[0]=c,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=s,e[6]=a):a=e[6],a},Gk=()=>{const t=Xe.c(16),{t:e}=Ct();let s;t[0]!==e?(s=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=s):s=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let c;t[8]!==e?(c=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=c):c=t[9];let a;return t[10]!==s||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==c?(a={select:s,marquee:r,draw:i,commentPlaceholder:o,submit:c},t[10]=s,t[11]=r,t[12]=i,t[13]=o,t[14]=c,t[15]=a):a=t[15],a};function qk(t){return t.currentSessionId}function Yk(t){return t.newSessionDraft?.open}function Xk(t){return t.addDraft}function Qk(t){return t.addAttachedFile}const Zk=3e4,Jk=3,ej=250,tj={attempts:0,windowStartedAt:null},sj=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=Zk,r=s?0:t.attempts;return r>=Jk?null:{delayMs:ej*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},nj=-3,eo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",Yn=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},rj=(t,{initialUrl:e,onUrlChange:s})=>{const[r,i]=l.useState(e?{kind:"loading",url:e}:P0),[o,c]=l.useState(e),[a,d]=l.useState(""),[u,f]=l.useState(!1),[p,m]=l.useState(!1),g=l.useRef(s);g.current=s;const y=l.useRef(tj);return l.useEffect(()=>{if(!t)return;const v=()=>{try{const D=t.getURL();return eo(D)?D:""}catch{return""}},x=()=>{try{f(t.canGoBack()),m(t.canGoForward())}catch{}},b=D=>{eo(D)&&(c(D),g.current(D))},h=()=>{const D=v();i({kind:"loading",url:D})},S=()=>{const D=v();let E="";try{E=t.getTitle()||""}catch{E=""}d(E),b(D),x(),i(R=>R.kind==="failed"?R:{kind:"ready",url:D,title:E})},w=D=>{const E=Yn(D);eo(E.url)&&(b(E.url),x())},j=D=>{const E=Yn(D),R=Array.isArray(E.favicons)?E.favicons.find(Boolean):"",z=v();if(!R||!z)return;let _=-1;try{_=t.getWebContentsId()}catch{return}!Number.isFinite(_)||_<0||fp.getState().resolve(z,R,_)},k=D=>{const E=Yn(D);typeof E.title=="string"&&d(E.title)},T=D=>{const E=Yn(D);if(E.isMainFrame===!1)return;const R=typeof E.errorCode=="number"?E.errorCode:0;R!==nj&&i({kind:"failed",url:eo(E.validatedURL)?E.validatedURL:v(),code:R,description:typeof E.errorDescription=="string"?E.errorDescription:""})};let O=null;const $=()=>{const D=v(),E=sj(y.current,Date.now());if(!E){i({kind:"failed",url:D,code:0,description:"",crashed:!0});return}y.current=E.state,i({kind:"loading",url:D}),O=setTimeout(()=>{O=null;try{t.reload()}catch{i({kind:"failed",url:D,code:0,description:"",crashed:!0})}},E.delayMs)};t.addEventListener("did-start-loading",h),t.addEventListener("did-stop-loading",S),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",T),t.addEventListener("render-process-gone",$),t.addEventListener("crashed",$);try{!t.isLoading()&&v()&&S()}catch{}return()=>{O!==null&&clearTimeout(O),t.removeEventListener("render-process-gone",$),t.removeEventListener("crashed",$),t.removeEventListener("did-start-loading",h),t.removeEventListener("did-stop-loading",S),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",T)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:p}},ld=1e3,Wp=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},oj=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},ij=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},aj=(t,e)=>{const s=l.useRef(0),r=l.useRef(0),i=l.useRef(0),o=l.useRef(null),c=l.useCallback(()=>{if(!t||document.activeElement!==t)return;const a=o.current;a&&a.isConnected&&a!==document.body?a.focus({preventScroll:!0}):t.blur()},[t]);return l.useEffect(()=>{if(!t)return;document.activeElement!==t&&(o.current=ij());const a=d=>{if(document.activeElement!==t){o.current=oj(d);return}const u=e.current,f=s.current>r.current||Date.now()<i.current;u&&Wp(u)&&!f||r.current>0||c()};return document.addEventListener("focusin",a,!0),()=>document.removeEventListener("focusin",a,!0)},[c,e,t]),l.useCallback(async a=>{const d=t!==null&&document.activeElement===t;let u=!1;const f=()=>{u&&(u=!1,r.current-=1,i.current=Date.now()+ld,!d&&r.current===0&&c())},p=()=>(u||(u=!0,r.current+=1),f);s.current+=1;try{return await a(p)}finally{s.current-=1,i.current=Date.now()+ld,f()}},[c,t])},lj=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),cj=()=>document.visibilityState==="visible",dj=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,to=.5,uj=-3,fj=4,pj="persist:openchamber-browser",Hp=(t,e,s)=>Us(t)!==null&&yu(e)?{icon:"box-3",label:s}:void 0,cd=t=>{const e=Us(t);return e?`openchamber-space-preview:${e}`:pj},dd=20,hj=600,mj=2e4,gj=15e3,bj=t=>{if(!t||Wp(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}},yj=({initialUrl:t,directory:e,tabID:s,ownerSessionId:r,visible:i})=>{const{t:o}=Ct(),{currentTheme:c}=dr(),a=l.useRef(null),[d,u]=l.useState(null),f=l.useCallback(Me=>{a.current=Me,u(Me)},[]),p=de(Me=>Me.setContextPanelTabTargetPath),m=l.useRef(Qn(t)),g=m.current!==Sn?m.current:"",[y,v]=l.useState(g?null:Sn),x=Cl(e),[b,h]=l.useState(g),[S,w]=l.useState(!1),[j,k]=l.useState(!1),[T,O]=l.useState(0),$=l.useRef(0),[D,E]=l.useState(!1),[R,z]=l.useState(Bo),_=l.useRef(R);_.current=R;const W=l.useRef([]),[N,Y]=l.useState("system"),[C,P]=l.useState({width:0,height:0}),I=l.useRef(null),H=l.useRef(null),A=Ps(e),F=l.useRef(!!g&&!_m(A,s)),L=l.useRef(null);l.useEffect(()=>{bu(A,s)},[A,s]);const X=l.useRef(!1),re=l.useRef(Date.now()),te=l.useCallback(Me=>{!Me||Me===Sn||!e||!s||p(e,s,Me)},[e,s,p]),M=rj(d,{initialUrl:g,onUrlChange:l.useCallback(Me=>{const Pe=Wn(Me);h(Pe),te(Pe)},[te])}),[ee,V]=l.useState(null),[Ee,ve]=l.useState(Us(e)===null);l.useEffect(()=>{const Me=Us(e);if(Me===null){ve(!0);return}let Pe=!0;return ve(!1),Un("desktop_space_preview_prepare",{spaceId:Me}).then(()=>{Pe&&ve(!0)}).catch(()=>{Pe&&V(g||"http://localhost/")}),()=>{Pe=!1}},[e,g]);const ce=Uk(e),Be=Gk(),me=M.status.kind==="loading",he=er(Mp(e)),G=er(Me=>Me.recordVisit),le=er(Me=>Me.forget);l.useEffect(()=>{M.status.kind==="ready"&&G(e,{url:Wn(M.status.url),title:M.status.title})},[e,M.status,G]);const ye=l.useMemo(()=>Np(he,b),[he,b]),Ie=l.useCallback(Me=>{const Pe=Qn(Me);Pe!==Sn&&(F.current=!1,h(Pe),V(null),ic(Pe,e).then(ot=>{const et=a.current;if(!et){v(ot);return}try{et.loadURL(ot)}catch{v(ot)}}).catch(ot=>{ot instanceof ac&&V(Pe)}))},[e]);l.useEffect(()=>{if(!g)return;let Me=!0;return ic(g,e).then(Pe=>{Me&&v(Pe)}).catch(Pe=>{if(Me){if(Pe instanceof ac){V(g),F.current=!1,v(Sn);return}v(g)}}),()=>{Me=!1}},[]);const K=l.useMemo(()=>({executeJavaScript:async(Me,Pe)=>{const ot=a.current;if(!ot)throw new Error("Browser view is not available");return ot.executeJavaScript(Me,Pe)},capturePage:async()=>{const Me=a.current;if(!Me)return null;const Pe=Me.getWebContentsId();return Number.isFinite(Pe)?await Un("desktop_browser_capture_page",{webContentsId:Pe}):null}}),[]),se=l.useCallback(()=>{if(S){w(!1),bo(K);return}if(!M.url){ze.error(o("contextPanel.browser.annotate.noPage"));return}const Me=$0(c.metadata.variant==="light"?"light":"dark");w(!0),L0({host:K,theme:Me,labels:Be}).then(async Pe=>{w(!1),Pe&&await ce(Pe)}).catch(()=>{w(!1),ze.error(o("contextPanel.browser.annotate.failed"))})},[K,ce,c,S,M.url,Be,o]);l.useEffect(()=>{if(!S)return;const Me=Pe=>{sl(Pe)||Pe.key!=="Escape"||(Pe.preventDefault(),Pe.stopImmediatePropagation(),w(!1),bo(K))};return window.addEventListener("keydown",Me,!0),()=>window.removeEventListener("keydown",Me,!0)},[K,S]);const U=l.useRef(!1);l.useEffect(()=>{if(!d)return;const Me=()=>{U.current=!0};return d.addEventListener("dom-ready",Me),d.addEventListener("did-fail-load",Me),()=>{d.removeEventListener("dom-ready",Me),d.removeEventListener("did-fail-load",Me)}},[d]);const ie=l.useCallback(async()=>{const Me=Date.now()+gj;for(;!(a.current&&U.current)&&Date.now()<Me;)await new Promise(Pe=>setTimeout(Pe,100));return a.current},[]),we=l.useCallback(async(Me=8e3)=>{const Pe=Date.now();for(;;){const ot=a.current;if(!ot)return!1;let et=!1;try{et=ot.isLoading()}catch{return!1}if(!et)return!0;if(Date.now()-Pe>Me)return!1;await new Promise(Ze=>setTimeout(Ze,120))}},[]),pe=l.useCallback(async(Me,Pe,ot)=>{const et=await ie();if(!et)throw new Error("The browser panel is not ready");const Ze=()=>{ad(Pe.viewport)&&(z(Ia(Pe.viewport)),E(!0))};if(Me==="browser.back"||Me==="browser.forward"){const tt=Me==="browser.back";if(!(tt?et.canGoBack():et.canGoForward()))throw new Error(tt?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");tt?et.goBack():et.goForward(),await new Promise(it=>setTimeout(it,150)),await we();let ht="";try{ht=et.getTitle()||""}catch{ht=""}return{url:Wn(et.getURL()),title:ht}}if(Me==="browser.capture"){const tt=bj(I.current);try{await new Promise(it=>{requestAnimationFrame(()=>requestAnimationFrame(()=>it()))}),await we();const bt=await K.capturePage();if(!bt)throw new Error("The page could not be captured");let ht="";try{ht=et.getTitle()||""}catch{ht=""}return{...bt,url:Wn(et.getURL()),title:ht,viewport:Zr(_.current)}}finally{tt()}}if(Me==="browser.resize"){if(!ad(Pe.viewport))throw new Error("viewport is required");return Ze(),await new Promise(tt=>setTimeout(tt,200)),await we(),{viewport:Zr(Ia(Pe.viewport))}}if(Me==="browser.open"){const tt=typeof Pe.url=="string"?Pe.url:"";if(!tt)throw new Error("url is required");Ze(),Ie(tt),await new Promise(it=>setTimeout(it,150));const bt=await we(25e3);let ht="";try{ht=et.getTitle()||""}catch{ht=""}return{url:Qn(tt),title:ht,opened:!0,settled:bt,viewport:Zr(_.current)}}await we();const dt=tt=>typeof tt=="string"&&tt?tt:void 0,_e=(()=>{switch(Me){case"browser.snapshot":return fk({selector:dt(Pe.selector)});case"browser.click":return pk({selector:dt(Pe.selector),text:dt(Pe.text)});case"browser.type":return hk({selector:String(Pe.selector??""),value:String(Pe.value??""),submit:Pe.submit===!0});case"browser.inspect":return bk({selector:String(Pe.selector??"")});case"browser.scroll":return mk({selector:dt(Pe.selector),direction:dt(Pe.direction)});default:return null}})();if(!_e)throw new Error(`Unsupported browser action: ${Me}`);let Le=()=>{};(Me==="browser.click"||Me==="browser.type")&&(await Un("desktop_browser_keep_page_focused",{webContentsId:et.getWebContentsId()}).then(bt=>bt.focused===!0).catch(()=>!1)||(Le=ot(),et.focus({preventScroll:!0})));let He;try{He=await et.executeJavaScript(_e,!0)}finally{Le()}if(!He||typeof He!="object")throw new Error("The page returned no result");const $e=He;if($e.ok!==!0)throw new Error(typeof $e.error=="string"&&$e.error?$e.error:"Browser action failed");if(Me==="browser.snapshot"){const tt=W.current;return{...$e,viewport:Zr(_.current),...tt.length>0?{consoleProblems:[...tt]}:{}}}return(Me==="browser.click"||Me==="browser.type"&&Pe.submit===!0)&&(await new Promise(tt=>setTimeout(tt,150)),await we()),He},[K,Ie,we,ie]),Se=aj(d,I),[Ce,Oe]=l.useState(!1),B=l.useCallback((Me,Pe)=>(Oe(!0),Se(ot=>pe(Me,Pe,ot))),[Se,pe]),ae=l.useCallback(()=>{const Me=a.current;if(!Me)return{title:"",url:""};let Pe="",ot="";try{Pe=Me.getTitle()||""}catch{Pe=""}try{ot=Wn(Me.getURL())}catch{ot=""}return{title:Pe,url:ot}},[]);l.useEffect(()=>Y0({tabId:s,directory:A,ownerSessionId:r,describe:ae,run:B}),[ae,r,B,A,s]),l.useEffect(()=>{const Me=K;return()=>{bo(Me)}},[K]),l.useEffect(()=>{if(!d)return;const Me=ot=>{const et=ot;if(typeof et.level!="number"||et.level<2)return;const Ze=et.sourceId?`${et.sourceId}${et.line?`:${et.line}`:""}`:"";W.current.push({level:et.level>=3?"error":"warning",message:String(et.message??"").slice(0,400),source:Ze}),W.current.length>dd&&W.current.splice(0,W.current.length-dd)},Pe=()=>{W.current=[]};return d.addEventListener("console-message",Me),d.addEventListener("did-start-loading",Pe),()=>{d.removeEventListener("console-message",Me),d.removeEventListener("did-start-loading",Pe)}},[d]);const xe=l.useRef(new Set),Te=l.useCallback(Me=>{xe.current.clear(),Ie(Me)},[Ie]),Ge=l.useRef(M.status);Ge.current=M.status;const st=l.useRef(!1);M.status.kind==="ready"&&M.status.url&&(st.current=!0),l.useEffect(()=>$m(A,s,Me=>{Km(Ge.current,st.current)&&Te(Me)}),[Te,A,s]),l.useEffect(()=>{if(!d)return;const Me=ot=>{const et=Yn(ot),Ze=typeof et.url=="string"?et.url:"";!Ze||!lc(Ze,e)||(ot.preventDefault(),Ie(Ze))},Pe=ot=>{const et=Yn(ot);if(et.isMainFrame===!1||et.errorCode===-3)return;const Ze=typeof et.validatedURL=="string"?et.validatedURL:"";!Ze||!lc(Ze,e)||xe.current.has(Ze)||(xe.current.add(Ze),Ie(Ze))};return d.addEventListener("will-navigate",Me),d.addEventListener("did-fail-load",Pe),()=>{d.removeEventListener("will-navigate",Me),d.removeEventListener("did-fail-load",Pe)}},[e,Ie,d]),l.useEffect(()=>{if(!d)return;const Me=Pe=>{const ot=Pe.detail;Pe.preventDefault(),ot?.url&&Ie(ot.url)};return d.addEventListener("new-window",Me),()=>d.removeEventListener("new-window",Me)},[Ie,d]);const rt=l.useCallback(Me=>{const Pe=Math.min(fj,Math.max(uj,Me));$.current=Pe,O(Pe);try{a.current?.setZoomLevel(Pe)}catch{}},[]);l.useEffect(()=>{const Me=Pe=>{if(!(Pe instanceof CustomEvent))return;const ot=Pe.detail,et=a.current;!et||document.activeElement!==et||(ot==="zoom-in"?rt($.current+to):ot==="zoom-out"?rt($.current-to):ot==="zoom-reset"&&rt(0))};return window.addEventListener("openchamber:zoom",Me),()=>window.removeEventListener("openchamber:zoom",Me)},[rt]);const Ke=l.useCallback(Me=>{Un("desktop_browser_clear_data",{partition:cd(e),cookies:Me==="cookies",cache:Me==="cache"}).then(()=>{ze.success(o(Me==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{a.current?.reloadIgnoringCache()}catch{}}).catch(()=>ze.error(o("contextPanel.browser.clearFailed")))},[e,o]);l.useEffect(()=>{const Me=I.current;if(!Me||typeof ResizeObserver>"u")return;const Pe=new ResizeObserver(ot=>{const et=ot[0]?.contentRect;et&&P({width:et.width,height:et.height})});return Pe.observe(Me),()=>Pe.disconnect()},[]);const ke=l.useCallback(Me=>{Y(Me);const Pe=a.current;if(!Pe)return;let ot=-1;try{ot=Pe.getWebContentsId()}catch{return}Un("desktop_browser_set_color_scheme",{webContentsId:ot,scheme:Me}).catch(et=>{Y("system"),ze.error(et instanceof Error?et.message:o("contextPanel.browser.device.schemeFailed"))})},[o]),ge=l.useCallback(()=>{try{me?a.current?.stop():a.current?.reload()}catch{}},[me]),Ve=M.status,Ue=l.useSyncExternalStore(lj,cj),ft=i&&Ue||r!==null||Ce;l.useEffect(()=>{const Me=dt=>{k(!0);const J=setTimeout(()=>{try{a.current?.reload()}catch{}},dt);return()=>clearTimeout(J)};if(Ve.kind==="loading")return;const Pe=F.current||L.current===Ve;if(F.current&&(Ve.kind==="failed"||Ve.kind==="ready"&&Ve.url)&&(F.current=!1,L.current=Ve),Ve.kind==="failed"){const dt=zm(Ve,{run:H.current,restored:Pe,watched:ft,now:Date.now()});if(H.current=dt.run,dt.next==="retry")return Me(dt.delayMs);k(dt.next==="pause");return}if(H.current=null,Ve.kind!=="ready"||!Ve.url||!yu(Ve.url)){X.current=!0,k(!1);return}if(Pe||X.current||Date.now()-re.current>mj){X.current=!0,k(!1);return}let ot=!1,et=null;return(Us(e)?Promise.resolve(null):v0(Wn(Ve.url))).then(dt=>{if(!ot){if(dt===null||dt<500){X.current=!0,k(!1);return}et=Me(hj)}}),()=>{ot=!0,et?.()}},[e,Ve,ft]);const Qe=M.status.kind==="failed"&&!j?M.status:null,wt=vk(R,C);return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[n.jsx(Ap,{address:b,onAddressChange:h,onSubmit:Te,suggestions:ye,onForgetSuggestion:Me=>le(e,Me),onBack:()=>{try{a.current?.goBack()}catch{}},onForward:()=>{try{a.current?.goForward()}catch{}},onReload:ge,onOpenExternal:()=>{si(M.url||b)},addressMark:Hp(e,b,x??o("contextPanel.browser.spaceAddress")),canOpenExternal:Us(e)===null,canGoBack:M.canGoBack,canGoForward:M.canGoForward,isLoading:me,onAnnotate:se,isAnnotating:S,onOpenDevTools:()=>{try{a.current?.openDevTools()}catch{}},onHardReload:()=>{try{a.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>rt(T+to),onZoomOut:()=>rt(T-to),onZoomReset:()=>rt(0),zoomPercent:Math.round(Math.pow(1.2,T)*100),onClearCookies:()=>Ke("cookies"),onClearCache:()=>Ke("cache"),onToggleDeviceBar:()=>E(Me=>!Me),isDeviceBarOpen:D}),D?n.jsx(jk,{viewport:R,onViewportChange:z,colorScheme:N,onColorSchemeChange:ke,scale:wt?.scale??1}):null,n.jsxs("div",{ref:I,className:De("relative min-h-0 flex-1 bg-background",wt&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[y!==null&&Ee?n.jsx("webview",{ref:f,src:y,partition:cd(e),allowpopups:!0,style:wt?{width:`${wt.width}px`,height:`${wt.height}px`,transform:`scale(${wt.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,y!==null&&!g&&!M.url&&!me?n.jsx(Kp,{onOpen:Te,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:o("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.waitingForServerHint")})]}):null,ee?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[Us(e)!==null?n.jsx(Q,{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:o("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:o(Us(e)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:ee})})]}):null,Qe&&!ee?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:Qe.crashed?o("contextPanel.browser.crashed"):o("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:Qe.crashed?o("contextPanel.browser.crashedHint"):Qe.description||o("contextPanel.browser.loadFailedUnknown")})]}):null,me?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]})]})},xj=t=>{const e=Xe.c(74),{initialUrl:s,directory:r,tabID:i}=t,{t:o}=Ct(),c=de(vj);let a;e[0]!==s?(a=Qn(s),e[0]=s,e[1]=a):a=e[1];const d=a,u=d!==Sn?d:"",[f,p]=l.useState(u);let m;e[2]!==r||e[3]!==u?(m=Ii(u,r),e[2]=r,e[3]=u,e[4]=m):m=e[4];const[g,y]=l.useState(m);let v;e[5]!==r||e[6]!==u?(v=Ru(u,r)?u:"",e[5]=r,e[6]=u,e[7]=v):v=e[7];const[x,b]=l.useState(v);let h;e[8]!==r?(h=Us(r),e[8]=r,e[9]=h):h=e[9];const S=h!==null,w=Cl(r);let j;e[10]!==u?(j=u?[u]:[],e[10]=u,e[11]=j):j=e[11];const[k,T]=l.useState(j),[O,$]=l.useState(u?0:-1),[D,E]=l.useReducer(wj,0);let R,z;e[12]!==r||e[13]!==i?(R=()=>{bu(Ps(r),i)},z=[r,i],e[12]=r,e[13]=i,e[14]=R,e[15]=z):(R=e[14],z=e[15]),l.useEffect(R,z);let _;e[16]!==r||e[17]!==c||e[18]!==i?(_=le=>{!le||le===Sn||!r||!i||c(r,i,le)},e[16]=r,e[17]=c,e[18]=i,e[19]=_):_=e[19];const W=_;let N;e[20]!==r?(N=Mp(r),e[20]=r,e[21]=N):N=e[21];const Y=er(N),C=er(kj),P=er(jj);let I;e[22]!==f||e[23]!==Y?(I=Np(Y,f),e[22]=f,e[23]=Y,e[24]=I):I=e[24];const H=I;let A;e[25]!==r||e[26]!==O||e[27]!==W||e[28]!==C?(A=le=>{const ye=Qn(le);if(ye===Sn)return;p(ye);const Ie=Ii(ye,r);y(Ie),b(Ie?"":ye),W(ye),C(r,{url:ye}),T(K=>{const se=O>=0?K.slice(0,O+1):[];return se[se.length-1]===ye?($(se.length-1),se):($(se.length),[...se,ye])})},e[25]=r,e[26]=O,e[27]=W,e[28]=C,e[29]=A):A=e[29];const F=A;let L;e[30]!==r||e[31]!==k||e[32]!==W?(L=le=>{const ye=k[le];if(!ye)return;$(le),p(ye);const Ie=Ii(ye,r);y(Ie),b(Ie?"":ye),W(ye)},e[30]=r,e[31]=k,e[32]=W,e[33]=L):L=e[33];const X=L;let re;e[34]!==r||e[35]!==P?(re=le=>P(r,le),e[34]=r,e[35]=P,e[36]=re):re=e[36];let te,M;e[37]!==X||e[38]!==O?(te=()=>X(O-1),M=()=>X(O+1),e[37]=X,e[38]=O,e[39]=te,e[40]=M):(te=e[39],M=e[40]);let ee;e[41]!==f||e[42]!==g?(ee=()=>{si(g||f)},e[41]=f,e[42]=g,e[43]=ee):ee=e[43];let V;e[44]!==w||e[45]!==o?(V=w??o("contextPanel.browser.spaceAddress"),e[44]=w,e[45]=o,e[46]=V):V=e[46];let Ee;e[47]!==f||e[48]!==r||e[49]!==V?(Ee=Hp(r,f,V),e[47]=f,e[48]=r,e[49]=V,e[50]=Ee):Ee=e[50];const ve=!x,ce=O>0,Be=O>=0&&O<k.length-1;let me;e[51]!==f||e[52]!==F||e[53]!==H||e[54]!==re||e[55]!==te||e[56]!==M||e[57]!==ee||e[58]!==Ee||e[59]!==ve||e[60]!==ce||e[61]!==Be?(me=n.jsx(Ap,{address:f,onAddressChange:p,onSubmit:F,suggestions:H,onForgetSuggestion:re,onBack:te,onForward:M,onReload:E,onOpenExternal:ee,addressMark:Ee,canOpenExternal:ve,canGoBack:ce,canGoForward:Be,isLoading:!1}),e[51]=f,e[52]=F,e[53]=H,e[54]=re,e[55]=te,e[56]=M,e[57]=ee,e[58]=Ee,e[59]=ve,e[60]=ce,e[61]=Be,e[62]=me):me=e[62];let he;e[63]!==r||e[64]!==S||e[65]!==g||e[66]!==F||e[67]!==D||e[68]!==o||e[69]!==x?(he=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:x?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[S?n.jsx(Q,{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:o(S?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:Yo(x)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.remoteLoopback.hint")})]}):g?n.jsx("iframe",{src:g,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${D}`):n.jsx(Kp,{onOpen:F,directory:r})}),e[63]=r,e[64]=S,e[65]=g,e[66]=F,e[67]=D,e[68]=o,e[69]=x,e[70]=he):he=e[70];let G;return e[71]!==me||e[72]!==he?(G=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[me,he]}),e[71]=me,e[72]=he,e[73]=G):G=e[73],G},Sj=t=>{const e=Xe.c(3),[s]=l.useState(dj);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(yj,{...t}):n.jsx(xj,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function vj(t){return t.setContextPanelTabTargetPath}function wj(t){return t+1}function kj(t){return t.recordVisit}function jj(t){return t.forget}const Cj=t=>{const e=Xe.c(13),{zone:s,children:r}=t,[i]=l.useState(Pj);let o;e[0]!==s?(o=m=>m.body[s],e[0]=s,e[1]=o):o=e[1];const c=Rr(o);let a,d;e[2]!==c||e[3]!==i||e[4]!==s?(a=()=>{const m=c??Rr.getState().body[s];if(!m){i.remove();return}if(i.parentElement===m)return;const g=document.activeElement;m.moveBefore&&i.isConnected?m.moveBefore(i,null):m.append(i),g instanceof HTMLElement&&i.contains(g)&&document.activeElement!==g&&g.focus({preventScroll:!0})},d=[c,i,s],e[2]=c,e[3]=i,e[4]=s,e[5]=a,e[6]=d):(a=e[5],d=e[6]),l.useLayoutEffect(a,d);let u,f;e[7]!==i?(u=()=>()=>i.remove(),f=[i],e[7]=i,e[8]=u,e[9]=f):(u=e[8],f=e[9]),l.useLayoutEffect(u,f);let p;return e[10]!==r||e[11]!==i?(p=Wa.createPortal(r,i),e[10]=r,e[11]=i,e[12]=p):p=e[12],p};function Pj(){const t=document.createElement("div");return t.style.display="contents",t}const Ra=2e4,Ej=(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},so=(t,e)=>Wm(Hm.getState().dictionary,t,e),Ij=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"},Tj=async(t,e,s)=>{const r=!!(s?.directory&&!dx(e,s.directory));if(t.readFile)return(await t.readFile(e,{optional:!0,directory:s?.directory,allowOutsideWorkspace:r})).content??"";const i=new URLSearchParams({path:e,optional:"true"});s?.directory&&i.set("directory",s.directory),r&&i.set("allowOutsideWorkspace","true");const o=await Gs(`/api/fs/read?${i.toString()}`,{cache:"no-store",headers:s?.directory?{"x-opencode-directory":s.directory}:void 0});if(!o.ok){const c=await o.json().catch(()=>({error:o.statusText}));throw new Error(c.error||"Failed to read file")}return o.text()},Dj=async(t,e,s)=>{if(ix(e)||ax(e)||lx(e))return{ok:!0};try{const r=await Tj(t,e,s);return cx(r)?{ok:!1,reason:"binary"}:Ej(r,Ra)>Ra?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:Ij(r)}}},Rj=t=>{if(t==="too-large"){const e=Ra.toLocaleString(gf());return so("contextFileOpen.failure.tooLarge",{count:e})}return so(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},ud=8;let Nr=null;const Vp=(t,e)=>Math.abs(e.clientX-t.x)<=ud&&Math.abs(e.clientY-t.y)<=ud,Up=t=>{Nr={x:t.clientX,y:t.clientY}},Gp=t=>{const e=Nr;return Nr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Vp(e,t)},qp=t=>Nr!==null&&Vp(Nr,t);let Yp=null;const fd=t=>{Yp=t},Xp=()=>Yp,pd=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},Qp=(t,e,s)=>{const r=e===null?s:e.type==="directory"?e.path:pd(e.path);return!r||pd(t.path)===r||t.type==="directory"&&Vm(r,t.path,t.path)!==null?null:r},Nj=(t,e)=>{const s=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${s}`:`${e}/${s}`},tr=t=>Array.from(t.types).includes("Files"),Er=t=>Array.from(t.types).includes(ni)?Xp():null,Zp=(t,e,s)=>t.getData(ni)===ci(e,s.path),Mj=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]:[]})},Aj=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),ls=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},ci=(t,e)=>{const s=ls(e),r=ls(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},mr=(t,e)=>{const s=ci(t,e);if(s!==".")return s;const r=ls(t);return r.split("/").filter(Boolean).pop()??r},So=t=>{const e=ls(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},Oj=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),Bj=new Set(["node_modules"]),Fj=t=>Bj.has(t),Lj=t=>{const e=ls(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},_j=8,Qs=new Map,El=t=>JSON.stringify([Xt(),t]),$j=t=>{const e=El(t),s=Qs.get(e);return s?(s.touchedAt=Date.now(),Qs.delete(e),Qs.set(e,s),s):null},Wi=t=>{const e=El(t),s=Qs.get(e);if(s)return s.touchedAt=Date.now(),s;if(Qs.size>=_j){const i=Qs.keys().next().value;i!==void 0&&Qs.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Qs.set(e,r),r},zj=t=>{const e=Xe.c(127),{node:s,root:r,isExpanded:i,isActive:o,isBrowserClient:c,depth:a,isOpen:d,status:u,badge:f,isDropTarget:p,isDragSource:m,canUpload:g,canMove:y,permissions:v,downloadFile:x,onSelect:b,onToggle:h,onRevealPath:S,onOpenDialog:w,onSetDropTarget:j,onDropFiles:k,onPickFiles:T,onMoveDragChange:O,onSetMoveDropTarget:$,onMoveDrop:D}=t,{t:E}=Ct(),R=s.type==="directory";let z;e[0]!==R||e[1]!==s.path?(z=R?s.path:So(s.path),e[0]=R,e[1]=s.path,e[2]=z):z=e[2];const _=z,{canRename:W,canCreateFile:N,canCreateFolder:Y,canDelete:C,canReveal:P}=v,I=!R&&!!x,H=P&&!c,A=R&&g,F=W||N||Y||A||C||I||H,[L,X]=l.useState(!1),[re,te]=l.useState(!1);let M;e[3]!==F?(M=Ze=>{F&&(Ze?.preventDefault(),te(!0))},e[3]=F,e[4]=M):M=e[4];const ee=M;let V;e[5]!==R||e[6]!==s||e[7]!==b||e[8]!==h?(V=()=>{R?h(s.path):b(s)},e[5]=R,e[6]=s,e[7]=b,e[8]=h,e[9]=V):V=e[9];const Ee=V;let ve;e[10]!==R||e[11]!==s||e[12]!==b?(ve=()=>{R||b(s,{pin:!0})},e[10]=R,e[11]=s,e[12]=b,e[13]=ve):ve=e[13];const ce=ve;let Be;e[14]===Symbol.for("react.memo_cache_sentinel")?(Be=Ze=>{Ze.stopPropagation(),te(!1),X(!0)},e[14]=Be):Be=e[14];const me=Be;let he;e[15]!==N||e[16]!==Y||e[17]!==C||e[18]!==W||e[19]!==H||e[20]!==A||e[21]!==x||e[22]!==c||e[23]!==R||e[24]!==s||e[25]!==w||e[26]!==T||e[27]!==S||e[28]!==E?(he=Ze=>{const{Item:dt,Separator:J}=Ze;return n.jsxs(n.Fragment,{children:[W&&n.jsxs(dt,{onClick:_e=>{_e.stopPropagation(),w("rename",s)},children:[n.jsx(Q,{name:"edit",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.rename")]}),n.jsxs(dt,{onClick:_e=>{_e.stopPropagation(),ti(s.path).then(Le=>{if(Le.ok){ze.success(E("sidebarFilesTree.toast.pathCopied"));return}ze.error(E("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(Q,{name:"file-copy",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.copyPath")]}),!R&&x&&n.jsxs(dt,{onClick:_e=>{_e.stopPropagation(),x(s.path).catch(Le=>{console.error("Download failed:",Le),ze.error(E("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Q,{name:"download",className:"me-2 h-4 w-4"})," ",E(c?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),H&&n.jsxs(dt,{onClick:_e=>{_e.stopPropagation(),S(s.path)},children:[n.jsx(Q,{name:"folder-received",className:"me-2 h-4 w-4"})," ",E(xf())]}),!R&&H&&Qo()&&n.jsxs(dt,{onClick:_e=>{_e.stopPropagation(),Um(s.path).then(Le=>{Le||ze.error(E("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Q,{name:"external-link",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.openInDefaultApp")]}),R&&(N||Y||A)&&n.jsxs(n.Fragment,{children:[n.jsx(J,{}),N&&n.jsxs(dt,{onClick:_e=>{_e.stopPropagation(),w("createFile",s)},children:[n.jsx(Q,{name:"file-add",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.newFile")]}),Y&&n.jsxs(dt,{onClick:_e=>{_e.stopPropagation(),w("createFolder",s)},children:[n.jsx(Q,{name:"folder-add",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.newFolder")]}),A&&n.jsxs(dt,{onClick:_e=>{_e.stopPropagation(),T(s.path)},children:[n.jsx(Q,{name:"upload-2",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.uploadFiles")]})]}),C&&n.jsxs(n.Fragment,{children:[n.jsx(J,{}),n.jsxs(dt,{onClick:_e=>{_e.stopPropagation(),w("delete",s)},className:"text-destructive focus:text-destructive",children:[n.jsx(Q,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.delete")]})]})]})},e[15]=N,e[16]=Y,e[17]=C,e[18]=W,e[19]=H,e[20]=A,e[21]=x,e[22]=c,e[23]=R,e[24]=s,e[25]=w,e[26]=T,e[27]=S,e[28]=E,e[29]=he):he=e[29];const G=he;let le;e[30]!==y||e[31]!==s.path||e[32]!==s.type||e[33]!==O||e[34]!==r?(le=Ze=>{Up(Ze);const dt=ci(r,s.path);!dt||dt==="."||(Ze.dataTransfer.setData(ni,dt),Ze.dataTransfer.effectAllowed=y?"copyMove":"copy",y&&O({path:s.path,type:s.type}))},e[30]=y,e[31]=s.path,e[32]=s.type,e[33]=O,e[34]=r,e[35]=le):le=e[35];const ye=le;let Ie;e[36]!==y||e[37]!==Ee||e[38]!==O?(Ie=Ze=>{y&&O(null),Gp(Ze)&&Ee()},e[36]=y,e[37]=Ee,e[38]=O,e[39]=Ie):Ie=e[39];const K=Ie;let se;e[40]!==g||e[41]!==j||e[42]!==_?(se=Ze=>{!g||!_||!tr(Ze.dataTransfer)||(Ze.preventDefault(),Ze.stopPropagation(),Ze.dataTransfer.dropEffect="copy",j(_))},e[40]=g,e[41]=j,e[42]=_,e[43]=se):se=e[43];const U=se;let ie;e[44]!==g||e[45]!==j||e[46]!==_?(ie=Ze=>{!g||!_||!tr(Ze.dataTransfer)||Ze.relatedTarget instanceof Node&&Ze.currentTarget.contains(Ze.relatedTarget)||(Ze.stopPropagation(),j(null))},e[44]=g,e[45]=j,e[46]=_,e[47]=ie):ie=e[47];const we=ie;let pe;e[48]!==g||e[49]!==k||e[50]!==_?(pe=Ze=>{!g||!_||!tr(Ze.dataTransfer)||(Ze.preventDefault(),Ze.stopPropagation(),k(_,Ze.dataTransfer))},e[48]=g,e[49]=k,e[50]=_,e[51]=pe):pe=e[51];const Se=pe;let Ce;e[52]!==s.path||e[53]!==s.type||e[54]!==r?(Ce=(Ze,dt)=>qp(Ze)?null:Qp(dt,{path:s.path,type:s.type},r),e[52]=s.path,e[53]=s.type,e[54]=r,e[55]=Ce):Ce=e[55];const Oe=Ce;let B;e[56]!==y||e[57]!==Oe||e[58]!==U||e[59]!==$?(B=Ze=>{const dt=y?Er(Ze.dataTransfer):null;if(!dt){U(Ze);return}Ze.stopPropagation();const J=Oe(Ze,dt);$(J),J&&(Ze.preventDefault(),Ze.dataTransfer.dropEffect="move")},e[56]=y,e[57]=Oe,e[58]=U,e[59]=$,e[60]=B):B=e[60];const ae=B;let xe;e[61]!==y||e[62]!==Oe||e[63]!==Se||e[64]!==D||e[65]!==$||e[66]!==r?(xe=Ze=>{const dt=y?Er(Ze.dataTransfer):null;if(!dt){Se(Ze);return}Ze.stopPropagation(),Ze.preventDefault(),$(null);const J=Oe(Ze,dt);J&&Zp(Ze.dataTransfer,r,dt)&&D(dt,J)},e[61]=y,e[62]=Oe,e[63]=Se,e[64]=D,e[65]=$,e[66]=r,e[67]=xe):xe=e[67];const Te=xe;let Ge;e[68]===Symbol.for("react.memo_cache_sentinel")?(Ge={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[68]=Ge):Ge=e[68];let st;e[69]!==ee||e[70]!==we||e[71]!==ae||e[72]!==Te?(st=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Ge,onContextMenu:ee,onDragEnter:ae,onDragOver:ae,onDragLeave:we,onDrop:Te}),e[69]=ee,e[70]=we,e[71]=ae,e[72]=Te,e[73]=st):st=e[73];let rt;e[74]!==a?(rt=n.jsx(Mu,{depth:a}),e[74]=a,e[75]=rt):rt=e[75];let Ke;e[76]!==o||e[77]!==m||e[78]!==p?(Ke=De("flex w-full items-center gap-1.5 rounded-md py-1 pe-8 text-start transition-colors select-none",p?"bg-interactive-selection text-interactive-selection-foreground ring-2 ring-inset ring-primary":Nu(o),m&&"opacity-50"),e[76]=o,e[77]=m,e[78]=p,e[79]=Ke):Ke=e[79];let ke;e[80]!==a?(ke=qa(a),e[80]=a,e[81]=ke):ke=e[81];let ge;e[82]!==ke?(ge={paddingInlineStart:ke},e[82]=ke,e[83]=ge):ge=e[83];let Ve;e[84]!==R||e[85]!==i||e[86]!==s.extension||e[87]!==s.path?(Ve=R?n.jsx(Ar,{expanded:i}):n.jsx(ol,{filePath:s.path,extension:s.extension,className:"ms-0.5 size-3.5"}),e[84]=R,e[85]=i,e[86]=s.extension,e[87]=s.path,e[88]=Ve):Ve=e[88];let Ue;e[89]!==s.name||e[90]!==s.path?(Ue=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]=Ue):Ue=e[91];let ft;e[92]!==R||e[93]!==d||e[94]!==u?(ft=!R&&n.jsx(Jg,{isOpen:d,status:u}),e[92]=R,e[93]=d,e[94]=u,e[95]=ft):ft=e[95];let Qe;e[96]!==f||e[97]!==R?(Qe=R&&f&&n.jsx(eb,{badge:f}),e[96]=f,e[97]=R,e[98]=Qe):Qe=e[98];let wt;e[99]!==ee||e[100]!==ce||e[101]!==K||e[102]!==ye||e[103]!==Ee||e[104]!==Ke||e[105]!==ge||e[106]!==Ve||e[107]!==Ue||e[108]!==ft||e[109]!==Qe?(wt=n.jsxs("button",{type:"button",onClick:Ee,onDoubleClick:ce,onContextMenu:ee,draggable:!0,onDragStart:ye,onDragEnd:K,className:Ke,style:ge,children:[Ve,Ue,ft,Qe]}),e[99]=ee,e[100]=ce,e[101]=K,e[102]=ye,e[103]=Ee,e[104]=Ke,e[105]=ge,e[106]=Ve,e[107]=Ue,e[108]=ft,e[109]=Qe,e[110]=wt):wt=e[110];let Me;e[111]!==L||e[112]!==F||e[113]!==G||e[114]!==E?(Me=F&&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(Ts,{open:L,onOpenChange:X,children:[n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Ds,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:me,title:E("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":E("sidebarFilesTree.actions.fileMenuTitle"),children:n.jsx(Q,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(Ft,{side:"bottom",sideOffset:6,children:E("sidebarFilesTree.actions.fileMenuTitle")})]}),n.jsx(Rs,{align:"end",side:"bottom",onCloseAutoFocus:()=>X(!1),children:G({Item:Zt,Separator:jn})})]})}),e[111]=L,e[112]=F,e[113]=G,e[114]=E,e[115]=Me):Me=e[115];let Pe;e[116]!==st||e[117]!==rt||e[118]!==wt||e[119]!==Me?(Pe=n.jsxs(ll,{render:st,children:[rt,wt,Me]}),e[116]=st,e[117]=rt,e[118]=wt,e[119]=Me,e[120]=Pe):Pe=e[120];let ot;e[121]!==G?(ot=n.jsx(al,{className:"min-w-[180px]",children:G({Item:Ln,Separator:uo})}),e[121]=G,e[122]=ot):ot=e[122];let et;return e[123]!==re||e[124]!==Pe||e[125]!==ot?(et=n.jsxs(cl,{open:re,onOpenChange:te,children:[Pe,ot]}),e[123]=re,e[124]=Pe,e[125]=ot,e[126]=et):et=e[126],et},Kj=(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,Wj=l.memo(zj,Kj),Hj=t=>{const e=Xe.c(6),{visible:s}=t,r=s===void 0?!0:s,i=kn(Uj),o=hn();let c;e[0]!==o||e[1]!==i?(c=JSON.stringify([i,o]),e[0]=o,e[1]=i,e[2]=c):c=e[2];let a;return e[3]!==c||e[4]!==r?(a=n.jsx(Vj,{visible:r},c),e[3]=c,e[4]=r,e[5]=a):a=e[5],a},Vj=({visible:t})=>{const e=l.useRef(t);e.current=t;const{t:s}=Ct(),{files:r,runtime:i}=Ws(),o=Gm(i.platform),c=hn()??"",a=ls(c.trim()),d=El(a),u=qm(),f=Ym(),p=Xm(q=>q.searchFiles),m=de(q=>q.openContextFile),g=rl(t?c:null),[y,v]=l.useState(""),x=ux(y,200),b=l.useRef(null),[h,S]=l.useState([]),[w,j]=l.useState(!1),[k,T]=l.useState(null),[O,$]=l.useState(null),[D,E]=l.useState(null),[R,z]=l.useState(null),{hasTouchOnlyPointer:_}=Tn(),W=!!(r.rename&&a)&&!_,N=de(q=>q.confirmFileTreeMove),Y=de(q=>q.setConfirmFileTreeMove),[C,P]=l.useState({}),[I,H]=l.useState({}),A=l.useRef(new Set),F=l.useRef(new Map),L=l.useMemo(()=>new w1,[]);l.useEffect(()=>()=>L.clear(),[L]);const X=l.useRef(null);l.useEffect(()=>{if(T(null),E(null),z(null),!a){P({}),H({}),A.current=new Set;return}const q=$j(a);q?(P({...q.childrenByDir}),H({...q.loadErrorsByDir}),A.current=new Set(q.loadedDirs)):(P({}),H({}),A.current=new Set)},[a]),l.useEffect(()=>{if(!a)return;const q=Wi(a);q.childrenByDir=C},[a,C]),l.useEffect(()=>{if(!a)return;const q=Wi(a);q.loadErrorsByDir=I},[a,I]),l.useEffect(()=>{if(!a)return;const q=Wi(a);q.loadedDirs=new Set(A.current)},[a,C,I]),l.useEffect(()=>()=>{if(!a)return;const q=Qs.get(d);q&&q.loadedDirs.size===0&&Object.keys(q.childrenByDir).length===0&&Qs.delete(d)},[d,a]);const re=l.useMemo(()=>[],[]),te=l.useMemo(()=>[],[]),M=Vs(q=>a?q.byRoot[a]?.expandedPaths??re:re),ee=l.useMemo(()=>new Set(M),[M]),V=Vs(q=>a?q.byRoot[a]?.selectedPath??null:null),Ee=Vs(q=>q.setSelectedPath),ve=l.useRef(null),ce=l.useRef(null);l.useEffect(()=>{ce.current=V},[V]);const Be=Vs(q=>q.addOpenPath),me=Vs(q=>q.removeOpenPathsByPrefix),he=Vs(q=>q.toggleExpandedPath),G=Vs(q=>q.expandPath),le=Vs(q=>q.collapseAllExpandedPaths),ye=de(q=>a?q.contextPanelByDirectory[a]?.tabs??te:te),Ie=l.useMemo(()=>new Set(ye.map(q=>q.mode==="file"?q.targetPath:null).filter(q=>typeof q=="string"&&q.length>0).map(q=>ls(q))),[ye]),[K,se]=l.useState(null),[U,ie]=l.useState(null),[we,pe]=l.useState(""),[Se,Ce]=l.useState(!1),Oe=!!r.writeFile,B=!!r.createDirectory,ae=!!r.rename,xe=!!r.delete,Te=!!r.revealPath,Ge=l.useMemo(()=>({canRename:ae,canCreateFile:Oe,canCreateFolder:B,canDelete:xe,canReveal:Te}),[ae,Oe,B,xe,Te]),st=l.useCallback(q=>{r.revealPath&&r.revealPath(q).catch(()=>{ze.error(s("sidebarFilesTree.toast.revealFailed"))})},[r,s]),rt=l.useCallback((q,fe)=>{se(q),ie(fe),pe(q==="rename"&&fe.name||""),Ce(!1)},[]),Ke=l.useCallback((q,fe)=>{const We=fe.filter(be=>be&&typeof be.name=="string"&&be.name.length>0).filter(be=>u||!be.name.startsWith(".")).filter(be=>f||!Fj(be.name)).map(be=>{const Ne=be.name,mt=ls(be.path||""),jt=mt?Oj(mt)?mt:ls(`${q}/${mt}`):ls(`${q}/${Ne}`),At=be.isDirectory?"directory":"file",Ot=At==="file"&&Ne.includes(".")?Ne.split(".").pop()?.toLowerCase():void 0;return{name:Ne,path:jt,type:At,extension:Ot}});return Aj(We)},[f,u]),ke=l.useCallback(async(q,fe,We=!1)=>{if(!e.current||fe?.())return;const be=ls(q.trim());if(!be||!We&&A.current.has(be))return;const Ne=Xt();return L.run(be,async mt=>{const jt=()=>!mt()||Xt()!==Ne;try{const At=!f,Ot=r.listDirectory?(await r.listDirectory(be,{respectGitignore:At})).entries:await Co.listLocalDirectory(be,{respectGitignore:At});if(jt())return;F.current.set(be,Ot.length);const Wt=Ke(be,Ot);A.current=new Set(A.current),A.current.add(be),H(Qt=>{if(!Qt[be])return Qt;const Ut={...Qt};return delete Ut[be],Ut}),P(Qt=>Qt[be]&&k1(Qt[be],Wt)?Qt:{...Qt,[be]:Wt})}catch(At){if(jt())return;const Ot=At instanceof Error?At.message:String(At??"");console.error("Failed to load sidebar directory:",At),H(Wt=>({...Wt,[be]:Ot}))}},We)},[L,r,Ke,f]),ge=l.useCallback(async()=>{if(!a)return;X.current?.abort();const q=new AbortController;X.current=q,L.clear();try{const We=(Vs.getState().byRoot[a]?.expandedPaths??[]).map(mt=>ls(mt)).filter(mt=>!!mt&&mt!==a&&mt.startsWith(`${a}/`)),be=[a,...We];A.current=new Set(A.current);for(const mt of be)A.current.delete(mt);H(mt=>{if(Object.keys(mt).length===0)return mt;const jt={...mt};let At=!1;for(const Ot of be)Ot in jt&&(delete jt[Ot],At=!0);return At?jt:mt});const Ne=()=>q.signal.aborted;await ke(a,Ne);for(let mt=0;mt<We.length&&!q.signal.aborted;mt+=3){const jt=We.slice(mt,mt+3);await Promise.all(jt.map(At=>ke(At,Ne)))}}catch(fe){if(q.signal.aborted)return;console.error("Failed to refresh sidebar tree:",fe)}finally{X.current===q&&(X.current=null)}},[L,ke,a]),Ve=l.useCallback(async q=>{if(!q){await ge();return}const fe=ls(q);A.current=new Set(A.current),A.current.delete(fe),await ke(fe,void 0,!0)},[ke,ge]);l.useEffect(()=>{a&&(X.current?.abort(),A.current=new Set,L.clear(),H({}),P(q=>Object.keys(q).length===0?q:{}),ke(a))},[L,ke,a,u,f]),l.useEffect(()=>{if(!t||!a||M.length===0)return;const q=M.map(be=>ls(be)).filter(be=>!!be&&be!==a&&be.startsWith(`${a}/`)&&!A.current.has(be)&&!L.has(be)).sort((be,Ne)=>be.split("/").length-Ne.split("/").length);if(q.length===0)return;let fe=!1;const We=()=>fe;return(async()=>{for(let be=0;be<q.length&&!fe;be+=3){const Ne=q.slice(be,be+3);await Promise.all(Ne.map(mt=>ke(mt,We)))}})(),()=>{fe=!0}},[L,M,ke,a,t]);const Ue=l.useRef(t);l.useEffect(()=>{const q=t&&!Ue.current;Ue.current=t,q&&ge()},[ge,t]);const ft=l.useCallback(({directories:q})=>{if(!a)return;const fe=new Set((Vs.getState().byRoot[a]?.expandedPaths??[]).map(Ot=>ls(Ot))),We=a==="/"?"/":`${a}/`,be=Ot=>{for(let Wt=Ot;Wt!==a;Wt=So(Wt))if(!Wt.startsWith(We)||!fe.has(Wt))return!1;return!0},Ne=Ot=>{for(let Wt=Ot;Wt===a||Wt.startsWith(We);Wt=So(Wt)){if(A.current.has(Wt))return Wt;if(Wt===a)break}return null},mt=new Set,jt=new Set;for(const Ot of q??A.current){const Wt=Ne(ls(Ot));Wt&&(be(Wt)?mt:jt).add(Wt)}jt.size>0&&(A.current=new Set([...A.current].filter(Ot=>!jt.has(Ot))));const At=[...mt].filter(Ot=>(F.current.get(Ot)??0)<=tb);(async()=>{for(let Ot=0;Ot<At.length;Ot+=3)await Promise.all(At.slice(Ot,Ot+3).map(Wt=>ke(Wt,void 0,!0)))})()},[ke,a]);sb({root:a,active:t,whileInactive:"drop",onChanges:ft}),l.useEffect(()=>{if(!t)return;if(!c){S([]),j(!1);return}const q=x.trim();if(!q){S([]),j(!1);return}let fe=!1;return j(!0),p(c,q,150,{includeHidden:u,respectGitignore:!f,type:"file"}).then(We=>{if(fe)return;const Ne=We.filter(mt=>f||!Lj(mt.path)).map(mt=>({name:mt.name,path:ls(mt.path),type:"file",extension:mt.extension,relativePath:mt.relativePath}));S(Ne)}).catch(()=>{fe||S([])}).finally(()=>{fe||j(!1)}),()=>{fe=!0}},[c,x,p,u,f,t]);const Qe=l.useMemo(()=>{const q=new Map;if(!g?.files)return q;for(const fe of g.files)fe.index==="A"||fe.working_dir==="?"?q.set(fe.path,"git-added"):fe.index==="D"?q.set(fe.path,"git-deleted"):(fe.index==="M"||fe.working_dir==="M")&&q.set(fe.path,"git-modified");return q},[g]),wt=l.useMemo(()=>{const q=new Map;if(!g?.files||!a)return q;for(const fe of g.files){const We=fe.index==="M"||fe.working_dir==="M",be=fe.index==="A"||fe.working_dir==="?";if(!We&&!be)continue;const Ne=fe.path.split("/");if(Ne.length<=1)continue;let mt=a;for(let jt=0;jt<Ne.length-1;jt++){mt=`${mt}/${Ne[jt]}`;let At=q.get(mt);At||(At={modified:0,added:0},q.set(mt,At)),We&&At.modified++,be&&At.added++}}return q},[g,a]),Me=l.useCallback(q=>{if(Qe.size===0)return null;const fe=q.startsWith(a+"/")?q.slice(a.length+1):q;return Qe.get(fe)??null},[Qe,a]),Pe=l.useCallback(q=>{if(wt.size===0)return null;const fe=wt.get(q);return fe&&fe.modified+fe.added>0?fe:null},[wt]),ot=l.useCallback(async(q,fe)=>{if(!a)return;const We=await Dj(r,q.path,{directory:a});if(!We.ok){ze.error(Rj(We.reason));return}Ee(a,q.path),Be(a,q.path),m(a,q.path,{preview:!fe?.pin&&!de.getState().isMobile})},[Be,r,m,a,Ee]),et=l.useCallback(async q=>{const fe=ls(q);a&&(he(a,fe),A.current.has(fe)||await ke(fe))},[ke,a,he]),{canUpload:Ze,uploadingDirectory:dt,uploadFiles:J,pickFiles:_e,uploadElements:Le}=nb({root:a,refreshDirectory:Ve}),He=dt!==null,$e=dt??k,tt=l.useCallback((q,fe)=>{const We=Mj(fe);We.length!==0&&(T(null),J(q,We))},[J]),bt=l.useCallback(q=>{if(fd(q),!q){$(null),E(null);return}requestAnimationFrame(()=>{Xp()?.path===q.path&&$(q.path)})},[]),ht=l.useCallback(async(q,fe)=>{const We=Nj(q,fe),be=await Mc(r,a,q.path,We);if(be==="conflict"){ze.error(s("sidebarFilesTree.toast.nameTaken",{name:We.slice(We.lastIndexOf("/")+1),folder:mr(a,fe)}));return}if(be==="failed"){ze.error(s("sidebarFilesTree.toast.operationFailed"));return}fe!==a&&G(a,fe),await Promise.all([Ve(So(q.path)),Ve(fe)]).catch(()=>{})},[G,r,Ve,a,s]),it=l.useCallback((q,fe)=>{if(de.getState().confirmFileTreeMove){z({source:q,targetDirectory:fe});return}ht(q,fe)},[ht]),Mt=l.useCallback(()=>{R&&(z(null),ht(R.source,R.targetDirectory))},[ht,R]),nt=l.useCallback((q,fe)=>!W||qp(q)?null:Qp(fe,null,a),[W,a]),Lt=l.useCallback(q=>{const fe=Er(q.dataTransfer);if(fe){const We=nt(q,fe);if(E(We),!We)return;q.preventDefault(),q.dataTransfer.dropEffect="move";return}!Ze||He||!a||!tr(q.dataTransfer)||(q.preventDefault(),q.dataTransfer.dropEffect="copy",T(a))},[Ze,nt,He,a]),_t=l.useCallback(q=>{if(!(q.relatedTarget instanceof Node&&q.currentTarget.contains(q.relatedTarget))){if(Er(q.dataTransfer)){E(null);return}tr(q.dataTransfer)&&T(null)}},[]),Tt=l.useCallback(q=>{const fe=Er(q.dataTransfer);if(fe){q.preventDefault(),E(null);const We=nt(q,fe);We&&Zp(q.dataTransfer,a,fe)&&it(fe,We);return}!Ze||He||!a||!tr(q.dataTransfer)||(q.preventDefault(),tt(a,q.dataTransfer))},[Ze,nt,tt,it,He,a]),Ae=l.useCallback(async q=>{if(q?.preventDefault(),!U||!K)return;Ce(!0);const fe=()=>Ce(!1),We=()=>se(null);if(K==="createFile"){if(!we.trim()){ze.error(s("sidebarFilesTree.toast.filenameRequired")),fe();return}if(!r.writeFile){ze.error(s("sidebarFilesTree.toast.writeNotSupported")),fe();return}const be=U.path,Ne=be?`${be}/`:"",mt=ls(`${Ne}${we.trim()}`);await r.writeFile(mt,"").then(async jt=>{jt.success&&(ze.success(s("sidebarFilesTree.toast.fileCreated")),await Ve(be)),We()}).catch(()=>ze.error(s("sidebarFilesTree.toast.operationFailed"))).finally(fe);return}if(K==="createFolder"){if(!we.trim()){ze.error(s("sidebarFilesTree.toast.folderNameRequired")),fe();return}const be=U.path,Ne=be?`${be}/`:"",mt=ls(`${Ne}${we.trim()}`);await r.createDirectory(mt).then(async jt=>{jt.success&&(ze.success(s("sidebarFilesTree.toast.folderCreated")),await Ve(be)),We()}).catch(()=>ze.error(s("sidebarFilesTree.toast.operationFailed"))).finally(fe);return}if(K==="rename"){if(!we.trim()){ze.error(s("sidebarFilesTree.toast.nameRequired")),fe();return}if(!r.rename){ze.error(s("sidebarFilesTree.toast.renameNotSupported")),fe();return}const be=U.path,Ne=be.split("/").slice(0,-1).join("/"),mt=Ne?`${Ne}/`:"",jt=we.trim(),At=ls(`${mt}${jt}`);try{const Ot=await Mc(r,a,be,At);Ot==="moved"?(ze.success(s("sidebarFilesTree.toast.renamedSuccessfully")),await Ve(Ne),We()):Ot==="conflict"?ze.error(s("sidebarFilesTree.toast.nameTaken",{name:jt,folder:mr(a,Ne)})):ze.error(s("sidebarFilesTree.toast.operationFailed"))}catch{ze.error(s("sidebarFilesTree.toast.operationFailed"))}finally{fe()}return}if(K==="delete"){if(!r.delete){ze.error(s("sidebarFilesTree.toast.deleteNotSupported")),fe();return}const be=U.path,Ne=be.split("/").slice(0,-1).join("/");await r.delete(be).then(async mt=>{mt.success&&(ze.success(s("sidebarFilesTree.toast.deletedSuccessfully")),await Ve(Ne),a&&me(a,be),(V===be||V&&V.startsWith(be+"/"))&&Ee(a,null)),We()}).catch(()=>ze.error(s("sidebarFilesTree.toast.operationFailed"))).finally(fe);return}fe()},[K,U,we,r,Ve,me,a,V,Ee,s]);function at(q,fe){return(C[q]??[]).map(be=>{const Ne=be.type==="directory",mt=Ne&&ee.has(be.path),jt=V===be.path;return n.jsxs("li",{"data-file-tree-path":Ne?void 0:be.path,children:[n.jsx(Wj,{node:be,root:a,isExpanded:mt,isActive:jt,isBrowserClient:o,depth:fe,isOpen:!Ne&&Ie.has(be.path),status:Ne?void 0:Me(be.path),badge:Ne?Pe(be.path):void 0,isDropTarget:Ne&&($e===be.path||D===be.path),isDragSource:O===be.path,canUpload:Ze&&!He,canMove:W,permissions:Ge,downloadFile:r.downloadFile,onSelect:ot,onToggle:et,onRevealPath:st,onOpenDialog:rt,onSetDropTarget:T,onDropFiles:tt,onPickFiles:_e,onMoveDragChange:bt,onSetMoveDropTarget:E,onMoveDrop:it}),Ne&&mt&&n.jsxs("ul",{className:"flex flex-col",children:[I[be.path]?n.jsxs("li",{className:"relative flex items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:qa(fe+1)},children:[n.jsx(Mu,{depth:fe+1}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:I[be.path],children:I[be.path]}),n.jsxs(It,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ve(be.path)},children:[n.jsx(Q,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):null,at(be.path,fe+1)]})]},be.path)})}l.useEffect(()=>{const q=ce.current,fe=ve.current;if(!q||!fe)return;const We=fe.querySelector(`[data-file-tree-path="${CSS.escape(q)}"]`);!We||We.offsetParent===null||(ce.current=null,We.scrollIntoView({block:"nearest"}))});const ut=!!(a&&C[a]),pt=a?I[a]:null,lt=x.trim().length>0,St=$e?mr(a,$e):"",ct=D?mr(a,D):"",oe=R?R.source.path.slice(R.source.path.lastIndexOf("/")+1):"";return n.jsxs("section",{ref:ve,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:[Oe||B||Ze?n.jsxs(Ts,{children:[n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Ds,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"sm",className:"size-6 p-0 flex-shrink-0","aria-label":s("sidebarFilesTree.actions.addMenuTitle"),children:n.jsx(Q,{name:He?"loader-4":"add",className:De("h-4 w-4",He&&"animate-spin")})})})})}),n.jsx(Ft,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.addMenuTitle")})]}),n.jsxs(Rs,{align:"end",className:"min-w-[180px]",children:[Oe?n.jsxs(Zt,{onClick:()=>rt("createFile",{path:c,type:"directory"}),children:[n.jsx(Q,{name:"file-add",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.newFile")]}):null,B?n.jsxs(Zt,{onClick:()=>rt("createFolder",{path:c,type:"directory"}),children:[n.jsx(Q,{name:"folder-add",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.newFolder")]}):null,Ze?n.jsxs(Zt,{disabled:!a||He,onClick:()=>_e(a),children:[n.jsx(Q,{name:"upload-2",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.uploadFiles")]}):null]})]}):null,n.jsx(j1,{className:"size-6"}),n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(It,{variant:"ghost",size:"sm",onClick:()=>{ge()},className:"size-6 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.refreshTitle"),"aria-label":s("sidebarFilesTree.actions.refreshTitle"),children:n.jsx(Q,{name:"refresh",className:"h-4 w-4"})})})}),n.jsx(Ft,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.refreshTitle")})]}),n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(It,{variant:"ghost",size:"sm",onClick:()=>{a&&le(a)},className:"size-6 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":s("sidebarFilesTree.actions.collapseAllTitle"),children:n.jsx(Q,{name:"collapse-vertical",className:"h-4 w-4"})})})}),n.jsx(Ft,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.collapseAllTitle")})]})]}),n.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[n.jsx(Q,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),n.jsx(To,{ref:b,value:y,onChange:q=>v(q.target.value),placeholder:s("sidebarFilesTree.search.placeholder"),className:"h-8 ps-8 pe-8 typography-meta"}),y.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(""),b.current?.focus()},children:n.jsx(Q,{name:"close",className:"h-4 w-4"})}):null]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsx(Or,{outerClassName:"h-full min-h-0",className:De("px-1.5 py-1.5",($e===a||D===a)&&"bg-interactive-selection/10"),onDragEnter:Lt,onDragOver:Lt,onDragLeave:_t,onDrop:Tt,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(Q,{name:"loader-4",className:"h-4 w-4 animate-spin"}),s("sidebarFilesTree.state.searching")]}):lt&&h.length===0?n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:s("mobile.files.search.empty")}):h.length>0?h.map(q=>{const fe=V===q.path;return n.jsx("li",{"data-file-tree-path":q.path,children:n.jsxs("button",{type:"button",onClick:()=>ot(q),onDoubleClick:()=>ot(q,{pin:!0}),draggable:!0,onDragStart:We=>{Up(We),fd(null);const be=q.relativePath||ci(a??"",q.path);!be||be==="."||(We.dataTransfer.setData(ni,be),We.dataTransfer.effectAllowed="copy")},onDragEnd:We=>{Gp(We)&&ot(q)},className:De("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",Nu(fe)),title:q.path,children:[n.jsx(ol,{filePath:q.path,extension:q.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:`${q.relativePath??q.path}`})]})},q.path)}):pt?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:pt}),n.jsxs(It,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ge()},children:[n.jsx(Q,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):ut&&a?at(a,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:s("sidebarFilesTree.state.loading")})})}),$e?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(Q,{name:He?"loader-4":"folder-received",className:De("size-4 flex-shrink-0",He&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:St,children:s(He?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:St})})]}):D?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(Q,{name:"folder-received",className:"size-4 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:ct,children:s("sidebarFilesTree.drop.moveTarget",{path:ct})})]}):null]}),Le,n.jsx(Ys,{open:!!K,onOpenChange:q=>!q&&se(null),children:n.jsxs(qs,{children:[n.jsxs(en,{children:[n.jsxs(Zs,{children:[K==="createFile"&&s("sidebarFilesTree.dialog.createFile.title"),K==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.title"),K==="rename"&&s("sidebarFilesTree.dialog.rename.title"),K==="delete"&&s("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(Js,{children:[K==="createFile"&&s("sidebarFilesTree.dialog.createFile.description",{path:U?.path??s("sidebarFilesTree.dialog.rootFallback")}),K==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.description",{path:U?.path??s("sidebarFilesTree.dialog.rootFallback")}),K==="rename"&&s("sidebarFilesTree.dialog.rename.description",{name:U?.name??""}),K==="delete"&&s("sidebarFilesTree.dialog.delete.description",{name:U?.name??""})]})]}),K!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(To,{value:we,onChange:q=>pe(q.target.value),placeholder:s(K==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:q=>{q.key==="Enter"&&Ae()},autoFocus:!0})}),n.jsxs(Cn,{children:[n.jsx(It,{variant:"outline",onClick:()=>se(null),disabled:Se,children:s("sidebarFilesTree.dialog.cancel")}),n.jsx(It,{variant:K==="delete"?"destructive":"default",onClick:()=>{Ae()},disabled:Se||K!=="delete"&&!we.trim(),children:Se?n.jsx(Q,{name:"loader-4",className:"size-4 animate-spin"}):s(K==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),n.jsx(Ys,{open:R!==null,onOpenChange:q=>{q||z(null)},children:n.jsxs(qs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(en,{children:[n.jsx(Zs,{children:s("sidebarFilesTree.dialog.move.title")}),n.jsx(Js,{children:R?s("sidebarFilesTree.dialog.move.description",{name:oe,folder:mr(a,R.targetDirectory)}):null})]}),n.jsxs(Cn,{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:()=>Y(!N),children:[n.jsx(fx,{checked:!N,onChange:q=>Y(!q),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(It,{variant:"ghost",onClick:()=>z(null),children:s("sidebarFilesTree.dialog.cancel")}),n.jsx(It,{onClick:Mt,children:s("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function Uj(t){return t.runtimeKey}const Gj=Br(()=>os(()=>import("./WalkthroughView-B2BJJ4u5.js"),__vite__mapDeps([125,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,126,84,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,127,87,116,117,118,119,120,121,122,123,124])).then(t=>({default:t.WalkthroughView}))),qj=Br(()=>os(()=>import("./DiffView-B5yeuxv8.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,126,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,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,129,87,116,117,118,119,120,121,86,122,123,124])).then(t=>({default:t.DiffView}))),Yj=Br(()=>os(()=>import("./FilesView-ni2zfAwL.js"),__vite__mapDeps([130,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,131,132,133,134,123,135,119,84,136,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,137,138,139,140,120,121,118,141,142])).then(t=>({default:t.FilesView}))),Jp=l.lazy(()=>os(()=>import("./useAppFontEffects-Cs6k0JKv.js").then(t=>t.nD),__vite__mapDeps([3,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>({default:t.PluginPane}))),hd=l.lazy(()=>os(()=>import("./GuestSurfacePane-D1gLktSj.js"),__vite__mapDeps([143,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>({default:t.GuestSurfacePane}))),eh={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}},Xj=t=>{const e=Xe.c(12),{mode:s,docking:r}=t,[i,o]=l.useState(null),c=eh[r.dock],a=Math.max(gx,i??r.size),d=c.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==c.page||e[1]!==d?(u=De("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,c.page),e[0]=c.page,e[1]=d,e[2]=u):u=e[2];let f;e[3]!==c.vertical||e[4]!==a?(f=c.vertical?{height:a}:{width:a},e[3]=c.vertical,e[4]=a,e[5]=f):f=e[5];let p;e[6]!==s?(p=n.jsx(Jp,{mode:s,onResize:o}),e[6]=s,e[7]=p):p=e[7];let m;return e[8]!==u||e[9]!==f||e[10]!==p?(m=n.jsx("div",{className:u,style:f,children:p}),e[8]=u,e[9]=f,e[10]=p,e[11]=m):m=e[11],m},Qj=({visible:t,active:e,fill:s=!1,side:r})=>{const{t:i}=Ct(),o=de(S=>S.contextEditorTreeWidth),c=de(S=>S.setContextEditorTreeWidth),[a,d]=l.useState(!1),u=l.useRef(0),f=l.useRef(o),p=l.useRef(null),m=l.useRef(null),g=l.useRef(null),y=l.useCallback(S=>{const w=g.current;w&&(w.style.width=`${S}px`,w.style.setProperty("--oc-editor-tree-width",`${S}px`))},[]),v=S=>{if(t){try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}m.current=S.pointerId,d(!0),u.current=S.clientX,f.current=o,p.current=o,S.preventDefault()}},x=S=>{if(!a||m.current!==S.pointerId)return;const w=r==="left"?S.clientX-u.current:u.current-S.clientX,j=Uo(S.currentTarget)?-w:w,k=ta(f.current+j);p.current!==k&&(p.current=k,y(k))},b=S=>{if(m.current!==S.pointerId)return;try{S.currentTarget.releasePointerCapture(S.pointerId)}catch{}const w=ta(p.current??o);m.current=null,p.current=null,d(!1),c(w)},h=t?o:0;return n.jsxs("div",{ref:g,className:De("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:`${a?p.current??h:h}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${a?p.current??o:o}px`,overflowX:"clip",transitionProperty:a?"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:De("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:De("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",a&&"bg-[var(--interactive-border)]"),onPointerDown:v,onPointerMove:x,onPointerUp:b,onPointerCancel:b,role:"separator","aria-orientation":"vertical","aria-label":i("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:De("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",a&&"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(Hj,{visible:t&&e})})]})},Mn=t=>{const e=Xe.c(12),{zone:s,isOpen:r,directoryKey:i,className:o,children:c}=t,a=de(Jj);let d;e[0]!==a||e[1]!==i||e[2]!==r||e[3]!==s?(d=m=>{pp(m,r,()=>{i&&a(i,s)},m.currentTarget.closest("[data-context-zone]"))},e[0]=a,e[1]=i,e[2]=r,e[3]=s,e[4]=d):d=e[4];const u=d;let f;e[5]!==c||e[6]!==o||e[7]!==u?(f=n.jsx("div",{className:o,onKeyDownCapture:u,children:c}),e[5]=c,e[6]=o,e[7]=u,e[8]=f):f=e[8];let p;return e[9]!==f||e[10]!==s?(p=n.jsx(Cj,{zone:s,children:f}),e[9]=f,e[10]=s,e[11]=p):p=e[11],p},Zj=()=>{const{t}=Ct(),e=hn()??"",s=l.useMemo(()=>e?Ps(e):"",[e]),r=de(K=>s?K.contextPanelByDirectory[s]:void 0),i=de(K=>K.contextSurfaceZones),o=de(K=>K.contextPanelByDirectory),c=de(K=>K.closeContextPanelTab),a=de(K=>K.closeContextFile),d=de(K=>K.openContextPanelTab),u=de(K=>K.openAgentBrowserTab),f=de(K=>K.openContextFile),p=de(K=>K.contextEditorTreeVisible),m=de(K=>K.contextEditorVisible),g=de(K=>K.fileTreeSide),y=Vs(K=>K.setSelectedPath),v=Rr(K=>K.headerSlot),x=l.useMemo(()=>r?.tabs??[],[r?.tabs]),b=ca(K=>K.chatCovered),h=l.useMemo(()=>{const K=se=>{const U=r?ko(r,i,se):null,ie=se==="bottom"&&b;return{activeTab:U,isOpen:!!(r&&qo(r,se).isOpen&&U)&&!ie}};return{left:K("left"),right:K("right"),bottom:K("bottom")}},[b,r,i]),S={left:Cr(h.left.isOpen),right:Cr(h.right.isOpen),bottom:Cr(h.bottom.isOpen)},w=K=>!S[K],j=K=>{const se=Po(i,K);return{zone:se,...h[se]}},k=j("file"),T=j("chat"),O=j("browser"),$=j("diff"),D=j("terminal"),E=j("walkthrough"),[R,z]=l.useState(()=>new Set),_=l.useCallback(K=>{z(se=>se.has(K)?se:new Set(se).add(K))},[]);l.useEffect(()=>Z0((K,se)=>{const U=se.directory?Ps(se.directory):s;if(!U)return null;const ie=u(U,K,se.sessionId);return ie&&_(ie),ie}),[s,u,_]),l.useEffect(()=>Pn(K=>{if(K.type!=="file-open-request")return;const se=K.directory??e;se&&f(se,K.path)}),[e,f]),l.useEffect(()=>Pn(K=>{if(K.type!=="plan-open-request")return;const se=K.directory??e,U=rb(se,K.projectId);!se||!U||de.getState().openProjectKnowledgePlan(se,px(U),K.planId)}),[e]);const W=O.activeTab?.mode==="browser"?O.activeTab.id:null;l.useEffect(()=>{Q0(s,W)},[s,W]);const N=k.activeTab;l.useEffect(()=>{!s||N?.mode!=="file"||!N.targetPath||y(s,N.targetPath,{allowOutsideRoot:!0})},[s,N,y]);const Y=l.useMemo(()=>x.some(K=>K.mode==="file"&&K.targetPath),[x]),C=l.useMemo(()=>x.some(K=>K.mode==="file"),[x]),P=Y&&(m||!p),I=k.activeTab?.mode==="file",H=l.useCallback(K=>{s&&a(s,K)},[a,s]),A=T.isOpen&&T.activeTab?.mode==="chat"?T.activeTab:null,F=A?yl(A.dedupeKey):null,L=l.useMemo(()=>(A?.targetDirectory?Ps(A.targetDirectory):"")||s||null,[A?.targetDirectory,s]),X=l.useMemo(()=>F?{sessionId:F,directory:L}:null,[F,L]);l.useEffect(()=>{if(!L||!F||typeof window>"u")return;const K=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Di(L,F,!1);return}Sf(F),Di(L,F,!0)};K();const se=window.setInterval(K,1e4);return window.addEventListener("focus",K),window.addEventListener("blur",K),document.addEventListener("visibilitychange",K),()=>{window.clearInterval(se),window.removeEventListener("focus",K),window.removeEventListener("blur",K),document.removeEventListener("visibilitychange",K),Di(L,F,!1)}},[L,F]);const re=$.activeTab,te=l.useCallback(K=>{!s||re?.mode!=="diff"||d(s,{mode:"diff",targetPath:re.targetPath,stagedDiff:K==="staged",diffScope:K})},[re,s,d]),M=O.isOpen&&O.activeTab?.mode==="browser"?O.activeTab.id:null;l.useEffect(()=>{M&&_(M)},[M,_]);const{loadedBrowserTabs:ee,sleepingBrowserTabs:V}=l.useMemo(()=>{const K=[],se=[];for(const[ie,we]of Object.entries(o)){const pe=ie===s;for(const Se of we.tabs){if(Se.mode!=="browser"||!pe&&Se.ownerSessionId===null)continue;const Ce={directory:ie,id:Se.id,targetPath:Se.targetPath,ownerSessionId:Se.ownerSessionId};(R.has(Se.id)||pe&&Se.id===M?K:se).push(Ce)}}const U=ie=>`${ie.directory}\0${ie.id}`;return K.sort((ie,we)=>U(ie)<U(we)?-1:1),{loadedBrowserTabs:K,sleepingBrowserTabs:se}},[o,s,M,R]);l.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const K=V.map(se=>X0({tabId:se.id,directory:se.directory,ownerSessionId:se.ownerSessionId,describe:()=>({title:"",url:se.targetPath??""}),wake:()=>_(se.id)}));return()=>K.forEach(se=>se())},[V,_]);const Ee=l.useMemo(()=>x.filter(K=>K.mode==="diff"),[x]),ve=l.useMemo(()=>x.find(K=>K.mode==="terminal")??null,[x]),ce=l.useMemo(()=>x.some(K=>K.mode==="walkthrough"),[x]),Be=l.useMemo(()=>x.filter(K=>rr(K.mode)),[x]),me=el(K=>K.guests),he=l.useMemo(()=>new Set(me.filter(hx).map(K=>K.id)),[me]),G=l.useMemo(()=>{const K=new Map;for(const se of me){const U=mx(se);U&&K.set(se.id,U)}return K},[me]),le=D.zone,ye=l.useCallback(K=>{const se=Sl({mode:"terminal",label:t("layout.mainTab.terminal"),from:le},K);return{finish:()=>se.finish(s),cancel:se.cancel}},[s,t,le]),Ie=(K,se)=>se?v[K]:null;return n.jsxs(n.Fragment,{children:[C?n.jsxs(Mn,{zone:k.zone,isOpen:k.isOpen,directoryKey:s,className:De("absolute inset-0 flex",g==="left"&&"flex-row-reverse",I?"flex":"hidden"),children:[Y||!p?n.jsx("div",{className:De("h-full min-w-0 flex-1",Y&&!P&&"hidden"),children:Y?n.jsx(l.Suspense,{fallback:null,children:n.jsx(Yj,{mode:"editor-only",visible:!w(k.zone)&&I&&P,onCloseFile:H})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx(Q,{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(Qj,{visible:p,active:k.isOpen&&I,fill:!P,side:g})]}):null,A&&F&&X?n.jsx(Mn,{zone:T.zone,isOpen:T.isOpen,directoryKey:s,className:"absolute inset-0 bg-background",children:n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:F}),className:"h-full",children:n.jsx(Au,{pinnedSession:X,readOnly:A.readOnly})})},A.id):null,ee.map(K=>{const se=K.directory===s&&O.activeTab?.id===K.id;return n.jsx(Mn,{zone:O.zone,isOpen:O.isOpen,directoryKey:s,className:De("absolute inset-0",!se&&"invisible pointer-events-none"),children:n.jsx("div",{className:"h-full","aria-hidden":!se||void 0,children:n.jsx(Sj,{initialUrl:K.targetPath??"",directory:K.directory,tabID:K.id,ownerSessionId:K.ownerSessionId,visible:se&&O.isOpen})})},`${K.directory}\0${K.id}`)}),Ee.map(K=>{const se=$.activeTab?.id===K.id;return n.jsx(Mn,{zone:$.zone,isOpen:$.isOpen,directoryKey:s,className:De("absolute inset-0",!se&&"hidden"),children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(Zn,{value:Ie($.zone,se),children:n.jsx(qj,{visible:$.isOpen&&se,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:K.diffScope??(K.stagedDiff?"staged":null),onDiffScopeChange:te,targetFilePath:K.targetPath,flushContent:!0})})})},K.id)}),ve?n.jsx(Mn,{zone:D.zone,isOpen:D.isOpen,directoryKey:s,className:De("absolute inset-0",D.activeTab?.mode==="terminal"?"block":"hidden"),children:n.jsx(Zn,{value:Ie(D.zone,D.activeTab?.mode==="terminal"),children:n.jsx(ob.Provider,{value:ye,children:n.jsx(ib,{visible:D.isOpen&&D.activeTab?.mode==="terminal",directory:ve.targetDirectory,onLastTabClosed:()=>{s&&c(s,ve.id)}})})})}):null,ce?n.jsx(Mn,{zone:E.zone,isOpen:E.isOpen,directoryKey:s,className:De("absolute inset-0",E.activeTab?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(Zn,{value:Ie(E.zone,E.activeTab?.mode==="walkthrough"),children:n.jsx(Gj,{directory:e,visible:E.isOpen&&E.activeTab?.mode==="walkthrough"})})})}):null,Be.map(K=>{if(!rr(K.mode))return null;const se=j(K.mode),U=jo(K.mode),ie=he.has(U),we=G.get(U),pe=se.activeTab?.id===K.id,Se=pe&&se.isOpen;return ie&&!we&&!Se?null:n.jsx(Mn,{zone:se.zone,isOpen:se.isOpen,directoryKey:s,className:De("absolute inset-0",pe?"block":"hidden"),children:n.jsx(l.Suspense,{fallback:null,children:ie?we?n.jsxs("div",{className:De("flex h-full",eh[we.dock].container),children:[n.jsx(Xj,{mode:K.mode,docking:we}),n.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Se?n.jsx(hd,{mode:K.mode}):null})]}):n.jsx(hd,{mode:K.mode}):n.jsx(Jp,{mode:K.mode})})},K.id)})]})};function Jj(t){return t.closeContextZone}const e2={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},t2=()=>{const t=Xe.c(20),{t:e}=Ct(),s=pn(s2),r=pn(n2),i=l.useRef(null),[o,c]=l.useState(!1);let a,d;t[0]!==s?(a=()=>{if(!s){c(!1);return}const b=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(b)},d=[s],t[0]=s,t[1]=a,t[2]=d):(a=t[1],d=t[2]),l.useEffect(a,d);let u,f;if(t[3]!==s?(u=()=>{if(!s)return;const b=h=>{const S=i.current;S&&(S.style.transform=`translate(${h.clientX+12}px, ${h.clientY+12}px)`)};return window.addEventListener("pointermove",b),()=>window.removeEventListener("pointermove",b)},f=[s],t[3]=s,t[4]=u,t[5]=f):(u=t[4],f=t[5]),l.useEffect(u,f),!s)return null;const p=o?"opacity-100":"opacity-0";let m;t[6]!==p?(m=De("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",p),t[6]=p,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 y;t[10]!==s.frames||t[11]!==r||t[12]!==e?(y=Qm.map(b=>{const h=s.frames[b];if(h.width<=0||h.height<=0)return null;const S=r===b;return n.jsx("div",{className:De("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",S?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:h.left,top:h.top,width:h.width,height:h.height},children:n.jsx("span",{className:"typography-ui-label",children:e(e2[b])})},b)}),t[10]=s.frames,t[11]=r,t[12]=e,t[13]=y):y=t[13];let v;t[14]!==s.label?(v=n.jsx("div",{ref:i,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 x;return t[16]!==g||t[17]!==y||t[18]!==v?(x=Wa.createPortal(n.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[g,y,v]}),document.body),t[16]=g,t[17]=y,t[18]=v,t[19]=x):x=t[19],x};function s2(t){return t.drag}function n2(t){return t.hovered}const md=400,r2=({rowWidth:t,leftWidth:e,rightWidth:s,sidebarWidth:r,opening:i})=>{let o=t-e-s;if(o>=md)return{collapseSidebar:!1,displace:null};const c=r!==null;if(c&&(o+=r),o>=md)return{collapseSidebar:c,displace:null};const a=i==="left"?"right":"left";return{collapseSidebar:c,displace:(a==="left"?e:s)>0?a:null}},o2=()=>{const t=Xe.c(5),e=hn();let s;t[0]!==e?(s=e?Ps(e):"",t[0]=e,t[1]=s):s=t[1];const r=s,i=l.useRef(null);let o,c;return t[2]!==r?(o=()=>{if(!r)return;const a=x=>{const b=x.contextPanelByDirectory[r];return{left:vr(b,x.contextSurfaceZones,"left"),right:vr(b,x.contextSurfaceZones,"right")}},d=(x,b,h)=>{const S=x.contextPanelByDirectory[r],w=h&&S?ko(S,x.contextSurfaceZones,b):null;return w?S?.widthByMode[w.mode]??da(w.mode):0};let u=null,f=!1,p=a(de.getState());const m=x=>{f=!0,de.getState().setSidebarOpen(x),f=!1},g=i.current;g&&!p[g]&&(i.current=null,de.getState().isSidebarOpen||m(!0));const y=(x,b,h)=>{const S=document.querySelector("[data-workspace-row]")?.clientWidth;if(!S)return;const w=r2({rowWidth:S,leftWidth:d(x,"left",h.left),rightWidth:d(x,"right",h.right),sidebarWidth:x.isSidebarOpen?x.sidebarWidth:null,opening:b});if(w.displace){const j=qo(x.contextPanelByDirectory[r],w.displace).activeTabId;j&&(u={side:w.displace,by:b,tabId:j})}w.collapseSidebar&&(i.current=b,m(!1)),w.displace&&x.closeContextZone(r,w.displace)},v=x=>{if(u?.side===x){i.current===x&&(i.current=u.by);return}const b=u?.by===x?u:null;b&&(u=null),i.current===x&&(b?i.current=b.side:(i.current=null,de.getState().isSidebarOpen||m(!0))),b&&de.getState().setActiveContextPanelTab(r,b.tabId)};return de.subscribe((x,b)=>{x.isSidebarOpen!==b.isSidebarOpen&&!f&&(i.current=null);const h=a(x),S=p;p=h;const w=["left","right"],j=w.filter(T=>h[T]&&!S[T]),k=w.filter(T=>!h[T]&&S[T]);for(const T of k){const O=T==="left"?"right":"left";j.includes(O)&&(i.current===T&&(i.current=O),u?.by===T&&(u=null))}for(const T of k)v(T);for(const T of j)y(x,T,h)})},c=[r],t[2]=r,t[3]=o,t[4]=c):(o=t[3],c=t[4]),l.useEffect(o,c),null},i2=t=>{const e=Xe.c(29),{surfaceId:s,label:r,checked:i,onChange:o}=t,{t:c}=Ct();let a;e[0]!==s?(a={id:s},e[0]=s,e[1]=a):a=e[1];const{attributes:d,listeners:u,setNodeRef:f,setActivatorNodeRef:p,transform:m,transition:g,isDragging:y}=Wr(a);let v;e[2]!==m?(v=Hr.Translate.toString(m),e[2]=m,e[3]=v):v=e[3];let x;e[4]!==v||e[5]!==g?(x={transform:v,transition:g},e[4]=v,e[5]=g,e[6]=x):x=e[6];const b=y&&"z-10 opacity-60";let h;e[7]!==b?(h=De("relative flex items-center gap-2",b),e[7]=b,e[8]=h):h=e[8];let S;e[9]!==r||e[10]!==c?(S=c("contextRail.configure.reorder",{label:r}),e[9]=r,e[10]=c,e[11]=S):S=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Q,{name:"draggable",className:"size-4"}),e[12]=w):w=e[12];let j;e[13]!==d||e[14]!==u||e[15]!==p||e[16]!==S?(j=n.jsx(It,{ref:p,variant:"ghost",size:"icon",...d,...u,"aria-label":S,className:"shrink-0 touch-none select-none cursor-grab text-muted-foreground hover:bg-transparent active:cursor-grabbing",children:w}),e[13]=d,e[14]=u,e[15]=p,e[16]=S,e[17]=j):j=e[17];const k=`layout.context-rail.surface.${s}`;let T;e[18]!==i||e[19]!==r||e[20]!==o||e[21]!==k?(T=n.jsx(bx,{settingsItem:k,checked:i,onChange:o,label:r,ariaLabel:r,className:"min-w-0 flex-1"}),e[18]=i,e[19]=r,e[20]=o,e[21]=k,e[22]=T):T=e[22];let O;return e[23]!==f||e[24]!==T||e[25]!==x||e[26]!==h||e[27]!==j?(O=n.jsxs("div",{ref:f,style:x,className:h,children:[j,T]}),e[23]=f,e[24]=T,e[25]=x,e[26]=h,e[27]=j,e[28]=O):O=e[28],O},a2=t=>{const e=Xe.c(86),{open:s,onOpenChange:r}=t,{t:i}=Ct(),o=de(l2),c=de(c2),a=de(d2),d=de(u2),u=de(f2),f=il();let p;e[0]!==o||e[1]!==f?(p=vf(o,f),e[0]=o,e[1]=f,e[2]=p):p=e[2];const m=p,g=a.length===0;let y;if(e[3]!==a||e[4]!==m){let me;e[6]!==a?(me=he=>a.includes(he.id),e[6]=a,e[7]=me):me=e[7],y=m.every(me),e[3]=a,e[4]=m,e[5]=y}else y=e[5];const v=y,x=l.useRef(!1);let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b={activationConstraint:{distance:8}},e[8]=b):b=e[8];let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={activationConstraint:{delay:200,tolerance:6}},e[9]=h):h=e[9];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S={coordinateGetter:Jf},e[10]=S):S=e[10];const w=Lr(zs($r,b),zs(_r,h),zs(Zf,S));let j;e[11]!==o||e[12]!==c||e[13]!==m?(j=me=>{const{active:he,over:G}=me;if(x.current=!1,!G||he.id===G.id)return;const le=m.findIndex(se=>se.id===he.id),ye=m.findIndex(se=>se.id===G.id);if(le<0||ye<0)return;const Ie=ml(m,le,ye).map(p2),K=new Set(Ie);c([...Ie,...o.filter(se=>!K.has(se))])},e[11]=o,e[12]=c,e[13]=m,e[14]=j):j=e[14];const k=j;let T;e[15]!==m||e[16]!==i?(T=(me,he)=>{const G=he===void 0?me:he,le=m.find(ye=>ye.id===me);if(le)return i("contextRail.configure.position",{label:le.label??i(le.labelKey),position:m.findIndex(ye=>ye.id===G)+1,count:m.length})},e[15]=m,e[16]=i,e[17]=T):T=e[17];const O=T;let $,D;e[18]!==O?($=me=>{const{active:he}=me;return O(he.id)},D=me=>{const{active:he,over:G}=me;return G?O(he.id,G.id):void 0},e[18]=O,e[19]=$,e[20]=D):($=e[19],D=e[20]);let E;e[21]!==O||e[22]!==i?(E=me=>{const{active:he,over:G}=me;return G?O(he.id,G.id):i("contextRail.configure.dragCancelled")},e[21]=O,e[22]=i,e[23]=E):E=e[23];let R;e[24]!==i?(R=()=>i("contextRail.configure.dragCancelled"),e[24]=i,e[25]=R):R=e[25];let z;e[26]!==E||e[27]!==R||e[28]!==$||e[29]!==D?(z={onDragStart:$,onDragOver:D,onDragEnd:E,onDragCancel:R},e[26]=E,e[27]=R,e[28]=$,e[29]=D,e[30]=z):z=e[30];const _=z;let W;e[31]!==i?(W=i("contextRail.configure.dragInstructions"),e[31]=i,e[32]=W):W=e[32];let N;e[33]!==W?(N={draggable:W},e[33]=W,e[34]=N):N=e[34];let Y;e[35]!==_||e[36]!==N?(Y={screenReaderInstructions:N,announcements:_},e[35]=_,e[36]=N,e[37]=Y):Y=e[37];const C=Y;let P;e[38]!==r?(P=(me,he)=>{if(!me&&he.reason==="escape-key"&&x.current){he.cancel(),he.allowPropagation();return}x.current=!1,r(me)},e[38]=r,e[39]=P):P=e[39];let I;e[40]===Symbol.for("react.memo_cache_sentinel")?(I=me=>{x.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(me.key)&&me.preventBaseUIHandler()},e[40]=I):I=e[40];let H;e[41]!==i?(H=i("contextRail.configure.dialogTitle"),e[41]=i,e[42]=H):H=e[42];let A;e[43]!==H?(A=n.jsx(Zs,{children:H}),e[43]=H,e[44]=A):A=e[44];let F;e[45]!==i?(F=i("contextRail.configure.dialogDescription"),e[45]=i,e[46]=F):F=e[46];let L;e[47]!==F?(L=n.jsx(Js,{children:F}),e[47]=F,e[48]=L):L=e[48];let X;e[49]!==A||e[50]!==L?(X=n.jsxs(en,{children:[A,L]}),e[49]=A,e[50]=L,e[51]=X):X=e[51];let re,te;e[52]===Symbol.for("react.memo_cache_sentinel")?(re=()=>{x.current=!0},te=()=>{x.current=!1},e[52]=re,e[53]=te):(re=e[52],te=e[53]);let M;if(e[54]!==a||e[55]!==d||e[56]!==m||e[57]!==i){let me;e[59]!==a||e[60]!==d||e[61]!==i?(me=he=>n.jsx(i2,{surfaceId:he.id,checked:!a.includes(he.id),onChange:G=>d(he.id,G),label:he.label??i(he.labelKey)},he.id),e[59]=a,e[60]=d,e[61]=i,e[62]=me):me=e[62],M=m.map(me),e[54]=a,e[55]=d,e[56]=m,e[57]=i,e[58]=M}else M=e[58];let ee;e[63]!==M?(ee=n.jsx("div",{className:"flex flex-col",children:M}),e[63]=M,e[64]=ee):ee=e[64];let V;e[65]!==m||e[66]!==ee?(V=n.jsx(ii,{items:m,strategy:gl,children:ee}),e[65]=m,e[66]=ee,e[67]=V):V=e[67];let Ee;e[68]!==C||e[69]!==k||e[70]!==w||e[71]!==V?(Ee=n.jsx(zr,{sensors:w,collisionDetection:Kr,onDragStart:re,onDragCancel:te,onDragEnd:k,accessibility:C,children:V}),e[68]=C,e[69]=k,e[70]=w,e[71]=V,e[72]=Ee):Ee=e[72];let ve;e[73]!==g||e[74]!==v||e[75]!==u||e[76]!==i?(ve=g?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[v?n.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(It,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[73]=g,e[74]=v,e[75]=u,e[76]=i,e[77]=ve):ve=e[77];let ce;e[78]!==X||e[79]!==Ee||e[80]!==ve?(ce=n.jsxs(qs,{className:"max-w-md",onKeyDown:I,children:[X,Ee,ve]}),e[78]=X,e[79]=Ee,e[80]=ve,e[81]=ce):ce=e[81];let Be;return e[82]!==s||e[83]!==P||e[84]!==ce?(Be=n.jsx(Ys,{open:s,onOpenChange:P,children:ce}),e[82]=s,e[83]=P,e[84]=ce,e[85]=Be):Be=e[85],Be};function l2(t){return t.contextRailOrder}function c2(t){return t.setContextRailOrder}function d2(t){return t.contextRailHiddenSurfaces}function u2(t){return t.setContextRailSurfaceVisible}function f2(t){return t.setContextRailHiddenSurfaces}function p2(t){return t.id}const h2=t=>{const e=mf(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},m2=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,th=()=>{const t=Xe.c(4),e=xt(y2),s=xt(x2)??void 0,r=xx(e??"",s,h2,m2),{context:i}=Sx(e,s),o=i>0?i:vx;let c;return t[0]!==r||t[1]!==o||t[2]!==e?(c={sessionId:e,fill:r,limit:o},t[0]=r,t[1]=o,t[2]=e,t[3]=c):c=t[3],c},gd=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),an=18,Na=2,Ma=(an-Na)/2,bd=2*Math.PI*Ma,g2=t=>{const e=Xe.c(8),{className:s}=t,{fill:r,limit:i}=th(),o=r?.state==="measured"?Math.min(100,r.totalTokens/i*100):0;let c;e[0]!==s?(c=De("shrink-0",s),e[0]=s,e[1]=c):c=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("circle",{cx:an/2,cy:an/2,r:Ma,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:Na}),e[2]=a):a=e[2];let d;e[3]!==o?(d=o>0?n.jsx("circle",{cx:an/2,cy:an/2,r:Ma,fill:"none",stroke:"currentColor",strokeWidth:Na,strokeLinecap:"round",strokeDasharray:bd,strokeDashoffset:bd*(1-o/100),transform:`rotate(-90 ${an/2} ${an/2})`}):null,e[3]=o,e[4]=d):d=e[4];let u;return e[5]!==c||e[6]!==d?(u=n.jsxs("svg",{viewBox:`0 0 ${an} ${an}`,className:c,"aria-hidden":"true",children:[a,d]}),e[5]=c,e[6]=d,e[7]=u):u=e[7],u},b2=()=>{const t=Xe.c(16),{t:e}=Ct(),{sessionId:s,fill:r,limit:i}=th(),{totalCost:o}=yx(s);if(!s||!r)return null;let c;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(c=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:gd(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=c):c=t[3];let a;t[4]!==i||t[5]!==e?(a=e("contextUsage.tooltip.contextLimit",{tokens:gd(i)}),t[4]=i,t[5]=e,t[6]=a):a=t[6];let d;t[7]!==e||t[8]!==o?(d=o!==null&&o>0?[e("contextUsage.tooltip.cost",{cost:Qf(o)})]:[],t[7]=e,t[8]=o,t[9]=d):d=t[9];let u;t[10]!==c||t[11]!==a||t[12]!==d?(u=[c,a,...d],t[10]=c,t[11]=a,t[12]=d,t[13]=u):u=t[13];const f=u;let p;return t[14]!==f?(p=n.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-border/60 pt-1 tabular-nums",children:f.map(S2)}),t[14]=f,t[15]=p):p=t[15],p};function y2(t){return t.currentSessionId}function x2(t){return t.currentSessionDirectory}function S2(t){return n.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const sh=150,v2=500,w2=[],k2=t=>t>99?"99+":String(t),j2=t=>{const e=Xe.c(62),{surface:s,isActive:r,showActivityDot:i,label:o,description:c,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:f,showOrderNumber:p,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:y,listeners:v,setNodeRef:x,transform:b,transition:h,isDragging:S}=Wr(g);let w;e[2]!==a?(w=a!=null&&a>0?k2(a):null,e[2]=a,e[3]=w):w=e[3];const j=w;let k;e[4]!==b?(k=Hr.Translate.toString(b),e[4]=b,e[5]=k):k=e[5];let T;e[6]!==k||e[7]!==h?(T={transform:k,transition:h},e[6]=k,e[7]=h,e[8]=T):T=e[8];const O=S&&"z-10 opacity-70";let $;e[9]!==O?($=De("relative",O),e[9]=O,e[10]=$):$=e[10];let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx("div",{}),e[11]=D):D=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 R=d??o,z=s.id,_=r?"text-primary":"text-muted-foreground hover:text-foreground";let W;e[15]!==_?(W=De("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",_),e[15]=_,e[16]=W):W=e[16];let N;e[17]!==s.icon||e[18]!==s.iconSrc||e[19]!==s.id?(N=s.id==="diff"?n.jsx(Du,{className:"h-[18px] w-[18px]"}):s.id==="context"?n.jsx(g2,{className:"h-[18px] w-[18px]"}):n.jsx(ur,{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]=N):N=e[20];let Y;e[21]!==j||e[22]!==f||e[23]!==i||e[24]!==p?(Y=p&&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}):i?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]=i,e[24]=p,e[25]=Y):Y=e[25];let C;e[26]!==y||e[27]!==r||e[28]!==v||e[29]!==s.id||e[30]!==W||e[31]!==N||e[32]!==Y||e[33]!==E||e[34]!==R?(C=n.jsx(zt,{asChild:!0,children:n.jsxs("button",{type:"button",...y,...v,onClick:E,"aria-label":R,"aria-pressed":r,"data-context-surface":z,className:W,children:[N,Y]})}),e[26]=y,e[27]=r,e[28]=v,e[29]=s.id,e[30]=W,e[31]=N,e[32]=Y,e[33]=E,e[34]=R,e[35]=C):C=e[35];let P;e[36]!==o?(P=n.jsx("span",{children:o}),e[36]=o,e[37]=P):P=e[37];let I;e[38]!==c?(I=n.jsx("span",{className:"typography-micro text-muted-foreground",children:c}),e[38]=c,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 A;e[42]!==s.id?(A=s.id==="context"?n.jsx(b2,{}):null,e[42]=s.id,e[43]=A):A=e[43];let F;e[44]!==P||e[45]!==I||e[46]!==H||e[47]!==A?(F=n.jsx(Ft,{side:"left",sideOffset:8,children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[P,I,H,A]})}),e[44]=P,e[45]=I,e[46]=H,e[47]=A,e[48]=F):F=e[48];let L;e[49]!==C||e[50]!==F?(L=n.jsx(ll,{render:D,children:n.jsxs(Kt,{delayDuration:sh,children:[C,F]})}),e[49]=C,e[50]=F,e[51]=L):L=e[51];let X;e[52]!==s.mode?(X=n.jsx(al,{children:n.jsx(Tu,{mode:s.mode})}),e[52]=s.mode,e[53]=X):X=e[53];let re;e[54]!==L||e[55]!==X?(re=n.jsxs(cl,{children:[L,X]}),e[54]=L,e[55]=X,e[56]=re):re=e[56];let te;return e[57]!==x||e[58]!==re||e[59]!==T||e[60]!==$?(te=n.jsx("div",{ref:x,style:T,className:$,children:re}),e[57]=x,e[58]=re,e[59]=T,e[60]=$,e[61]=te):te=e[61],te},C2=()=>{const t=Xe.c(98),{t:e}=Ct(),s=hn();let r;t[0]!==s?(r=s?Ps(s):"",t[0]=s,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=B=>i?B.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const c=de(o),a=de(P2),d=de(E2),u=de(I2),f=de(T2),p=de(D2),m=de(R2),g=de(N2),y=de(M2),v=af(lf)?.hasChecked??!1,x=wn(O2),b=yf(i||null),{screenWidth:h}=Tn(),S=rl(i||null);let w;t[4]!==y?(w=wx("switch_context_surface",y),t[4]=y,t[5]=w):w=t[5];const j=w,[k,T]=l.useState(!1);let O,$;t[6]!==j?(O=()=>{const B=new Set;let ae=null,xe=!1;const Te=B2,Ge=()=>{Sc(j,B)?!xe&&ae===null&&(ae=setTimeout(()=>T(!0),v2)):(xe=!1,ae!==null&&(clearTimeout(ae),ae=null),T(!1))},st=ke=>{if(B.add(ke.key.toLowerCase()),Te(ke.key)&&Sc(j,B)){xe=!0,ae!==null&&(clearTimeout(ae),ae=null),T(!1);return}Ge()},rt=ke=>{B.delete(ke.key.toLowerCase()),Ge()},Ke=()=>{B.clear(),xe=!1,ae!==null&&(clearTimeout(ae),ae=null),T(!1)};return window.addEventListener("keydown",st,!0),window.addEventListener("keyup",rt,!0),window.addEventListener("blur",Ke),()=>{window.removeEventListener("keydown",st,!0),window.removeEventListener("keyup",rt,!0),window.removeEventListener("blur",Ke),ae!==null&&clearTimeout(ae)}},$=[j],t[6]=j,t[7]=O,t[8]=$):(O=t[7],$=t[8]),l.useEffect(O,$);let D;t[9]===Symbol.for("react.memo_cache_sentinel")?(D={activationConstraint:{distance:8}},t[9]=D):D=t[9];let E;t[10]===Symbol.for("react.memo_cache_sentinel")?(E={activationConstraint:{delay:200,tolerance:6}},t[10]=E):E=t[10];const R=Lr(zs($r,D),zs(_r,E)),z=il(),_=xc(F2),W=xc(L2),N=c?.tabs??w2;let Y;t[11]!==g||t[12]!==c?(Y=Ha(c,g),t[11]=g,t[12]=c,t[13]=Y):Y=t[13];const C=Y,P=S?.files.length??0;let I;if(t[14]!==u||t[15]!==d||t[16]!==z||t[17]!==b||t[18]!==h||t[19]!==x||t[20]!==N){let B;t[22]!==b?(B=ae=>ae.id==="pr"&&b==="gitlab"?{...ae,icon:"gitlab"}:ae,t[22]=b,t[23]=B):B=t[23],I=kx({railOrder:d,hiddenSurfaces:u,isVSCode:In(),screenWidth:h,tabs:N,sourceControlConnected:x,extras:z}).map(B),t[14]=u,t[15]=d,t[16]=z,t[17]=b,t[18]=h,t[19]=x,t[20]=N,t[21]=I}else I=t[21];const H=I;let A,F;t[24]!==m||t[25]!==g||t[26]!==i||t[27]!==v||t[28]!==C||t[29]!==x?(F=()=>{!i||!v||x||!C.has("pr")||m(i,Po(g,"pr"))},A=[m,g,i,v,C,x],t[24]=m,t[25]=g,t[26]=i,t[27]=v,t[28]=C,t[29]=x,t[30]=A,t[31]=F):(A=t[30],F=t[31]),l.useEffect(F,A);const[L,X]=l.useState(!1),re=l.useRef(null),te=l.useRef(null);let M;t[32]!==b||t[33]!==H||t[34]!==e?(M=B=>{const ae=H.find(Te=>Te.id===B.active.id),xe=re.current?.getBoundingClientRect().left;!ae||xe===void 0||(te.current?.cancel(),te.current=Sl({mode:ae.mode,label:ae.label??e(cn(ae.labelKey,b)),from:Po(de.getState().contextSurfaceZones,ae.mode)},Te=>Te.x<xe-16))},t[32]=b,t[33]=H,t[34]=e,t[35]=M):M=t[35];const ee=M;let V;t[36]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{te.current?.cancel(),te.current=null},t[36]=V):V=t[36];const Ee=V;let ve,ce;t[37]===Symbol.for("react.memo_cache_sentinel")?(ve=()=>()=>te.current?.cancel(),ce=[],t[37]=ve,t[38]=ce):(ve=t[37],ce=t[38]),l.useEffect(ve,ce);let Be;t[39]!==i||t[40]!==z||t[41]!==f?(Be=B=>{const ae=te.current;if(te.current=null,ae?.finish(i))return;const{active:xe,over:Te}=B;if(!Te||xe.id===Te.id)return;const Ge=vf(de.getState().contextRailOrder,z).map(_2),st=Ge.indexOf(xe.id),rt=Ge.indexOf(Te.id);st===-1||rt===-1||f(ml(Ge,st,rt))},t[39]=i,t[40]=z,t[41]=f,t[42]=Be):Be=t[42];const me=Be;if(!i)return null;let he;t[43]!==e?(he=e("contextRail.aria.rail"),t[43]=e,t[44]=he):he=t[44];let G;t[45]!==H?(G=H.map($2),t[45]=H,t[46]=G):G=t[46];let le;if(t[47]!==P||t[48]!==W||t[49]!==i||t[50]!==_||t[51]!==p||t[52]!==b||t[53]!==k||t[54]!==C||t[55]!==H||t[56]!==e||t[57]!==a){let B;t[59]!==P||t[60]!==W||t[61]!==i||t[62]!==_||t[63]!==p||t[64]!==b||t[65]!==k||t[66]!==C||t[67]!==e||t[68]!==a?(B=(ae,xe)=>{const Te=ae.label??e(cn(ae.labelKey,b)),Ge=ae.id==="git"&&!a?P:0,st=rr(ae.mode)&&!C.has(ae.mode)?_[jo(ae.mode)]??0:0,rt=Ge>0?Ge:st>0?st:null,Ke=rt!==null&&Ge===0;return n.jsx(j2,{surface:ae,isActive:C.has(ae.mode),showActivityDot:!1,label:Te,description:e(cn(ae.descriptionKey,b)),badgeCount:rt,badgeAriaLabel:rt!==null?e(Ke?rt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":rt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:Te,count:rt}):null,badgeDescription:rt!==null?e(Ke?rt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":rt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:rt}):null,orderNumber:xe+1,showOrderNumber:k,onSelect:ke=>{rr(ke.mode)&&W(jo(ke.mode)),p(i,ke.mode)}},ae.id)},t[59]=P,t[60]=W,t[61]=i,t[62]=_,t[63]=p,t[64]=b,t[65]=k,t[66]=C,t[67]=e,t[68]=a,t[69]=B):B=t[69],le=H.map(B),t[47]=P,t[48]=W,t[49]=i,t[50]=_,t[51]=p,t[52]=b,t[53]=k,t[54]=C,t[55]=H,t[56]=e,t[57]=a,t[58]=le}else le=t[58];let ye;t[70]!==G||t[71]!==le?(ye=n.jsx(ii,{items:G,strategy:gl,children:le}),t[70]=G,t[71]=le,t[72]=ye):ye=t[72];let Ie;t[73]!==me||t[74]!==ee||t[75]!==R||t[76]!==ye?(Ie=n.jsx(zr,{sensors:R,collisionDetection:Kr,onDragStart:ee,onDragCancel:Ee,onDragEnd:me,children:ye}),t[73]=me,t[74]=ee,t[75]=R,t[76]=ye,t[77]=Ie):Ie=t[77];let K;t[78]!==e?(K=e("contextRail.configure.open"),t[78]=e,t[79]=K):K=t[79];let se;t[80]===Symbol.for("react.memo_cache_sentinel")?(se=()=>X(!0),t[80]=se):se=t[80];let U;t[81]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsx(Q,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[81]=U):U=t[81];let ie;t[82]!==K?(ie=n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":K,onClick:se,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:U})}),t[82]=K,t[83]=ie):ie=t[83];let we;t[84]!==e?(we=e("contextRail.configure.open"),t[84]=e,t[85]=we):we=t[85];let pe;t[86]!==we?(pe=n.jsx(Ft,{side:"left",sideOffset:8,children:we}),t[86]=we,t[87]=pe):pe=t[87];let Se;t[88]!==ie||t[89]!==pe?(Se=n.jsxs(Kt,{delayDuration:sh,children:[ie,pe]}),t[88]=ie,t[89]=pe,t[90]=Se):Se=t[90];let Ce;t[91]!==L?(Ce=n.jsx(a2,{open:L,onOpenChange:X}),t[91]=L,t[92]=Ce):Ce=t[92];let Oe;return t[93]!==he||t[94]!==Ie||t[95]!==Se||t[96]!==Ce?(Oe=n.jsxs("nav",{ref:re,"aria-label":he,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",children:[Ie,Se,Ce]}),t[93]=he,t[94]=Ie,t[95]=Se,t[96]=Ce,t[97]=Oe):Oe=t[97],Oe};function P2(t){return t.workStatusPanelVisible}function E2(t){return t.contextRailOrder}function I2(t){return t.contextRailHiddenSurfaces}function T2(t){return t.setContextRailOrder}function D2(t){return t.openContextSurface}function R2(t){return t.closeContextZone}function N2(t){return t.contextSurfaceZones}function M2(t){return t.shortcutOverrides}function A2(t){return t.status?.status==="connected"}function O2(t){return Object.values(t.entries).some(A2)}function B2(t){return t.length===1&&t>="0"&&t<="9"}function F2(t){return t.countByGuest}function L2(t){return t.clearBadge}function _2(t){return t.id}function $2(t){return t.id}const z2=t=>{const e=Xe.c(16),{enabled:s,isSessionSearchOpen:r,openSessionSearch:i,closeSessionSearch:o,sessionSearchInputRef:c,sessionSearchContainerRef:a}=t,d=s===void 0?!0:s;let u,f;e[0]!==d||e[1]!==r||e[2]!==c?(u=()=>{if(!d||!r||typeof window>"u")return;const v=window.requestAnimationFrame(()=>{c.current?.focus(),c.current?.select()});return()=>window.cancelAnimationFrame(v)},f=[d,r,c],e[0]=d,e[1]=r,e[2]=c,e[3]=u,e[4]=f):(u=e[3],f=e[4]),l.useEffect(u,f);let p,m;e[5]!==d||e[6]!==i||e[7]!==c?(p=()=>{if(!d||typeof window>"u")return;const v=()=>{i(),c.current?.focus(),c.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",v),()=>window.removeEventListener("openchamber:sidebar-session-search",v)},m=[d,i,c],e[5]=d,e[6]=i,e[7]=c,e[8]=p,e[9]=m):(p=e[8],m=e[9]),l.useEffect(p,m);let g,y;e[10]!==o||e[11]!==d||e[12]!==r||e[13]!==a?(g=()=>{if(!d||!r||typeof document>"u")return;const v=x=>{a.current&&(a.current.contains(x.target)||o())};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},y=[d,r,o,a],e[10]=o,e[11]=d,e[12]=r,e[13]=a,e[14]=g,e[15]=y):(g=e[14],y=e[15]),l.useEffect(g,y)},K2=t=>{const e=Xe.c(4);let s;e[0]!==t?(s=(o,c)=>{const a=t.get(o);if(!a||a.length===0)return c;const d=new Map(c.map(W2)),u=[];a.forEach(m=>{const g=d.get(m);g&&(u.push(g),d.delete(m))});const f=[],p=[];return c.forEach(m=>{d.has(m.id)&&(m.isArchivedBucket?p.push(m):f.push(m))}),[...f,...u,...p]},e[0]=t,e[1]=s):s=e[1];const r=s;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function W2(t){return[t.id,t]}const H2=(t,e)=>{const s=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!s)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==s.id);return(e.mainWorkspaceOnly?[s,...r?[r]:[]]:[...t.groups.find(o=>o.isMain)?[t.groups.find(o=>o.isMain)]:[],...t.groups.filter(o=>!o.isMain)]).map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?o.id===s.id:o.isMain}))},yd=(t,e,s)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const c of i.children)o=r(c)||o;return o&&s.add(i.session.id),o};for(const i of t)r(i)},lr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const s of t.children)if(lr(s,e))return!0;return!1},V2=({isSubtaskSession:t,archivedBucket:e,isVSCode:s,sessionDirectory:r})=>!t&&!e&&!s&&!Va(r),U2=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:s})=>!t||e||s,Aa=(t,e,s)=>{const r=new Map,i=o=>{const c=or(o.session)??vt(o.worktree?.path)??s;if(c){const a=r.get(c)??[];a.push(o.session.id),r.set(c,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,c])=>({directory:o,sessionIDs:c}))},Oa=(t,e)=>{const s=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(s.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},nh=t=>{const e=new Map(t.map(c=>[c.id,c])),s=new Map;for(const c of t){if(!c.parentId||!e.has(c.parentId))continue;const a=s.get(c.parentId)??[];a.push(c),s.set(c.parentId,a)}const r=new Set,i=[],o=c=>{if(r.has(c.id))return;i.push(c);const a=[c.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of s.get(d)??[])a.push(u.id)}}};return t.forEach(c=>{(!c.parentId||!e.has(c.parentId))&&o(c)}),t.forEach(o),i},rh=(t,e)=>{const s=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const m=i.get(u.parentId)??[];m.push(u.id),i.set(u.parentId,m)}const f=new Set;let p=u.id;for(;p;){if(f.has(p)){o.add(u.id);break}f.add(p),p=r.get(p)?.parentId}}const c=new Set,a=new Set,d=u=>{if(c.has(u))return!0;if(a.has(u))return!1;const f=r.get(u);if(!f)return!1;a.add(u);let p=o.has(u);return!p&&e.archivedBucket&&f.nodeCount===0?p=(i.get(u)??[]).some(d):(!p&&!e.searchQuery&&(p=!0),!p&&(f.nodeCount>0||!s&&Do([f.name],e.searchQuery))&&(p=!0),p||(p=(i.get(u)??[]).some(d))),a.delete(u),p&&c.add(u),p};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>c.has(u.id)).map(u=>u.id))},xd=new WeakMap;let Sd=1;const G2=t=>{const e=xd.get(t);if(e!==void 0)return e;const s=Sd;return Sd+=1,xd.set(t,s),s},Mr=t=>t.children.length===0?"":t.children.map(s=>{const r=G2(s.session);return s.children.length===0?`${s.session.id}@${r}`:`${s.session.id}@${r}:${Mr(s)}`}).join("|"),oh=(t,e,s,r,i,o)=>{const c=Xt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const f=d.session.directory??i,p=u.session.directory??o,m=vc(c,f??"",d.session.id),g=vc(c,p??"",u.session.id);return(m?s.has(m):!1)!==(g?r.has(g):!1)?!0:d.children.some((y,v)=>a(y,u.children[v]))};return a(t,e)},q2=(t,e)=>t?t.branchLabel??null:e??null,Y2=(t,e)=>{if(e)return null;const s=t?.branch?.trim(),r=vt(t?.path??null);return s&&r?{directory:r,branch:s}:null},_o=(t,e,s,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const c=a=>{if(`${s}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(c(u))return!0;return!1};return t.forEach(a=>c(a)),o},Bn=(t,e)=>`${t}\0${e}`,sr=(t,e)=>t??Ua(e)??vt(e??null),_n=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??vt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},Il=t=>t.startsWith("__archived__:"),Tl=(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)=>Tl(t.session,e)||t.children.some(s=>ih(s,e)),Dl=(t,e)=>(Tl(t.session,e)?1:0)+t.children.reduce((s,r)=>s+Dl(r,e),0),vd=({sessions:t,getSessionLocation:e,getSessionNode:s,query:r})=>t.flatMap(i=>{if(!Tl(i,r))return[];const o=e(i.id);return[{node:s(i),projectId:o?.projectId??null,groupDirectory:o?.groupDirectory??i.directory??null,secondaryMeta:{projectLabel:o?.projectLabel??null,branchLabel:o?.branchLabel??null,inSpace:o?.inSpace??!1}}]}),ah=["chats","pinned","work"],lh=t=>t==="project"||t==="mixed-compact"||t==="tree-chat",cr=t=>t==="timeline"||t==="timeline-mixed",X2=t=>cr(t)||t==="mixed-compact",no=t=>"run"in t,Q2=(t,e)=>`${t}:active:run:${e}`,Hi=(t,e,s)=>{if(s||e.runKeyBySessionId.size===0)return[...t];const r=[],i=new Map;for(const o of t){const c=e.runKeyBySessionId.get(o.session.id),a=c?e.runs.get(c):void 0;if(!a){r.push(o);continue}const d=i.get(a.key);if(d){d.lanes.push(o);continue}const u={run:a,lanes:[o]};i.set(a.key,u),r.push(u)}for(const o of i.values()){const c=new Map(o.run.memberIds.map((a,d)=>[a,d]));o.lanes.sort((a,d)=>(c.get(a.session.id)??0)-(c.get(d.session.id)??0))}return r},ch=(t,e)=>{const s=e.trim().toLowerCase(),r=s.startsWith("ses_"),i=o=>o.reduce((c,a)=>c+(!r||a.session.id.toLowerCase()===s?1:0)+i(a.children),0);return i(t)},Vi=[],Z2=new Set,wd=32,kd=52,J2=3,eC=7,jd=7,Cd=7,dh=t=>`timeline-project:${t}`,Vn=32,nn=28,Pd=(t,e,s,r)=>{const i=r.get(t.session.id),o=r.get(e.session.id);if(i!==void 0||o!==void 0){if(i===void 0)return 1;if(o===void 0)return-1;if(i!==o)return i-o}return dl(t.session,e.session,s,wf)},Ui=t=>{const e=new Map,s=new Map,r=[],i=new WeakMap,o=t.map(c=>({node:c,visited:!1})).reverse();for(;o.length>0;){const c=o.pop();if(!c)continue;if(!c.visited){e.set(c.node.session.id,c.node),s.set(c.node.session.id,c.node.session);const d=r.length;r.push(c.node.session.id),i.set(c.node,[d,d+1]),o.push({node:c.node,visited:!0});for(let u=c.node.children.length-1;u>=0;u-=1){const f=c.node.children[u];f&&o.push({node:f,visited:!1})}continue}const a=i.get(c.node);a&&i.set(c.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:s,preorderIds:Object.freeze(r),subtreeRangeByNode:i}},tC=(t,e,s)=>`${t}:${e?"archived":"active"}:${s}`,sC=(t,e)=>{let s=null;for(const r of t){if(r.rowIndex>e)break;s=r}return s},nC=t=>{const e=[],s=[],r=[],i=[],o=[],c=new Map,a=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds),f=t.zoneSessionIds??Z2,p=C=>d&&f.has(C);let m=0;const y=[...[...t.authoritativeSections.flatMap(C=>C.groups.flatMap(P=>P.sessions)),...t.chatGroup?.sessions??[]]];for(;y.length>0;){const C=y.pop();C&&(c.set(C.session.id,C.session),y.push(...C.children))}const v=C=>{const P=a.get(C)??0;return a.set(C,P+1),P===0?C:`${C}:${P}`},x=C=>{e.push(Object.freeze(C))},b=t.runIndex??jx,h=(C,P)=>{const I=Q2(P.renderContext,C.run.key),H=!X2(P.renderContext)&&(d||t.expandedParents.has(I)),A=C.lanes[0]?.session.id,F=A&&P.getSecondaryMeta?P.getSecondaryMeta(A):P.secondaryMeta,L=Object.freeze([...new Set(C.lanes.flatMap(X=>(P.getBlockingBadgeSessionScopes?.(X.session.id)??[]).flatMap(re=>re.sessionIDs)))]);x({kind:"run",key:v(`${P.containerKey}:run:${C.run.key}`),estimateSize:cr(P.renderContext)?kd:wd,run:C.run,depth:P.baseDepth??0,laneNodes:Object.freeze([...C.lanes]),blockingSessionIds:L,projectId:P.projectId,projectLabel:F?.projectLabel??null,groupDirectory:P.groupDirectory,renderContext:P.renderContext,expansionKey:I,expanded:H,forceExpanded:d}),H&&w(C.lanes,(P.baseDepth??0)+1,P)},S=C=>{for(const P of Hi(C.nodes,b,C.archived))no(P)?h(P,C):w([P],C.baseDepth??0,C)},w=(C,P,I)=>{const H=[...C].reverse().map(A=>({node:A,depth:P,directory:I.groupDirectory}));for(;H.length>0;){const A=H.pop();if(!A)continue;const F=v(`${I.containerKey}:session:${A.node.session.id}`),L=A.node.session.directory??A.directory;c.set(A.node.session.id,A.node.session),x({kind:"session",key:F,estimateSize:cr(I.renderContext)?kd:wd,node:A.node,blockingBadgeSessionScopes:A.depth===P?I.getBlockingBadgeSessionScopes?.(A.node.session.id)??I.blockingBadgeSessionScopes:void 0,depth:A.depth,projectId:I.projectId,groupDirectory:A.directory,ownerKey:I.ownerKey,selectionScopeKey:I.selectionScopeKey,archived:I.archived,renderContext:I.renderContext,secondaryMeta:I.getSecondaryMeta?I.getSecondaryMeta(A.node.session.id):I.secondaryMeta??null});const X=I.indexedNodes?.subtreeRangeByNode.get(A.node),re=X&&X[1]>X[0]+1?Object.freeze([(I.selectionPoolOffset??0)+X[0]+1,(I.selectionPoolOffset??0)+X[1]]):void 0;if(s.push(Object.freeze({id:A.node.session.id,rowKey:F,scopeKey:I.selectionScopeKey,archived:I.archived,descendantRange:re})),!(!d&&!t.expandedParents.has(tC(I.renderContext,I.archived,A.node.session.id))))for(let te=A.node.children.length-1;te>=0;te-=1){const M=A.node.children[te];M&&H.push({node:M,depth:A.depth+1,directory:L})}}},j=C=>{const P=t.groupSearchDataByGroup.get(C);if(P?.hasMatch!==!0)return 0;const I=f.size>0?P.filteredNodes.filter(A=>p(A.session.id)):[];return Math.max(0,P.matchedSessionCount-ch(I,t.normalizedQuery))+P.folderNameMatchCount+(P.groupMatches?1:0)},k=(C,P,I,H,A)=>{const F=t.groupSearchDataByGroup.get(C);if(d){const ge=j(C);if(ge===0)return;m+=ge}const L=(d?F?.filteredNodes??[]:C.sessions).filter(ge=>!p(ge.session.id)).sort((ge,Ve)=>Pd(ge,Ve,u,t.sessionOrderIndex)),X=Ui(L),re=r.length;r.push(...X.preorderIds);for(const[ge,Ve]of X.sessionsById)c.set(ge,Ve);const te=sr(I,C.directory),M=!d&&t.collapsedGroups.has(P),ee=H?0:1,V=A!==void 0&&!lh(A.renderContext),Ee=t.groupStatusByKey.get(P),ve=!Ee||Ee.state==="ready",ce=L.length===0&&ve&&_n(C).every(({scopeKey:ge})=>(t.foldersMap[ge]??Vi).length===0);if(!H){const ge=X.preorderIds.flatMap(Ve=>X.sessionsById.get(Ve)??[]);x({kind:"group-header",key:`${P}:header`,estimateSize:Vn,group:C,groupKey:P,projectId:I,collapsed:M&&!ce,forceExpanded:d,empty:ce,allSessions:Object.freeze(ge)})}if(M&&!ce)return;const Be=_n(C).flatMap(({scopeKey:ge,directory:Ve})=>(t.foldersMap[ge]??Vi).map(Ue=>({folder:Ue,scopeKey:ge,scopeDirectory:Ve,ownerKey:te,nodes:Oa(Ue.sessionIds,X.byId).sort((ft,Qe)=>Pd(ft,Qe,u,t.sessionOrderIndex))}))),me=rh(Be.map(ge=>({id:ge.folder.id,name:ge.folder.name,parentId:ge.folder.parentId,nodeCount:ge.nodes.length})),{archivedBucket:C.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),he=Be.filter(ge=>me.has(ge.folder.id)),G=new Map(he.map(ge=>[Bn(ge.scopeKey,ge.folder.id),ge])),le=new Map;for(const ge of he){if(!ge.folder.parentId)continue;const Ve=Bn(ge.scopeKey,ge.folder.parentId),Ue=le.get(Ve)??[];Ue.push(ge),le.set(Ve,Ue)}const ye=nh(he.map(ge=>({...ge.folder,scopeKey:ge.scopeKey}))).map(ge=>G.get(Bn(ge.scopeKey??"",ge.id))).filter(ge=>!!ge),Ie=new Set(he.flatMap(ge=>ge.folder.sessionIds)),K=L.filter(ge=>!Ie.has(ge.session.id)),se=new Map,U=ye.map(ge=>({folder:ge,visited:!1})),ie=new Set;for(;U.length>0;){const ge=U.pop();if(!ge)continue;const Ve=Bn(ge.folder.scopeKey,ge.folder.folder.id);if(!ge.visited){if(ie.has(Ve))continue;ie.add(Ve),U.push({folder:ge.folder,visited:!0});for(const ft of le.get(Ve)??[])U.push({folder:ft,visited:!1});continue}const Ue=ge.folder.nodes.flatMap(ft=>{const Qe=X.subtreeRangeByNode.get(ft);return Qe?X.preorderIds.slice(Qe[0],Qe[1]).flatMap(wt=>X.sessionsById.get(wt)??[]):[ft.session]});for(const ft of le.get(Ve)??[])Ue.push(...se.get(Bn(ft.scopeKey,ft.folder.id))??[]);se.set(Ve,Object.freeze(Ue))}const we=new Set,pe=(ge,Ve)=>{const Ue=Bn(ge.scopeKey,ge.folder.id);if(we.has(Ue))return;we.add(Ue);const ft=Ve?`${Ve} / ${ge.folder.name}`:ge.folder.name,Qe=`${P}:folder:${Ue}`,wt=ve&&ge.nodes.length===0&&(le.get(Ue)?.length??0)===0,Me=!d&&!wt&&t.collapsedFolders.has(ge.folder.id),Pe=se.get(Ue)??[],ot=Me&&!C.isArchivedBucket?Oa([...new Set(Pe.map(dt=>dt.id))],X.byId):[],et=te?t.folderAuthorityByOwner.get(te):void 0,Ze=!!te&&!C.isArchivedBucket&&!Il(ge.scopeKey)&&et?.complete===!0&&et.scopeKeys.includes(ge.scopeKey);if(x({kind:"folder-header",key:Qe,estimateSize:Vn,depth:ee,group:C,folder:ge.folder,displayName:ft,scopeKey:ge.scopeKey,scopeDirectory:ge.scopeDirectory,ownerKey:te,nodes:ge.nodes,activityNodes:ot,projectId:I,archived:C.isArchivedBucket===!0,collapsed:Me,forceExpanded:d,empty:wt,deleteSessions:Pe,subFolderCount:le.get(Ue)?.length??0,dropEnabled:Ze}),te&&o.push(Object.freeze({rowKey:Qe,scopeKey:ge.scopeKey,folderId:ge.folder.id,ownerKey:te,enabled:Ze})),!Me){S({nodes:ge.nodes,containerKey:Qe,projectId:I,groupDirectory:ge.scopeDirectory??C.directory,ownerKey:te,selectionScopeKey:te,archived:C.isArchivedBucket===!0,renderContext:"project",indexedNodes:X,selectionPoolOffset:re,baseDepth:ee+1});for(const dt of le.get(Ue)??[])pe(dt,ft)}};for(const ge of ye)pe(ge,"");const Se=I?t.sessionBatchSize:void 0,Ce=A?.initial??Se??(t.hideDirectoryControls?10:jd),Oe=A?.increment??Se??Cd,B=Math.max(Ce,t.visibleCountByContainer.get(P)??Ce),ae=ge=>!no(ge)&&A?.pinnedAlwaysVisible===!0&&ri(u,ge.session.directory??C.directory,ge.session.id),xe=Hi(K,b,C.isArchivedBucket===!0),Te=xe.filter(ge=>!ae(ge));let Ge=B;const st=C.isArchivedBucket||d?xe:xe.filter(ge=>ae(ge)?!0:Ge<=0?!1:(Ge-=1,!0)),rt=st.flatMap(ge=>no(ge)?ge.lanes:[ge]);S({nodes:rt,containerKey:P,projectId:I,groupDirectory:C.directory,ownerKey:te,selectionScopeKey:te,archived:C.isArchivedBucket===!0,renderContext:A?.renderContext??"project",indexedNodes:X,selectionPoolOffset:re,baseDepth:ee});const Ke=xe.length-st.length,ke=B-Ge;!d&&!C.isArchivedBucket&&Ke>0?x({kind:"show-control",key:`${P}:more`,estimateSize:nn,control:"more",containerKey:P,currentCount:ke,increment:Oe,depth:ee,flat:V}):!d&&!C.isArchivedBucket&&Te.length>Ce&&Ke===0&&x({kind:"show-control",key:`${P}:fewer`,estimateSize:nn,control:"fewer",containerKey:P,currentCount:ke,increment:Oe,depth:ee,flat:V}),L.length===0&&he.length===0?Ee&&Ee.state!=="ready"?x({kind:"status",key:`${P}:status`,estimateSize:nn,status:Ee,group:C,groupKey:P,depth:ee,flat:V}):C.isArchivedBucket&&x({kind:"empty",key:`${P}:empty`,estimateSize:nn,emptyKind:"archived",depth:ee}):Ee&&Ee.state!=="ready"&&Ee.state!=="loading"&&x({kind:"status",key:`${P}:status`,estimateSize:nn,status:Ee,group:C,groupKey:P,depth:ee,flat:V})},T=C=>{const P=!d&&t.collapsedActivities.has(C),I=e.length;return x({kind:"activity-header",key:`activity:${C}:header`,estimateSize:Vn,activityKey:C,collapsed:P,forceExpanded:d}),i.push(Object.freeze({rowIndex:I,kind:"activity",id:C})),P},O=t.viewMode==="timeline",$=C=>"run"in C,D=C=>{const P=Hi(C.map(H=>H.node),b,!1),I=new Map(C.map(H=>[H.node,H]));return P.flatMap(H=>{if(!no(H)){const A=I.get(H);return A?[A]:[]}return[{run:H.run,items:H.lanes.flatMap(A=>I.get(A)??[])}]})},E=(C,P,I)=>{const H=C.items[0];if(!H)return;const A=C.items.map(M=>M.node),F=Ui(A),L=r.length;r.push(...F.preorderIds);const X=sr(H.projectId,H.groupDirectory),re=new Map(C.items.map(M=>[M.node.session.id,M.getSecondaryMeta?M.getSecondaryMeta(M.node.session.id):M.secondaryMeta])),te=new Map(C.items.map(M=>[M.node.session.id,M.blockingBadgeSessionScopes]));h({run:C.run,lanes:A},{nodes:A,containerKey:P,projectId:H.projectId,groupDirectory:H.groupDirectory,ownerKey:X,selectionScopeKey:null,archived:!1,renderContext:I,getSecondaryMeta:M=>re.get(M)??null,getBlockingBadgeSessionScopes:M=>te.get(M),indexedNodes:F,selectionPoolOffset:L})},R=(C,P,I,H=()=>1)=>{for(const A of D(C)){if($(A)){E(A,P,I),d&&(m+=A.items.reduce((te,M)=>te+H(M),0));continue}const F=A,L=Ui([F.node]),X=r.length;r.push(...L.preorderIds);const re=sr(F.projectId,F.groupDirectory);S({nodes:[F.node],containerKey:P,projectId:F.projectId,groupDirectory:F.groupDirectory,ownerKey:re,selectionScopeKey:null,archived:!1,renderContext:I,blockingBadgeSessionScopes:F.blockingBadgeSessionScopes,secondaryMeta:F.secondaryMeta,getSecondaryMeta:F.getSecondaryMeta,indexedNodes:L,selectionPoolOffset:X}),d&&(m+=H(F))}};t.chatGroup&&(!d||j(t.chatGroup)>0)&&(T("chats")||k(t.chatGroup,"activity:chats",null,!0,{initial:J2,increment:eC,pinnedAlwaysVisible:!0,renderContext:O?"timeline-chat":"tree-chat"}));const z=O||t.detailedZoneRows?"timeline-mixed":"mixed-compact",_=(C,P,I,H,A)=>{const F=Math.max(H,t.visibleCountByContainer.get(P)??H),L=D(C),X=d?L:L.slice(0,F);R(X.flatMap(re=>$(re)?re.items:[re]),P,I),!d&&(L.length>X.length?x({kind:"show-control",key:`${P}:more`,estimateSize:nn,control:"more",containerKey:P,currentCount:X.length,increment:A,flat:!0}):L.length>H&&x({kind:"show-control",key:`${P}:fewer`,estimateSize:nn,control:"fewer",containerKey:P,currentCount:X.length,increment:A,flat:!0}))},W=(C,P)=>{if(P.length===0)return;T(C)||R(P,`activity:${C}`,z,H=>H.searchMatchCount??Dl(H.node,t.normalizedQuery))};if(W("pinned",t.pinnedItems??[]),W("work",t.workItems??[]),O){const C=new Map;for(const P of t.timelineItems??[]){if(!P.projectId||p(P.node.session.id))continue;const I=C.get(P.projectId);I?I.push(P):C.set(P.projectId,[P])}for(const P of t.sections){const I=P.project.id,H=C.get(I)??[];if(d&&H.length===0)continue;const A=!d&&t.collapsedProjects.has(I),F=e.length;if(x({kind:"project-header",key:`project:${I}:header`,estimateSize:Vn,section:P,collapsed:A,forceExpanded:d}),i.push(Object.freeze({rowIndex:F,kind:"project",id:I})),A)continue;if(!d)for(const te of P.groups){if(!te.space||te.sessions.length>0)continue;const M=`${I}:${te.id}`,ee=t.groupStatusByKey.get(M);if(ee?.state==="loading")continue;const V=(!ee||ee.state==="ready")&&_n(te).every(({scopeKey:Ee})=>(t.foldersMap[Ee]??Vi).length===0);x({kind:"group-header",key:`${M}:header`,estimateSize:Vn,group:te,groupKey:M,projectId:I,collapsed:!1,forceExpanded:!0,empty:V,allSessions:Object.freeze([])}),ee&&ee.state!=="ready"&&x({kind:"status",key:`${M}:status`,estimateSize:nn,status:ee,group:te,groupKey:M,flat:!0})}if(H.length>0){_(H,dh(I),"timeline",jd,Cd);continue}const L=P.groups.find(te=>te.isMain);if(!L)continue;const X=`${I}:${L.id}`,re=t.groupStatusByKey.get(X);re&&re.state!=="ready"&&x({kind:"status",key:`${X}:status`,estimateSize:nn,status:re,group:L,groupKey:X,flat:!0})}}let N=O?[]:t.singleProjectMode?t.sections.filter(C=>C.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const C=N.find(P=>P.project.id===t.activeProjectId)??N[0];N=C?[C]:[]}for(const C of N){const P=H2(C,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(d&&!P.some(H=>j(H.group)>0))continue;const I=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(C.project.id);if(!t.showOnlyMainWorkspace){const H=e.length;x({kind:"project-header",key:`project:${C.project.id}:header`,estimateSize:Vn,section:C,collapsed:I,forceExpanded:d}),i.push(Object.freeze({rowIndex:H,kind:"project",id:C.project.id}))}if(!I)for(const H of P)k(H.group,H.groupKey,H.projectId,H.hideGroupLabel)}e.length===0&&x({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const Y=new Map;return e.forEach((C,P)=>Y.set(C.key,P)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(s),selectionDescendantIds:Object.freeze(r),rowIndexByKey:Y,stickyHeaders:Object.freeze(i),folderDropTargets:Object.freeze(o),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:c,searchMatchCount:d?m:0})},ro="oc.sessions.projectCollapse",Ed="oc.sessions.groupOrder",Id="oc.sessions.groupCollapse",Td="oc.sessions.activityCollapse",Gi=t=>{if(!t)return new Set;try{const e=ai(Ks()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},rC=t=>{if(!t)return new Map;try{const e=Dr(Ks(),ai(Ks())).safeParse(JSON.parse(t));if(!e.success)return new Map;const s=new Map;for(const[r,i]of Object.entries(e.data))s.set(r,i);return s}catch{return new Map}},oC=t=>{const e=Xe.c(45),{isVSCode:s,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Eo(),e[0]=i):i=e[0];const o=i;let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=()=>Gi(o.getItem(ro)),e[1]=c):c=e[1];const[a,d]=l.useState(c);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>Gi(o.getItem(Id)),e[2]=u):u=e[2];const[f,p]=l.useState(u);let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=()=>Gi(o.getItem(Td)),e[3]=m):m=e[3];const[g,y]=l.useState(m);let v;e[4]===Symbol.for("react.memo_cache_sentinel")?(v=()=>rC(o.getItem(Ed)),e[4]=v):v=e[4];const[x,b]=l.useState(v),h=l.useRef(0),S=l.useRef(!1),w=l.useRef(!1),j=l.useRef(!1),k=l.useRef(null),T=l.useRef(null);let O;e[5]!==s?(O=()=>{if(s)return;const le=T.current;if(T.current=null,k.current=null,!le)return;const{projects:ye}=ns.getState(),Ie=ye.map(K=>({...K,sidebarCollapsed:le.has(K.id)}));on({projects:Ie}).catch(iC)},e[5]=s,e[6]=O):O=e[6];const $=O;let D;e[7]!==$||e[8]!==s?(D=le=>{!globalThis.window||s||(T.current=le,k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{$()},700))},e[7]=$,e[8]=s,e[9]=D):D=e[9];const E=D;let R,z;e[10]===Symbol.for("react.memo_cache_sentinel")?(R=()=>()=>{globalThis.window&&k.current!==null&&window.clearTimeout(k.current),k.current=null,T.current=null},z=[],e[10]=R,e[11]=z):(R=e[10],z=e[11]),l.useEffect(R,z);let _,W;e[12]!==x?(_=()=>{if(j.current)try{o.setItem(Ed,JSON.stringify(Object.fromEntries(x.entries())))}catch{}},W=[x,o],e[12]=x,e[13]=_,e[14]=W):(_=e[13],W=e[14]),l.useEffect(_,W);let N,Y;e[15]!==f?(N=()=>{if(S.current)try{o.setItem(Id,JSON.stringify(Array.from(f)))}catch{}},Y=[f,o],e[15]=f,e[16]=N,e[17]=Y):(N=e[16],Y=e[17]),l.useEffect(N,Y);let C,P;e[18]!==g?(C=()=>{if(w.current)try{o.setItem(Td,JSON.stringify(Array.from(g)))}catch{}},P=[g,o],e[18]=g,e[19]=C,e[20]=P):(C=e[19],P=e[20]),l.useEffect(C,P);let I;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=le=>{w.current=!0,y(le)},e[21]=I):I=e[21];const H=I;let A;e[22]!==r||e[23]!==E?(A=()=>{h.current=Date.now()+150,S.current=!0,w.current=!0,p(new Set),y(aC),d(()=>{const le=new Set(r.map(lC));try{o.setItem(ro,JSON.stringify(Array.from(le)))}catch{}return E(le),le})},e[22]=r,e[23]=E,e[24]=A):A=e[24];const F=A;let L;e[25]!==E?(L=()=>{h.current=Date.now()+150,S.current=!0,w.current=!0,p(new Set),y(cC),d(()=>{const le=new Set;try{o.setItem(ro,JSON.stringify([]))}catch{}return E(le),le})},e[25]=E,e[26]=L):L=e[26];const X=L;let re;e[27]!==E?(re=le=>{h.current=Date.now()+150,d(ye=>{const Ie=new Set(ye);Ie.has(le)?Ie.delete(le):Ie.add(le);try{o.setItem(ro,JSON.stringify(Array.from(Ie)))}catch{}return E(Ie),Ie})},e[27]=E,e[28]=re):re=e[28];const te=re;let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=le=>{S.current=!0,p(ye=>{const Ie=new Set(ye);return Ie.has(le)?Ie.delete(le):Ie.add(le),Ie})},e[29]=M):M=e[29];const ee=M;let V;e[30]===Symbol.for("react.memo_cache_sentinel")?(V=le=>{j.current=!0,b(le)},e[30]=V):V=e[30];const Ee=V,{getOrderedGroups:ve}=K2(x);let ce;e[31]!==g||e[32]!==f||e[33]!==a||e[34]!==x?(ce={collapsedProjects:a,collapsedGroups:f,collapsedActivities:g,groupOrderByProject:x},e[31]=g,e[32]=f,e[33]=a,e[34]=x,e[35]=ce):ce=e[35];const Be=ce;let me;e[36]!==F||e[37]!==X||e[38]!==ve||e[39]!==E||e[40]!==te?(me={setCollapsedProjects:d,toggleProject:te,collapseAll:F,expandAll:X,scheduleCollapsedProjectsPersist:E,setCollapsedGroups:p,setCollapsedActivities:H,toggleGroup:ee,setGroupOrderByProject:Ee,getOrderedGroups:ve},e[36]=F,e[37]=X,e[38]=ve,e[39]=E,e[40]=te,e[41]=me):me=e[41];const he=me;let G;return e[42]!==he||e[43]!==Be?(G={state:Be,actions:he},e[42]=he,e[43]=Be,e[44]=G):G=e[44],G};function iC(){}function aC(t){return new Set([...t,...ah])}function lC(t){return t.id}function cC(t){const e=new Set(t);for(const s of ah)e.delete(s);return e}const dC=5*6e4,uC=t=>{const e=Xe.c(38),{normalizedProjects:s,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:c}=t,a=r===void 0?!0:r,{git:d}=Ws(),u=kn(fC),f=kn(pC),p=l.useRef(null),m=l.useRef(a);let g,y;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==f?(g=()=>{const E=a&&!m.current;m.current=a;const R=p.current;if(!(!E||!d||!R||R.git!==d||R.runtimeKey!==f))for(const z of R.paths)kr(()=>u(z,d))},y=[a,u,d,f],e[0]=a,e[1]=u,e[2]=d,e[3]=f,e[4]=g,e[5]=y):(g=e[4],y=e[5]),l.useEffect(g,y);let v,x;e[6]!==a||e[7]!==u||e[8]!==d||e[9]!==f||e[10]!==s||e[11]!==o?(v=()=>{if(!a)return;if(!d||s.length===0){p.current=null,o(new Map);return}let E=p.current;(!E||E.runtimeKey!==f||E.git!==d)&&(E={runtimeKey:f,git:d,paths:new Set},p.current=E);const{paths:R}=E,z=new Set(s.map(hC));for(const N of R)z.has(N)||R.delete(N);const _=[...z].filter(N=>!R.has(N));if(_.length===0)return;for(const N of _)R.add(N);const W=N=>{const Y=kn.getState().directories.get(N);Y?.isGitRepo!==!1&&!Y?.status&&R.delete(N)};kr(async()=>{await d.prefetchProjectStatuses?.(_),await Promise.all(_.map(N=>u(N,d).then(()=>W(N),()=>W(N))))})},x=[a,s,d,f,u,o],e[6]=a,e[7]=u,e[8]=d,e[9]=f,e[10]=s,e[11]=o,e[12]=v,e[13]=x):(v=e[12],x=e[13]),l.useEffect(v,x);let b,h;e[14]!==a||e[15]!==i||e[16]!==s||e[17]!==o?(b=()=>{if(!a)return;const E=new Map;s.forEach(R=>{E.set(R.id,i.get(R.normalizedPath)?.isGitRepo??null)}),o(E)},h=[a,s,i,o],e[14]=a,e[15]=i,e[16]=s,e[17]=o,e[18]=b,e[19]=h):(b=e[18],h=e[19]),l.useEffect(b,h);let S;if(e[20]!==i||e[21]!==s){let E;e[23]!==i?(E=R=>{const z=i.get(R.normalizedPath)?.branch??"";return`${R.id}:${z}`},e[23]=i,e[24]=E):E=e[24],S=s.map(E).join("|"),e[20]=i,e[21]=s,e[22]=S}else S=e[22];const w=S;let j;e[25]===Symbol.for("react.memo_cache_sentinel")?(j=new Map,e[25]=j):j=e[25];const k=l.useRef(j);let T;e[26]===Symbol.for("react.memo_cache_sentinel")?(T=new Map,e[26]=T):T=e[26];const O=l.useRef(T);let $;e[27]!==a||e[28]!==i||e[29]!==s||e[30]!==c?($=()=>{if(!a)return;let E=!1;const R=setTimeout(()=>{(async()=>{const _=new Set(s.map(mC));for(const I of k.current.keys())_.has(I)||(k.current.delete(I),O.current.delete(I));const W=Date.now(),N=s.filter(I=>{const H=i.get(I.normalizedPath);if(H?.isGitRepo===!1)return k.current.delete(I.id),O.current.delete(I.id),!1;if(H?.isGitRepo!==!0||H.branch===null)return!1;const A=H.branch.trim(),F=`${I.normalizedPath}\0${A}`,L=k.current.get(I.id);if(L===F){const X=O.current.get(I.id);return X&&(X.at=W),!1}return!(L!==void 0&&W-(O.current.get(I.id)?.at??0)<dC)});if(N.length===0)return;const Y=await kr(()=>Promise.all(N.map(async I=>{const H=i.get(I.normalizedPath)?.branch?.trim()??"",A=`${I.normalizedPath}\0${H}`,F=await hf(I.normalizedPath,H?{knownBranch:H}:void 0).catch(gC);return{id:I.id,inputKey:A,branch:F}})));if(E)return;const C=Y.filter(bC);if(C.length===0)return;const P=Date.now();c(I=>{const H=new Map(I);return C.forEach(A=>{const{id:F,branch:L}=A;L&&H.set(F,L)}),H}),C.forEach(I=>{const{id:H,inputKey:A,branch:F}=I;k.current.set(H,A),F&&O.current.set(H,{branch:F,at:P})})})()},150);return()=>{E=!0,clearTimeout(R)}},e[27]=a,e[28]=i,e[29]=s,e[30]=c,e[31]=$):$=e[31];let D;e[32]!==a||e[33]!==i||e[34]!==s||e[35]!==w||e[36]!==c?(D=[a,s,w,i,c],e[32]=a,e[33]=i,e[34]=s,e[35]=w,e[36]=c,e[37]=D):D=e[37],l.useEffect($,D)};function fC(t){return t.ensureStatus}function pC(t){return t.runtimeKey}function hC(t){return t.normalizedPath}function mC(t){return t.id}function gC(){return null}function bC(t){return t.branch}const yC=t=>{const e=Xe.c(19),{open:s,onOpenChange:r,project:i,onSave:o}=t,c=de(xC),[a,d]=l.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]),l.useEffect(u,f);const p=i?.id??null;let m;e:{if(!p){m=void 0;break e}let b;e[3]!==r||e[4]!==p||e[5]!==c?(b=()=>{r(!1),c(p)},e[3]=r,e[4]=p,e[5]=c,e[6]=b):b=e[6],m=b}const g=m;let y;e[7]!==g||e[8]!==o||e[9]!==s||e[10]!==i||e[11]!==a?(y=s&&i?n.jsx(ab,{frame:"dialog",project:i,onIdentitySave:o,tab:a,onTabChange:d,onOpenWorktrees:g}):null,e[7]=g,e[8]=o,e[9]=s,e[10]=i,e[11]=a,e[12]=y):y=e[12];let v;e[13]!==y?(v=n.jsx(qs,{className:"flex h-[min(85vh,40rem)] w-full max-w-2xl flex-col gap-0 overflow-hidden p-0",children:y}),e[13]=y,e[14]=v):v=e[14];let x;return e[15]!==r||e[16]!==s||e[17]!==v?(x=n.jsx(Ys,{open:s,onOpenChange:r,children:v}),e[15]=r,e[16]=s,e[17]=v,e[18]=x):x=e[18],x};function xC(t){return t.setWorktreesPageProjectId}function SC(t,e,s,r){const i=Xe.c(6),[o,c]=l.useState(!0);let a,d;return i[0]!==e||i[1]!==r||i[2]!==s||i[3]!==t?(a=()=>{const u=t.current,f=e.current,p=s.current;if(!u||!f||!p||r===0)return;const m=()=>{const y=f.lastElementChild,v=y?y.getBoundingClientRect().width:0,x=Number.parseFloat(getComputedStyle(f).columnGap)||0,b=Number.parseFloat(getComputedStyle(u).columnGap)||0,h=f.getBoundingClientRect().width+r*(x+v),S=u.getBoundingClientRect().right-f.getBoundingClientRect().left-p.getBoundingClientRect().width-b;c(h<=S)};m();const g=new ResizeObserver(m);return g.observe(u),g.observe(f),g.observe(p),()=>g.disconnect()},d=[t,e,s,r],i[0]=e,i[1]=r,i[2]=s,i[3]=t,i[4]=a,i[5]=d):(a=i[4],d=i[5]),l.useLayoutEffect(a,d),o}const uh="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground",fh="text-muted-foreground hover:text-foreground hover:bg-transparent";function oo(t){const e=Xe.c(14),{label:s,pressed:r,onClick:i,className:o,children:c}=t,a=r?uh:fh;let d;e[0]!==o||e[1]!==a?(d=De(o,a),e[0]=o,e[1]=a,e[2]=d):d=e[2];let u;e[3]!==c||e[4]!==s||e[5]!==i||e[6]!==r||e[7]!==d?(u=n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:i,className:d,"aria-label":s,"aria-pressed":r,children:c})}),e[3]=c,e[4]=s,e[5]=i,e[6]=r,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==s?(f=n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:s})}),e[9]=s,e[10]=f):f=e[10];let p;return e[11]!==u||e[12]!==f?(p=n.jsxs(Kt,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13],p}function vC(t){const e=Xe.c(263),{t:s}=Ct(),r=kf(),{hideDirectoryControls:i,showProjectDisplayControls:o,showSectionControls:c,handleOpenDirectoryDialog:a,showSourceBoard:d,headerActionIconClass:u,headerActionButtonClass:f,isSessionSearchOpen:p,openSessionSearch:m,closeSessionSearch:g,sessionSearchInputRef:y,sessionSearchQuery:v,setSessionSearchQuery:x,hasSessionSearchQuery:b,searchMatchCount:h,collapseAll:S,expandAll:w}=t,j=l.useRef(null),k=l.useRef(null),T=l.useRef(null),O=SC(j,k,T,r.length),$=us(UC),D=us(VC),E=de(HC),R=de(WC),z=de(KC),_=de(zC),W=Jt($C),N=Jt(_C),Y=Jt(LC),C=Jt(FC),P=Jt(BC),I=Jt(OC),H=Jt(AC),A=Jt(MC),F=de(NC),L=Jt(RC),X=Jt(DC),re=Jt(TC),te=Jt(IC),M=Jt(EC),ee=Jt(PC),V=Jt(CC),Ee=Jt(jC),ve=o&&M==="timeline",ce=o&&!ve&&V==="single";let Be;e[0]===Symbol.for("react.memo_cache_sentinel")?(Be=n.jsx(Q,{name:"check",className:"h-4 w-4 text-primary"}),e[0]=Be):Be=e[0];const me=Be;let he;e[1]!==s?(he=(at,ut,pt,lt)=>{const St=ut.find(ct=>{const[oe]=ct;return oe===pt})?.[1];return n.jsxs(Pf,{children:[n.jsxs(Ef,{children:[n.jsx("span",{className:"flex-1",children:s(at)}),St?n.jsx("span",{className:"ms-4 text-muted-foreground",children:s(St)}):null]}),n.jsx(If,{className:"min-w-[160px]",children:ut.map(ct=>{const[oe,q]=ct;return n.jsxs(Zt,{onClick:()=>lt(oe),className:"flex items-center justify-between",children:[n.jsx("span",{children:s(q)}),pt===oe?me:null]},oe)})})]})},e[1]=s,e[2]=he):he=e[2];const G=he;let le;e[3]!==s?(le=(at,ut,pt)=>n.jsxs(Zt,{onClick:pt,className:"flex items-center justify-between",children:[n.jsx("span",{children:s(at)}),ut?me:null]}),e[3]=s,e[4]=le):le=e[4];const ye=le;let Ie;e[5]===Symbol.for("react.memo_cache_sentinel")?(Ie=n.jsx(Q,{name:"checkbox-multiple",className:"h-4 w-4"}),e[5]=Ie):Ie=e[5];let K;e[6]!==$||e[7]!==s?(K=s($?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[6]=$,e[7]=s,e[8]=K):K=e[8];let se;e[9]!==K?(se=n.jsx("span",{children:K}),e[9]=K,e[10]=se):se=e[10];let U;e[11]!==se||e[12]!==D?(U=n.jsxs(Zt,{onClick:D,className:"flex items-center gap-2",children:[Ie,se]},"select"),e[11]=se,e[12]=D,e[13]=U):U=e[13];let ie;if(e[14]!==G||e[15]!==S||e[16]!==H||e[17]!==w||e[18]!==ce||e[19]!==V||e[20]!==L||e[21]!==F||e[22]!==A||e[23]!==Ee||e[24]!==X||e[25]!==N||e[26]!==I||e[27]!==C||e[28]!==ee||e[29]!==te||e[30]!==W||e[31]!==P||e[32]!==o||e[33]!==c||e[34]!==Y||e[35]!==M||e[36]!==s||e[37]!==U||e[38]!==ve||e[39]!==ye||e[40]!==re){if(ie=[U],o){let at;e[42]!==s?(at=s("sessions.sidebar.header.viewMode.label"),e[42]=s,e[43]=at):at=e[43];let ut;e[44]!==at?(ut=n.jsx(aa,{children:at}),e[44]=at,e[45]=ut):ut=e[45];let pt;e[46]!==ee||e[47]!==M||e[48]!==s?(pt=[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(St=>{const[ct,oe]=St;return n.jsxs(Zt,{onClick:()=>{ee(ct),on({sidebarViewMode:ct})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(oe)}),M===ct?me:null]},ct)}),e[46]=ee,e[47]=M,e[48]=s,e[49]=pt):pt=e[49];let lt;e[50]!==ut||e[51]!==pt?(lt=n.jsxs(n.Fragment,{children:[ut,pt]}),e[50]=ut,e[51]=pt,e[52]=lt):lt=e[52],ie.push(lt)}if(!ve){let at;if(e[53]!==G||e[54]!==L||e[55]!==X){let St;e[57]!==X?(St=ct=>{X(ct),on({sidebarProjectSortOrder:ct})},e[57]=X,e[58]=St):St=e[58],at=G("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"]],L,St),e[53]=G,e[54]=L,e[55]=X,e[56]=at}else at=e[56];let ut;e[59]!==G||e[60]!==te||e[61]!==o||e[62]!==re?(ut=o?G("sessions.sidebar.header.actions.sortWorktrees",[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]],re,St=>{te(St),on({sidebarWorktreeSortOrder:St})}):null,e[59]=G,e[60]=te,e[61]=o,e[62]=re,e[63]=ut):ut=e[63];let pt;e[64]!==G||e[65]!==V||e[66]!==Ee||e[67]!==o?(pt=o?G("sessions.sidebar.header.projectDisplay.label",[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]],V,St=>{Ee(St),on({sidebarProjectDisplayMode:St})}):null,e[64]=G,e[65]=V,e[66]=Ee,e[67]=o,e[68]=pt):pt=e[68];let lt;e[69]!==at||e[70]!==ut||e[71]!==pt?(lt=n.jsxs(n.Fragment,{children:[at,ut,pt]}),e[69]=at,e[70]=ut,e[71]=pt,e[72]=lt):lt=e[72],ie.push(lt)}if(c){let at;e[73]!==N||e[74]!==W?(at=()=>{N(!W),on({sidebarShowChatsSection:!W})},e[73]=N,e[74]=W,e[75]=at):at=e[75];let ut;e[76]!==W||e[77]!==at||e[78]!==ye?(ut=ye("sessions.sidebar.header.displayMode.showChats",W,at),e[76]=W,e[77]=at,e[78]=ye,e[79]=ut):ut=e[79];let pt;e[80]!==I||e[81]!==P?(pt=()=>{I(!P),on({sidebarShowPinnedSection:!P})},e[80]=I,e[81]=P,e[82]=pt):pt=e[82];let lt;e[83]!==P||e[84]!==pt||e[85]!==ye?(lt=ye("sessions.sidebar.header.displayMode.showPinned",P,pt),e[83]=P,e[84]=pt,e[85]=ye,e[86]=lt):lt=e[86];let St;e[87]!==F||e[88]!==C||e[89]!==Y||e[90]!==ye?(St=F?ye("sessions.sidebar.header.displayMode.showWork",Y,()=>{C(!Y),on({sidebarShowWorkSection:!Y})}):null,e[87]=F,e[88]=C,e[89]=Y,e[90]=ye,e[91]=St):St=e[91];let ct;e[92]!==H||e[93]!==A||e[94]!==ve||e[95]!==ye?(ct=ve?null:ye("sessions.sidebar.header.displayMode.detailedZoneRows",H,()=>{A(!H),on({sidebarDetailedZoneRows:!H})}),e[92]=H,e[93]=A,e[94]=ve,e[95]=ye,e[96]=ct):ct=e[96];let oe;e[97]!==lt||e[98]!==St||e[99]!==ct||e[100]!==ut?(oe=n.jsxs(n.Fragment,{children:[ut,lt,St,ct]}),e[97]=lt,e[98]=St,e[99]=ct,e[100]=ut,e[101]=oe):oe=e[101],ie.push(oe)}if(!ce){let at;e[102]===Symbol.for("react.memo_cache_sentinel")?(at=n.jsx(Q,{name:"contract-up-down",className:"h-4 w-4"}),e[102]=at):at=e[102];let ut;e[103]!==s?(ut=s("sessions.sidebar.header.displayMode.collapseAll"),e[103]=s,e[104]=ut):ut=e[104];let pt;e[105]!==ut?(pt=n.jsx("span",{children:ut}),e[105]=ut,e[106]=pt):pt=e[106];let lt;e[107]!==S||e[108]!==pt?(lt=n.jsxs(Zt,{onClick:S,className:"flex items-center gap-2",children:[at,pt]}),e[107]=S,e[108]=pt,e[109]=lt):lt=e[109];let St;e[110]===Symbol.for("react.memo_cache_sentinel")?(St=n.jsx(Q,{name:"expand-up-down",className:"h-4 w-4"}),e[110]=St):St=e[110];let ct;e[111]!==s?(ct=s("sessions.sidebar.header.displayMode.expandAll"),e[111]=s,e[112]=ct):ct=e[112];let oe;e[113]!==ct?(oe=n.jsx("span",{children:ct}),e[113]=ct,e[114]=oe):oe=e[114];let q;e[115]!==w||e[116]!==oe?(q=n.jsxs(Zt,{onClick:w,className:"flex items-center gap-2",children:[St,oe]}),e[115]=w,e[116]=oe,e[117]=q):q=e[117];let fe;e[118]!==lt||e[119]!==q?(fe=n.jsxs(n.Fragment,{children:[lt,q]}),e[118]=lt,e[119]=q,e[120]=fe):fe=e[120],ie.push(fe)}e[14]=G,e[15]=S,e[16]=H,e[17]=w,e[18]=ce,e[19]=V,e[20]=L,e[21]=F,e[22]=A,e[23]=Ee,e[24]=X,e[25]=N,e[26]=I,e[27]=C,e[28]=ee,e[29]=te,e[30]=W,e[31]=P,e[32]=o,e[33]=c,e[34]=Y,e[35]=M,e[36]=s,e[37]=U,e[38]=ve,e[39]=ye,e[40]=re,e[41]=ie}else ie=e[41];if(i){let at;e[121]!==s?(at=s("sessions.sidebar.header.search.placeholder"),e[121]=s,e[122]=at):at=e[122];let ut;e[123]!==s?(ut=s("sessions.sidebar.header.search.clear"),e[123]=s,e[124]=ut):ut=e[124];let pt;e[125]!==b||e[126]!==h||e[127]!==s?(pt=b?h===1?s("sessions.sidebar.header.search.matchCountSingle",{count:h}):s("sessions.sidebar.header.search.matchCountPlural",{count:h}):void 0,e[125]=b,e[126]=h,e[127]=s,e[128]=pt):pt=e[128];let lt;e[129]!==s?(lt=s("sessions.sidebar.header.search.escapeHint"),e[129]=s,e[130]=lt):lt=e[130];let St;return e[131]!==g||e[132]!==y||e[133]!==v||e[134]!==x||e[135]!==lt||e[136]!==at||e[137]!==ut||e[138]!==pt?(St=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1.5",children:n.jsx(cc,{inputRef:y,value:v,onSearch:x,onClose:g,placeholder:at,clearLabel:ut,leadingHint:pt,trailingHint:lt})}),e[131]=g,e[132]=y,e[133]=v,e[134]=x,e[135]=lt,e[136]=at,e[137]=ut,e[138]=pt,e[139]=St):St=e[139],St}let we;e[140]!==f||e[141]!==u||e[142]!==E||e[143]!==d||e[144]!==s?(we=d?n.jsx(oo,{label:s("sourceBoard.title"),pressed:E,onClick:()=>de.getState().setSourceBoardOpen(!E),className:f,children:n.jsx(Q,{name:"todo",className:u})}):null,e[140]=f,e[141]=u,e[142]=E,e[143]=d,e[144]=s,e[145]=we):we=e[145];let pe;e[146]!==s?(pe=s("sessions.sidebar.header.actions.scheduledTasks"),e[146]=s,e[147]=pe):pe=e[147];let Se;e[148]!==R?(Se=()=>de.getState().setScheduledTasksDialogOpen(!R),e[148]=R,e[149]=Se):Se=e[149];let Ce;e[150]!==u?(Ce=n.jsx(Q,{name:"calendar-schedule",className:u}),e[150]=u,e[151]=Ce):Ce=e[151];let Oe;e[152]!==f||e[153]!==R||e[154]!==Ce||e[155]!==pe||e[156]!==Se?(Oe=n.jsx(oo,{label:pe,pressed:R,onClick:Se,className:f,children:Ce}),e[152]=f,e[153]=R,e[154]=Ce,e[155]=pe,e[156]=Se,e[157]=Oe):Oe=e[157];let B;e[158]!==s?(B=s("sessions.sidebar.nav.archive"),e[158]=s,e[159]=B):B=e[159];let ae;e[160]!==z?(ae=()=>de.getState().setArchivePageOpen(!z),e[160]=z,e[161]=ae):ae=e[161];let xe;e[162]!==u?(xe=n.jsx(Q,{name:"archive",className:u}),e[162]=u,e[163]=xe):xe=e[163];let Te;e[164]!==f||e[165]!==z||e[166]!==B||e[167]!==ae||e[168]!==xe?(Te=n.jsx(oo,{label:B,pressed:z,onClick:ae,className:f,children:xe}),e[164]=f,e[165]=z,e[166]=B,e[167]=ae,e[168]=xe,e[169]=Te):Te=e[169];let Ge;e[170]!==Oe||e[171]!==Te||e[172]!==we?(Ge=n.jsxs("div",{ref:k,className:"flex items-center gap-1.5",children:[we,Oe,Te]}),e[170]=Oe,e[171]=Te,e[172]=we,e[173]=Ge):Ge=e[173];let st;e[174]!==r||e[175]!==O||e[176]!==f||e[177]!==u||e[178]!==_||e[179]!==s?(st=O?r.map(at=>{const ut=_===at.id;return n.jsx(oo,{label:at.pageTitle??at.name,pressed:ut,onClick:()=>de.getState().setOpenGuestPage(ut?null:at.id),className:f,children:n.jsx(ur,{icon:Cf(at.icon),iconSrc:jf(at.id,at.icon,xu().authenticatedAsset),className:u})},at.id)}):r.length>0&&n.jsxs(Ts,{children:[n.jsx(Ds,{asChild:!0,children:n.jsx(It,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":s("sessions.sidebar.header.actions.extensionPages"),children:n.jsx(Q,{name:"puzzle",className:u})})}),n.jsxs(Rs,{align:"start",children:[n.jsx(aa,{children:s("sessions.sidebar.header.actions.extensionPages")}),r.map(kC)]})]}),e[174]=r,e[175]=O,e[176]=f,e[177]=u,e[178]=_,e[179]=s,e[180]=st):st=e[180];let rt;e[181]!==Ge||e[182]!==st?(rt=n.jsxs("div",{className:"ms-[3px] flex min-w-0 items-center gap-1.5",children:[Ge,st]}),e[181]=Ge,e[182]=st,e[183]=rt):rt=e[183];const Ke=p?g:m,ke=p?uh:fh;let ge;e[184]!==f||e[185]!==ke?(ge=De(f,ke),e[184]=f,e[185]=ke,e[186]=ge):ge=e[186];let Ve;e[187]!==s?(Ve=s("sessions.sidebar.header.actions.searchSessions"),e[187]=s,e[188]=Ve):Ve=e[188];let Ue;e[189]!==u?(Ue=n.jsx(Q,{name:"search",className:u}),e[189]=u,e[190]=Ue):Ue=e[190];let ft;e[191]!==p||e[192]!==Ke||e[193]!==ge||e[194]!==Ve||e[195]!==Ue?(ft=n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ke,className:ge,"aria-label":Ve,"aria-expanded":p,children:Ue})}),e[191]=p,e[192]=Ke,e[193]=ge,e[194]=Ve,e[195]=Ue,e[196]=ft):ft=e[196];let Qe;e[197]!==s?(Qe=s("sessions.sidebar.header.actions.searchSessions"),e[197]=s,e[198]=Qe):Qe=e[198];let wt;e[199]!==Qe?(wt=n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Qe})}),e[199]=Qe,e[200]=wt):wt=e[200];let Me;e[201]!==ft||e[202]!==wt?(Me=n.jsxs(Kt,{children:[ft,wt]}),e[201]=ft,e[202]=wt,e[203]=Me):Me=e[203];let Pe;e[204]!==f?(Pe=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[204]=f,e[205]=Pe):Pe=e[205];let ot;e[206]!==s?(ot=s("sessions.sidebar.header.actions.addProject"),e[206]=s,e[207]=ot):ot=e[207];let et;e[208]!==u?(et=n.jsx(Q,{name:"folder-add",className:u}),e[208]=u,e[209]=et):et=e[209];let Ze;e[210]!==a||e[211]!==Pe||e[212]!==ot||e[213]!==et?(Ze=n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:a,className:Pe,"aria-label":ot,children:et})}),e[210]=a,e[211]=Pe,e[212]=ot,e[213]=et,e[214]=Ze):Ze=e[214];let dt;e[215]!==s?(dt=s("sessions.sidebar.header.actions.addProject"),e[215]=s,e[216]=dt):dt=e[216];let J;e[217]!==dt?(J=n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:dt})}),e[217]=dt,e[218]=J):J=e[218];let _e;e[219]!==Ze||e[220]!==J?(_e=n.jsxs(Kt,{children:[Ze,J]}),e[219]=Ze,e[220]=J,e[221]=_e):_e=e[221];let Le;e[222]!==f?(Le=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[222]=f,e[223]=Le):Le=e[223];let He;e[224]!==s?(He=s("sessions.sidebar.header.displayMode.label"),e[224]=s,e[225]=He):He=e[225];let $e;e[226]!==u?($e=n.jsx(Q,{name:"equalizer-2",className:u}),e[226]=u,e[227]=$e):$e=e[227];let tt;e[228]!==Le||e[229]!==He||e[230]!==$e?(tt=n.jsx(zt,{asChild:!0,children:n.jsx(Ds,{asChild:!0,children:n.jsx("button",{type:"button",className:Le,"aria-label":He,children:$e})})}),e[228]=Le,e[229]=He,e[230]=$e,e[231]=tt):tt=e[231];let bt;e[232]!==s?(bt=s("sessions.sidebar.header.displayMode.label"),e[232]=s,e[233]=bt):bt=e[233];let ht;e[234]!==bt?(ht=n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:bt})}),e[234]=bt,e[235]=ht):ht=e[235];let it;e[236]!==tt||e[237]!==ht?(it=n.jsxs(Kt,{children:[tt,ht]}),e[236]=tt,e[237]=ht,e[238]=it):it=e[238];let Mt;e[239]!==ie?(Mt=n.jsx(Rs,{align:"end",className:"min-w-[200px]",children:ie.map(wC)}),e[239]=ie,e[240]=Mt):Mt=e[240];let nt;e[241]!==it||e[242]!==Mt?(nt=n.jsxs(Ts,{children:[it,Mt]}),e[241]=it,e[242]=Mt,e[243]=nt):nt=e[243];let Lt;e[244]!==Me||e[245]!==_e||e[246]!==nt?(Lt=n.jsxs("div",{ref:T,className:"flex min-w-0 items-center gap-1.5",children:[Me,_e,nt]}),e[244]=Me,e[245]=_e,e[246]=nt,e[247]=Lt):Lt=e[247];let _t;e[248]!==rt||e[249]!==Lt?(_t=n.jsxs("div",{ref:j,className:"flex min-h-8 flex-wrap items-center justify-between gap-2",children:[rt,Lt]}),e[248]=rt,e[249]=Lt,e[250]=_t):_t=e[250];let Tt;e[251]!==g||e[252]!==b||e[253]!==p||e[254]!==h||e[255]!==y||e[256]!==v||e[257]!==x||e[258]!==s?(Tt=p?n.jsx("div",{className:"pb-1",children:n.jsx(cc,{inputRef:y,value:v,onSearch:x,onClose:g,placeholder:s("sessions.sidebar.header.search.placeholder"),clearLabel:s("sessions.sidebar.header.search.clear"),leadingHint:b?h===1?s("sessions.sidebar.header.search.matchCountSingle",{count:h}):s("sessions.sidebar.header.search.matchCountPlural",{count:h}):void 0,trailingHint:s("sessions.sidebar.header.search.escapeHint")})}):null,e[251]=g,e[252]=b,e[253]=p,e[254]=h,e[255]=y,e[256]=v,e[257]=x,e[258]=s,e[259]=Tt):Tt=e[259];let Ae;return e[260]!==_t||e[261]!==Tt?(Ae=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,Tt]})}),e[260]=_t,e[261]=Tt,e[262]=Ae):Ae=e[262],Ae}function wC(t,e){return n.jsxs(l.Fragment,{children:[e>0?n.jsx(jn,{}):null,t]},e)}function kC(t){return n.jsxs(Zt,{onSelect:()=>de.getState().setOpenGuestPage(t.id),children:[n.jsx(ur,{icon:Cf(t.icon),iconSrc:jf(t.id,t.icon,xu().authenticatedAsset),className:"size-4"}),n.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function jC(t){return t.setProjectDisplayMode}function CC(t){return t.projectDisplayMode}function PC(t){return t.setSidebarViewMode}function EC(t){return t.sidebarViewMode}function IC(t){return t.setWorktreeSortOrder}function TC(t){return t.worktreeSortOrder}function DC(t){return t.setProjectSortOrder}function RC(t){return t.projectSortOrder}function NC(t){return t.sessionWorkEnabled}function MC(t){return t.setDetailedZoneRows}function AC(t){return t.detailedZoneRows}function OC(t){return t.setShowPinnedSection}function BC(t){return t.showPinnedSection}function FC(t){return t.setShowWorkSection}function LC(t){return t.showWorkSection}function _C(t){return t.setShowChatsSection}function $C(t){return t.showChatsSection}function zC(t){return t.openGuestPageId}function KC(t){return t.isArchivePageOpen}function WC(t){return t.isScheduledTasksDialogOpen}function HC(t){return t.isSourceBoardOpen}function VC(t){return t.toggleMode}function UC(t){return t.enabled}function GC(t){const e=Xe.c(2),{className:s}=t,[r]=l.useState(qC);if(!r)return null;let i;return e[0]!==s?(i=n.jsx(YC,{className:s}),e[0]=s,e[1]=i):i=e[1],i}function qC(){return un()}function YC({className:t}){const{t:e}=Ct(),s=de(k=>k.shortcutOverrides),[r,i]=l.useState(!1),[o,c]=l.useState("Local"),[a,d]=l.useState(!0),[u,f]=l.useState(!1),[p,m]=l.useState(null),[g,y]=l.useState(!1),[v,x]=l.useState(null),b=l.useCallback(async()=>{try{if(Qo()){c("Local"),d(!0);return}d(!1);const k=await Zo(),T=Zm(Jm(k.hosts,k.localOrigin));if(T.id===eg){c("Local"),d(!0);return}c(Su(T.label.trim()||"Instance"))}catch{c("Local"),d(!0)}},[]);l.useEffect(()=>(b(),Go(()=>{b()})),[b]);const h=l.useCallback(async()=>{if(a){m(null),x(null);return}y(!0),x(null);try{const k=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),T=await Gs(`/api/openchamber/update-check?${k.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!T.ok)throw new Error(`Server responded with ${T.status}`);m(lb(await T.json()))}catch(k){m(null),x(k instanceof Error?k.message:e("header.services.remoteUpdate.error"))}finally{y(!1)}},[a,e]);l.useEffect(()=>{m(null),x(null),f(!1)},[a,o]),l.useEffect(()=>{if(a)return;const k=3e3,T=3600*1e3;let O=!1,$=null;const D=E=>{$=window.setTimeout(()=>{if(O||typeof document<"u"&&document.visibilityState!=="visible"){D(T);return}h().finally(()=>{O||D(T)})},E)};return D(k),()=>{O=!0,$!==null&&window.clearTimeout($)}},[h,a,o]);const S=l.useCallback(()=>{if(p?.available){f(!0);return}h()},[h,p?.available]),w=l.useCallback(k=>{i(k),k&&b()},[b]);sf({toggle_services_menu:()=>{if(r){i(!1);return}const k=de.getState();k.isSidebarOpen||k.setSidebarOpen(!0),w(!0)}});const j=rf(of("toggle_services_menu",s));return n.jsxs(n.Fragment,{children:[n.jsxs(Ts,{open:r,onOpenChange:w,children:[n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx(Ds,{asChild:!0,children:n.jsxs("button",{type:"button","aria-label":e("header.services.openWithCurrent",{current:o}),className:t,children:[n.jsx(Q,{name:"server",className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate typography-ui-label",children:o})]})})}),n.jsx(Ft,{side:"top",sideOffset:4,children:n.jsx("p",{children:e("header.services.tooltip.currentInstance",{current:o,toggle:j})})})]}),n.jsxs(Rs,{side:"top",align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:[a?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:p?.available?e("header.services.remoteUpdate.available",{version:p.version||""}):g?e("header.services.remoteUpdate.checking"):v||e("header.services.remoteUpdate.upToDate")})]}),p?.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:S,children:e("header.services.remoteUpdate.actions.open")}):null]})}),n.jsx(Cx,{embedded:!0,open:r,onOpenChange:()=>{},onHostSwitched:()=>i(!1)})]})]}),n.jsx(Ya,{open:u,onOpenChange:f,info:p,downloading:!1,downloaded:!1,progress:null,error:v,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const gr="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",XC="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground";function QC(t){const e=Xe.c(28),{onOpenSettings:s,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:c,showUpdateButton:a}=t,d=c===void 0?!0:c,u=a===void 0?!0:a,{t:f}=Ct(),p=cb(),m=de(ZC);if(!d&&!u)return null;let g;e[0]!==p||e[1]!==f?(g=f(p?"sessions.sidebar.footer.actions.updateApp":"sessions.sidebar.footer.actions.update"),e[0]=p,e[1]=f,e[2]=g):g=e[2];const y=g;let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=De(gr,"text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]"),e[3]=v):v=e[3];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Q,{name:"download",className:"h-4 w-4"}),e[4]=x):x=e[4];let b;e[5]!==o||e[6]!==y?(b=n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:v,"aria-label":y,children:x})}),e[5]=o,e[6]=y,e[7]=b):b=e[7];let h;e[8]!==y?(h=n.jsx(Ft,{side:"top",sideOffset:4,children:n.jsx("p",{children:y})}),e[8]=y,e[9]=h):h=e[9];let S;e[10]!==b||e[11]!==h?(S=n.jsxs(Kt,{children:[b,h]}),e[10]=b,e[11]=h,e[12]=S):S=e[12];const w=S;let j;e[13]!==m||e[14]!==i||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(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:s,className:gr,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:n.jsx(Q,{name:"settings-3",className:"h-4 w-4"})})}),n.jsx(Ft,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>de.getState().setUsageStatsPageOpen(!m),className:De(gr,m&&XC),"aria-label":f("usageStats.openAction"),"aria-pressed":m,children:n.jsx(Q,{name:"bar-chart",className:"h-4 w-4"})})}),n.jsx(Ft,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("usageStats.openAction")})})]}),n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:r,className:gr,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:n.jsx(Q,{name:"command",className:"h-4 w-4"})})}),n.jsx(Ft,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),u?w:n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:i,className:gr,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:n.jsx(Q,{name:"information",className:"h-4 w-4"})})}),n.jsx(Ft,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[13]=m,e[14]=i,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 T;e[22]!==d?(T=d?n.jsx(GC,{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]=T):T=e[23];let O;return e[24]!==k||e[25]!==T||e[26]!==j?(O=n.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[j,k,T]}),e[24]=k,e[25]=T,e[26]=j,e[27]=O):O=e[27],O}function ZC(t){return t.isUsageStatsPageOpen}function JC(t){const e=Xe.c(19),{query:s,showArchive:r,resetSessionSearch:i}=t,{t:o}=Ct();let c;e[0]!==s||e[1]!==i?(c=()=>{de.getState().setArchivePageOpen(!0,s),i()},e[0]=s,e[1]=i,e[2]=c):c=e[2];const a=c;let d;e[3]!==o?(d=o("sessions.sidebar.empty.noMatches.title"),e[3]=o,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]!==o?(f=o("sessions.sidebar.empty.noMatches.description"),e[7]=o,e[8]=f):f=e[8];let p;e[9]!==f?(p=n.jsx("p",{className:"typography-meta mt-1",children:f}),e[9]=f,e[10]=p):p=e[10];let m;e[11]!==a||e[12]!==r||e[13]!==o?(m=r?n.jsx(It,{variant:"link",size:"xs",className:"mt-2 h-auto p-0 typography-meta",onClick:a,children:o("sessions.sidebar.empty.noMatches.searchArchive")}):null,e[11]=a,e[12]=r,e[13]=o,e[14]=m):m=e[14];let g;return e[15]!==u||e[16]!==p||e[17]!==m?(g=n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[u,p,m]}),e[15]=u,e[16]=p,e[17]=m,e[18]=g):g=e[18],g}const e3=t=>{for(const e of t.sessions.values())if(e.tabs.some(vu))return!0;return!1},t3=()=>{const t=Xe.c(4),{terminal:e}=Ws(),s=Bt(e3);let r,i;return t[0]!==s||t[1]!==e?(r=()=>{const o=s3,c=n3;if(s)return ra(e,"",c,o);let a=r3;return a=ra(e,"",c,d=>{o(d),a()}),()=>a()},i=[e,s],t[0]=s,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),l.useEffect(r,i),null};function s3(t){const e=Bt.getState(),s=db(t.sessions),r=new Set([...e.sessions.keys(),...s.keys()]);for(const i of r)e.reconcileServerSessions(i,s.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function n3(){return new Map(Bt.getState().actionMutationRevisions)}function r3(){}const o3=50,i3=t=>{const e=new Map;for(const s of t){const r=vt(s.directory),i=s.branch.trim();if(!(!r||!i||e.has(r))&&(e.set(r,{directory:r,branch:i}),e.size===o3))break}return[...e.values()]},a3=t=>{const e=Xe.c(12),{normalizedProjects:s,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:c,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:f,addSessionToFolder:p}=t,m=r===void 0?!0:r;let g,y;e[0]!==p||e[1]!==f||e[2]!==m||e[3]!==u||e[4]!==c||e[5]!==o||e[6]!==a||e[7]!==s||e[8]!==i||e[9]!==d?(g=()=>{!m||o||!c||a||s.forEach(v=>{if(d.has(v.normalizedPath))return;const x=Tf(v.normalizedPath),b=i.archivedSessionsByProject.get(v.id)??[],h=u[x]??[],S=new Map(h.map(l3));b.forEach(w=>{const j=Px(w,v.normalizedPath),k=j.toLowerCase();let T=S.get(k);T||(T=f(x,j),S.set(k,T)),T.sessionIds.includes(w.id)||p(x,T.id,w.id)})})},y=[s,m,i,o,c,a,d,u,f,p],e[0]=p,e[1]=f,e[2]=m,e[3]=u,e[4]=c,e[5]=o,e[6]=a,e[7]=s,e[8]=i,e[9]=d,e[10]=g,e[11]=y):(g=e[10],y=e[11]),l.useEffect(g,y)};function l3(t){return[t.name.toLowerCase(),t]}function c3({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:s,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:c}){if(e&&s===t)return{kind:"preserve-current"};if(s==null){const u=!!(e&&Array.from(i.entries()).some(([f,p])=>f!==t&&p.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??c;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const d3=t=>{const e=Xe.c(26),{projectSections:s,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:c,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:f,openNewSessionDraft:p,setSessionSwitcherOpen:m}=t;let g,y;if(e[0]!==s){y=new Map,g=new Map;const k=(T,O,$,D)=>{y.has(T)||y.set(T,new Map);const E=y.get(T);D.forEach(R=>{const z=vt(R.worktree?.path??R.session.directory??$??O);E.set(R.session.id,{directory:z}),g.has(T)||g.set(T,{id:R.session.id,directory:z}),R.children.length>0&&k(T,O,z,R.children)})};s.forEach(T=>{T.groups.forEach(O=>{k(T.project.id,T.project.normalizedPath,O.directory,O.sessions)})}),e[0]=s,e[1]=g,e[2]=y}else g=e[1],y=e[2];let v;e[3]!==g||e[4]!==y?(v={metaByProject:y,firstSessionByProject:g},e[3]=g,e[4]=y,e[5]=v):v=e[5];const x=v,b=l.useRef(null);let h,S;e[6]!==r||e[7]!==i||e[8]!==c||e[9]!==a||e[10]!==d||e[11]!==f||e[12]!==u||e[13]!==p||e[14]!==s||e[15]!==x||e[16]!==o||e[17]!==m?(h=()=>{if(!r||u||de.getState().isNewWorktreeDialogOpen||b.current===r)return;const k=s.find(D=>D.project.id===r);if(!k)return;if(b.current===null){b.current=r;return}const T=x.metaByProject.get(r);if(c&&T&&T.has(c)){b.current=r,o(D=>{if(D.get(r)===c)return D;const E=new Map(D);return E.set(r,c),E});return}const O=c3({activeProjectId:r,currentSessionId:c,currentSessionOwnerProjectId:a,projectMap:T,metaByProject:x.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(O.kind==="preserve-current"){a===r&&(b.current=r);return}if(b.current=r,O.kind==="open-draft"){f&&m(!1),p({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(O.kind!=="select-session")return;const $=T?.get(O.sessionId)?.directory??null;d(O.sessionId,$)},S=[r,i,c,a,d,u,f,p,s,x,m,o],e[6]=r,e[7]=i,e[8]=c,e[9]=a,e[10]=d,e[11]=f,e[12]=u,e[13]=p,e[14]=s,e[15]=x,e[16]=o,e[17]=m,e[18]=h,e[19]=S):(h=e[18],S=e[19]),l.useLayoutEffect(h,S);let w,j;e[20]!==r||e[21]!==c||e[22]!==x||e[23]!==o?(w=()=>{if(!r||!c)return;const k=x.metaByProject.get(r);!k||!k.has(c)||o(T=>{if(T.get(r)===c)return T;const O=new Map(T);return O.set(r,c),O})},j=[r,c,x,o],e[20]=r,e[21]=c,e[22]=x,e[23]=o,e[24]=w,e[25]=j):(w=e[24],j=e[25]),l.useEffect(w,j)},u3=t=>{const e=Xe.c(20);let s,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...s}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=i,e[4]=o):(s=e[1],r=e[2],i=e[3],o=e[4]);const c=xt(f3),a=xt(p3);let d;e[5]!==c||e[6]!==o?(d=c?o?.get(c)?.projectId??null:null,e[5]=c,e[6]=o,e[7]=d):d=e[7];const u=d;let f;e[8]!==r?(f=()=>new Map(r),e[8]=r,e[9]=f):f=e[9];const[p,m]=l.useState(f);let g;e[10]!==p||e[11]!==s||e[12]!==c||e[13]!==u||e[14]!==a?(g={...s,activeSessionByProject:p,setActiveSessionByProject:m,currentSessionId:c,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=p,e[11]=s,e[12]=c,e[13]=u,e[14]=a,e[15]=g):g=e[15],d3(g);let y,v;return e[16]!==p||e[17]!==i?(y=()=>{i(p)},v=[p,i],e[16]=p,e[17]=i,e[18]=y,e[19]=v):(y=e[18],v=e[19]),l.useEffect(y,v),null};function f3(t){return t.currentSessionId}function p3(t){return!!t.newSessionDraft?.open}const h3=t=>{const e=Xe.c(7),{ownership:s}=t;let r;e[0]!==s?(r=d=>s.sessionsByProject.get(d)??[],e[0]=s,e[1]=r):r=e[1];const i=r;let o;e[2]!==s?(o=d=>s.archivedSessionsByProject.get(d)??[],e[2]=s,e[3]=o):o=e[3];const c=o;let a;return e[4]!==c||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:c},e[4]=c,e[5]=i,e[6]=a):a=e[6],a},m3=(t,e)=>t.map(s=>{const r=vt(s.path)??s.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
1045
|
+
`),g3=(t,e,s)=>e.length===0?"":t.map(r=>s.get(r.id)??"").join(","),b3=[],y3=new WeakMap,x3=t=>{const{normalizedProjects:e,getSessionsForProject:s,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:c,gitBranches:a,sessionOrderRanks:d,lastRepoStatus:u,buildGroupedSessions:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:m,filterSessionNodesForSearch:g,buildGroupSearchText:y,foldersMap:v,standaloneGroups:x}=t,b=l.useRef(new Map),h=l.useMemo(()=>{const D=b.current,E=new Map;let R=0,z=0;const _=(N,Y)=>N.length===Y.length&&N.every((C,P)=>C===Y[P]),W=e.map(N=>{const Y=s(N.id),C=r(N.id),P=i.get(N.normalizedPath)??b3,I=o.has(N.id)?!!o.get(N.id):u,H=c.get(N.id)??null,A=m3(P,a),F=g3(Y,P,d),L=D.get(N.id);if(L&&L.project===N&&_(L.activeSessions,Y)&&_(L.archivedSessions,C)&&L.availableWorktrees===P&&L.rootBranch===H&&L.worktreeBranchesKey===A&&L.worktreeRanksKey===F&&L.isRepo===I&&L.buildGroupedSessions===f)return R+=1,E.set(N.id,L),L.section;if(z+=1,L){const M=L.project!==N?"project":_(L.activeSessions,Y)?_(L.archivedSessions,C)?L.availableWorktrees!==P?"worktrees":L.rootBranch!==H?"branch":L.worktreeBranchesKey!==A?"worktreeBranches":L.worktreeRanksKey!==F?"worktreeRanks":L.isRepo!==I?"repo":"builder":"archived":"sessions";Cs(`ui.sidebar.project_section.rebuilt_reason.${M}`)}const X=Df([...Y,...C]),re=f(X,N.normalizedPath,P,H,I),te={project:N,groups:re};return E.set(N.id,{project:N,activeSessions:Y,archivedSessions:C,availableWorktrees:P,rootBranch:H,worktreeBranchesKey:A,worktreeRanksKey:F,isRepo:I,buildGroupedSessions:f,section:te}),te});return b.current=E,R>0&&Cs("ui.sidebar.project_section.reused",R),z>0&&Cs("ui.sidebar.project_section.rebuilt",z),W},[e,s,r,i,o,u,f,c,a,d]),S=l.useMemo(()=>h,[h]),w=l.useMemo(()=>{if(!p)return y3;const D=new WeakMap,R=m.trim().toLowerCase().startsWith("ses_"),z=_=>{const W=g(_.sessions,m),N=ch(W,m),Y=!R&&Do([y(_)],m),C=_n(_).flatMap(({scopeKey:I})=>v[I]??[]),P=R?0:C.filter(I=>Do([I.name],m)).length;D.set(_,{filteredNodes:W,matchedSessionCount:N,folderNameMatchCount:P,groupMatches:Y,hasMatch:Y||N>0||P>0})};return S.forEach(_=>{_.groups.forEach(z)}),x.forEach(z),D},[p,S,x,g,m,y,v]),j=l.useMemo(()=>p?S.map(D=>({...D,groups:D.groups.filter(E=>w.get(E)?.hasMatch===!0)})).filter(D=>D.groups.length>0):S,[p,S,w]),k=p?j:S,T=l.useRef(new WeakMap),O=l.useMemo(()=>{const D=T.current;return k.map(E=>{const R=D.get(E);if(R&&R.query===m)return R.section;const z=E.groups.filter(I=>!I.isArchivedBucket),_=E.groups.filter(I=>I.isArchivedBucket),W=z.flatMap(I=>p?w.get(I)?.filteredNodes??[]:I.sessions),N=z.map(I=>({scopeKey:I.folderScopeKey??vt(I.directory??null),directory:I.directory??null})).filter(I=>!!I.scopeKey),Y=z.find(I=>I.isMain)??null,C={id:"flat",label:Y?.label??"",branch:Y?.branch??null,description:Y?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:Y?.directory??E.project.normalizedPath,folderScopeKey:Y?.folderScopeKey??E.project.normalizedPath,folderScopes:N,sessions:W};if(p){const I=z.map(H=>w.get(H)).filter(H=>!!H);w.set(C,{filteredNodes:W,matchedSessionCount:I.reduce((H,A)=>H+A.matchedSessionCount,0),folderNameMatchCount:I.reduce((H,A)=>H+A.folderNameMatchCount,0),groupMatches:I.some(H=>H.groupMatches),hasMatch:I.some(H=>H.hasMatch)})}const P={project:E.project,groups:[C,..._]};return D.set(E,{query:m,section:P}),P})},[w,p,m,k]),$=l.useMemo(()=>{if(!p)return 0;const D=(R,z)=>{const _=w.get(z);if(!_)return R;const W=_.folderNameMatchCount+(_.groupMatches?1:0);return R+_.matchedSessionCount+W},E=k.reduce((R,z)=>z.groups.reduce(D,R),0);return x.reduce(D,E)},[p,k,x,w]);return{projectSections:h,visibleProjectSections:S,groupSearchDataByGroup:w,searchableProjectSections:j,sectionsForRender:k,flatSectionsForRender:O,searchMatchCount:$}},S3=180,Dd=150,v3=2,w3=8,Rd=[-1,1],io=t=>`${t.directory}
|
|
1046
|
+
${t.sessionId}`,Nd=t=>t?.directory?.trim()||null,ph=l.createContext(null),k3=()=>l.useContext(ph),j3=({enabled:t=!0,currentSessionId:e,sortedSessions:s,workSessions:r=[],prefetchSession:i})=>{const o=l.useRef(new Map),c=l.useRef(new Set),a=l.useRef([]),d=l.useRef(new Set),u=l.useRef(0),f=l.useMemo(()=>In(),[]),p=l.useCallback(()=>{u.current+=1,a.current=[],o.current.forEach(b=>window.clearTimeout(b)),o.current.clear(),c.current.clear()},[]),m=l.useCallback(()=>{if(!(!t||f))for(;d.current.size<v3&&a.current.length>0;){const b=a.current.shift();if(!b)break;if(b.generation!==u.current||xt.getState().currentSessionId===b.sessionId||ua(b.sessionId,b.directory).renderable)continue;const S=io(b);d.current.add(S),i({directory:b.directory,sessionID:b.sessionId}).catch(()=>{}).finally(()=>{d.current.delete(S),m()})}},[t,f,i]),g=l.useCallback((b,h="neighbor")=>{const S=b?.id,w=Nd(b);if(!t||f||!S||!w||S===e)return;const j={sessionId:S,directory:w,generation:u.current},k=io(j);if(ua(S,w).renderable||d.current.has(k)||a.current.some($=>io($)===k))return;const T=o.current.get(k);if(T!==void 0){if(h==="hover"&&!c.current.has(k))return;window.clearTimeout(T)}h==="hover"?c.current.add(k):c.current.delete(k);const O=window.setTimeout(()=>{if(o.current.delete(k),c.current.delete(k),j.generation!==u.current)return;const $=a.current;$.length>=w3&&$.shift(),$.push(j),m()},S3);o.current.set(k,O)},[e,t,f,m]),y=l.useCallback(b=>{const h=Nd(b);if(!h)return;const S=io({sessionId:b.id,directory:h}),w=o.current.get(S);w===void 0||!c.current.has(S)||(window.clearTimeout(w),o.current.delete(S),c.current.delete(S))},[]),v=l.useRef(g);v.current=g;const[x]=l.useState(()=>({schedule:b=>v.current(b,"hover"),cancel:y}));return l.useEffect(()=>{p()},[p,e,t,f]),l.useEffect(()=>{if(!t||f||!e||s.length===0)return;const b=window.setTimeout(()=>{const h=s.findIndex(S=>S.id===e);if(!(h<0))for(const S of Rd)g(s[h+S])},Dd);return()=>window.clearTimeout(b)},[e,t,f,g,s]),l.useEffect(()=>{if(!t||f||!e||r.length===0)return;const b=window.setTimeout(()=>{const h=r.findIndex(S=>S.id===e);if(!(h<0))for(const S of Rd)g(r[h+S])},Dd);return()=>window.clearTimeout(b)},[e,t,f,r,g]),l.useEffect(()=>p,[p]),x},C3=t=>{const e=Xe.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 i=xt(P3);let o;e[3]!==s||e[4]!==i?(o={...s,currentSessionId:i},e[3]=s,e[4]=i,e[5]=o):o=e[5];const c=j3(o);let a;if(e[6]!==r||e[7]!==c){let d;e[9]!==c?(d={value:c},e[9]=c,e[10]=d):d=e[10],a=l.createElement(ph.Provider,d,r),e[6]=r,e[7]=c,e[8]=a}else a=e[8];return a};function P3(t){return t.currentSessionId}const E3=6,$n=t=>qa(t,E3),Md=t=>`calc(${$n(t)} + 20px)`,I3=t=>{const e=Xe.c(92),{folder:s,displayName:r,sessions:i,subFolderItems:o,isCollapsed:c,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:f,children:p,renderBody:m,mobileVariant:g,alwaysShowActions:y,isRenaming:v,renameDraft:x,onRenameDraftChange:b,onRenameSave:h,onRenameCancel:S,droppableRef:w,isDropTarget:j,onNewSession:k,depth:T,canExpand:O,hideActions:$,archivedBucket:D}=t,E=a===void 0?null:a,R=m===void 0?!0:m,_=y===void 0?g===void 0?!1:g:y,W=v===void 0?!1:v,N=x===void 0?"":x,Y=j===void 0?!1:j,C=T===void 0?0:T,P=O===void 0?!0:O,I=$===void 0?!1:$,H=D===void 0?!1:D,{t:A}=Ct(),[F,L]=l.useState(!1),[X,re]=l.useState(""),te=l.useRef(null),M=W||F,ee=W?N:X;let V;e[0]!==s.name?(V=()=>{re(s.name),L(!0)},e[0]=s.name,e[1]=V):V=e[1];const Ee=V;let ve;e[2]!==ee||e[3]!==s.name||e[4]!==W||e[5]!==u||e[6]!==h?(ve=()=>{const Qe=ee.trim();Qe&&Qe!==s.name&&u(Qe),W&&h&&h(),L(!1),re("")},e[2]=ee,e[3]=s.name,e[4]=W,e[5]=u,e[6]=h,e[7]=ve):ve=e[7];const ce=ve;let Be;e[8]!==W||e[9]!==S?(Be=()=>{W&&S&&S(),L(!1),re("")},e[8]=W,e[9]=S,e[10]=Be):Be=e[10];const me=Be;let he;e[11]!==W||e[12]!==b?(he=Qe=>{W&&b?b(Qe):re(Qe)},e[11]=W,e[12]=b,e[13]=he):he=e[13];const G=he;let le,ye;e[14]!==W?(le=()=>{if(!W)return;const Qe=()=>{const Pe=te.current;Pe&&(Pe.focus(),Pe.select())},wt=requestAnimationFrame(Qe),Me=window.setTimeout(Qe,0);return()=>{cancelAnimationFrame(wt),window.clearTimeout(Me)}},ye=[W],e[14]=W,e[15]=le,e[16]=ye):(le=e[15],ye=e[16]),l.useEffect(le,ye);const Ie=c?"folder":"folder-open",K=!M&&P;let se;e[17]!==C?(se=$n(C),e[17]=C,e[18]=se):se=e[18];let U;e[19]!==se?(U={paddingInlineStart:se},e[19]=se,e[20]=U):U=e[20];const ie=Y&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let we;e[21]!==ie?(we=De("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",ie),e[21]=ie,e[22]=we):we=e[22];let pe;e[23]!==d||e[24]!==K?(pe=K?Qe=>{Qe.currentTarget.blur(),d()}:void 0,e[23]=d,e[24]=K,e[25]=pe):pe=e[25];const Se=K?"button":void 0,Ce=K?0:void 0;let Oe;e[26]!==d||e[27]!==K?(Oe=K?Qe=>{(Qe.key==="Enter"||Qe.key===" ")&&(Qe.preventDefault(),d())}:void 0,e[26]=d,e[27]=K,e[28]=Oe):Oe=e[28];let B;e[29]!==s.name||e[30]!==c||e[31]!==A||e[32]!==K?(B=K?c?A("sessions.sidebar.folderItem.expandAria",{folderName:s.name}):A("sessions.sidebar.folderItem.collapseAria",{folderName:s.name}):void 0,e[29]=s.name,e[30]=c,e[31]=A,e[32]=K,e[33]=B):B=e[33];const ae=H?_?"pe-7":"group-hover/folder:pe-7 group-has-[:focus-visible]/folder:pe-7":_?"pe-20":"group-hover/folder:pe-20 group-has-[:focus-visible]/folder:pe-20";let xe;e[34]!==ae?(xe=De("min-w-0 flex items-center gap-0.5 flex-1",ae),e[34]=ae,e[35]=xe):xe=e[35];let Te;e[36]!==P||e[37]!==c?(Te=P?n.jsx(Ar,{expanded:!c}):n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}),e[36]=P,e[37]=c,e[38]=Te):Te=e[38];const Ge=Y?"text-primary":"text-muted-foreground";let st;e[39]!==Ge?(st=De("mx-px h-3 w-3 flex-shrink-0",Ge),e[39]=Ge,e[40]=st):st=e[40];let rt;e[41]!==Ie||e[42]!==st?(rt=n.jsx(Q,{name:Ie,className:st}),e[41]=Ie,e[42]=st,e[43]=rt):rt=e[43];let Ke;e[44]!==E||e[45]!==r||e[46]!==ee||e[47]!==s.name||e[48]!==me||e[49]!==G||e[50]!==ce||e[51]!==Y||e[52]!==M||e[53]!==i||e[54]!==A?(Ke=M?n.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:T3,onMouseDown:D3,onSubmit:Qe=>{Qe.preventDefault(),ce()},children:[n.jsx("input",{ref:te,value:ee,onChange:Qe=>G(Qe.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:A("sessions.sidebar.folderItem.namePlaceholder"),onClick:R3,onPointerDown:N3,onMouseDown:M3,onKeyDown:Qe=>{if(Qe.key==="Escape"){Qe.stopPropagation(),me();return}(Qe.key===" "||Qe.key==="Enter")&&Qe.stopPropagation()}}),n.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:A3,onPointerDown:O3,onMouseDown:B3,children:n.jsx(Q,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:Qe=>{Qe.stopPropagation(),me()},onPointerDown:F3,onMouseDown:L3,className:"shrink-0 text-muted-foreground hover:text-foreground",children:n.jsx(Q,{name:"close",className:"size-4"})})]}):n.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("span",{className:De("typography-ui-label font-medium truncate",Y?"text-primary":"text-foreground/85"),children:r??s.name})}),n.jsx(Ft,{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:["• ",i.length]}),E?n.jsx(ub,{state:E}):null]}),e[44]=E,e[45]=r,e[46]=ee,e[47]=s.name,e[48]=me,e[49]=G,e[50]=ce,e[51]=Y,e[52]=M,e[53]=i,e[54]=A,e[55]=Ke):Ke=e[55];let ke;e[56]!==xe||e[57]!==Te||e[58]!==rt||e[59]!==Ke?(ke=n.jsxs("div",{className:xe,children:[Te,rt,Ke]}),e[56]=xe,e[57]=Te,e[58]=rt,e[59]=Ke,e[60]=ke):ke=e[60];let ge;e[61]!==_||e[62]!==H||e[63]!==s.name||e[64]!==Ee||e[65]!==I||e[66]!==f||e[67]!==k||e[68]!==M||e[69]!==A?(ge=!M&&(!I||H)?n.jsx("div",{className:De("absolute inset-e-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",_?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-has-[:focus-visible]/folder:opacity-100 group-has-[:focus-visible]/folder:pointer-events-auto"),children:n.jsxs("div",{className:"flex items-center gap-0.5",children:[!H&&k?n.jsx("button",{type:"button",onClick:Qe=>{Qe.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":A("sessions.sidebar.folderItem.newSessionAria",{folderName:s.name}),title:A("sessions.sidebar.project.actions.newSession"),children:n.jsx(Q,{name:"add",className:"h-3.5 w-3.5"})}):null,H?null:n.jsx("button",{type:"button",onClick:Qe=>{Qe.stopPropagation(),Ee()},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":A("sessions.sidebar.folderItem.renameAria",{folderName:s.name}),children:n.jsx(Q,{name:"pencil-ai",className:"h-3 w-3"})}),n.jsx("button",{type:"button",onClick:Qe=>{Qe.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?A("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:s.name}):A("sessions.sidebar.folderItem.deleteFolderAria",{folderName:s.name}),children:n.jsx(Q,{name:"delete-bin",className:"h-3 w-3"})})]})}):null,e[61]=_,e[62]=H,e[63]=s.name,e[64]=Ee,e[65]=I,e[66]=f,e[67]=k,e[68]=M,e[69]=A,e[70]=ge):ge=e[70];let Ve;e[71]!==w||e[72]!==U||e[73]!==we||e[74]!==pe||e[75]!==Se||e[76]!==Ce||e[77]!==Oe||e[78]!==B||e[79]!==ke||e[80]!==ge?(Ve=n.jsxs("div",{ref:w,style:U,className:we,onClick:pe,role:Se,tabIndex:Ce,onKeyDown:Oe,"aria-label":B,children:[ke,ge]}),e[71]=w,e[72]=U,e[73]=we,e[74]=pe,e[75]=Se,e[76]=Ce,e[77]=Oe,e[78]=B,e[79]=ke,e[80]=ge,e[81]=Ve):Ve=e[81];let Ue;e[82]!==p||e[83]!==c||e[84]!==R||e[85]!==i||e[86]!==o||e[87]!==A?(Ue=!c&&R?n.jsxs("div",{className:"pb-1",children:[o,i.length>0?p:o?null:n.jsx("div",{className:"py-1 ps-1.5 text-start typography-micro text-muted-foreground/70",children:A("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[82]=p,e[83]=c,e[84]=R,e[85]=i,e[86]=o,e[87]=A,e[88]=Ue):Ue=e[88];let ft;return e[89]!==Ve||e[90]!==Ue?(ft=n.jsxs("div",{className:"oc-folder",children:[Ve,Ue]}),e[89]=Ve,e[90]=Ue,e[91]=ft):ft=e[91],ft},hh=l.memo(I3);function T3(t){return t.stopPropagation()}function D3(t){return t.stopPropagation()}function R3(t){return t.stopPropagation()}function N3(t){return t.stopPropagation()}function M3(t){return t.stopPropagation()}function A3(t){return t.stopPropagation()}function O3(t){return t.stopPropagation()}function B3(t){return t.stopPropagation()}function F3(t){return t.stopPropagation()}function L3(t){return t.stopPropagation()}function _3(t){const e=Xe.c(11);let s,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:s,...i}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=i):(s=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let c;e[4]!==s||e[5]!==r||e[6]!==o?(c={nodes:s,includeUnreadSubtasks:r,enabled:o},e[4]=s,e[5]=r,e[6]=o,e[7]=c):c=e[7];const a=Ou(c);let d;return e[8]!==a||e[9]!==i?(d=n.jsx(hh,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=d):d=e[10],d}const $o=t=>{const e=Xe.c(16),{directory:s,className:r}=t,{t:i}=Ct();let o;e[0]!==s?(o=tg(s),e[0]=s,e[1]=o):o=e[1];const c=o;let a;if(e[2]!==c?(a=x=>x.sessions.get(c),e[2]=c,e[3]=a):a=e[3],!Bt(a)?.tabs.some(vu))return null;let f;e[4]!==i?(f=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=f):f=e[5];const p=f;let m;e[6]!==r?(m=De("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=m):m=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Q,{name:"pulse",className:"size-3.5"}),e[8]=g):g=e[8];let y;e[9]!==c||e[10]!==p||e[11]!==m?(y=n.jsx("span",{className:m,role:"img","aria-label":p,"data-action-directory":c,children:g}),e[9]=c,e[10]=p,e[11]=m,e[12]=y):y=e[12];let v;return e[13]!==p||e[14]!==y?(v=n.jsx(Fn,{label:p,children:y}),e[13]=p,e[14]=y,e[15]=v):v=e[15],v},$3=t=>{const e=Xe.c(19),{sessionId:s,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:c,archivedBucket:a,children:d}=t,u=i===void 0?null:i,f=a===void 0?!1:a,p=`session-drag:${r??s}`;let m;e[0]!==f||e[1]!==u||e[2]!==o||e[3]!==s||e[4]!==c?(m={type:"session",sessionId:s,ownerKey:u,sessionDirectory:o,sessionTitle:c,archivedBucket:f},e[0]=f,e[1]=u,e[2]=o,e[3]=s,e[4]=c,e[5]=m):m=e[5];let g;e[6]!==f||e[7]!==p||e[8]!==m?(g={id:p,disabled:f,data:m},e[6]=f,e[7]=p,e[8]=m,e[9]=g):g=e[9];const{attributes:y,listeners:v,setNodeRef:x,isDragging:b}=p1(g);let h;e[10]!==v?(h=k=>{k.stopPropagation(),v?.onPointerDown&&v.onPointerDown(k)},e[10]=v,e[11]=h):h=e[11];const S=h,w=`touch-pan-y select-none${b?" opacity-30":""}`;let j;return e[12]!==y||e[13]!==d||e[14]!==S||e[15]!==v||e[16]!==x||e[17]!==w?(j=n.jsx("div",{ref:x,...y,...v,onPointerDown:S,className:w,children:d}),e[12]=y,e[13]=d,e[14]=S,e[15]=v,e[16]=x,e[17]=w,e[18]=j):j=e[18],j},mh=t=>{const e=Xe.c(20),{folderId:s,scopeKey:r,ownerKey:i,disabled:o,children:c}=t,a=o===void 0?!1:o;let d;e[0]!==s||e[1]!==r?(d=Bn(r,s),e[0]=s,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let f;e[3]!==a||e[4]!==r?(f=a||Il(r),e[3]=a,e[4]=r,e[5]=f):f=e[5];let p;e[6]!==s||e[7]!==i||e[8]!==r?(p={type:"folder",folderId:s,scopeKey:r,ownerKey:i},e[6]=s,e[7]=i,e[8]=r,e[9]=p):p=e[9];let m;e[10]!==u||e[11]!==f||e[12]!==p?(m={id:u,disabled:f,data:p},e[10]=u,e[11]=f,e[12]=p,e[13]=m):m=e[13];const{setNodeRef:g,isOver:y}=h1(m);let v;e[14]!==c||e[15]!==y||e[16]!==g?(v=c(g,y),e[14]=c,e[15]=y,e[16]=g,e[17]=v):v=e[17];let x;return e[18]!==v?(x=n.jsx(n.Fragment,{children:v}),e[18]=v,e[19]=x):x=e[19],x},z3=t=>{const e=Xe.c(22),{scopeKey:s,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:c}=t,a=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const f=Lr(zs($r,d),zs(_r,u)),[p,m]=l.useState(null),[g,y]=l.useState("Session"),[v,x]=l.useState(null),[b,h]=l.useState(null);if(!s){let D;return e[2]!==c?(D=n.jsx(n.Fragment,{children:c}),e[2]=c,e[3]=D):D=e[3],D}let S;e[4]!==o||e[5]!==a?(S=D=>{m(null),x(null),h(null);const{active:E,over:R}=D;if(!R)return;const z=E.data.current,_=R.data.current;z?.type!=="session"||!z.sessionId||!z.ownerKey||z.archivedBucket===!0||a&&z.ownerKey!==a||_?.type!=="folder"||!_.folderId||!_.scopeKey||!_.ownerKey||Il(_.scopeKey)||_.ownerKey!==z.ownerKey||o(z.sessionId,{folderId:_.folderId,scopeKey:_.scopeKey,ownerKey:_.ownerKey},z.ownerKey)},e[4]=o,e[5]=a,e[6]=S):S=e[6];const w=S;let j,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=D=>{const E=D.active.data.current;if(E?.type==="session"&&E.sessionId){m(E.sessionId),y(E.sessionTitle??"Session");const R=D.active.rect.current.initial?.width,z=D.active.rect.current.initial?.height;x(R??null),h(z??null)}},k=()=>{m(null),x(null),h(null)},e[7]=j,e[8]=k):(j=e[7],k=e[8]);let T;e[9]!==b||e[10]!==p||e[11]!==g||e[12]!==v||e[13]!==i?(T=p&&i?n.jsxs("div",{style:{width:v?`${v}px`:"auto",height:b?`${b}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(Q,{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]=b,e[10]=p,e[11]=g,e[12]=v,e[13]=i,e[14]=T):T=e[14];let O;e[15]!==T?(O=n.jsx(m1,{children:T}),e[15]=T,e[16]=O):O=e[16];let $;return e[17]!==c||e[18]!==w||e[19]!==f||e[20]!==O?($=n.jsxs(zr,{sensors:f,collisionDetection:Kr,onDragStart:j,onDragCancel:k,onDragEnd:w,children:[c,O]}),e[17]=c,e[18]=w,e[19]=f,e[20]=O,e[21]=$):$=e[21],$},gh=l.createContext(null),K3=({entries:t,descendantIds:e,sessionsById:s,children:r})=>{const i=l.useRef(t),o=l.useRef(e),c=l.useRef(s);i.current=t,o.current=e,c.current=s;const a=l.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>c.current}),n.jsx(gh.Provider,{value:a.current,children:r})},bh=()=>l.useContext(gh),W3=(t,e,s)=>{const r=t[0];if(!r)return null;const i=s??r.scopeKey,o=[],c=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const f of u)c.has(f)||(c.add(f),o.push(f))}return o.length>0?{ids:o,scopeKey:i}:null},yh=(t,e)=>{if(t.size===0)return!1;for(const s of t)if(!e.get(s)?.time?.archived)return!1;return!0},H3=({menuInstanceKey:t,contextMenuInstanceKey:e,openSidebarMenuKey:s,setOpenSidebarMenuKey:r,hasDeferredCloseWork:i,onCloseComplete:o})=>{const[c,a]=l.useState(!1),[d,u]=l.useState(!1),f=s===t&&!d,p=e?s===e&&!d:c,m=h=>{if(s===h){if(i()){u(!0);return}r(null)}},g=h=>{if(h){a(!1),u(!1),r(t);return}m(t)},y=h=>{if(!e){a(h);return}if(h){u(!1),r(e);return}m(e)},v=h=>{h||(o(),u(!1),(s===t||s===e)&&r(null))},x=()=>{u(!1),r(f?null:t)},b=l.useRef({menu:g,contextMenu:y});return b.current={menu:g,contextMenu:y},l.useEffect(()=>{if(!f&&!p)return;const h=()=>{p&&b.current.contextMenu(!1),f&&b.current.menu(!1)};return window.addEventListener("blur",h),()=>window.removeEventListener("blur",h)},[f,p]),{isMenuOpen:f,isContextMenuOpen:p,handleMenuOpenChange:g,handleContextMenuOpenChange:y,handleMenuOpenChangeComplete:v,toggleMenu:x}},V3=t=>{const e=Xe.c(10),{project:s,fallback:r}=t,{currentTheme:i}=dr(),o=s.iconImage??null;let c;e[0]!==s.id||e[1]!==o?(c={id:s.id,iconImage:o},e[0]=s.id,e[1]=o,e[2]=c):c=e[2];let a;e[3]!==i.colors.surface.foreground||e[4]!==i.metadata.variant?(a={themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},e[3]=i.colors.surface.foreground,e[4]=i.metadata.variant,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==c||e[8]!==a?(d=n.jsx(Za,{project:c,options:a,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=c,e[8]=a,e[9]=d):d=e[9],d},U3=t=>{const e=Xe.c(14),{project:s,label:r}=t,i=s.icon?Xa[s.icon]:null;let o;e[0]!==s.color?(o=Qa(s.color),e[0]=s.color,e[1]=o):o=e[1];const c=o;let a;e[2]!==c||e[3]!==i?(a=i?n.jsx(Q,{name:i,className:De("h-3 w-3",!c&&"text-muted-foreground/75"),style:c?{color:c}:void 0}):n.jsx(Q,{name:"folder",className:"h-3 w-3 text-muted-foreground/75",style:c?{color:c}:void 0}),e[2]=c,e[3]=i,e[4]=a):a=e[4];const d=a;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 p;e[7]!==d||e[8]!==f||e[9]!==s?(p=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(V3,{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]=p):p=e[10];const m=p;let g;return e[11]!==r||e[12]!==m?(g=r?n.jsx(Fn,{label:r,children:m}):m,e[11]=r,e[12]=m,e[13]=g):g=e[13],g},Ba=t=>{const e=Xe.c(54),{compact:s,project:r,projectLabel:i,title:o,titleClassName:c,branchLabel:a,spaceMark:d,metaLineLead:u,statusDot:f,pinnedMarker:p,timeSlot:m,directoryIndicator:g,prBadge:y,zombieIndicator:v,goal:x,badges:b,doneHint:h,providerId:S,metaPaddingClass:w,hideMetaOnHoverClass:j,actionsReserveClass:k,actionsMaskClass:T}=t,O=s===void 0?!1:s,$=d===void 0?null:d,D=u===void 0?null:u,E=x===void 0?null:x,R=h===void 0?null:h;let z;e[0]!==j||e[1]!==w?(z=De("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?E:null,W=O?v??y:null,N=O?b:null;let Y;e[3]!==m?(Y=n.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:m}),e[3]=m,e[4]=Y):Y=e[4];let C;e[5]!==g||e[6]!==R||e[7]!==p||e[8]!==f||e[9]!==Y||e[10]!==z||e[11]!==_||e[12]!==W||e[13]!==N?(C=n.jsxs("span",{className:z,children:[_,W,N,g,p,R,f,Y]}),e[5]=g,e[6]=R,e[7]=p,e[8]=f,e[9]=Y,e[10]=z,e[11]=_,e[12]=W,e[13]=N,e[14]=C):C=e[14];const P=C;let I;e[15]!==T||e[16]!==c?(I=De("oc-ui-start-align min-w-0 flex-1 truncate typography-ui-label font-normal",T,c),e[15]=T,e[16]=c,e[17]=I):I=e[17];let H;e[18]!==I||e[19]!==o?(H=n.jsx("div",{dir:"auto",className:I,children:o}),e[18]=I,e[19]=o,e[20]=H):H=e[20];const A=H;if(O){let ve;e[21]!==k?(ve=De("@container relative flex w-full min-w-0 items-center gap-1",k),e[21]=k,e[22]=ve):ve=e[22];let ce;return e[23]!==P||e[24]!==ve||e[25]!==A?(ce=n.jsxs("div",{className:ve,children:[A,P]}),e[23]=P,e[24]=ve,e[25]=A,e[26]=ce):ce=e[26],ce}let F;e[27]!==k?(F=De("@container relative flex h-5 w-full min-w-0 items-center gap-1",k),e[27]=k,e[28]=F):F=e[28];let L;e[29]!==P||e[30]!==F||e[31]!==A?(L=n.jsxs("div",{className:F,children:[A,P]}),e[29]=P,e[30]=F,e[31]=A,e[32]=L):L=e[32];let X;e[33]!==r||e[34]!==i?(X=r?n.jsx(U3,{project:r,label:i}):null,e[33]=r,e[34]=i,e[35]=X):X=e[35];let re;e[36]!==a||e[37]!==D||e[38]!==$?(re=D??(a?n.jsxs(n.Fragment,{children:[$?n.jsx(Q,{name:"box-3",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":!1,role:"img","aria-label":$}):n.jsx(Q,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:a})]}):null),e[36]=a,e[37]=D,e[38]=$,e[39]=re):re=e[39];const te=v??y;let M;e[40]!==S?(M=S?n.jsx(Rf,{providerId:S,className:"h-3 w-3 flex-shrink-0 opacity-45"}):null,e[40]=S,e[41]=M):M=e[41];let ee;e[42]!==b||e[43]!==E||e[44]!==te||e[45]!==M?(ee=n.jsxs("span",{className:"ms-auto flex flex-shrink-0 items-center gap-1",children:[E,te,b,M]}),e[42]=b,e[43]=E,e[44]=te,e[45]=M,e[46]=ee):ee=e[46];let V;e[47]!==X||e[48]!==re||e[49]!==ee?(V=n.jsxs("div",{className:"flex h-4 w-full min-w-0 items-center gap-1",children:[X,re,ee]}),e[47]=X,e[48]=re,e[49]=ee,e[50]=V):V=e[50];let Ee;return e[51]!==L||e[52]!==V?(Ee=n.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[L,V]}),e[51]=L,e[52]=V,e[53]=Ee):Ee=e[53],Ee},xh=750,zo=t=>{const e=Xe.c(9),{items:s,directory:r}=t,i=ul();let o;if(e[0]!==r||e[1]!==s||e[2]!==i){let a;e[4]!==r||e[5]!==i?(a=d=>n.jsxs("button",{type:"button",className:De("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:G3,onMouseDown:q3,onKeyDown:Y3,onClick:u=>{u.stopPropagation(),d.url&&i(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(Q,{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]=i,e[6]=a):a=e[6],o=s.map(a),e[0]=r,e[1]=s,e[2]=i,e[3]=o}else o=e[3];let c;return e[7]!==o?(c=n.jsx("div",{className:"flex min-w-0 flex-col gap-1",children:o}),e[7]=o,e[8]=c):c=e[8],c};function G3(t){return t.stopPropagation()}function q3(t){return t.stopPropagation()}function Y3(t){return t.stopPropagation()}const X3=150,qi={capture:!0,passive:!0};let vo=null;const Ad=new WeakSet,Q3=t=>{vo={target:t.target,at:performance.now()}},Od=(t,e)=>t instanceof Node&&t.contains(e);function Z3(){const t=Xe.c(4),e=l.useRef(null),s=l.useRef(null);let r,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>(Ad.has(document)||(Ad.add(document),document.addEventListener("scroll",Q3,qi)),()=>s.current?.()),i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),l.useEffect(r,i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=(d,u)=>{s.current?.(),s.current=null;const f=u.trigger;if(!d||!f)return;if(vo&&performance.now()-vo.at<X3&&Od(vo.target,f)){u.cancel();return}const p=m=>{Od(m.target,f)&&e.current?.close()};document.addEventListener("scroll",p,qi),s.current=()=>document.removeEventListener("scroll",p,qi)},t[2]=o):o=t[2];const c=o;let a;return t[3]===Symbol.for("react.memo_cache_sentinel")?(a={actionsRef:e,onOpenChange:c},t[3]=a):a=t[3],a}let Fa=!1;const La=new Set;let Bd=!1;function J3(){for(const t of La)t()}function Sh(t){Fa!==t&&(Fa=t,J3())}function ao(t){Sh(t.shiftKey)}function e4(){Sh(!1)}function t4(){if(Bd||typeof window>"u")return;Bd=!0;const t={capture:!0,passive:!0};window.addEventListener("keydown",ao,t),window.addEventListener("keyup",ao,t),window.addEventListener("pointermove",ao,t),window.addEventListener("pointerdown",ao,t),window.addEventListener("blur",e4)}function s4(t){return t4(),La.add(t),()=>{La.delete(t)}}function n4(){return Fa}function r4(){return!1}function vh(){return fs.useSyncExternalStore(s4,n4,r4)}const wh=async(t,e,s)=>{const r=s.getRuntimeKey(),i=vt(t.path);if(!i)throw new Error("Unable to resolve worktree project");const o=await s.listProjectWorktrees(t,{force:!0});if(s.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const c=s.getCurrentProjects(),a=c.find(y=>y.id===t.id)??null;if(!a||vt(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const d=Rl({rawWorktreesByProjectRef:s.rawWorktreesByProjectRef,publishedWorktreesByProject:s.getPublishedWorktreesByProject(),runtimeKey:r}),u=o.map(y=>Ko(y));u.sort((y,v)=>kh({metadata:y},{metadata:v}));const f=Ex(d.worktreesByProject,i,u,e?.projectDirectory);o4(s.rawWorktreesByProjectRef,r),s.rawWorktreesByProjectRef.current={runtimeKey:r,revision:s.rawWorktreesByProjectRef.current.revision,worktreesByProject:f};const p=s.getPublishedWorktreesByProject(),m=Ix(s.partitionWorktreesByRegisteredProject(c,f),p),g=[...m.values()].flat();return s.recordWorktreesSeen(g.map(y=>y.path),s.now()),s.worktreeMapsEqual(m,p)||s.publishTopology({availableWorktrees:g,availableWorktreesByProject:m}),u},o4=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),i4=t=>new Map([...t.entries()].map(([e,s])=>[e,s.map(r=>Ko(r))])),Rl=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:i4(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),kh=(t,e)=>{const s=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=s.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},Fd=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Ko=t=>({...t,path:vt(t.path)??t.path,projectDirectory:vt(t.projectDirectory)??t.projectDirectory,worktreeRoot:vt(t.worktreeRoot??t.path)??t.worktreeRoot}),Ld=t=>{const{currentWorktree:e,path:s,projectDirectory:r,projectRootBranch:i}=t,c=vt(e?.path??null)===s,a=c?e?.branch??"":i??"",d={path:s,projectDirectory:r,branch:a,label:c?e?.label||e?.branch||e?.name||Fd(s):i||Fd(s),name:c?e?.name:void 0,worktreeRoot:c?vt(e?.worktreeRoot??s)??s:s,worktreeStatus:c?e?.worktreeStatus??"ready":"ready",worktreeSource:c?e?.worktreeSource??"existing":"existing",headState:c?e?.headState:i?"branch":void 0};return c&&e?{...e,...d}:d},_d=t=>{const e=vt(t.projectPath??null),s=vt(t.sourceDirectory??null)??vt(t.currentWorktree?.path??null),r=vt(t.discoveredWorktrees.find(f=>vt(f.projectDirectory??null))?.projectDirectory??null),i=vt(t.currentWorktree?.projectDirectory??null),o=r??i??e,c=new Map,a=f=>{const p=vt(f.metadata.path??null);!p||c.has(p)||e&&p!==s&&Tx(p,e)||c.set(p,{...f,metadata:Ko({...f.metadata,path:p})})};for(const f of t.discoveredWorktrees){const p=vt(f.path??null);p&&a({metadata:Ko({...f,path:p,projectDirectory:vt(f.projectDirectory??null)??o??e??p}),isPrimary:o===p,isCurrent:s===p})}o&&!c.has(o)&&a({metadata:Ld({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:s===o}),s&&!c.has(s)&&a({metadata:Ld({path:s,projectDirectory:o??e??s,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===s,isCurrent:!0});const d=[],u=[];for(const f of c.values()){if(f.isPrimary){d.push(f);continue}u.push(f)}return d.sort((f,p)=>f.metadata.path.localeCompare(p.metadata.path,void 0,{sensitivity:"base"})),u.sort(kh),[...d,...u]},jh=(t,e)=>{const s=t.projectId?e.projects.find(o=>o.id===t.projectId)??null:null;if(s)return s;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const i=t.currentWorktree?.projectDirectory??null;return i?e.resolveProject(i):null},a4=(t,e)=>{const s=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=Rl({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:s}),o=jh(t,e),c=vt(o?.path??null);return{cachedTargets:_d({projectPath:c,discoveredWorktrees:c?i.worktreesByProject.get(c)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!o||!c)throw new Error("Unable to resolve worktree project");const d=await wh(o,t.currentWorktree,e);return _d({projectPath:c,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},l4=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},c4=t=>({refreshState:t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),d4=(t,e)=>vt(t.worktree?.path??null)===vt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,u4=[],f4=[],p4=[],$d=10,Yi=new WeakMap,h4=t=>{const e=t.closest("[data-session-row]"),s=e?.closest(".overlay-scrollbar-container");if(!e||!s)return;Yi.get(s)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,c=null;const a=()=>{o=!0,c!==null&&window.cancelAnimationFrame(c),c=null,Yi.delete(s),s.removeEventListener("wheel",a),s.removeEventListener("touchstart",a)},d=()=>{if(o||!e.isConnected||!s.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(s.scrollTop+=u,Cs("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}c=window.requestAnimationFrame(d)};s.addEventListener("wheel",a,{passive:!0}),s.addEventListener("touchstart",a,{passive:!0}),Yi.set(s,a),c=window.requestAnimationFrame(d)},m4=l.memo(function(e){const s=Xe.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:c,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:f}=e,p=vh(),m=p?i:r;let g;s[0]!==u||s[1]!==f||s[2]!==p?(g=k=>{if(p||k.shiftKey){f(k);return}u(k)},s[0]=u,s[1]=f,s[2]=p,s[3]=g):g=s[3];const y=g,v=p?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let x;s[4]!==o||s[5]!==v?(x=De("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",v,o),s[4]=o,s[5]=v,s[6]=x):x=s[6];const b=p?"delete-bin":"archive";let h;s[7]!==c||s[8]!==b?(h=n.jsx(Q,{name:b,className:c}),s[7]=c,s[8]=b,s[9]=h):h=s[9];let S;s[10]!==y||s[11]!==m||s[12]!==d||s[13]!==a||s[14]!==x||s[15]!==h?(S=n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",className:x,"aria-label":m,onPointerDown:a,onMouseDown:d,onClick:y,onKeyDown:j4,children:h})}),s[10]=y,s[11]=m,s[12]=d,s[13]=a,s[14]=x,s[15]=h,s[16]=S):S=s[16];let w;s[17]!==m?(w=n.jsx(Ft,{side:"top",sideOffset:6,children:m}),s[17]=m,s[18]=w):w=s[18];let j;return s[19]!==S||s[20]!==w?(j=n.jsxs(Kt,{children:[S,w]}),s[19]=S,s[20]=w,s[21]=j):j=s[21],j});function g4(t){Cs("ui.sidebar_session_node.render");const{t:e}=Ct(),{node:s,depth:r=0,groupDirectory:i,projectId:o,folderOwnerKey:c,selectionScopeKey:a,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:m,notifyOnSubtasks:g,editingId:y,editingRowKey:v,setEditingId:x,setEditingRowKey:b,editTitle:h,setEditTitle:S,handleSaveEdit:w,handleCancelEdit:j,toggleParent:k,handleSessionSelect:T,handleSessionDoubleClick:O,handleCopySessionId:$,openSidebarMenuKey:D,setOpenSidebarMenuKey:E,createFolderAndStartRename:R,handleDeleteSession:z,handleRestoreSession:_,startSessionWorktreeMenuLoad:W,mobileVariant:N,alwaysShowActions:Y,secondaryMeta:C,renderContext:P="project",blockingBadgeSessionScopes:I,rowKey:H,dragKey:A,children:F}=t,L=Nf(Z=>Z.toggle),X=es(Z=>Z.getFoldersForScope),re=es(Z=>Z.getSessionFolderId),te=es(Z=>Z.removeSessionFromFolder),M=es(Z=>Z.addSessionToFolder),ee=de(Z=>Z.openContextPanelTab),V=l.useMemo(()=>In(),[]),Ee=l.useMemo(()=>wo(),[]),ve=l.useContext(Dx),ce=V?"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",Be=V?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",me=V,he=!d&&!N,G=de(Z=>Z.sessionWorkEnabled),le=de(Z=>Z.sessionRecapEnabled),ye=G&&!d&&!s.session.parentID&&!Va(s.session.directory),Ie=ye&&!Y,K=(Ie?1:0)+(he?1:0)+(me?1:0),se=["group-hover:pe-8","group-hover:pe-14","group-hover:pe-18","group-hover:pe-22"][K],U=he?"pe-13":"pe-7",ie=l.useRef(!1),[we,pe]=l.useState(!1),Se=l.useRef(y);Se.current=y;const Ce=l.useRef(null),Oe=l.useRef(!1),B=l.useRef(w);B.current=w;const ae=h,xe=l.useRef(ae);xe.current=ae;const Te=l.useRef(null),Ge=l.useRef(!1),st=l.useRef(null),rt=l.useRef(null),Ke=Z3(),ke=s.session,ge=ke,Ve=ns(l.useCallback(Z=>{if(C?.projectLabel||!o)return null;const Nt=Z.projects.find(qt=>qt.id===o);return Nt?Nt.label?.trim()||Jo(vt(Nt.path)??Nt.path,null)||Nt.path:null},[o,C?.projectLabel])),Ue=P==="timeline-chat"||P==="tree-chat"||P==="mixed-compact",ft=cr(P)||Ue,Qe=lh(P),wt=P==="timeline-mixed"||P==="mixed-compact",Me=Jt(Z=>Z.showPinnedSection),Pe=wt&&Me,ot=ns(l.useCallback(Z=>P!=="timeline-mixed"||!o?null:Z.projects.find(Nt=>Nt.id===o)??null,[P,o])),et=C?.projectLabel??(Ve?Mf(Ve):null),Ze=q2(C,s.worktree?.branch??null),dt=C?.inSpace===!0,J=l.useMemo(()=>Y2(s.worktree,V),[V,s.worktree]),_e=Af(J?.directory??null,J?.branch??null),Le=l.useMemo(()=>V?u4:Of(ke),[V,ke]),He=l.useMemo(()=>Le.map(Z=>({item:Ir("pull",Z),url:Z.url,title:Z.title})),[Le]),$e=wc(He),tt=l.useMemo(()=>$e.filter(Z=>Z!==null),[$e]),bt=l.useMemo(()=>V?p4:Rx(ke),[V,ke]),ht=l.useMemo(()=>bt.flatMap(Z=>Z.gitlab?[{item:Tr("pull",Z.gitlab),url:Z.url,title:Z.title}]:[]),[bt]),it=wc(ht),Mt=l.useMemo(()=>Nx(_e,[...tt,...it.filter(Z=>Z!==null)]),[_e,it,tt]),nt=l.useMemo(()=>{let Z=0;return bt.filter(Nt=>{if(!Nt.gitlab)return!0;const qt=it[Z]!==null;return Z+=1,!qt})},[it,bt]),Lt=l.useMemo(()=>Mx(Le,Mt),[Le,Mt]),_t=_e?`var(--pr-${_e.visualState})`:void 0,Tt=l.useMemo(()=>V?f4:fl(ke),[V,ke]),Ae=l.useMemo(()=>Tt.flatMap(Z=>Z.source==="github"?[Ir("issue",Z)]:[]),[Tt]),at=Ro(Ae),ut=l.useMemo(()=>Tt.flatMap(Z=>Z.source==="gitlab"?[Tr("issue",Z.ref)]:[]),[Tt]),pt=Ro(ut),lt=l.useMemo(()=>Tt.flatMap(Z=>Z.source==="linear"?[pl(Z.identifier)]:[]),[Tt]),St=Bf(lt),ct=l.useMemo(()=>{if(Mt.length>0||Lt.length>0||nt.length>0){const Z=Mt.map(Ht=>{const cs=Ff(Ht,e),Yt=nl(Ht.provider,Ht.number);return{key:`${Ht.provider??""}:${Ht.repo?.owner??""}/${Ht.repo?.repo??""}#${Ht.number}`,icon:"git-pull-request",label:Yt,color:`var(--pr-${Ht.visualState})`,url:Ht.url,title:Ht.title,text:cs?`${Yt} · ${cs}`:Yt}}),Nt=Lt.map(Ht=>({key:`${Ht.owner}/${Ht.repo}#${Ht.number}`,icon:"git-pull-request",label:`#${Ht.number}`,url:Ht.url,title:Ht.title,text:`#${Ht.number}`})),qt=nt.map(Ht=>({key:Ht.key,icon:"git-pull-request",label:Ht.identifier,url:Ht.url,title:Ht.title,text:Ht.identifier}));return[...Z,...Nt,...qt]}return Lf(Tt,at,St,pt).map(Z=>({key:Z.key,icon:Z.icon,label:Z.label,color:Z.color??void 0,url:Z.url,title:Z.title,text:Z.statusKey?`${Z.label} · ${e(Z.statusKey)}`:Z.statusText?`${Z.label} · ${Z.statusText}`:Z.label}))},[pt,at,Tt,St,Lt,Mt,e,nt]),oe=ct[0]??null,q=Math.max(0,ct.length-1),fe=ul(),We=ct.map(Z=>Z.text).join(", "),be=xt(Z=>Z.currentSessionId===ke.id),Ne=vt(ke.directory??null)??vt(i??null),mt=a!==void 0?a:o??Ne??null,jt=Yu(),At=_f(),Ot=V,Wt=k3(),Qt=us(Z=>Z.enabled),Ut=us(l.useCallback(Z=>Z.selectedIds.has(ke.id),[ke.id])),Ss=us(Z=>Z.toggleSelected),bs=us(Z=>Z.setRange),ys=bh(),Re=H??ke.id,ue=y===ke.id&&v===Re,Fe=l.useCallback(Z=>{const Nt=[],qt=Ht=>{Ht.children.forEach(cs=>{Nt.push(cs.session.id),qt(cs)})};return qt(Z),Nt},[]),yt=l.useCallback(Z=>{const Nt=[],qt=Ht=>{Ht.children.forEach(cs=>{Nt.push(cs.session),qt(cs)})};return qt(Z),Nt},[]),[$t,Et]=l.useState(!1),[ne,Ye]=l.useState(!0),qe=`${P}:${d?"archived":"active"}:${ke.id}`,Pt=H?`session-menu:${H}`:qe,Rt=H?`session-context:${H}`:null,je=Ax(l.useCallback(Z=>!!Z.sessionMemoryState.get(Ox(ke.id))?.isZombie,[ke.id])),Je=_u(ke.id),gt=Je!==null,kt=Bx(ke.id,gt),Dt=ip(ke.id),Gt=Ga(ke.id,Ne),rs=Dt||Gt,Vt=s.worktree??xt.getState().getWorktreeMetadata(ke.id)??null,[ts,ms]=l.useState([]),[mn,As]=l.useState(!1),gn=l.useRef(!1),as=l.useRef(0),Os=Fx(ge),vs=ye&&hl(ge),Hh=vs&&!gt&&Lx(ge),Nl=e(vs?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),Ml=async()=>{try{await Xx(ke.id,Ne,vs?"done":"open")}catch{ze.error(e("sessions.sidebar.session.work.updateFailed"))}},Al=Os?e(_x[Os.status]):"",Ol=Os?n.jsx(Fn,{label:Al,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":Al,children:n.jsx(Q,{name:"target",className:"h-3 w-3",style:{color:$x[Os.status]}})})}):null,bn=ge.title||e("sessions.sidebar.session.untitled"),ui=!ft&&s.children.length>0,Gr=ri(u,Ne,ke.id),fi=qe,zn=p?!0:f.has(fi),Vh=l.useMemo(()=>I??Aa(s,zn,Ne),[zn,s,Ne,I]),{hasPermission:pi,hasForm:hi}=zx(Vh),Bl=!!ge.parentID,Uh=$u(ke.id)>0&&(!Bl||g),Fl=Kx(ge)||Date.now(),Gh=Wx(Fl),mi=$f(Fl),{isMenuOpen:Ll,isContextMenuOpen:_l,handleMenuOpenChange:qh,handleContextMenuOpenChange:Yh,handleMenuOpenChangeComplete:$l,toggleMenu:Xh}=H3({menuInstanceKey:Pt,contextMenuInstanceKey:Rt,openSidebarMenuKey:D,setOpenSidebarMenuKey:E,hasDeferredCloseWork:()=>Ce.current!==null,onCloseComplete:()=>{if(!Ce.current)return;const{id:Z,title:Nt}=Ce.current;Ce.current=null,x(Z),b(Re),S(Nt)}}),fr=Ll||_l,zl=l.useMemo(()=>Hx(ge)?.key??null,[ge]),gi=l.useMemo(()=>Fe(s).length,[Fe,s]),bi=l.useCallback(async Z=>{const Nt=[];let qt=0;for(const Ht of Z)try{if(!Ne)throw new Error("Session directory is required for export");const cs=await jt({directory:Ne,sessionID:Ht.session.id});if(!cs)throw new Error("Session runtime changed during export");const Yt=Ht.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Hs=Ht.session.agent,ks=await bi(Ht.children);qt+=ks.skipped,Nt.push({title:Yt,agent:Hs,records:cs,children:ks.children})}catch{qt+=Fe(Ht).length+1}return{children:Nt,skipped:qt}},[Fe,jt,Ne,e]),yi=l.useCallback(Z=>{Z<=0||ze.warning(Z===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Z}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Z}))},[e]),xi=l.useCallback(async Z=>{if(!Ne){ze.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Nt=await jt({directory:Ne,sessionID:ke.id}).catch(()=>null);if(!Nt){ze.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Nt.length===0){ze.error(e("sessions.sidebar.session.export.nothingToExport"));return}let qt,Ht=0;if(Z&&s.children.length>0){const ks=await bi(s.children);qt=ks.children,Ht=ks.skipped}const cs=Xu(Nt,ge.title??null,qt),Yt=Qu(ge.title??null),Hs=await Zu(cs,Yt);if(Hs){ze.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Ux()),onClick:()=>{Vx(Hs).then(ks=>{ks||ze.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),yi(Ht);return}Ju(cs,Yt),ze.success(e("sessions.sidebar.session.export.success")),yi(Ht)},[bi,jt,s.children,ge.title,ke.id,Ne,yi,e]),Kl=ef(),Qh=l.useMemo(()=>tf(Kl),[Kl]),Zh=l.useCallback(Z=>{rp({entry:Z,t:e,session:{id:ke.id,title:ge.title,directory:Ne},loadRecords:()=>Ne?jt({directory:Ne,sessionID:ke.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>ze.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[jt,ge.title,ke.id,Ne,e]),Jh=l.useCallback(async()=>{if(s.children.length>0){Ye(!0),Et(!0);return}await xi(!1)},[xi,s.children.length]),em=l.useCallback(()=>{Ne&&vn("desktop_open_session_mini_chat_window",{sessionId:ke.id,directory:Ne,...Sr()}).catch(Z=>{console.warn("[session-sidebar] failed to open mini chat window",Z)})},[ke.id,Ne]),Wl=()=>{if(!Ne)return;const Z=Qx()??Ne;ee(Z,{mode:"chat",dedupeKey:`session:${ke.id}`,label:bn,sessionTitleFallback:bn,targetDirectory:Ne})};if(l.useEffect(()=>{if(!ue)return;const Z=Nt=>{const Ht=(Nt.target instanceof HTMLElement?Nt.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Re)}"]`);rt.current&&!Ht&&B.current(xe.current)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[ue,Re]),l.useLayoutEffect(()=>{if(!ue){Te.current===Re&&(Te.current=null);return}Te.current!==Re&&(Te.current=Re,Ge.current=!0)},[h,ue,Re]),l.useLayoutEffect(()=>{if(!ue||!Ge.current)return;const Z=st.current;!Z||Z.value!==h||(Ge.current=!1,Z.focus(),Z.select())},[h,ue,ae]),ue){const Z=n.jsxs("form",{ref:rt,"data-session-rename-form":Re,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:Nt=>{Nt.preventDefault(),w(ae)},children:[n.jsx("input",{ref:st,value:ae,onChange:Nt=>S(Nt.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:Nt=>na(Nt,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(Q,{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(Q,{name:"close",className:"size-3.5"})})]});return Qe?n.jsxs("div",{style:{paddingInlineStart:$n(r)},className:De("group relative my-0.5 flex items-center gap-1.5 rounded-md pe-2.5",ft?"py-1":"py-[3px]"),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:Z})]},ke.id):n.jsx("div",{style:{paddingInlineStart:$d},className:De("oc-ref-tint-scope group relative my-0.5 flex items-center rounded-md pe-2.5",Ue?"py-1":"py-1.5",be&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:n.jsx(Ba,{compact:Ue,project:ot,projectLabel:et,title:Z,titleClassName:"text-foreground",branchLabel:Ze,spaceMark:dt?e("sessions.sidebar.group.space"):null,statusDot:null,pinnedMarker:null,timeSlot:mi,directoryIndicator:null,prBadge:oe?n.jsxs("span",{className:De("inline-flex flex-shrink-0 items-center gap-1 typography-micro",oe.color?"oc-ref-tint":"text-muted-foreground"),style:oe.color?Jn(oe.color):void 0,children:[n.jsx(Q,{name:oe.icon,className:"h-3 w-3"}),Ue?null:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"leading-none tabular-nums",children:oe.label}),q>0?n.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",q]}):null]})]}):null,zombieIndicator:null,goal:Ol,badges:null,hideMetaOnHoverClass:""})},ke.id)}const Hl=e("sessions.sidebar.session.status.questionPending"),Si=!rs&&!gt&&Uh&&!be,tm=gt||Si,sm=n.jsx(Wu,{state:Je??"unread",tooltip:!0}),nm=(gt||Si)&&kt,rm=ft&&!Ue?["[--oc-actions-reserve:14px]","[--oc-actions-reserve:36px]","[--oc-actions-reserve:58px]","[--oc-actions-reserve:80px]"][K]:["[--oc-actions-reserve:10px]","[--oc-actions-reserve:28px]","[--oc-actions-reserve:46px]","[--oc-actions-reserve:64px]"][K],om=Y?void 0:fr?"oc-actions-mask":V?"group-hover:oc-actions-mask":"group-hover:oc-actions-mask group-has-[:focus-visible]:oc-actions-mask",im=fr?"opacity-0":Be,Vl=e("sessions.sidebar.session.status.pinned"),am=n.jsx(Fn,{label:Vl,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":Vl,children:n.jsx(Q,{name:"pushpin",className:"h-3 w-3 text-primary"})})}),lm=n.jsx(Q,{name:"loader-4",className:"h-3 w-3 flex-shrink-0 animate-spin text-primary","aria-label":e(Gt?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}),qr=rs?lm:tm?sm:null,vi=Qe&&qr!==null&&!(ui&&Y),wi=ui?n.jsx("span",{role:"button",tabIndex:0,onClick:Z=>{Z.stopPropagation(),Z.currentTarget.blur(),k(fi)},onKeyDown:Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),Z.stopPropagation(),k(fi))},className:De("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",vi&&"opacity-0 transition-opacity group-hover:opacity-100 group-has-[:focus-visible]:opacity-100"),"aria-label":e(zn?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":zn,children:n.jsx(Ar,{expanded:zn})}):null,cm=Qe?vi?n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[wi,wi?n.jsx("span",{className:"pointer-events-none absolute inset-0 inline-flex items-center justify-center transition-opacity group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",children:qr}):qr]}):wi??n.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0"}):null,ki=je?n.jsx(Q,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,dm=Z=>{Z.preventDefault(),Z.stopPropagation(),Xh()},um=Z=>{Z.preventDefault(),Z.stopPropagation()},fm=Z=>{Z.preventDefault(),Z.stopPropagation()},ji=Z=>{Z.preventDefault(),Z.stopPropagation()},Ci=Z=>{Z.preventDefault(),Z.stopPropagation()},pm=Z=>{Z.preventDefault(),Z.stopPropagation(),E(null),z(ke,{archivedBucket:d})},hm=Z=>{Z.preventDefault(),Z.stopPropagation(),E(null),z(ke,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},mm=Z=>{Z.preventDefault(),Z.stopPropagation()},gm=Z=>{Z.preventDefault(),Z.stopPropagation()},bm=Z=>{Z.preventDefault(),Z.stopPropagation(),ve?.vscode?.executeCommand("openchamber.openSessionInEditor",ke.id,bn)},Ul=Z=>{if(ie.current){ie.current=!1;return}if(Qt){if(Z?.preventDefault(),Z?.stopPropagation(),Z?.shiftKey){const Nt=ys?.getEntries(),qt=Nt??Array.from(document.querySelectorAll("[data-session-row]")).map(Yt=>Yt.getAttribute("data-session-row")).filter(Yt=>!!Yt).map(Yt=>({id:Yt,rowKey:Yt,scopeKey:mt,archived:d})),Ht=Nt?us.getState().anchorRowKey:us.getState().anchorId,cs=new Map;cs.set(ke.id,Fe(s)),bs(Ht,Re,qt,ys?.getDescendantIds()??[],mt,cs);return}Ss(ke.id,mt,Fe(s),Re);return}if(Z?.shiftKey&&!V&&Ne){Wl();return}Z?.currentTarget&&h4(Z.currentTarget),T(ke.id,Ne)},ym=Z=>{Z.defaultPrevented||(Z.target instanceof HTMLElement?Z.target:null)?.closest('button, a, input, [data-session-row-main], [role="menuitem"], [role="menu"]')||Ul(Z)},xm=Z=>{(Z.button===2||Z.button===0&&Z.ctrlKey&&!Qt)&&(ie.current=!0),Z.button===0&&Z.shiftKey&&!Qt&&Z.preventDefault()},Sm=Z=>{N&&Z.pointerType==="touch"&&pe(!0),Z.button===0&&!be&&!Qt&&!Ot&&Ne&&!ua(ke.id,Ne).renderable&&At({directory:Ne,sessionID:ke.id}).catch(()=>{})},Kn=!be&&!Qt&&Ne?{id:ke.id,directory:Ne}:null,vm=Z=>{Z.pointerType!=="mouse"||!Kn||Wt?.schedule(Kn)},wm=()=>{Kn&&Wt?.schedule(Kn)},Gl=()=>{Kn&&Wt?.cancel(Kn)},ql=Z=>{N&&Z.pointerType==="touch"&&pe(!1)},km=Z=>{gn.current=Z,as.current+=1;const Nt=as.current;if(!Z){As(!1);return}const qt=W({projectId:o??null,sourceDirectory:Ne,currentWorktree:Vt});ms(qt.cachedTargets),As(!1),qt.refreshTargets.then(Ht=>{!gn.current||as.current!==Nt||(ms(Ht),As(!1))}).catch(()=>{!gn.current||as.current!==Nt||As(!0)})},Yl=({Item:Z,Separator:Nt,Sub:qt,SubTrigger:Ht,SubContent:cs})=>n.jsxs(n.Fragment,{children:[n.jsx(ss,{hint:e("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(Z,{onClick:()=>{Ce.current={id:ke.id,title:bn}},className:"[&>svg]:me-1",children:[n.jsx(Q,{name:"pencil-ai",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]})}),n.jsx(xa,{sessionID:ke.id,directory:Ne,open:fr,Item:Z}),n.jsx(ss,{hint:e("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(Z,{onClick:()=>$(ke.id),className:"[&>svg]:me-1",children:[n.jsx(Q,{name:"file-copy",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]})}),n.jsx(ss,{hint:e(Gr?"sessions.sidebar.session.menuHint.unpin":"sessions.sidebar.session.menuHint.pin"),children:n.jsxs(Z,{onClick:()=>Ne&&L({directory:Ne,sessionId:ke.id}),className:"[&>svg]:me-1",children:[Gr?n.jsx(Q,{name:"unpin",className:"me-1 h-4 w-4"}):n.jsx(Q,{name:"pushpin",className:"me-1 h-4 w-4"}),e(Gr?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]})}),ye?n.jsx(ss,{hint:e(vs?"sessions.sidebar.session.menuHint.markDone":"sessions.sidebar.session.menuHint.track"),children:n.jsxs(Z,{onClick:()=>{Ml()},className:"[&>svg]:me-1",children:[n.jsx(Q,{name:vs?"check":"eye",className:"me-1 h-4 w-4"}),e(vs?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]})}):null,n.jsx(ss,{hint:e("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(Z,{onClick:()=>{Jh()},className:"[&>svg]:me-1",children:[n.jsx(Q,{name:"download",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]})}),Qh.map(Yt=>n.jsxs(Z,{onClick:()=>Zh(Yt),className:"[&>svg]:me-1",children:[n.jsx(ur,{icon:Yt.icon,iconSrc:Yt.iconSrc,className:"me-1 size-4"}),Yt.action.label]},`${Yt.guest.id}:${Yt.action.id}`)),V2({isSubtaskSession:Bl,archivedBucket:!!d,isVSCode:V,sessionDirectory:Ne})?(()=>{const Yt=U2({sessionDirectory:Ne,isStreaming:gt,isMovingToWorktree:Dt}),Hs=c4({targets:ts,loadFailed:mn}),ks=n.jsxs(Ht,{disabled:Yt,className:"w-full [&>svg]:me-1","data-session-worktree-submenu-trigger":ke.id,children:[n.jsx(Q,{name:"folder-shared",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]}),Bs=Dt?e("sessions.sidebar.session.moveToWorktree.tooltipMoving"):gt?e("sessions.sidebar.session.moveToWorktree.tooltipBusy"):null;return n.jsxs(qt,{onOpenChange:km,children:[Bs?n.jsx(ss,{hint:Bs,children:ks}):ks,n.jsxs(cs,{className:"min-w-[220px]","data-session-worktree-submenu":ke.id,children:[ts.map(gs=>{const ps=vt(gs.metadata.path??null)??gs.metadata.path,hs=gs.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):gs.metadata.label||gs.metadata.branch||gs.metadata.name||gs.metadata.path,sn=gs.isCurrent||gs.metadata.worktreeStatus!=="ready";return n.jsxs(Z,{disabled:sn,title:gs.metadata.path,"data-session-worktree-target":ps,onClick:()=>{sn||!Ne||Mo({kind:"existing",root:ge,descendants:yt(s),sourceDirectory:Ne,destination:gs.metadata,messages:No(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:hs}),gs.isCurrent?n.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),gs.isCurrent?n.jsx(Q,{name:"check",className:"ms-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},ps)}),Hs.refreshState==="error"?n.jsx(Z,{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(Nt,{}),n.jsxs(Z,{disabled:Yt,"data-session-worktree-new-action":"true",onClick:()=>{Yt||!Ne||Mo({kind:"quick",root:ge,descendants:yt(s),sourceDirectory:Ne,messages:No(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:me-1",children:[n.jsx(Q,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,zl?n.jsx(ss,{hint:e("sessions.sidebar.session.menuHint.openRunOverview"),children:n.jsxs(Z,{onClick:()=>de.getState().setRunOverviewKey(zl),className:"[&>svg]:me-1",children:[n.jsx(fa,{className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]})}):null,Ne&&!d&&!ft?(()=>{const Yt=[],Hs=ps=>{const hs=vt(ps??null);hs&&!Yt.includes(hs)&&Yt.push(hs)};if(o&&!V){const ps=ns.getState().projects.find(sn=>sn.id===o),hs=vt(ps?.path??null);Hs(hs),hs&&(xt.getState().availableWorktreesByProject.get(hs)??[]).forEach(sn=>Hs(sn.path))}Hs(Ua(Ne)),Hs(Ne);const ks=Yt.flatMap(ps=>X(ps).map(hs=>({scope:ps,folder:hs}))),Bs=ks.find(({scope:ps,folder:hs})=>re(ps,ke.id)===hs.id)??null,gs=Yt[0]??Ne;return n.jsxs(n.Fragment,{children:[n.jsx(Nt,{}),n.jsxs(qt,{children:[n.jsx(ss,{hint:e("sessions.sidebar.session.menuHint.moveToFolder"),children:n.jsxs(Ht,{className:"[&>svg]:me-1",children:[n.jsx(Q,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]})}),n.jsxs(cs,{className:"min-w-[180px]",children:[ks.length===0?n.jsx(Z,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):ks.map(({scope:ps,folder:hs})=>{const sn=Bs?.folder.id===hs.id;return n.jsxs(Z,{onClick:()=>{if(sn){te(ps,ke.id);return}Bs&&Bs.scope!==ps&&te(Bs.scope,ke.id),M(ps,hs.id,ke.id)},children:[n.jsx("span",{className:"flex-1 truncate",children:hs.name}),sn?n.jsx(Q,{name:"check",className:"ms-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},hs.id)}),n.jsx(Nt,{}),n.jsxs(Z,{onClick:()=>{const ps=R(gs);ps&&(Oe.current=!0,Bs&&Bs.scope!==gs&&te(Bs.scope,ke.id),M(gs,ps.id,ke.id))},children:[n.jsx(Q,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Bs?n.jsxs(Z,{onClick:()=>{te(Bs.scope,ke.id)},className:"text-destructive focus:text-destructive",children:[n.jsx(Q,{name:"close",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,V?null:n.jsx(ss,{hint:e("sessions.sidebar.session.menuHint.openInSidePanel"),children:n.jsxs(Z,{disabled:!Ne,onClick:Wl,className:"[&>svg]:me-1",children:[n.jsx(Q,{name:"chat-4",className:"me-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")})]})}),Ee?n.jsx(ss,{hint:e("sessions.sidebar.session.menuHint.openMiniChatWindow"),children:n.jsxs(Z,{disabled:!Ne,onClick:em,className:"[&>svg]:me-1",children:[n.jsx(Q,{name:"window",className:"me-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]})}):null,n.jsx(Nt,{}),d?null:n.jsx(ss,{hint:e("sessions.sidebar.session.menuHint.archive"),children:n.jsxs(Z,{className:"[&>svg]:me-1",onClick:()=>z(ke,{archivedBucket:d}),children:[n.jsx(Q,{name:"inbox-archive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]})}),d?n.jsx(ss,{hint:e("sessions.sidebar.session.menuHint.restore"),children:n.jsxs(Z,{className:"[&>svg]:me-1",onClick:()=>_(ke),children:[n.jsx(Q,{name:"inbox-unarchive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]})}):null,n.jsx(ss,{hint:e("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(Z,{className:"text-destructive focus:text-destructive [&>svg]:me-1",onClick:()=>z(ke,{archivedBucket:d,hardDelete:!0}),children:[n.jsx(Q,{name:"delete-bin",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})})]}),jm=Z=>{Z.preventDefault(),Z.stopPropagation(),Ml()},Pi=Y?"h-6 w-6":ft&&!Ue?"h-5 w-5":"h-4 w-4",Yr=Y?"h-3.5 w-3.5":ft&&!Ue?"h-3 w-3":"h-2.5 w-2.5",Cm=Y?"h-4 w-4":ft&&!Ue?"h-3.5 w-3.5":"h-3 w-3",Xl=le&&!gt&&Gx(ge)?.recap||null,Ql=e("sessions.sidebar.session.work.doneSuggested"),Pm=Z=>Hh?n.jsx(Fn,{label:Ql,children:n.jsx("span",{className:De("inline-flex flex-shrink-0 items-center text-muted-foreground/75",Z),"aria-label":Ql,children:n.jsx(Q,{name:"check",className:"h-3.5 w-3.5"})})}):null,Zl=e("sessions.sidebar.session.status.permissionRequired"),Em=pi||hi?n.jsxs(n.Fragment,{children:[pi?n.jsx(Fn,{label:Zl,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":Zl,children:n.jsx(Q,{name:"shield",className:"h-3 w-3"})})}):null,hi?n.jsx(Fn,{label:Hl,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":Hl,children:n.jsx(Q,{name:"question",className:"h-3 w-3"})})}):null]}):null,Im=ft&&oe?n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,closeDelay:xh,children:n.jsxs("button",{type:"button",className:De("inline-flex flex-shrink-0 items-center gap-1 rounded typography-micro hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",oe.color?"oc-ref-tint":"text-muted-foreground"),style:oe.color?Jn(oe.color):void 0,disabled:!oe.url,"aria-label":We,onPointerDown:ji,onMouseDown:Ci,onClick:Z=>{Z.preventDefault(),Z.stopPropagation(),!(Z.target instanceof Element&&Z.target.closest("[data-ref-more]"))&&oe.url&&fe(oe.url,Ne,Z)},onKeyDown:Z=>Z.stopPropagation(),children:[n.jsx(Q,{name:oe.icon,className:"h-3 w-3"}),Ue?null:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"leading-none tabular-nums",children:oe.label}),q>0?n.jsxs("span",{"data-ref-more":!0,className:"leading-none tabular-nums text-muted-foreground",children:["+",q]}):null]})]})}),n.jsx(Ft,{side:"top",sideOffset:6,className:"max-w-xs",children:n.jsx(zo,{items:ct,directory:Ne})})]}):null,Tm=n.jsx(Ba,{compact:!cr(P),project:ot,projectLabel:et,title:fo(bn,m),titleClassName:be||Ut?"text-interactive-selection-foreground":Si||pi||hi?"font-semibold text-foreground":gt?"text-foreground":"text-muted-foreground",branchLabel:Ze,spaceMark:dt?e("sessions.sidebar.group.space"):null,statusDot:vi?null:qr,pinnedMarker:Gr&&!rs&&!Pe?am:null,timeSlot:nm?n.jsx(qx,{sessionId:ke.id,running:gt,className:"typography-micro"}):mi,directoryIndicator:!d&&Ne&&P!=="project"?n.jsx($o,{directory:Ne}):null,prBadge:Im,zombieIndicator:ft?ki:null,goal:Ol,badges:Em,doneHint:Pm(),providerId:ft?ge.model?.providerID??null:null,metaPaddingClass:ft&&Y?he?"pe-13":"pe-7":void 0,hideMetaOnHoverClass:Y&&!V?"":im,actionsReserveClass:rm,actionsMaskClass:om}),Dm=n.jsx(Rs,{align:"end",className:"min-w-[180px]",finalFocus:()=>Oe.current?(Oe.current=!1,!1):!Se.current,children:Yl({Item:Zt,Separator:jn,Sub:Pf,SubTrigger:Ef,SubContent:If})}),Rm=n.jsx(ma,{children:n.jsx(ga,{className:"app-region-no-drag z-50",children:n.jsx(ba,{"data-slot":"dropdown-menu-content",finalFocus:()=>Oe.current?(Oe.current=!1,!1):!Se.current,style:{color:"var(--surface-elevated-foreground)"},className:De(oa,"min-w-[180px]"),children:Yl({Item:({className:Z,...Nt})=>n.jsx(tp,{className:De(Ku,Z),...Nt}),Separator:({className:Z,...Nt})=>n.jsx(ep,{className:De(zu,Z),...Nt}),Sub:y1,SubTrigger:({className:Z,children:Nt,...qt})=>n.jsxs(x1,{className:De(Yx,Z),...qt,children:[Nt,n.jsx(Q,{name:"arrow-right-s",className:"ms-auto size-3.5"})]}),SubContent:({className:Z,children:Nt,...qt})=>n.jsx(ma,{children:n.jsx(ga,{className:"app-region-no-drag z-50",children:n.jsx(ba,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:De(oa,Z),...qt,children:Nt})})})})})})});return n.jsxs(l.Fragment,{children:[n.jsx($3,{sessionId:ke.id,dragKey:A??Re,ownerKey:c??mt,sessionDirectory:Ne??null,sessionTitle:bn,archivedBucket:d,children:n.jsxs(np,{open:_l,onOpenChange:Yh,onOpenChangeComplete:$l,children:[n.jsxs(sp,{render:n.jsx("div",{"data-session-row":ke.id,"data-session-scope":mt??"","data-session-archived":d?"1":"0","aria-current":be?"page":void 0,onClick:ym,style:{paddingInlineStart:Qe?$n(r):$d},className:De("oc-ref-tint-scope group relative my-0.5 flex cursor-pointer items-center rounded-md pe-2.5",Qe&&"gap-1.5",ft?Ue?"py-1":"py-1.5":"py-[3px]",!(be||Ut)&&"hover:bg-interactive-hover/60",(be||Ut)&&"bg-interactive-selection/70 text-interactive-selection-foreground",Ut&&"ring-1 ring-inset ring-border")}),children:[cm,n.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:n.jsxs(Kt,{actionsRef:Ke.actionsRef,onOpenChange:Ke.onOpenChange,children:[n.jsx(zt,{asChild:!0,closeDelay:0,disabled:V,children:n.jsx("div",{role:"button",tabIndex:0,"data-session-row-main":"",onKeyDown:Z=>{Z.target!==Z.currentTarget||Z.key!=="Enter"&&Z.key!==" "||(Z.preventDefault(),Z.currentTarget.click())},"aria-pressed":Qt?Ut:void 0,onPointerDown:Sm,onPointerUp:ql,onPointerCancel:ql,onPointerEnter:vm,onPointerLeave:Gl,onFocus:wm,onBlur:Gl,onMouseDown:xm,onClick:Z=>Ul(Z),onDoubleClick:Z=>{Z.stopPropagation(),O(ke.id,bn)},className:De("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",we&&"bg-interactive-hover/70",ft||!Y?void 0:V?se:U),children:Tm})}),V?null:n.jsx(Ft,{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:bn}),n.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:Gh,children:mi})]}),et?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[n.jsx(Q,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:et})]}):null,Ze?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[dt?n.jsx(Q,{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(Q,{name:"git-branch",className:De("h-3 w-3 flex-shrink-0",_t&&"oc-ref-tint"),style:_t?Jn(_t):void 0}),n.jsx("span",{className:"min-w-0 truncate",children:Ze})]}):null,ct.length>0?n.jsx(zo,{items:ct,directory:Ne}):null,Xl?n.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:Xl}):null]})})]})}),ki&&!N&&!ft?n.jsx("div",{className:"absolute inset-e-1 top-1/2 -translate-y-1/2 z-10",children:ki}):null,n.jsx("div",{className:De("absolute inset-e-1 z-10 flex items-center gap-0.5 transition-opacity",ft&&!Ue?"top-1.5 h-5":"top-1/2 -translate-y-1/2",fr||Y&&!V?"opacity-100":De("opacity-0",ce)),children:n.jsxs(oi,{delayDuration:400,children:[Ie?n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",className:De("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",Pi,vs?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":Nl,onPointerDown:ji,onMouseDown:Ci,onClick:jm,onKeyDown:Z=>Z.stopPropagation(),children:n.jsx(Q,{name:vs?"check":"eye",className:vs?Cm:Yr})})}),n.jsx(Ft,{side:"top",sideOffset:6,children:Nl})]}):null,he?n.jsx(m4,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:Pi,iconSizeClass:Yr,onPointerDown:ji,onMouseDown:Ci,onArchive:pm,onDelete:hm}):null,me?n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",className:De("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",Pi),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:mm,onMouseDown:gm,onClick:bm,onKeyDown:Z=>Z.stopPropagation(),children:n.jsx(Q,{name:"external-link",className:Yr})})}),n.jsx(Ft,{side:"top",sideOffset:6,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,n.jsxs(Ts,{open:Ll,onOpenChange:qh,onOpenChangeComplete:$l,children:[n.jsx(Ds,{asChild:!0,children:n.jsx("button",{type:"button",className:De("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",Y?"h-6 w-6 opacity-100":fr?"h-4 w-4 opacity-100":De("h-4 w-4 opacity-0",ce)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:um,onMouseDown:fm,onClick:dm,onKeyDown:Z=>Z.stopPropagation(),children:n.jsx(Q,{name:"more-2",className:Yr})})}),Dm]})]})})]}),Rm]})}),ui&&zn?F:null,n.jsx(Ys,{open:$t,onOpenChange:Et,children:n.jsxs(qs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(en,{children:[n.jsx(Zs,{children:e("sessions.sidebar.session.export.dialog.title")}),n.jsx(Js,{children:gi===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:gi}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:gi})})]}),n.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:ne,onChange:Z=>Ye(Z.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),n.jsxs(Cn,{children:[n.jsx(It,{type:"button",onClick:()=>Et(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),n.jsx(It,{type:"button",onClick:()=>{Et(!1),xi(ne)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},ke.id)}const zd=t=>vt(t.session.directory??null),b4=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null)&&(t?.inSpace??!1)===(e?.inSpace??!1),y4=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},Kd=t=>t.menuOpenSessionId??y4(t),lo=(t,e,s)=>e?s.has(t.node.session.id)?!0:lr(t.node,e):!1,_a=(t,e,s,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(s.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let c=0;c<t.children.length;c+=1)if(_a(t.children[c],e.children[c],s,r,i))return!0;return!1},x4=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const s=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return _a(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${s}:${i.session.id}`)||_a(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},S4=(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&&zf(t,e),v4=(t,e)=>{if(t.node.session.id!==e.node.session.id||!S4(t.node.session,e.node.session)||!d4(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(zd(t.node)!==zd(e.node))return"nodeDirectory";if(!b4(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&oh(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&x4(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(lo(t,t.editingId,t.subtreeContainsEditing)||lo(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&&(lo(t,t.editingId,t.subtreeContainsEditing)||lo(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=Kd(t),i=Kd(e);if(lr(t.node,r)||lr(e.node,i))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.handleCopySessionId===e.handleCopySessionId&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.children===e.children?null:"callbacks"},w4=(t,e)=>{const s=v4(t,e);return s===null?!0:(Cs(`ui.sidebar_session_node.props_changed.${s}`),!1)},k4=l.memo(g4,w4);function j4(t){return t.stopPropagation()}const C4=t=>{const{t:e}=Ct(),s=l.useRef(t.editingId),r=l.useRef(t.editTitle),i=l.useRef(t.deleteSessionConfirm);s.current=t.editingId,r.current=t.editTitle,i.current=t.deleteSessionConfirm;const o=de(C=>C.setSessionSwitcherOpen),c=xt(C=>C.setCurrentSession),a=xt(C=>C.updateSessionTitle),d=xt(C=>C.deleteSession),u=xt(C=>C.deleteSessions),f=xt(C=>C.archiveSession),p=xt(C=>C.archiveSessions),m=xt(C=>C.unarchiveSession),{mobileVariant:g,allowReselect:y,onSessionSelected:v,resetSessionSearch:x,descendantIds:b,showDeletionDialog:h,setDeleteSessionConfirm:S,setEditingId:w,setEditingRowKey:j,editingSessionId:k,editingOccurrenceKey:T,setEditTitle:O}=t,$=l.useCallback((C,P)=>{if(sa("navigation.session_select"),de.getState().closeMainSurfaces(),g&&o(!1),C===xt.getState().currentSessionId){y&&v?.(C),x();return}sa("navigation.session_state_set"),c(C,P??null),v?.(C),x()},[y,g,v,x,c,o]),D=l.useCallback((C,P)=>{w(C),j(T),O(P)},[T,O,w,j]),E=l.useCallback(async C=>{if(!s.current)return;const I=(C??r.current).trim();if(I)try{await a(k,I)}catch(H){console.error("[session-actions] rename failed",H),ze.error(e("sessions.sidebar.session.rename.error",{detail:Bu(H instanceof Error?H:new Error(String(H)),e)}))}w(null),j(null),O("")},[k,O,w,j,e,a]),R=l.useCallback(()=>{w(null),j(null),O("")},[O,w,j]),z=l.useCallback(C=>{ti(C).then(P=>{if(P.ok){ze.success(e("sessions.sidebar.session.copyId.success"));return}ze.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(e("sessions.sidebar.session.copyId.error")))},[e]),_=l.useCallback(async(C,P,I)=>{const H=P?.archivedBucket===!0||P?.hardDelete===!0,A=I?.descendantIds??b;await fb(H?"delete":"archive",C,A,{archiveSession:f,archiveSessions:p,deleteSession:d,deleteSessions:u},e)},[f,p,d,u,b,e]),W=l.useCallback((C,P)=>{const I=P?.archivedBucket===!0||P?.hardDelete===!0,H=Iu(C.id,b,I);if(!h||P?.skipConfirm===!0){_(C,P,{descendantIds:H});return}S({session:C,descendantCount:H.length,descendantIds:H,archivedBucket:I})},[b,_,S,h]),N=l.useCallback(async()=>{const C=i.current;if(!C)return;const{session:P,archivedBucket:I,descendantIds:H}=C;S(null),await _(P,{archivedBucket:I},{descendantIds:H})},[_,S]),Y=l.useCallback(async C=>{await m(C.id)?ze.success(e("sessions.sidebar.session.restore.success")):ze.error(e("sessions.sidebar.session.restore.error"))},[e,m]);return l.useMemo(()=>({handleSessionSelect:$,handleSessionDoubleClick:D,handleSaveEdit:E,handleCancelEdit:R,handleCopySessionId:z,handleDeleteSession:W,handleRestoreSession:Y,confirmDeleteSession:N}),[R,z,W,Y,E,D,$,N])};function P4(t){const e=Xe.c(71),{t:s}=Ct(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:c,onConfirm:a}=t;let d,u,f,p,m,g,y,v,x,b;if(e[0]!==i||e[1]!==s||e[2]!==r){const P=s("sessions.sidebar.session.untitled");p=Ys,x=!!r,e[13]!==i?(b=H=>{H||i(null)},e[13]=i,e[14]=b):b=e[14],f=qs,y=!1,v="max-w-sm gap-5",u=en;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(Zs,{children:I}),e[18]=I,e[19]=g):g=e[19],d=Js,m=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?s("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||P,count:r.descendantCount}):s("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||P,count:r.descendantCount}):r.descendantCount===1?s("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||P,count:r.descendantCount}):s("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||P,count:r.descendantCount}):r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||P}):s("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||P}),e[0]=i,e[1]=s,e[2]=r,e[3]=d,e[4]=u,e[5]=f,e[6]=p,e[7]=m,e[8]=g,e[9]=y,e[10]=v,e[11]=x,e[12]=b}else d=e[3],u=e[4],f=e[5],p=e[6],m=e[7],g=e[8],y=e[9],v=e[10],x=e[11],b=e[12];let h;e[20]!==d||e[21]!==m?(h=n.jsx(d,{children:m}),e[20]=d,e[21]=m,e[22]=h):h=e[22];let S;e[23]!==u||e[24]!==g||e[25]!==h?(S=n.jsxs(u,{children:[g,h]}),e[23]=u,e[24]=g,e[25]=h,e[26]=S):S=e[26];let w;e[27]!==c||e[28]!==o?(w=()=>c(!o),e[27]=c,e[28]=o,e[29]=w):w=e[29];const j=!o;let k;e[30]!==o?(k=o?n.jsx(Q,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(Q,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=k):k=e[31];let T;e[32]!==s?(T=s("sessions.sidebar.dialogs.neverAsk"),e[32]=s,e[33]=T):T=e[33];let O;e[34]!==k||e[35]!==T||e[36]!==w||e[37]!==j?(O=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,T]}),e[34]=k,e[35]=T,e[36]=w,e[37]=j,e[38]=O):O=e[38];let $;e[39]!==i?($=()=>i(null),e[39]=i,e[40]=$):$=e[40];let D;e[41]!==s?(D=s("sessions.sidebar.dialogs.cancel"),e[41]=s,e[42]=D):D=e[42];let E;e[43]!==$||e[44]!==D?(E=n.jsx("button",{type:"button",onClick:$,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:D}),e[43]=$,e[44]=D,e[45]=E):E=e[45];let R;e[46]!==a?(R=()=>{a()},e[46]=a,e[47]=R):R=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 _;e[51]!==R||e[52]!==z?(_=n.jsx("button",{type:"button",onClick:R,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]=R,e[52]=z,e[53]=_):_=e[53];let W;e[54]!==E||e[55]!==_?(W=n.jsxs("div",{className:"flex items-center gap-2",children:[E,_]}),e[54]=E,e[55]=_,e[56]=W):W=e[56];let N;e[57]!==O||e[58]!==W?(N=n.jsxs(Cn,{className:"w-full sm:items-center sm:justify-between",children:[O,W]}),e[57]=O,e[58]=W,e[59]=N):N=e[59];let Y;e[60]!==f||e[61]!==y||e[62]!==N||e[63]!==v||e[64]!==S?(Y=n.jsxs(f,{showCloseButton:y,className:v,children:[S,N]}),e[60]=f,e[61]=y,e[62]=N,e[63]=v,e[64]=S,e[65]=Y):Y=e[65];let C;return e[66]!==p||e[67]!==Y||e[68]!==x||e[69]!==b?(C=n.jsx(p,{open:x,onOpenChange:b,children:Y}),e[66]=p,e[67]=Y,e[68]=x,e[69]=b,e[70]=C):C=e[70],C}function E4(t){const e=Xe.c(57),{t:s}=Ct(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:c,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let f;e[0]!==d||e[1]!==u||e[2]!==s?(f=s(d?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=d,e[1]=u,e[2]=s,e[3]=f):f=e[3];const p=f;let m;e[4]!==d||e[5]!==u||e[6]!==s?(m=d?u===1?s("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):s("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?s("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):s("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=s,e[7]=m):m=e[7];const g=m,y=!!r;let v;e[8]!==i?(v=C=>{C||i(null)},e[8]=i,e[9]=v):v=e[9];let x;e[10]!==p?(x=n.jsx(Zs,{children:p}),e[10]=p,e[11]=x):x=e[11];let b;e[12]!==g?(b=n.jsx(Js,{children:g}),e[12]=g,e[13]=b):b=e[13];let h;e[14]!==x||e[15]!==b?(h=n.jsxs(en,{children:[x,b]}),e[14]=x,e[15]=b,e[16]=h):h=e[16];let S;e[17]!==c||e[18]!==o?(S=()=>c(!o),e[17]=c,e[18]=o,e[19]=S):S=e[19];const w=!o;let j;e[20]!==o?(j=o?n.jsx(Q,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(Q,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,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 T;e[24]!==k||e[25]!==S||e[26]!==w||e[27]!==j?(T=n.jsxs("button",{type:"button",onClick:S,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":w,children:[j,k]}),e[24]=k,e[25]=S,e[26]=w,e[27]=j,e[28]=T):T=e[28];let O;e[29]!==i?(O=()=>i(null),e[29]=i,e[30]=O):O=e[30];let $;e[31]!==s?($=s("sessions.sidebar.dialogs.cancel"),e[31]=s,e[32]=$):$=e[32];let D;e[33]!==O||e[34]!==$?(D=n.jsx("button",{type:"button",onClick:O,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:$}),e[33]=O,e[34]=$,e[35]=D):D=e[35];let E;e[36]!==a?(E=()=>{a()},e[36]=a,e[37]=E):E=e[37];let R;e[38]!==d||e[39]!==s?(R=s(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=s,e[40]=R):R=e[40];let z;e[41]!==E||e[42]!==R?(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:R}),e[41]=E,e[42]=R,e[43]=z):z=e[43];let _;e[44]!==D||e[45]!==z?(_=n.jsxs("div",{className:"flex items-center gap-2",children:[D,z]}),e[44]=D,e[45]=z,e[46]=_):_=e[46];let W;e[47]!==T||e[48]!==_?(W=n.jsxs(Cn,{className:"w-full sm:items-center sm:justify-between",children:[T,_]}),e[47]=T,e[48]=_,e[49]=W):W=e[49];let N;e[50]!==W||e[51]!==h?(N=n.jsxs(qs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[h,W]}),e[50]=W,e[51]=h,e[52]=N):N=e[52];let Y;return e[53]!==y||e[54]!==N||e[55]!==v?(Y=n.jsx(Ys,{open:y,onOpenChange:v,children:N}),e[53]=y,e[54]=N,e[55]=v,e[56]=Y):Y=e[56],Y}function Ch(t){const e=Xe.c(36),{t:s}=Ct(),{value:r,setValue:i,onConfirm:o}=t,c=!!r;let a;e[0]!==i?(a=j=>{j||i(null)},e[0]=i,e[1]=a):a=e[1];let d;e[2]!==s?(d=s("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==d?(u=n.jsx(Zs,{children:d}),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==s||e[7]!==r?(f=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?s("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):s("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):s("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):s("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=s,e[7]=r,e[8]=f):f=e[8];let p;e[9]!==f?(p=n.jsx(Js,{children:f}),e[9]=f,e[10]=p):p=e[10];let m;e[11]!==u||e[12]!==p?(m=n.jsxs(en,{children:[u,p]}),e[11]=u,e[12]=p,e[13]=m):m=e[13];let g;e[14]!==i?(g=()=>i(null),e[14]=i,e[15]=g):g=e[15];let y;e[16]!==s?(y=s("sessions.sidebar.dialogs.cancel"),e[16]=s,e[17]=y):y=e[17];let v;e[18]!==g||e[19]!==y?(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:y}),e[18]=g,e[19]=y,e[20]=v):v=e[20];let x;e[21]!==s?(x=s("sessions.sidebar.bulkActions.delete"),e[21]=s,e[22]=x):x=e[22];let b;e[23]!==o||e[24]!==x?(b=n.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:x}),e[23]=o,e[24]=x,e[25]=b):b=e[25];let h;e[26]!==b||e[27]!==v?(h=n.jsxs(Cn,{children:[v,b]}),e[26]=b,e[27]=v,e[28]=h):h=e[28];let S;e[29]!==h||e[30]!==m?(S=n.jsxs(qs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[m,h]}),e[29]=h,e[30]=m,e[31]=S):S=e[31];let w;return e[32]!==c||e[33]!==a||e[34]!==S?(w=n.jsx(Ys,{open:c,onOpenChange:a,children:S}),e[32]=c,e[33]=a,e[34]=S,e[35]=w):w=e[35],w}const I4=new Set;function T4(t){const e=Xe.c(113),{node:s,depth:r,groupDirectory:i,projectId:o,folderOwnerKey:c,selectionScopeKey:a,archivedBucket:d,secondaryMeta:u,renderContext:f,rowKey:p,dragKey:m,renderExtras:g,pinnedSessionIds:y,expandedParents:v,hasSessionSearchQuery:x,normalizedSessionSearchQuery:b,notifyOnSubtasks:h,editingId:S,editingRowKey:w,setEditingId:j,setEditingRowKey:k,editTitle:T,setEditTitle:O,toggleParent:$,openSidebarMenuKey:D,setOpenSidebarMenuKey:E,allowReselect:R,onSessionSelected:z,resetSessionSearch:_,deleteSessionConfirm:W,setDeleteSessionConfirm:N,startFolderRename:Y,startSessionWorktreeMenuLoad:C,mobileVariant:P,alwaysShowActions:I,renderChildren:H}=t,A=r===void 0?0:r,F=d===void 0?!1:d,L=f===void 0?"project":f,X=H===void 0?!0:H;Cs("ui.sidebar_tree_item.render");const re=p??`${L}:${F?"archived":"active"}:${s.session.id}`,te=es(M4),M=es(N4),ee=de(R4),V=de(D4);let Ee;if(e[0]!==s){Ee=[];const Te=Ge=>Ge.children.forEach(st=>{Ee.push(st.session.id),Te(st)});Te(s),e[0]=s,e[1]=Ee}else Ee=e[1];const ve=Ee.join(`
|
|
1047
|
+
`);let ce;e[2]!==ve?(ce=ve?ve.split(`
|
|
1048
|
+
`):[],e[2]=ve,e[3]=ce):ce=e[3];const Be=ce;let me;e[4]!==te||e[5]!==Y||e[6]!==M?(me=(Te,Ge)=>{if(!Te)return null;Ge&&es.getState().collapsedFolderIds.has(Ge)&&M(Ge);const st=te(Te,"New folder",Ge);return Y(Te,st),st},e[4]=te,e[5]=Y,e[6]=M,e[7]=me):me=e[7];const he=me;let G;e[8]!==R||e[9]!==W||e[10]!==Be||e[11]!==T||e[12]!==S||e[13]!==re||e[14]!==P||e[15]!==s.session.id||e[16]!==z||e[17]!==_||e[18]!==N||e[19]!==O||e[20]!==j||e[21]!==k||e[22]!==ee?(G={mobileVariant:P,allowReselect:R,onSessionSelected:z,resetSessionSearch:_,descendantIds:Be,showDeletionDialog:ee,setDeleteSessionConfirm:N,deleteSessionConfirm:W,editingId:S,setEditingId:j,setEditingRowKey:k,editingSessionId:s.session.id,editingOccurrenceKey:re,editTitle:T,setEditTitle:O},e[8]=R,e[9]=W,e[10]=Be,e[11]=T,e[12]=S,e[13]=re,e[14]=P,e[15]=s.session.id,e[16]=z,e[17]=_,e[18]=N,e[19]=O,e[20]=j,e[21]=k,e[22]=ee,e[23]=G):G=e[23];const le=C4(G),ye=g?.childRenderExtrasFor,Ie=s.session.directory??i;let K;e[24]!==F||e[25]!==o||e[26]!==L||e[27]!==Ie?(K={groupDirectory:Ie,projectId:o,archivedBucket:F,renderContext:L},e[24]=F,e[25]=o,e[26]=L,e[27]=Ie,e[28]=K):K=e[28];const se=K,U=m??p??s.session.id,ie=g?.subtreeContainsEditing??I4,we=g?.menuOpenSessionId??null,pe=g?.nodeStructureKey??"",Se=g?.blockingBadgeSessionScopes,Ce=g?.relativeTimeTick;let Oe;e[29]!==R||e[30]!==I||e[31]!==se||e[32]!==ye||e[33]!==W||e[34]!==A||e[35]!==T||e[36]!==S||e[37]!==w||e[38]!==v||e[39]!==c||e[40]!==x||e[41]!==P||e[42]!==s.children||e[43]!==b||e[44]!==h||e[45]!==z||e[46]!==D||e[47]!==y||e[48]!==X||e[49]!==_||e[50]!==a||e[51]!==N||e[52]!==O||e[53]!==j||e[54]!==k||e[55]!==E||e[56]!==Y||e[57]!==C||e[58]!==$?(Oe=X?s.children.map(Te=>n.jsx(Wo,{node:Te,pinnedSessionIds:y,expandedParents:v,hasSessionSearchQuery:x,normalizedSessionSearchQuery:b,notifyOnSubtasks:h,editingId:S,editingRowKey:w,setEditingId:j,setEditingRowKey:k,editTitle:T,setEditTitle:O,toggleParent:$,openSidebarMenuKey:D,setOpenSidebarMenuKey:E,allowReselect:R,onSessionSelected:z,resetSessionSearch:_,deleteSessionConfirm:W,setDeleteSessionConfirm:N,startFolderRename:Y,startSessionWorktreeMenuLoad:C,mobileVariant:P,alwaysShowActions:I,depth:A+1,folderOwnerKey:c,selectionScopeKey:a,...se,renderExtras:ye?.(Te)},Te.session.id)):null,e[29]=R,e[30]=I,e[31]=se,e[32]=ye,e[33]=W,e[34]=A,e[35]=T,e[36]=S,e[37]=w,e[38]=v,e[39]=c,e[40]=x,e[41]=P,e[42]=s.children,e[43]=b,e[44]=h,e[45]=z,e[46]=D,e[47]=y,e[48]=X,e[49]=_,e[50]=a,e[51]=N,e[52]=O,e[53]=j,e[54]=k,e[55]=E,e[56]=Y,e[57]=C,e[58]=$,e[59]=Oe):Oe=e[59];let B;e[60]!==I||e[61]!==F||e[62]!==he||e[63]!==A||e[64]!==T||e[65]!==S||e[66]!==w||e[67]!==re||e[68]!==v||e[69]!==c||e[70]!==i||e[71]!==x||e[72]!==P||e[73]!==s||e[74]!==b||e[75]!==h||e[76]!==D||e[77]!==y||e[78]!==o||e[79]!==L||e[80]!==u||e[81]!==a||e[82]!==le.handleCancelEdit||e[83]!==le.handleCopySessionId||e[84]!==le.handleDeleteSession||e[85]!==le.handleRestoreSession||e[86]!==le.handleSaveEdit||e[87]!==le.handleSessionDoubleClick||e[88]!==le.handleSessionSelect||e[89]!==O||e[90]!==j||e[91]!==k||e[92]!==E||e[93]!==C||e[94]!==U||e[95]!==ie||e[96]!==we||e[97]!==pe||e[98]!==Se||e[99]!==Ce||e[100]!==Oe||e[101]!==$?(B=n.jsx(k4,{expandedParents:v,hasSessionSearchQuery:x,normalizedSessionSearchQuery:b,notifyOnSubtasks:h,editingId:S,editingRowKey:w,setEditingId:j,setEditingRowKey:k,editTitle:T,setEditTitle:O,handleSaveEdit:le.handleSaveEdit,handleCancelEdit:le.handleCancelEdit,toggleParent:$,handleSessionSelect:le.handleSessionSelect,handleSessionDoubleClick:le.handleSessionDoubleClick,handleCopySessionId:le.handleCopySessionId,openSidebarMenuKey:D,setOpenSidebarMenuKey:E,createFolderAndStartRename:he,handleDeleteSession:le.handleDeleteSession,handleRestoreSession:le.handleRestoreSession,startSessionWorktreeMenuLoad:C,mobileVariant:P,alwaysShowActions:I,pinnedSessionIds:y,node:s,depth:A,groupDirectory:i,projectId:o,folderOwnerKey:c,selectionScopeKey:a,archivedBucket:F,secondaryMeta:u,renderContext:L,rowKey:re,dragKey:U,subtreeContainsEditing:ie,menuOpenSessionId:we,nodeStructureKey:pe,blockingBadgeSessionScopes:Se,relativeTimeTick:Ce,children:Oe}),e[60]=I,e[61]=F,e[62]=he,e[63]=A,e[64]=T,e[65]=S,e[66]=w,e[67]=re,e[68]=v,e[69]=c,e[70]=i,e[71]=x,e[72]=P,e[73]=s,e[74]=b,e[75]=h,e[76]=D,e[77]=y,e[78]=o,e[79]=L,e[80]=u,e[81]=a,e[82]=le.handleCancelEdit,e[83]=le.handleCopySessionId,e[84]=le.handleDeleteSession,e[85]=le.handleRestoreSession,e[86]=le.handleSaveEdit,e[87]=le.handleSessionDoubleClick,e[88]=le.handleSessionSelect,e[89]=O,e[90]=j,e[91]=k,e[92]=E,e[93]=C,e[94]=U,e[95]=ie,e[96]=we,e[97]=pe,e[98]=Se,e[99]=Ce,e[100]=Oe,e[101]=$,e[102]=B):B=e[102];let ae;e[103]!==W||e[104]!==s.session.id||e[105]!==le.confirmDeleteSession||e[106]!==N||e[107]!==V||e[108]!==ee?(ae=W?.session.id===s.session.id?n.jsx(P4,{value:W,setValue:N,showDeletionDialog:ee,setShowDeletionDialog:V,onConfirm:le.confirmDeleteSession}):null,e[103]=W,e[104]=s.session.id,e[105]=le.confirmDeleteSession,e[106]=N,e[107]=V,e[108]=ee,e[109]=ae):ae=e[109];let xe;return e[110]!==B||e[111]!==ae?(xe=n.jsxs(n.Fragment,{children:[B,ae]}),e[110]=B,e[111]=ae,e[112]=xe):xe=e[112],xe}function D4(t){return t.setShowDeletionDialog}function R4(t){return t.showDeletionDialog}function N4(t){return t.toggleFolderCollapse}function M4(t){return t.createFolder}const A4=(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&&zf(t.session,e.session)&&vt(t.worktree?.path??null)===vt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,O4=(t,e)=>{if(t.node!==e.node&&!A4(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 i of r)if(t[i]!==e[i])return!1;return!0},Wo=l.memo(T4,O4),B4=10,F4=4;function Wd(t){const e=Xe.c(7),{providerIDs:s,ringClass:r}=t;let i;if(e[0]!==s||e[1]!==r){let c;e[3]!==r?(c=a=>n.jsx("span",{className:De("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:n.jsx(Rf,{providerId:a,className:"h-3 w-3"})},a),e[3]=r,e[4]=c):c=e[4],i=s.slice(0,F4).map(c),e[0]=s,e[1]=r,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=n.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:i}),e[5]=i,e[6]=o):o=e[6],o}function L4(t){const e=Xe.c(106),{run:s,depth:r,laneNodes:i,blockingSessionIds:o,renderContext:c,projectId:a,projectLabel:d,expansionKey:u,expanded:f,forceExpanded:p,notifyOnSubtasks:m,toggleParent:g}=t,{t:y}=Ct();let v;e[0]!==s.key?(v=me=>me.runOverviewKey===s.key,e[0]=s.key,e[1]=v):v=e[1];const x=de(v),b=c==="mixed-compact",h=cr(c)||b;let S;e[2]!==a||e[3]!==c?(S=me=>c==="timeline-mixed"&&a?me.projects.find(he=>he.id===a)??null:null,e[2]=a,e[3]=c,e[4]=S):S=e[4];const w=ns(S),j=s.lanes.length;let k;e[5]!==j||e[6]!==y?(k=j===1?y("sessions.sidebar.run.laneCountSingle",{count:j}):y("sessions.sidebar.run.laneCountPlural",{count:j}),e[5]=j,e[6]=y,e[7]=k):k=e[7];const T=k;let O;e[8]!==i?(O=[...i],e[8]=i,e[9]=O):O=e[9];const $=O;let D;e[10]!==$||e[11]!==o||e[12]!==m?(D=n.jsx(Fu,{nodes:$,blockingSessionIds:o,includeUnreadSubtasks:m}),e[10]=$,e[11]=o,e[12]=m,e[13]=D):D=e[13];const E=D,R=x?"text-interactive-selection-foreground":"text-muted-foreground";let z;e[14]!==s.key?(z=()=>de.getState().setRunOverviewKey(s.key),e[14]=s.key,e[15]=z):z=e[15];const _=z;if(h){const me=s.key,he=x?"page":void 0;let G;e[16]!==s.title||e[17]!==y?(G=y("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[16]=s.title,e[17]=y,e[18]=G):G=e[18];let le;e[19]!==r||e[20]!==b?(le=b?$n(r):B4,e[19]=r,e[20]=b,e[21]=le):le=e[21];let ye;e[22]!==le?(ye={paddingInlineStart:le},e[22]=le,e[23]=ye):ye=e[23];const Ie=b?"gap-1.5 py-1":"py-1.5",K=x?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let se;e[24]!==Ie||e[25]!==K?(se=De("group relative my-0.5 flex w-full cursor-pointer items-center rounded-md pe-2.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Ie,K),e[24]=Ie,e[25]=K,e[26]=se):se=e[26];let U;e[27]!==E||e[28]!==b?(U=b?n.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:E}):null,e[27]=E,e[28]=b,e[29]=U):U=e[29];const ie=s.title;let we;e[30]===Symbol.for("react.memo_cache_sentinel")?(we=n.jsx(fa,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[30]=we):we=e[30];let pe;e[31]!==T?(pe=n.jsxs(n.Fragment,{children:[we,n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:T})]}),e[31]=T,e[32]=pe):pe=e[32];const Se=b?null:E;let Ce;e[33]!==s.lastActivity?(Ce=$f(s.lastActivity),e[33]=s.lastActivity,e[34]=Ce):Ce=e[34];let Oe;e[35]!==s.providerIDs?(Oe=n.jsx(Wd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[35]=s.providerIDs,e[36]=Oe):Oe=e[36];let B;e[37]!==b||e[38]!==d||e[39]!==s.title||e[40]!==pe||e[41]!==Se||e[42]!==Ce||e[43]!==Oe||e[44]!==w||e[45]!==R?(B=n.jsx(Ba,{compact:b,project:w,projectLabel:d,title:ie,titleClassName:R,branchLabel:null,metaLineLead:pe,statusDot:Se,pinnedMarker:null,timeSlot:Ce,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:Oe,hideMetaOnHoverClass:""}),e[37]=b,e[38]=d,e[39]=s.title,e[40]=pe,e[41]=Se,e[42]=Ce,e[43]=Oe,e[44]=w,e[45]=R,e[46]=B):B=e[46];let ae;return e[47]!==_||e[48]!==s.key||e[49]!==ye||e[50]!==se||e[51]!==U||e[52]!==B||e[53]!==he||e[54]!==G?(ae=n.jsxs("button",{type:"button","data-run-row":me,"aria-current":he,"aria-label":G,onClick:_,style:ye,className:se,children:[U,B]}),e[47]=_,e[48]=s.key,e[49]=ye,e[50]=se,e[51]=U,e[52]=B,e[53]=he,e[54]=G,e[55]=ae):ae=e[55],ae}let W;e[56]!==u||e[57]!==p||e[58]!==g?(W=me=>{me.stopPropagation(),p||g(u)},e[56]=u,e[57]=p,e[58]=g,e[59]=W):W=e[59];const N=W,Y=s.key,C=x?"page":void 0;let P;e[60]!==r?(P=$n(r),e[60]=r,e[61]=P):P=e[61];let I;e[62]!==P?(I={paddingInlineStart:P},e[62]=P,e[63]=I):I=e[63];const H=x?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let A;e[64]!==H?(A=De("group relative my-0.5 flex cursor-pointer items-center gap-1.5 rounded-md py-[3px] pe-2.5",H),e[64]=H,e[65]=A):A=e[65];let F;e[66]!==N?(F=me=>{(me.key==="Enter"||me.key===" ")&&(me.preventDefault(),N(me))},e[66]=N,e[67]=F):F=e[67];let L;e[68]!==f||e[69]!==y?(L=y(f?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[68]=f,e[69]=y,e[70]=L):L=e[70];let X;e[71]!==f?(X=n.jsx(Ar,{expanded:f}),e[71]=f,e[72]=X):X=e[72];let re;e[73]!==f||e[74]!==F||e[75]!==L||e[76]!==X||e[77]!==N?(re=n.jsx("button",{type:"button",onClick:N,onKeyDown:F,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":L,children:X}),e[73]=f,e[74]=F,e[75]=L,e[76]=X,e[77]=N,e[78]=re):re=e[78];let te;e[79]!==_?(te=me=>{me.stopPropagation(),_()},e[79]=_,e[80]=te):te=e[80];let M;e[81]!==s.title||e[82]!==y?(M=y("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[81]=s.title,e[82]=y,e[83]=M):M=e[83];let ee;e[84]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx(fa,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[84]=ee):ee=e[84];let V;e[85]!==R?(V=De("oc-ui-start-align block min-w-0 flex-1 truncate typography-ui-label font-normal",R),e[85]=R,e[86]=V):V=e[86];let Ee;e[87]!==s.title||e[88]!==V?(Ee=n.jsx("span",{dir:"auto",className:V,children:s.title}),e[87]=s.title,e[88]=V,e[89]=Ee):Ee=e[89];let ve;e[90]!==s.providerIDs?(ve=n.jsx(Wd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar"}),e[90]=s.providerIDs,e[91]=ve):ve=e[91];let ce;e[92]!==E||e[93]!==te||e[94]!==M||e[95]!==Ee||e[96]!==ve?(ce=n.jsxs("button",{type:"button",onClick:te,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":M,children:[ee,Ee,ve,E]}),e[92]=E,e[93]=te,e[94]=M,e[95]=Ee,e[96]=ve,e[97]=ce):ce=e[97];let Be;return e[98]!==_||e[99]!==s.key||e[100]!==I||e[101]!==A||e[102]!==re||e[103]!==ce||e[104]!==C?(Be=n.jsxs("div",{"data-run-row":Y,"aria-current":C,onClick:_,style:I,className:A,children:[re,ce]}),e[98]=_,e[99]=s.key,e[100]=I,e[101]=A,e[102]=re,e[103]=ce,e[104]=C,e[105]=Be):Be=e[105],Be}const _4=l.memo(L4),$4=24,z4=t=>Array.from({length:Math.min(t,$4)},(e,s)=>s),K4=(t,e,s)=>{const r=new Set(t);for(const i of e)i>=0&&i<s&&r.add(i);return[...r].sort((i,o)=>i-o)},W4=(t,e)=>t.find(s=>s.end>e)?.index??0,H4={"pb-2":8,"pb-1.5":6},Hd=t=>`${t.kind}:${"renderContext"in t?t.renderContext:""}`,V4=(t,e)=>`${t.key}|${Xn(t,e)??""}`,U4=(t,e,s={})=>{const r=Xn(t,e),i=r?s.gapBySpacing?.get(r)??H4[r]:0;return(s.height??t.estimateSize)+i},Xn=(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,G4=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function q4({model:t,scrollElement:e,pinnedRowIndexes:s,renderRow:r,onFirstVisibleIndexChange:i}){const o=t.rows,c=l.useCallback(()=>e,[e]),a=l.useRef(new Map),d=l.useRef(new Map),u=l.useCallback(D=>{const E=o[D];if(!E)return 32;const R=o[D+1];return U4(E,R,{height:a.current.get(Hd(E)),gapBySpacing:d.current})},[o]),f=l.useCallback((D,E,R)=>{const z=E1(D,E,R),_=R.indexFromElement(D),W=o[_];if(W){const N=Xn(W,o[_+1]),Y=N&&Number.parseFloat(getComputedStyle(D).paddingBottom)||0;N&&d.current.set(N,Y),a.current.set(Hd(W),z-Y)}return z},[o]),p=l.useCallback(D=>{const E=o[D];return E?V4(E,o[D+1]):D},[o]),m=l.useRef(0),[g,y]=l.useState(null),v=g?.slidingIndexes,x=l.useCallback(D=>{const E=I1(D),R=v?.length?new Set([...s,...v]):s;return K4(E,R,o.length)},[s,o.length,v]),b=P1({count:o.length,enabled:e!==null,getScrollElement:c,estimateSize:u,measureElement:f,getItemKey:p,overscan:8,rangeExtractor:x}),h=b.getVirtualItems(),S=e?b.getTotalSize():0,w=e?Math.max(S-e.clientHeight,0):0,j=e?Math.min(e.scrollTop,w):0,k=W4(h,j);l.useLayoutEffect(()=>{i(k)},[k,i]);const T=l.useRef(null),O=l.useRef(null);if(l.useLayoutEffect(()=>{const D=O.current;if(!D||D.rows===o||!e||G4())return;const E=pb(D.rows,o);if(!E)return;const R=D.measurements,z=b.measurementsCache,_=R[E.previousHeaderIndex],W=z[E.nextHeaderIndex];if(!_||!W)return;const N=W.start-_.start,Y=E.opened?R[E.previousHeaderIndex+1]:R[E.blockEnd],C=E.opened?E.blockEnd:E.nextHeaderIndex+1,P=z[C],I=(Y?.start??_.end)+N,H=P?.start??W.end,A=e.scrollTop-e.clientHeight,F=e.scrollTop+e.clientHeight*2,L=new Set,X=[],re=[];if(E.opened){for(let te=E.blockStart;te<E.blockEnd;te+=1)L.add(o[te].key);for(let te=C;te<z.length&&z[te].start+I-H<F;te+=1)re.push(te)}else for(let te=E.blockStart;te<E.blockEnd;te+=1){const M=R[te];!M||M.end+N<A||M.start+N>F||X.push({row:D.rows[te],nextRow:D.rows[te+1],start:M.start+N,end:M.end+N})}m.current+=1,y({id:m.current,revealKeys:L,ghosts:X,followingIndex:C,from:I,to:H,slidingIndexes:re})},[o,e,b]),l.useLayoutEffect(()=>{O.current={rows:o,measurements:b.measurementsCache}}),l.useLayoutEffect(()=>{const D=T.current;if(!g||!D)return;const E={duration:mb,easing:hb},R=g.from-g.to,z=[];for(const W of D.children){if(!(W instanceof HTMLElement))continue;const N=W.dataset.sidebarRowKey??"",Y=Number(W.dataset.sidebarVirtualStart);W.dataset.sidebarGhost==="true"?z.push(W.animate(dc(Y,W.offsetHeight,g.from,g.to),{...E,fill:"forwards"})):g.revealKeys.has(N)?z.push(W.animate(dc(Y,W.offsetHeight,g.from,g.to),E)):Number(W.dataset.index)>=g.followingIndex&&R!==0&&z.push(W.animate([{transform:`translateY(${Y+R}px)`},{transform:`translateY(${Y}px)`}],E))}let _=!1;return Promise.all(z.map(W=>W.finished)).then(()=>{_||y(W=>W?.id===g.id?null:W)},()=>{}),()=>{_=!0;for(const W of z)W.cancel()}},[g]),!e){const D=z4(o.length),E=D.reduce((z,_)=>z+(o[_]?.estimateSize??0),0),R=o.reduce((z,_)=>z+_.estimateSize,0);return n.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[D.map(z=>{const _=o[z];return _?n.jsx("div",{className:Xn(_,o[z+1]),children:r(_,z)},_.key):null}),R>E?n.jsx("div",{"aria-hidden":"true",style:{height:R-E}}):null]})}const $=g?.ghosts.reduce((D,E)=>Math.max(D,E.end),0)??0;return n.jsxs("div",{ref:T,"data-sidebar-virtual-ready":"true",style:{height:Math.max(S,$),position:"relative"},children:[g?.ghosts.map(D=>n.jsx("div",{"aria-hidden":"true",inert:!0,className:`[&_[data-session-row]]:my-px ${Xn(D.row,D.nextRow)??""}`,"data-sidebar-ghost":"true","data-sidebar-row-key":D.row.key,"data-sidebar-virtual-start":D.start,style:{position:"absolute",top:0,left:0,width:"100%",pointerEvents:"none",transform:`translateY(${D.start}px)`},children:r(D.row,-1)},D.row.key)),h.map(D=>{const E=o[D.index];return E?n.jsx("div",{className:`[&_[data-session-row]]:my-px ${Xn(E,o[D.index+1])??""}`,"data-index":D.index,"data-sidebar-row-key":E.key,"data-sidebar-virtual-start":D.start,ref:b.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${D.start}px)`},children:r(E,D.index)},E.key):null})]})}const Y4={pinned:"pushpin",work:"eye",chats:"chat-4"},X4={pinned:"sessions.sidebar.activity.pinnedTitle",work:"sessions.sidebar.work.title",chats:"sessions.sidebar.activity.chatsTitle"},Q4=t=>{const e=Xe.c(33),{activityKey:s,collapsed:r,forceExpanded:i,alwaysShowActions:o,onToggle:c,onNewChat:a}=t,{t:d}=Ct(),u=s==="chats",f=i?void 0:c,p=u?"pe-10":"pe-3.5";let m;e[0]!==p?(m=De("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",p),e[0]=p,e[1]=m):m=e[1];const g=!r,y=Y4[s],v=!i&&"group-hover:hidden";let x;e[2]!==v?(x=De("h-3.5 w-3.5 text-muted-foreground/80",v),e[2]=v,e[3]=x):x=e[3];let b;e[4]!==y||e[5]!==x?(b=n.jsx(Q,{name:y,className:x}),e[4]=y,e[5]=x,e[6]=b):b=e[6];let h;e[7]!==r||e[8]!==i?(h=i?null:n.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:n.jsx(Q,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[7]=r,e[8]=i,e[9]=h):h=e[9];let S;e[10]!==b||e[11]!==h?(S=n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[b,h]}),e[10]=b,e[11]=h,e[12]=S):S=e[12];const w=X4[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 T;e[18]!==i||e[19]!==f||e[20]!==S||e[21]!==k||e[22]!==m||e[23]!==g?(T=n.jsxs("button",{type:"button",onClick:f,disabled:i,className:m,"aria-expanded":g,children:[S,k]}),e[18]=i,e[19]=f,e[20]=S,e[21]=k,e[22]=m,e[23]=g,e[24]=T):T=e[24];let O;e[25]!==o||e[26]!==u||e[27]!==a||e[28]!==d?(O=u?n.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),a()},className:De("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",o?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-has-[:focus-visible]/chats:opacity-100 group-has-[:focus-visible]/chats:pointer-events-auto"),"aria-label":d("sessions.sidebar.header.actions.newSession"),children:n.jsx(Q,{name:"add",className:"h-4 w-4"})}):null,e[25]=o,e[26]=u,e[27]=a,e[28]=d,e[29]=O):O=e[29];let $;return e[30]!==T||e[31]!==O?($=n.jsxs("div",{className:"relative group/chats -ms-2.5 -me-2",children:[T,O]}),e[30]=T,e[31]=O,e[32]=$):$=e[32],$},Ph=l.createContext(null);function Vd(t){let e=0,s=t;for(;s;){e+=s.offsetTop;const o=s.offsetParent;s=o instanceof HTMLElement?o:null}const r=t.closest("[data-sidebar-virtual-start]"),i=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(i)?i:0)}function Z4(t){const e=Xe.c(11),{suspended:s,layoutKey:r,scrollRef:i,children:o}=t,c=s===void 0?!1:s,a=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=l.useRef(d),f=l.useRef(null);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=x=>(u.current.add(x),f.current?.(),()=>{u.current.delete(x),f.current?.()}),e[1]=p):p=e[1];const m=p;let g;e[2]!==i||e[3]!==c?(g=()=>{const x=i.current;if(c||!x)return;const b=document.createElement("div");b.dataset.sidebarCrossfadeLayer="true",b.className="pointer-events-none sticky top-0 z-30 h-0",b.style.marginBlock="0px",x.prepend(b);let h=null,S=null,w=null,j=0;const k=new Set;let T=[];const O=window.matchMedia("(prefers-reduced-motion: reduce)"),$=(N,Y)=>{const C=document.activeElement,P=C instanceof HTMLElement&&N.host.contains(C),I=P?x.scrollTop:null;Y.moveBefore&&Y.isConnected&&N.host.isConnected?Y.moveBefore(N.host,null):Y.append(N.host),P&&C.focus({preventScroll:!0}),I!==null&&x.scrollTop!==I&&(x.scrollTop=I)},D=()=>{w?.cancel(),w=null,S?.remove(),S=null},E=()=>{let N=null,Y=-1/0;for(const{entry:C,top:P}of T)P<=x.scrollTop&&P>=Y&&(Y=P,N=C);if(h!==N){if(D(),h&&N&&!O.matches){const C=h.host.cloneNode(!0);C instanceof HTMLElement&&(C.inert=!0,C.setAttribute("aria-hidden","true"),C.querySelectorAll("[id]").forEach(J4),C.className="pointer-events-none absolute inset-x-0 top-0 z-30",S=C)}h&&($(h,h.slot),h.slot.style.removeProperty("height")),h=N,b.hidden=!N,N&&(N.slot.style.height=`${N.host.getBoundingClientRect().height}px`,$(N,b),S&&(b.append(S),w=S.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),w.onfinish=D))}},R=()=>{h&&(h.slot.style.height=`${h.host.getBoundingClientRect().height}px`);const N=Vd(x)+x.clientTop;T=Array.from(u.current,Y=>({entry:Y,top:Vd(Y.slot)-N})),E()},z=new ResizeObserver(R),_=new MutationObserver(()=>{cancelAnimationFrame(j),j=requestAnimationFrame(R)});z.observe(x);const W=()=>{_.disconnect();for(const N of k)u.current.has(N)||(z.unobserve(N.host),N.slot.parentElement&&z.unobserve(N.slot.parentElement),k.delete(N));for(const N of u.current){const Y=N.slot.closest("[data-sidebar-virtual-start]");Y&&_.observe(Y,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),k.has(N)||(z.observe(N.host),N.slot.parentElement&&z.observe(N.slot.parentElement),k.add(N))}cancelAnimationFrame(j),j=requestAnimationFrame(R)};return f.current=W,x.addEventListener("scroll",E,{passive:!0}),W(),R(),()=>{f.current=null,cancelAnimationFrame(j),x.removeEventListener("scroll",E),z.disconnect(),_.disconnect(),D(),b.hidden=!0,h&&($(h,h.slot),h.slot.style.removeProperty("height")),b.remove()}},e[2]=i,e[3]=c,e[4]=g):g=e[4];let y;e[5]!==a||e[6]!==i||e[7]!==c?(y=[c,a,i],e[5]=a,e[6]=i,e[7]=c,e[8]=y):y=e[8],l.useLayoutEffect(g,y);let v;return e[9]!==o?(v=n.jsx(Ph.Provider,{value:m,children:o}),e[9]=o,e[10]=v):v=e[10],v}function J4(t){return t.removeAttribute("id")}function e5(t){const e=Xe.c(15);let s,r;e[0]!==t?({register:r,...s}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const i=l.useRef(null),[o]=l.useState(t5);let c,a;e[3]!==o||e[4]!==r?(c=()=>{const m=i.current;if(!m)return;m.append(o);const g=r({slot:m,host:o});return()=>{g(),o.remove()}},a=[o,r],e[3]=o,e[4]=r,e[5]=c,e[6]=a):(c=e[5],a=e[6]),l.useLayoutEffect(c,a);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{ref:i}),e[7]=d):d=e[7];let u;e[8]!==s?(u=n.jsx("div",{...s}),e[8]=s,e[9]=u):u=e[9];let f;e[10]!==o||e[11]!==u?(f=Wa.createPortal(u,o),e[10]=o,e[11]=u,e[12]=f):f=e[12];let p;return e[13]!==f?(p=n.jsxs(n.Fragment,{children:[d,f]}),e[13]=f,e[14]=p):p=e[14],p}function t5(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function Eh(t){const e=Xe.c(3),s=l.useContext(Ph);let r;return e[0]!==t||e[1]!==s?(r=s?n.jsx(e5,{...t,register:s}):n.jsx("div",{...t}),e[0]=t,e[1]=s,e[2]=r):r=e[2],r}const s5=t=>{const e=Xe.c(3),[s,r]=l.useState(!1);let i,o;return e[0]!==t?(i=()=>{if(!t){r(!1);return}let c=!0;const a=()=>{Co.getDirectoryAvailability(t).then(d=>{c&&d!=="unknown"&&r(d==="missing")})};return a(),window.addEventListener("focus",a),()=>{c=!1,window.removeEventListener("focus",a)}},o=[t],e[0]=t,e[1]=i,e[2]=o):(i=e[1],o=e[2]),l.useEffect(i,o),s},Xi=t=>{const e=Xe.c(27),{id:s,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:c,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u,labelClassName:f}=t,p=u===void 0?!1:u,{currentTheme:m}=dr(),g=i?Xa[i]:null;let y;e[0]!==o?(y=Qa(o),e[0]=o,e[1]=y):y=e[1];const v=y,x=d!==void 0,b=x?p?"hidden":"transition-opacity group-hover/project:opacity-0 group-has-[:focus-visible]/project:opacity-0":void 0;let h;e[2]!==p||e[3]!==x||e[4]!==d?(h=x?n.jsx("span",{className:De("h-3.5 w-3.5 items-center justify-center text-muted-foreground",p?"inline-flex":"absolute inset-0 inline-flex opacity-0 transition-opacity group-hover/project:opacity-100 group-has-[:focus-visible]/project:opacity-100"),children:n.jsx(Q,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[2]=p,e[3]=x,e[4]=d,e[5]=h):h=e[5];let S;e[6]!==p||e[7]!==m||e[8]!==x||e[9]!==v||e[10]!==b||e[11]!==s||e[12]!==a||e[13]!==c||e[14]!==g?(S=c?n.jsx("span",{className:De("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",x&&p?"hidden":"inline-flex",b),style:a?{backgroundColor:a}:void 0,children:n.jsx(Za,{project:{id:s,iconImage:c},options:{themeVariant:m.metadata.variant,iconColor:m.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?n.jsx(Q,{name:g,className:"h-3.5 w-3.5",style:v?{color:v}:void 0}):n.jsx(Q,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:v?{color:v}:void 0})})}):g?n.jsx(Q,{name:g,className:De("h-3.5 w-3.5",b),style:v?{color:v}:void 0}):n.jsx(Q,{name:"folder",className:De("h-3.5 w-3.5 text-muted-foreground/80",b),style:v?{color:v}:void 0}),e[6]=p,e[7]=m,e[8]=x,e[9]=v,e[10]=b,e[11]=s,e[12]=a,e[13]=c,e[14]=g,e[15]=S):S=e[15];let w;e[16]!==h||e[17]!==S?(w=n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[h,S]}),e[16]=h,e[17]=S,e[18]=w):w=e[18];let j;e[19]!==f?(j=De("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 T;return e[24]!==w||e[25]!==k?(T=n.jsxs(n.Fragment,{children:[w,k]}),e[24]=w,e[25]=k,e[26]=T):T=e[26],T},n5=t=>{const e=Xe.c(67),{id:s,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:c,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:p,isRepo:m,hideDirectoryControls:g,alwaysShowActions:y,onToggle:v,onNewSession:x,onNewWorktreeSession:b,onManageWorktrees:h,onManageSpaces:S,onOpenFolder:w,onRenameStart:j,onArchiveAll:k,onClose:T,children:O,showCreateButtons:$,hideHeader:D,statusIndicator:E,openSidebarMenuKey:R,setOpenSidebarMenuKey:z,projectPickerOptions:_,onProjectSelect:W}=t,N=r===void 0?!1:r,Y=$===void 0?!0:$,C=D===void 0?!1:D,P=E===void 0?null:E,{t:I}=Ct(),H=s5(c);let A;e[0]!==N||e[1]!==s?(A={id:s,disabled:N},e[0]=N,e[1]=s,e[2]=A):A=e[2];const{attributes:F,listeners:L,setNodeRef:X,transform:re,transition:te,isDragging:M}=Wr(A),ee=l.useRef(!1),V=`project:${s}`,Ee=R===V,[ve,ce]=l.useState(!1),Be=!!(_&&W);let me;e[3]!==V||e[4]!==z?(me=Ke=>{Ke&&ce(!1),z(Ke?V:null)},e[3]=V,e[4]=z,e[5]=me):me=e[5];const he=me;let G;e[6]!==g||e[7]!==m||e[8]!==k||e[9]!==T||e[10]!==S||e[11]!==h||e[12]!==x||e[13]!==w||e[14]!==j||e[15]!==Y||e[16]!==I?(G=Ke=>n.jsxs(n.Fragment,{children:[Y&&!m&&!g&&x&&n.jsxs(Ke,{onClick:x,children:[n.jsx(Q,{name:"add",className:"me-1.5 h-4 w-4"}),I("sessions.sidebar.project.actions.newSession")]}),m&&!g&&h&&n.jsxs(Ke,{onClick:h,children:[n.jsx(Q,{name:"node-tree",className:"me-1.5 h-4 w-4"}),I("sessions.sidebar.project.actions.manageWorktrees")]}),m&&!g&&S&&n.jsxs(Ke,{onClick:S,children:[n.jsx(Q,{name:"box-3",className:"me-1.5 h-4 w-4"}),I("spaces.page.menuItem")]}),w&&n.jsxs(Ke,{onClick:w,children:[n.jsx(Q,{name:"folder-received",className:"me-1.5 h-4 w-4"}),I(xf())]}),n.jsxs(Ke,{onClick:j,children:[n.jsx(Q,{name:"pencil-ai",className:"me-1.5 h-4 w-4"}),I("sessions.sidebar.project.actions.edit")]}),k&&n.jsxs(Ke,{onClick:k,children:[n.jsx(Q,{name:"archive",className:"me-1.5 h-4 w-4"}),I("sessions.sidebar.project.actions.archiveAll")]}),n.jsxs(Ke,{onClick:T,className:"text-destructive focus:text-destructive",children:[n.jsx(Q,{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]=T,e[10]=S,e[11]=h,e[12]=x,e[13]=w,e[14]=j,e[15]=Y,e[16]=I,e[17]=G):G=e[17];const le=G,ye=i5,Ie=a5,K=l5;let se;e[18]===Symbol.for("react.memo_cache_sentinel")?(se=Ke=>{(Ke.button===2||Ke.button===0&&Ke.ctrlKey)&&(ee.current=!0)},e[18]=se):se=e[18];const U=se;let ie;e[19]!==v?(ie=()=>{if(ee.current){ee.current=!1;return}v()},e[19]=v,e[20]=ie):ie=e[20];const we=ie,Se=(Y&&m&&!g&&!!b?1:0)+(g?0:1),Ce=Se===2?"[--oc-actions-reserve:66px]":Se===1&&Y?"[--oc-actions-reserve:38px]":Y||Se===1?"[--oc-actions-reserve:12px]":void 0,Oe=y?void 0:Ee?"oc-actions-mask":"group-hover/project:oc-actions-mask group-has-[:focus-visible]/project:oc-actions-mask",B=y?void 0:Ee?"opacity-0":"transition-opacity group-hover/project:opacity-0 group-has-[:focus-visible]/project:opacity-0";let ae;e[21]!==re?(ae=Hr.Transform.toString(re),e[21]=re,e[22]=ae):ae=e[22];let xe;e[23]!==ae||e[24]!==te?(xe={transform:ae,transition:te},e[23]=ae,e[24]=te,e[25]=xe):xe=e[25];const Te=M&&"opacity-30";let Ge;e[26]!==Te?(Ge=De("relative",Te),e[26]=Te,e[27]=Ge):Ge=e[27];let st;e[28]!==y||e[29]!==F||e[30]!==H||e[31]!==he||e[32]!==we||e[33]!==Ce||e[34]!==B||e[35]!==Oe||e[36]!==g||e[37]!==C||e[38]!==s||e[39]!==p||e[40]!==ve||e[41]!==Ee||e[42]!==Be||e[43]!==m||e[44]!==L||e[45]!==x||e[46]!==b||e[47]!==W||e[48]!==d||e[49]!==o||e[50]!==c||e[51]!==a||e[52]!==f||e[53]!==u||e[54]!==i||e[55]!==_||e[56]!==le||e[57]!==Y||e[58]!==P||e[59]!==I?(st=C?null:n.jsx(n.Fragment,{children:n.jsxs(cl,{open:ve,onOpenChange:ce,children:[n.jsx(ll,{render:n.jsx(Eh,{className:De("-ms-2.5 -me-2 text-start group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:Ke=>{g||(Ke.preventDefault(),ce(!0))}}),children:n.jsxs("div",{className:"relative flex items-center gap-1 py-1 ps-4 pe-3.5",...F,children:[Be?n.jsxs(Ts,{children:[n.jsx(Ds,{asChild:!0,children:n.jsxs("button",{type:"button",className:De("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?y||Ee?"pe-20":"pe-0 group-hover/project:pe-20 group-has-[:focus-visible]/project:pe-20":y||Ee?"pe-14":"pe-0 group-hover/project:pe-14 group-has-[:focus-visible]/project:pe-14"),"aria-label":I("sessions.sidebar.project.selectAria",{project:i}),children:[n.jsx(Xi,{id:s,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f}),n.jsx(Q,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),c?n.jsx($o,{directory:c,className:"ms-auto"}):null]})}),n.jsx(Rs,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:_?.map(Ke=>n.jsxs(Zt,{onClick:()=>W?.(Ke.id),className:"flex items-center justify-between gap-3",title:Ke.projectDescription,children:[n.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:n.jsx(Xi,{...Ke})}),Ke.id===s?n.jsx(Q,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},Ke.id))})]}):n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsxs("button",{type:"button",onMouseDown:U,onClick:we,...L,className:De("@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",y?m&&!g?"pe-20":"pe-14":Ce),children:[n.jsx(Xi,{id:s,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:p,alwaysShowActions:y,labelClassName:De("[--oc-actions-inset:20px]",Oe)}),H?n.jsx("span",{className:De("inline-flex flex-shrink-0 items-center text-status-warning",B),title:I("sessions.sidebar.project.folderMissing"),"aria-label":I("sessions.sidebar.project.folderMissing"),children:n.jsx(Q,{name:"alert",className:"h-3 w-3"})}):null,P?n.jsx("span",{className:De("ms-1 inline-flex flex-shrink-0 items-center",B),children:P}):null,c?n.jsx($o,{directory:c,className:De("ms-auto",B)}):null]})}),n.jsx(Ft,{side:"right",sideOffset:8,children:o})]}),n.jsxs("div",{className:De("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",Y?"inset-e-7":"inset-e-0.5"),children:[Y&&m&&!g&&b?n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ke=>{Ke.stopPropagation(),b()},className:De("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground transition-opacity",y?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-has-[:focus-visible]/project:opacity-100 group-has-[:focus-visible]/project:pointer-events-auto"),"aria-label":I("sessions.sidebar.project.actions.newWorktree"),children:n.jsx(Q,{name:"node-tree",className:"h-3.5 w-3.5"})})}),n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:I("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,g?null:n.jsxs(Ts,{open:Ee,onOpenChange:he,children:[n.jsx(Ds,{asChild:!0,children:n.jsx("button",{type:"button",className:De("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground",Ee?"opacity-100 pointer-events-auto":y?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-has-[:focus-visible]/project:opacity-100 group-has-[:focus-visible]/project:pointer-events-auto"),"aria-label":I("sessions.sidebar.project.actions.projectMenu"),onPointerDown:Ie,onMouseDown:K,onClick:ye,children:n.jsx(Q,{name:"more-2",className:"h-3 w-3"})})}),n.jsx(Rs,{align:"end",className:"min-w-[180px]",children:le(Zt)})]})]}),Y&&x?n.jsx("div",{className:"absolute inset-e-0.5 top-1/2 z-10 -translate-y-1/2",children:n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ke=>{Ke.stopPropagation(),x()},className:De("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",y?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-has-[:focus-visible]/project:opacity-100 group-has-[:focus-visible]/project:pointer-events-auto"),"aria-label":I(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:n.jsx(Q,{name:"add",className:"h-4 w-4"})})}),n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:I(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),n.jsx(al,{className:"min-w-[180px]",children:le(Ln)})]})}),e[28]=y,e[29]=F,e[30]=H,e[31]=he,e[32]=we,e[33]=Ce,e[34]=B,e[35]=Oe,e[36]=g,e[37]=C,e[38]=s,e[39]=p,e[40]=ve,e[41]=Ee,e[42]=Be,e[43]=m,e[44]=L,e[45]=x,e[46]=b,e[47]=W,e[48]=d,e[49]=o,e[50]=c,e[51]=a,e[52]=f,e[53]=u,e[54]=i,e[55]=_,e[56]=le,e[57]=Y,e[58]=P,e[59]=I,e[60]=st):st=e[60];let rt;return e[61]!==O||e[62]!==X||e[63]!==xe||e[64]!==Ge||e[65]!==st?(rt=n.jsxs("div",{ref:X,style:xe,className:Ge,children:[st,O]}),e[61]=O,e[62]=X,e[63]=xe,e[64]=Ge,e[65]=st,e[66]=rt):rt=e[66],rt},r5=t=>{const e=Xe.c(21),{id:s,disabled:r,children:i}=t,o=r===void 0?!1:r;let c;e[0]!==o||e[1]!==s?(c={id:s,disabled:o},e[0]=o,e[1]=s,e[2]=c):c=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:f,transition:p,isDragging:m}=Wr(c);let g;e[3]!==a||e[4]!==u?(g={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=g):g=e[5];const y=g;let v;e[6]!==f?(v=Hr.Transform.toString(f),e[6]=f,e[7]=v):v=e[7];let x;e[8]!==v||e[9]!==p?(x={transform:v,transition:p},e[8]=v,e[9]=p,e[10]=x):x=e[10];const b=m&&"opacity-50";let h;e[11]!==b?(h=De("space-y-0.5 rounded-md",b),e[11]=b,e[12]=h):h=e[12];let S;e[13]!==i||e[14]!==y?(S=i(y),e[13]=i,e[14]=y,e[15]=S):S=e[15];let w;return e[16]!==d||e[17]!==x||e[18]!==h||e[19]!==S?(w=n.jsx("div",{ref:d,style:x,className:h,children:S}),e[16]=d,e[17]=x,e[18]=h,e[19]=S,e[20]=w):w=e[20],w},o5=l.memo(r5);function i5(t){t.stopPropagation()}function a5(t){t.stopPropagation()}function l5(t){t.stopPropagation()}const Ud=[],c5=t=>{const e=Xe.c(6),{nodes:s,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==s?(o={nodes:s,includeUnreadSubtasks:r},e[0]=r,e[1]=s,e[2]=o):o=e[2];const c=Ou(o);let a;return e[3]!==i||e[4]!==c?(a=i(c),e[3]=i,e[4]=c,e[5]=a):a=e[5],a},Qi=(t,e)=>e?t.sessions.some(s=>lr(s,e)):!1,d5=(t,e,s)=>t.sessions.some(r=>oh(r,r,e,s,t.directory,t.directory)),u5=(t,e,s)=>{const r=i=>{const o=i.session.id;return e.get(o)!==s.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},f5=(t,e,s)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const c=`project:${r}:${o.session.id}`;return e.has(c)!==s.has(c)?!0:o.children.some(i)};return t.sessions.some(i)},p5=(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&&d5(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&u5(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&f5(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Qi(e.group,t.editingId)||Qi(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Qi(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const s=e.group.isArchivedBucket===!0,r=_o(e.group.sessions,t.openSidebarMenuKey,"project",s),i=_o(e.group.sessions,e.openSidebarMenuKey,"project",s);if(r||i)return!1}if(t.folderRename!==e.folderRename){const s=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??vt(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},h5=l.memo(function(e){const s=Xe.c(23),{label:r,sessions:i,worktree:o}=e,{t:c}=Ct(),a=vh();let d;s[0]!==i||s[1]!==a||s[2]!==o?(d=b=>{b.stopPropagation(),En.requestDelete({sessions:i,mode:"worktree",worktree:o,skipDialogIfSafe:a||b.shiftKey})},s[0]=i,s[1]=a,s[2]=o,s[3]=d):d=s[3];const u=a?"text-destructive":"text-muted-foreground";let f;s[4]!==u?(f=De("inline-flex h-6 w-6 items-center justify-center rounded-md hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u),s[4]=u,s[5]=f):f=s[5];let p;s[6]!==r||s[7]!==a||s[8]!==c?(p=a?c("sessions.sidebar.group.actions.deleteGroupAndBranchAria",{label:r}):c("sessions.sidebar.group.actions.deleteGroupAria",{label:r}),s[6]=r,s[7]=a,s[8]=c,s[9]=p):p=s[9];let m;s[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Q,{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]!==p?(g=n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,className:f,"aria-label":p,children:m})}),s[11]=d,s[12]=f,s[13]=p,s[14]=g):g=s[14];let y;s[15]!==a||s[16]!==c?(y=c(a?"sessions.sidebar.group.actions.deleteWorktreeAndBranch":"sessions.sidebar.group.actions.deleteWorktree"),s[15]=a,s[16]=c,s[17]=y):y=s[17];let v;s[18]!==y?(v=n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:y})}),s[18]=y,s[19]=v):v=s[19];let x;return s[20]!==g||s[21]!==v?(x=n.jsxs(Kt,{children:[g,v]}),s[20]=g,s[21]=v,s[22]=x):x=s[22],x}),Gd=[];function m5(t){const{t:e}=Ct(),s=ul(),r=sg(t.group.space?.id),i=$s(je=>{const Je=t.group.space?.id;return Je!=null&&Zx(je.journey?.get(Je),je.spaces.get(Je),je.actions.get(Je))}),{group:o,groupKey:c,projectId:a,hideGroupLabel:d,renderBody:u=!0,isEmpty:f=!1,hasSessionSearchQuery:p,normalizedSessionSearchQuery:m,groupSearchDataByGroup:g,visibleSessionCount:y,sessionBatchSize:v,collapsedGroups:x,hideDirectoryControls:b,showMoreGroupSessions:h,resetGroupSessionLimit:S,mobileVariant:w,alwaysShowActions:j,activeProjectId:k,setActiveProjectIdOnly:T,setSessionSwitcherOpen:O,openNewSessionDraft:$,pinnedSessionIds:D,sessionOrderIndex:E,notifyOnSubtasks:R,onToggleCollapsedGroup:z,dragHandleProps:_,compactBodyPadding:W=!1,expandedParents:N,editingId:Y,editingRowKey:C,openSidebarMenuKey:P,editTitle:I,folderRename:H,setFolderRenameDraft:A,clearFolderRename:F}=t,L=es(je=>je.toggleFolderCollapse),X=es(je=>je.renameFolder),re=es(je=>je.deleteFolder),te=es(je=>je.addSessionToFolder),M=de(je=>je.showDeletionDialog),[ee,V]=l.useState(null),Ee=l.useCallback((je,Je)=>{const gt=E.get(je.session.id),kt=E.get(Je.session.id);if(gt!==void 0||kt!==void 0){if(gt===void 0)return 1;if(kt===void 0)return-1;if(gt!==kt)return gt-kt}return dl(je.session,Je.session,D,wf)},[D,E]),ve=p?g.get(o):null,ce=p?!1:x.has(c),Be=Jx(!o.isMain&&o.worktree?o.worktree.path:null),me=o.isMain||o.isArchivedBucket||d?null:vt(o.directory??null),he=o.isMain||o.isArchivedBucket||d?null:o.branch?.trim()||null,G=Af(me,he),le=G?`var(--pr-${G.visualState})`:void 0,ye=Ff(G,e),Ie=G?nl(G.provider,G.number):"",K=G?ye?`${Ie} · ${ye}`:Ie:void 0,se=Fr(),U=l.useMemo(()=>{const je=o.folderScopes?.map(Je=>vt(Je.directory))??[vt(o.directory??null)];return[...new Set(je.filter(Je=>!!Je))]},[o.directory,o.folderScopes]);l.useSyncExternalStore(l.useCallback(je=>U.length>0?se.subscribeBootstrap(je):()=>{},[U.length,se]),l.useCallback(()=>U.map(je=>`${je}\0${se.getBootstrapState(je)??""}\0${se.getBootstrapFailure(je)??""}\0${se.getInitializationState(je)??""}\0${se.getInitializationFailure(je)??""}`).join(""),[U,se]),l.useCallback(()=>"",[]));const ie=U.some(je=>{const Je=se.getBootstrapState(je);return Je==="queued"||Je==="running"}),we=U.find(je=>se.getBootstrapState(je)==="failed"||se.getInitializationState(je)==="failed")??null,pe=we!==null&&se.getBootstrapState(we)==="failed",Se=we?pe?se.getBootstrapFailure(we):se.getInitializationFailure(we):void 0,Ce=Se==="os-permission"&&wu(),[Oe,B]=l.useState(!1),ae=l.useCallback(()=>{we&&se.requestBootstrap({directory:we,priority:ce?"visible":"expanded",reason:o.isMain?"project-expanded":"worktree-expanded",force:!0})},[se,we,o.isMain,ce]),xe=l.useCallback(async()=>{if(!(!we||!Ce||Oe)){B(!0);try{(await ku(we)).success&&ae()}finally{B(!1)}}},[Ce,we,Oe,ae]),Te=v??(b?10:7),Ge=Math.max(Te,y??Te),st=p?ve?.groupMatches===!0:!1,rt=p,Ke=l.useMemo(()=>[...rt?ve?.filteredNodes??[]:o.sessions].sort(Ee),[Ee,o.sessions,ve?.filteredNodes,rt]),ke=o.folderScopeKey??vt(o.directory??null),ge=sr(a,o.directory),Ve=l.useMemo(()=>o.folderScopes&&o.folderScopes.length>0?o.folderScopes:ke?[{scopeKey:ke,directory:o.directory??null}]:[],[ke,o.directory,o.folderScopes]),Ue=es(ar(l.useCallback(je=>Ve.map(({scopeKey:Je})=>je.foldersMap[Je]??Ud),[Ve]))),ft=l.useMemo(()=>Ve.flatMap(({scopeKey:je,directory:Je},gt)=>(Ue[gt]??Ud).map(Dt=>({folder:Dt,scopeKey:je,scopeDirectory:Je}))),[Ue,Ve]),Qe=es(ar(l.useCallback(je=>new Set(Ue.flatMap(Je=>Je.filter(gt=>je.collapsedFolderIds.has(gt.id)).map(gt=>gt.id))),[Ue]))),wt=l.useMemo(()=>{const je=new Map,Je=gt=>{gt.forEach(kt=>{je.set(kt.session.id,kt),kt.children.length>0&&Je(kt.children)})};return Je(Ke),je},[Ke]),Me=l.useMemo(()=>ft.map(({folder:je,scopeKey:Je,scopeDirectory:gt})=>{const kt=Oa(je.sessionIds,wt).sort(Ee);return{folder:je,scopeKey:Je,scopeDirectory:gt,nodes:kt}}),[ft,wt,Ee]),Pe=l.useMemo(()=>{const je=rh(Me.map(({folder:Je,nodes:gt})=>({id:Je.id,name:Je.name,parentId:Je.parentId,nodeCount:gt.length})),{archivedBucket:o.isArchivedBucket===!0,searchQuery:p?m:""});return Me.filter(({folder:Je})=>je.has(Je.id))},[Me,o.isArchivedBucket,p,m]),ot=Y,et=P,Ze=l.useMemo(()=>new Set(Pe.flatMap(je=>je.folder.sessionIds)),[Pe]),dt=l.useMemo(()=>Ke.filter(je=>!Ze.has(je.session.id)),[Ke,Ze]),J=l.useMemo(()=>{const je=new Map(Pe.map(Je=>[Je.folder.id,Je]));return nh(Pe.map(Je=>Je.folder)).map(Je=>je.get(Je.id)).filter(Je=>!!Je)},[Pe]),_e=l.useMemo(()=>{const je=new Map;return Pe.forEach(Je=>{if(!Je.folder.parentId)return;const gt=je.get(Je.folder.parentId)??[];gt.push(Je),je.set(Je.folder.parentId,gt)}),je},[Pe]),Le=l.useMemo(()=>{const je=new Map(Pe.map(kt=>[kt.folder.id,kt])),Je=new Map,gt=(kt,Dt)=>{const Gt=Je.get(kt);if(Gt!==void 0)return Gt;if(Dt.has(kt))return[];Dt.add(kt);const rs=je.get(kt),Vt=rs?[...rs.nodes]:[];for(const ts of _e.get(kt)??[])Vt.push(...gt(ts.folder.id,Dt));return Je.set(kt,Vt),Vt};return Pe.forEach(({folder:kt})=>gt(kt.id,new Set)),Je},[Pe,_e]),He="project",$e=l.useMemo(()=>{const je=new Set;return yd(Ke,ot,je),Pe.forEach(({nodes:Je})=>{yd(Je,ot,je)}),je},[Ke,Pe,ot]),tt=l.useMemo(()=>{if(!et)return null;const je=_o(Ke,et,He,!!o.isArchivedBucket);if(je)return je;for(const{nodes:Je}of Pe){const gt=_o(Je,et,He,!!o.isArchivedBucket);if(gt)return gt}return null},[et,Ke,Pe,o.isArchivedBucket]),bt=l.useCallback(je=>{const Je=new WeakMap,gt=kt=>{Je.set(kt,Mr(kt));for(const Dt of kt.children)gt(Dt)};return je.forEach(gt),Je},[]),ht=l.useMemo(()=>bt(Ke),[bt,Ke]),it=l.useMemo(()=>{const je=new WeakMap;return Pe.forEach(({nodes:Je})=>{Je.forEach(gt=>je.set(gt,Mr(gt)))}),je},[Pe]),Mt=l.useCallback(je=>ht.get(je)??it.get(je)??"",[ht,it]),nt=l.useCallback(je=>({subtreeContainsEditing:$e,menuOpenSessionId:tt,nodeStructureKey:Mt(je)}),[$e,tt,Mt]),Lt=dt.length,_t=o.isArchivedBucket||p?dt:dt.slice(0,Ge),Tt=Lt-_t.length,Ae=!o.isArchivedBucket&&!p&&Lt>Te&&Tt===0,at=l.useCallback(je=>{const Je=[],gt=kt=>{kt.forEach(Dt=>{Je.push(Dt.session),Dt.children.length>0&>(Dt.children)})};return gt(je),Je},[]),ut=l.useMemo(()=>at(Ke),[at,Ke]),pt=l.useMemo(()=>{if(G||o.isMain||o.isArchivedBucket||d)return Gd;const je=new Map;for(const Je of ut)for(const gt of fl(Je))je.has(gt.key)||je.set(gt.key,gt);return je.size>0?[...je.values()]:Gd},[ut,o.isArchivedBucket,o.isMain,G,d]),lt=l.useMemo(()=>pt.flatMap(je=>je.source==="github"?[Ir("issue",je)]:[]),[pt]),St=Ro(lt),ct=l.useMemo(()=>pt.flatMap(je=>je.source==="linear"?[pl(je.identifier)]:[]),[pt]),oe=Bf(ct),q=l.useMemo(()=>pt.flatMap(je=>je.source==="gitlab"?[Tr("issue",je.ref)]:[]),[pt]),fe=Ro(q),We=l.useMemo(()=>Lf(pt,St,oe,fe).map(je=>({...je,text:je.statusKey?`${je.label} · ${e(je.statusKey)}`:je.statusText?`${je.label} · ${je.statusText}`:je.label})),[fe,St,pt,oe,e]),be=We[0]??null,Ne=l.useMemo(()=>{if(!o.isArchivedBucket)return new Map;const je=new Map,Je=new Map;for(const{folder:kt}of Pe){if(!kt.parentId)continue;const Dt=Je.get(kt.parentId)??[];Dt.push(kt.id),Je.set(kt.parentId,Dt)}const gt=(kt,Dt)=>{if(Dt.has(kt))return[];Dt.add(kt);const Gt=Pe.find(({folder:ts})=>ts.id===kt),rs=Gt?at(Gt.nodes):[],Vt=Je.get(kt)??[];for(const ts of Vt)rs.push(...gt(ts,Dt));return rs};for(const{folder:kt}of Pe)je.set(kt.id,gt(kt.id,new Set));return je},[Pe,at,o.isArchivedBucket]);if(p&&!st&&J.length===0&&dt.length===0)return null;const mt=!o.isMain&&!!o.branch,jt=o.branch&&eS(o.branch,o.label)?{label:o.branch}:null,At=ce?n.jsx(Fu,{nodes:Ke,includeUnreadSubtasks:R}):null,Ot=(je,Je)=>{const{folder:gt,scopeKey:kt,scopeDirectory:Dt,nodes:Gt}=je,rs=Ne.get(gt.id)??[],Vt=H?.folderId===gt.id&&H?.scopeKey===kt,ts=p?!1:Qe.has(gt.id),ms=mn=>n.jsx(mh,{folderId:gt.id,scopeKey:kt,ownerKey:ge,children:(As,gn)=>n.jsx(hh,{folder:gt,displayName:Je,sessions:Gt,isCollapsed:ts,collapsedActivityState:mn,onToggle:()=>L(gt.id),onRename:as=>{X(kt,gt.id,as)},onDelete:()=>{if(o.isArchivedBucket){En.requestDelete({sessions:rs,mode:"session"});return}if(!M){re(kt,gt.id);return}const as=Pe.filter(({folder:vs})=>vs.parentId===gt.id).length,Os=Gt.length;V({scopeKey:kt,folderId:gt.id,folderName:gt.name,subFolderCount:as,sessionCount:Os})},groupDirectory:Dt??o.directory,projectId:a,mobileVariant:w,alwaysShowActions:j,isRenaming:Vt,renameDraft:Vt?H?.draft:void 0,onRenameDraftChange:A,onRenameSave:()=>{const as=H?.draft.trim()??"";as&&X(kt,gt.id,as),F()},onRenameCancel:F,droppableRef:As,isDropTarget:gn,depth:0,onNewSession:()=>{a&&a!==k&&T(a),w&&O(!1),$({selectedProjectId:a,directoryOverride:Dt??o.directory,targetFolderId:gt.id,target:o.draftTarget})},hideActions:!1,archivedBucket:o.isArchivedBucket===!0,children:Gt.map(as=>n.jsx(Wo,{node:as,pinnedSessionIds:D,expandedParents:N,hasSessionSearchQuery:p,normalizedSessionSearchQuery:m,notifyOnSubtasks:R,editingId:Y,editingRowKey:C,editTitle:I,openSidebarMenuKey:P,mobileVariant:w,alwaysShowActions:j,groupDirectory:Dt??o.directory,projectId:a,folderOwnerKey:ge,selectionScopeKey:ge,archivedBucket:o.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:$e,menuOpenSessionId:tt,nodeStructureKey:Mt(as),childRenderExtrasFor:nt},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},as.session.id))})},gt.id);return ts?n.jsx(c5,{nodes:Le.get(gt.id)??Gt,includeUnreadSubtasks:R,children:ms},gt.id):ms(null)},Wt=()=>{const je=new Map;for(const Dt of Pe){const Gt=Dt.folder.parentId;if(!Gt)continue;const rs=je.get(Gt);rs?rs.push(Dt):je.set(Gt,[Dt])}const Je=[],gt=new Set,kt=(Dt,Gt)=>{if(gt.has(Dt.folder.id))return;gt.add(Dt.folder.id);const rs=Gt?`${Gt} / ${Dt.folder.name}`:Dt.folder.name;Je.push(Ot(Dt,rs)),!(!p&&Qe.has(Dt.folder.id))&&(je.get(Dt.folder.id)??[]).forEach(ts=>kt(ts,rs))};return J.forEach(Dt=>kt(Dt,"")),Je},Qt=!!(!o.isMain&&o.worktree&&!Be),Ut=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(Q,{name:"alert",className:"h-3 w-3"})}):null,Ss=o.space&&o.space.state!=="complete"&&!i?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(Q,{name:"alert",className:"h-3 w-3"})}):null,bs=Qt||!!o.space,ys=!!o.space,Re=j?ys?"pe-20":bs?"pe-14":"pe-7":De("pe-2",ys?"[--oc-actions-reserve:68px]":bs?"[--oc-actions-reserve:44px]":"[--oc-actions-reserve:18px]"),ue=j?void 0:"group-hover/gh:oc-actions-mask group-has-[:focus-visible]/gh:oc-actions-mask",Fe=j?void 0:"transition-opacity group-hover/gh:opacity-0 group-has-[:focus-visible]/gh:opacity-0",yt=f?n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}):n.jsx(Ar,{expanded:!ce}),$t=je=>n.jsx("span",{className:"relative me-1 inline-flex size-3.5 flex-shrink-0 items-center justify-center",children:f||j?je:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"inline-flex items-center justify-center transition-opacity group-hover/gh:opacity-0 group-has-[:focus-visible]/gh:opacity-0",children:je}),n.jsx("span",{className:"absolute inset-0 inline-flex items-center justify-center text-muted-foreground opacity-0 transition-opacity group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100",children:yt})]})}),Et=G&&ye?[{key:`pr:${G.number}`,icon:"git-pull-request",text:`${Ie} · ${ye}`,title:G.title,color:le,url:G.url}]:[],ne=we?n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Se==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":pe?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),Ce?n.jsx(It,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:Oe,onClick:()=>{xe()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,n.jsx(It,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:ae,children:e("sessions.sidebar.group.empty.retry")})]}):null,Ye=je=>n.jsx(Wo,{node:je,pinnedSessionIds:D,expandedParents:N,hasSessionSearchQuery:p,normalizedSessionSearchQuery:m,notifyOnSubtasks:R,editingId:Y,editingRowKey:C,editTitle:I,openSidebarMenuKey:P,mobileVariant:w,alwaysShowActions:j,groupDirectory:o.directory,projectId:a,folderOwnerKey:ge,selectionScopeKey:ge,archivedBucket:o.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:$e,menuOpenSessionId:tt,nodeStructureKey:Mt(je),childRenderExtrasFor:nt},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},je.session.id),qe=n.jsxs(z3,{scopeKey:Ve[0]?.scopeKey??ke,ownerKey:ge,hasFolders:Pe.length>0,onSessionDroppedOnFolder:(je,Je)=>{const gt=Pe.find(({folder:Dt,scopeKey:Gt})=>Dt.id===Je.folderId&&Gt===Je.scopeKey);if(!gt)return;const kt=es.getState();for(const{scopeKey:Dt}of Ve)Dt!==gt.scopeKey&&kt.getSessionFolderId(Dt,je)&&kt.removeSessionFromFolder(Dt,je);te(gt.scopeKey,Je.folderId,je)},children:[Wt(),_t.map(Ye),Lt===0&&Pe.length===0&&!r?!o.isArchivedBucket&&!ie&&!ne&&o.directory&&!o.emptyMessage?n.jsx(It,{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!==k&&T(a),w&&O(!1),$({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"):ie?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Q,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):ne||(o.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,Lt>0&&ne?n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-status-error",children:ne}):null,Tt>0?n.jsx("button",{type:"button",onClick:()=>h(c,_t.length,v??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,Ae?n.jsx("button",{type:"button",onClick:()=>S(c),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]}),Pt="pb-2",Rt=n.jsx(Ch,{value:ee,setValue:V,onConfirm:()=>{const je=ee;je&&(re(je.scopeKey,je.folderId),V(null))}});return d?u?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"oc-group",children:n.jsx("div",{className:De("oc-group-body",Pt),children:qe})}),Rt]}):null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:De("oc-group",Be&&"opacity-60"),"aria-busy":Be||void 0,children:[n.jsxs("div",{className:De("oc-ref-tint-scope group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),children:[n.jsxs(Kt,{disabled:G?!ye:!be,children:[n.jsx(zt,{asChild:!0,closeDelay:xh,children:n.jsx("div",{className:"min-w-0 flex-1",...f?{}:{onClick:()=>z(c),role:"button",tabIndex:0,onKeyDown:je=>{(je.key==="Enter"||je.key===" ")&&(je.preventDefault(),z(c))},"aria-label":ce?e("sessions.sidebar.group.expandAria",{label:o.label}):e("sessions.sidebar.group.collapseAria",{label:o.label}),"aria-expanded":!ce},children:n.jsxs("div",{ref:_?.setActivatorNodeRef,style:{paddingInlineStart:$n(0)},className:De("@container min-w-0 flex flex-1 items-start gap-1 overflow-hidden",Re),..._?.listeners??{},children:[n.jsxs("div",{className:De("min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",ue),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:[$t(n.jsx(Q,{name:"archive",className:"h-3 w-3 shrink-0 text-muted-foreground"})),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:fo(o.label,m)}),Ut,At]}):!o.isMain||o.worktree?n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-0.5",children:[$t(Be?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(Q,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"})}):n.jsx(Q,{name:o.space?"box-3":"git-branch",className:De("h-3 w-3 shrink-0",le?"oc-ref-tint":"text-muted-foreground"),style:le?Jn(le):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/85",children:fo(o.label,m)}),Ut,Ss,At,G?n.jsx("button",{type:"button",className:De("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",le&&"oc-ref-tint",Fe),style:le?Jn(le):void 0,disabled:!G.url,"aria-label":K,onPointerDown:je=>je.stopPropagation(),onKeyDown:je=>je.stopPropagation(),onClick:je=>{je.stopPropagation(),G.url&&s(G.url,o.directory??null,je)},children:Ie}):be?n.jsxs("button",{type:"button",className:De("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",be.color?"oc-ref-tint":"text-muted-foreground",Fe),style:be.color?Jn(be.color):void 0,"aria-label":We.map(je=>je.text).join(", "),onPointerDown:je=>je.stopPropagation(),onKeyDown:je=>je.stopPropagation(),onClick:je=>{je.stopPropagation(),!(je.target instanceof Element&&je.target.closest("[data-ref-more]"))&&s(be.url,o.directory??null,je)},children:[n.jsx(Q,{name:be.icon,className:"h-3 w-3"}),be.label,We.length>1?n.jsxs("span",{"data-ref-more":!0,className:"text-muted-foreground",children:["+",We.length-1]}):null]}):null]}):n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[yt,n.jsx("span",{className:"min-w-0 truncate",children:fo(o.label,m)}),At]})}),mt&&jt?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[o.isArchivedBucket?n.jsx(Q,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):n.jsx(Q,{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:jt.label})]}):null]}),!o.isArchivedBucket&&o.directory?n.jsx($o,{directory:o.directory,className:De("self-center",Fe)}):null]})})}),Et.length>0?n.jsx(Ft,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(zo,{items:Et,directory:o.directory??null})}):!G&&be?n.jsx(Ft,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(zo,{items:We,directory:o.directory??null})}):null]}),n.jsxs(oi,{delayDuration:400,children:[o.isArchivedBucket&&ut.length>0?n.jsx("div",{className:De("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",j?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:je=>{je.stopPropagation(),En.requestDelete({sessions:ut,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(Q,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,o.directory&&!o.isMain&&o.worktree&&!Be?n.jsx("div",{className:De("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",j?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsx(h5,{label:o.label,sessions:ut,worktree:o.worktree})}):null,o.space?n.jsx("div",{className:De("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",j?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:je=>{je.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(Q,{name:"key",className:"h-3.5 w-3.5"})})}),n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,o.space?n.jsx("div",{className:De("absolute inset-e-[3.25rem] top-1/2 -translate-y-1/2 z-10 transition-opacity",j?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100 has-[[data-popup-open]]:opacity-100"),children:n.jsx(gb,{spaceId:o.space.id,label:o.label})}):null,o.directory?n.jsx("div",{className:De("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",j?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:je=>{je.stopPropagation(),a&&a!==k&&T(a),w&&O(!1),$({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(Q,{name:"add",className:"h-4 w-4"})})}),n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]})]}),o.space?n.jsx(bb,{spaceId:o.space.id,className:"pb-1 ps-5"}):null,!ce&&u?n.jsx("div",{className:De("oc-group-body",Pt),children:qe}):null]}),Rt]})}const g5=l.memo(m5,p5),Zi=({projectId:t,mobileVariant:e,closeMobileSwitcher:s,setActiveProjectIdOnly:r,setSessionSwitcherOpen:i})=>{t&&r(t),e&&s&&i(!1)},b5=(t,e)=>{const s=new Set;for(const r of t)if(!r.isArchivedBucket)for(const i of r.sessions){const{session:o}=i;o.time?.archived||e(o)||s.add(o.id)}return[...s]},qd=10,Yd=(t,e)=>Mf(t.label?.trim()||Jo(t.normalizedPath,e)||t.normalizedPath);function y5(t){const e=Xe.c(103),{model:s,view:r,actions:i}=t;Cs("ui.sidebar_projects_list.render");const{t:o}=Ct(),c=Fr(),{files:a}=Ws(),d=es(T5),u=es(I5),f=es(E5),p=es(P5),m=de(C5),g=de(j5)&&!In(),[y,v]=l.useState(null),[x,b]=l.useState(null),[h,S]=l.useState(null),[w,j]=l.useState(null),[k,T]=l.useState(null),O=k?.kind==="project",$=l.useRef(null);let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D={activationConstraint:{distance:8}},e[0]=D):D=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 R;e[2]===Symbol.for("react.memo_cache_sentinel")?(R={coordinateGetter:Jf},e[2]=R):R=e[2];const z=Lr(zs($r,D),zs(_r,E),zs(Zf,R));let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=B=>{$.current=B,j(B)},e[3]=_):_=e[3];const W=_;let N;if(e[4]!==s.projectSections||e[5]!==r.homeDirectory){let B;e[7]!==r.homeDirectory?(B=ae=>({id:ae.project.id,projectLabel:Yd(ae.project,r.homeDirectory),projectDescription:ir(ae.project.normalizedPath,r.homeDirectory),projectIcon:ae.project.icon,projectColor:ae.project.color,projectIconImage:ae.project.iconImage,projectIconBackground:ae.project.iconBackground}),e[7]=r.homeDirectory,e[8]=B):B=e[8],N=s.projectSections.map(B),e[4]=s.projectSections,e[5]=r.homeDirectory,e[6]=N}else N=e[6];const Y=N,C=tS(),{confirm:P}=C;let I;e[9]!==P||e[10]!==o?(I=async(B,ae)=>{const xe=Nf.getState().ids,Te=b5(ae,Ke=>ri(xe,Ke.directory,Ke.id)||Vu(Ke.id)||hl(Ke));if(Te.length===0){ze.info(o("sessions.sidebar.project.archiveAll.nothing"));return}if(!await P({title:o("sessions.sidebar.project.archiveAll.title",{project:B}),message:Te.length===1?o("sessions.sidebar.project.archiveAll.descriptionSingle",{count:Te.length}):o("sessions.sidebar.project.archiveAll.descriptionPlural",{count:Te.length}),action:o("sessions.sidebar.bulkActions.archive")}))return;const{archivedIds:st,failedIds:rt}=await xt.getState().archiveSessions(Te);st.length>0&&ze.success(st.length===1?o("sessions.sidebar.bulkActions.archivedSingle",{count:st.length}):o("sessions.sidebar.bulkActions.archivedPlural",{count:st.length})),rt.length>0&&ze.error(rt.length===1?o("sessions.sidebar.bulkActions.failedArchiveSingle",{count:rt.length}):o("sessions.sidebar.bulkActions.failedArchivePlural",{count:rt.length}))},e[9]=P,e[10]=o,e[11]=I):I=e[11];const H=I;let A;e[12]!==a||e[13]!==o?(A=B=>{a.revealPath&&a.revealPath(B).catch(()=>{ze.error(o("sidebarFilesTree.toast.revealFailed"))})},e[12]=a,e[13]=o,e[14]=A):A=e[14];const F=A;let L;e[15]!==x?(L=B=>`${B.kind}:${B.id}`===x,e[15]=x,e[16]=L):L=e[16];const X=s.rowModel.stickyHeaders.findIndex(L);let re;if(e[17]!==h||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]!==X){if(re=new Set,h){let B;e[25]!==h||e[26]!==s.rowModel.rowIndexByKey?(B=s.rowModel.rowIndexByKey.get(h),e[25]=h,e[26]=s.rowModel.rowIndexByKey,e[27]=B):B=e[27];const ae=B;ae!==void 0&&re.add(ae)}for(let B=0;B<s.rowModel.rows.length;B=B+1,B){const ae=s.rowModel.rows[B];ae?.kind==="session"&&(s.groupProps.editingRowKey===ae.key||s.state.openSidebarMenuKey===`session-menu:${ae.key}`||s.state.openSidebarMenuKey===`session-context:${ae.key}`)&&re.add(B)}if(X>=0){const B=Math.max(0,X-1),ae=Math.min(s.rowModel.stickyHeaders.length-1,X+1);for(let xe=B;xe<=ae;xe=xe+1,xe){const Te=s.rowModel.stickyHeaders[xe];Te&&re.add(Te.rowIndex)}}e[17]=h,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]=X,e[24]=re}else re=e[24];const te=re;let M;e[28]!==s.rowModel.stickyHeaders?(M=B=>{const ae=sC(s.rowModel.stickyHeaders,B),xe=ae?`${ae.kind}:${ae.id}`:null;b(Te=>Te===xe?Te:xe)},e[28]=s.rowModel.stickyHeaders,e[29]=M):M=e[29];const ee=M;let V;e[30]!==c||e[31]!==o?(V=B=>{const ae=()=>{if(!B.status.directory){Kf();return}c.requestBootstrap({directory:B.status.directory,priority:"expanded",reason:B.group.isMain?"project-expanded":"worktree-expanded",force:!0})},xe=async()=>{if(!B.status.directory)return;(await ku(B.status.directory)).success&&ae()};let Te;e:switch(B.status.state){case"permission-denied":{Te=o("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Te=o("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Te=o("sessions.sidebar.group.empty.initializationFailed");break e}default:Te=o("sessions.sidebar.group.empty.loadingSessions")}return n.jsx("div",{className:"relative py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:B.flat?qd:Md(B.depth??0)},children:n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[B.status.state==="loading"?n.jsx(Q,{name:"loader-4",className:"size-3 animate-spin"}):null,Te,B.status.canGrantAccess?n.jsx(It,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{xe()},children:o("sessions.sidebar.group.empty.grantAccess")}):null,B.status.state!=="loading"?n.jsx(It,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:ae,children:o("sessions.sidebar.group.empty.retry")}):null]})})},e[30]=c,e[31]=o,e[32]=V):V=e[32];const Ee=V;let ve;e[33]!==i||e[34]!==f||e[35]!==a||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]!==F||e[43]!==Y||e[44]!==u||e[45]!==Ee||e[46]!==H||e[47]!==m||e[48]!==g||e[49]!==o||e[50]!==d||e[51]!==r?(ve=B=>{if(B.kind==="activity-header")return n.jsx(Eh,{className:"sticky top-0 z-20 bg-sidebar","data-sidebar-sticky-header":"true",children:n.jsx(Q4,{activityKey:B.activityKey,collapsed:B.collapsed,forceExpanded:B.forceExpanded,alwaysShowActions:r.alwaysShowActions,onToggle:()=>{if(!B.collapsed){const xe=`activity:${B.activityKey}`;i.group.resetGroupSessionLimit(xe),s.state.setVisibleActivityCountByKey(Te=>{if(!Te.has(xe))return Te;const Ge=new Map(Te);return Ge.delete(xe),Ge})}s.state.setCollapsedActivityKeys(xe=>{const Te=new Set(xe);return Te.has(B.activityKey)?Te.delete(B.activityKey):Te.add(B.activityKey),Te})},onNewChat:()=>{de.getState().closeMainSurfaces(),r.mobileVariant&&i.setSessionSwitcherOpen(!1),i.openNewSessionDraft({selectedProjectId:ng,directoryOverride:null})}})});if(B.kind==="project-header"){const xe=B.section.project,Te=Yd(xe,r.homeDirectory);return n.jsx(n5,{id:xe.id,disabled:s.singleProjectMode||B.forceExpanded||s.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:Te,projectDescription:ir(xe.normalizedPath,r.homeDirectory),projectDirectory:xe.normalizedPath,projectIcon:xe.icon,projectColor:xe.color,projectIconImage:xe.iconImage,projectIconBackground:xe.iconBackground,isCollapsed:B.collapsed,isRepo:!!s.projectRepoStatus.get(xe.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:B.collapsed?i.renderProjectStatusIndicator?.(xe.id,B.section.groups):null,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,projectPickerOptions:s.singleProjectMode?Y:void 0,onProjectSelect:s.singleProjectMode?i.setSingleProjectId:void 0,onToggle:()=>{!B.forceExpanded&&!s.singleProjectMode&&i.toggleProject(xe.id)},onNewSession:()=>{Zi({projectId:xe.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:xe.id,directoryOverride:xe.normalizedPath})},onNewWorktreeSession:()=>{Zi({projectId:xe.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewWorktreeDialog()},onManageWorktrees:()=>i.openWorktreesPage(xe.id),onManageSpaces:g?()=>de.getState().setSpacesPageProjectId(xe.id):void 0,onOpenFolder:xe.normalizedPath&&a.revealPath?()=>F(xe.normalizedPath):void 0,onRenameStart:()=>i.openProjectEditDialog(xe.id),onArchiveAll:()=>{H(Te,B.section.groups)},onClose:()=>i.removeProject(xe.id),showCreateButtons:!0})}if(B.kind==="group-header")return n.jsx(o5,{id:B.groupKey,disabled:B.forceExpanded||s.state.editingId!==null||r.worktreeSortOrder!=="manual",children:xe=>n.jsx(g5,{...s.groupProps,...i.group,group:B.group,groupKey:B.groupKey,projectId:B.projectId,isEmpty:B.empty,visibleSessionCount:s.state.visibleSessionCountByGroup.get(B.groupKey),editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,dragHandleProps:xe,renderBody:!1})});if(B.kind==="folder-header"){const xe=s.groupProps.folderRename?.folderId===B.folder.id&&s.groupProps.folderRename.scopeKey===B.scopeKey;return n.jsx(mh,{folderId:B.folder.id,scopeKey:B.scopeKey,ownerKey:B.ownerKey,disabled:!B.dropEnabled,children:(Te,Ge)=>n.jsx(_3,{notifyOnSubtasks:s.groupProps.notifyOnSubtasks,activityNodes:B.activityNodes,folder:B.folder,displayName:B.displayName,sessions:B.nodes,depth:B.depth,canExpand:!B.empty,isCollapsed:B.collapsed,onToggle:B.forceExpanded?k5:()=>d(B.folder.id),onRename:st=>u(B.scopeKey,B.folder.id,st),onDelete:()=>{B.archived?En.requestDelete({sessions:[...B.deleteSessions],mode:"session"}):m?v({scopeKey:B.scopeKey,folderId:B.folder.id,folderName:B.folder.name,subFolderCount:B.subFolderCount,sessionCount:B.nodes.length}):f(B.scopeKey,B.folder.id)},renderBody:!1,groupDirectory:B.scopeDirectory??B.group.directory,projectId:B.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:xe,renameDraft:xe?s.groupProps.folderRename?.draft:void 0,onRenameDraftChange:s.groupProps.setFolderRenameDraft,onRenameSave:()=>{const st=s.groupProps.folderRename?.draft.trim();st&&u(B.scopeKey,B.folder.id,st),s.groupProps.clearFolderRename()},onRenameCancel:s.groupProps.clearFolderRename,droppableRef:Te,isDropTarget:Ge,onNewSession:()=>{Zi({projectId:B.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:B.projectId,directoryOverride:B.scopeDirectory??B.group.directory,targetFolderId:B.folder.id,target:B.group.draftTarget})},archivedBucket:B.archived})})}if(B.kind==="session"){const xe=new Set;return lr(B.node,s.state.editingId)&&xe.add(B.node.session.id),n.jsx("div",{onFocusCapture:()=>S(B.key),onBlurCapture:()=>S(Te=>Te===B.key?null:Te),children:n.jsx(Wo,{...s.groupProps,node:B.node,depth:B.depth,groupDirectory:B.groupDirectory,projectId:B.projectId,folderOwnerKey:B.ownerKey,selectionScopeKey:B.selectionScopeKey,archivedBucket:B.archived,renderContext:B.renderContext,rowKey:B.key,dragKey:B.key,secondaryMeta:B.secondaryMeta,renderChildren:!1,editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:xe,menuOpenSessionId:s.state.openSidebarMenuKey===`session-menu:${B.key}`||s.state.openSidebarMenuKey===`session-context:${B.key}`?B.node.session.id:null,nodeStructureKey:B.blockingBadgeSessionScopes?`${Mr(B.node)}:${JSON.stringify(B.blockingBadgeSessionScopes)}`:Mr(B.node),blockingBadgeSessionScopes:B.blockingBadgeSessionScopes}})})}if(B.kind==="run")return n.jsx(_4,{run:B.run,depth:B.depth,laneNodes:B.laneNodes,blockingSessionIds:B.blockingSessionIds,renderContext:B.renderContext,projectId:B.projectId,projectLabel:B.projectLabel,expansionKey:B.expansionKey,expanded:B.expanded,forceExpanded:B.forceExpanded,notifyOnSubtasks:s.groupProps.notifyOnSubtasks,toggleParent:s.groupProps.toggleParent});const ae=B.kind==="show-control"&&B.flat===!0?qd:Md(B.kind==="show-control"||B.kind==="empty"?B.depth??0:0);return B.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:ae},onClick:()=>{B.containerKey.startsWith("activity:")?s.state.setVisibleActivityCountByKey(xe=>{const Te=new Map(xe);return B.control==="more"?Te.set(B.containerKey,B.currentCount+B.increment):Te.delete(B.containerKey),Te}):B.control==="more"?i.group.showMoreGroupSessions(B.containerKey,B.currentCount,B.increment):i.group.resetGroupSessionLimit(B.containerKey)},children:o(B.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")})}):B.kind==="status"?Ee(B):B.emptyKind==="sidebar"?s.emptyState:B.emptyKind==="search"?s.searchEmptyState:n.jsx("div",{className:"py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:ae},children:o("sessions.sidebar.group.empty.noArchivedSessions")})},e[33]=i,e[34]=f,e[35]=a,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]=F,e[43]=Y,e[44]=u,e[45]=Ee,e[46]=H,e[47]=m,e[48]=g,e[49]=o,e[50]=d,e[51]=r,e[52]=ve):ve=e[52];const ce=ve;let Be;if(e[53]!==k||e[54]!==s.rowModel.rows){let B;e[56]!==k?(B=ae=>ae.kind==="project-header"?k?.kind==="group"?[]:[ae.section.project.id]:ae.kind!=="group-header"?[]:k?.kind==="project"?[]:k?.kind==="group"&&ae.projectId!==k.projectId?[]:[ae.groupKey],e[56]=k,e[57]=B):B=e[57],Be=s.rowModel.rows.flatMap(B),e[53]=k,e[54]=s.rowModel.rows,e[55]=Be}else Be=e[55];const me=Be;let he;e[58]!==s.sectionsForRender?(he=new Set(s.sectionsForRender.map(w5)),e[58]=s.sectionsForRender,e[59]=he):he=e[59];const G=he;let le;e[60]!==s.rowModel.stickyHeaders?(le=s.rowModel.stickyHeaders.map(v5).join(""),e[60]=s.rowModel.stickyHeaders,e[61]=le):le=e[61];const ye=le;let Ie;e[62]!==s.rowModel.rows||e[63]!==G?(Ie=B=>{const ae=String(B.active.id);if(G.has(ae)){T({kind:"project"});return}const xe=s.rowModel.rows.find(Te=>Te.kind==="group-header"&&Te.groupKey===ae);T(xe?{kind:"group",projectId:xe.projectId}:null)},e[62]=s.rowModel.rows,e[63]=G,e[64]=Ie):Ie=e[64];let K;e[65]===Symbol.for("react.memo_cache_sentinel")?(K=()=>T(null),e[65]=K):K=e[65];let se;e[66]!==i||e[67]!==p||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?(se=B=>{if(T(null),!B.over)return;const ae=B.active.data.current,xe=B.over.data.current;if(ae?.type==="session"&&ae.sessionId&&ae.ownerKey&&ae.archivedBucket!==!0&&xe?.type==="folder"&&xe.folderId&&xe.scopeKey&&xe.ownerKey===ae.ownerKey){const wt=s.rowModel.folderDropTargets.find(ot=>ot.folderId===xe.folderId&&ot.scopeKey===xe.scopeKey&&ot.ownerKey===ae.ownerKey),Me=s.rowModel.folderAuthorityByOwner.get(ae.ownerKey);if(!wt?.enabled||Me?.complete!==!0)return;const Pe=es.getState();for(const ot of Me.scopeKeys)ot!==xe.scopeKey&&Pe.removeSessionFromFolder(ot,ae.sessionId);p(xe.scopeKey,xe.folderId,ae.sessionId);return}if(r.hasSessionSearchQuery||s.state.editingId!==null||B.active.id===B.over.id)return;const Te=String(B.active.id),Ge=String(B.over.id),st=s.sectionsForRender.map(S5),rt=st.indexOf(Te),Ke=st.indexOf(Ge);if(rt>=0&&Ke>=0&&r.projectSortOrder==="manual"){i.reorderProjects(rt,Ke);return}const ke=s.rowModel.rows.find(wt=>wt.kind==="group-header"&&wt.groupKey===Te),ge=s.rowModel.rows.find(wt=>wt.kind==="group-header"&&wt.groupKey===Ge);if(!ke||!ge||ke.projectId!==ge.projectId||!ke.projectId)return;const Ve=ke.projectId,Ue=s.sectionsForRender.find(wt=>wt.project.id===Ve);if(!Ue)return;const ft=Ue.groups.findIndex(wt=>wt.id===ke.group.id),Qe=Ue.groups.findIndex(wt=>wt.id===ge.group.id);ft<0||Qe<0||i.setGroupOrderByProject(wt=>new Map(wt).set(Ve,ml(Ue.groups,ft,Qe).map(x5)))},e[66]=i,e[67]=p,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]=se):se=e[74];let U;e[75]!==ee||e[76]!==s.rowModel||e[77]!==te||e[78]!==ce||e[79]!==w?(U=n.jsx(q4,{model:s.rowModel,scrollElement:w,pinnedRowIndexes:te,renderRow:ce,onFirstVisibleIndexChange:ee}),e[75]=ee,e[76]=s.rowModel,e[77]=te,e[78]=ce,e[79]=w,e[80]=U):U=e[80];let ie;e[81]!==me||e[82]!==U?(ie=n.jsx(ii,{items:me,strategy:gl,children:U}),e[81]=me,e[82]=U,e[83]=ie):ie=e[83];let we;e[84]!==z||e[85]!==Ie||e[86]!==se||e[87]!==ie?(we=n.jsx(Or,{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(zr,{sensors:z,collisionDetection:Kr,onDragStart:Ie,onDragCancel:K,onDragEnd:se,children:ie})}),e[84]=z,e[85]=Ie,e[86]=se,e[87]=ie,e[88]=we):we=e[88];let pe;e[89]!==O||e[90]!==we||e[91]!==ye?(pe=n.jsx(Z4,{suspended:O,layoutKey:ye,scrollRef:$,children:we}),e[89]=O,e[90]=we,e[91]=ye,e[92]=pe):pe=e[92];let Se;e[93]!==f||e[94]!==y?(Se=()=>{y&&(f(y.scopeKey,y.folderId),v(null))},e[93]=f,e[94]=y,e[95]=Se):Se=e[95];let Ce;e[96]!==y||e[97]!==Se?(Ce=n.jsx(Ch,{value:y,setValue:v,onConfirm:Se}),e[96]=y,e[97]=Se,e[98]=Ce):Ce=e[98];let Oe;return e[99]!==C.dialog||e[100]!==pe||e[101]!==Ce?(Oe=n.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[pe,Ce,C.dialog]}),e[99]=C.dialog,e[100]=pe,e[101]=Ce,e[102]=Oe):Oe=e[102],Oe}function x5(t){return t.id}function S5(t){return t.project.id}function v5(t){const{kind:e,id:s,rowIndex:r}=t;return`${e}:${s}:${r}`}function w5(t){return t.project.id}function k5(){}function j5(t){return t.isolatedSpacesEnabled}function C5(t){return t.showDeletionDialog}function P5(t){return t.addSessionToFolder}function E5(t){return t.deleteFolder}function I5(t){return t.renameFolder}function T5(t){return t.toggleFolderCollapse}const D5=l.memo(y5),$a=new Map,Xd=(t,e)=>{for(const s of t){const r=vt(s??null);r&&!$a.has(r)&&$a.set(r,e)}},Qd=t=>{const e=vt(t??null);return e?$a.get(e)??0:0},br=t=>!!t.time?.archived,R5=(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},N5=t=>{const{t:e}=Ct(),s=l.useRef(t.gitBranches);s.current=t.gitBranches;const r=l.useRef(t.sessionOrderRanks);r.current=t.sessionOrderRanks;const i=l.useRef(t.sessionOwners),o=l.useMemo(()=>(R5(i.current,t.sessionOwners)||(i.current=t.sessionOwners),i.current),[t.sessionOwners]),c=l.useCallback(f=>[f.label,f.branch??"",f.description??"",f.directory??""].join(" ").toLowerCase(),[]),a=l.useCallback(f=>{const p=vt(f.directory??null)??"";return`${(f.title||e("sessions.sidebar.session.untitled")).trim()} ${p}`.toLowerCase()},[e]),d=l.useCallback((f,p)=>{if(!p)return f;const m=p.trim().toLowerCase(),g=m.startsWith("ses_");return f.flatMap(y=>{if(g&&br(y.session))return[];if(g?y.session.id.toLowerCase()===m:Do([a(y.session)],p))return[y];const x=d(y.children,p);return x.length===0?[]:[{...y,children:x}]})},[a]),u=l.useCallback((f,p,m,g,y)=>{const v=vt(p??null),x=Df(f),b=new Map(x.map(F=>[F.id,F])),h=new Map;x.forEach(F=>{const L=F.parentID;if(!L)return;const X=b.get(L);if(!X||br(X)||br(F))return;const re=h.get(L)??[];re.push(F),h.set(L,re)});const S=sS(m,v),w=(v&&!t.isVSCode?t.spacesByProject?.get(v):void 0)??[],j=new Map;for(const F of w){const L=vt(F.directory);L&&j.set(L,F)}const k=F=>{const L=vt(F.directory??null),X=t.worktreeMetadata.get(F.id)??null;if(X)return X;if(L){const re=S.get(L)??null;if(re&&L!==v)return re}return null},T=new Set,O=F=>{T.add(F.id);const L=h.get(F.id)??[],X=[];for(const re of L)T.has(re.id)||X.push(O(re));return{session:F,children:X,worktree:k(F)}},$=F=>{const L=F.parentID;if(!L)return!1;if(br(F))return!0;const X=b.get(L);return!!(X&&br(X))},D=x.filter(F=>{const L=F.parentID;return L?!b.has(L)&&!$(F):!0}),E=[],R=F=>{T.has(F.id)||E.push(O(F))};D.forEach(R),x.forEach(F=>{$(F)||R(F)});const z=new Map,_="__archived__",W=F=>{if(F.time?.archived)return _;if(t.isVSCode||t.runKeyBySessionId?.has(F.id))return v??"__project_root__";const L=o?.get(F.id)?.scopeDirectory;if(L){if(L===v)return v??"__project_root__";if(S.has(L)||j.has(L))return L}const re=vt(t.worktreeMetadata.get(F.id)?.path??null)??or(F);return re&&re!==v&&S.has(re)?re:v??"__project_root__"};E.forEach(F=>{const L=W(F.session);z.has(L)||z.set(L,[]),z.get(L)?.push(F)});const N=v??"__project_root__",Y=[{id:"root",label:y&&g&&g!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:g}):e("sessions.sidebar.grouping.projectRoot"),branch:g??null,description:v?ir(v,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:v,folderScopeKey:v,sessions:z.get(N)??[]}],C=new Map;m.forEach(F=>{const L=vt(F.path)??F.path,X=z.get(L)??[],re=X.length>0,te=X.reduce((M,ee)=>{const V=nS(ee.session,r.current);return Number.isFinite(V)?Math.max(M,V):M},0);C.set(L,{hasActiveSession:re,lastUpdatedAt:te})});const P=(F,L)=>{const X=(F.label||F.branch||F.name||F.path||"").toLowerCase(),re=(L.label||L.branch||L.name||L.path||"").toLowerCase();return X.localeCompare(re)},I=t.worktreeSortOrder!=="recent"?[...m].sort(P):[...m].sort((F,L)=>{const X=vt(F.path)??F.path,re=vt(L.path)??L.path,te=C.get(X)??{hasActiveSession:!1,lastUpdatedAt:0},M=C.get(re)??{hasActiveSession:!1,lastUpdatedAt:0};if(te.hasActiveSession!==M.hasActiveSession)return te.hasActiveSession?-1:1;if(te.hasActiveSession&&M.hasActiveSession)return M.lastUpdatedAt-te.lastUpdatedAt;const ee=Qd(F.path),V=Qd(L.path);return ee!==V?V-ee:P(F,L)});(t.isVSCode?[]:I).forEach(F=>{const L=vt(F.path)??F.path,X=s.current.get(L)?.trim()||null,re=F.branch?.trim()||null,te=rS(F,X,Jo(L,t.homeDirectory)||L);Y.push({id:`worktree:${L}`,label:te,branch:X||re,description:ir(L,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:F,directory:L,folderScopeKey:L,sessions:z.get(L)??[]})});for(const[F,L]of j)Y.push({id:`space:${L.id}`,label:L.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:L,directory:F,folderScopeKey:F,sessions:z.get(F)??[]});const A=z.get(_)??[];return A.length>0&&Y.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?Tf(v):null,sessions:A}),Y},[t.homeDirectory,t.worktreeMetadata,t.isVSCode,t.worktreeSortOrder,o,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:c,buildSessionSearchText:a,filterSessionNodesForSearch:d,buildGroupedSessions:u}},M5=t=>{const e=Xe.c(60),{selectedCount:s,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:c,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:f,onArchive:p,onDelete:m,onDone:g}=t,{t:y}=Ct(),v=s>0,x=v&&!!r&&!o;let b;e[0]!==s||e[1]!==y?(b=y("sessions.sidebar.bulkActions.selectedCount",{count:s}),e[0]=s,e[1]=y,e[2]=b):b=e[2];let h;e[3]!==b?(h=n.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:b}),e[3]=b,e[4]=h):h=e[4];let S;e[5]!==x||e[6]!==u||e[7]!==a||e[8]!==c||e[9]!==d||e[10]!==i||e[11]!==y?(S=x?n.jsxs(Ts,{children:[n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx(Ds,{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":y("sessions.sidebar.bulkActions.moveToFolder"),children:n.jsx(Q,{name:"folder",className:"h-4 w-4"})})})}),n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:y("sessions.sidebar.bulkActions.moveToFolder")})})]}),n.jsxs(Rs,{align:"end",className:"min-w-[180px]",children:[i.length===0?n.jsx(Zt,{disabled:!0,className:"text-muted-foreground",children:y("sessions.sidebar.folders.none")}):i.map(A=>n.jsx(Zt,{onClick:()=>c(A.id),children:n.jsx("span",{className:"flex-1 truncate",children:A.name})},A.id)),n.jsx(jn,{}),n.jsxs(Zt,{onClick:a,children:[n.jsx(Q,{name:"add",className:"me-1 h-4 w-4"}),y("sessions.sidebar.folders.newFolderEllipsis")]}),u?n.jsxs(Zt,{onClick:d,className:"text-destructive focus:text-destructive",children:[n.jsx(Q,{name:"close",className:"me-1 h-4 w-4"}),y("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=x,e[6]=u,e[7]=a,e[8]=c,e[9]=d,e[10]=i,e[11]=y,e[12]=S):S=e[12];let w;e[13]!==o||e[14]!==v||e[15]!==f||e[16]!==y?(w=o?n.jsxs(Kt,{children:[n.jsx(zt,{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":y("sessions.sidebar.bulkActions.restore"),children:n.jsx(Q,{name:"inbox-unarchive",className:"h-4 w-4"})})}),n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:y("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=o,e[14]=v,e[15]=f,e[16]=y,e[17]=w):w=e[17];let j;e[18]!==o||e[19]!==v||e[20]!==p||e[21]!==y?(j=o?null:n.jsxs(Kt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:p,disabled:!v,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":y("sessions.sidebar.bulkActions.archive"),children:n.jsx(Q,{name:"archive",className:"h-4 w-4"})})}),n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:y("sessions.sidebar.bulkActions.archive")})})]}),e[18]=o,e[19]=v,e[20]=p,e[21]=y,e[22]=j):j=e[22];const k=!v;let T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=De("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50 disabled:pointer-events-none disabled:opacity-40"),e[23]=T):T=e[23];let O;e[24]!==y?(O=y("sessions.sidebar.bulkActions.delete"),e[24]=y,e[25]=O):O=e[25];let $;e[26]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(Q,{name:"delete-bin",className:"h-4 w-4"}),e[26]=$):$=e[26];let D;e[27]!==m||e[28]!==k||e[29]!==O?(D=n.jsx(zt,{asChild:!0,children:n.jsx("button",{type:"button",onClick:m,disabled:k,className:T,"aria-label":O,children:$})}),e[27]=m,e[28]=k,e[29]=O,e[30]=D):D=e[30];let E;e[31]!==y?(E=y("sessions.sidebar.bulkActions.delete"),e[31]=y,e[32]=E):E=e[32];let R;e[33]!==E?(R=n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:E})}),e[33]=E,e[34]=R):R=e[34];let z;e[35]!==D||e[36]!==R?(z=n.jsxs(Kt,{children:[D,R]}),e[35]=D,e[36]=R,e[37]=z):z=e[37];let _;e[38]!==y?(_=y("sessions.sidebar.header.actions.exitSelection"),e[38]=y,e[39]=_):_=e[39];let W;e[40]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(Q,{name:"close",className:"h-4 w-4"}),e[40]=W):W=e[40];let N;e[41]!==g||e[42]!==_?(N=n.jsx(zt,{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":_,children:W})}),e[41]=g,e[42]=_,e[43]=N):N=e[43];let Y;e[44]!==y?(Y=y("sessions.sidebar.header.actions.exitSelection"),e[44]=y,e[45]=Y):Y=e[45];let C;e[46]!==Y?(C=n.jsx(Ft,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Y})}),e[46]=Y,e[47]=C):C=e[47];let P;e[48]!==N||e[49]!==C?(P=n.jsxs(Kt,{children:[N,C]}),e[48]=N,e[49]=C,e[50]=P):P=e[50];let I;e[51]!==z||e[52]!==P||e[53]!==S||e[54]!==w||e[55]!==j?(I=n.jsxs("div",{className:"ms-auto flex items-center gap-0.5",children:[S,w,j,z,P]}),e[51]=z,e[52]=P,e[53]=S,e[54]=w,e[55]=j,e[56]=I):I=e[56];let H;return e[57]!==h||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:[h,I]}),e[57]=h,e[58]=I,e[59]=H):H=e[59],H},Zd=new Map,A5=(t,e)=>{if(!t)return[];const s=e(t);return s.length>0?s.map(r=>r.scopeKey):[t]},O5=(t,e)=>{const s=t.sessionIds.filter(o=>e.has(o));if(s.length===0)return{ready:!1,value:null};const r=t.archivedBucket||yh(new Set(s),e),i={sessionIds:s,sessionCount:s.length,archivedBucket:r};return{ready:s.length===t.sessionIds.length&&r===t.archivedBucket,value:i}},B5=t=>{const e=Xe.c(89),{t:s}=Ct();let r;e[0]!==s?(r=pe=>{const Se=oS(pe);return Se?{description:Bu(Se,s)}:void 0},e[0]=s,e[1]=r):r=e[1];const i=r,{isInlineEditing:o,showDeletionDialog:c,foldersMap:a,getFolderScopesForProject:d,addSessionsToFolder:u,removeSessionsFromFolders:f,createFolderAndStartRename:p,archiveSessions:m,unarchiveSessions:g,deleteSessions:y,bulkDeleteConfirm:v,setBulkDeleteConfirm:x}=t,b=us(F5),h=us(L5),S=h>0,w=us(_5),j=us($5),k=bh(),T=z5,O=K5;let $;e[2]!==S||e[3]!==k||e[4]!==w?($=S&&yh(w,k?.getSessionsById()??Zd),e[2]=S,e[3]=k,e[4]=w,e[5]=$):$=e[5];const D=$;let E;e:{if(j){E=j;break e}E=null}const R=E;let z;e[6]!==R||e[7]!==d?(z=A5(R,d),e[6]=R,e[7]=d,e[8]=z):z=e[8];const _=z;let W;if(e[9]!==a||e[10]!==_){let pe;e[12]!==a?(pe=Se=>a[Se]??[],e[12]=a,e[13]=pe):pe=e[13],W=_.flatMap(pe),e[9]=a,e[10]=_,e[11]=W}else W=e[11];const N=W;let Y;e[14]!==a||e[15]!==_?(Y=pe=>{for(const Se of _)if((a[Se]??[]).some(Ce=>Ce.id===pe))return Se;return null},e[14]=a,e[15]=_,e[16]=Y):Y=e[16];const C=Y;let P;e:{if(!S){P=!1;break e}for(const pe of _)for(const Se of a[pe]??[])for(const Ce of Se.sessionIds)if(w.has(Ce)){P=!0;break e}P=!1}const I=P;let H;e[17]!==u||e[18]!==f||e[19]!==w||e[20]!==_?(H=(pe,Se)=>{const Ce=Array.from(w);for(const Oe of _)Oe!==pe&&f(Oe,Ce);u(pe,Se,Ce)},e[17]=u,e[18]=f,e[19]=w,e[20]=_,e[21]=H):H=e[21];const A=H;let F;e[22]!==S||e[23]!==A||e[24]!==C?(F=pe=>{if(!S)return;const Se=C(pe);Se&&A(Se,pe)},e[22]=S,e[23]=A,e[24]=C,e[25]=F):F=e[25];const L=F;let X;e[26]!==p||e[27]!==S||e[28]!==A||e[29]!==_?(X=()=>{const pe=_[0];if(!pe||!S)return;const Se=p(pe);Se&&A(pe,Se.id)},e[26]=p,e[27]=S,e[28]=A,e[29]=_,e[30]=X):X=e[30];const re=X;let te;e[31]!==S||e[32]!==f||e[33]!==w||e[34]!==_?(te=()=>{if(!S)return;const pe=Array.from(w);for(const Se of _)f(Se,pe)},e[31]=S,e[32]=f,e[33]=w,e[34]=_,e[35]=te):te=e[35];const M=te;let ee;e[36]!==m||e[37]!==y||e[38]!==i||e[39]!==s?(ee=async(pe,Se)=>{if(pe.length!==0)if(Se){const{deletedIds:Ce,failedIds:Oe}=await y(pe);Ce.length>0&&ze.success(Ce.length===1?s("sessions.sidebar.bulkActions.deletedSingle",{count:Ce.length}):s("sessions.sidebar.bulkActions.deletedPlural",{count:Ce.length})),Oe.length>0&&ze.error(Oe.length===1?s("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Oe.length}):s("sessions.sidebar.bulkActions.failedDeletePlural",{count:Oe.length}),i(Oe)),us.getState().removeMany(Ce)}else{const{archivedIds:Ce,failedIds:Oe}=await m(pe);Ce.length>0&&ze.success(Ce.length===1?s("sessions.sidebar.bulkActions.archivedSingle",{count:Ce.length}):s("sessions.sidebar.bulkActions.archivedPlural",{count:Ce.length})),Oe.length>0&&ze.error(Oe.length===1?s("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Oe.length}):s("sessions.sidebar.bulkActions.failedArchivePlural",{count:Oe.length}),i(Oe)),us.getState().removeMany(Ce)}},e[36]=m,e[37]=y,e[38]=i,e[39]=s,e[40]=ee):ee=e[40];const V=ee;let Ee;e[41]!==V||e[42]!==S||e[43]!==w||e[44]!==x||e[45]!==c?(Ee=pe=>{if(!S)return;const Se=Array.from(w);if(!c){V(Se,pe);return}x({sessionIds:Se,sessionCount:Se.length,archivedBucket:pe})},e[41]=V,e[42]=S,e[43]=w,e[44]=x,e[45]=c,e[46]=Ee):Ee=e[46];const ve=Ee;let ce;e[47]!==D||e[48]!==ve?(ce=()=>ve(D),e[47]=D,e[48]=ve,e[49]=ce):ce=e[49];const Be=ce;let me;e[50]!==ve?(me=()=>ve(!1),e[50]=ve,e[51]=me):me=e[51];const he=me;let G;e[52]!==ve?(G=()=>ve(!0),e[52]=ve,e[53]=G):G=e[53];const le=G;let ye;e[54]!==D||e[55]!==i||e[56]!==S||e[57]!==w||e[58]!==s||e[59]!==g?(ye=async()=>{if(!S||!D)return;const pe=Array.from(w),{restoredIds:Se,failedIds:Ce}=await g(pe);Se.length>0&&ze.success(Se.length===1?s("sessions.sidebar.bulkActions.restoredSingle",{count:Se.length}):s("sessions.sidebar.bulkActions.restoredPlural",{count:Se.length})),Ce.length>0&&ze.error(Ce.length===1?s("sessions.sidebar.bulkActions.failedRestoreSingle",{count:Ce.length}):s("sessions.sidebar.bulkActions.failedRestorePlural",{count:Ce.length}),i(Ce)),us.getState().removeMany(Se)},e[54]=D,e[55]=i,e[56]=S,e[57]=w,e[58]=s,e[59]=g,e[60]=ye):ye=e[60];const Ie=ye;let K;e[61]!==v||e[62]!==V||e[63]!==k||e[64]!==x?(K=async()=>{if(!v)return;const pe=k?.getSessionsById()??Zd,Se=O5(v,pe);if(!Se.ready){x(Se.value);return}x(null),await V(Se.value.sessionIds,Se.value.archivedBucket)},e[61]=v,e[62]=V,e[63]=k,e[64]=x,e[65]=K):K=e[65];const se=K;let U,ie;e[66]!==v||e[67]!==Be||e[68]!==o||e[69]!==k||e[70]!==b?(U=()=>{if(!b)return;const pe=/Macintosh|Mac OS X/.test(navigator.userAgent||""),Se=Ce=>{if(v||o)return;const Oe=Ce.target instanceof HTMLElement?Ce.target:null;if(Oe&&(Oe.tagName==="INPUT"||Oe.tagName==="TEXTAREA"||Oe.isContentEditable))return;const B=pe?Ce.metaKey:Ce.ctrlKey;if(Ce.key==="Escape"){Ce.preventDefault(),us.getState().disable();return}if(B&&Ce.key==="Backspace"){Ce.preventDefault(),Be();return}if(B&&(Ce.key==="a"||Ce.key==="A")){const ae=W3(k?.getEntries()??[],k?.getDescendantIds()??[],us.getState().scopeKey);if(!ae)return;Ce.preventDefault(),us.getState().replaceAll(ae.ids,ae.scopeKey)}};return window.addEventListener("keydown",Se),()=>window.removeEventListener("keydown",Se)},ie=[v,Be,o,k,b],e[66]=v,e[67]=Be,e[68]=o,e[69]=k,e[70]=b,e[71]=U,e[72]=ie):(U=e[71],ie=e[72]),l.useEffect(U,ie);let we;return e[73]!==I||e[74]!==N||e[75]!==D||e[76]!==se||e[77]!==R||e[78]!==he||e[79]!==re||e[80]!==Be||e[81]!==le||e[82]!==L||e[83]!==M||e[84]!==Ie||e[85]!==S||e[86]!==h||e[87]!==b?(we={selectionModeEnabled:b,hasSelection:S,selectedIdsSize:h,bulkScopeIsArchived:D,derivedSelectionScope:R,bulkScopeFolders:N,bulkCanRemoveFromFolder:I,handleToggleSelectionMode:T,handleExitSelectionMode:O,handleBulkMoveToFolder:L,handleBulkCreateFolderAndMove:re,handleBulkRemoveFromFolder:M,handleBulkDelete:Be,handleBulkArchive:he,handleBulkHardDelete:le,handleBulkRestore:Ie,confirmBulkDelete:se},e[73]=I,e[74]=N,e[75]=D,e[76]=se,e[77]=R,e[78]=he,e[79]=re,e[80]=Be,e[81]=le,e[82]=L,e[83]=M,e[84]=Ie,e[85]=S,e[86]=h,e[87]=b,e[88]=we):we=e[88],we};function F5(t){return t.enabled}function L5(t){return t.selectedIds.size}function _5(t){return t.selectedIds}function $5(t){return t.scopeKey}function z5(){us.getState().toggleMode()}function K5(){us.getState().disable()}function W5(t){const e=Xe.c(37),{getFolderScopesForProject:s,isInlineEditing:r,startFolderRename:i}=t,[o,c]=l.useState(null),a=de(Z5),d=de(Q5),u=es(X5),f=es(Y5),p=es(q5),m=es(G5),g=xt(U5),y=xt(V5),v=xt(H5);let x;e[0]!==f||e[1]!==i?(x=k=>{const T=f(k,"New folder");return i(k,T),T},e[0]=f,e[1]=i,e[2]=x):x=e[2];let b;e[3]!==p||e[4]!==g||e[5]!==o||e[6]!==v||e[7]!==u||e[8]!==s||e[9]!==r||e[10]!==m||e[11]!==a||e[12]!==x||e[13]!==y?(b={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:s,addSessionsToFolder:p,removeSessionsFromFolders:m,createFolderAndStartRename:x,archiveSessions:g,unarchiveSessions:y,deleteSessions:v,bulkDeleteConfirm:o,setBulkDeleteConfirm:c},e[3]=p,e[4]=g,e[5]=o,e[6]=v,e[7]=u,e[8]=s,e[9]=r,e[10]=m,e[11]=a,e[12]=x,e[13]=y,e[14]=b):b=e[14];const h=B5(b);let S;e[15]!==h.bulkCanRemoveFromFolder||e[16]!==h.bulkScopeFolders||e[17]!==h.bulkScopeIsArchived||e[18]!==h.derivedSelectionScope||e[19]!==h.handleBulkArchive||e[20]!==h.handleBulkCreateFolderAndMove||e[21]!==h.handleBulkHardDelete||e[22]!==h.handleBulkMoveToFolder||e[23]!==h.handleBulkRemoveFromFolder||e[24]!==h.handleBulkRestore||e[25]!==h.handleExitSelectionMode||e[26]!==h.selectedIdsSize||e[27]!==h.selectionModeEnabled?(S=h.selectionModeEnabled?n.jsx(M5,{selectedCount:h.selectedIdsSize,scopeKey:h.derivedSelectionScope,scopeFolders:h.bulkScopeFolders,archivedBucket:h.bulkScopeIsArchived,onMoveToFolder:h.handleBulkMoveToFolder,onCreateFolderAndMove:h.handleBulkCreateFolderAndMove,onRemoveFromFolder:h.handleBulkRemoveFromFolder,canRemoveFromFolder:h.bulkCanRemoveFromFolder,onRestore:h.handleBulkRestore,onArchive:h.handleBulkArchive,onDelete:h.handleBulkHardDelete,onDone:h.handleExitSelectionMode}):null,e[15]=h.bulkCanRemoveFromFolder,e[16]=h.bulkScopeFolders,e[17]=h.bulkScopeIsArchived,e[18]=h.derivedSelectionScope,e[19]=h.handleBulkArchive,e[20]=h.handleBulkCreateFolderAndMove,e[21]=h.handleBulkHardDelete,e[22]=h.handleBulkMoveToFolder,e[23]=h.handleBulkRemoveFromFolder,e[24]=h.handleBulkRestore,e[25]=h.handleExitSelectionMode,e[26]=h.selectedIdsSize,e[27]=h.selectionModeEnabled,e[28]=S):S=e[28];let w;e[29]!==h.confirmBulkDelete||e[30]!==o||e[31]!==d||e[32]!==a?(w=n.jsx(E4,{value:o,setValue:c,showDeletionDialog:a,setShowDeletionDialog:d,onConfirm:h.confirmBulkDelete}),e[29]=h.confirmBulkDelete,e[30]=o,e[31]=d,e[32]=a,e[33]=w):w=e[33];let j;return e[34]!==S||e[35]!==w?(j=n.jsxs(n.Fragment,{children:[S,w]}),e[34]=S,e[35]=w,e[36]=j):j=e[36],j}function H5(t){return t.deleteSessions}function V5(t){return t.unarchiveSessions}function U5(t){return t.archiveSessions}function G5(t){return t.removeSessionsFromFolders}function q5(t){return t.addSessionsToFolder}function Y5(t){return t.createFolder}function X5(t){return t.foldersMap}function Q5(t){return t.setShowDeletionDialog}function Z5(t){return t.showDeletionDialog}const Ih="oc.sessions.expandedParents.v3",J5=ai(Ks()),eP=()=>{try{const t=globalThis.localStorage.getItem(Ih);if(t===null)return new Set;const e=J5.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},tP=()=>{const[t,e]=l.useState(eP),s=l.useRef(t);s.current=t;const r=l.useCallback(i=>{const o=iS(s.current,i);s.current=o,e(o);try{globalThis.localStorage.setItem(Ih,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},sP=t=>{const e=Xe.c(22),{childStores:s,sections:r,chatGroup:i,canGrantAccess:o}=t,c=Es(nP),a=Es(rP);let d;e[0]!==i||e[1]!==r?(d=[...r.flatMap(oP),...i?[{key:"activity:chats",group:i}]:[]].map(lP),e[0]=i,e[1]=r,e[2]=d):d=e[2];const u=d;let f;e[3]!==u?(f=new Set(u.flatMap(cP)),e[3]=u,e[4]=f):f=e[4];let p;e[5]!==f?(p=[...f],e[5]=f,e[6]=p):p=e[6];const m=p;let g;e[7]!==s||e[8]!==m.length?(g=S=>m.length>0?s.subscribeBootstrap(S):dP,e[7]=s,e[8]=m.length,e[9]=g):g=e[9];let y;e[10]!==s||e[11]!==m?(y=()=>m.map(S=>`${S}\0${s.getBootstrapState(S)??""}\0${s.getBootstrapFailure(S)??""}\0${s.getInitializationState(S)??""}\0${s.getInitializationFailure(S)??""}`).join(""),e[10]=s,e[11]=m,e[12]=y):y=e[12];const v=l.useSyncExternalStore(g,y,uP);let x;if(e[13]!==o||e[14]!==s||e[15]!==c||e[16]!==u||e[17]!==a){x=new Map;for(const{key:S,archived:w,directories:j}of u){const k=j.find(T=>s.getBootstrapState(T)==="failed"||s.getInitializationState(T)==="failed");if(k){const T=s.getBootstrapState(k)==="failed",O=T?s.getBootstrapFailure(k):s.getInitializationFailure(k);x.set(S,{state:O==="os-permission"?"permission-denied":T?"load-failed":"initialization-failed",directory:k,canGrantAccess:O==="os-permission"&&o})}else{const T=a||!w&&j.length>0&&j.every(O=>s.getBootstrapState(O)==="complete");x.set(S,{state:T?"ready":c==="error"?"load-failed":"loading",directory:T?j[0]??null:null,canGrantAccess:!1})}}e[13]=o,e[14]=s,e[15]=c,e[16]=u,e[17]=a,e[18]=x}else x=e[18];const b=x;let h;return e[19]!==v||e[20]!==b?(h={groupStatusByKey:b,bootstrapSnapshot:v},e[19]=v,e[20]=b,e[21]=h):h=e[21],h};function nP(t){return t.status}function rP(t){return t.hasLoaded}function oP(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function iP(t){return vt(t.directory)}function aP(t){return!!t}function lP(t){const{key:e,group:s}=t;return{key:e,archived:s.isArchivedBucket===!0,directories:_n(s).map(iP).filter(aP)}}function cP(t){return t.directories}function dP(){}function uP(){return""}const fP=6e4,pP=[],Jd=[],eu={pinned:[],work:[]},hP=t=>!t.parentID,mP=({topology:t,view:e,actions:s})=>{const{alwaysShowActions:r,notifyOnSubtasks:i,projectViewActions:o,rowActions:c,...a}=s,d=es(Re=>Re.foldersMap),u=es(Re=>Re.collapsedFolderIds),f=es(Re=>Re.createFolder),p=es(Re=>Re.addSessionToFolder),m=e.projectView,{getOrderedGroups:g,setGroupOrderByProject:y,toggleGroup:v,toggleProject:x,setCollapsedActivities:b}=o,h=yb({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),S=aS(Re=>Re.projects),w=rg(),j=l.useMemo(()=>new Map(w.map(Re=>[Re.id,Re.name])),[w]),k=l.useMemo(()=>{const Re=new Map;for(const ue of w){const Fe=vt(ue.projectDirectory);if(!Fe)continue;const yt=Re.get(Fe);yt?yt.push(ue):Re.set(Fe,[ue])}return Re},[w]),T=l.useMemo(()=>C1(h.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,h.archivedSessions,S,w),[S,h.archivedSessions,h.sessions,w,t.availableWorktreesByProject,t.isVSCode,t.projects]),[O,$]=l.useState(new Map),[D,E]=l.useState(new Map),R=l.useCallback((Re,ue,Fe=7)=>{$(yt=>new Map(yt).set(Re,ue+Fe))},[]),z=l.useCallback(Re=>{$(ue=>{if(!ue.has(Re))return ue;const Fe=new Map(ue);return Fe.delete(Re),Fe})},[]);l.useEffect(()=>{$(Re=>{if(Re.size===0)return Re;const ue=$t=>m.collapsedGroups.has($t)||[...m.collapsedProjects].some(Et=>$t===dh(Et)||$t.startsWith(`${Et}:`)),Fe=[...Re.keys()].filter(ue);if(Fe.length===0)return Re;const yt=new Map(Re);for(const $t of Fe)yt.delete($t);return yt})},[m.collapsedGroups,m.collapsedProjects]);const _=Jt(Re=>Re.showChatsSection),W=Jt(Re=>Re.projectDisplayMode),N=Jt(Re=>Re.singleProjectId),Y=Jt(Re=>Re.setSingleProjectId),P=!t.isVSCode&&!og()&&W==="single",I=e.sidebarViewMode==="timeline"&&!t.isVSCode,H=l.useMemo(()=>lS(h.rootSessions,Re=>vt(t.worktreeMetadata.get(Re.id)?.projectDirectory??Re.directory??null)),[h.rootSessions,t.worktreeMetadata]),A=l.useRef(null),F=l.useMemo(()=>{const Re=Array.from(H.runKeyBySessionId,([ue,Fe])=>`${ue}\0${Fe}`).sort().join("");return A.current?.signature!==Re&&(A.current={signature:Re,map:H.runKeyBySessionId}),A.current.map},[H]),[L,X]=l.useState(null),[re,te]=l.useState(null),[M,ee]=l.useState(""),[V,Ee]=l.useState(null),[ve,ce]=l.useState(null),[Be,me]=l.useState(null),he=l.useCallback((Re,ue)=>{me({scopeKey:Re,folderId:ue.id,draft:ue.name})},[]),G=l.useCallback(Re=>{me(ue=>ue?{...ue,draft:Re}:null)},[]),le=l.useCallback(()=>me(null),[]),{expandedParents:ye,toggleParent:Ie}=tP(),K=xt(Re=>Re.setCurrentSession),se=l.useCallback((Re,ue)=>{Re!==xt.getState().currentSessionId&&K(Re,ue)},[K]),U=_f(),ie=Jt(Re=>Re.worktreeSortOrder),{buildGroupedSessions:we,filterSessionNodesForSearch:pe,buildGroupSearchText:Se}=N5({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:h.pinnedSessionIds,sessionOrderRanks:h.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:ie,sessionOwners:T.bySessionId,spacesByProject:k,runKeyBySessionId:F}),{getSessionsForProject:Ce,getArchivedSessionsForProject:Oe}=h3({ownership:T}),B=cS(),ae=l.useMemo(()=>{if(t.isVSCode)return null;const Re=B??h.chatSessions.map(Fe=>Ua(Fe.directory)).find(Boolean)??null;if(!Re)return null;const ue=Array.from(new Set([Re,...h.chatSessions.map(Fe=>vt(Fe.directory??null)).filter(Boolean)])).filter(Fe=>!!Fe).map(Fe=>({scopeKey:Fe,directory:Fe}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Re,folderScopeKey:Re,folderScopes:ue,draftTarget:"chat",sessions:h.chatSessions.filter(Fe=>!Fe.time?.archived&&hP(Fe)).map(Fe=>pr(h.childrenMap,Fe))}},[h.chatSessions,h.childrenMap,B,t.isVSCode]),xe=l.useMemo(()=>ae?[ae]:pP,[ae]),{projectSections:Te,groupSearchDataByGroup:Ge,sectionsForRender:st,flatSectionsForRender:rt}=x3({normalizedProjects:t.projects,getSessionsForProject:Ce,getArchivedSessionsForProject:Oe,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,sessionOrderRanks:h.sessionOrderRanks,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:we,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:pe,buildGroupSearchText:Se,foldersMap:d,standaloneGroups:xe}),Ke=e.onSearchMatchCountChange;l.useEffect(()=>()=>Ke(0),[Ke]);const ke=Fr(),ge=e.useGroupedSections?st:rt,Ve=l.useMemo(()=>e.showInlineArchived?ge:ge.map(Re=>Re.groups.some(ue=>ue.isArchivedBucket)?{...Re,groups:Re.groups.filter(ue=>!ue.isArchivedBucket)}:Re),[ge,e.showInlineArchived]),Ue=l.useCallback(Re=>rt.find(Fe=>Fe.project.id===Re)?.groups.find(Fe=>!Fe.isArchivedBucket)?.folderScopes??[],[rt]);a3({enabled:!0,normalizedProjects:t.projects,ownership:T,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:h.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:d,createFolder:f,addSessionToFolder:p});const{sourceControl:ft}=Ws(),Qe=ds(Re=>Re.ensureEntry),wt=ds(Re=>Re.setParams),Me=ds(Re=>Re.refreshTargets),Pe=ds(Re=>Re.clearDirectoryStatus),ot=ds(Re=>Re.beginActiveContextsLoad),et=ds(Re=>Re.commitActiveContexts),Ze=ds(Re=>Re.releaseActiveContexts),dt=ds(Re=>Re.activeContextRegistrations),J=l.useId(),_e=l.useRef(new Set),Le=l.useMemo(()=>new Map(h.orderedSessions.map((Re,ue)=>[Re.id,ue])),[h.orderedSessions]),[He,$e]=l.useState(null),tt=l.useRef([]),bt=e.projectSortOrder==="recent";l.useEffect(()=>{bt||$e(null)},[bt]);const ht=l.useMemo(()=>{const Re=ie!=="manual"?Ve:Ve.map(Fe=>{const yt=g(Fe.project.id,Fe.groups);return yt===Fe.groups?Fe:{...Fe,groups:yt}}),ue=xb(Re,e.projectSortOrder,Fe=>Fe.project.id,T.sessionsByProject);return[...He&&bt?Sb(ue,He,Fe=>Fe.project.id):ue]},[g,He,bt,T.sessionsByProject,Ve,e.projectSortOrder,ie]);l.useEffect(()=>{tt.current=ht.map(Re=>Re.project.id)},[ht]);const it=l.useMemo(()=>{if(!I)return Jd;const Re=new Set(h.rootSessions.map(Et=>Et.id)),ue=h.orderedSessions.filter(Et=>Re.has(Et.id)&&!Et.time?.archived),Fe=new Map,yt=uc({sessions:ue,projects:t.projects,ownerBySessionId:T.bySessionId,spaceLabelById:j,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return vd({sessions:ue,getSessionLocation:Et=>yt.get(Et)??null,getSessionNode:Et=>{const ne=pr(h.childrenMap,Et),Ye=yt.get(Et.id);return Fe.set(Et.id,Aa(ne,!1,Ye?.groupDirectory??Et.directory??null)),{...ne,children:[],worktree:Ye?.worktree??null}},query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""}).map(Et=>({...Et,blockingBadgeSessionScopes:Fe.get(Et.node.session.id)}))},[h.childrenMap,h.orderedSessions,h.rootSessions,T.bySessionId,j,I,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),Mt=de(Re=>Re.sessionWorkEnabled),nt=Jt(Re=>Re.showWorkSection),Lt=Jt(Re=>Re.showPinnedSection),_t=Jt(Re=>Re.detailedZoneRows),Tt=l.useMemo(()=>{const Re=Mt&&nt;if(!Re&&!Lt)return eu;const ue=[],Fe=[];for(const yt of h.orderedSessions)yt.parentID||yt.time?.archived||Va(yt.directory)||(Lt&&ri(h.pinnedSessionIds,yt.directory,yt.id)?ue.push(yt):Re&&hl(yt)&&Fe.push(yt));return ue.length===0&&Fe.length===0?eu:{pinned:ue,work:Fe}},[h.orderedSessions,h.pinnedSessionIds,Mt,Lt,nt]),Ae=Tt.work,at=l.useMemo(()=>new Set([...Tt.pinned,...Tt.work].map(Re=>Re.id)),[Tt]),ut=l.useCallback(Re=>{if(Re.length===0)return Jd;const ue=uc({sessions:[...Re],projects:t.projects,ownerBySessionId:T.bySessionId,spaceLabelById:j,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1}),Fe=new Map,yt=new Map(Re.map(qe=>[qe.id,pr(h.childrenMap,qe)])),$t=new Map(Re.map(qe=>{const Pt=yt.get(qe.id)??pr(h.childrenMap,qe);Fe.set(qe.id,Aa(Pt,!1,ue.get(qe.id)?.groupDirectory??qe.directory??null));const Rt={...Pt,children:[],worktree:ue.get(qe.id)?.worktree??null};return[qe.id,Rt]})),Et=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",ne=Et?Re.filter(qe=>{const Pt=yt.get(qe.id);return Pt?ih(Pt,Et):!1}):[...Re];return vd({sessions:ne,getSessionLocation:qe=>ue.get(qe)??null,getSessionNode:qe=>$t.get(qe.id)??pr(h.childrenMap,qe),query:""}).map(qe=>{const Pt=yt.get(qe.node.session.id);return{...qe,blockingBadgeSessionScopes:Fe.get(qe.node.session.id),searchMatchCount:Et&&Pt?Dl(Pt,Et):void 0}})},[h.childrenMap,T.bySessionId,j,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),pt=l.useMemo(()=>ut(Tt.pinned),[ut,Tt.pinned]),lt=l.useMemo(()=>ut(Tt.work),[ut,Tt.work]),St=l.useMemo(()=>{const Re=new Map,ue=new Map,Fe=new Map,yt=new Map,$t=new Set,Et=(Ye,qe)=>{const Pt=qe?.trim();Ye&&Pt&&Re.set(fS(Ye,Pt),{directory:Ye,branch:Pt})},ne=Ye=>{if(Et(vt(Ye.worktree?.path??null),Ye.worktree?.branch),!t.isVSCode){for(const qe of Of(Ye.session))ue.set(`${qe.owner.toLowerCase()}/${qe.repo.toLowerCase()}#${qe.number}`,{owner:qe.owner,repo:qe.repo,number:qe.number});for(const qe of fl(Ye.session))qe.source==="github"?Fe.set(`${qe.owner.toLowerCase()}/${qe.repo.toLowerCase()}#${qe.number}`,{owner:qe.owner,repo:qe.repo,number:qe.number}):qe.source==="linear"&&$t.add(qe.identifier.toUpperCase());for(const qe of uS(Ye.session))yt.set(qe.key,qe)}Ye.children.forEach(ne)};return pt.forEach(Ye=>ne(Ye.node)),lt.forEach(Ye=>ne(Ye.node)),I?(it.forEach(Ye=>{(!Ye.projectId||!m.collapsedProjects.has(Ye.projectId))&&ne(Ye.node)}),{targets:Re,linkedRefs:[...ue.values()],linkedIssueRefs:[...Fe.values()],linearIdentifiers:[...$t],gitlabRefs:[...yt.values()]}):(Te.forEach(Ye=>{m.collapsedProjects.has(Ye.project.id)||Ye.groups.forEach(qe=>{if(qe.isArchivedBucket||(qe.sessions.forEach(ne),qe.isMain))return;const Pt=vt(qe.directory??null);Et(Pt,qe.branch?.trim()||t.gitBranches.get(Pt||""))})}),{targets:Re,linkedRefs:[...ue.values()],linkedIssueRefs:[...Fe.values()],linearIdentifiers:[...$t],gitlabRefs:[...yt.values()]})},[pt,Te,m.collapsedProjects,it,I,t.gitBranches,t.isVSCode,lt]),ct=St.targets,oe=l.useRef(null),q=l.useMemo(()=>{const Re=i3(ct.values()),ue=JSON.stringify(Re);return oe.current?.signature!==ue&&(oe.current={signature:ue,candidates:Re}),oe.current.candidates},[ct]);l.useEffect(()=>{const Re=q;if(Re.length===0)return;let ue=!1;const Fe=Xt(),yt=async(Rt,je=fP)=>{const Je=Date.now(),gt=new Map,kt=Vt=>{const ts=gt.get(Vt);if(ts)return ts;const ms=ot(Fe,Vt,J),mn=Dn.scope(Vt),As=kr(()=>Dn.read(mn,ft)).then(gn=>{if(ue||Fe!==Xt())return null;const as=gn.contexts[0],Os=as&&la(wn.getState().entries[qn(as)],as).connected?[as]:[];return et(Fe,Vt,J,ms,Os)?(Os.length===0&&Pe(Vt),Os):null});return gt.set(Vt,As),As},Dt=await Promise.all(Re.filter(Vt=>!Rt||Vt.directory===Rt).map(async Vt=>(await kt(Vt.directory)??[]).map(ms=>({...Vt,context:ms}))));if(ue||Fe!==Xt())return;const Gt=new Map,rs=new Map;for(const Vt of Dt.flat()){const ts=uf(Vt.context,Vt.branch);rs.set(ts,{context:Vt.context,branch:Vt.branch});const ms=ds.getState().entries[ts],mn=ms?.status?.changeRequest??ms?.status?.pr,As=mn?.state,as=!!mn&&!(As==="closed"||As==="merged"),Os=Math.max(ms?.lastRefreshAt??0,ms?.lastDiscoveryPollAt??0),vs=!!(ms?.isInitialStatusResolved&&!as&&(!_e.current.has(ts)||Je-Os>=je));(!ms||!ms.isInitialStatusResolved||vs)&&(vs&&_e.current.add(ts),Gt.has(ts)||Gt.set(ts,{context:Vt.context,branch:Vt.branch}))}rs.forEach((Vt,ts)=>{Qe(ts),wt(ts,{directory:Vt.context.directory,branch:Vt.branch,remoteName:Vt.context.primaryRemote,canShow:!0,identity:Vt.context,readContext:Vt.context,sourceControl:ft,authChecked:!0,connected:!0})}),Gt.size!==0&&await Me([...Gt.values()],{silent:!0,markInitialResolved:!0})},$t=[...new Set(Re.map(Rt=>Rt.directory))].map(Rt=>Dn.scope(Rt)),Et=$t.map(Rt=>{let je=Dn.snapshot(Rt);return Dn.subscribe(Rt,()=>{const Je=Dn.snapshot(Rt),gt=je.read!==null&&je!==Je;je=Je,gt&&!ue&&yt(Rt.directory)})}),ne=wn.subscribe((Rt,je)=>{if(!(ue||Fe!==Xt()||Rt.entries===je.entries))for(const Je of $t){const gt=Dn.snapshot(Je).contexts[0];if(!gt)continue;const kt=qn(gt);Rt.entries[kt]!==je.entries[kt]&&yt(Je.directory)}});yt();const Ye=new Set(Re.map(Rt=>Rt.directory)),qe=Pn(Rt=>{!ue&&Rt.type==="source-control-activity"&&Ye.has(Rt.directory)&&yt(Rt.directory,0)}),Pt=()=>{!ue&&document.visibilityState==="visible"&&yt()};return document.addEventListener("visibilitychange",Pt),()=>{ue=!0,ne(),Et.forEach(Rt=>Rt()),qe(),document.removeEventListener("visibilitychange",Pt);for(const Rt of Re)Ze(Fe,Rt.directory,J)}},[ot,Pe,et,q,Qe,Me,Ze,wt,ft,J]);const fe=l.useMemo(()=>dS(dt,ct.values()),[dt,ct]),We=pf(fe),be=l.useMemo(()=>[...We,...St.linkedRefs.map(Re=>Ir("pull",Re)),...St.linkedIssueRefs.map(Re=>Ir("issue",Re)),...St.gitlabRefs.map(Re=>Re.thread==="pull"?Tr("pull",Re):Tr("issue",Re)),...St.linearIdentifiers.map(pl)],[We,St]);ff(be);const{groupStatusByKey:Ne,bootstrapSnapshot:mt}=sP({childStores:ke,sections:ht,chatGroup:ae,canGrantAccess:wu()});let jt=null;P&&(Te.some(Re=>Re.project.id===N)?jt=N:Te.some(Re=>Re.project.id===e.activeProjectId)?jt=e.activeProjectId:jt=Te[0]?.project.id??null);const At=l.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:Ge,collapsedGroups:m.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:i,pinnedSessionIds:h.pinnedSessionIds,sessionOrderIndex:Le,expandedParents:ye,editingId:L,editingRowKey:re,editTitle:M,sessionBatchSize:P&&!e.useGroupedSections?20:void 0,setEditingId:X,setEditingRowKey:te,setEditTitle:ee,toggleParent:Ie,allowReselect:c.allowReselect,onSessionSelected:c.onSessionSelected,resetSessionSearch:c.resetSessionSearch,deleteSessionConfirm:ve,setDeleteSessionConfirm:ce,startFolderRename:he,startSessionWorktreeMenuLoad:s.startSessionWorktreeMenuLoad,folderRename:Be,setFolderRenameDraft:G,clearFolderRename:le}),[h.pinnedSessionIds,r,i,m.collapsedGroups,Ge,Le,M,L,re,ye,Be,G,le,he,ve,s.startSessionWorktreeMenuLoad,c,Ie,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,P]),Ot=l.useMemo(()=>({showMoreGroupSessions:R,resetGroupSessionLimit:z,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,onToggleCollapsedGroup:v}),[z,R,v,a.openNewSessionDraft,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen]),Wt=l.useMemo(()=>{const Re=new Map;for(const ue of ht)for(const Fe of ue.groups){const yt=sr(ue.project.id,Fe.directory);if(!yt)continue;const $t=_n(Fe),Et=Re.get(yt),ne=[...new Set([...Et?.scopeKeys??[],...$t.map(qe=>qe.scopeKey)])],Ye=h.hasAuthoritativeGlobalSessions&&$t.every(qe=>{const Pt=vt(qe.directory);return!Pt||ke.getBootstrapState(Pt)==="complete"});Re.set(yt,{scopeKeys:ne,complete:(Et?.complete??!0)&&Ye})}if(ae){const ue=sr(null,ae.directory);ue&&Re.set(ue,{scopeKeys:_n(ae).map(Fe=>Fe.scopeKey),complete:h.hasAuthoritativeGlobalSessions})}return Re},[mt,ae,ke,h.hasAuthoritativeGlobalSessions,ht]),Qt=l.useMemo(()=>new Map([...O,...D]),[D,O]),Ut=l.useMemo(()=>nC({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:I?"timeline":"projects",sections:ht,authoritativeSections:Te,chatGroup:_?ae:null,timelineItems:it,pinnedItems:pt,workItems:lt,zoneSessionIds:at,detailedZoneRows:_t,foldersMap:d,groupSearchDataByGroup:Ge,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:m.collapsedProjects,collapsedGroups:m.collapsedGroups,collapsedFolders:u,collapsedActivities:m.collapsedActivities,expandedParents:ye,visibleCountByContainer:Qt,pinnedSessionIds:h.pinnedSessionIds,sessionOrderIndex:Le,groupStatusByKey:Ne,folderAuthorityByOwner:Wt,activeProjectId:e.activeProjectId,singleProjectMode:P&&!I,singleProjectId:jt,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:P&&!e.useGroupedSections?20:void 0,runIndex:H}),[H,ae,_,m.collapsedActivities,it,I,pt,lt,at,_t,u,h.pinnedSessionIds,ye,Wt,d,Ge,Ne,ht,Te,m.collapsedGroups,m.collapsedProjects,jt,Le,P,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,Qt]);l.useEffect(()=>{Ke(Ut.searchMatchCount)},[Ke,Ut.searchMatchCount]),l.useEffect(()=>{if(e.hasSessionSearchQuery)return;const Re=es.getState().toggleFolderCollapse;for(const ue of Ut.rows)ue.kind==="group-header"&&ue.empty&&m.collapsedGroups.has(ue.groupKey)?v(ue.groupKey):ue.kind==="folder-header"&&ue.empty&&u.has(ue.folder.id)&&Re(ue.folder.id)},[u,m.collapsedGroups,Ut.rows,v,e.hasSessionSearchQuery]);const Ss=l.useMemo(()=>({rowModel:Ut,sectionsForRender:ht,projectSections:Te,singleProjectMode:P,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:L,openSidebarMenuKey:V,setOpenSidebarMenuKey:Ee,visibleSessionCountByGroup:O,collapsedActivityKeys:m.collapsedActivities,setCollapsedActivityKeys:b,visibleActivityCountByKey:D,setVisibleActivityCountByKey:E},groupProps:At}),[At,L,V,Te,ht,Ut,t.projectRepoStatus,e.emptyState,e.searchEmptyState,O,D,m.collapsedActivities,b,P]),bs=l.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:ie}),[ie,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder]),ys=l.useMemo(()=>({group:Ot,toggleProject:x,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,openNewWorktreeDialog:a.openNewWorktreeDialog,openWorktreesPage:a.openWorktreesPage,openProjectEditDialog:a.openProjectEditDialog,removeProject:a.removeProject,reorderProjects:a.reorderProjects,setGroupOrderByProject:y,renderProjectStatusIndicator:a.renderProjectStatusIndicator,setSingleProjectId:Y}),[Ot,a.openNewSessionDraft,a.openNewWorktreeDialog,a.openProjectEditDialog,a.openWorktreesPage,a.removeProject,a.reorderProjects,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen,y,x,a.renderProjectStatusIndicator,Y]);return n.jsxs(n.Fragment,{children:[n.jsx(t3,{}),n.jsx(u3,{projectSections:Te,activeProjectId:e.activeProjectId,initialActiveSessionByProject:s.initialActiveSessionByProject,persistActiveSessionByProject:s.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:s.openNewSessionDraft,setSessionSwitcherOpen:s.setSessionSwitcherOpen,sessionOwnerBySessionId:T.bySessionId,handleSessionSelect:se}),n.jsx(C3,{sortedSessions:h.orderedSessions,workSessions:Ae,prefetchSession:U,children:n.jsxs(K3,{entries:Ut.selectionEntries,descendantIds:Ut.selectionDescendantIds,sessionsById:Ut.sessionById,children:[n.jsx(W5,{getFolderScopesForProject:Ue,isInlineEditing:L!==null,startFolderRename:he}),n.jsx("div",{className:"contents",onPointerEnter:Re=>{bt&&Re.pointerType==="mouse"&&$e(tt.current)},onPointerLeave:()=>$e(null),children:n.jsx(D5,{model:Ss,view:bs,actions:ys})})]})})]})},gP=t=>{const e=Xe.c(3),[s,r]=l.useState(t.view.isVisible);t.view.isVisible&&!s&&r(!0);let i;return e[0]!==t||e[1]!==s?(i=s?n.jsx(mP,{...t}):null,e[0]=t,e[1]=s,e[2]=i):i=e[2],i},Th=(t,e,s)=>{const r=new Set;for(const i of t){const o=vt(i.path);o&&r.add(o)}if(s?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const c=vt(o.path);c&&r.add(c)}return r},tu="oc.sessions.activeSessionByProject",bP=Dr(Ks(),Ks().min(1).catch("")),yP=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:s,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{sa("react.session_sidebar_render"),Cs("ui.session_sidebar.render"),Cs(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Cs(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:c}=Ct(),[a,d]=l.useState(!1),[u,f]=l.useState(""),p=l.useCallback(()=>d(!0),[]),m=l.useCallback(()=>{f(""),d(!1)},[]),[g,y]=l.useState(0),v=l.useRef(null),x=l.useRef(null),[b,h]=l.useState(null),S=l.useMemo(()=>Eo(),[]),[w,j]=l.useState(new Map),k=de(Ae=>Ae.isNewWorktreeDialogOpen),T=de(Ae=>Ae.setNewWorktreeDialogOpen),[O,$]=l.useState(!1),D=l.useMemo(()=>{try{const Ae=S.getItem(tu);if(!Ae)return new Map;const at=bP.safeParse(JSON.parse(Ae));if(!at.success)return new Map;const ut=new Map;return Object.entries(at.data).forEach(([pt,lt])=>{lt&&ut.set(pt,lt)}),ut}catch{return new Map}},[S]),E=l.useCallback(Ae=>{try{S.setItem(tu,JSON.stringify(Object.fromEntries(Ae.entries())))}catch{}},[S]),[R,z]=l.useState(new Map),_=xs(Ae=>Ae.homeDirectory),W=ns(Ae=>Ae.projects),N=ns(Ae=>Ae.activeProjectId),Y=ns(Ae=>Ae.removeProject),C=ns(Ae=>Ae.setActiveProjectIdOnly),P=ns(Ae=>Ae.updateProjectMeta),I=ns(Ae=>Ae.reorderProjects),H=de(Ae=>Ae.setSettingsDialogOpen),A=de(Ae=>Ae.toggleHelpDialog),F=de(Ae=>Ae.setAboutDialogOpen),L=de(Ae=>Ae.setSessionSwitcherOpen),X=de(Ae=>Ae.setWorktreesPageProjectId),re=de(Ae=>Ae.notifyOnSubtasks),te=l.useMemo(()=>u.trim().toLowerCase(),[u]),M=te.length>0;z2({enabled:t,isSessionSearchOpen:a,openSessionSearch:p,closeSessionSearch:m,sessionSearchInputRef:x,sessionSearchContainerRef:v});const ee=pS(t),V=l.useMemo(()=>In(),[]),Ee=xt(Ae=>Ae.worktreeMetadata),ve=xt(Ae=>Ae.availableWorktreesByProject),ce=xt(Ae=>Ae.openNewSessionDraft),Be=l.useMemo(()=>Th(W,ve,{includeWorktrees:!V}),[ve,V,W]),me=l.useCallback(Ae=>{de.getState().closeMainSurfaces(),ce(Ae),V&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[V,ce]),he=wr(ar(Ae=>({checkForUpdates:Ae.checkForUpdates,available:Ae.available,runtimeType:Ae.runtimeType,info:Ae.info,downloading:Ae.downloading,downloaded:Ae.downloaded,installing:Ae.installing,progress:Ae.progress,error:Ae.error,downloadUpdate:Ae.downloadUpdate,restartToUpdate:Ae.restartToUpdate}))),G=Xt(),le=l.useMemo(()=>`${G}|${W.map(Ae=>`${Ae.id}:${vt(Ae.path)??""}`).join("|")}`,[W,G]),[ye,Ie]=l.useState(V?le:null),[K,se]=l.useReducer(Ae=>Ae+1,0),U=!V&&ye!==le,[ie,we]=l.useState(new Set),pe=l.useRef(ie);pe.current=ie;const Se=is(Ae=>Ae.isConnected),Ce=l.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});l.useEffect(()=>{let Ae=!1;return(async()=>{const ut=G,pt=is.getState().isConnected,lt=ns.getState().projects;if(xt.setState({worktreeDiscoveryByProject:new Map(lt.map(Ne=>[vt(Ne.path)??Ne.path,"loading"]))}),lt.length===0||V){Ae||(Ce.current={runtimeKey:null,revision:0,worktreesByProject:new Map},we(new Set),Ie(le));return}const St=xt.getState().availableWorktreesByProject,ct=Rl({rawWorktreesByProjectRef:Ce,publishedWorktreesByProject:St,runtimeKey:ut}),oe=ct.revision,q=new Map(ct.worktreesByProject),fe=new Set;if(await kr(()=>Promise.all(lt.map(async Ne=>{const mt=vt(Ne.path);if(mt)try{if(!(kn.getState().directories.get(mt)?.isGitRepo??await Uu(mt))){q.delete(mt);return}const Ot=await Cc({id:Ne.id,path:mt});if(Ae)return;Ot.length===0?q.delete(mt):q.set(mt,Ot)}catch{fe.add(mt)}}))),Ae||Xt()!==ut)return;const We=new Set(lt.map(Ne=>vt(Ne.path)).filter(Boolean));for(const Ne of q.keys())We.has(Ne)||q.delete(Ne);l4({rawWorktreesByProjectRef:Ce,runtimeKey:ut,capturedRevision:oe,nextRawWorktreesByProject:q,publishedWorktreesByProject:St,partitionWorktreesByRegisteredProject:jc,projects:lt,worktreeMapsEqual:kc,recordWorktreesSeen:Xd,publishTopology:Ne=>{xt.setState(Ne)},requestRediscovery:()=>{se()},now:()=>Date.now()})&&(we(fe),xt.setState({worktreeDiscoveryByProject:new Map(lt.map(Ne=>{const mt=vt(Ne.path)??Ne.path;return[mt,fe.has(mt)?"error":"ready"]}))}),Ie(le),fe.size>0&&!pt&&is.getState().isConnected&&se())})(),()=>{Ae=!0}},[V,le,G,K]),l.useEffect(()=>{Se&&pe.current.size>0&&se()},[Se]);const Oe=l.useMemo(()=>un(),[]),{isTablet:B}=Tn(),ae=e||B,xe=l.useMemo(()=>n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[n.jsx("p",{className:"typography-ui-label font-semibold",children:c("sessions.sidebar.empty.noSessions.title")}),n.jsx("p",{className:"typography-meta mt-1",children:c("sessions.sidebar.empty.noSessions.description")})]}),[c]),Te=l.useMemo(()=>W.find(Ae=>Ae.id===b)??null,[W,b]),Ge=l.useCallback(Ae=>{b&&P(b,{label:Ae.label,icon:Ae.icon,color:Ae.color,iconBackground:Ae.iconBackground,defaultAgent:Ae.defaultAgent??null,defaultModel:Ae.defaultModel??null,defaultVariant:Ae.defaultVariant??null})},[b,P]),st=l.useCallback(()=>{T(!0)},[T]),rt=l.useCallback(()=>{const Ae=wr.getState();if(Ae.available&&Ae.info){$(!0);return}he.checkForUpdates().then(()=>{const{available:at,error:ut}=wr.getState();if(ut){ze.error(c("sessions.sidebar.updateCheck.errorTitle"),{description:ut});return}if(!at){ze.success(c("sessions.sidebar.updateCheck.latestVersion"));return}$(!0)})},[c,he]),Ke=l.useCallback(()=>{e&&L(!1),H(!0)},[e,L,H]),ke=he.available&&(he.runtimeType==="desktop"||he.runtimeType==="web"),ge=l.useCallback(()=>{En.requestDirectoryDialog()},[]),Ve=l.useMemo(()=>W.flatMap(Ae=>{const at=vt(Ae.path);return at?[{id:Ae.id,path:Ae.path,label:Ae.label,normalizedPath:at,icon:Ae.icon??void 0,color:Ae.color??void 0,iconImage:Ae.iconImage??void 0,iconBackground:Ae.iconBackground??void 0,addedAt:Ae.addedAt,lastOpenedAt:Ae.lastOpenedAt,sidebarCollapsed:Ae.sidebarCollapsed}]:[]}),[W]),Ue=l.useMemo(()=>Ve.map(Ae=>Ae.normalizedPath),[Ve]),ft=hS(Ue,t);uC({enabled:t,normalizedProjects:Ve,gitRepoStatus:ft,setProjectRepoStatus:j,setProjectRootBranches:z});const Qe=xt(Ae=>Ae.isLoading),wt=l.useRef(!1);N&&w.has(N)&&(wt.current=!!w.get(N));const Me=Jt(Ae=>Ae.showArchivedSessions),Pe=Jt(Ae=>Ae.projectSortOrder),ot=Jt(Ae=>Ae.sidebarViewMode),et=V?"projects":ot,Ze=et==="timeline"?"manual":Pe,dt=ns(Ae=>Ae.manualProjectOrder),J={isVisible:t,mobileVariant:e,onSessionSelected:s,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:c,isTablet:B,projects:W,activeProjectId:N,manualProjectOrder:dt,worktreeMetadata:Ee,availableWorktreesByProject:ve,gitBranches:ee,gitRepoStatus:ft,updateStore:he,showArchivedSessions:Me,projectSortOrder:Ze,projectRepoStatus:w,projectRootBranches:R,resolvedWorktreeTopologyKey:ye,unresolvedWorktreeProjectPaths:ie,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:b,updateDialogOpen:O},_e=l.useRef(null),Le=_e.current;if(Le){let Ae=!1;for(const at of Object.keys(J))Object.is(Le[at],J[at])||(Cs(`ui.session_sidebar.source.${at}`),Ae=!0);Ae||Cs("ui.session_sidebar.source.parent_or_context")}_e.current=J;const He=l.useMemo(()=>vb(Ve,Ze,dt),[Ve,Ze,dt]),$e=oC({isVSCode:V,projects:He}),tt=l.useMemo(()=>n.jsx(JC,{query:u,showArchive:!V,resetSessionSearch:m}),[V,m,u]),bt=V&&Me,ht=!V,nt=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",Lt="h-4 w-4",_t=l.useMemo(()=>({projects:W,getCurrentProjects:()=>ns.getState().projects,rawWorktreesByProjectRef:Ce,getPublishedWorktreesByProject:()=>xt.getState().availableWorktreesByProject,resolveProject:Ae=>ia(Ae),listProjectWorktrees:Cc,partitionWorktreesByRegisteredProject:jc,worktreeMapsEqual:kc,recordWorktreesSeen:Xd,publishTopology:Ae=>{xt.setState(Ae)},getRuntimeKey:Xt,now:()=>Date.now()}),[W]),Tt=l.useCallback(Ae=>{const at=jh(Ae,{projects:W,resolveProject:ia});return a4(Ae,{..._t,projectRootBranch:at?R.get(at.id)??null:null})},[R,W,_t]);return l.useEffect(()=>{if(V)return;const Ae=at=>{for(const ut of at){const pt=vt(ut.path),lt=Xt(),St=ct=>{!pt||Xt()!==lt||xt.setState(oe=>({worktreeDiscoveryByProject:new Map(oe.worktreeDiscoveryByProject).set(pt,ct)}))};St("loading"),wh(ut,null,_t).then(()=>{!pt||Xt()!==lt||(St("ready"),we(ct=>{if(!ct.has(pt))return ct;const oe=new Set(ct);return oe.delete(pt),oe}))}).catch(()=>{!pt||Xt()!==lt||(St("error"),we(ct=>new Set(ct).add(pt)))})}};return Pn(at=>{if(at.type==="session-created"){const ut=mS(at.directory,ns.getState().projects);if(!ut){se();return}Ae([ut]);return}at.type==="worktree-changed"&&Ae(gS(at.directories))})},[V,_t]),n.jsx(oi,{delay:400,closeDelay:0,timeout:300,children:n.jsxs("div",{ref:v,className:De("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[n.jsx(vC,{hideDirectoryControls:i,showProjectDisplayControls:!V,showSectionControls:!V,handleOpenDirectoryDialog:ge,showSourceBoard:!e&&!V,headerActionIconClass:Lt,headerActionButtonClass:nt,isSessionSearchOpen:a,openSessionSearch:p,closeSessionSearch:m,sessionSearchInputRef:x,sessionSearchQuery:u,setSessionSearchQuery:f,hasSessionSearchQuery:M,searchMatchCount:g,collapseAll:$e.actions.collapseAll,expandAll:$e.actions.expandAll}),n.jsx(gP,{topology:{projects:He,availableWorktreesByProject:ve,knownDirectories:Be,isVSCode:V,worktreeMetadata:Ee,gitBranches:ee,projectRepoStatus:w,projectRootBranches:R,lastRepoStatus:wt.current},view:{isVisible:t,hasSessionSearchQuery:M,normalizedSessionSearchQuery:te,activeProjectId:N,showInlineArchived:bt,useGroupedSections:ht,homeDirectory:_,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:Oe,projectSortOrder:Ze,sidebarViewMode:et,emptyState:xe,searchEmptyState:tt,isSessionsLoading:Qe,isWorktreeTopologyLoading:U,unresolvedWorktreeProjectPaths:ie,projectView:$e.state,onSearchMatchCountChange:y},actions:{rowActions:{allowReselect:r,onSessionSelected:s,resetSessionSearch:m},alwaysShowActions:ae,notifyOnSubtasks:re,setActiveProjectIdOnly:C,setSessionSwitcherOpen:L,openNewSessionDraft:me,openNewWorktreeDialog:st,openWorktreesPage:Ae=>{e&&L(!1),X(Ae)},openProjectEditDialog:h,removeProject:Y,reorderProjects:I,startSessionWorktreeMenuLoad:Tt,initialActiveSessionByProject:D,persistActiveSessionByProject:E,projectViewActions:$e.actions}}),n.jsx(QC,{onOpenSettings:Ke,onOpenShortcuts:A,onOpenAbout:()=>F(!0),onOpenUpdate:rt,showRuntimeButtons:!V,showUpdateButton:ke}),n.jsx(Ya,{open:O,onOpenChange:$,info:he.info,downloading:he.downloading,downloaded:he.downloaded,installing:he.installing,progress:he.progress,error:he.error,onDownload:he.downloadUpdate,onRestart:he.restartToUpdate,runtimeType:he.runtimeType}),n.jsx(yC,{open:!!Te,onOpenChange:Ae=>{Ae||h(null)},project:Te,onSave:Ge}),n.jsx(bS,{open:k,onOpenChange:T,onWorktreeCreated:Ae=>{de.getState().closeMainSurfaces(),e&&L(!1),ce({directoryOverride:Ae,preserveDirectoryOverride:!0})}})]})})},xP=l.memo(yP),rn=t=>t?n.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,_s=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},SP=()=>{const{t}=Ct(),{git:e,sourceControl:s}=Ws(),[r,i]=l.useState(!1),[o,c]=l.useState(null),[a,d]=l.useState([]),[u,f]=l.useState(!1),[p,m]=l.useState(!1),[g,y]=l.useState(!1),[v,x]=l.useState(!1),[b,h]=l.useState(new Set),S=xt(U=>U.getWorktreeMetadata),w=xt(U=>U.newSessionDraft),j=xt(U=>U.setNewSessionDraftTarget),k=xt(U=>U.setDraftBootstrapPendingDirectory),T=yS,O=SS,$=xt(U=>U.deleteSessions),D=xt(U=>U.archiveSessions),E=de(U=>U.showDeletionDialog),R=de(U=>U.setShowDeletionDialog),z=xs(U=>U.currentDirectory),_=xs(U=>U.homeDirectory),W=ns(U=>U.projects),N=ns(U=>U.activeProjectId),{isMobile:Y,isTablet:C,hasTouchInput:P}=Tn(),I=Y||C||P,H=l.useMemo(()=>{const ie=(N?W.find(we=>we.id===N)??null:null)?.path??z;return _s(ie)},[N,z,W]),A=l.useCallback(U=>{const we=_s(U.projectDirectory)||H;return{id:(W.find(Se=>_s(Se.path)===we)??null)?.id??`path:${we}`,path:we}},[H,W]),F=v&&b.size>0,L=l.useMemo(()=>{const U=o?.worktree;return U&&typeof U.branch=="string"&&U.branch.trim().length>0?!!U.status?.upstream?.split("/")[0]?.trim():a.length>0&&a.every(({metadata:ie})=>typeof ie.branch=="string"&&ie.branch.trim().length>0&&!!ie.status?.upstream?.split("/")[0]?.trim())},[o?.worktree,a]),X=o?.mode==="worktree",re=g||!X||!L,te=g||!X,M=l.useCallback(U=>{c({sessions:U.sessions,dateLabel:U.dateLabel,mode:U.mode??"session",worktree:U.worktree??null})},[]),ee=l.useCallback(()=>{c(null),d([]),f(!1),m(!1),y(!1),x(!1),h(new Set)},[]),V=l.useCallback(async U=>{if(U.sessions.length===0)return;if(U.sessions.length===1){const Se=U.sessions[0];await T(Se.id)?ze.success(t("sessions.sidebar.session.delete.success")):ze.error(t("sessions.sidebar.session.delete.error"));return}const ie=U.sessions.map(Se=>Se.id),{deletedIds:we,failedIds:pe}=await $(ie);if(we.length>0){const Se=pe.length>0?pe.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:pe.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:pe.length}):U.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:U.dateLabel}):void 0;ze.success(we.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:we.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:we.length}),{description:rn(Se)})}pe.length>0&&ze.error(pe.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:pe.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:pe.length}),{description:rn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[T,$,t]);l.useEffect(()=>En.onDirectoryRequest(()=>{i(!0)}),[]),l.useEffect(()=>{if(!o){d([]),f(!1),m(!1),x(!1),h(new Set);return}const U=o.sessions.map(pe=>{const Se=S(pe.id);return Se?{session:pe,metadata:Se}:null}).filter(pe=>!!pe);d(U),f(!1),x(!1),h(new Set);const ie=new Map;if(o.worktree?.path&&ie.set(_s(o.worktree.path),o.worktree),U.forEach(({metadata:pe})=>{pe.path&&ie.set(_s(pe.path),pe)}),ie.size===0){x(!0);return}let we=!1;return(async()=>{const pe=new Map,Se=new Set;await Promise.all(Array.from(ie.entries()).map(async([Ce,Oe])=>{try{const B=await Pc(Oe.path);pe.set(Ce,B),B?.isDirty&&Se.add(Ce)}catch{Oe.status&&(pe.set(Ce,Oe.status),Oe.status.isDirty&&Se.add(Ce))}})).catch(Ce=>{console.warn("Failed to inspect worktree status before deletion:",Ce)}),!we&&(h(Se),x(!0),c(Ce=>{if(!Ce?.worktree?.path)return Ce;const Oe=_s(Ce.worktree.path),B=pe.get(Oe);if(!B)return Ce;const ae=Ce.worktree.status;return ae?.isDirty===B.isDirty&&ae?.ahead===B.ahead&&ae?.behind===B.behind&&ae?.upstream===B.upstream?Ce:{...Ce,worktree:{...Ce.worktree,status:B}}}),d(Ce=>Ce.map(Oe=>{const B=_s(Oe.metadata.path),ae=pe.get(B);return ae?{session:Oe.session,metadata:{...Oe.metadata,status:ae}}:Oe})))})(),()=>{we=!0}},[o,S]),l.useEffect(()=>{L||f(!1)},[L]);const Ee=l.useCallback(async(U,ie,we)=>{const pe=u&&L,Se=A(U),Ce=_s(U.path),Oe=_s(Se.path);try{await Gu(Se,U,{deleteRemoteBranch:pe,deleteLocalBranch:ie,remoteName:U.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s}});const B=_s(w?.directoryOverride);return w?.open&&Ce&&B===Ce&&Oe&&(k(null),j({projectId:Se.id,directoryOverride:Oe},{force:!0})),_s(z)===Ce&&Oe&&xs.getState().setDirectory(Oe,{showOverlay:!1}),!0}catch(B){return ze.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:Ri(U)}),{id:we,description:rn(B instanceof Error?B.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[L,z,u,A,e,w?.directoryOverride,w?.open,k,j,s,t]),ve=l.useCallback((U,ie,we)=>{const pe=u&&L,Se=ze.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Ri(U)}));return xS(U.path),(async()=>{try{const Ce=await wb({sessionIds:ie,removeWorktree:()=>Ee(U,we,Se),archiveSessions:async ae=>ae.length===1?await O(ae[0])?{archivedIds:ae,failedIds:[]}:{archivedIds:[],failedIds:ae}:D(ae)});if(!Ce.removed)return;const Oe=t(pe?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");ze.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:Ri(U)}),{id:Se,description:rn(Oe)});const{failedIds:B}=Ce.archive;B.length>0&&ze.error(B.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:B.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:B.length}),{description:rn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(Ce){ze.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Se,description:rn(Ce instanceof Error?Ce.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{vS(U.path)}})()},[O,D,L,u,Ee,t]),ce=l.useRef(new Set),Be=l.useCallback(async(U,ie)=>{const we=_s(U.path);if(!ce.current.has(we)){ce.current.add(we);try{const pe=await Pc(U.path).catch(()=>{});if(!wS(pe)){M({sessions:ie,mode:"worktree",worktree:U});return}await ve(U,ie.map(Se=>Se.id),!0)}finally{ce.current.delete(we)}}},[M,ve]);l.useEffect(()=>En.onDeleteRequest(U=>{if(!E&&(U.mode??"session")==="session"){V(U);return}if(U.mode==="worktree"&&U.skipDialogIfSafe&&U.worktree){Be(U.worktree,U.sessions);return}M(U)}),[M,E,V,Be]);const me=l.useCallback(async()=>{if(o){y(!0);try{if(X){const U=o.worktree??a[0]?.metadata;if(!U){ze.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:rn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),y(!1);return}ve(U,o.sessions.map(ie=>ie.id),p),ee();return}if(o.sessions.length===1){const U=o.sessions[0];if(!await T(U.id)){ze.error(t("sessions.sidebar.session.delete.error")),y(!1);return}ze.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const U=o.sessions.map(pe=>pe.id),{deletedIds:ie,failedIds:we}=await $(U);if(ie.length>0){const pe=we.length>0?we.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:we.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:we.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0;ze.success(ie.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ie.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ie.length}),{description:rn(pe),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(we.length>0&&(ze.error(we.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:we.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:we.length}),{description:rn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ie.length===0)){y(!1);return}}ee()}finally{y(!1)}}},[o,a,p,T,$,ee,X,ve,t]),he=o?.worktree??a[0]?.metadata??null;let G="";if(o?.mode==="worktree"){const U=o.sessions.length;U===0?G=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):U===1?G=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:U}):G=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:U})}else if(o){const U=o.sessions.length;U===1?G=o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):G=o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:U,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:U})}const le=o?n.jsxs("div",{className:De(X?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&n.jsxs("div",{className:De(X?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[X&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),n.jsxs("ul",{className:De(X?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(U=>n.jsxs("li",{className:De(X?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[n.jsx("span",{className:De(!X&&"hidden"),children:"•"}),n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:U.title||t("sessions.sidebar.session.untitled")})]},U.id)),o.sessions.length>5&&n.jsx("li",{className:De(X?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),X?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(Q,{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")}),he?.label?n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:he.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:he?ir(he.path,_):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),F&&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,ye=X?L?n.jsxs("button",{type:"button",onClick:()=>{re||f(U=>!U)},disabled:re,"aria-pressed":u,className:De("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:[u?n.jsx(Q,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(Q,{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,Ie=X?n.jsxs("button",{type:"button",onClick:()=>{te||m(U=>!U)},disabled:te,"aria-pressed":p,className:De("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",te?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?n.jsx(Q,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(Q,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,K=X?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:[Ie,ye]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(It,{variant:"ghost",onClick:ee,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(It,{variant:"destructive",onClick:me,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:()=>R(!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(Q,{name:"checkbox-blank",className:"size-4"}):n.jsx(Q,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(It,{variant:"ghost",onClick:ee,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(It,{variant:"destructive",onClick:me,disabled:g,children:g?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),se=X?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[I?n.jsx(kS,{open:!!o,onClose:()=>{g||ee()},title:se,footer:n.jsx("div",{className:"flex justify-end gap-2",children:K}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[G&&n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:G}),le]})}):n.jsx(Ys,{open:!!o,onOpenChange:U=>{if(!U){if(g)return;ee()}},children:n.jsxs(qs,{className:De(X?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[n.jsxs(en,{children:[n.jsxs(Zs,{className:De(X&&"flex items-center gap-2"),children:[X&&n.jsx(Q,{name:"delete-bin",className:"h-5 w-5"}),se]}),G&&n.jsx(Js,{children:G})]}),n.jsx("div",{className:De(X&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:le}),n.jsx(Cn,{className:"mt-2 gap-2 pt-1 pb-1",children:K})]})}),n.jsx(kb,{open:r,onOpenChange:i})]})},vP=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],wP=["dev","start","preview","serve"];async function kP(t,e,s){if(!t)return null;const r=PP(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(s){const i=EP(s);if(i){const o=await IP(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await jP(t)){const i=await CP(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function jP(t){const e=`${t}/index.html`,s=await Ho(e,t);return typeof s=="string"&&s.trim().length>0}async function CP(){try{const t=await Gs("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),s=typeof e?.port=="number"?e.port:null;return s&&Number.isFinite(s)?s:null}catch{return null}}function PP(t){for(const e of t){const s=`${e.name} ${e.command}`.toLowerCase();if(wP.some(i=>s.includes(i)))return e}return null}function EP(t){for(const{pattern:e}of vP)for(const s of Object.keys(t))if(e.test(s))return s;return null}async function IP(t){const e=await Ho(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const s=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of s){const o=await Ho(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ho(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await Gs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const s=ju()?.files;if(s?.readFile)try{const r=await s.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await Gs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function TP(t){try{const e=await Ho(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const DP=/\{(worktree|branch)\}/g,Ji=63,RP=new Set(["main","master"]),Dh=t=>/\{(worktree|branch)\}/.test(t??""),NP=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const s=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(s).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},Rh=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Ji)return e;const s=await NP(e);return s?`${e.slice(0,Ji-7).replace(/-+$/,"")}-${s}`:e.slice(0,Ji).replace(/-+$/,"")},MP=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},AP=async(t,e,s)=>{const r=s.includes("{branch}"),i=s.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!i)return{branch:null,linkedWorktree:i};const o=await t.getGitStatus(e,{mode:"light"});return{branch:MP(o.current),linkedWorktree:i}},OP=async t=>!t.linkedWorktree||!t.branch||RP.has(t.branch)?"":Rh(t.branch.split("/").pop()??""),BP=t=>{const e=t.lastIndexOf("@"),s=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const i=r.lastIndexOf(":"),o=i>=0?r.slice(0,i):r,c=i>=0?r.slice(i):"",a=o.split(".").map(d=>d.replace(/^-+|-+$/g,"")).filter(Boolean);return`${s}${a.join(".")}${c}`},FP=async(t,e)=>{const s={worktree:await OP(e),branch:e.branch?await Rh(e.branch):""},r=t.replace(DP,(d,u)=>s[u]),i=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!i)return r;const[,o="",c="",a=""]=i;return`${o}${BP(c)}${a}`},LP=async(t,e,s)=>Dh(e)?FP(e,await AP(t,s,e)):e,Nh="oc.projectActions.selectedAction.v1",_P=Dr(Ks(),Dr(Ks(),Ks())),Mh=()=>{const t=Xo().getItem(Nh);if(t===null)return{};try{const e=_P.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},su=(t,e=Xt())=>Mh()[e]?.[t]??null,$P=(t,e,s=Xt())=>{const r=Mh();r[s]?.[t]!==e&&Xo().setItem(Nh,JSON.stringify({...r,[s]:{...r[s],[t]:e}}))},zP=15e3,KP=3e3,WP=t=>{const e=(t||"").trim();if(!e)return null;const s=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(s);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},HP=({projectRef:t,directory:e,allowMobile:s=!1})=>{const{t:r}=Ct(),{currentTheme:i}=dr(),{terminal:o,runtime:c,git:a}=Ws(),d=hn(),{isMobile:u}=Tn(),f=l.useMemo(()=>un(),[]),p=fc(J=>J.instances),m=fc(J=>J.load),g=de(J=>J.terminalShell),y=de(J=>J.terminalLoginShells.includes(J.terminalShell)),v=de(J=>J.setSettingsPage),x=de(J=>J.setSettingsDialogOpen),b=de(J=>J.setSettingsProjectsSelectedId),h=de(J=>J.openContextPreview),S=Bt(J=>J.ensureDirectory),w=Bt(J=>J.reconcileServerSessions),j=Bt(J=>J.setTabLabel),k=Bt(J=>J.setTabIconKey),T=Bt(J=>J.setActiveTab),O=Bt(J=>J.setConnecting),$=Bt(J=>J.setTabSessionId),D=Bt(J=>J.setTabPurpose),E=Bt(J=>J.allocateActionExecution),R=Bt(J=>J.setTabLifecycle),z=Bt(J=>J.setTabPreviewUrl),_=Bt(J=>J.matchesActionExecution),W=Bt(J=>J.captureStartedActionMutationRevisions),[N,Y]=l.useState([]),C=l.useRef(null),[P,I]=l.useState(()=>t?.id?su(t.id):null),[H,A]=l.useState(!1),F=l.useRef({}),L=l.useRef({}),X=l.useRef({}),re=l.useRef(new Set),te=l.useRef(0),[M,ee]=l.useState({}),V=t?.id??null,Ee=t?.path??"";l.useEffect(()=>{I(V?su(V):null)},[V]);const ve=l.useMemo(()=>V?{id:V,path:Ee}:null,[V,Ee]);l.useEffect(()=>{f&&m().catch(()=>{})},[f,m]);const ce=l.useCallback(async J=>{await si(J)},[]),Be=l.useCallback(async()=>{if(!ve)return;const J=te.current+1;te.current=J,A(!0);try{const _e=await Ec(ve);if(te.current!==J)return;C.current=_e;const Le=_e.projectActions;Y(Le)}catch{if(te.current!==J)return}finally{te.current===J&&A(!1)}},[ve]),me=l.useMemo(()=>Ni(e||ve?.path||""),[e,ve?.path]),he=l.useMemo(()=>Ni(ve?.path||""),[ve?.path]),G=l.useMemo(()=>Ni(d||"")||me,[d,me]),le=l.useRef(G);l.useEffect(()=>{le.current=G},[G]);const ye=Bt(J=>me?J.getDirectoryState(me):void 0),Ie=Bt(J=>he&&he!==me?J.getDirectoryState(he):void 0),K=l.useMemo(()=>{const J=me?[{directory:me,state:ye}]:[];return he&&he!==me&&J.push({directory:he,state:Ie}),J},[ye,me,he,Ie]),se=l.useMemo(()=>{const J=me?[me]:[];return he&&he!==me&&J.push(he),J},[me,he]),U=l.useCallback(J=>J.id!==Rn&&J.runIn==="parent"&&he||me,[me,he]),ie=l.useCallback((J,_e,Le)=>`${J}::${_e}::${Le}`,[]),we=l.useCallback((J,_e,Le=Bt.getState())=>J?Le.getDirectoryState(J)?.tabs.find(He=>He.purpose.type==="project-action"&&He.purpose.actionId===_e)??null:null,[]),pe=l.useMemo(()=>{const J={};for(const{directory:_e,state:Le}of K)for(const He of Le?.tabs??[]){if(He.purpose.type!=="project-action"||!He.purpose.executionId||!He.terminalSessionId||He.lifecycle==="idle"||He.lifecycle==="exited")continue;const $e=Hn(_e,He.purpose.actionId),tt=ie(_e,He.purpose.actionId,He.purpose.executionId);J[$e]={directory:_e,actionId:He.purpose.actionId,tabId:He.id,sessionId:He.terminalSessionId,executionId:He.purpose.executionId,status:He.lifecycle==="stopping"?"stopping":M[tt]?"waiting-for-preview":"running"}}return J},[ie,M,K]),Se=l.useCallback((J,_e,Le)=>{const He=Hn(J,_e),$e=ie(J,_e,Le),bt=F.current[He]?.executionId===Le,ht=globalThis.window,it=Mt=>{ht?.clearTimeout(X.current[Mt]),delete X.current[Mt]};bt&&(delete F.current[He],it(He)),L.current[$e]?.(),delete L.current[$e],it($e),ee(Mt=>{if(!Mt[$e])return Mt;const nt={...Mt};return delete nt[$e],nt})},[ie]),Ce=l.useCallback(J=>{L.current[J]?.(),delete L.current[J]},[]),Oe=l.useCallback(J=>{window.clearTimeout(X.current[J]),delete X.current[J]},[]);l.useEffect(()=>{const J=L.current,_e=X.current;return()=>{for(const Le of Object.keys(J))Ce(Le);for(const Le of Object.keys(_e))Oe(Le)}},[Oe,Ce]),l.useEffect(()=>{const J=new Set(se);for(const _e of Object.values(F.current))J.has(_e.directory)||Se(_e.directory,_e.actionId,_e.executionId);for(const _e of Object.keys(L.current)){const Le=_e.split("::",1)[0]??"";J.has(Le)||Ce(_e)}},[Se,Ce,se]);const B=l.useCallback((J,_e)=>{de.getState().openContextPanelTab(J,{mode:"terminal",targetDirectory:_e===J?null:_e})},[]),ae=l.useMemo(()=>({id:Rn,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),xe=!u,Te=l.useMemo(()=>xe?[...N,ae]:N,[N,ae,xe]),Ge=l.useMemo(()=>P?Te.find(J=>J.id===P)??null:null,[Te,P]);l.useEffect(()=>{Be()},[Be]);const[st,rt]=l.useState(0),Ke=l.useCallback(()=>(rt(J=>J+1),()=>rt(J=>J-1)),[]),ke=st>0;l.useEffect(()=>{if(!ke)return;const J=se.map(_e=>ra(o,_e,W,Le=>w(_e,Le.sessions,{startedActionMutationRevisions:Le.startedActionMutationRevisions})));return()=>{for(const _e of J)_e()}},[W,ke,w,o,se]),l.useEffect(()=>{for(const{directory:J,state:_e}of K)if(J)for(const Le of _e?.tabs??[]){if(Le.purpose.type!=="project-action")continue;const He=Le.purpose.actionId,$e=Te.find(ht=>ht.id===He),tt=$e?.name??He,bt=$e?.icon||"play";Le.label!==tt&&j(J,Le.id,tt),Le.iconKey!==bt&&k(J,Le.id,bt)}},[Te,k,j,K]),l.useEffect(()=>{const J=globalThis.window;if(!J)return;const _e=Le=>{const He=Le.detail;V&&(He?.projectId&&He.projectId!==V||Be())};return J.addEventListener(Ic,_e),()=>{J.removeEventListener(Ic,_e)}},[Be,V]),l.useEffect(()=>{const J=Le=>{delete X.current[Le];const He=F.current[Le];if(!He||He.openedUrl)return;const $e=ie(He.directory,He.actionId,He.executionId),tt=He.announced;if(tt.length!==0){if(window.clearTimeout(X.current[$e]),delete X.current[$e],He.openedUrl=!0,ee(bt=>{if(!bt[$e])return bt;const ht={...bt};return delete ht[$e],ht}),tt.length===1){Ki(He.directory,[]),z(He.directory,He.tabId,tt[0],{locked:!1,autoOpened:!0}),h(He.directory,tt[0]);return}He.offering=!0,Ki(He.directory,tt),de.getState().openContextSurface(He.directory,"browser"),ze.info(r("projectActions.toast.multipleServers"))}},_e=()=>{const Le=Bt.getState(),He=Le.sessions,$e=pe;for(const[tt,bt]of Object.entries($e)){const it=He.get(bt.directory)?.tabs.find(lt=>lt.id===bt.tabId);if(!it||it.terminalSessionId!==bt.sessionId){Se(bt.directory,bt.actionId,bt.executionId);continue}const Mt=F.current[tt],nt=Mt?.executionId===bt.executionId?Mt:{hostDirectory:le.current||bt.directory,directory:bt.directory,tabId:bt.tabId,actionId:bt.actionId,executionId:bt.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};F.current[tt]=nt;const Lt=Te.find(lt=>lt.id===bt.actionId),_t=Le.getBuffer(bt.directory,bt.tabId).chunks;if(!Lt||_t.length===0)continue;const Tt=_t.filter(lt=>nt.lastSeenChunkId===null||lt.id>nt.lastSeenChunkId);if(Tt.length===0)continue;const Ae=Tt.map(lt=>lt.data).join(""),at=`${nt.tail}${Ae}`;for(const lt of Ib(at))nt.proxiedPorts.includes(lt)||nt.proxiedPorts.push(lt);if(nt.openInPreview&&(!nt.openedUrl||nt.offering)){const lt=Tb(at,{proxiedPorts:nt.proxiedPorts,namedAddressesReachable:!pc()}),St=nt.announced.length;for(const oe of lt)nt.announced.includes(oe)||nt.announced.push(oe);const ct=nt.announced.length-St;nt.offering&&ct>0?Ki(bt.directory,nt.announced):!nt.openedUrl&&St===0&&nt.announced.length>0&&(window.clearTimeout(X.current[tt]),X.current[tt]=window.setTimeout(()=>J(tt),KP))}const ut=!nt.openedUrl&&Lt.autoOpenUrl===!0&&!nt.openInPreview?Db(at,{proxiedPorts:nt.proxiedPorts,namedAddressesReachable:!pc()}):null,pt=Tt[Tt.length-1]?.id??nt.lastSeenChunkId;if(nt.lastSeenChunkId=pt,nt.tail=at.slice(-512),ut)if(nt.openedUrl=!0,nt.openInPreview){const lt=$e[tt];lt&&(z(lt.directory,lt.tabId,ut,{locked:!1,autoOpened:!1,expectedExecutionId:lt.executionId}),lt.status==="waiting-for-preview"&&ee(St=>{const ct=ie(lt.directory,lt.actionId,lt.executionId);if(!St[ct])return St;const oe={...St};return delete oe[ct],oe}),window.clearTimeout(X.current[tt]),delete X.current[tt],h(lt.directory,ut))}else ce(ut),ze.success(r("projectActions.toast.openedUrlFromOutput"));F.current[tt]=nt}for(const tt of Object.keys(F.current))if(!$e[tt]){const bt=F.current[tt],ht=bt?He.get(bt.directory)?.tabs.find(Mt=>Mt.id===bt.tabId):void 0;if(ht?.purpose.type==="project-action"&&ht.purpose.executionId===bt?.executionId&&!!ht.terminalSessionId&&ht.lifecycle!=="idle"&&ht.lifecycle!=="exited")continue;delete F.current[tt],window.clearTimeout(X.current[tt]),delete X.current[tt]}};return _e(),Bt.subscribe((Le,He)=>{(Le.sessions!==He.sessions||Le.buffers!==He.buffers)&&_e()})},[Se,le,Te,ie,h,ce,pe,z,r]),l.useEffect(()=>{for(const{directory:J,state:_e}of K)for(const Le of _e?.tabs??[]){if(Le.purpose.type!=="project-action"||!Le.purpose.executionId||!Le.terminalSessionId||Le.lifecycle!=="running")continue;const He=Le.purpose.actionId,$e=Le.purpose.executionId,tt=ie(J,He,$e);if(L.current[tt])continue;const bt=o.connect(Le.terminalSessionId,{onEvent:ht=>{if(!_(J,Le.id,$e))return;ht.type==="snapshot"&&(Bt.getState().replaceBuffer(J,Le.id,ht.data??"",ht.sequence??0,Jl(ht)),ht.status==="running"&&Bt.getState().setTabLifecycle(J,Le.id,"running",{expectedExecutionId:$e}),ht.status==="exited"&&(Bt.getState().setTabLifecycle(J,Le.id,"exited",{expectedExecutionId:$e}),Bt.getState().setTabPurpose(J,Le.id,{type:"project-action",actionId:He,executionId:null}),Se(J,He,$e)));const it=ht.type==="data"?ht.data??"":"";it&&Bt.getState().appendToBuffer(J,Le.id,it,ht.sequence,ht.replayData),ht.type==="exit"&&(Bt.getState().setTabLifecycle(J,Le.id,"exited",{expectedExecutionId:$e}),Bt.getState().setTabPurpose(J,Le.id,{type:"project-action",actionId:He,executionId:null}),Se(J,He,$e))},onError:(ht,it)=>{!it||!_(J,Le.id,$e)||(Bt.getState().setTabLifecycle(J,Le.id,"exited",{expectedExecutionId:$e}),Bt.getState().setTabSessionId(J,Le.id,null,{expectedExecutionId:$e}),Bt.getState().setTabPurpose(J,Le.id,{type:"project-action",actionId:He,executionId:null}),Se(J,He,$e))}},J);L.current[tt]=bt.close}},[Se,ie,_,o,K]);const ge=l.useCallback(async J=>{const _e=U(J);if(!_e)throw new Error(r("projectActions.error.noActiveDirectory"));const Le=Hn(_e,J.id);S(_e);const He=Bt.getState(),$e=we(_e,J.id,He),tt=$e?.id??He.createTab(_e);j(_e,tt,J.name),k(_e,tt,J.icon||"play"),$e||D(_e,tt,{type:"project-action",actionId:J.id,executionId:null}),T(_e,tt);const ht=Bt.getState().getDirectoryState(_e)?.tabs.find(it=>it.id===tt);return{executionDirectory:_e,key:Le,tabId:tt,sessionId:ht?.terminalSessionId??null,executionId:ht?.purpose.type==="project-action"?ht.purpose.executionId:null}},[S,U,we,T,k,j,D,r]),Ve=l.useCallback(async J=>{if(c.isVSCode||!s&&u)return;if(!me){ze.error(r("projectActions.error.noActiveDirectoryForAction"));return}const _e=Hn(U(J),J.id),Le=pe[_e];if(Le&&Le.status==="running"||re.current.has(_e))return;re.current.add(_e);let He=null;try{const $e=J.id===Rn?await(async()=>{const[fe,We]=await Promise.all([jS({id:ve?.id??"",path:me}),TP(me)]),be=await kP(me,fe.actions,We);if(!be)throw new Error(r("contextPanel.preview.noDevServer"));return{id:Rn,name:r("projectActions.actions.autoDiscover"),command:be.command,icon:"scan-2",autoOpenUrl:!0,openUrl:be.previewUrlHint||""}})():J,tt=$e.autoOpenUrl===!0&&($e.openUrl||"").trim().length>0,bt=!tt&&J.id!==Rn,ht=le.current||me,{executionDirectory:it,key:Mt,tabId:nt}=await ge($e),Lt=jb($e.command);if(!Lt)throw new Error(r("projectActions.error.failedToRunAction"));const _t=$e.autoOpenUrl===!0&&f&&($e.desktopOpenSshForward||"").trim().length>0,Tt=$e.autoOpenUrl&&$e.openUrl||"";let Ae=!1;const at=Dh(Tt)?await LP(a,Tt,it).catch(()=>(Ae=!0,"")):Tt,ut=$e.autoOpenUrl?WP(at):null,pt=$e.autoOpenUrl&&f?CS($e.desktopOpenSshForward,p):null;if(o.listSessions){const fe=we(it,$e.id);if(fe?.purpose.type==="project-action"&&fe.purpose.executionId===null){const We=await Cb(o,it,{captureStartedActionMutationRevisions:W});We&&w(it,We.sessions,{startedActionMutationRevisions:We.startedActionMutationRevisions})}}const lt=we(it,$e.id);let St,ct;if(lt?.lifecycle==="running"&<.terminalSessionId&<.purpose.type==="project-action"&<.purpose.executionId)St=lt.terminalSessionId,ct=lt.purpose.executionId;else{const fe=lt?.purpose.type==="project-action"?lt.purpose.executionId:null;fe&&Se(it,$e.id,fe);const We=E(it,nt,$e.id);if(!We)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));He={directory:it,tabId:nt,id:We},O(it,nt,!0,{expectedExecutionId:We});const be=await Pb({terminal:o,createOptions:{cwd:it,shell:g,loginShell:y,themeMode:i.metadata.variant==="light"?"light":"dark",terminalBackground:i.colors.surface.background,terminalForeground:i.colors.syntax.base.foreground},command:Lt,isRunStillExpected:()=>_(it,nt,We),purpose:{type:"project-action",actionId:$e.id,executionId:We}});if(!_(it,nt,We)){be.sessionId===We&&await o.close(be.sessionId).catch(()=>{});return}ct=be.purpose?.type==="project-action"?be.purpose.executionId:We,St=be.sessionId,D(it,nt,{type:"project-action",actionId:$e.id,executionId:ct}),$(it,nt,St,{expectedExecutionId:ct}),O(it,nt,!1,{expectedExecutionId:ct})}bt&&ht&&B(ht,it),F.current[Mt]={hostDirectory:ht,directory:it,tabId:nt,actionId:$e.id,executionId:ct,lastSeenChunkId:null,openedUrl:!!pt||!!ut||tt,tail:"",openInPreview:$e.id===Rn,announced:[],offering:!1,proxiedPorts:[]};const oe=ie(it,$e.id,ct);O(it,nt,!0,{expectedExecutionId:ct});const q=o.connect(St,{onEvent:fe=>{if(!_(it,nt,ct)||fe.purpose?.type==="project-action"&&fe.purpose.executionId!==ct)return;fe.type==="snapshot"&&(Bt.getState().replaceBuffer(it,nt,fe.data??"",fe.sequence??0,Jl(fe)),Bt.getState().setConnecting(it,nt,!1,{expectedExecutionId:ct}),fe.purpose?.type==="project-action"&&Bt.getState().setTabPurpose(it,nt,{type:"project-action",actionId:fe.purpose.actionId,executionId:fe.purpose.executionId}),fe.status==="running"&&Bt.getState().setTabLifecycle(it,nt,"running",{expectedExecutionId:ct}),fe.status==="exited"&&(Bt.getState().setTabLifecycle(it,nt,"exited",{expectedExecutionId:ct}),Bt.getState().setTabPurpose(it,nt,{type:"project-action",actionId:$e.id,executionId:null}),Se(it,$e.id,ct)));const We=fe.type==="data"?fe.data??"":"";We&&Bt.getState().appendToBuffer(it,nt,We,fe.sequence,fe.replayData),fe.type==="exit"&&(Bt.getState().setTabLifecycle(it,nt,"exited",{expectedExecutionId:ct}),Bt.getState().setConnecting(it,nt,!1,{expectedExecutionId:ct}),Bt.getState().setTabPurpose(it,nt,{type:"project-action",actionId:$e.id,executionId:null}),Se(it,$e.id,ct))},onError:(fe,We)=>{_(it,nt,ct)&&(Bt.getState().setConnecting(it,nt,!1,{expectedExecutionId:ct}),We&&(Bt.getState().setTabLifecycle(it,nt,"exited",{expectedExecutionId:ct}),Bt.getState().setTabSessionId(it,nt,null,{expectedExecutionId:ct}),Bt.getState().setTabPurpose(it,nt,{type:"project-action",actionId:$e.id,executionId:null}),Se(it,$e.id,ct)))}},it);if(!_(it,nt,ct)){q.close();return}L.current[oe]?.(),L.current[oe]=q.close,window.clearTimeout(X.current[oe]),delete X.current[oe],$e.id===Rn&&!ut&&(ee(fe=>({...fe,[oe]:!0})),X.current[oe]=window.setTimeout(()=>{delete X.current[oe];const fe=F.current[Mt];!fe||fe.executionId!==ct||fe.openedUrl||fe.offering||_(it,nt,ct)&&(ee(We=>{if(!We[oe])return We;const be={...We};return delete be[oe],be}),Bt.getState().setActiveTab(it,nt),B(fe.hostDirectory,it))},zP)),pt?(z(it,nt,null,{locked:!0,expectedExecutionId:ct}),ce(pt),ze.success(r("projectActions.toast.openedForwardedUrl"))):ut?(z(it,nt,ut,{locked:!0,autoOpened:!0,expectedExecutionId:ct}),h(ht,ut),ze.success(r("projectActions.toast.openedActionUrl"))):Ae?(z(it,nt,null,{locked:!0,expectedExecutionId:ct}),ze.error(r("projectActions.error.openUrlTemplateUnresolved"))):tt?(z(it,nt,null,{locked:!0,expectedExecutionId:ct}),ze.error(r("projectActions.error.invalidCustomUrlFormat"))):_t?(z(it,nt,null,{locked:!0,expectedExecutionId:ct}),ze.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):z(it,nt,null,{locked:!1,autoOpened:!1,expectedExecutionId:ct})}catch($e){if(He&&_(He.directory,He.tabId,He.id)){const{directory:tt,tabId:bt,id:ht}=He;Se(tt,J.id,ht),R(tt,bt,"exited",{expectedExecutionId:ht}),D(tt,bt,{type:"project-action",actionId:J.id,executionId:null})}if($e instanceof Error&&$e.message==="PROJECT_ACTION_RUN_CANCELLED")return;if($e instanceof Error&&($e.message==="COMMAND_MODE_UNSUPPORTED"||$e.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){ze.error(r("projectActions.error.failedToCreateTerminalSession"));return}ze.error($e instanceof Error?$e.message:r("projectActions.error.failedToRunAction"))}finally{re.current.delete(_e)}},[i.colors.surface.background,i.colors.syntax.base.foreground,i.metadata.variant,le,p,ge,a,s,u,f,me,y,g,ce,h,pe,B,c.isVSCode,U,_,Se,ie,we,w,E,W,O,R,D,z,$,ve?.id,r,o]),Ue=l.useCallback(async J=>{const _e=Hn(U(J),J.id),Le=pe[_e];Le&&await Eb({terminal:o,sessionId:Le.sessionId,isExecutionStillCurrent:()=>_(Le.directory,Le.tabId,Le.executionId),markStopping:()=>{R(Le.directory,Le.tabId,"stopping",{expectedExecutionId:Le.executionId})},restoreRunning:()=>{R(Le.directory,Le.tabId,"running",{expectedExecutionId:Le.executionId})},clearSession:()=>{$(Le.directory,Le.tabId,null,{expectedExecutionId:Le.executionId})},finalizeExit:()=>{R(Le.directory,Le.tabId,"exited",{expectedExecutionId:Le.executionId}),D(Le.directory,Le.tabId,{type:"project-action",actionId:Le.actionId,executionId:null}),Se(Le.directory,Le.actionId,Le.executionId)}})},[Se,U,_,pe,R,D,$,o]),ft=l.useCallback(async J=>{if(J.source==="shared"&&ve){const _e=C.current?.trust.trusted?C.current:await Ec(ve);if(C.current=_e,!await PS(ve,_e))return;C.current={..._e,trust:{..._e.trust,trusted:!0}}}await Ve(J)},[Ve,ve]),Qe=l.useCallback(J=>pe[Hn(U(J),J.id)]??null,[U,pe]),wt=(Ge&&Qe(Ge)?Ge:null)??Te.find(J=>Qe(J)!==null)??Ge??Te[0]??null,Me=l.useCallback(J=>{const _e=Qe(J);if(_e?.status!=="stopping"){if(_e){Ue(J);return}ft(J)}},[ft,Qe,Ue]),Pe=l.useCallback(J=>{ft(J)},[ft]),ot=l.useCallback(J=>{Ue(J)},[Ue]),et=l.useCallback(J=>{I(J.id),V&&$P(V,J.id)},[V]),Ze=l.useCallback(()=>{ve?.id&&(b(ve.id),v("projects"),x(!0))},[x,v,b,ve?.id]),dt=!c.isVSCode&&(s||!u)&&!!ve&&!!me;return l.useMemo(()=>({available:dt,actions:dt?Te:[],shown:dt?wt:null,isLoading:H,observe:Ke,runOf:Qe,select:et,run:Pe,stop:ot,toggle:Me,openSettings:Ze}),[dt,Te,H,Ke,Ze,Pe,Qe,et,wt,ot,Me])},VP=t=>{const e=Xe.c(6);let s,r;e[0]!==t?({children:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const i=HP(r);let o;return e[3]!==s||e[4]!==i?(o=n.jsx(ES.Provider,{value:i,children:s}),e[3]=s,e[4]=i,e[5]=o):o=e[5],o},UP=t=>{const e=Xe.c(4),{children:s}=t,r=IS(),i=r?.projectRef??null,o=r?.directory??"";let c;return e[0]!==s||e[1]!==i||e[2]!==o?(c=n.jsx(VP,{projectRef:i,directory:o,children:s}),e[0]=s,e[1]=i,e[2]=o,e[3]=c):c=e[3],c};function di(t,e,s){const[r,i]=l.useState(null),o=l.useRef(s);return o.current=s,l.useEffect(()=>{if(!t||r)return;let c=!1;return TS(e).then(a=>{c||i(()=>a)},a=>{console.error("[on-demand] failed to load component",a),c||o.current()}),()=>{c=!0}},[r,e,t]),r}function GP(t){const e=[],s=(r,i)=>{const o=vt(r);!o||e.some(c=>c.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const qP=new Map,YP=t=>{const e=Xe.c(23),{isVSCode:s}=t,r=Fr(),i=ns(XP),o=xs(QP),c=xt(ZP);let a;e[0]!==s?(a=$=>s?qP:$.availableWorktreesByProject,e[0]=s,e[1]=a):a=e[1];const d=xt(a),u=!s;let f;e[2]!==d||e[3]!==i||e[4]!==u?(f=Th(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=f):f=e[5];const p=f,m=Es(JP),g=Es(eE),y=Es(tE),v=`session-list-sync:${l.useId()}`;let x,b;e[6]!==v||e[7]!==r||e[8]!==o||e[9]!==c?(x=()=>(r.setBootstrapDemand(v,GP({currentDirectory:o,currentSessionDirectory:c})),()=>r.clearBootstrapDemand(v)),b=[v,r,o,c],e[6]=v,e[7]=r,e[8]=o,e[9]=c,e[10]=x,e[11]=b):(x=e[10],b=e[11]),l.useEffect(x,b);const h=l.useRef(null);let S,w;e[12]!==s||e[13]!==p?(S=()=>{const $=new Set(p),D=h.current;h.current=$;const E=D?[...$].filter(R=>!D.has(R)):s?[...$]:[];E.length&&Ja(E,pa())},w=[s,p],e[12]=s,e[13]=p,e[14]=S,e[15]=w):(S=e[14],w=e[15]),l.useEffect(S,w);let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[16]=j):j=e[16],l.useEffect(sE,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 T=k;let O;e[20]!==T||e[21]!==y?(O={enabled:!0,hasAuthoritativeGlobalSessions:y,sessions:T},e[20]=T,e[21]=y,e[22]=O):O=e[22],Rb(O)};function XP(t){return t.projects}function QP(t){return t.currentDirectory}function ZP(t){return t.currentSessionDirectory}function JP(t){return t.activeSessions}function eE(t){return t.archivedSessions}function tE(t){return t.status==="ready"}function sE(){let t=null,e=!1;const s=new Set,r=Pn(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")s.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,s.clear(),Kf(pa());return}const o=[...s];s.clear(),o.length&&Ja(o,pa())},500)});return()=>{t&&clearTimeout(t),r()}}const nE=()=>os(()=>import("./SettingsWindow-Dd1hHvgh.js"),__vite__mapDeps([144,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,145,84,146,131,132,133,134,140,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,147,148,139,127,149])).then(t=>t.SettingsWindow),rE=()=>os(()=>import("./CommandPalette-BICwnwAZ.js"),__vite__mapDeps([150,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,149,84,122,123,124])).then(t=>t.CommandPalette),oE=()=>os(()=>import("./HelpDialog-CxC6qTaS.js"),__vite__mapDeps([151,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>t.HelpDialog),iE=()=>os(()=>import("./ProjectActionsDialog-D660By4K.js"),__vite__mapDeps([152,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])).then(t=>t.ProjectActionsDialog),aE=()=>os(()=>import("./OpenCodeStatusDialog-Cxa2yqOB.js"),__vite__mapDeps([153,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])).then(t=>t.OpenCodeStatusDialog),lE=()=>os(()=>import("./RunOverview-C1uTMnQS.js"),__vite__mapDeps([154,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84])).then(t=>t.RunOverview),cE=()=>os(()=>import("./ScheduledTasksDialog-S-gAgo7Z.js"),__vite__mapDeps([155,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,142,156,157])).then(t=>t.ScheduledTasksDialog),dE=()=>os(()=>import("./ArchiveView-sbNreasJ.js"),__vite__mapDeps([158,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])).then(t=>t.ArchiveView),uE=()=>os(()=>import("./UsageStatsView-BxtYEAa0.js"),__vite__mapDeps([159,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])).then(t=>t.UsageStatsView),fE=()=>os(()=>import("./SourceBoardView-DbGWAxtS.js"),__vite__mapDeps([160,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])).then(t=>t.SourceBoardView),pE=()=>os(()=>import("./WorktreesView-Dv0AO9dF.js"),__vite__mapDeps([161,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])).then(t=>t.WorktreesView),hE=()=>os(()=>import("./SpacesView-CYCrlp0D.js"),__vite__mapDeps([162,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,163,84])).then(t=>t.SpacesView),mE=()=>os(()=>import("./SpaceAccessDialog-muTSsEJ9.js"),__vite__mapDeps([164,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,165])).then(t=>t.SpaceAccessDialog),gE=()=>os(()=>import("./SpaceApplyDialog-Dsf6MNGm.js"),__vite__mapDeps([166,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,167])).then(t=>t.SpaceApplyDialog),bE=()=>os(()=>import("./SpaceSetupOutput-BytPfCOC.js"),__vite__mapDeps([168,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,165])).then(t=>t.SpaceSetupOutputDialog),An=()=>de.getState().closeMainSurfaces(),js=t=>{const e=Xe.c(2),{needed:s,load:r,onFailure:i}=t,o=di(s,r,i);let c;return e[0]!==o?(c=o?n.jsx(o,{}):null,e[0]=o,e[1]=c):c=e[1],c},Ah=l.memo(t=>{const e=Xe.c(11),{isMobile:s}=t,r=de(xE),i=!r&&!s,o=ei();let c;e[0]!==i||e[1]!==o?(c={enabled:i,layoutAnimationMs:o},e[0]=i,e[1]=o,e[2]=c):c=e[2];const a=wv(c);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(gv,{}),e[3]=d):d=e[3];const u=r||a.state!==!1;let f;e[4]!==u?(f=n.jsx(xP,{isVisible:u}),e[4]=u,e[5]=f):f=e[5];let p;return e[6]!==s||e[7]!==r||e[8]!==a||e[9]!==f?(p=n.jsx(mv,{isOpen:r,isMobile:s,className:"border-border",topBar:d,peek:a,children:f}),e[6]=s,e[7]=r,e[8]=a,e[9]=f,e[10]=p):p=e[10],p});Ah.displayName="LeftSidebar";const yE=()=>{const t=Xe.c(104);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],YP(e),Nb();const s=de(SE),r=de(vE),i=de(wE),o=de(kE);let c;t[1]!==o?(c=()=>o(!1),t[1]=o,t[2]=c):c=t[2];const a=di(i,nE,c),d=de(jE),u=de(CE),f=de(PE),p=de(EE),m=de(IE),g=de(TE),y=de(DE),v=de(RE),x=de(NE),b=de(ME),h=de(AE),S=$s(OE),w=$s(BE),j=$s(FE),k=de(LE),T=kf();let O;if(t[3]!==T||t[4]!==k){let Ue;t[6]!==k?(Ue=ft=>ft.id===k,t[6]=k,t[7]=Ue):Ue=t[7],O=T.find(Ue),t[3]=T,t[4]=k,t[5]=O}else O=t[5];const $=O;let D,E;t[8]!==$||t[9]!==k?(D=()=>{k&&!$&&de.getState().setOpenGuestPage(null)},E=[k,$],t[8]=$,t[9]=k,t[10]=D,t[11]=E):(D=t[10],E=t[11]),l.useEffect(D,E);let R;t[12]===Symbol.for("react.memo_cache_sentinel")?(R=[],t[12]=R):R=t[12],l.useEffect($E,R);let z;t[13]===Symbol.for("react.memo_cache_sentinel")?(z=[],t[13]=z):z=t[13],l.useEffect(zE,z);const _=u||f||p||m||!!g||y||d||!!$;let W,N;t[14]!==_?(W=()=>{Wf(_)},N=[_],t[14]=_,t[15]=W,t[16]=N):(W=t[15],N=t[16]),l.useLayoutEffect(W,N);let Y;t[17]===Symbol.for("react.memo_cache_sentinel")?(Y=[],t[17]=Y):Y=t[17],l.useEffect(WE,Y);let C;t[18]===Symbol.for("react.memo_cache_sentinel")?(C=[],t[18]=C):C=t[18],l.useEffect(VE,C);const{isMobile:P}=Tn();Mb();let I,H;t[19]!==P||t[20]!==r?(I=()=>{de.getState().isMobile!==P&&r(P)},H=[P,r],t[19]=P,t[20]=r,t[21]=I,t[22]=H):(I=t[21],H=t[22]),l.useEffect(I,H);let A;t[23]!==v?(A=n.jsx(js,{needed:v,load:rE,onFailure:UE}),t[23]=v,t[24]=A):A=t[24];let F;t[25]!==x?(F=n.jsx(js,{needed:x,load:oE,onFailure:GE}),t[25]=x,t[26]=F):F=t[26];let L;t[27]!==b?(L=n.jsx(js,{needed:b,load:iE,onFailure:qE}),t[27]=b,t[28]=L):L=t[28];let X;t[29]!==h?(X=n.jsx(js,{needed:h,load:aE,onFailure:YE}),t[29]=h,t[30]=X):X=t[30];let re,te;t[31]===Symbol.for("react.memo_cache_sentinel")?(re=n.jsx(Ab,{}),te=n.jsx(SP,{}),t[31]=re,t[32]=te):(re=t[31],te=t[32]);let M;t[33]!==S||t[34]!==w||t[35]!==j||t[36]!==s?(M=s?n.jsxs(n.Fragment,{children:[n.jsx(js,{needed:S,load:mE,onFailure:XE}),n.jsx(Ob,{}),n.jsx(js,{needed:w,load:gE,onFailure:QE}),n.jsx(Bb,{}),n.jsx(js,{needed:j,load:bE,onFailure:ZE})]}):null,t[33]=S,t[34]=w,t[35]=j,t[36]=s,t[37]=M):M=t[37];let ee;t[38]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx(kv,{}),t[38]=ee):ee=t[38];let V;t[39]!==P?(V=n.jsx(Ah,{isMobile:P}),t[39]=P,t[40]=V):V=t[40];let Ee;t[41]===Symbol.for("react.memo_cache_sentinel")?(Ee=n.jsx(hv,{}),t[41]=Ee):Ee=t[41];let ve;t[42]===Symbol.for("react.memo_cache_sentinel")?(ve=n.jsx($i,{zone:"left"}),t[42]=ve):ve=t[42];const ce=_&&"invisible";let Be;t[43]!==ce?(Be=De("absolute inset-0",ce),t[43]=ce,t[44]=Be):Be=t[44];const me=!i&&!_;let he;t[45]!==me?(he=n.jsx(ws,{children:n.jsx(Au,{active:me})}),t[45]=me,t[46]=he):he=t[46];let G;t[47]!==Be||t[48]!==he?(G=n.jsx("div",{className:Be,children:he}),t[47]=Be,t[48]=he,t[49]=G):G=t[49];let le;t[50]!==d?(le=n.jsx(ws,{children:n.jsx(js,{needed:d,load:lE,onFailure:An})}),t[50]=d,t[51]=le):le=t[51];let ye;t[52]!==u?(ye=n.jsx(ws,{children:n.jsx(js,{needed:u,load:cE,onFailure:An})}),t[52]=u,t[53]=ye):ye=t[53];let Ie;t[54]!==f?(Ie=n.jsx(ws,{children:n.jsx(js,{needed:f,load:dE,onFailure:An})}),t[54]=f,t[55]=Ie):Ie=t[55];let K;t[56]!==p?(K=p&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(ws,{children:n.jsx(js,{needed:!0,load:uE,onFailure:An})})}),t[56]=p,t[57]=K):K=t[57];let se;t[58]!==m?(se=n.jsx(js,{needed:m,load:fE,onFailure:An}),t[58]=m,t[59]=se):se=t[59];const U=!!g;let ie;t[60]!==U?(ie=n.jsx(ws,{children:n.jsx(js,{needed:U,load:pE,onFailure:An})}),t[60]=U,t[61]=ie):ie=t[61];let we;t[62]!==y?(we=y?n.jsx(ws,{children:n.jsx(js,{needed:!0,load:hE,onFailure:An})}):null,t[62]=y,t[63]=we):we=t[63];let pe;t[64]!==$?(pe=$&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(ws,{children:n.jsx(DS,{mode:`plugin:${$.id}`,surface:"page",item:null,onDismiss:JE})})}),t[64]=$,t[65]=pe):pe=t[65];let Se;t[66]!==G||t[67]!==le||t[68]!==ye||t[69]!==Ie||t[70]!==K||t[71]!==se||t[72]!==ie||t[73]!==we||t[74]!==pe?(Se=n.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[G,le,ye,Ie,K,se,ie,we,pe]}),t[66]=G,t[67]=le,t[68]=ye,t[69]=Ie,t[70]=K,t[71]=se,t[72]=ie,t[73]=we,t[74]=pe,t[75]=Se):Se=t[75];let Ce;t[76]===Symbol.for("react.memo_cache_sentinel")?(Ce=n.jsx($i,{zone:"bottom"}),t[76]=Ce):Ce=t[76];let Oe;t[77]!==Se?(Oe=n.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[Se,Ce]}),t[77]=Se,t[78]=Oe):Oe=t[78];let B,ae,xe,Te;t[79]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx($i,{zone:"right"}),ae=n.jsx(Zj,{}),xe=n.jsx(t2,{}),Te=n.jsx(o2,{}),t[79]=B,t[80]=ae,t[81]=xe,t[82]=Te):(B=t[79],ae=t[80],xe=t[81],Te=t[82]);let Ge;t[83]!==Oe?(Ge=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:[ve,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:[Oe,B,ae,xe,Te]})]})}),t[83]=Oe,t[84]=Ge):Ge=t[84];let st;t[85]===Symbol.for("react.memo_cache_sentinel")?(st=n.jsx("div",{"data-page-scroll-lock":"true",children:n.jsx(ws,{children:n.jsx(C2,{})})}),t[85]=st):st=t[85];let rt;t[86]===Symbol.for("react.memo_cache_sentinel")?(rt=n.jsx(ws,{children:n.jsx(d1,{})}),t[86]=rt):rt=t[86];let Ke;t[87]!==Ge?(Ke=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ee,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ge,st,rt]})]}),t[87]=Ge,t[88]=Ke):Ke=t[88];let ke;t[89]!==V||t[90]!==Ke?(ke=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[V,Ke]}),t[89]=V,t[90]=Ke,t[91]=ke):ke=t[91];let ge;t[92]!==a||t[93]!==i||t[94]!==o?(ge=a?n.jsx(a,{open:i,onOpenChange:o}):null,t[92]=a,t[93]=i,t[94]=o,t[95]=ge):ge=t[95];let Ve;return t[96]!==A||t[97]!==F||t[98]!==L||t[99]!==X||t[100]!==M||t[101]!==ke||t[102]!==ge?(Ve=n.jsx(Fb,{children:n.jsx(UP,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[A,F,L,X,re,te,M,ee,ke,ge]})})}),t[96]=A,t[97]=F,t[98]=L,t[99]=X,t[100]=M,t[101]=ke,t[102]=ge,t[103]=Ve):Ve=t[103],Ve};function xE(t){return t.isSidebarOpen}function SE(t){return t.isolatedSpacesEnabled}function vE(t){return t.setIsMobile}function wE(t){return t.isSettingsDialogOpen}function kE(t){return t.setSettingsDialogOpen}function jE(t){return t.runOverviewKey!==null}function CE(t){return t.isScheduledTasksDialogOpen}function PE(t){return t.isArchivePageOpen}function EE(t){return t.isUsageStatsPageOpen}function IE(t){return t.isSourceBoardOpen}function TE(t){return t.worktreesPageProjectId}function DE(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function RE(t){return t.isCommandPaletteOpen}function NE(t){return t.isHelpDialogOpen}function ME(t){return t.isProjectActionsDialogOpen}function AE(t){return t.isOpenCodeStatusDialogOpen}function OE(t){return t.accessDialog!==null}function BE(t){return t.applyDialog!==null}function FE(t){return t.setupOutputDialog!==null}function LE(t){return t.openGuestPageId}function _E(){return de.getState().setOpenGuestPage(null)}function $E(){return Go(_E)}function zE(){return c1()}function KE(){return Wf(!1)}function WE(){return KE}function HE(){return de.getState().closeMainSurfaces()}function VE(){const t=HE,e=xt.subscribe((s,r)=>{const i=!!s.currentSessionId&&s.currentSessionId!==r.currentSessionId,o=!!s.newSessionDraft?.open&&s.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function UE(){return de.getState().setCommandPaletteOpen(!1)}function GE(){return de.getState().setHelpDialogOpen(!1)}function qE(){return de.getState().setProjectActionsDialogOpen(!1)}function YE(){return de.getState().setOpenCodeStatusDialogOpen(!1)}function XE(){return $s.getState().closeAccessDialog()}function QE(){return $s.getState().closeApplyDialog()}function ZE(){return $s.getState().closeSetupOutputDialog()}function JE(){return de.getState().setOpenGuestPage(null)}const Oh=12,eI=[{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"}],tI=t=>{const e=Xe.c(18),{isActive:s,burstKey:r,className:i,durationMs:o,bursts:c,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,f=c===void 0?eI:c,p=fs.useRef(!1);let m,g;e[0]!==s||e[1]!==a?(m=()=>{!s&&p.current&&a?.(),s&&(p.current=!0)},g=[s,a],e[0]=s,e[1]=a,e[2]=m,e[3]=g):(m=e[2],g=e[3]),fs.useEffect(m,g);let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=Array.from({length:Oh},sI),e[4]=y):y=e[4];const v=y;if(!s)return null;let x;e[5]!==i?(x=De("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=x):x=e[6];let b;if(e[7]!==d||e[8]!==f||e[9]!==u){let S;e[11]!==d||e[12]!==u?(S=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,T)=>{const O=k.x*w.radius,$=k.y*w.radius,D={"--translate-x":`${O}px`,"--translate-y":`${$}px`,"--particle-delay":`${k.delay}ms`,color:`var(${w.colorVar})`};return n.jsx("span",{className:"firework-particle",style:D},`${w.id}-${T}-${d}`)})},`${w.id}-${d}`)},e[11]=d,e[12]=u,e[13]=S):S=e[13],b=f.map(S),e[7]=d,e[8]=f,e[9]=u,e[10]=b}else b=e[10];let h;return e[14]!==d||e[15]!==x||e[16]!==b?(h=n.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":d,children:b}),e[14]=d,e[15]=x,e[16]=b,e[17]=h):h=e[17],h};function sI(t,e){const s=Math.PI*2*e/Oh;return{x:Math.cos(s),y:Math.sin(s),delay:e*18}}const nI=t=>{const e=Xe.c(13);let s;e[0]!==t?(s={},e[0]=t,e[1]=s):s=e[1];const{durationMs:r}=s,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[c,a]=fs.useState(o),d=fs.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const f=u;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{f(),a(rI)},e[4]=p):p=e[4];const m=p;let g;e[5]!==i?(g=()=>{f(),a(oI),d.current=window.setTimeout(()=>{a(iI),d.current=null},i)},e[5]=i,e[6]=g):g=e[6];const y=g;let v,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>f(),x=[f],e[7]=v,e[8]=x):(v=e[7],x=e[8]),fs.useEffect(v,x);let b;return e[9]!==c.cycle||e[10]!==c.isActive||e[11]!==y?(b={isActive:c.isActive,burstKey:c.cycle,triggerFireworks:y,dismissFireworks:m},e[9]=c.cycle,e[10]=c.isActive,e[11]=y,e[12]=b):b=e[12],b};function rI(t){return t.isActive?{...t,isActive:!1}:t}function oI(t){return{isActive:!0,cycle:t.cycle+1}}function iI(t){return t.isActive?{...t,isActive:!1}:t}const Bh=l.createContext(void 0),aI=t=>{const e=Xe.c(10),{children:s}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:c}=nI();let a;e[0]!==c||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:c},e[0]=c,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=n.jsx(tI,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let f;return e[6]!==s||e[7]!==u||e[8]!==d?(f=n.jsxs(Bh.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f},BT=()=>{const t=l.useContext(Bh);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},za="openchamber_requests_in_flight",Fh=1e3,lI=300*1e3,Vo=Math.ceil(lI/Fh),cI=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(za)==="1"}catch{return!1}},Lh=()=>({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 dI=1;const uI=(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))},fI=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},_h=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),s=[];for(const r of t.inFlightStarts.values())s.push(Math.max(0,e-r));return s.sort((r,i)=>r-i),s},nr=(t,e)=>{const s=t.length;if(s===0)return 0;if(s===1)return t[0];const r=e/100*(s-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},pI=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const s=async(r,i)=>{const o=dI++;uI(o,Date.now());try{return await e(r,i)}finally{fI(o)}};window.fetch=s},nu=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},yr=t=>{t.length>Vo&&t.splice(0,t.length-Vo)},hI=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=_h(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(nr(e,50)),t.p90Samples.push(nr(e,90)),t.p99Samples.push(nr(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,yr(t.samples),yr(t.p50Samples),yr(t.p90Samples),yr(t.p99Samples),yr(t.maxSamples),t.lastSampleAt=Date.now()},mI=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(hI,Fh))},ru=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},ou=t=>{if(!(typeof window>"u"))try{if(t){ru(),nu(),window.localStorage.setItem(za,"1"),window.__openchamberRequestsInFlight__=Lh(),pI(),mI();return}window.localStorage.removeItem(za),ru(),nu(),delete window.__openchamberRequestsInFlight__}catch{}},FT=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Lh();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},LT=()=>{if(typeof window>"u")return iu();const t=window.__openchamberRequestsInFlight__;if(!cI()||!t)return iu();const e=_h(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:nr(e,50),ageP90:nr(e,90),ageP99:nr(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:Vo}},iu=()=>({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:Vo}),gI=()=>{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()??"":""},bI=async()=>{const t=gI()||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")},au="openchamber:menu-action",ea="openchamber:check-for-updates",yI=t=>{const e=xt(b=>b.openNewSessionDraft),s=de(b=>b.toggleCommandPalette),r=de(b=>b.setCommandPaletteOpen),i=de(b=>b.toggleHelpDialog),o=de(b=>b.toggleSidebar),c=de(b=>b.setSessionSwitcherOpen),a=de(b=>b.setSettingsDialogOpen),d=de(b=>b.setAboutDialogOpen),u=wr(b=>b.checkForUpdates),{setThemeMode:f}=dr(),p=l.useRef(!1),m=l.useCallback(()=>{p.current||(p.current=!0,u().then(()=>{const{available:b,error:h}=wr.getState();if(h){ze.error("Failed to check for updates",{description:h});return}b||ze.success("You are on the latest version")}).finally(()=>{p.current=!1}))},[u]),g=l.useCallback(()=>{En.requestDirectoryDialog()},[]),y=l.useCallback(b=>{const h=RS();if(h.length===0)return;const S=xt.getState().currentSessionId,w=h.findIndex(T=>T.id===S);let j=b>0?0:h.length-1;w>=0&&(j=(w+b+h.length)%h.length);const k=h[j];k&&(c(!1),xt.getState().setCurrentSession(k.id))},[c]),v=l.useCallback(b=>{const{activeProjectId:h,projects:S,setActiveProject:w}=ns.getState();if(S.length===0)return;const j=S.findIndex(O=>O.id===h);let k=b>0?0:S.length-1;j>=0&&(k=(j+b+S.length)%S.length);const T=S[k];T&&w(T.id)},[]),x=l.useCallback(b=>{switch(b){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":s();break;case"quick-open":r(!0);break;case"new-session":c(!1);{const h=xt.getState(),S=xs.getState().currentDirectory;e(h.currentSessionId&&S?{directoryOverride:S}:void 0)}break;case"new-worktree-session":c(!1),AS();break;case"change-workspace":g();break;case"toggle-right-sidebar":{const h=xs.getState().currentDirectory;if(!h)break;const S=de.getState(),w=Ps(h),j=S.contextPanelByDirectory[w],k=j?ig(j.tabs,S.contextSurfaceZones,"right",qo(j,"right").activeTabId):null;j?.isOpen?S.closeContextPanel(w):k?S.setActiveContextPanelTab(w,k):S.openContextSurface(w,"git");break}case"open-right-sidebar-git":{const h=xs.getState().currentDirectory;if(!h)break;de.getState().openContextSurface(Ps(h),"git");break}case"open-right-sidebar-files":{const h=xs.getState().currentDirectory;if(!h)break;de.getState().openContextSurface(Ps(h),"file");break}case"toggle-terminal":{const h=xs.getState().currentDirectory;if(!h)break;de.getState().openContextSurface(Ps(h),"terminal");break}case"toggle-terminal-expanded":{const h=xs.getState().currentDirectory;if(!h)break;const S=Ps(h),w=de.getState(),j=w.contextPanelByDirectory[S];Ha(j,w.contextSurfaceZones).has("terminal")||w.openContextSurface(S,"terminal"),w.toggleContextPanelExpanded(S,Po(w.contextSurfaceZones,"terminal"));break}case"copy":{const h=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(h)||bI();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":MS();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":Tc(-1);break;case"go-forward":Tc(1);break;case"previous-session":y(-1);break;case"next-session":y(1);break;case"previous-project":v(-1);break;case"next-project":v(1);break;case"help-dialog":i();break;case"download-logs":{NS().catch(()=>{ze.error("Failed to collect OpenCode status")});break}}},[g,v,y,t,e,d,c,r,a,f,s,i,o]);l.useEffect(()=>{const b=S=>{const w=S.detail;w&&x(w)},h=()=>{m()};return window.addEventListener(au,b),window.addEventListener(ea,h),()=>{window.removeEventListener(au,b),window.removeEventListener(ea,h)}},[x,m]),l.useEffect(()=>{if(typeof window>"u")return;const h=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof h!="function")return;let S=null,w=null;return h("openchamber:menu-action",j=>{const k=j?.payload;typeof k=="string"&&x(k)}).then(j=>{S=j}).catch(()=>{}),h("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(ea))}).then(j=>{w=j}).catch(()=>{}),()=>{(async()=>{try{const k=S?.();k instanceof Promise&&await k}catch{}try{const k=w?.();k instanceof Promise&&await k}catch{}})()}},[x])},xI="openchamber:tray-action",SI=5e3,vI=500,wI=20,lu=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},cu=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,$h=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},zh=t=>t.title.trim()||"Question",kI=new Set,jI=(t,e)=>dl(t,e,kI,Gf.getState().rankById),CI=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},PI=(t,e,s,r,i)=>{if(!t)return"";const o=Lu(s,r,t),c=e.project?.name,a=o?.label?.trim()||c?.trim()||CI(t),d=po(t);let u=d&&i.get(d)||"";if(!u){for(const[f,p]of kn.getState().directories)if(po(f)===d){u=p.status?.current??"";break}}if(!u)for(const f of r.values()){const p=f.find(m=>po(m.path)===d);if(p?.branch){u=p.branch;break}}return u?`${a} · ${u}`:a},EI=()=>{const{results:t,dropdownProviderIds:e,displayMode:s}=Gn.getState(),r=s==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(c=>[c.providerId,c])),o=[];for(const c of BS){if(!e.includes(c.id))continue;const a=i.get(c.id);if(!a||a.configured!==!0)continue;const d=[];for(const[f,p]of Object.entries(a.usage?.windows??{})){const m=r==="remaining"?p.remainingPercent:p.usedPercent;d.push({label:LS(f),value:FS(p.valueLabel,m)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:c.name,rows:d,status:u})}return{mode:r,groups:o}},II=async()=>{try{if(Qo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=ag();if(e&&ec(e,t))return"Local OpenChamber";const r=(await Zo()).hosts.find(i=>e?ec(e,Cu(i)):!1);return r?.label?.trim()?Su(r.label.trim()):"Instance"}catch{return""}},TI=()=>{const t=new Map,e=new Map,s=[],r=new Map;let i;try{i=ha()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[o,c]of i.children.entries()){const a=c.getState();a.vcs?.branch&&e.set(po(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const f=u?.type,p=f==="busy"?"busy":f==="retry"?"retry":"idle",m=t.get(d);(!m||m==="idle")&&t.set(d,p)}for(const[d,u]of Object.entries(a.permission??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||d;s.push({kind:"permission",id:f.id,sessionId:p,sessionTitle:"",label:$h(f),directory:o,canSave:qf(f.save)})}for(const[d,u]of Object.entries(a.form??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||d;s.push({kind:"form",id:f.id,sessionId:p,sessionTitle:"",label:zh(f),directory:o,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},DI=(t,e)=>{const s=Hf.getState().index.session,r=Es.getState().activeSessions,i=new Map;for(const h of r)if(h?.id&&h.parentID){const S=i.get(h.parentID)??[];S.push(h.id),i.set(h.parentID,S)}const o=h=>{const S=[],w=[...i.get(h)??[]],j=new Set;for(;w.length;){const k=w.pop();j.has(k)||(j.add(k),S.push(k),w.push(...i.get(k)??[]))}return S},c=de.getState();let a=0;if(c.dockBadgeEnabled)for(const h of r){if(!h?.id||h.parentID)continue;let S=s.unseenCount[h.id]??0;S===0&&c.notifyOnSubtasks&&(S=o(h.id).reduce((w,j)=>w+(s.unseenCount[j]??0),0)),S>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=TI(),u=new Map(d.titleById);for(const h of r)h?.id&&h.title&&u.set(h.id,h.title);const f=Vf.getState().statusById,p=h=>{const S=d.statusById.get(h);return S&&S!=="idle"?S:f.get(h)?.status.type??S??"idle"},m=h=>{const S=h.map(w=>p(w));return S.includes("busy")?"busy":S.includes("retry")?"retry":"idle"},g=ns.getState().projects,y=xt.getState().availableWorktreesByProject,v=r.filter(h=>h?.id&&!h.parentID).slice().sort(jI).slice(0,wI).map(h=>{const S=[h.id,...o(h.id)],w=or(h)??"";return{id:h.id,title:h.title||"Untitled session",status:m(S),branch:w?d.branchByDirectory.get(w)??"":"",unseen:S.reduce((j,k)=>j+(s.unseenCount[k]??0),0),hasError:S.some(j=>s.unseenHasError[j]??!1),directory:w,subtitle:PI(w,h,g,y,d.branchByDirectory)}}),x=d.approvals.map(h=>({...h,sessionTitle:u.get(h.sessionId)||""})),b=new Set(x.map(h=>h.id));for(const[h,S]of Uf.getState().bySession){const w=u.get(h)||"";for(const j of S.permissions)b.has(j.id)||(b.add(j.id),x.push({kind:"permission",id:j.id,sessionId:h,sessionTitle:w,label:$h(j),directory:S.directory,canSave:qf(j.save)}));for(const j of S.forms)b.has(j.id)||(b.add(j.id),x.push({kind:"form",id:j.id,sessionId:h,sessionTitle:w,label:zh(j),directory:S.directory,canSave:!1}))}return{sessions:v,approvals:x,instanceName:t,usage:EI(),dockBadgeCount:a}},RI=()=>{l.useEffect(()=>{if(!lu()||!wo())return;const t=cu();let e=!1,s="",r=null,i="";const o=()=>{if(e)return;const k=DI(i,t),T=JSON.stringify(k);T!==s&&(s=T,vn("desktop_tray_update",k))},c=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},vI))},a=Hf.subscribe(()=>c()),d=Es.subscribe(()=>c()),u=de.subscribe((k,T)=>{(k.dockBadgeEnabled!==T.dockBadgeEnabled||k.notifyOnSubtasks!==T.notifyOnSubtasks)&&c()}),f=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),f;II().then(k=>{e||(i=k,o())});const p=new Map,m=()=>{if(e)return;let k;try{k=ha()}catch{return}const T=new Set;for(const[O,$]of k.children.entries())T.add(O),p.has(O)||p.set(O,$.subscribe(()=>c()));for(const[O,$]of p)T.has(O)||($(),p.delete(O))};let g=null;try{g=ha().subscribeRegistry(()=>{m(),c()})}catch{}m();const y=ns.subscribe(()=>c()),v=xt.subscribe(()=>c()),x=kn.subscribe(()=>c()),b=Vf.subscribe(()=>c()),h=Uf.subscribe(()=>c()),S=Gf.subscribe(()=>c()),w=Gn.subscribe(()=>c());Gn.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:k,results:T}=Gn.getState();k.length>0&&k.some($=>!T.some(D=>D.providerId===$))&&Gn.getState().fetchQuotas(k)});const j=window.setInterval(()=>{m(),o()},SI);return o(),()=>{f(),window.clearInterval(j),y(),v(),x(),b(),h(),S(),w(),g?.();for(const k of p.values())k();p.clear()}},[]),l.useEffect(()=>{if(!lu()||!cu()||!wo())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=i=>{i.type==="respond-permission"&&OS(i.sessionId,i.id,i.response).catch(()=>{ze.error("Failed to respond to permission request")})};let r=null;return e(xI,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||s(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},NI=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,MI=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,AI=t=>{t.kind!=="plugin"||!t.title||ze.info(t.title,{id:MI(t.kind,t.title,t.body,t.tag),description:t.body})},OI=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,BI=t=>{const e=Xe.c(3),s=!0;let r,i;e[0]!==s?(r=()=>{if(!(un()||!Pu()||!globalThis.window))return Pn(FI)},i=[s],e[0]=s,e[1]=r,e[2]=i):(r=e[1],i=e[2]),l.useEffect(r,i)};function FI(t){if(t.type!=="notification")return;const e=de.getState();if(!e.nativeNotificationsEnabled)return;const s=NI();if(OI(t.payload,s)){AI(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&s)return;ju()?.notifications?.notifyAgentCompletion(t.payload)}const LI=()=>{const t=Xe.c(4),{t:e}=Ct(),s=de(_I);let r,i;t[0]!==s||t[1]!==e?(r=()=>Pn(o=>{o.type==="browser-provider-reset"&&(s("builtin"),ze.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[s,e],t[0]=s,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),l.useEffect(r,i)};function _I(t){return t.setBrowserProvider}const du="relay-limit-reached",$I=()=>{const t=Xe.c(3),{t:e}=Ct();let s,r;t[0]!==e?(s=()=>{const i=()=>{ze.error(e("relayConnection.limitReached.title"),{id:du,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:zI}})};return tc(Eu()?.getStatus())&&i(),lg(c=>{tc(c)?i():(c.state==="connected"||c.state==="idle")&&ze.dismiss(du)})},r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),l.useEffect(s,r)};function zI(){return Eu()?.retry()}const uu=()=>{cg()||(Lb(),_S(_b.map(t=>t.id)))},KI=(t,e)=>{const s=Xe.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const c=window.requestIdleCallback(uu,{timeout:1e4});return()=>window.cancelIdleCallback(c)}const o=setTimeout(uu,3e3);return()=>clearTimeout(o)},s[0]=t,s[1]=r):r=s[1];let i;s[2]!==e||s[3]!==t?(i=[t,e],s[2]=e,s[3]=t,s[4]=i):i=s[4],l.useEffect(r,i)},fu="pwa-install-toast-shown",pu="pwa-install-toast-dismissed",WI=()=>{const t=Xe.c(6),{browserTab:e}=$b(),{t:s}=Ct(),r=l.useRef(s);let i,o;t[0]!==s?(i=()=>{r.current=s},o=[s],t[0]=s,t[1]=i,t[2]=o):(i=t[1],o=t[2]),l.useEffect(i,o);let c,a;t[3]!==e?(c=()=>{if(typeof window>"u"||!Pu()||!e)return;let d=null,u=null;const f=()=>{u!==null&&(ze.dismiss(u),u=null)},p=async()=>{if(!d)return;const y=d;d=null,f(),await y.prompt();const{outcome:v}=await y.userChoice;v==="accepted"&&ze.success(r.current("pwa.installPrompt.started"))},m=y=>{const v=y;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const x=Eo(),b=dg();zb({dismissed:x.getItem(pu),sessionShown:b.getItem(fu),hasActiveToast:u!==null})&&(b.setItem(fu,"true"),u=ze.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{p()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Eo().setItem(pu,"true"),f()}}}))},g=()=>{d=null,f(),ze.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",m),window.addEventListener("appinstalled",g),()=>{f(),window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",g)}},a=[e],t[3]=e,t[4]=c,t[5]=a):(c=t[4],a=t[5]),l.useEffect(c,a)},HI=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",Kh=async(t,e)=>{const s=(await Zo()).hosts.find(i=>i.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await hg(s.id,e);return}const r=mg(Cu(s));if(!r)throw new Error("host-not-found");gg({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:bg(s),sshForwarded:s.sshForwarded===!0})},VI=async t=>{const e=await Zo(),s=await fg(t,e.hosts);await pg({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:!0}),await Kh(s.hostId,{reconnectActive:!0})},UI=async t=>{const e=await ug();for(const s of e)try{s.type==="pairing"?await VI(s.link):await Kh(s.hostId)}catch(r){const i=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,i),t(HI(i))}},Ka="project-config-invalid",GI=()=>{const t=Xe.c(9),{t:e}=Ct(),s=is(qI);let r;t[0]!==s?(r=m=>m.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const i=is(r),[o,c]=fs.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const m=is.getState(),g=m.activeDirectoryKey;c(!0),Promise.all([m.loadProviders({directory:g,source:"projectConfigError:retry"}),m.loadAgents({directory:g,source:"projectConfigError:retry"})]).finally(()=>c(!1))},t[2]=a):a=t[2];const d=a;let u,f;t[3]!==i||t[4]!==o||t[5]!==e?(u=()=>{if(!i){ze.dismiss(Ka);return}ze.error(e("projectConfigError.toast.title"),{id:Ka,duration:1/0,description:n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[n.jsx("span",{className:"break-all font-mono typography-meta",children:i.path??e("projectConfigError.toast.unknownFile")}),i.message&&n.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:i.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(o?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:m=>{m.preventDefault(),o||d()}}})},f=[i,o,d,e],t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=f):(u=t[6],f=t[7]),fs.useEffect(u,f);let p;return t[8]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[8]=p):p=t[8],fs.useEffect(XI,p),null};function qI(t){return t.activeDirectoryKey}function YI(){ze.dismiss(Ka)}function XI(){return YI}const QI="\x1B",ZI=new RegExp(`${QI}\\[[0-9;?]*[ -/]*[@-~]`,"g"),co=Ks().transform(t=>t.replace(ZI,"").trim()).nullish(),JI=ya({isOpenCodeReady:Nc().optional(),openCodeRunning:Nc().optional(),lastOpenCodeError:co,opencodeBinaryResolved:co,lastOpenCodeLaunchDiagnostics:ya({sourceBinary:co,binary:co}).nullish()}),eT=async(t,e=Gs)=>{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=JI.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}},tT=(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"}},sT=ya({openchamberVersion:Ks()}),nT=async(t,e=Gs)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=sT.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},rT=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function oT({version:t}){const{t:e}=Ct(),[s,r]=l.useState({kind:"idle"}),i=async()=>{r({kind:"checking"});try{const a=await Kb();r(a.available&&!a.installBlocked?{kind:"available",info:a}:{kind:"manual",info:a,error:null})}catch(a){r({kind:"manual",info:null,error:a instanceof Error?a.message:null})}},o=s.kind==="manual"?s:null,c=o?.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(It,{type:"button",onClick:()=>{i()},disabled:s.kind==="checking",children:[n.jsx(Q,{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")]}),o&&n.jsxs("div",{className:"w-full space-y-2 text-start",children:[!o.info?.available&&n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),o.error&&n.jsx("p",{className:"typography-meta text-muted-foreground",children:o.error}),o.info?.installBlocked==="desktop-host"?n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:o.info.version||""})}):n.jsxs(n.Fragment,{children:[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:c})]})]}),n.jsx(Ya,{open:s.kind==="available",onOpenChange:a=>{a||r({kind:"idle"})},info:s.kind==="available"?s.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const hu=Br(()=>os(()=>import("./OnboardingScreen-BDT-J2JP.js"),__vite__mapDeps([169,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])).then(t=>({default:t.OnboardingScreen}))),iT=()=>os(()=>import("./AboutDialog-Ctk2zvrv.js"),__vite__mapDeps([170,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])).then(t=>t.AboutDialog),aT=()=>os(()=>import("./MemoryDebugPanel-caUWOKiz.js"),__vite__mapDeps([171,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,122,123,124])).then(t=>t.MemoryDebugPanel),lT=()=>{const t=Xe.c(6),e=de(pT),s=de(hT);let r;t[0]!==s?(r=()=>s(!1),t[0]=s,t[1]=r):r=t[1];const i=di(e,iT,r);if(!i)return null;let o;return t[2]!==i||t[3]!==e||t[4]!==s?(o=n.jsx(i,{open:e,onOpenChange:s}),t[2]=i,t[3]=e,t[4]=s,t[5]=o):o=t[5],o},cT=t=>{const e=Xe.c(3),{onClose:s}=t,r=di(!0,aT,s);let i;return e[0]!==r||e[1]!==s?(i=r?n.jsx(r,{onClose:s}):null,e[0]=r,e[1]=s,e[2]=i):i=e[2],i},dT=t=>{const e=Xe.c(47),{onRetry:s,isRetrying:r}=t,{t:i}=Ct(),[o,c]=l.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const $=new AbortController,D=Xt(),E=setTimeout(()=>$.abort(),5e3);return eT($.signal).then(R=>{!$.signal.aborted&&Xt()===D&&c(R)}).catch(mT).finally(()=>clearTimeout(E)),()=>{$.abort(),clearTimeout(E)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),l.useEffect(a,d);const[u,f]=l.useState(null);let p,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const $=new AbortController,D=Xt(),E=setTimeout(()=>$.abort(),5e3);return nT($.signal).then(R=>{$.signal.aborted||Xt()!==D||f(R&&rT(R)?R:null)}).catch(gT).finally(()=>clearTimeout(E)),()=>{$.abort(),clearTimeout(E)}},m=[],e[2]=p,e[3]=m):(p=e[2],m=e[3]),l.useEffect(p,m);const g=is(bT),y=o?null:g?.message??null;if(u){let $;e[4]!==u?($=n.jsx(oT,{version:u}),e[4]=u,e[5]=$):$=e[5];let D;e[6]!==r||e[7]!==i?(D=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=i,e[8]=D):D=e[8];let E;e[9]!==r||e[10]!==s||e[11]!==D?(E=n.jsx(It,{type:"button",variant:"outline",onClick:s,disabled:r,children:D}),e[9]=r,e[10]=s,e[11]=D,e[12]=E):E=e[12];let R;return e[13]!==$||e[14]!==E?(R=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:[$,E]})}),e[13]=$,e[14]=E,e[15]=R):R=e[15],R}let v;e[16]!==i?(v=i("startup.initRecovery.title"),e[16]=i,e[17]=v):v=e[17];let x;e[18]!==v?(x=n.jsx("h1",{className:"typography-title text-foreground",children:v}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==o||e[21]!==g||e[22]!==i?(b=i(tT(o,g)),e[20]=o,e[21]=g,e[22]=i,e[23]=b):b=e[23];let h;e[24]!==b?(h=n.jsx("p",{className:"typography-body text-muted-foreground",children:b}),e[24]=b,e[25]=h):h=e[25];let S;e[26]!==x||e[27]!==h?(S=n.jsxs("div",{className:"flex flex-col gap-2",children:[x,h]}),e[26]=x,e[27]=h,e[28]=S):S=e[28];let w;e[29]!==y||e[30]!==i?(w=y&&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:i("startup.initRecovery.lastError")}),n.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:y})]}),e[29]=y,e[30]=i,e[31]=w):w=e[31];let j;e[32]!==o||e[33]!==i?(j=o&&n.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[o.binary&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),n.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),n.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[32]=o,e[33]=i,e[34]=j):j=e[34];let k;e[35]!==r||e[36]!==i?(k=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=i,e[37]=k):k=e[37];let T;e[38]!==r||e[39]!==s||e[40]!==k?(T=n.jsx(It,{type:"button",onClick:s,disabled:r,children:k}),e[38]=r,e[39]=s,e[40]=k,e[41]=T):T=e[41];let O;return e[42]!==w||e[43]!==j||e[44]!==T||e[45]!==S?(O=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:[S,w,j,T]})}),e[42]=w,e[43]=j,e[44]=T,e[45]=S,e[46]=O):O=e[46],O};function uT({apis:t}){l.useEffect(()=>{yg("App:mounted"),xg()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=is(M=>M.initializeApp),s=is(M=>M.isInitialized),r=is(M=>M.isConnected),i=is(M=>M.providersLoaded),o=is(M=>M.agentsLoaded),c=is(M=>M.loadProviders),a=is(M=>M.loadAgents),d=xt(M=>M.error),u=xt(M=>M.clearError),f=xs(M=>M.currentDirectory),p=xs(M=>M.isSwitchingDirectory),[m,g]=l.useState(!1),y=wn(M=>M.refreshAll),v=$S(M=>M.refreshStatus),[x,b]=l.useState(()=>t.runtime.isVSCode),[h,S]=l.useState(!1),[w,j]=l.useState(0),[k,T]=l.useState(0),[O,$]=l.useState(!1),D=de(M=>M.wideChatLayoutEnabled),E=de(M=>M.mobileKeyboardMode),R=l.useMemo(()=>un(),[]),[z,_]=l.useState(()=>sc()),[W,N]=l.useState(()=>{const M=Ei();return M!==null?nc({isDesktopShell:!0,bootOutcome:M}):null}),Y=l.useRef(!1),{t:C}=Ct(),P=l.useRef(!1);l.useEffect(()=>{if(!s||z!=="valid"||P.current)return;const M=Ei();M?.target!=="local"||M.status!=="ok"||!M.sshStartupFallbackHostId||(P.current=!0,ze.error(C("desktopHostSwitcher.startup.title"),{description:C("desktopHostSwitcher.startup.fellBackToLocal")}))},[z,s,C]),l.useEffect(()=>(rc(m),ou(m),()=>{rc(!1),ou(!1)}),[m]),l.useEffect(()=>{Sg(E)},[E]),l.useEffect(()=>{b(t.runtime.isVSCode)},[t.runtime.isVSCode]),l.useEffect(()=>Go(M=>{Hb(M)&&Vb(M),T(ee=>ee+1),S(!1),j(ee=>ee+1)}),[]);const I=Dc(M=>{const ee=Xt();return Object.values(M.runsByOriginalSessionID).filter(V=>V.status==="running"&&V.runtimeKey===ee).map(V=>`${V.originalSessionID}:${V.phase}:${V.lastForwardedMessageID??""}:${V.expectedAssistantParentID??""}`).sort().join("|")});l.useEffect(()=>{const M=Xt(),ee=Object.values(Dc.getState().runsByOriginalSessionID).filter(V=>V.status==="running"&&V.runtimeKey===M);for(const V of ee)zS(V.originalSessionID)},[I,k]),l.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",D),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[D]),l.useEffect(()=>(oc(t),()=>oc(null)),[t]),l.useEffect(()=>{r&&(y(t.sourceControl,{force:!0}),v(t.linear,{force:!0}))},[t.sourceControl,t.linear,r,y,v,k]),KS();const H=z==="valid",A=W?.screen==="main";l.useEffect(()=>{if(!vg({isDesktopShell:R,bootOutcomeKnown:H}))return;WS();const M=setTimeout(()=>{const ee=document.getElementById("initial-loading");ee&&(ee.classList.add("fade-out"),setTimeout(()=>{ee.remove()},300))},150);return()=>clearTimeout(M)},[R,H]),l.useEffect(()=>{if(!R||z!=="malformed")return;const M=document.getElementById("initial-loading");M&&(M.textContent="Desktop startup failed — please restart the app.")},[R,z]),l.useEffect(()=>{x||e()},[e,x]),l.useEffect(()=>{if(x||s)return;let M=!0,ee,V=0;const Ee=10,ve=1e3,ce=async()=>{if(!M)return;if(V>=Ee){S(!0);return}const Be=is.getState();if(Be.isInitialized){S(!1);return}V+=1,await Be.initializeApp();const me=is.getState();if(!M)return;if(me.isInitialized){S(!1);return}if(V>=Ee){S(!0);return}const he=Math.min(ve*Math.pow(2,V-1),4e3);ee=setTimeout(ce,he)};return ee=setTimeout(ce,ve),()=>{M=!1,ee&&clearTimeout(ee)}},[w,s,x]),l.useEffect(()=>{s&&S(!1)},[s]),l.useEffect(()=>{if(!h)return;const M=document.getElementById("initial-loading");M&&(M.classList.add("fade-out"),setTimeout(()=>{M.remove()},300))},[h]),l.useEffect(()=>{if(x||!r||i&&o)return;let M=!0,ee=0;const V=15,Ee=async()=>{const ce=is.getState();if(!(ce.providersLoaded&&ce.agentsLoaded))try{ce.providersLoaded||await c({source:"startupRecovery"}),is.getState().agentsLoaded||await a({source:"startupRecovery"})}catch{}};Ee();const ve=setInterval(()=>{if(M){if(++ee>=V){clearInterval(ve);return}Ee()}},2e3);return()=>{M=!1,clearInterval(ve)}},[r,x,a,c,i,o]),l.useEffect(()=>{p||x||r&&Co.setDirectory(f)},[f,p,r,x]),l.useEffect(()=>{if(typeof window>"u")return;const M=ee=>{const V=ee.detail,Ee=typeof V?.sessionId=="string"?V.sessionId.trim():"";if(!Ee)return;const ve=typeof V?.directory=="string"&&V.directory.trim().length>0?V.directory.trim():null,ce=String(V?.runtimeKey??"").trim();if(!(ce&&ce!==Xt()&&Cg(ce,Ee))){if(!ve){Rc(Ee,typeof V?.messageId=="string"?V.messageId.trim():null);return}xt.getState().setCurrentSession(Ee,ve)}};return window.addEventListener("openchamber:open-session",M),wg().then(ee=>{for(const V of ee)Rc(V.sessionId,V.messageId)}),()=>window.removeEventListener("openchamber:open-session",M)},[]),l.useEffect(()=>{if(!un())return;const M=()=>{UI(ee=>{ze.error(C(ee==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":ee==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",M),M(),()=>window.removeEventListener("openchamber:host-actions-ready",M)},[C]);const F=l.useRef({attempt:null,running:!1,done:!1});l.useLayoutEffect(()=>{const M=F.current;M.attempt||(M.attempt=Ub({selectNow:!Gb().sessionId}))},[]),l.useEffect(()=>{const M=F.current,ee=()=>{const V=M.attempt;if(!V||M.running||M.done)return;const Ee=is.getState().isInitialized;M.running=!0,V().then(ve=>{if(M.running=!1,ve!=="failed"||Ee){M.done=!0;return}is.getState().isInitialized&&ee()})};ee()},[s]),l.useEffect(()=>{if(typeof window>"u")return;const M=()=>{vn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Sr()})};return window.addEventListener("openchamber:open-mini-chat",M),()=>window.removeEventListener("openchamber:open-mini-chat",M)},[]),l.useEffect(()=>{if(typeof window>"u")return;const M=()=>{const ee=xt.getState().currentSessionId;ee&&Sf(ee)};return window.addEventListener("focus",M),()=>window.removeEventListener("focus",M)},[]),l.useEffect(()=>{if(typeof window>"u")return;const M=ee=>{const V=ee.detail,Ee=typeof V?.directory=="string"&&V.directory.trim().length>0?V.directory.trim():null,ve=typeof V?.projectId=="string"&&V.projectId.trim().length>0?V.projectId.trim():null,ce=!!(Ee||ve);de.getState().setSessionSwitcherOpen(!1),xt.getState().openNewSessionDraft({target:ce?"project":"chat",selectedProjectId:ce?ve:null,directoryOverride:ce?Ee:null,preserveDirectoryOverride:!!Ee})};return window.addEventListener("openchamber:open-draft-session",M),()=>window.removeEventListener("openchamber:open-draft-session",M)},[]),l.useEffect(()=>{typeof window>"u"||!s||p||Y.current||(Y.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,p]),HS(),BI(),qb(f||null),LI(),VS(),Yb(),$I(),KI(s&&r,k),WI(),US(),u1(),Xb();const L=l.useCallback(()=>{g(M=>!M)},[]);yI(L),RI(),f1(!0),l.useEffect(()=>{const M=()=>g(ee=>!ee);return window.addEventListener("openchamber:memory-debug-toggle",M),()=>window.removeEventListener("openchamber:memory-debug-toggle",M)},[]),l.useEffect(()=>{d&&setTimeout(()=>u(),5e3)},[u,d]),l.useEffect(()=>{if(!R||z!=="not-injected")return;let M=!1,ee=0;const V=200,Ee=2e3,ve=50,ce=()=>{if(M)return;ee++;const Be=sc();if(Be!=="not-injected"){if(M=!0,_(Be),Be==="valid"){const he=Ei();he&&N(nc({isDesktopShell:!0,bootOutcome:he}))}return}const me=Math.min(V*Math.pow(1.1,ee),Ee);if(ee>=ve){const he=document.getElementById("initial-loading");he&&!he.textContent?.includes("taking longer")&&(he.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(ce,me)};return window.setTimeout(ce,V),()=>{M=!0}},[R,z]);const X=l.useCallback(async()=>{if(kg({isDesktopShell:un(),isDesktopLocalOriginActive:Qo()})){await jg();return}window.location.reload()},[]),re=l.useCallback(async()=>{if(!O){S(!1),$(!0);try{await is.getState().initializeApp()}finally{$(!1)}is.getState().isInitialized||j(M=>M+1)}},[O]),te=M=>{if(M.screen==="recovery")return M.variant};if(R&&W&&W.screen!=="main"){if(W.screen==="chooser")return n.jsx(ws,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(l.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(hu,{mode:"first-launch",localAvailable:W.localAvailable!==!1,onCliAvailable:X,onChooseRemote:()=>{}})})})});const M=te(W),ee=W.screen==="recovery"&&"url"in W?W.url:void 0,V=W.screen==="recovery"&&"hostId"in W?W.hostId:void 0;return n.jsx(ws,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(l.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(hu,{mode:"recovery",recoveryVariant:M,recoveryHostUrl:ee,recoveryHostLabel:void 0,recoveryHostId:V,localAvailable:W.localAvailable!==!1,onCliAvailable:X})})})})}return h&&!s&&!x?n.jsx(ws,{children:n.jsx(dT,{onRetry:()=>{re()},isRetrying:O},k)}):n.jsx(ws,{children:n.jsx(GS,{sdk:Co.getSdkClient(),directory:f||"",children:n.jsx(qS,{apis:t,children:n.jsx(aI,{children:n.jsx(oi,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:R?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(YS,{backgroundWorkEnabled:!0}),n.jsx(Qb,{}),n.jsx(GI,{}),n.jsx(yE,{}),R?n.jsx(Zb,{ready:H&&A}):null,n.jsx(XS,{}),n.jsx(QS,{}),n.jsx(ZS,{}),n.jsx(Jb,{}),n.jsx(lT,{}),m&&n.jsx(cT,{onClose:()=>g(!1)})]})})})})},k)})}function fT(t){const e=Xe.c(2);let s;return e[0]!==t?(s=n.jsx(Wb,{children:n.jsx(uT,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function pT(t){return t.isAboutDialogOpen}function hT(t){return t.setAboutDialogOpen}function mT(){}function gT(){}function bT(t){return t.lastInitFailure}const yT=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Pg();ey();ty();Eg().then(()=>{JS().catch(t=>{console.error("[main] settings init failed:",t)}),e1(),t1(),s1()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Wh=document.getElementById("root");if(!Wh)throw new Error("Root element not found");n1();Nm.createRoot(Wh).render(n.jsx(fs.StrictMode,{children:n.jsx(r1,{children:n.jsx(o1,{children:n.jsx(i1,{children:n.jsx(a1,{children:n.jsx(fT,{apis:yT})})})})})}));const _T=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Av as W,Rj as a,BT as b,LT as g,_T as m,FT as r,Tv as u,Dj as v};
|