@openchamber/web 1.18.4 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/assets/{CodeMirrorCommentWidgets-4qZbrEXU.js → CodeMirrorCommentWidgets-DAvopJvy.js} +1 -1
- package/dist/assets/{CommitSection-MJmntVPJ.js → CommitSection-D9cV-qR9.js} +1 -1
- package/dist/assets/{DiagramEditor-jnG3Hbxg.js → DiagramEditor-B9NCadU7.js} +1 -1
- package/dist/assets/DiagramView-LKGBwf4G.js +1 -0
- package/dist/assets/{DiffView-DZIoOnV7.js → DiffView-BWNq-0ov.js} +2 -2
- package/dist/assets/FilesView-DB-Q0Gkz.js +14 -0
- package/dist/assets/{GitView-DBFrDDBv.js → GitView-DsWXqWx3.js} +3 -3
- package/dist/assets/{JsonTreeView-DLW2Wy1g.js → JsonTreeView-h4dHASlq.js} +1 -1
- package/dist/assets/MarkdownImageGallery-n0ikH-xm.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +12 -0
- package/dist/assets/OnboardingScreen-CDjgzxEe.js +1 -0
- package/dist/assets/{PatchDiff-BuLPx7AN.js → PatchDiff-jPKTJje5.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BHm4Yr0X.js → PierreDiffViewer-D_Gt4A_6.js} +1 -1
- package/dist/assets/PlanView-UvuxIl9-.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +1 -0
- package/dist/assets/SettingsView-3B9VN6Ys.js +28 -0
- package/dist/assets/SettingsWindow-CqQNDKNd.js +1 -0
- package/dist/assets/{ToolOutputDialog-Za6V4VMJ.js → ToolOutputDialog-PmjlAxVE.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-BL-9ixyC.js → ToolPartDiffPreview-B34Xw9wq.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-CwGocYQd.js → VirtualizedFileDiff-B37yB9jZ.js} +3 -3
- package/dist/assets/{WalkthroughView-5DyvN03T.js → WalkthroughView-Bxun3k66.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-Da00Jg7M.js → computeVirtualFileMetrics-DYFv_yZS.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-BO1wRpaN.js +1 -0
- package/dist/assets/de-DbV6CLxv.js +9 -0
- package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
- package/dist/assets/es-CVDlyzZ4.js +15 -0
- package/dist/assets/fr-Czc-p0g-.js +13 -0
- package/dist/assets/index-1OhiMDBz.css +1 -0
- package/dist/assets/index-BSvmTvZl.js +1 -0
- package/dist/assets/index-DzriVon2.js +7 -0
- package/dist/assets/{isDiffPlainText-D9YpoLrV.js → isDiffPlainText-DwHKxDYc.js} +1 -1
- package/dist/assets/{isFilePlainText-gTibdNIe.js → isFilePlainText-Dwq6ILxo.js} +1 -1
- package/dist/assets/ja-dwc9NM_S.js +15 -0
- package/dist/assets/ko-Ds1DZ8FX.js +15 -0
- package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
- package/dist/assets/main-BF51IOVF.js +921 -0
- package/dist/assets/{main-D7UcL3VQ.js → main-D7UPARut.js} +2 -2
- package/dist/assets/markdownCore-BgeBDwD3.js +2 -0
- package/dist/assets/{miniChat-O_GVoEbc.js → miniChat-BISXSGOo.js} +2 -2
- package/dist/assets/mobile-BnYxVuvw.js +2 -0
- package/dist/assets/{patchFileDiff-KNkxM1C1.js → patchFileDiff-BEDPDypx.js} +2 -2
- package/dist/assets/pl-CLiTO7i-.js +15 -0
- package/dist/assets/pt-BR-GIimJgpK.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +2 -0
- package/dist/assets/{renderMobileApp-toj9cXoh.js → renderMobileApp-BiMbzPq9.js} +7 -7
- package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +15 -0
- package/dist/assets/scheduledTasksApi-01zzfzqH.js +1 -0
- package/dist/assets/{shikiHighlight-C7LTbwFx.js → shikiHighlight-DXYW46vW.js} +1 -1
- package/dist/assets/uk-DLfgD1ki.js +15 -0
- package/dist/assets/{useAppFontEffects-BikB6enL.js → useAppFontEffects-CbzHzFop.js} +139 -142
- package/dist/assets/{useInlineCommentController-CYPvYJDt.js → useInlineCommentController-CegKdDXi.js} +2 -2
- package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-BYlZTzrw.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +1 -0
- package/dist/assets/vendor-codemirror-commands-B7H_j0iU.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-angular-CgY7_gQ1.js → vendor-codemirror-lang-angular-DEPs2M5t.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-B5Ta4enQ.js → vendor-codemirror-lang-cpp-DhkseaMo.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-VgNqFSH-.js → vendor-codemirror-lang-css-O0cZX78y.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-LxLz62pp.js → vendor-codemirror-lang-go-fMdQYcON.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-html-CfgK872x.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-java-Bksi1PH4.js → vendor-codemirror-lang-java-CQj4S3zl.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js +13 -0
- package/dist/assets/{vendor-codemirror-lang-jinja-C7npuDD7.js → vendor-codemirror-lang-jinja-BmZZv8g-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-ryCw7nab.js → vendor-codemirror-lang-json-CMBS2tG9.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-BxsZJD6N.js → vendor-codemirror-lang-less-C6Eo8hVS.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-De6qch10.js → vendor-codemirror-lang-liquid-DSTR47-H.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-markdown-BPGOH9ye.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-php-Cm1es33p.js → vendor-codemirror-lang-php-DD9udfPH.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-N414WYK-.js → vendor-codemirror-lang-python-HahnQaAS.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-C_WuUStH.js → vendor-codemirror-lang-rust-nLTovbjv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-8UHTCAOM.js → vendor-codemirror-lang-sass-pL2Yc72v.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-CV3sMA5D.js → vendor-codemirror-lang-sql-BVBnan19.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-DzvC1Dhk.js → vendor-codemirror-lang-vue-BqGzJVm1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-jlr-LDdA.js → vendor-codemirror-lang-wast-B0_m5DqU.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-CrO63OVp.js → vendor-codemirror-lang-xml-Dj3voadT.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-dxi6CISW.js → vendor-codemirror-lang-yaml-yu-9Z5u7.js} +1 -1
- package/dist/assets/vendor-codemirror-language-BgPj_McA.js +3 -0
- package/dist/assets/{vendor-codemirror-language-data-CLHw8NWn.js → vendor-codemirror-language-data-CiAYDJXN.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +2 -0
- package/dist/assets/{vendor-codemirror-state-CNWM3Q8V.js → vendor-codemirror-state-C9awkmn-.js} +5 -5
- package/dist/assets/vendor-codemirror-view-CiLROUVV.js +4 -0
- package/dist/assets/vendor-replit-codemirror-vim-B2DJlAhT.js +6 -0
- package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
- package/dist/assets/vendor-zod-adaMkgkm.js +39 -0
- package/dist/assets/{web-components-GMc3oR3i.js → web-components-DCLjCO9n.js} +1 -1
- package/dist/assets/zh-CN-DkeP5awK.js +15 -0
- package/dist/assets/zh-TW-BocaFm3d.js +15 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/index.js +116 -3
- package/server/lib/agent-memory/actions.js +243 -0
- package/server/lib/agent-memory/actions.test.js +343 -0
- package/server/lib/agent-memory/feature-flag.js +19 -0
- package/server/lib/agent-memory/feature-flag.test.js +38 -0
- package/server/lib/agent-memory/project-resolution.js +56 -0
- package/server/lib/agent-memory/project-resolution.test.js +85 -0
- package/server/lib/agent-memory/routes.http.test.js +270 -0
- package/server/lib/agent-memory/routes.js +169 -0
- package/server/lib/agent-memory/runtime.js +427 -0
- package/server/lib/agent-memory/runtime.test.js +344 -0
- package/server/lib/agent-memory/threat-patterns.js +61 -0
- package/server/lib/agent-memory/threat-patterns.test.js +61 -0
- package/server/lib/agent-tool/DOCUMENTATION.md +14 -0
- package/server/lib/agent-tool/runtime.js +63 -13
- package/server/lib/agent-tool/runtime.test.js +85 -2
- package/server/lib/context-obligatory/runtime.js +34 -3
- package/server/lib/context-obligatory/runtime.test.js +114 -0
- package/server/lib/fs/DOCUMENTATION.md +3 -0
- package/server/lib/fs/routes.js +149 -32
- package/server/lib/fs/routes.test.js +225 -0
- package/server/lib/git/DOCUMENTATION.md +8 -0
- package/server/lib/git/service.js +121 -67
- package/server/lib/git/service.test.js +129 -0
- package/server/lib/github/DOCUMENTATION.md +14 -3
- package/server/lib/github/pr-status.js +188 -83
- package/server/lib/github/pr-status.test.js +182 -0
- package/server/lib/github/routes.js +36 -30
- package/server/lib/notifications/template-runtime.js +2 -3
- package/server/lib/openchamber-control/action-resolution.test.js +65 -0
- package/server/lib/openchamber-control/actions.js +78 -0
- package/server/lib/openchamber-control/service.js +7 -0
- package/server/lib/openchamber-sessions/routes.js +14 -0
- package/server/lib/opencode/DOCUMENTATION.md +6 -4
- package/server/lib/opencode/claude-cli-auth.js +60 -0
- package/server/lib/opencode/claude-cli-auth.test.js +54 -0
- package/server/lib/opencode/feature-routes-runtime.js +11 -0
- package/server/lib/opencode/plugins.js +12 -3
- package/server/lib/opencode/plugins.test.js +18 -0
- package/server/lib/opencode/proxy-agent-wiring.test.js +152 -0
- package/server/lib/opencode/proxy.js +116 -6
- package/server/lib/opencode/proxy.test.js +158 -1
- package/server/lib/opencode/routes.js +4 -1
- package/server/lib/opencode/settings-helpers.js +11 -0
- package/server/lib/opencode/settings-helpers.test.js +35 -0
- package/server/lib/opencode/settings-runtime.js +51 -0
- package/server/lib/opencode/shared.js +120 -16
- package/server/lib/opencode/shared.test.js +185 -1
- package/server/lib/project-context/DOCUMENTATION.md +158 -0
- package/server/lib/project-context/routes.http.test.js +264 -0
- package/server/lib/project-context/routes.js +237 -0
- package/server/lib/project-context/runtime.js +667 -0
- package/server/lib/project-context/runtime.test.js +498 -0
- package/server/lib/quota/DOCUMENTATION.md +16 -1
- package/server/lib/quota/providers/claude/auth.js +113 -0
- package/server/lib/quota/providers/claude/auth.test.js +117 -0
- package/server/lib/quota/providers/claude/index.js +151 -0
- package/server/lib/quota/providers/claude/index.test.js +147 -0
- package/server/lib/quota/providers/claude/transforms.js +127 -0
- package/server/lib/quota/providers/claude/transforms.test.js +82 -0
- package/server/lib/quota/providers/command-code.js +90 -0
- package/server/lib/quota/providers/command-code.test.js +72 -0
- package/server/lib/quota/providers/index.js +22 -2
- package/server/lib/quota/providers/index.test.js +10 -1
- package/server/lib/quota/utils/formatters.js +2 -1
- package/server/lib/scheduled-tasks/runtime.js +21 -2
- package/server/lib/session-knowledge/DOCUMENTATION.md +87 -0
- package/server/lib/session-knowledge/routes.js +107 -0
- package/server/lib/session-knowledge/runtime.js +331 -0
- package/server/lib/session-knowledge/runtime.test.js +275 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +22 -22
- package/server/lib/skills-catalog/curated-sources.js +1 -1
- package/server/lib/skills-catalog/curated-sources.test.js +10 -0
- package/server/lib/small-model/index.js +8 -0
- package/server/lib/small-model/index.test.js +31 -1
- package/server/lib/small-model/routes.js +3 -1
- package/dist/assets/DiagramView-CFXxgg_a.js +0 -1
- package/dist/assets/FilesView-BKL6YlKG.js +0 -14
- package/dist/assets/MarkdownImageGallery-DKIylIK7.js +0 -1
- package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +0 -12
- package/dist/assets/OnboardingScreen-D2Y6djMw.js +0 -1
- package/dist/assets/PlanView-ZYEJn8A_.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-rro-SsaO.js +0 -1
- package/dist/assets/SettingsView-5RmswFZe.js +0 -28
- package/dist/assets/SettingsWindow-BZhAYFdS.js +0 -1
- package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +0 -1
- package/dist/assets/de-u7gSnqWs.js +0 -9
- package/dist/assets/document-attachments-CX_YaDsu.js +0 -30
- package/dist/assets/es-T9O7aAOr.js +0 -15
- package/dist/assets/fr-Oor7ewbE.js +0 -13
- package/dist/assets/index-BzIpNlNE.css +0 -1
- package/dist/assets/index-C0yNhuZw.js +0 -1
- package/dist/assets/index-DRpChWux.js +0 -7
- package/dist/assets/ja-DHpqbVmr.js +0 -15
- package/dist/assets/ko-CwLkS3nx.js +0 -15
- package/dist/assets/main-DPMd2iKS.js +0 -915
- package/dist/assets/markdownCore-DDrHVneM.js +0 -2
- package/dist/assets/mobile-Br4TtAqc.js +0 -2
- package/dist/assets/pl-CcZILN8q.js +0 -15
- package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-CJpdxTT1.js +0 -2
- package/dist/assets/runtimeEndpointReset-BVmispdD.js +0 -13
- package/dist/assets/scheduledTasksApi-ByKya3Un.js +0 -1
- package/dist/assets/uk-BA2kZR38.js +0 -15
- package/dist/assets/vendor-codemirror-autocomplete-BjbBRsUA.js +0 -1
- package/dist/assets/vendor-codemirror-commands-ARAOgp1x.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-B3Qe3OpS.js +0 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js +0 -13
- package/dist/assets/vendor-codemirror-lang-markdown-FGQydhTc.js +0 -1
- package/dist/assets/vendor-codemirror-language-DUOssd4j.js +0 -3
- package/dist/assets/vendor-codemirror-search-8kyQdB3f.js +0 -2
- package/dist/assets/vendor-codemirror-view-DSzLbZiS.js +0 -4
- package/dist/assets/vendor-replit-codemirror-vim-B0Ecqnlh.js +0 -39
- package/dist/assets/zh-CN-dlOQK6v9.js +0 -15
- package/dist/assets/zh-TW-BnqQ-WL5.js +0 -15
- package/server/lib/quota/providers/claude.js +0 -107
|
@@ -1,915 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-5DyvN03T.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-BikB6enL.js","assets/index-DRpChWux.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/vendor-zustand-BAGL70zf.js","assets/index-BzIpNlNE.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-D_V6hAcE.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-DKpLs02S.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-B-bSg3P5.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-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-DUOssd4j.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BjbBRsUA.js","assets/vendor-codemirror-lang-json-ryCw7nab.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-VgNqFSH-.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-B3Qe3OpS.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-FGQydhTc.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CLHw8NWn.js","assets/vendor-codemirror-lang-python-N414WYK-.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-ARAOgp1x.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CRSgBxjL.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/PierreDiffViewer-BHm4Yr0X.js","assets/web-components-GMc3oR3i.js","assets/computeVirtualFileMetrics-Da00Jg7M.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/VirtualizedFileDiff-CwGocYQd.js","assets/isDiffPlainText-D9YpoLrV.js","assets/vendor-diff-C3JhlQdm.js","assets/useInlineCommentController-CYPvYJDt.js","assets/runtimeEndpointReset-BVmispdD.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/patchFileDiff-KNkxM1C1.js","assets/SessionSwitcherDropdown-rro-SsaO.js","assets/scheduledTasksApi-ByKya3Un.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-DZIoOnV7.js","assets/FilesView-BKL6YlKG.js","assets/shikiHighlight-C7LTbwFx.js","assets/vendor-codemirror-search-8kyQdB3f.js","assets/vendor-replit-codemirror-vim-B0Ecqnlh.js","assets/JsonTreeView-DLW2Wy1g.js","assets/Virtualizer-X_7XPoTH.js","assets/isFilePlainText-gTibdNIe.js","assets/DiagramEditor-jnG3Hbxg.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-4qZbrEXU.js","assets/GitView-DBFrDDBv.js","assets/CommitSection-MJmntVPJ.js","assets/PlanView-ZYEJn8A_.js","assets/DiagramView-CFXxgg_a.js","assets/SettingsView-5RmswFZe.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SettingsWindow-BZhAYFdS.js","assets/OnboardingScreen-D2Y6djMw.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as tt,j as s,R as l,r as Ge,h as Dm}from"./vendor-react-BUCujlKS.js";import{x as $n,y as Ti,O as Hl,D as Pm,z as Em,A as Jd,r as ms,n as Ii,u as xe,B as Tm,C as er,E as Im,F as wt,G as In,H as Ri,I as Zd,J as eu,q as Mi,K as tu,L as ur,M as ko,e as fr,N as Rm,a as xn,P as Mm,Q as Om,R as Fm,S as su,m as Bn,t as Xs,T as nu,U as Bm,V as ru,W as Lm,X as Vr,l as ls,Y as rl,Z as Da,_ as _m,$ as $m,d as Hr,a0 as si,a1 as ni,a2 as zm,a3 as Kl,a4 as Um,a5 as Wm,a6 as Vm,a7 as Hm,a8 as Gl,a9 as ql,aa as Yl,ab as Ql,ac as Km,o as Xl,ad as Gm,ae as qm,af as Ym,v as Qm,w as Xm}from"./index-DRpChWux.js";import{_ as Js}from"./vendor-vite-runtime-DD1OZmLC.js";import{I as R,f as mt,h as ye,aQ as Gt,g as Xn,t as Ee,aR as bn,aS as gn,aT as yn,aU as vn,L as _r,V as tr,aV as pr,o as Oi,aW as Jl,aX as dt,aY as ut,aZ as ft,a_ as ou,a$ as Co,b0 as Jm,y as Je,b1 as Zm,b2 as eh,b3 as iu,b4 as th,b5 as ri,b6 as sh,b7 as nh,K as au,b8 as rh,b9 as Pa,l as Vt,ba as oh,A as lu,u as Rs,b as qt,n as Cs,aj as Lr,bb as cu,bc as ih,bd as ah,be as lh,bf as ch,p as dh,bg as du,bh as uh,bi as fh,bj as mh,bk as uu,bl as hh,bm as ph,bn as ol,bo as Fi,bp as Ea,ak as il,bq as Bi,br as Or,ae as fu,bs as Ws,bt as Vs,bu as Rn,bv as wn,bw as Sn,bx as gr,B as nt,by as mu,bz as oa,P as pi,i as Ta,j as gh,bA as hu,bB as xh,bC as pu,ac as cs,G as bh,bD as yh,bE as vh,bF as hn,bG as Li,bH as gu,bI as Ia,bJ as wh,bK as Ls,bL as _s,bM as Ds,bN as $s,bO as rs,S as Jn,bP as Kr,bQ as Zl,bR as qr,M as _i,a0 as Io,a1 as al,bS as xu,a4 as mr,bT as $i,bU as Yn,Z as ll,bV as Sh,bW as jh,ab as kh,bX as Ch,bY as Nh,bZ as Ah,ad as cl,b_ as dl,b$ as yo,c0 as bu,c1 as Dh,c2 as Ph,c3 as Ro,c4 as Eh,O as yu,c5 as Th,c6 as Zs,c7 as Ih,c8 as Rh,c9 as ia,ca as vu,cb as Mh,cc as Oh,cd as Fh,ce as ec,cf as xo,c as No,d as zi,Y as wu,cg as Su,ch as uo,ci as bo,cj as Bh,r as Us,ck as Lh,W as ul,cl as _h,cm as $h,cn as zh,co as Uh,cp as ju,cq as _n,cr as Wh,cs as Vh,ct as tc,cu as ku,cv as Hh,cw as Cu,e as to,cx as gi,cy as Kh,cz as sc,cA as hr,cB as Ra,cC as Gh,cD as qh,cE as nc,cF as Fs,cG as Nu,cH as Au,cI as Yh,cJ as oi,cK as Qh,Q as fl,N as ml,R as hl,cL as pl,cM as Ma,cN as Du,cO as Xh,cP as Pu,cQ as Jh,H as Zh,cR as rc,cS as ep,cT as oc,cU as tp,cV as sp,cW as Eu,cX as np,D as rp,cY as op,cZ as ip,c_ as ap,c$ as ic,d0 as lp,d1 as cp,C as dp,d2 as Tu,E as up,d3 as ac,d4 as fp,d5 as mp,d6 as hp,d7 as pp,d8 as gp,d9 as xp,da as Ui,a as Wi,db as bp,dc as aa,F as xi,dd as yp,de as vp,df as lc,aw as Oa,dg as Iu,_ as wp,$ as Sp,az as jp,dh as kp,J as Cp,di as Np,dj as Ap,dk as Dp,dl as Ru,dm as Mu,dn as Ou,dp as Pp,dq as Ep,dr as Tp,ds as Ip,dt as Rp,du as Mp,dv as Op,dw as Fp,dx as Bp,dy as bi,a2 as Lp,a3 as _p,dz as $p,dA as cc,dB as zp,dC as Up,dD as Wp,dE as Vp,dF as dc,dG as Hp,dH as Kp,dI as Gp,dJ as qp,dK as Yp,dL as Qp,dM as Xp,dN as Jp,dO as Zp,dP as ii,dQ as eg,dR as tg,af as sg,dS as ng,dT as rg,dU as og,dV as ig,dW as uc,dX as ag,aq as lg,ar as cg,as as dg,au as fc,av as mc,ax as Fu,ay as Bu,dY as ug,aL as fg,aM as mg,aN as hg,aO as pg,aP as gg,aH as xg,aI as bg,aJ as yg,aK as vg}from"./useAppFontEffects-BikB6enL.js";import{h as hc,i as Qt,n as wg,j as pc,t as Kn,k as Sg,l as la,m as jg,o as kg,U as Lu,b as gl,M as Cg,p as gc,q as yi,s as xl,v as vi,w as _u,x as Ng,y as $u,z as zu,A as Uu,P as Wu,T as Vu,B as Ag,E as Dg,F as Pg,S as xc,u as vo,N as Eg,D as Tg,W as Ig,L as bc,G as Rg,d as Mg,g as Og,f as Fa,H as Fg,I as Bg,c as Lg,e as _g,O as Hu,C as $g}from"./runtimeEndpointReset-BVmispdD.js";import{u as Ku,S as zg,C as Ug,W as Gu}from"./SessionSwitcherDropdown-rro-SsaO.js";import{u as Pr,f as Wg,a as yc,s as Vg,d as Hg,b as Kg,r as Gg}from"./scheduledTasksApi-ByKya3Un.js";import{c as xr,u as qn,d as qu,p as Yu}from"./vendor-zustand-BAGL70zf.js";import{g as qg,b as Yg,E as Qg,c as Xg,i as Jg}from"./contextPanelEmbeddedChat-B-bSg3P5.js";import{f as wi,h as Yr,T as Zg,M as ex,D as Si,j as ji,P as Ba,b as tx,d as sx,k as La,i as nx}from"./vendor-dnd-kit-core-BZknOX2w.js";import{a as Qu,S as _a,v as $a,u as bl,s as rx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as yl}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{u as ox}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{M as vc,a as wc,b as Sc,C as ix,c as ax,d as lx,S as cx,e as dx,f as ux}from"./vendor-base-ui-D_V6hAcE.js";import{d as Xu}from"./vendor-cron-parser-CUcP7OfX.js";import{u as jc,a as kc,m as Cc}from"./vendor-framer-motion-CRSgBxjL.js";function Ju(t){const e=tt.c(5),{className:n}=t,o=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let i,c,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),c=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(R,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=i,e[1]=c,e[2]=a):(i=e[0],c=e[1],a=e[2]);let d;return e[3]!==o?(d=s.jsxs("span",{"aria-hidden":"true",className:o,children:[i,c,a]}),e[3]=o,e[4]=d):d=e[4],d}function Nc(t){const e=tt.c(14);let n,r,o,i;e[0]!==t?({size:o,className:n,style:i,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=i):(n=e[1],r=e[2],o=e[3],i=e[4]);const c=typeof o=="number"?`${o}px`:o,a=typeof o=="number"?`${o}px`:o;let d;e[5]!==i||e[6]!==c||e[7]!==a?(d={width:c,height:a,...i},e[5]=i,e[6]=c,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("path",{d:"M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z"}),e[9]=u):u=e[9];let h;return e[10]!==n||e[11]!==r||e[12]!==d?(h=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:n,style:d,...r,children:u}),e[10]=n,e[11]=r,e[12]=d,e[13]=h):h=e[13],h}const fx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",mx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",ca=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?fx:t.id==="terminal"?mx:void 0}),Ac=t=>{const e=tt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:o}=t,[i,c]=l.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||o;if(u&&!i){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>c(!0),e[2]=g):g=e[2];let b;return e[3]!==u?(b=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:g}),e[3]=u,e[4]=b):b=e[4],b}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=ye("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:h,children:d}),e[6]=d,e[7]=f):f=e[7],f},hx=t=>{const e=tt.c(75),{directory:n,className:r}=t,{t:o}=mt(),i=Pr(px),c=Pr(gx),a=Pr(xx),d=Pr(bx),u=Pr(yx),h=Pr(vx),f=Pr(wx);let g,b;e[0]!==u?(g=()=>{u()},b=[u],e[0]=u,e[1]=g,e[2]=b):(g=e[1],b=e[2]),l.useEffect(g,b);const S=$n()&&Ti();let v;e:{let Y;e[3]!==c||e[4]!==i?(Y=c.find(Q=>Q.id===i)??c.find(Sx)??c[0]??Hl[0],e[3]=c,e[4]=i,e[5]=Y):Y=e[5];const we=Y;if(we){let Q;e[6]!==we?(Q=ca(we),e[6]=we,e[7]=Q):Q=e[7],v=Q;break e}let me;e[8]===Symbol.for("react.memo_cache_sentinel")?(me=ca(Hl[0]),e[8]=me):me=e[8],v=me}const p=v;if(!S||!n||c.length===0)return null;let m;e[9]!==n?(m=async Y=>{await Em(n,Y.id,Y.appName)||await Jd(n,Y.appName)},e[9]=n,e[10]=m):m=e[10];const x=m;let w;e[11]!==x||e[12]!==f?(w=async Y=>{await f(Y.id),await x(Y)},e[11]=x,e[12]=f,e[13]=w):w=e[13];const j=w;let N;e[14]!==n||e[15]!==o?(N=async()=>{(await Xn(n)).ok&&Ee.success(o("openInApp.toast.pathCopied"))},e[14]=n,e[15]=o,e[16]=N):N=e[16];const A=N;let k;e[17]!==r?(k=ye("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=k):k=e[18];let C;e[19]!==x||e[20]!==p?(C=()=>{x(p)},e[19]=x,e[20]=p,e[21]=C):C=e[21];const P=d&&"animate-pulse";let D;e[22]!==P?(D=ye("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",P),e[22]=P,e[23]=D):D=e[23];let F;e[24]!==p.label||e[25]!==o?(F=o("openInApp.actions.openInAria",{app:p.label}),e[24]=p.label,e[25]=o,e[26]=F):F=e[26];let B;e[27]!==p.fallbackIconDataUrl||e[28]!==p.iconDataUrl||e[29]!==p.label?(B=s.jsx(Ac,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}),e[27]=p.fallbackIconDataUrl,e[28]=p.iconDataUrl,e[29]=p.label,e[30]=B):B=e[30];let E;e[31]!==D||e[32]!==F||e[33]!==B||e[34]!==C?(E=s.jsx("button",{type:"button",onClick:C,className:D,"aria-label":F,children:B}),e[31]=D,e[32]=F,e[33]=B,e[34]=C,e[35]=E):E=e[35];let _;e[36]===Symbol.for("react.memo_cache_sentinel")?(_=ye("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=_):_=e[36];let W;e[37]!==o?(W=o("openInApp.actions.chooseAppAria"),e[37]=o,e[38]=W):W=e[38];let V;e[39]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=V):V=e[39];let K;e[40]!==W?(K=s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:_,"aria-label":W,children:V})}),e[40]=W,e[41]=K):K=e[41];let y;e[42]!==A?(y=()=>{A()},e[42]=A,e[43]=y):y=e[43];let I;e[44]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(R,{name:"file-copy",className:"h-4 w-4"}),e[44]=I):I=e[44];let $;e[45]!==o?($=o("openInApp.actions.copyPath"),e[45]=o,e[46]=$):$=e[46];let z;e[47]!==$?(z=s.jsx("span",{className:"typography-ui-label text-foreground",children:$}),e[47]=$,e[48]=z):z=e[48];let G;e[49]!==y||e[50]!==z?(G=s.jsxs(Gt,{className:"flex items-center gap-2",onClick:y,children:[I,z]}),e[49]=y,e[50]=z,e[51]=G):G=e[51];let J;e[52]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(gn,{}),e[52]=J):J=e[52];let Z;if(e[53]!==c||e[54]!==j||e[55]!==p.id){let Y;e[57]!==j||e[58]!==p.id?(Y=we=>{const me=ca(we);return s.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{j(we)},children:[s.jsx(Ac,{label:we.label,iconDataUrl:we.iconDataUrl,fallbackIconDataUrl:me.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:we.label}),p.id===we.id?s.jsx(R,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},we.id)},e[57]=j,e[58]=p.id,e[59]=Y):Y=e[59],Z=c.map(Y),e[53]=c,e[54]=j,e[55]=p.id,e[56]=Z}else Z=e[56];let re;e[60]!==a||e[61]!==h||e[62]!==o?(re=a?s.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(R,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=o,e[63]=re):re=e[63];let ee;e[64]!==G||e[65]!==Z||e[66]!==re?(ee=s.jsxs(yn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[G,J,Z,re]}),e[64]=G,e[65]=Z,e[66]=re,e[67]=ee):ee=e[67];let he;e[68]!==K||e[69]!==ee?(he=s.jsxs(vn,{children:[K,ee]}),e[68]=K,e[69]=ee,e[70]=he):he=e[70];let be;return e[71]!==E||e[72]!==he||e[73]!==k?(be=s.jsxs("div",{className:k,children:[E,he]}),e[71]=E,e[72]=he,e[73]=k,e[74]=be):be=e[74],be};function px(t){return t.selectedAppId}function gx(t){return t.availableApps}function xx(t){return t.isCacheStale}function bx(t){return t.isScanning}function yx(t){return t.initialize}function vx(t){return t.loadInstalledApps}function wx(t){return t.selectApp}function Sx(t){return t.id===Pm}const ki=new Map,za=new Set,Zu=()=>{for(const t of za)t()},da=(t,e)=>{const n=t.trim();n&&(e.length===0?ki.delete(n):ki.set(n,[...e]),Zu())},jx=t=>{ki.delete(t.trim())&&Zu()},ef=[],kx=t=>ki.get(t.trim())??ef,Cx=t=>(za.add(t),()=>{za.delete(t)}),Nx=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=()=>kx(t),e[0]=t,e[1]=n):n=e[1],l.useSyncExternalStore(Cx,n,Ax)};function Ax(){return ef}const Dx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Px=["dev","start","preview","serve"];async function Ex(t,e,n){if(!t)return null;const r=Rx(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const o=Mx(n);if(o){const i=await Ox(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await Tx(t)){const o=await Ix(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function Tx(t){const e=`${t}/index.html`,n=await Ci(e,t);return typeof n=="string"&&n.trim().length>0}async function Ix(){try{const t=await ms("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Rx(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Px.some(o=>n.includes(o)))return e}return null}function Mx(t){for(const{pattern:e}of Dx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ox(t){const e=await Ci(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of n){const i=await Ci(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Ci(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await ms(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Ii()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ms(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Fx(t){try{const e=await Ci(`${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 Bx=(t,e,n)=>new Promise(r=>{let o=!1,i=null,c=null;const a=d=>{o||(o=!0,c&&clearTimeout(c),i?.close(),r(d))};i=t.connect(e,{onEvent:d=>{(d.type==="exit"||d.type==="snapshot"&&d.status==="exited")&&a(!0)},onError:(d,u)=>{u&&a(!0)}}),o?i.close():c=setTimeout(()=>a(!1),n)}),Ys="__openchamber_auto_discover_preview__",Lx=15e3,_x=3e3,$x=t=>{let e="";for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(e+=t[n])}return e},zx=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},tf=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:o=!1})=>{const{t:i}=mt(),{currentTheme:c}=_r(),{terminal:a,runtime:d}=tr(),{isMobile:u}=pr(),h=l.useMemo(()=>$n(),[]),f=hc(X=>X.instances),g=hc(X=>X.load),b=xe(X=>X.terminalShell),S=xe(X=>X.terminalLoginShells.includes(X.terminalShell)),v=xe(X=>X.setSettingsPage),p=xe(X=>X.setSettingsDialogOpen),m=xe(X=>X.setSettingsProjectsSelectedId),x=xe(X=>X.openContextPreview),w=Qt(X=>X.ensureDirectory),j=Qt(X=>X.setTabLabel),N=Qt(X=>X.setTabIconKey),A=Qt(X=>X.setActiveTab),k=Qt(X=>X.setConnecting),C=Qt(X=>X.setTabSessionId),P=Qt(X=>X.setTabPreviewUrl),D=Qt(X=>X.projectActionRuns),F=Qt(X=>X.setProjectActionRun),B=Qt(X=>X.updateProjectActionRunStatus),E=Qt(X=>X.removeProjectActionRun),[_,W]=l.useState([]),[V,K]=l.useState(null),[y,I]=l.useState(!1),$=l.useRef({}),z=l.useRef({}),G=l.useRef({}),J=l.useRef({}),Z=l.useRef(new Set),re=l.useRef(0),ee=t?.id??null,he=t?.path??"",be=l.useMemo(()=>ee?{id:ee,path:he}:null,[ee,he]);l.useEffect(()=>{h&&g().catch(()=>{})},[h,g]);const Y=l.useCallback(async X=>{await Oi(X)},[]),we=l.useCallback(async()=>{if(!be)return;const X=re.current+1;re.current=X,I(!0);try{const le=await Jl(be);if(re.current!==X)return;const se=le.actions;W(se),K(T=>T===Ys||T&&se.some(ie=>ie.id===T)?T:null)}catch{if(re.current!==X)return}finally{re.current===X&&I(!1)}},[be]),me=l.useMemo(()=>wg(e||be?.path||""),[e,be?.path]),Q=l.useMemo(()=>V?_.find(X=>X.id===V)??null:null,[_,V]),pe=l.useMemo(()=>({id:Ys,name:i("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[i]),ve=!u,Te=l.useMemo(()=>ve?[pe,..._]:_,[_,pe,ve]);l.useEffect(()=>{we()},[we]),l.useEffect(()=>{if(typeof window>"u")return;const X=le=>{const se=le.detail;ee&&(se?.projectId&&se.projectId!==ee||we())};return window.addEventListener(pc,X),()=>{window.removeEventListener(pc,X)}},[we,ee]),l.useEffect(()=>{V&&(V===Ys&&ve||_.some(X=>X.id===V)||K(null))},[_,ve,V]),l.useEffect(()=>{const X=se=>{delete J.current[se];const T=z.current[se];if(!T||T.openedUrl)return;const ie=Qt.getState(),je=ie.projectActionRuns[se];if(!je)return;const Pe=T.announced;if(Pe.length!==0){if(T.openedUrl=!0,ie.updateProjectActionRunStatus(se,"running"),Pe.length===1){da(je.directory,[]),P(je.directory,je.tabId,Pe[0],{locked:!1,autoOpened:!0}),x(je.directory,Pe[0]);return}T.offering=!0,da(je.directory,Pe),xe.getState().openContextSurface(je.directory,"browser"),Ee.info(i("projectActions.toast.multipleServers"))}},le=()=>{const se=Qt.getState(),T=se.sessions,ie=se.projectActionRuns;for(const[je,Pe]of Object.entries(ie)){const Be=T.get(Pe.directory)?.tabs.find(it=>it.id===Pe.tabId);if(!Be||Be.terminalSessionId!==Pe.sessionId){E(je);continue}const Fe=z.current[je]??{lastSeenChunkId:null,openedUrl:!1,tail:"",openInPreview:!1,announced:[],offering:!1};z.current[je]=Fe;const Ye=Te.find(it=>it.id===Pe.actionId),at=se.getBuffer(Pe.directory,Pe.tabId).chunks;if(!Ye||at.length===0)continue;const st=at.filter(it=>Fe.lastSeenChunkId===null||it.id>Fe.lastSeenChunkId);if(st.length===0)continue;const ct=st.map(it=>it.data).join(""),bt=`${Fe.tail}${ct}`;if(Fe.openInPreview&&(!Fe.openedUrl||Fe.offering)){const it=jg(bt),Et=Fe.announced.length;for(const Dt of it)Fe.announced.includes(Dt)||Fe.announced.push(Dt);const Ft=Fe.announced.length-Et;Fe.offering&&Ft>0?da(Pe.directory,Fe.announced):!Fe.openedUrl&&Et===0&&Fe.announced.length>0&&(window.clearTimeout(J.current[je]),J.current[je]=window.setTimeout(()=>X(je),_x))}const rt=!Fe.openedUrl&&Ye.autoOpenUrl===!0&&!Fe.openInPreview?kg(bt):null,gt=st[st.length-1]?.id??Fe.lastSeenChunkId;if(Fe.lastSeenChunkId=gt,Fe.tail=bt.slice(-512),rt)if(Fe.openedUrl=!0,Fe.openInPreview){const it=ie[je];it&&(P(it.directory,it.tabId,rt,{locked:!1,autoOpened:!1}),it.status==="waiting-for-preview"&&B(je,"running"),window.clearTimeout(J.current[je]),delete J.current[je],x(it.directory,rt))}else Y(rt),Ee.success(i("projectActions.toast.openedUrlFromOutput"));z.current[je]=Fe}for(const je of Object.keys(z.current))ie[je]||(delete z.current[je],window.clearTimeout(J.current[je]),delete J.current[je])};return le(),Qt.subscribe((se,T)=>{(se.sessions!==T.sessions||se.buffers!==T.buffers)&&le()})},[Te,x,Y,D,E,P,i,B]);const ke=l.useCallback(async(X,le={})=>{if(!me)throw new Error(i("projectActions.error.noActiveDirectory"));const se=Kn(me,X.id);w(me);const T=Qt.getState(),ie=T.getDirectoryState(me);let je=$.current[se]||null;const Pe=je?!!ie?.tabs.some(Fe=>Fe.id===je):!1;(!je||!Pe)&&(je=T.createTab(me),$.current[se]=je),j(me,je,`Action: ${X.name}`),N(me,je,X.icon||"play"),A(me,je),le.revealTerminal!==!1&&xe.getState().openContextPanelTab(me,{mode:"terminal"});const Be=Qt.getState().getDirectoryState(me)?.tabs.find(Fe=>Fe.id===je);return{key:se,tabId:je,sessionId:Be?.terminalSessionId??null}},[w,me,A,N,j,i]),Ie=l.useCallback(async X=>{if(d.isVSCode||!o&&u)return;if(!me){Ee.error(i("projectActions.error.noActiveDirectoryForAction"));return}const le=Kn(me,X.id),se=D[le];if(!(se&&se.status==="running")&&!Z.current.has(le)){Z.current.add(le);try{const T=X.id===Ys?await(async()=>{const[rt,gt]=await Promise.all([Jl({id:be?.id??"",path:me}),Fx(me)]),it=await Ex(me,rt.actions,gt);if(!it)throw new Error(i("contextPanel.preview.noDevServer"));return{id:Ys,name:i("projectActions.actions.autoDiscover"),command:it.command,icon:"scan-2",autoOpenUrl:!0,openUrl:it.previewUrlHint||""}})():X,ie=T.autoOpenUrl===!0&&(T.openUrl||"").trim().length>0,je=!ie&&X.id!==Ys,{key:Pe,tabId:U,sessionId:Be}=await ke(T,{revealTerminal:je});let Fe=Be;if(!Fe){k(me,U,!0);try{Fe=(await a.createSession({cwd:me,sessionId:U,shell:b,loginShell:S,themeMode:c.metadata.variant==="light"?"light":"dark",terminalBackground:c.colors.surface.background,terminalForeground:c.colors.syntax.base.foreground})).sessionId,C(me,U,Fe)}finally{k(me,U,!1)}}if(!Fe)throw new Error(i("projectActions.error.failedToCreateTerminalSession"));G.current[Pe]?.(),k(me,U,!0);const Ye=a.connect(Fe,{onEvent:rt=>{rt.type==="snapshot"&&(Qt.getState().replaceBuffer(me,U,rt.data??"",rt.sequence??0),Qt.getState().setConnecting(me,U,!1)),rt.type==="data"&&typeof rt.data=="string"&&rt.data.length>0&&Qt.getState().appendToBuffer(me,U,rt.data,rt.sequence,rt.replayData),rt.type==="exit"&&(Qt.getState().setTabLifecycle(me,U,"exited"),Qt.getState().setConnecting(me,U,!1),Qt.getState().removeProjectActionRun(Pe),delete z.current[Pe],G.current[Pe]?.(),delete G.current[Pe],window.clearTimeout(J.current[Pe]),delete J.current[Pe])},onError:(rt,gt)=>{Qt.getState().setConnecting(me,U,!1),gt&&(Qt.getState().setTabLifecycle(me,U,"exited"),Qt.getState().setTabSessionId(me,U,null),Qt.getState().removeProjectActionRun(Pe))}});G.current[Pe]=Ye.close;const at=T.autoOpenUrl===!0&&h&&(T.desktopOpenSshForward||"").trim().length>0,st=T.autoOpenUrl?zx(T.openUrl):null,ct=T.autoOpenUrl&&h?Sg(T.desktopOpenSshForward,f):null;F({key:Pe,directory:me,actionId:T.id,tabId:U,sessionId:Fe,status:T.id===Ys&&!st?"waiting-for-preview":"running"}),window.clearTimeout(J.current[Pe]),delete J.current[Pe],T.id===Ys&&!st&&(J.current[Pe]=window.setTimeout(()=>{const rt=Qt.getState(),gt=rt.projectActionRuns[Pe];rt.updateProjectActionRunStatus(Pe,"running"),gt&&(rt.setActiveTab(gt.directory,gt.tabId),xe.getState().openContextPanelTab(gt.directory,{mode:"terminal"})),delete J.current[Pe]},Lx)),z.current[Pe]={lastSeenChunkId:null,openedUrl:!!ct||!!st||ie,tail:"",openInPreview:T.id===Ys,announced:[],offering:!1};const bt=$x(T.command.trim().replace(/\r\n|\r/g,`
|
|
3
|
-
`));await a.sendInput(Fe,`${bt}\r`),ct?(P(me,U,null,{locked:!0}),Y(ct),Ee.success(i("projectActions.toast.openedForwardedUrl"))):st?(P(me,U,st,{locked:!0,autoOpened:!0}),x(me,st),Ee.success(i("projectActions.toast.openedActionUrl"))):ie?(P(me,U,null,{locked:!0}),Ee.error(i("projectActions.error.invalidCustomUrlFormat"))):at?(P(me,U,null,{locked:!0}),Ee.error(i("projectActions.error.selectedDesktopSshForwardUnavailable"))):P(me,U,null,{locked:!1,autoOpened:!1})}catch(T){E(le),delete z.current[le],G.current[le]?.(),delete G.current[le],window.clearTimeout(J.current[le]),delete J.current[le],Ee.error(T instanceof Error?T.message:i("projectActions.error.failedToRunAction"))}finally{Z.current.delete(le)}}},[c.colors.surface.background,c.colors.syntax.base.foreground,c.metadata.variant,f,ke,o,u,h,me,S,b,Y,x,D,d.isVSCode,E,k,F,P,C,be?.id,i,a]),Ne=l.useCallback(async X=>{const le=Kn(me,X.id),se=D[le];if(!se)return;B(le,"stopping");const T=Bx(a,se.sessionId,1e3);try{await a.sendInput(se.sessionId,"")}catch{}const ie=await T;if(Qt.getState().getDirectoryState(se.directory)?.tabs.find(U=>U.id===se.tabId)?.terminalSessionId===se.sessionId&&!ie){if(typeof a.forceKill=="function")try{await a.forceKill({sessionId:se.sessionId})}catch{}else try{await a.close(se.sessionId)}catch{}C(se.directory,se.tabId,null)}E(le),delete z.current[le],G.current[le]?.(),delete G.current[le],window.clearTimeout(J.current[le]),delete J.current[le]},[me,D,E,C,a,B]),Ae=l.useCallback(()=>{const X=Q??Te[0];if(!X)return;const le=Kn(me,X.id),se=D[le];if(se?.status!=="stopping"){if(se){Ne(X);return}Ie(X)}},[Te,me,Ie,D,Q,Ne]),Se=l.useCallback((X,le=!1)=>{if(K(X.id),!le){Ie(X);return}const se=Kn(me,X.id),T=D[se];if(T?.status!=="stopping"){if(T){Ne(X);return}Ie(X)}},[me,Ie,D,Ne]),Oe=l.useCallback(()=>{be?.id&&(m(be.id),v("projects"),p(!0))},[p,v,m,be?.id]),ne=Q??Te[0]??null,ce=ne?D[Kn(me,ne.id)]:null,Re=Qt(X=>ce?X.sessions.get(ce.directory)?.tabs.find(le=>le.id===ce.tabId)?.previewUrl??null:null);if(d.isVSCode||!o&&u||!be||!me)return null;const te=Q??Te[0]??null;if(!te)return null;const ae=te.icon||"play",de=te.id===Ys?"scan-2":la[ae]||"play",H=Kn(me,te.id),ge=D[H],ue=ge?.status==="stopping",M=ge?.status==="waiting-for-preview",oe=!!(ge&&Re),De=()=>{!ge||!Re||x(ge.directory,Re)},fe=te.id===Ys;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",disabled:y||ue,className:ye("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","disabled:cursor-not-allowed",n),onClick:Ae,"aria-label":ge?i("projectActions.actions.stopNamedAria",{name:te.name}):i("projectActions.actions.runNamedAria",{name:te.name}),children:ue||M?s.jsx(R,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):ge?s.jsx(R,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(R,{name:de,className:"h-5 w-5"})})}),fe?s.jsx(ft,{sideOffset:6,children:i("projectActions.actions.autoDiscoverTooltip")}):null]}),oe?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":i("projectActions.actions.openPreview"),onClick:De,children:s.jsx(R,{name:"global",className:"h-4 w-4"})})}),s.jsx(ft,{sideOffset:6,children:i("projectActions.actions.openPreview")})]}):null,s.jsxs(vn,{children:[s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":i("projectActions.actions.chooseActionAria"),children:s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(yn,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Gt,{className:"flex items-center gap-2",onClick:Oe,children:[s.jsx(R,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("projectActions.actions.addNewAction")})]}),s.jsx(gn,{}),Te.map(X=>{const le=X.icon||"play",se=X.id===Ys?"scan-2":la[le]||"play",T=Kn(me,X.id),ie=D[T],je=!!ie,Pe=ie?.status==="stopping";return s.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{Se(X,!0)},children:[s.jsx(R,{name:se,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),Pe||ie?.status==="waiting-for-preview"?s.jsx(R,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):je?s.jsx(R,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]}):s.jsxs("div",{className:ye("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ae,disabled:y||ue,className:ye("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed"),"aria-label":ge?i("projectActions.actions.stopNamedAria",{name:te.name}):i("projectActions.actions.runNamedAria",{name:te.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:ue||M?s.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):ge?s.jsx(R,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(R,{name:de,className:"h-4 w-4"})})})}),fe?s.jsx(ft,{sideOffset:6,children:i("projectActions.actions.autoDiscoverTooltip")}):null]}),oe?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:De,className:ye(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),"aria-label":i("projectActions.actions.openPreview"),children:s.jsx(R,{name:"global",className:"h-4 w-4"})})}),s.jsx(ft,{sideOffset:6,children:i("projectActions.actions.openPreview")})]}):null,s.jsxs(vn,{children:[s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:ye(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),"aria-label":i("projectActions.actions.chooseActionAria"),children:s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(yn,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Gt,{className:"flex items-center gap-2",onClick:Oe,children:[s.jsx(R,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("projectActions.actions.addNewAction")})]}),s.jsx(gn,{}),Te.map(X=>{const le=X.icon||"play",se=X.id===Ys?"scan-2":la[le]||"play",T=Kn(me,X.id),ie=D[T],je=!!ie,Pe=ie?.status==="stopping";return s.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{Se(X,!0)},children:[s.jsx(R,{name:se,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),Pe||ie?.status==="waiting-for-preview"?s.jsx(R,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):je?s.jsx(R,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]})};function Ux(t){if(typeof t!="number"||!Number.isFinite(t))return"";const e=new Date(t);if(Number.isNaN(e.getTime()))return"";const n=e.toLocaleString(Co(),{month:"short"}),r=e.getDate(),o=e.getFullYear(),i=String(e.getHours()).padStart(2,"0"),c=String(e.getMinutes()).padStart(2,"0");return`${n} ${r}, ${o}, ${i}:${c}`}function Wx(t){if(t.info.role==="user")return"";const e=typeof t.info.providerID=="string"?t.info.providerID.trim():"",n=typeof t.info.modelID=="string"?t.info.modelID.trim():"";return e&&n?`${e}/${n}`:n||e}function Vx(t){const e=t.info.role==="user"?"User":"Assistant",n=Ux(t.info.time?.created),r=Wx(t),o=n&&r?`${n} (${r})`:n||r;return o?`**${e}**
|
|
4
|
-
|
|
5
|
-
*${o}*`:`**${e}**`}function Hx(t){return t.filter(e=>e.type==="text"&&typeof e.text=="string").map(e=>e.text).join("")}function sf(t){const e=Vx(t),n=Hx(t.parts).trim();return n?`${e}
|
|
6
|
-
|
|
7
|
-
${n}`:""}function nf(t,e){const n="#".repeat(Math.min(e+1,6)),r=t.agent?` — ${t.agent}`:"",o=`${n} Sub-agent: ${t.title}${r}
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
`,i=t.records.map(sf).filter(Boolean).join(`
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
`),c=[o+i];for(const a of t.children)c.push(nf(a,e+1));return c.join(`
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
`)}function rf(t,e,n){const r=e?.trim()||"Session",o=new Date().toISOString().split("T")[0],i=`# ${r}
|
|
20
|
-
|
|
21
|
-
*Exported on ${o}*
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
`,c=t.map(sf).filter(Boolean).join(`
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
`);let a=i+c;if(n&&n.length>0){const d=n.map(u=>nf(u,1)).join(`
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
`);a+=`
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
`+d}return a}function of(t,e){const n=new Blob([t],{type:"text/markdown;charset=utf-8"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}async function af(t,e){const n=await Tm(e,t);if(n)return n;if(!er())return null;try{const r=await Ii()?.vscode?.saveMarkdown?.({fileName:e,content:t});if(!r||r.saved!==!0)return null;const o=typeof r.path=="string"?r.path.trim():"";return o.length>0?o:null}catch{return null}}async function Kx(t){const e=Ii()?.files;if(e?.revealPath)try{return!!(await e.revealPath(t))?.success}catch{return!1}return await Im(t)?!0:Jd(t)}function Gx(){return ou()}function lf(t){const r=(t?.trim()||"session").normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,60)||"session",o=new Date().toISOString().split("T")[0];return`${r}-${o}.md`}const vl=xr(()=>({pendingSessionIds:new Set})),cf=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],vl(n)},Dc=(t,e)=>{vl.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{pendingSessionIds:r}})},qx=async(t,e)=>{try{const d=(await nh(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=wt(t),r=wt(e)??e,o=Je.getState().availableWorktreesByProject,c=(o.get(r)??o.get(e)??[]).find(a=>wt(a.path)===n)?.branch?.trim();if(c)return c;throw new Error("Unable to determine the current branch")},Pc=(t,e)=>{const n=sh(e);if(!n)throw new Error("Session status is unavailable");const r=n.session_status;if(t.some(i=>{const c=r[i.id]?.type;return c==="busy"||c==="retry"}))throw new Error("Session is not idle")},Yx=async(t,e,n,r,o)=>{const i=[];for(const c of[...t].reverse())try{await iu(c,r,n,c.id===e),Je.getState().setWorktreeMetadata(c.id,o.get(c.id)??null)}catch(a){i.push(a)}return i},Qx=async(t,e,n)=>{try{await au(t,e,{deleteLocalBranch:!0})}catch{const r=n instanceof Error?n.message:String(n);throw new Error(`Session move failed and the new worktree could not be removed: ${r}`)}throw n},Xx=async t=>{if(vl.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Dc(t.root.id,!0);try{const e=Jm(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=[t.root,...t.descendants],r=new Map(n.map(a=>[a.id,Je.getState().getWorktreeMetadata(a.id)]));Pc(n,t.sourceDirectory);const o=await qx(t.sourceDirectory,e.path),i=await Zm(e,{startRef:o}),c=[];try{await eh(i.path),Pc(n,t.sourceDirectory);for(const[a,d]of n.entries())await iu(d,t.sourceDirectory,i.path,a===0),c.push(d),Je.getState().setWorktreeMetadata(d.id,th(i))}catch(a){if((await Yx(c,t.root.id,t.sourceDirectory,i.path,r)).length>0)throw new Error(`Session move partially failed and could not be fully rolled back: ${a instanceof Error?a.message:String(a)}`);return Qx(e,i,a)}try{await ri([t.sourceDirectory,i.path])}catch(a){console.warn("[session-worktree-move] Failed to refresh moved sessions",a)}return i.path}finally{Dc(t.root.id,!1)}},df=t=>{Xx(t).then(()=>Ee.success(t.successMessage)).catch(e=>Ee.error(t.failureMessage,{description:e instanceof Error?e.message:String(e)}))},Ao="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",Jx="app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors",Zx=l.memo(function(e){const n=tt.c(17),{visible:r,title:o,ariaLabel:i,onClick:c,className:a,Icon:d,iconClassName:u,pressed:h}=e,f=r===void 0?!0:r,g=h===void 0?!1:h;if(!f)return null;const b=a??Ao,S=g&&"bg-interactive-selection text-interactive-selection-foreground";let v;n[0]!==b||n[1]!==S?(v=ye(b,S),n[0]=b,n[1]=S,n[2]=v):v=n[2];const p=u??"h-[18px] w-[18px]";let m;n[3]!==d||n[4]!==p?(m=s.jsx(R,{name:d,className:p}),n[3]=d,n[4]=p,n[5]=m):m=n[5];let x;n[6]!==i||n[7]!==c||n[8]!==g||n[9]!==v||n[10]!==m?(x=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:c,"aria-label":i,"aria-pressed":g,className:v,children:m})}),n[6]=i,n[7]=c,n[8]=g,n[9]=v,n[10]=m,n[11]=x):x=n[11];let w;n[12]!==o?(w=s.jsx(ft,{children:s.jsx("p",{children:o})}),n[12]=o,n[13]=w):w=n[13];let j;return n[14]!==x||n[15]!==w?(j=s.jsxs(dt,{children:[x,w]}),n[14]=x,n[15]=w,n[16]=j):j=n[16],j}),eb=l.memo(function(e){const n=tt.c(42),{isMobile:r,githubAuthStatus:o,githubAccounts:i,githubAvatarUrl:c,githubLogin:a,isSwitchingGitHubAccount:d,handleGitHubAccountSwitch:u}=e,{t:h}=mt();if(!o?.connected||r)return null;if(i.length>1){let S;n[0]===Symbol.for("react.memo_cache_sentinel")?(S=ye(Ao,"h-7 w-7 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0"),n[0]=S):S=n[0];let v;n[1]!==a||n[2]!==h?(v=a?h("header.github.connectedWithLogin",{login:a}):h("header.github.connected"),n[1]=a,n[2]=h,n[3]=v):v=n[3];let p;n[4]!==c||n[5]!==a||n[6]!==h?(p=c?s.jsx("img",{src:c,alt:a?h("header.github.avatarWithLogin",{login:a}):h("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(R,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"}),n[4]=c,n[5]=a,n[6]=h,n[7]=p):p=n[7];let m;n[8]!==d||n[9]!==v||n[10]!==p?(m=s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:S,title:v,disabled:d,children:p})}),n[8]=d,n[9]=v,n[10]=p,n[11]=m):m=n[11];let x;n[12]!==h?(x=h("header.github.accountsTitle"),n[12]=h,n[13]=x):x=n[13];let w;n[14]!==x?(w=s.jsx(Pa,{className:"typography-ui-header font-semibold text-foreground",children:x}),n[14]=x,n[15]=w):w=n[15];let j;n[16]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(gn,{}),n[16]=j):j=n[16];let N;if(n[17]!==i||n[18]!==u||n[19]!==d||n[20]!==h){let C;n[22]!==u||n[23]!==d||n[24]!==h?(C=P=>{const D=P.user,F=!!P.current,B=P.source==="gh-cli"?h("header.github.accountSource.cli"):h("header.github.accountSource.oauth");return s.jsxs(Gt,{className:"gap-2",disabled:d,onSelect:()=>{F||u(P.id)},children:[D?.avatarUrl?s.jsx("img",{src:D.avatarUrl,alt:D.login?h("header.github.avatarWithLogin",{login:D.login}):h("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(R,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:D?.name?.trim()||D?.login||"GitHub"}),D?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:D.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:B})]}):null]}),F?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]},P.id)},n[22]=u,n[23]=d,n[24]=h,n[25]=C):C=n[25],N=i.map(C),n[17]=i,n[18]=u,n[19]=d,n[20]=h,n[21]=N}else N=n[21];let A;n[26]!==w||n[27]!==N?(A=s.jsxs(yn,{align:"end",className:"w-64",children:[w,j,N]}),n[26]=w,n[27]=N,n[28]=A):A=n[28];let k;return n[29]!==m||n[30]!==A?(k=s.jsxs(vn,{children:[m,A]}),n[29]=m,n[30]=A,n[31]=k):k=n[31],k}let f;n[32]!==a||n[33]!==h?(f=a?h("header.github.connectedWithLogin",{login:a}):h("header.github.connected"),n[32]=a,n[33]=h,n[34]=f):f=n[34];let g;n[35]!==c||n[36]!==a||n[37]!==h?(g=c?s.jsx("img",{src:c,alt:a?h("header.github.avatarWithLogin",{login:a}):h("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(R,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"}),n[35]=c,n[36]=a,n[37]=h,n[38]=g):g=n[38];let b;return n[39]!==f||n[40]!==g?(b=s.jsx("div",{className:"app-region-no-drag flex h-7 w-7 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",title:f,children:g}),n[39]=f,n[40]=g,n[41]=b):b=n[41],b}),tb=l.memo(function(e){const n=tt.c(43),{isDesktopApp:r,currentInstanceLabel:o,compactCurrentInstanceLabel:i,currentInstanceIsLocal:c,isDesktopServicesOpen:a,setIsDesktopServicesOpen:d,refreshCurrentInstanceLabel:u,shortcutLabel:h,remoteUpdateInfo:f,remoteUpdateChecking:g,remoteUpdateError:b,onOpenRemoteUpdate:S}=e,{t:v}=mt();let p;n[0]!==u||n[1]!==d?(p=E=>{d(E),E&&u()},n[0]=u,n[1]=d,n[2]=p):p=n[2];let m;n[3]!==o||n[4]!==r||n[5]!==v?(m=r?v("header.services.openWithCurrent",{current:o}):v("header.services.open"),n[3]=o,n[4]=r,n[5]=v,n[6]=m):m=n[6];const x=r?"w-auto max-w-[14rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let w;n[7]!==x?(w=ye(Ao,x),n[7]=x,n[8]=w):w=n[8];let j;n[9]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(R,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=j):j=n[9];let N;n[10]!==i||n[11]!==r?(N=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=N):N=n[12];let A;n[13]!==m||n[14]!==w||n[15]!==N?(A=s.jsx(ut,{asChild:!0,children:s.jsx(bn,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":m,className:w,children:[j,N]})})}),n[13]=m,n[14]=w,n[15]=N,n[16]=A):A=n[16];let k;n[17]!==o||n[18]!==h||n[19]!==v?(k=v("header.services.tooltip.currentInstance",{current:o,toggle:h("toggle_services_menu")}),n[17]=o,n[18]=h,n[19]=v,n[20]=k):k=n[20];let C;n[21]!==k?(C=s.jsx(ft,{children:s.jsx("p",{children:k})}),n[21]=k,n[22]=C):C=n[22];let P;n[23]!==A||n[24]!==C?(P=s.jsxs(dt,{children:[A,C]}),n[23]=A,n[24]=C,n[25]=P):P=n[25];let D;n[26]!==c||n[27]!==r||n[28]!==a||n[29]!==S||n[30]!==g||n[31]!==b||n[32]!==f||n[33]!==d||n[34]!==v?(D=r?s.jsxs("div",{children:[c?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:v("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:f?.available?v("header.services.remoteUpdate.available",{version:f.version||""}):g?v("header.services.remoteUpdate.checking"):b||v("header.services.remoteUpdate.upToDate")})]}),f?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:S,children:v("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(rh,{embedded:!0,open:a,onOpenChange:ob,onHostSwitched:()=>d(!1)})]}):null,n[26]=c,n[27]=r,n[28]=a,n[29]=S,n[30]=g,n[31]=b,n[32]=f,n[33]=d,n[34]=v,n[35]=D):D=n[35];let F;n[36]!==D?(F=s.jsx(yn,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:D}),n[36]=D,n[37]=F):F=n[37];let B;return n[38]!==a||n[39]!==p||n[40]!==P||n[41]!==F?(B=s.jsxs(vn,{open:a,onOpenChange:p,children:[P,F]}),n[38]=a,n[39]=p,n[40]=P,n[41]=F,n[42]=B):B=n[42],B}),sb=(t,e)=>t===e?!0:!t||!e?!1:t.totalTokens===e.totalTokens&&t.percentage===e.percentage&&t.contextLimit===e.contextLimit&&(t.outputLimit??0)===(e.outputLimit??0)&&(t.normalizedOutput??0)===(e.normalizedOutput??0)&&t.thresholdLimit===e.thresholdLimit&&(t.lastMessageId??"")===(e.lastMessageId??""),nb=t=>{const e=t.trim();if(!e)return"";const n=e.split(/\s+/).filter(Boolean);if(n.length>=2){const r=n[0],o=n[1].slice(0,3),i=`${r} ${o}`.trim();return n.length>2||i.length<e.length?`${i}...`:i}return e.length>12?`${e.slice(0,9).trimEnd()}...`:e},rb=(t,e)=>{if(!t)return"-";try{return pu(t,e,{fallback:"-"})}catch{return"-"}},En=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ua=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,Ec=({onToggleLeftDrawer:t,onToggleRightDrawer:e,leftDrawerOpen:n,rightDrawerOpen:r})=>{In("ui.header.render");const{t:o}=mt(),i=xe(O=>O.setSessionSwitcherOpen),c=xe(O=>O.toggleSidebar),a=xe(O=>O.isSidebarOpen),d=xe(O=>O.openContextOverview),u=xe(O=>O.openContextPlan),h=xe(O=>O.closeContextPanel),f=xe(O=>O.activeMainTab),g=xe(O=>O.setActiveMainTab),b=xe(O=>O.shortcutOverrides),S=xe(O=>O.timeFormatPreference),v=Vt(O=>O.getCurrentModel),p=tr(),m=Je(O=>O.getContextUsage),x=Je(O=>!!O.newSessionDraft?.open),w=Je(O=>O.currentSessionId),j=oh(w??""),N=lu(w??""),A=cf(w??""),k=Rs(qn(l.useCallback(O=>{if(!w)return null;const Le=O.activeSessions.find(vt=>vt.id===w);if(!Le)return null;const Xe=Le;return{title:Le.title??null,directory:Xe.directory??null,created:Le.time?.created??null,slug:Xe.slug??null,shareUrl:Le.share?.url??null,parentId:Le.parentID??null}},[w]))),C=qt(qn(O=>{if(!O.activeProjectId)return null;const Le=O.projects.find(Xe=>Xe.id===O.activeProjectId);return Le?{id:Le.id,path:Le.path,label:Le.label}:null})),P=l.useMemo(()=>{if(!C)return null;const O=C.label?.trim();if(O)return O;const Le=C.path.split(/[\\/]/).filter(Boolean);return Le[Le.length-1]??null},[C]),D=Cs(O=>O.results),F=Cs(O=>O.fetchAllQuotas),B=Cs(O=>O.isLoading),E=Cs(O=>O.lastUpdated),_=Cs(O=>O.displayMode),W=Cs(O=>O.dropdownProviderIds),V=Cs(O=>O.loadSettings),K=Cs(O=>O.setDisplayMode),{isMobile:y}=pr(),I=Lr(O=>O.status),$=Lr(O=>O.setStatus),z=l.useRef(null),[G,J]=l.useState(()=>typeof window>"u"?!1:$n()),Z=l.useMemo(()=>Ri(),[]),re=cu(),[ee,he]=l.useState(!1),be=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:Y,side:we}=Ku(),me=l.useMemo(()=>{if(typeof window>"u")return null;const O=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof O=="number"&&Number.isFinite(O)&&O>0)return O;if(typeof navigator>"u")return null;const Le=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Le)return null;const Xe=Number.parseInt(Le[1],10),vt=Number.parseInt(Le[2],10);return Number.isNaN(Xe)?null:Xe===10?vt:Xe},[]);Ge.useEffect(()=>{typeof window>"u"||J($n())},[]);const Q=v(),pe=Q&&typeof Q.limit=="object"&&Q.limit!==null?Q.limit:null,ve=pe&&typeof pe.context=="number"?pe.context:0,Te=pe&&typeof pe.output=="number"?pe.output:0,ke=m(ve,Te),[Ie,Ne]=l.useState(null),Ae=!w||j;Ge.useEffect(()=>{if(!w){Ne(O=>O===null?O:null);return}if(ke&&ke.totalTokens>0){Ne(O=>sb(O,ke)?O:ke);return}Ae&&Ne(O=>O===null?O:null)},[ke,w,Ae]);const Se=xe(O=>O.isSessionSwitcherOpen),Oe=I?.connected?I.user?.avatarUrl??null:null,ne=I?.connected?I.user?.login??null:null,ce=I?.accounts??[],[Re,te]=l.useState(!1),[ae,de]=l.useState(!1),[H,ge]=l.useState(!1),[ue,M]=l.useState(!1),[oe,De]=l.useState("Local"),[fe,X]=l.useState(!0),[le,se]=l.useState(!1),[T,ie]=l.useState(null),[je,Pe]=l.useState(!1),[U,Be]=l.useState(null),Fe=l.useMemo(()=>nb(oe),[oe]),[Ye,at]=l.useState("usage"),st=l.useMemo(()=>er(),[]),ct=xe(O=>O.workStatusPanelVisible),bt=xe(O=>O.workStatusPanelEnabled),rt=xe(O=>O.setWorkStatusPanelEnabled),gt=xe(O=>O.workStatusPanelFits),it=xe(O=>O.workStatusOverlayOpen),Et=xe(O=>O.setWorkStatusOverlayOpen),Dt=bt&>||it,Bt=l.useCallback(()=>{if(bt&&!gt){Et(!it);return}rt(!bt)},[Et,rt,it,bt,gt]),qe=!st&&!ct&&f==="chat"&&!!Ie&&Ie.totalTokens>0,zt=Ie&&Ie.contextLimit>0?Math.min(999,Ie.totalTokens/Ie.contextLimit*100):0,Nt=l.useCallback(async()=>{if(!(typeof window>"u"||!G))try{if(Ti()){De("Local"),X(!0);return}X(!1);const O=await Zd(),Le=ih(),Xe=ah([lh(Le),...O.hosts]);if(Xe.id===ch){De("Local"),X(!0);return}De(eu(Xe.label.trim()||"Instance"))}catch{De("Local"),X(!0)}},[G]);Ge.useEffect(()=>(Nt(),Mi(()=>{Nt()})),[Nt]);const xt=l.useCallback(async()=>{if(fe){ie(null),Be(null);return}Pe(!0),Be(null);try{const O=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Le=await ms(`/api/openchamber/update-check?${O.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Le.ok)throw new Error(`Server responded with ${Le.status}`);const Xe=await Le.json();ie({available:Xe.available??!1,version:Xe.version,currentVersion:Xe.currentVersion??"unknown",body:Xe.body,nextSuggestedCheckInSec:typeof Xe.nextSuggestedCheckInSec=="number"?Xe.nextSuggestedCheckInSec:void 0,packageManager:Xe.packageManager,updateCommand:Xe.updateCommand})}catch(O){ie(null),Be(O instanceof Error?O.message:o("header.services.remoteUpdate.error"))}finally{Pe(!1)}},[fe,o]);l.useEffect(()=>{ie(null),Be(null),se(!1)},[fe,oe]),l.useEffect(()=>{if(!G||fe)return;const O=3e3,Le=3600*1e3;let Xe=!1,vt=null;const Ut=as=>{vt=window.setTimeout(()=>{if(Xe||typeof document<"u"&&document.visibilityState!=="visible"){Ut(Le);return}xt().finally(()=>{Xe||Ut(Le)})},as)};return Ut(O),()=>{Xe=!0,vt!==null&&window.clearTimeout(vt)}},[xt,fe,oe,G]);const Pt=l.useCallback(()=>{if(T?.available){se(!0);return}xt()},[xt,T?.available]);dh();const Mt=Cs(O=>O.selectedModels),Xt=Cs(O=>O.expandedFamilies),Qe=Cs(O=>O.toggleFamilyExpanded),ht=l.useMemo(()=>{const O=[];for(const Le of du){if(!W.includes(Le.id))continue;const Xe=D.find(bs=>bs.providerId===Le.id),vt=Xe?.usage?.windows??{},Ut=Xe?.usage?.models,as=Object.entries(vt),ts={providerId:Le.id,providerName:Le.name,entries:as,error:Xe&&!Xe.ok&&Xe.configured?Xe.error:void 0};if(Ut&&Object.keys(Ut).length>0){const bs=Mt[Le.id]??[],Nr=bs.length>0,zr=uh(Ut,Le.id),ea=fh(Le.id),ta=mh(ea);ts.modelFamilies=[];for(const ln of ta){const Dn=zr.get(ln.id)??[];if(Dn.length===0)continue;const rr=Nr?Dn.filter(Ar=>bs.includes(Ar)):Dn;if(rr.length===0)continue;const Fn=[];for(const Ar of rr){const lo=Ut[Ar];if(lo?.windows){const Dr=Object.entries(lo.windows);Dr.length>0&&Fn.push([Ar,Dr[0][1]])}}Fn.length>0&&ts.modelFamilies.push({familyId:ln.id,familyLabel:ln.label,models:Fn})}const ao=zr.get(null)??[],On=Nr?ao.filter(ln=>bs.includes(ln)):ao;if(On.length>0){const ln=[];for(const Dn of On){const rr=Ut[Dn];if(rr?.windows){const Fn=Object.entries(rr.windows);Fn.length>0&&ln.push([Dn,Fn[0][1]])}}ln.length>0&&ts.modelFamilies.push({familyId:null,familyLabel:o("header.services.modelFamily.other"),models:ln})}}(as.length>0||ts.modelFamilies&&ts.modelFamilies.length>0||ts.error)&&O.push(ts)}return O},[W,D,Mt,o]),Ze=ht.length>0;l.useEffect(()=>{V()},[V]);const $e=l.useCallback(async O=>{K(O);try{await tu({usageDisplayMode:O})}catch(Le){console.warn("Failed to update usage display mode:",Le)}},[K]),St=l.useCallback(()=>{if(ue)return;M(!0);const O=new Promise(Le=>setTimeout(Le,500));Promise.all([F(),O]).finally(()=>{M(!1)})},[F,ue]),Lt=w?k??null:null,Ot=l.useRef(null),[ss,_t]=l.useState(0);l.useEffect(()=>{if(!w){Ot.current&&(Ot.current=null,_t(vt=>vt+1));return}if(Lt){Ot.current={sessionId:w,session:Lt,expiresAt:Date.now()+2e3};return}const O=Ot.current;if(!O||O.sessionId!==w)return;const Le=O.expiresAt-Date.now();if(Le<=0){Ot.current=null,_t(vt=>vt+1);return}const Xe=window.setTimeout(()=>{Ot.current?.sessionId===w&&(Ot.current=null),_t(vt=>vt+1)},Le);return()=>{window.clearTimeout(Xe)}},[w,Lt]);const Ct=(()=>{if(Lt)return Lt;if(!w)return null;const O=Ot.current;return O&&O.sessionId===w&&O.expiresAt>Date.now()?O.session:null})(),os=Je(O=>w?O.worktreeMetadata.get(w)?.path??"":""),hs=Je(O=>w?O.worktreeMetadata.get(w)?.branch?.trim()??null:null),Rt=uu(O=>w?O.getAttachment(w):void 0),$t=l.useMemo(()=>Rt?hh(Rt,{pending:o("gitView.empty.worktreeSetupInProgress")}):null,[o,Rt]),Wt=l.useMemo(()=>Rt?Rt.legacy?"legacy":Rt.degraded?"degraded":Rt.worktreeStatus==="pending"?"pending":Rt.worktreeStatus==="missing"?"missing":Rt.worktreeStatus==="invalid"?"invalid":Rt.attentionReason?"attention":null:null,[Rt]),is=l.useMemo(()=>En(os||""),[os]),Me=l.useMemo(()=>{const O=typeof Ct?.directory=="string"?Ct.directory:"";return En(O||"")},[Ct?.directory]),Ke=Je(O=>O.newSessionDraft?.open?En(O.newSessionDraft.bootstrapPendingDirectory??O.newSessionDraft.directoryOverride??""):""),ze=l.useMemo(()=>is||Me||Ke,[Ke,Me,is]),He=xe(l.useCallback(O=>{const Le=En(ze||"");return Le?ua(O.contextPanelByDirectory[Le]):null},[ze])),Ve=Je(O=>{const Le=En(is||Me||"");if(!Le)return null;for(const Xe of O.availableWorktreesByProject.values()){const Ut=Xe.find(as=>En(as.path)===Le)?.branch?.trim();if(Ut)return Ut}return null}),Jt=ph(ze||null)||hs||Ve,yt=!ct&&!!(P||Jt||!x&&Wt),Yt=l.useMemo(()=>{if(!w)return P??"OpenChamber";const O=Ct?.title?.trim();return O&&O.length>0?O:"Untitled Session"},[P,Ct?.title,w]),ps=ol(ze||void 0,{bootstrap:!1}),Zt=Fi(),Ss=Je(O=>O.updateSessionTitle),en=Je(O=>O.shareSession),Mn=Je(O=>O.unshareSession),Un=Je(O=>O.archiveSessions),Ps=Je(O=>O.deleteSessions),[Ms,tn]=l.useState(!1),[jn,Hs]=l.useState(!1),Es=l.useRef(!1),[kn,sn]=l.useState(""),[Ks,Gs]=l.useState(null),sr=l.useRef(null);l.useEffect(()=>{Es.current=!1,Hs(!1),tn(!1),sn(""),Gs(null)},[w]);const Cn=l.useCallback(()=>{w&&(sn(Ct?.title?.trim()||Yt),tn(!0))},[Ct?.title,w,Yt]),q=l.useCallback(async()=>{if(!w)return;const O=kn.trim();O&&O!==Ct?.title?.trim()&&await Ss(w,O),tn(!1)},[Ct?.title,w,kn,Ss]);l.useEffect(()=>{if(!Ms)return;const O=Le=>{const Xe=Le.target;(!Xe||!sr.current?.contains(Xe))&&q()};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[Ms,q]);const We=l.useCallback(()=>{w&&Xn(w).then(O=>{Ee[O.ok?"success":"error"](o(O.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Ee.error(o("sessions.sidebar.session.copyId.error")))},[w,o]),et=l.useCallback(async()=>{if(!w)return;const O=await en(w);if(O?.share?.url){const Le=await Xn(O.share.url);Ee[Le.ok?"success":"warning"](o("sessions.sidebar.session.share.successTitle"),{description:o(Le.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}Ee.error(o("sessions.sidebar.session.share.error"))},[w,en,o]),lt=l.useCallback(()=>{const O=Ct?.shareUrl;O&&Xn(O).then(Le=>{Ee[Le.ok?"success":"error"](o(Le.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>Ee.error(o("sessions.sidebar.session.share.copyUrlError")))},[Ct?.shareUrl,o]),Tt=l.useCallback(async()=>{if(!w)return;const O=await Mn(w);Ee[O?"success":"error"](o(O?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[w,o,Mn]),kt=l.useCallback(async()=>{if(!w||!ze){Ee.error(o("sessions.sidebar.session.export.nothingToExport"));return}try{await Zt.loadCompleteHistory(w,ze)}catch{Ee.error(o("sessions.sidebar.session.export.failedLoadHistory"));return}const O=Ea(ps.getState(),w).list;if(O.length===0){Ee.error(o("sessions.sidebar.session.export.nothingToExport"));return}const Le=rf(O,Ct?.title??null),Xe=lf(Ct?.title??null);await af(Le,Xe)||of(Le,Xe),Ee.success(o("sessions.sidebar.session.export.success"))},[Ct?.title,w,ps,ze,Zt,o]),pt=N?.type==="busy"||N?.type==="retry",ds=l.useCallback(()=>{if(!w||!Me||pt||A)return;const O=Rs.getState().activeSessions,Le=O.find(Ut=>Ut.id===w);if(!Le)return;const Xe=[],vt=[w];for(let Ut=0;Ut<vt.length;Ut+=1){const as=vt[Ut];for(const ts of O)ts.parentID===as&&(Xe.push(ts),vt.push(ts.id))}df({root:Le,descendants:Xe,sourceDirectory:Me,successMessage:o("sessions.sidebar.session.moveToWorktree.success"),failureMessage:o("sessions.sidebar.session.moveToWorktree.failed")})},[w,pt,A,Me,o]),vs=l.useCallback(async()=>{if(!w||!Ks)return;const O=Rs.getState().activeSessions,Le=[w];for(let as=0;as<Le.length;as+=1){const ts=Le[as];for(const bs of O)bs.parentID===ts&&!Le.includes(bs.id)&&Le.push(bs.id)}const Xe=Ks;if(Gs(null),(Xe==="archive"?await Un(Le):await Ps(Le)).failedIds.length>0){Ee.error(o(Xe==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Ee.success(o(Xe==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[Un,w,Ps,Ks,o]),es=xe(O=>O.isScheduledTasksDialogOpen),Ts=xe(O=>O.isArchivePageOpen),js=xe(O=>O.worktreesPageProjectId),Wn=xe(O=>O.isMultiRunLauncherOpen),nn=qt(O=>{if(!js)return null;const Le=O.projects.find(Xe=>Xe.id===js);return Le?.label?.trim()||Le?.path?.split("/").pop()||null}),nr=l.useMemo(()=>es?{title:o("sessions.scheduledTasks.dialog.title"),subtitle:null}:Ts?{title:o("sessions.archivePage.title"),subtitle:null}:js?{title:o("sessions.worktreesPage.title",{project:nn??""}),subtitle:null}:Wn?{title:o("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[Ts,Wn,es,o,js,nn]),rn=l.useMemo(()=>En(ze||C?.path||""),[C?.path,ze]),Nn=l.useMemo(()=>C?{id:C.id,path:C.path}:null,[C]),br=l.useRef(null);l.useEffect(()=>{!Nn||!rn||(br.current={projectRef:Nn,directory:rn})},[rn,Nn]);const yr=l.useMemo(()=>Nn&&rn?{projectRef:Nn,directory:rn}:br.current,[rn,Nn]),vr=il(O=>O.planModeEnabled),Ce=Je(O=>O.isSessionPlanAvailable),At=vr&&w?Ce(w):!1,Ht=At,ns=l.useRef("");l.useEffect(()=>{if(!vr){xe.getState().activeMainTab==="plan"&&xe.getState().setActiveMainTab("chat");return}if(!w)return;const O=`${w||"none"}:${Me||"none"}:${Ct?.created||0}:${Ct?.slug||"none"}`;ns.current!==O&&(ns.current=O),!At&&xe.getState().activeMainTab==="plan"&&xe.getState().setActiveMainTab("chat")},[vr,At,Ct?.slug,Ct?.created,w,Me]);const gs=l.useCallback(async O=>{if(!(!O||Re)){te(!0);try{const Le=p.github?await p.github.authActivate(O):await(async()=>{const Xe=await ms("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:O})}),vt=await Xe.json().catch(()=>null);if(!Xe.ok||!vt)throw new Error(vt?.error||Xe.statusText);return vt})();$(Le)}catch(Le){console.error("Failed to switch GitHub account:",Le)}finally{te(!1)}}},[Re,p.github,$]),us=l.useCallback(()=>{if(typeof document>"u")return;const O=document.activeElement;if(!O)return;const Le=O.tagName;(Le==="INPUT"||Le==="TEXTAREA"||Le==="SELECT"||O.isContentEditable)&&O.blur()},[]),on=l.useCallback(()=>{if(y){us(),i(!Se);return}c()},[us,y,Se,i,c]),ks=l.useCallback(()=>{ur("desktop_open_draft_mini_chat_window",{directory:En(ze||C?.path||""),projectId:C?.id??null,apiBaseUrl:fr(),clientToken:ko()}).catch(O=>{console.warn("[header] failed to open draft mini chat window",O)})},[C?.id,C?.path,ze]),qs=l.useCallback(()=>{if(x){ks();return}w&&ur("desktop_open_session_mini_chat_window",{sessionId:w,directory:En(ze||C?.path||""),apiBaseUrl:fr(),clientToken:ko()}).catch(O=>{console.warn("[header] failed to open session mini chat window",O)})},[C?.path,w,ks,x,ze]),wr=l.useCallback(()=>{const O=En(ze||"");if(!O)return;const Le=xe.getState().contextPanelByDirectory[O];if(ua(Le)==="context"){h(O);return}d(O)},[h,d,ze]),xs=He==="context",fs=l.useCallback(()=>{const O=En(ze||"");if(!O)return;const Le=xe.getState().contextPanelByDirectory[O];if(ua(Le)==="plan"){h(O);return}u(O)},[h,u,ze]),An=Ao,Sr=Jx,jr=l.useMemo(()=>ae?"services":n?"sessions":r?"git":f,[f,ae,n,r]),ro=l.useCallback(()=>{de(!1),n&&t&&t(),r&&e&&e(),!t&&Se&&i(!1)},[Se,n,t,e,r,i]),Ki=l.useCallback(()=>{n||de(!1),t?.()},[n,t]),Gi=l.useCallback(()=>{r||de(!1),e?.()},[e,r]),Oo=l.useMemo(()=>G&&be&&!ee?"5.5rem":re?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!G||Y)&&!st?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[G,ee,be,re,st,Y]);Ge.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",Oo)},[Oo]);const qi=a?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Yi=a?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";Ge.useEffect(()=>{if(!G||!be){he(!1);return}let O=!1;const Le=async()=>{try{const vt=await ur("desktop_is_window_fullscreen");O||he(vt===!0)}catch{O||he(!1)}},Xe=()=>{Le()};return Le(),window.addEventListener("openchamber:window-resized",Xe),()=>{O=!0,window.removeEventListener("openchamber:window-resized",Xe)}},[G,be]);const Fo=l.useMemo(()=>!G||!be||me===null?"":me>=26?"h-12":me<=15?"h-14":"",[G,be,me]),Qi=l.useMemo(()=>{if(!(G&&!Y||st))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[G,st,Y]),kr=l.useCallback(()=>{if(typeof document>"u")return;const O=z.current?.getBoundingClientRect().height;O&&document.documentElement.style.setProperty("--oc-header-height",`${O}px`)},[]);Ge.useEffect(()=>{if(typeof window>"u")return;kr();const O=z.current;if(!O||typeof ResizeObserver>"u")return()=>{};let Le=0;const Xe=()=>{Le||(Le=requestAnimationFrame(()=>{Le=0,kr()}))},vt=new ResizeObserver(Xe);return vt.observe(O),window.addEventListener("resize",Xe),window.addEventListener("orientationchange",Xe),()=>{Le&&cancelAnimationFrame(Le),vt.disconnect(),window.removeEventListener("resize",Xe),window.removeEventListener("orientationchange",Xe)}},[kr]),Ge.useEffect(()=>{kr()},[kr,y,Fo]);const oo=l.useCallback(async O=>{const Le=O.target;Le.closest(".app-region-no-drag")||Le.closest("button, a, input, select, textarea")||O.button===0&&G&&await Rm()},[G]),Vn=l.useMemo(()=>{if(y){const O=[{id:"chat",label:o("layout.mainTab.chat"),icon:"chat-4"}];return Ht&&O.push({id:"plan",label:o("layout.mainTab.plan"),icon:"file-text"}),O.push({id:"diff",label:o("layout.mainTab.diff"),icon:"diff"},{id:"files",label:o("layout.mainTab.files"),icon:"folder-6"},{id:"terminal",label:o("layout.mainTab.terminal"),icon:"terminal-box"},{id:"context",label:o("layout.mainTab.context"),icon:"file-list-2"},{id:"diagram",label:o("layout.mainTab.diagram"),icon:"file"}),O}return[]},[y,Ht,o]),$r=l.useCallback(O=>Bi(Or(O,b)),[b]);Ge.useEffect(()=>{!y&&f!=="chat"&&f!=="terminal"&&f!=="diagram"&&g("chat")},[f,y,g]);const io=l.useMemo(()=>{const O=[];return G&&O.push({value:"instance",label:o("layout.services.instance"),icon:s.jsx(R,{name:"server",className:"h-3.5 w-3.5"})}),O},[G,o]),Bo=l.useMemo(()=>[{id:"usage",label:o("layout.services.usage"),icon:s.jsx(R,{name:"timer",className:"h-3.5 w-3.5"})},{id:"mcp",label:"MCP",icon:s.jsx(fu,{className:"h-3.5 w-3.5"})}],[o]);Ge.useEffect(()=>{const O=Le=>{if(mu(Le)&&!Le.shiftKey&&!Le.altKey){const Xe=parseInt(Le.key,10);Xe>=1&&Xe<=Vn.length&&(Le.preventDefault(),y&&(us(),ro()),g(Vn[Xe-1].id))}};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[us,ro,y,g,Vn]),Ge.useEffect(()=>{const O=Le=>{const Xe=Or("toggle_services_menu",b);if(oa(Le,Xe)){Le.preventDefault(),H?ge(!1):(ge(!0),Nt());return}const vt=Or("cycle_services_tab",b);if(oa(Le,vt)){if(Le.preventDefault(),io.length===0)return;ge(!0),Nt();return}const Ut=Or("toggle_context_plan",b);oa(Le,Ut)&&(Le.preventDefault(),fs())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[b,H,io,D.length,F,Nt,fs]);const Xi=O=>{const Le=f===O.id,Xe=O.icon==="diff",vt=Xe?null:O.icon,Ut=O.id==="chat",as=bs=>Xe?s.jsx(Nc,{size:bs}):vt?s.jsx(R,{name:vt,className:`h-${bs/4} w-${bs/4}`}):null,ts=s.jsxs("button",{type:"button",onClick:()=>g(O.id),className:ye("relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors",Le?"app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none":"app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",Ut&&!y&&"min-w-[100px] justify-center"),"aria-label":O.label,"aria-selected":Le,role:"tab",children:[y?as(20):s.jsxs(s.Fragment,{children:[as(16),s.jsx("span",{className:"header-tab-label",children:O.label})]}),O.badge!==void 0&&O.badge>0&&s.jsx("span",{className:"header-tab-badge typography-micro text-status-info font-medium",children:O.badge})]});return s.jsx(l.Fragment,{children:ts},O.id)},Ji=s.jsxs(s.Fragment,{children:[s.jsx(hx,{directory:rn,className:"mr-1"}),G?s.jsx(tb,{isDesktopApp:G,currentInstanceLabel:oe,compactCurrentInstanceLabel:Fe,currentInstanceIsLocal:fe,isDesktopServicesOpen:H,setIsDesktopServicesOpen:ge,refreshCurrentInstanceLabel:Nt,shortcutLabel:$r,remoteUpdateInfo:T,remoteUpdateChecking:je,remoteUpdateError:U,onOpenRemoteUpdate:Pt}):null,s.jsx(eb,{isMobile:y,githubAuthStatus:I,githubAccounts:ce,githubAvatarUrl:Oe,githubLogin:ne,isSwitchingGitHubAccount:Re,handleGitHubAccountSwitch:gs})]}),Lo=Z&&(x||!!w),an=()=>s.jsxs("div",{onMouseDown:oo,className:ye("app-region-drag relative flex h-12 select-none items-center pr-3",Fo),style:Qi,role:"tablist","aria-label":o("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:qi}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Yi}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[nr?s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:nr.title}),nr.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:nr.subtitle}):null]}):s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[a?null:s.jsx(zg,{align:"start",children:s.jsx("button",{type:"button",className:An,"aria-label":o("sessions.switcher.openAria"),children:s.jsx(R,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[Ms?s.jsxs("form",{ref:sr,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onSubmit:O=>{O.preventDefault(),q()},children:[s.jsx("input",{value:kn,onChange:O=>sn(O.target.value),autoFocus:!0,onKeyDown:O=>{O.stopPropagation(),O.key==="Escape"&&tn(!1)},placeholder:o("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":o("sessions.sidebar.session.rename.save"),title:o("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>tn(!1),"aria-label":o("sessions.sidebar.session.rename.cancel"),title:o("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:x?o("sessions.switcher.draftTitle"):Yt}),yt?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[P?s.jsx("span",{className:"truncate",children:P}):null,Jt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(R,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:Jt})]}):null,!x&&Wt?s.jsxs("span",{className:ye("inline-flex min-w-0 items-center gap-0.5",Wt==="attention"||Wt==="invalid"||Wt==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(R,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:$t})]}):null]}):null]}),s.jsx("div",{className:ye("flex h-[18px] shrink-0 items-center justify-center",yt?"self-start":"self-center"),children:w&&!x&&!Ms?s.jsxs(vn,{open:jn,onOpenChange:Hs,onOpenChangeComplete:O=>{!O&&Es.current&&(Es.current=!1,Cn())},children:[s.jsx(bn,{asChild:!0,children:s.jsx(nt,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":o("header.sessionActions.openAria"),children:s.jsx(R,{name:"more",className:"size-4"})})}),s.jsxs(yn,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Gt,{onClick:()=>{Es.current=!0},children:[s.jsx(R,{name:"pencil-ai",className:"mr-2 size-4"}),o("sessions.sidebar.session.menu.rename")]}),s.jsxs(Gt,{onClick:We,children:[s.jsx(R,{name:"file-copy",className:"mr-2 size-4"}),o("sessions.sidebar.session.menu.copyId")]}),s.jsx(gn,{}),Ct?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Gt,{onClick:lt,children:[s.jsx(R,{name:"file-copy",className:"mr-2 size-4"}),o("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Gt,{onClick:()=>{Tt()},children:[s.jsx(R,{name:"link-unlink-m",className:"mr-2 size-4"}),o("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Gt,{onClick:()=>{et()},children:[s.jsx(R,{name:"share-2",className:"mr-2 size-4"}),o("sessions.sidebar.session.menu.share")]}),s.jsxs(Gt,{onClick:()=>{kt()},children:[s.jsx(R,{name:"download",className:"mr-2 size-4"}),o("sessions.sidebar.session.menu.exportMarkdown")]}),!st&&Ct&&!Ct.parentId?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Gt,{disabled:!Me||pt||A,onClick:ds,className:"w-full",children:[s.jsx(R,{name:"folder-shared",className:"mr-2 size-4"}),o("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(ft,{side:"right",className:"max-w-72",children:o(A?"sessions.sidebar.session.moveToWorktree.tooltipMoving":pt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(gn,{}),s.jsxs(Gt,{onClick:()=>Gs("archive"),children:[s.jsx(R,{name:"inbox-archive",className:"mr-2 size-4"}),o("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Gt,{className:"text-destructive focus:text-destructive",onClick:()=>Gs("delete"),children:[s.jsx(R,{name:"delete-bin",className:"mr-2 size-4"}),o("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}),Vn.length>0&&s.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1",children:Vn.map(O=>Xi(O))}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[qe&&Ie?s.jsx(Ug,{totalTokens:Ie.totalTokens,percentage:zt,colorPercentage:Ie.percentage,contextLimit:Ie.contextLimit,outputLimit:Ie.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:wr,pressed:xs,className:Lo?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(Zx,{visible:Lo,title:o(x?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:o(x?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:qs,className:ye(An,"mr-1"),Icon:"picture-in-picture-2"}),f==="chat"&&!st?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":Dt,"aria-label":o("header.workStatusPanel.toggleAria"),onClick:Bt,className:ye(Ao,"mr-1",Dt?"text-foreground":"text-muted-foreground/50"),children:s.jsx(R,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(ft,{side:"bottom",children:o(bt&&!gt?it?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":bt?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}):null,Ji,s.jsx(Gu,{visible:Y&&we==="right",position:"right"})]})]})]}),Zi=()=>s.jsxs("div",{className:"app-region-drag relative flex items-center gap-2 px-3 py-2 select-none",children:[s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t?s.jsx("button",{type:"button",onClick:Ki,className:ye(Sr,jr==="sessions"&&"bg-interactive-selection text-interactive-selection-foreground"),"aria-label":o(n?"header.actions.closeSessionsAria":"header.actions.openSessionsAria"),children:s.jsx(R,{name:"layout-left",className:"h-5 w-5"})}):Se?s.jsx("button",{type:"button",onClick:()=>i(!1),className:"app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active","aria-label":o("header.actions.backAria"),children:s.jsx(R,{name:"arrow-left-s",className:"h-5 w-5"})}):s.jsx("button",{type:"button",onClick:on,className:"app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active","aria-label":o("header.actions.openSessionsAria"),children:s.jsx(R,{name:"play-list-add",className:"h-5 w-5"})}),!t&&Se&&s.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:o("header.sessions.title")})]}),(!Se||!!t)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"app-region-no-drag flex min-w-0 flex-1 items-center",children:s.jsx("div",{className:"flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain",children:s.jsx("div",{className:"flex w-max items-center gap-1 pr-1",children:s.jsx("div",{className:"flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5",role:"tablist","aria-label":o("header.navigation.mainAria"),children:Vn.map(O=>{const Le=f===O.id,Xe=O.icon==="diff",vt=Xe?null:O.icon;return s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>{y&&(us(),ro()),g(O.id)},"aria-label":O.label,"aria-selected":Le,role:"tab",className:ye(Sr,"relative rounded-lg",jr===O.id&&"bg-interactive-selection text-interactive-selection-foreground"),children:[Xe?s.jsx(Nc,{className:"h-5 w-5"}):vt?s.jsx(R,{name:vt,className:"h-5 w-5"}):null,O.badge!==void 0&&O.badge>0&&s.jsx("span",{className:"absolute -top-1 -right-1 text-[10px] font-semibold text-primary",children:O.badge}),O.showDot&&s.jsx("span",{className:"absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary","aria-label":o("header.changes.availableAria")})]})}),s.jsx(ft,{children:s.jsx("p",{children:O.label})})]},O.id)})})})})}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[yr&&s.jsx(tf,{projectRef:yr.projectRef,directory:yr.directory,compact:!0,allowMobile:!0,className:"h-9"}),s.jsxs(vn,{open:ae,onOpenChange:O=>{O&&(n&&t&&t(),r&&e&&e()),de(O),O&&D.length===0&&F()},children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":o("header.services.viewAria"),className:ye(Sr,jr==="services"&&"bg-interactive-selection text-interactive-selection-foreground"),children:s.jsx(R,{name:"stack",className:"h-5 w-5"})})})}),s.jsx(ft,{children:s.jsx("p",{children:o("header.services.title")})})]}),s.jsx(yn,{align:"end",sideOffset:0,positionerClassName:"!fixed !bottom-0 !left-0 !right-0 !top-[var(--oc-header-height,56px)] !transform-none",className:"h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden",children:s.jsxs("div",{className:"flex h-full flex-col bg-[var(--surface-elevated)]",children:[s.jsx("div",{className:"sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px",children:s.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-0",children:[s.jsx("div",{className:"h-10 min-w-0 flex-1",children:s.jsx(gl,{items:Bo,activeId:Ye,onSelect:O=>{const Le=O;at(Le),Le==="usage"&&D.length===0&&F()},layoutMode:"fit",variant:"active-pill",activePillInsetClassName:"gap-0.5 px-px py-0",activePillButtonClassName:"h-8",className:"h-full"})}),s.jsx("button",{type:"button",onClick:()=>de(!1),className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover","aria-label":o("header.services.closeAria"),children:s.jsx(R,{name:"close",className:"h-5 w-5"})})]})}),Ye==="mcp"&&s.jsx(Cg,{active:ae&&Ye==="mcp"}),Ye==="usage"&&s.jsxs("div",{className:"flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]",children:[s.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[s.jsxs("div",{className:"flex flex-col min-w-0 gap-0.5",children:[s.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:o("header.services.rateLimits")}),s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:rb(E,S)})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("div",{className:"flex items-center h-6",children:[s.jsx("button",{type:"button",onClick:()=>$e("usage"),className:ye("typography-ui-label px-1 pb-0.5 transition-colors",_==="usage"?"text-foreground border-b-2 border-[var(--primary-base)]":"text-muted-foreground hover:text-foreground"),children:o("header.services.used")}),s.jsx("span",{className:"text-muted-foreground typography-ui-label px-0.5",children:"·"}),s.jsx("button",{type:"button",onClick:()=>$e("remaining"),className:ye("typography-ui-label px-1 pb-0.5 transition-colors",_==="remaining"?"text-foreground border-b-2 border-[var(--primary-base)]":"text-muted-foreground hover:text-foreground"),children:o("header.services.remaining")})]}),s.jsx("button",{type:"button",className:ye("inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors","hover:text-foreground hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),onClick:St,disabled:B||ue,"aria-label":o("header.services.refreshRateLimitsAria"),children:s.jsx(R,{name:"refresh",className:ye("h-4 w-4",ue&&"animate-spin")})})]})]})}),!Ze&&s.jsx("div",{className:"px-4 py-6 text-center",children:s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:o("header.services.noRateLimits")})}),s.jsx("div",{className:"py-1",children:ht.map((O,Le)=>s.jsxs(l.Fragment,{children:[Le>0?s.jsx("div",{className:"mx-4 my-1 border-t border-[var(--interactive-border)]"}):null,s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",children:[s.jsx(pi,{providerId:O.providerId,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:O.providerName})]}),O.entries.length===0&&(!O.modelFamilies||O.modelFamilies.length===0)?s.jsx("div",{className:"px-4 pb-2",children:s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:O.error??o("header.services.noRateLimitsReported")})}):s.jsxs("div",{className:"space-y-3 px-4 pb-2",children:[O.entries.map(([Xe,vt])=>{const Ut=_==="remaining"?vt.remainingPercent:vt.usedPercent,as=Ta(vt.valueLabel,Ut),ts=gh(vt.resetAt,vt.resetAfterFormatted??vt.resetAtFormatted,S);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:hu(Xe)}),ts?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:ts}):null]}),s.jsx("span",{className:"typography-ui-label text-foreground tabular-nums",children:as==="-"?"":as})]}),s.jsx(gc,{percent:Ut,tonePercent:vt.usedPercent,className:"h-1.5"})]},`${O.providerId}-${Xe}`)}),O.modelFamilies&&O.modelFamilies.length>0&&s.jsx("div",{className:"space-y-0.5",children:O.modelFamilies.map(Xe=>{const Ut=(Xt[O.providerId]??[]).includes(Xe.familyId??"other");return s.jsxs(yi,{open:Ut,onOpenChange:()=>Qe(O.providerId,Xe.familyId??"other"),children:[s.jsxs(xl,{className:"flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:Xe.familyLabel}),Ut?s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):s.jsx(R,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"})]}),s.jsx(vi,{children:s.jsx("div",{className:"space-y-2.5 pb-1 pl-1 pt-1",children:Xe.models.map(([as,ts])=>{const bs=_==="remaining"?ts.remainingPercent:ts.usedPercent,Nr=Ta(ts.valueLabel,bs);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:xh(as)}),s.jsx("span",{className:"typography-ui-label text-foreground tabular-nums",children:Nr==="-"?"":Nr})]}),s.jsx(gc,{percent:bs,tonePercent:ts.usedPercent,className:"h-1.5"})]},`${O.providerId}-${as}`)})})})]},Xe.familyId??"other")})})]})]},O.providerId))})]})]})})]}),e?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Gi,className:ye(Sr,"relative",jr==="git"&&"bg-interactive-selection text-interactive-selection-foreground"),"aria-label":r?"Close git sidebar":"Open git sidebar",children:s.jsx(R,{name:"layout-right",className:"h-5 w-5"})})}),s.jsx(ft,{children:s.jsx("p",{children:r?"Close git sidebar":"Open git sidebar"})})]}):null]})]})]}),Cr=ye("header-safe-area relative z-10 bg-background",y&&"border-b border-border/50");return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:z,className:Cr,style:{"--padding-scale":"1"},children:y?Zi():an()}),s.jsx(Ws,{open:Ks!==null,onOpenChange:O=>{O||Gs(null)},children:s.jsxs(Vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Rn,{children:[s.jsx(wn,{children:o(Ks==="delete"?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Sn,{children:Ks==="delete"?o("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Yt}):o("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Yt})})]}),s.jsxs(gr,{children:[s.jsx(nt,{variant:"outline",size:"sm",onClick:()=>Gs(null),children:o("sessions.sidebar.dialogs.cancel")}),s.jsx(nt,{variant:"destructive",size:"sm",onClick:()=>{vs()},children:o(Ks==="delete"?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Lu,{open:le,onOpenChange:se,info:T,downloading:!1,downloaded:!1,progress:null,error:U,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function ob(){}const Tc=280,Ic=280,Rc=500,ib=({isOpen:t,isMobile:e,children:n,className:r,topBar:o})=>{const{t:i}=mt(),c=xe(k=>k.sidebarWidth),a=xe(k=>k.setSidebarWidth),[d,u]=l.useState(!1),h=l.useRef(0),f=l.useRef(c||Tc),g=l.useRef(null),b=l.useRef(null),S=l.useRef(null),v=l.useCallback(k=>Math.min(Rc,Math.max(Ic,k)),[]),p=l.useCallback(k=>{const C=S.current;C&&(C.style.width=`${k}px`,C.style.minWidth=`${k}px`,C.style.maxWidth=`${k}px`,C.style.setProperty("--oc-left-sidebar-width",`${k}px`))},[]);if(l.useEffect(()=>{e&&d&&u(!1)},[e,d]),l.useEffect(()=>{d||(g.current=null,b.current=null)},[d]),e)return null;const m=Math.min(Rc,Math.max(Ic,c||Tc)),x=t?m:0,w=k=>{if(t){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}b.current=k.pointerId,u(!0),h.current=k.clientX,f.current=x,g.current=x,p(x),k.preventDefault()}},j=k=>{if(e||!d||b.current!==k.pointerId)return;const C=k.clientX-h.current,P=v(f.current+C);g.current!==P&&(g.current=P,p(P))},N=k=>{if(b.current!==k.pointerId||e)return;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const C=v(g.current??x);b.current=null,g.current=null,u(!1),a(C)},A=d?g.current??x:x;return s.jsxs("aside",{ref:S,className:ye("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${A}px`,minWidth:`${A}px`,maxWidth:`${A}px`,"--oc-left-sidebar-width":`${d?A:m}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||x===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:ye("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:j,onPointerUp:N,onPointerCancel:N,role:"separator","aria-orientation":"vertical","aria-label":i("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:ye("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[o,s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:s.jsx(cs,{children:n})})]})]})},ab=()=>{const t=tt.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},Uo=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function lb(){const t=qt(f=>f.activeProjectId?f.projects.find(g=>g.id===f.activeProjectId)??null:null),e=Je(f=>f.currentSessionId),n=bh(e??null),r=Je(f=>e?f.worktreeMetadata.get(e)?.path??"":""),o=Je(f=>f.newSessionDraft?.open?Uo(f.newSessionDraft.bootstrapPendingDirectory??f.newSessionDraft.directoryOverride??""):""),i=l.useMemo(()=>Uo(r||""),[r]),c=l.useMemo(()=>{const f=typeof n?.directory=="string"?n.directory:"";return Uo(f||"")},[n?.directory]),a=i||c||o,d=l.useMemo(()=>Uo(a||t?.path||""),[t?.path,a]),u=l.useMemo(()=>t?{id:t.id,path:t.path}:null,[t]),h=l.useRef(null);return l.useEffect(()=>{u&&d&&(h.current={projectRef:u,directory:d})},[d,u]),l.useMemo(()=>u&&d?{projectRef:u,directory:d}:h.current,[u,d])}const Mc="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors",cb=()=>{const t=tt.c(35),{t:e}=mt(),n=xe(db),r=xe(ub),o=lb(),i=l.useRef(null),c=Bi(Or("toggle_sidebar",r)),{usesFramelessChrome:a,side:d}=Ku(),u=mb;let h,f;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{if(typeof document>"u")return;const _=i.current;if(!_)return;const W=()=>{const K=Math.max(_.getBoundingClientRect().width,_.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(K)}px`)};if(W(),typeof ResizeObserver>"u")return;const V=new ResizeObserver(W);return V.observe(_),()=>{V.disconnect()}},f=[],t[0]=h,t[1]=f):(h=t[0],f=t[1]),l.useEffect(h,f);const g="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let b;t[2]===Symbol.for("react.memo_cache_sentinel")?(b={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=b):b=t[2];const S="flex items-center gap-2";let v;t[3]!==a||t[4]!==d?(v=a&&d==="left"?s.jsx(Gu,{visible:!0,position:"left"}):null,t[3]=a,t[4]=d,t[5]=v):v=t[5];let p;t[6]!==e||t[7]!==a?(p=a?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,"aria-label":e("header.actions.openAppMenuAria"),className:ye(Mc,"shrink-0"),children:s.jsx(R,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(ft,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=a,t[8]=p):p=t[8];const m=dt;let x;t[9]!==e?(x=e("header.actions.openSessionsAria"),t[9]=e,t[10]=x):x=t[10];let w,j;t[11]===Symbol.for("react.memo_cache_sentinel")?(w=ye(Mc,"shrink-0"),j=s.jsx(R,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=w,t[12]=j):(w=t[11],j=t[12]);let N;t[13]!==x||t[14]!==n?(N=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":x,className:w,children:j})}),t[13]=x,t[14]=n,t[15]=N):N=t[15];const A=ft,k=e("header.actions.openSessionsWithShortcut",{shortcut:c});let C;t[16]!==k?(C=s.jsx("p",{children:k}),t[16]=k,t[17]=C):C=t[17];let P;t[18]!==A||t[19]!==C?(P=s.jsx(A,{children:C}),t[18]=A,t[19]=C,t[20]=P):P=t[20];let D;t[21]!==m||t[22]!==N||t[23]!==P?(D=s.jsxs(m,{children:[N,P]}),t[21]=m,t[22]=N,t[23]=P,t[24]=D):D=t[24];let F;t[25]!==o?(F=o?s.jsx(tf,{projectRef:o.projectRef,directory:o.directory}):null,t[25]=o,t[26]=F):F=t[26];let B;t[27]!==D||t[28]!==F||t[29]!==v||t[30]!==p?(B=s.jsxs("div",{ref:i,className:S,children:[v,p,D,F]}),t[27]=D,t[28]=F,t[29]=v,t[30]=p,t[31]=B):B=t[31];let E;return t[32]!==B||t[33]!==b?(E=s.jsx("div",{className:g,style:b,children:B}),t[32]=B,t[33]=b,t[34]=E):E=t[34],E};function db(t){return t.toggleSidebar}function ub(t){return t.shortcutOverrides}function fb(t){console.warn("[titlebar] failed to open app menu",t)}function mb(t){const e=t.currentTarget.getBoundingClientRect();ur("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(fb)}const Oc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function hb(t,e,n){const r=tt.c(5),[o,i]=l.useState();let c,a;return r[0]!==n||r[1]!==t||r[2]!==e?(c=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let d=!1;return(async()=>{const[u,h]=await Promise.all([yh(t),vh(t)]).catch(pb);if(d)return;const f=Oc(u),g=Oc(h);if(!f||!g||g===f)return;const b=n||"",S=g.split("/").filter(Boolean).pop()||g;i({source:"sdk",path:g,projectDirectory:f,branch:b,label:b||S,name:S,worktreeRoot:g,worktreeStatus:"ready",headState:b?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=c,r[4]=a):(c=r[3],a=r[4]),l.useEffect(c,a),e??o}function pb(){return["",""]}class Vi extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const Hi="/api/walkthrough",uf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),ff=()=>new Vi("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),gb=t=>!uf(t)&&(t.ok||t.status===404),wl=async(t,e)=>{if(gb(t))throw ff();const n=await t.json().catch(()=>null);throw new Vi(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},mf=async t=>{if(!uf(t))throw ff();try{return await t.json()}catch{throw new Vi("The server returned a malformed walkthrough response")}};async function xb(t,e,n={}){const r=await ms(Hi,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?mf(r):wl(r,"Failed to load walkthrough")}async function bb(t,e,n={}){const r=await ms(`${Hi}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?mf(r):wl(r,"Failed to generate walkthrough")}async function yb(t,e){const n=await ms(`${Hi}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await wl(n,"Failed to cancel walkthrough generation")}async function vb(t,e,n){const r=await ms(`${Hi}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const o=await r.json().catch(()=>null);return typeof o?.stage=="string"?o.stage:null}const fo={status:"idle",stage:null,result:null,readiness:null,error:null},wb=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:`pr:${t.number}`,lr=(t,e)=>`${xn()}\0${t}\0${wb(e)}`,Fc=t=>t instanceof Vi?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},dn=new Map,mo=new Map,Sb=1e3,jb=xr()(qu((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,o)=>{const i=lr(n,r);t(c=>{const a={...c.selectedLanguage};return o?a[i]=o:delete a[i],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[lr(n,r)],selectModel:(n,r,o)=>{const i=lr(n,r);t(c=>{const a={...c.selectedModel};return o?a[i]=o:delete a[i],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[lr(n,r)],requestSource:(n,r)=>{t(o=>({requestedSource:{...o.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const o={...r.requestedSource};return delete o[n],{requestedSource:o}})},getEntry:(n,r)=>e().entries[lr(n,r)]??fo,load:async(n,r,o={})=>{if(!n)return;const i=lr(n,r);if(e().entries[i]?.status==="generating")return;dn.get(i)?.abort();const a=new AbortController;dn.set(i,a),t(d=>({entries:{...d.entries,[i]:{...d.entries[i]??fo,status:"loading",error:null}}}));try{const d=await xb(n,r,{model:e().selectedModel[i],language:o.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[i]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:o.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[i]:{...u.entries[i]??fo,status:"error",stage:null,error:Fc(d)}}}))}finally{dn.get(i)===a&&dn.delete(i)}},generate:async(n,r,o={})=>{if(!n)return;const i=lr(n,r);dn.get(i)?.abort();const c=new AbortController;dn.set(i,c),t(d=>({entries:{...d.entries,[i]:{...d.entries[i]??fo,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=mo.get(i);d!==void 0&&(clearInterval(d),mo.delete(i))};a(),mo.set(i,setInterval(()=>{vb(n,r).then(d=>{!d||c.signal.aborted||t(u=>{const h=u.entries[i];return!h||h.status!=="generating"||h.stage===d?u:{entries:{...u.entries,[i]:{...h,stage:d}}}})}).catch(()=>{})},Sb));try{const d=await bb(n,r,{force:o.force,model:e().selectedModel[i],language:o.language,signal:c.signal});if(c.signal.aborted)return;t(u=>({entries:{...u.entries,[i]:{status:"ready",stage:null,result:d,readiness:u.entries[i]?.readiness??null,error:null}}}))}catch(d){if(c.signal.aborted)return;t(u=>({entries:{...u.entries,[i]:{...u.entries[i]??fo,status:"error",stage:null,error:Fc(d)}}}))}finally{a(),dn.get(i)===c&&dn.delete(i)}},cancel:(n,r)=>{const o=lr(n,r);yb(n,r).catch(()=>{}),dn.get(o)?.abort(),dn.delete(o),t(i=>{const c=i.entries[o];return c?{entries:{...i.entries,[o]:{...c,status:c.result?"ready":"idle",stage:null,error:null}}}:i})},reset:()=>{for(const n of dn.values())n.abort();dn.clear();for(const n of mo.values())clearInterval(n);mo.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),kb="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)]",Cb=3e4,Bc=20,hf=(t,e)=>JSON.stringify([xn(),t,e]),Nb=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,o]=e;return typeof n!="string"||typeof r!="string"||typeof o!="number"?null:{runtimeKey:n,directory:r,number:o}}catch{return null}},Lc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),Wo=new Map,Ab=t=>{const e=Object.entries(t);return e.length<=Bc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,Bc))},_c=xr()((t,e)=>({entries:{},ensure:async(n,r,o,i)=>{const c=hf(r,o),a=i?.includeCheckDetails??!1,d=e().entries[c],u=d&&d.result&&Date.now()-d.fetchedAt<Cb&&(d.hasCheckDetails||!a);if(!i?.force&&u)return d.result;const h=`${c}::${a?"details":"plain"}`,g=Wo.get(`${c}::details`)??(a?null:Wo.get(h));if(g&&!i?.force)return g;const b=(async()=>{t(S=>({entries:{...S.entries,[c]:{...S.entries[c]??Lc(),isLoading:!0,error:null}}}));try{const S=await n.prContext(r,o,{includeDiff:!1,includeCheckDetails:a,sourceRepo:i?.sourceRepo??null});return t(v=>({entries:Ab({...v.entries,[c]:{result:S,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),S}catch(S){const v=S instanceof Error?S.message:"Failed to load pull request context";return t(p=>({entries:{...p.entries,[c]:{...p.entries[c]??Lc(),isLoading:!1,error:v}}})),null}finally{Wo.delete(h)}})();return Wo.set(h,b),b},invalidate:(n,r)=>{t(o=>{const i={};for(const[c,a]of Object.entries(o.entries)){const d=Nb(c);d&&d.directory===n&&(r==null||d.number===r)||(i[c]=a)}return{entries:i}})}})),Db=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const i of t){if(i.status==="in_progress"){e.pending+=1,e.inProgress+=1,i.startedAt&&(!n||i.startedAt<n)&&(n=i.startedAt);continue}if(i.status==="queued"){e.pending+=1,e.queued+=1;continue}const c=typeof i.conclusion=="string"?i.conclusion.toLowerCase():"";if(!c){e.pending+=1;continue}c==="success"||c==="neutral"||c==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},Pb=35e3,fa=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const o=e?Date.parse(e):n??Date.now();if(!Number.isFinite(o)||o<=r)return null;const i=Math.floor((o-r)/6e4);if(i<1)return"<1m";if(i<60)return`${i}m`;const c=Math.floor(i/60),a=i%60;return a>0?`${c}h ${a}m`:`${c}h`},ma=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},$c=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},Eb=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",o=e.mergeable===!1||r==="blocked"||r==="dirty";return n||o?"blocked":"open"},Tb=[2e3,5e3],zc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),dr=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):""},Ib=(t,e)=>{const n=dr(t);if(!n||n.includes("->"))return"";if(e){const o=`${e}/`;return n.startsWith(o)?n.slice(o.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},Rb=(t,e)=>`${t}::${e}`,Sl=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},ha=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const i=t.find(c=>c.name===n);if(i)return i}const r=Sl(e.trackingBranch);if(r){const i=r==="origin"?t.find(a=>a.name==="upstream"):null;if(i)return i;const c=t.find(a=>a.name===r);if(c)return c}const o=t.find(i=>i.name==="origin");return o||(t[0]??null)},Mb=t=>t.startsWith("pr-"),Ob=(t,e)=>{const n=Sl(e),r=new Map(t.map(c=>[c.name,c])),o=[],i=c=>{c&&(o.some(a=>a.name===c.name)||o.push(c))};return n&&i(r.get(n)),i(r.get("upstream")),i(r.get("origin")),t.filter(c=>!Mb(c.name)).forEach(c=>i(c)),t.forEach(c=>i(c)),o},ho=new Map,pa=Oi;function Fb(t,e){const[n,r]=l.useState(null),[o,i]=l.useState([]),c=l.useRef(null);return l.useEffect(()=>{r(null),i([])},[t]),l.useEffect(()=>{if(!t||!e?.repoUpstream||c.current===t)return;c.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||i(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:o}}const Bb=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:o=[],remoteBranches:i=[],onGeneratedDescription:c})=>{const{t:a}=mt(),d=xe(q=>q.timeFormatPreference),{github:u}=tr(),h=Lr(q=>q.status),f=Lr(q=>q.hasChecked),g=xe(q=>q.setSettingsDialogOpen),b=xe(q=>q.setSettingsPage),S=xe(q=>q.setActiveMainTab),v=Je(q=>q.currentSessionId),p=Je(q=>!!q.newSessionDraft?.open),{isMobile:m,hasTouchInput:x,screenWidth:w}=pr(),j=xe(q=>q.openContextSurface),N=jb(q=>q.requestSource),A=!m&&w>=768&&!er(),k=l.useCallback(()=>{b("github"),g(!0)},[g,b]),C=l.useMemo(()=>Rb(t,e),[t,e]),P=l.useMemo(()=>ho.get(C)??null,[C]),D=hn(q=>q.ensureEntry),F=hn(q=>q.setParams),B=hn(q=>q.startWatching),E=hn(q=>q.stopWatching),_=hn(q=>q.refresh),W=hn(q=>q.updateStatus),[V,K]=l.useState(()=>P?.title??zc(e)),[y,I]=l.useState(()=>P?.body??""),[$,z]=l.useState(()=>P?.draft??!1),[G,J]=l.useState(()=>P?.additionalContext??""),[Z,re]=l.useState(()=>{const q=typeof P?.targetBaseBranch=="string"?dr(P.targetBaseBranch):"";return q||dr(n)}),[ee,he]=l.useState("squash"),[be,Y]=l.useState(!1),[we,me]=l.useState(!1),[Q,pe]=l.useState(!1),[ve,Te]=l.useState(!1),[ke,Ie]=l.useState(!1),[Ne,Ae]=l.useState(!1),[Se,Oe]=l.useState(null),[ne,ce]=l.useState(""),[Re,te]=l.useState(""),[ae,de]=l.useState(!1),[H,ge]=l.useState(!1),[ue,M]=l.useState(()=>ha(o,{selectedRemoteName:P?.selectedRemoteName,trackingBranch:r})),[oe,De]=l.useState(!1),{detectedUpstream:fe,upstreamBranches:X}=Fb(t,u);l.useEffect(()=>{De(!1)},[t]);const le=o.some(q=>q.name==="upstream"),T=!!(t&&e&&n&&(e!==n||(le||fe!==null))),ie=l.useMemo(()=>Li(t,e,ue?.name??null),[t,e,ue?.name]),je=hn(q=>q.entries[ie]),Pe=je?.isLoading??!1,U=je?.status??null,Be=je?.error??null,Fe=je?.isInitialStatusResolved??!1,Ye=l.useMemo(()=>{const q=oe?null:ue?.name?.trim()||null,We=new Set;for(const Tt of i){const kt=Ib(Tt,q);!kt||kt==="HEAD"||We.add(kt)}if(oe)for(const Tt of X)Tt&&Tt!=="HEAD"&&We.add(Tt);const et=dr(n);et&&et!=="HEAD"&&We.add(et);const lt=dr(Z);return lt&<!=="HEAD"&&We.add(lt),Array.from(We).sort((Tt,kt)=>Tt.localeCompare(kt))},[n,i,ue?.name,Z,X,oe]);l.useEffect(()=>{if(o.length===0){ue&&M(null);return}(!ue||!o.some(q=>q.name===ue.name))&&M(ha(o,{selectedRemoteName:P?.selectedRemoteName,trackingBranch:r}))},[P?.selectedRemoteName,o,ue,r]),l.useEffect(()=>{const q=dr(n);if(!Z&&q){re(q);return}if(Ye.length!==0&&!Ye.includes(Z)){const We=Ye.includes(q)?q:Ye[0];We&&re(We)}},[Ye,n,Z]);const[at,st]=l.useState(()=>P?.activeSegment??"overview"),[ct,bt]=l.useState(new Set),[rt,gt]=l.useState(new Set),it=l.useRef(new Set),Et=l.useRef(null),Ft=l.useRef(!1),Dt=l.useRef(new Set),Bt=l.useRef([]);l.useEffect(()=>{fe&&!le&&De(!0)},[fe,le]),l.useEffect(()=>{oe&&fe?.defaultBranch&&re(fe.defaultBranch)},[oe,fe?.defaultBranch]);const qe=U?.pr??null,zt=qe?hf(t,qe.number):null,Nt=_c(q=>zt?q.entries[zt]:void 0),xt=_c(q=>q.ensure),Pt=Nt?.result??null,Mt=Nt?.isLoading??!1,Xt=l.useCallback(q=>{st(q);const We=ho.get(C);We&&ho.set(C,{...We,activeSegment:q})},[C]);l.useEffect(()=>{!qe||!u?.prContext||at==="overview"||xt(u,t,qe.number,{includeCheckDetails:at==="checks",sourceRepo:U?.repo??null})},[at,t,xt,u,qe,U?.repo]);const Qe=U?.checks??null,ht=(Qe?.pending??0)>0,Ze=Pt?.checkRuns??null,$e=Pt?.fetchedAt;l.useEffect(()=>{if(!Ze||Ze.length===0)return;const q=Db(Ze);W(ie,We=>{if(!We?.pr||typeof $e=="number"&&typeof We.fetchedAt=="number"&&$e<We.fetchedAt)return We;const et=We.checks;return et&&et.state===q.state&&et.total===q.total&&et.success===q.success&&et.failure===q.failure&&et.pending===q.pending&&et.inProgress===q.inProgress&&et.queued===q.queued&&et.startedAt===q.startedAt?We:{...We,checks:q,...typeof $e=="number"?{fetchedAt:$e}:{}}})},[Ze,$e,ie,W]),l.useEffect(()=>{if(at!=="checks"||!ht||!qe||!u?.prContext)return;const q=window.setInterval(()=>{xt(u,t,qe.number,{includeCheckDetails:!0,sourceRepo:U?.repo??null,force:!0})},Pb);return()=>window.clearInterval(q)},[at,ht,t,xt,u,qe,U?.repo]);const[St,Lt]=l.useState(()=>Date.now());l.useEffect(()=>{if(!ht)return;Lt(Date.now());const q=window.setInterval(()=>Lt(Date.now()),3e4);return()=>window.clearInterval(q)},[ht]);const Ot=qe?`${t}#${qe.number}`:null,ss=!!(Ot&&Se===Ot);l.useEffect(()=>{if(!u?.prContext||!qe||typeof qe.body=="string"&&qe.body.length>0)return;const q=`${t}#${qe.number}`;if(it.current.has(q))return;it.current.add(q),Oe(q);let We=!1;return xt(u,t,qe.number,{sourceRepo:U?.repo??null}).then(et=>{if(We)return;const lt=et?.pr;lt&&W(ie,Tt=>!Tt?.pr||Tt.pr.number!==qe.number?Tt:{...Tt,pr:{...Tt.pr,body:lt.body||""}})}).catch(()=>{}).finally(()=>{We||Oe(et=>et===q?null:et)}),()=>{We=!0}},[t,xt,u,qe,ie,U?.repo,W]),l.useEffect(()=>{if(!qe){Ae(!1),ce(""),te(""),Et.current=null;return}const q=Et.current!==null&&Et.current!==qe.number;q&&Ae(!1),(!Ne||q)&&(ce(qe.title||""),te(qe.body||"")),Et.current=qe.number},[Ne,qe]);const _t=l.useCallback(q=>{if(!q)return"";const We=Date.parse(q);return Number.isFinite(We)?gu(We,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):q},[d]),Ct=l.useMemo(()=>{const q=h?.user?.login;return typeof q=="string"?q.trim():""},[h]),os=l.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),hs=l.useCallback(q=>{const We=Ct.toLowerCase(),et=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return q.replace(et,(lt,Tt,kt)=>{const pt=`@${kt}`,ds=kt.toLowerCase();return`${Tt}[${pt}](https://github.com/${ds}${We&&ds===We?"?oc-self-mention=1":""})`})},[Ct]),Rt=l.useMemo(()=>{const q=(Pt?.issueComments??[]).map(lt=>({id:`issue-${lt.id}`,body:lt.body||"",authorName:lt.author?.name||lt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:lt.author?.login||null,avatarUrl:lt.author?.avatarUrl||null,createdAt:lt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),We=(Pt?.reviewComments??[]).map(lt=>({id:`review-${lt.id}`,body:lt.body||"",authorName:lt.author?.name||lt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:lt.author?.login||null,avatarUrl:lt.author?.avatarUrl||null,createdAt:lt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:lt.path||null,line:lt.line??null})),et=[...q,...We];return et.sort((lt,Tt)=>{const kt=lt.createdAt?Date.parse(lt.createdAt):0,pt=Tt.createdAt?Date.parse(Tt.createdAt):0,ds=Number.isFinite(kt)?kt:0,vs=Number.isFinite(pt)?pt:0;return ds-vs}),et},[Pt,a]),$t=l.useCallback(()=>{const q=v??(p?"draft":null);return q?{directory:t,sessionKey:q}:(Ee.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[v,t,p,a]),Wt=l.useCallback((q,We)=>{const et=We.authorLogin?`@${We.authorLogin}`:We.authorName,lt=We.path?` · ${We.path}${We.line?`:${We.line}`:""}`:"";Ia.getState().addDraft(q,{source:"pr-comment",fileLabel:`PR #${qe?.number??""} ${et}${lt}`,startLine:We.line??0,endLine:We.line??0,code:We.body,language:"markdown",text:""})},[qe?.number]),is=l.useCallback((q,We)=>{const et=q.status||"unknown",lt=q.conclusion??void 0,Tt=lt?`${et} / ${lt}`:et,kt=q.app?.name||q.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:We?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[We?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:q.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:kt?`${kt} · ${Tt}`:Tt})]}),q.detailsUrl?s.jsx(nt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:q.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(R,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),q.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:q.output.title}):null,q.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:q.output.summary}):null,q.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:q.output.text}):null,Array.isArray(q.annotations)&&q.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",q.annotations.length>20?` (showing 20/${q.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:q.annotations.slice(0,20).map((pt,ds)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[pt.title||pt.level||"Issue",pt.path?` · ${pt.path}`:"",typeof pt.startLine=="number"?`:${pt.startLine}`:"",typeof pt.endLine=="number"&&pt.endLine!==pt.startLine?`-${pt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:pt.message}),pt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:pt.rawDetails}):null]},`${pt.path||"file"}:${pt.startLine||ds}:${ds}`))})]}):null,q.job?.steps&&q.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:q.job.steps.map((pt,ds)=>{const vs=(pt.conclusion||"").toLowerCase(),es=vs&&!["success","neutral","skipped"].includes(vs),Ts=`${q.id??"run"}:${q.job?.jobId??"job"}:${pt.number??ds}:${pt.name}`,js=ct.has(Ts);return es?s.jsxs(yi,{open:js,children:[s.jsxs("button",{type:"button",onClick:()=>{bt(Wn=>{const nn=new Set(Wn);return nn.has(Ts)?nn.delete(Ts):nn.add(Ts),nn})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(es?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[js?s.jsx(R,{name:"arrow-down-s",className:"size-4"}):s.jsx(R,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:pt.name}),pt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:pt.conclusion}):null]}),s.jsx(vi,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof pt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",pt.number]}):null,pt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",pt.status]}):null,pt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",pt.conclusion]}):null,pt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",_t(pt.startedAt)]}):null,pt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",_t(pt.completedAt)]}):null]})})]},Ts):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:pt.name}),pt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:pt.conclusion}):null]},Ts)})})]}):null]})},[ct,_t,a]),[Me,Ke]=l.useState(!1),[ze,He]=l.useState(!1),Ve=l.useCallback(async()=>{if(!u?.prContext){Ee.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!qe)return;const q=$t();if(q){Ke(!0);try{const We=await xt(u,t,qe.number,{includeCheckDetails:!0,sourceRepo:U?.repo??null});if(!We){Ee.error(a("gitView.pr.toast.loadChecksFailed"));return}const lt=(We.checkRuns??[]).filter(kt=>ma(kt.conclusion));if(lt.length===0){Ee.message(a("gitView.pr.toast.noFailedChecks"));return}const Tt=Ia.getState();for(const kt of lt){const pt=(kt.annotations??[]).map(es=>[[es.level,es.title].filter(Boolean).join(" "),es.path?`${es.path}${typeof es.startLine=="number"?`:${es.startLine}`:""}`:null,es.message,es.rawDetails].filter(Boolean).join(`
|
|
38
|
-
`)),ds=(kt.job?.steps??[]).filter(es=>ma(es.conclusion)).map(es=>`step ${es.number??"?"}: ${es.name} → ${es.conclusion}`),vs=[`check: ${kt.job?.workflowName?`${kt.job.workflowName} / ${kt.name}`:kt.name}`,`status: ${kt.status??"unknown"} / ${kt.conclusion??"unknown"}`,kt.detailsUrl?`url: ${kt.detailsUrl}`:null,kt.output?.title?`title: ${kt.output.title}`:null,kt.output?.summary?`summary:
|
|
39
|
-
${kt.output.summary}`:null,ds.length>0?`failed steps:
|
|
40
|
-
${ds.join(`
|
|
41
|
-
`)}`:null,pt.length>0?`annotations:
|
|
42
|
-
${pt.join(`
|
|
43
|
-
---
|
|
44
|
-
`)}`:null].filter(Boolean).join(`
|
|
45
|
-
|
|
46
|
-
`);Tt.addDraft(q,{source:"pr-check",fileLabel:`PR #${qe.number} · ${kt.name}`,startLine:0,endLine:0,code:vs,language:"text",text:""})}S("chat")}catch(We){const et=We instanceof Error?We.message:String(We);Ee.error(a("gitView.pr.toast.loadChecksFailed"),{description:et})}finally{Ke(!1)}}},[t,xt,u,qe,$t,S,U?.repo,a]),jt=l.useCallback(async()=>{if(!u?.prContext){Ee.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!qe)return;const q=$t();if(q){He(!0);try{if(!await xt(u,t,qe.number,{sourceRepo:U?.repo??null})){Ee.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(Rt.length===0){Ee.message(a("gitView.pr.toast.noPrComments"));return}for(const et of Rt)Wt(q,et);S("chat")}catch(We){const et=We instanceof Error?We.message:String(We);Ee.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:et})}finally{He(!1)}}},[Wt,t,xt,u,qe,$t,S,U?.repo,a,Rt]),Jt=l.useCallback(async q=>{const We=$t();We&&(Wt(We,q),S("chat"))},[Wt,$t,S]),yt=l.useCallback(async q=>{await _(ie,q)},[ie,_]),Yt=l.useCallback(()=>{Bt.current.forEach(q=>{window.clearTimeout(q)}),Bt.current=Tb.map(q=>window.setTimeout(()=>{yt({force:!0,silent:!0,markInitialResolved:!0})},q))},[yt]);l.useEffect(()=>{if(!u?.prStatus||!T||o.length<=1||Ft.current||U?.pr)return;const q=`${C}::${ue?.name??""}`;if(Dt.current.has(q))return;Dt.current.add(q);const We=Ob(o,r).filter(Tt=>Tt.name!==ue?.name);if(We.length===0)return;let et=!1;return(async()=>{for(const Tt of We){if(et)return;try{if(!(await u.prStatus(t,e,Tt.name))?.pr)continue;if(et)return;M(pt=>pt?.name===Tt.name?pt:Tt);return}catch{}}})(),()=>{et=!0}},[e,T,t,u,o,ue?.name,C,U?.pr,r]),l.useEffect(()=>{D(ie),F(ie,{directory:t,branch:e,remoteName:ue?.name??null,canShow:T,github:u,githubAuthChecked:f,githubConnected:h?.connected??null})},[e,T,t,D,u,f,h?.connected,ie,ue?.name,F]),l.useEffect(()=>(B(ie),()=>{E(ie)}),[ie,B,E]),l.useEffect(()=>{const q=ho.get(C)??null;K(q?.title??zc(e)),I(q?.body??""),z(q?.draft??!1),re(q?.targetBaseBranch?dr(q.targetBaseBranch):dr(n));const We=ha(o,{selectedRemoteName:q?.selectedRemoteName,trackingBranch:r});M(et=>et?.name===We?.name?et:We)},[n,e,o,C,r]),l.useEffect(()=>{yt({markInitialResolved:!0})},[ie,yt]),l.useEffect(()=>{!T||!ue?.name||yt({force:!0,silent:!0,markInitialResolved:!0})},[T,yt,ue?.name]),l.useEffect(()=>{const q=U?.resolvedRemoteName?.trim();if(!q||Ft.current)return;const We=o.find(et=>et.name===q);We&&M(et=>et?.name===We.name?et:We)},[o,U?.resolvedRemoteName]),l.useEffect(()=>{const q=U?.pr?.state==="closed"||U?.pr?.state==="merged",We=je?.lastRefreshAt??0,et=Date.now()-We>6e4,lt=!q&&et,Tt=()=>{lt&&yt({force:!0,silent:!0})},kt=()=>{document.visibilityState==="visible"&<&&yt({force:!0,silent:!0})};return window.addEventListener("focus",Tt),document.addEventListener("visibilitychange",kt),()=>{window.removeEventListener("focus",Tt),document.removeEventListener("visibilitychange",kt)}},[yt,U?.pr?.state,je?.lastRefreshAt]),l.useEffect(()=>{f&&h?.connected===!1&&yt({force:!0,silent:!0,markInitialResolved:!0})},[f,h,yt]),l.useEffect(()=>{!t||!e||ho.set(C,{title:V,body:y,draft:$,additionalContext:G,targetBaseBranch:Z,selectedRemoteName:ue?.name,activeSegment:at})},[C,V,y,$,G,Z,ue?.name,t,e,at]),l.useEffect(()=>{const q=Bt.current;return()=>{q.forEach(We=>{window.clearTimeout(We)}),Bt.current=[]}},[]);const ps=l.useCallback(async()=>{if(!be&&t){Y(!0);try{const We={base:oe&&fe?.defaultBranchSha?fe.defaultBranchSha:Z,head:e};G&&(We.context=G);const et=await wh(t,We);et.title?.trim()&&K(et.title.trim()),et.body?.trim()&&I(et.body.trim()),c?.()}catch(q){const We=q instanceof Error?q.message:String(q);Ee.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:We})}finally{Y(!1)}}},[G,e,fe?.defaultBranchSha,t,be,c,Z,a,oe]),Zt=l.useCallback(async()=>{if(!u?.prCreate){Ee.error(a("gitView.pr.toast.githubApiUnavailable"));return}const q=V.trim();if(!q){Ee.error(a("gitView.pr.toast.titleRequired"));return}const We=Z.trim();if(!We){Ee.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!oe&&We===e){Ee.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}me(!0);try{const et=Sl(r),lt=oe&&fe,Tt=await u.prCreate({directory:t,title:q,head:e,base:We,...y.trim()?{body:y}:{},draft:$,...lt?{targetRepo:{owner:fe.owner,repo:fe.repo},headRemote:"origin"}:{...ue?{remote:ue.name}:{},...et&&et!==ue?.name?{headRemote:et}:{}}});Ee.success(a("gitView.pr.toast.prCreated")),W(ie,kt=>kt&&{...kt,pr:Tt}),await yt({force:!0}),Yt()}catch(et){const lt=et instanceof Error?et.message:String(et);Ee.error(a("gitView.pr.toast.createPrFailed"),{description:lt})}finally{me(!1)}},[y,e,fe,t,$,u,ie,yt,Yt,ue,Z,V,r,W,oe,a]),Ss=l.useCallback(async q=>{if(!u?.prMerge){Ee.error(a("gitView.pr.toast.githubApiUnavailable"));return}Te(!0);try{const We=await u.prMerge({directory:t,number:q.number,method:ee});We.merged?Ee.success(a("gitView.pr.toast.prMerged")):Ee.message(a("gitView.pr.toast.prNotMerged"),{description:We.message||a("gitView.pr.notMergeable")}),await yt({force:!0}),Yt()}catch(We){const et=We instanceof Error?We.message:String(We);Ee.error(a("gitView.pr.toast.mergeFailed"),{description:et}),q.url&&pa(q.url)}finally{Te(!1)}},[t,u,ee,yt,Yt,a]),en=l.useCallback(async q=>{if(!u?.prReady){Ee.error(a("gitView.pr.toast.githubApiUnavailable"));return}Ie(!0);try{await u.prReady({directory:t,number:q.number}),Ee.success(a("gitView.pr.toast.markedReady")),await yt({force:!0}),Yt()}catch(We){const et=We instanceof Error?We.message:String(We);Ee.error(a("gitView.pr.toast.markReadyFailed"),{description:et}),q.url&&pa(q.url)}finally{Ie(!1)}},[t,u,yt,Yt,a]),Mn=l.useCallback(async q=>{if(!u?.prUpdate){Ee.error(a("gitView.pr.toast.githubApiUnavailable"));return}const We=ne.trim();if(!We){Ee.error(a("gitView.pr.toast.titleRequired"));return}pe(!0);try{const et=await u.prUpdate({directory:t,number:q.number,title:We,body:Re});W(ie,lt=>lt&&{...lt,pr:{...lt.pr??q,...et}}),Ae(!1),Ee.success(a("gitView.pr.toast.prUpdated")),await yt({force:!0}),Yt()}catch(et){const lt=et instanceof Error?et.message:String(et);Ee.error(a("gitView.pr.toast.updatePrFailed"),{description:lt})}finally{pe(!1)}},[t,Re,ne,u,ie,yt,Yt,W,a]);if(!T)return s.jsx("section",{className:"border-0 bg-transparent rounded-none",children:s.jsxs("div",{className:"space-y-1 pt-3",children:[s.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("gitView.pullRequest.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const Un=U?.repo?.url||null,Ps=oe&&fe?.url?fe.url:Un,Ms=!!U?.canMerge,tn=!!U?.connected,jn=f&&U?.connected===!1,Hs=Eb(U),Es=Hs?`var(--pr-${Hs})`:"var(--status-info)",kn=Hs==="draft"?"git-pr-draft":Hs==="merged"?"git-merge":Hs==="closed"?"git-close-pull-request":"git-pull-request",sn=qe?[`${qe.state}${qe.draft?" (draft)":""}`,qe.mergeable===!1?a("gitView.pr.notMergeable"):null,qe.state==="open"&&typeof qe.mergeableState=="string"&&qe.mergeableState&&qe.mergeableState!=="unknown"?qe.mergeableState:null].filter(Boolean).join(" · "):"",Ks=Qe?Qe.total>0?`${Qe.success}/${Qe.total} ${a("gitView.pr.checks.label")}`:`${Qe.state} ${a("gitView.pr.checks.label")}`:"";return s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[s.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[qe?s.jsxs(nt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{pa(qe.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(R,{name:kn,className:"size-4 shrink-0",style:{color:Es}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(R,{name:kn,className:"size-4 shrink-0",style:{color:"var(--surface-muted-foreground)"}}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:a("gitView.pullRequest.title")}),qe?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",qe.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Pe?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):null,s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex size-5 items-center justify-center rounded hover:bg-interactive-hover/60 disabled:opacity-40",disabled:Pe,onClick:()=>{yt({force:!0})},"aria-label":a("gitView.pr.actions.refreshAria"),children:s.jsx(R,{name:"refresh",className:"size-3.5 text-muted-foreground"})})}),s.jsx(ft,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]})]})]}),qe?s.jsxs("div",{className:"@container/pr-actions flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{style:{color:Es},children:sn}),Qe?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${$c(Qe.state)}`}),Ks]}):null,r&&ue&&r.split("/")[0]!==ue.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",ue.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[A?s.jsxs(nt,{variant:"outline",size:"sm",className:ye("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",kb),onClick:()=>{N(t,{kind:"pr",number:qe.number}),j(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(R,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,Ms&&qe.draft&&qe.state==="open"?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(nt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>en(qe),disabled:ke||ve||Q||Ne,"aria-label":a("gitView.pr.actions.markReadyAria"),children:ke?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(ft,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,Ms?s.jsxs(s.Fragment,{children:[s.jsxs(Ls,{value:ee,onValueChange:q=>he(q),disabled:ve||qe.state!=="open",children:[s.jsx(_s,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(Ds,{})}),s.jsxs($s,{children:[s.jsx(rs,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(rs,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(rs,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(nt,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>Ss(qe),disabled:ve||ke||qe.state!=="open"||qe.draft||Q||Ne,"aria-label":a("gitView.pr.actions.mergePrAria"),children:ve?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"git-merge",className:"size-4"})})}),s.jsx(ft,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[jn?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(nt,{variant:"outline",size:"sm",onClick:k,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,Be?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:Be}),Ps?s.jsx(nt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:Ps,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(R,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!qe&&!Fe&&!Be&&!jn?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):qe?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(gl,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Qe&&Qe.total>0?`${a("gitView.pr.segment.checks")} ${Qe.success}/${Qe.total}`:a("gitView.pr.segment.checks"),icon:Qe?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${$c(Qe.state)}`}):void 0},{id:"comments",label:Pt?`${a("gitView.pr.segment.comments")} ${(Pt.issueComments?.length??0)+(Pt.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:at,onSelect:q=>Xt(q),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),at==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Ms&&qe.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,Ms?null:s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.noMergePermission")}),s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:Ne?s.jsx(Jn,{value:ne,onChange:q=>ce(q.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:x?"on":"off",autoCapitalize:x?"sentences":"off",spellCheck:x}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:qe.title})}),qe.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:Ne?s.jsxs(s.Fragment,{children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(nt,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Ae(!1),ce(qe.title||""),te(qe.body||"")},disabled:Q,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(R,{name:"close",className:"size-4"})})}),s.jsx(ft,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(nt,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>Mn(qe),disabled:Q||!ne.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:Q?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"check",className:"size-4"})})}),s.jsx(ft,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(nt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Ae(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(R,{name:"edit",className:"size-4"})})}),s.jsx(ft,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),Ne?s.jsx(Kr,{value:Re,onChange:q=>te(q.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:x?"on":"off",autoCapitalize:x?"sentences":"off",spellCheck:x}):null,Ne?null:qe.body?.trim()?s.jsx(Zl,{content:qe.body,className:"typography-markdown-body min-w-0 text-muted-foreground break-words",enableFileReferences:!1}):s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:a(ss?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,at==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Qe&&Qe.total>0?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted/40",children:[Qe.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Qe.success/Qe.total*100}%`}}):null,Qe.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Qe.failure/Qe.total*100}%`}}):null,Qe.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Qe.pending/Qe.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Qe.success,"/",Qe.total," ",a("gitView.pr.checks.label")]}),(Qe.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}),fa(Qe.startedAt,void 0,St)]}):null]}):null,Qe?.failure?s.jsxs(nt,{variant:"outline",size:"sm",className:"w-fit gap-1.5 border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",onClick:Ve,disabled:Me,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[Me?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(Pt?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(Pt?.checkRuns??[]).map((q,We)=>{const et=`${q.id??"run"}:${q.name}:${We}`,lt=q.status==="in_progress",Tt=q.status==="queued",kt=ma(q.conclusion),pt=rt.has(et),ds=!!(q.output?.title||q.output?.summary||q.output?.text||(q.annotations?.length??0)>0||(q.job?.steps?.length??0)>0||q.detailsUrl),vs=q.job?.workflowName,es=lt?fa(q.startedAt,void 0,St):fa(q.startedAt,q.completedAt);return s.jsxs("div",{className:ye("rounded-md border border-border/40",kt&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!ds,onClick:()=>{gt(Ts=>{const js=new Set(Ts);return js.has(et)?js.delete(et):js.add(et),js})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[lt?s.jsx(R,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):Tt?s.jsx(R,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):kt?s.jsx(R,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(R,{name:"checkbox-circle",className:"size-4 shrink-0 text-[var(--status-success)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:vs&&vs!==q.name?`${vs} / ${q.name}`:q.name}),es?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:es}):null,ds?s.jsx(R,{name:"arrow-down-s",className:ye("size-4 shrink-0 text-muted-foreground transition-transform",pt&&"rotate-180")}):null]}),pt&&ds?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:is(q,{hideHeader:!0})}):null]},et)})}):Mt?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.checkDetails.empty")})]}):null,at==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Rt.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(nt,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)]",onClick:jt,disabled:ze,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[ze?s.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(R,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,Rt.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:Rt.map((q,We)=>{const et=(q.authorName||"?").charAt(0).toUpperCase(),lt=We===Rt.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[lt?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:q.avatarUrl?s.jsx("img",{src:q.avatarUrl,alt:q.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:et})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1 typography-micro text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-1 sm:gap-y-1",children:[s.jsxs("span",{className:"text-foreground whitespace-nowrap",children:[q.authorName,q.authorLogin&&q.authorLogin!==q.authorName?` · @${q.authorLogin}`:""]}),q.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:_t(q.createdAt)}):null,s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsxs(nt,{variant:"ghost",size:"sm",className:"h-6 px-0 has-[>svg]:px-0 sm:px-2 sm:has-[>svg]:px-2.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)] justify-start",onClick:()=>{Jt(q)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(R,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(ft,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[q.context,q.path?` · ${q.path}`:"",q.line?`:${q.line}`:""]}),s.jsx(Zl,{content:hs(q.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",os].filter(Boolean).join(" "),enableFileReferences:!1})]})]},q.id)})})}):Mt&&!Pt?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.comments.empty")})]}):null]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",Z," ",s.jsxs("span",{className:"opacity-60",children:["(",oe&&fe?"upstream":"remote",")"]})]})]}),Ps?s.jsx(nt,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:Ps,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(R,{name:"external-link",className:"size-4"}),a("gitView.pr.actions.repo")]})}):null]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.title")}),s.jsx(Jn,{value:V,onChange:q=>K(q.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:x?"on":"off",autoCapitalize:x?"sentences":"off",spellCheck:x})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),Ye.length>0?s.jsxs(Ls,{value:Z,onValueChange:re,children:[s.jsx(_s,{size:"lg",children:s.jsx(Ds,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx($s,{children:Ye.map(q=>s.jsx(rs,{value:q,children:q},q))})]}):s.jsx(Jn,{value:Z,onChange:q=>re(q.target.value),placeholder:a("gitView.pr.placeholder.main")})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.description")}),s.jsx(Kr,{value:y,onChange:q=>I(q.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:x?"on":"off",autoCapitalize:x?"sentences":"off",spellCheck:x})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":$,onClick:()=>z(q=>!q),onKeyDown:q=>{(q.key===" "||q.key==="Enter")&&(q.preventDefault(),z(We=>!We))},children:[s.jsx(qr,{size:"sm",checked:$,onChange:q=>z(q),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),m?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx(nt,{variant:"outline",size:"sm",onClick:()=>ge(!0),children:G.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),G.trim()&&s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"inline-flex items-center rounded-full bg-[var(--interactive-selection)] px-2 py-0.5 text-xs text-[var(--interactive-selection-foreground)]",children:a("gitView.pr.additionalContext.added")})})]}):s.jsxs(yi,{open:ae,onOpenChange:de,children:[s.jsxs(xl,{className:"flex w-full items-center justify-between rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-2 hover:bg-[var(--interactive-hover)]",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:ae?a("gitView.pr.actions.hide"):G.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(vi,{children:s.jsxs("div",{className:"mt-2 space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[s.jsx(Kr,{value:G,onChange:q=>J(q.target.value),className:"min-h-[100px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext")}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})})]}),s.jsx(_i,{open:H,onClose:()=>ge(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(nt,{size:"sm",onClick:()=>ge(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(Kr,{value:G,onChange:q=>J(q.target.value),className:"min-h-[200px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext"),autoFocus:!0}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(nt,{variant:"outline",size:"sm",onClick:ps,disabled:be||we,children:[be?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(nt,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:Zt,disabled:we||!tn||!Z.trim()||!oe&&Z.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:we?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(R,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},Lb=t=>{const{remoteNames:e,localBranches:n,worktreeCreatedFromBranch:r,rootBranchHint:o,defaultBranch:i,headBranch:c}=t,a=typeof c=="string"?c.trim():"",d=b=>{if(!b)return"";let S=b.trim();if(!S||S==="HEAD")return"";if(n.includes(S))return S;S.startsWith("refs/heads/")&&(S=S.slice(11)),S.startsWith("heads/")&&(S=S.slice(6)),S.startsWith("remotes/")&&(S=S.slice(8));const v=S.indexOf("/");if(v>0){const p=S.slice(0,v);if(e.has(p)){const m=S.slice(v+1).trim();m&&(S=m)}}return S},u=b=>{const S=d(typeof b=="string"?b:"");return S&&S!==a?S:""},h=u(r);if(h)return h;const f=u(o);if(f)return f;const g=u(i);return g||(n.includes("main")?"main":n.includes("master")?"master":n.includes("develop")?"develop":"main")},UC=t=>{const{baseBranch:e,localBranches:n,remoteBranches:r}=t;return n.includes(e)?!0:r.some(o=>{const i=o.indexOf("/");return i>0&&o.slice(i+1)===e})},ga=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),Vo=new Map,Ho=new Map,cr=t=>`${xn()}::${t}`,_b=()=>{const t=tt.c(86),{t:e}=mt(),{git:n}=tr(),r=Io(),o=al(r??null),i=xu(r??null),{ensureAll:c}=mr(qn($b)),a=Je(zb),d=Je(Ub),u=Je(Wb),h=Je(Vb);let f;t[0]!==r?(f=ga(r),t[0]=r,t[1]=f):f=t[1];const g=f;let b;if(t[2]!==h||t[3]!==g||t[4]!==u){e:{if(!g){b=void 0;break e}let Ae;if(t[6]!==h||t[7]!==g){let Oe;t[9]!==g?(Oe=ne=>ga(ne.path)===g,t[9]=g,t[10]=Oe):Oe=t[10],Ae=h.find(Oe),t[6]=h,t[7]=g,t[8]=Ae}else Ae=t[8];const Se=Ae;if(Se){b=Se;break e}for(const Oe of u.values())if(ga(Oe.path)===g){b=Oe;break e}b=void 0}t[2]=h,t[3]=g,t[4]=u,t[5]=b}else b=t[5];const S=b;let v;t[11]!==a||t[12]!==S||t[13]!==d?.open||t[14]!==u?(v=()=>{if(a)return u.get(a)??S;if(d?.open)return S},t[11]=a,t[12]=S,t[13]=d?.open,t[14]=u,t[15]=v):v=t[15],d?.open;let p;t[16]!==v?(p=v(),t[16]=v,t[17]=p):p=t[17];const m=p;let x;t[18]!==a?(x=Ae=>a?Ae.getAttachment(a):void 0,t[18]=a,t[19]=x):x=t[19];const w=uu(x),j=w&&!w.degraded&&!w.legacy?w.worktreeRoot??void 0:void 0,N=hb(r,m,o?.current??void 0);let A,k;t[20]!==r||t[21]!==c||t[22]!==n?(A=()=>{!r||!n||c(r,n)},k=[r,c,n],t[20]=r,t[21]=c,t[22]=n,t[23]=A,t[24]=k):(A=t[23],k=t[24]),l.useEffect(A,k);const[C,P]=l.useState(null);let D;t[25]!==j||t[26]!==N?.projectDirectory?(D=()=>{const Ae=j||N?.projectDirectory;if(!Ae){P(null);return}let Se=!1;return $i(Ae).then(Oe=>{if(Se)return;const ne=Oe.trim();P(ne&&ne!=="HEAD"?ne:null)}).catch(()=>{Se||P(null)}),()=>{Se=!0}},t[25]=j,t[26]=N?.projectDirectory,t[27]=D):D=t[27];const F=N?.projectDirectory;let B;t[28]!==j||t[29]!==F?(B=[j,F],t[28]=j,t[29]=F,t[30]=B):B=t[30],l.useEffect(D,B);let E;t[31]!==r?(E=()=>(r?Vo.get(cr(r)):void 0)??[],t[31]=r,t[32]=E):E=t[32];const[_,W]=l.useState(E);let V;t[33]!==r?(V=()=>(r?Ho.get(cr(r)):void 0)??null,t[33]=r,t[34]=V):V=t[34];const[K,y]=l.useState(V);let I,$;t[35]!==r||t[36]!==n?(I=()=>{if(!r||!n?.getRemotes){W([]);return}W(Vo.get(cr(r))??[]);let Ae=!1;return n.getRemotes(r).then(Se=>{Ae||(Vo.set(cr(r),Se??[]),W(Se??[]))}).catch(()=>{Ae||W(Vo.get(cr(r))??[])}),()=>{Ae=!0}},$=[r,n],t[35]=r,t[36]=n,t[37]=I,t[38]=$):(I=t[37],$=t[38]),l.useEffect(I,$);let z,G;t[39]!==r||t[40]!==n?(z=()=>{if(!r||!n?.getRemoteUrl){y(null);return}y(Ho.get(cr(r))??null);let Ae=!1;return n.getRemoteUrl(r).then(Se=>{Ae||(Ho.set(cr(r),Se),y(Se))}).catch(()=>{Ae||y(Ho.get(cr(r))??null)}),()=>{Ae=!0}},G=[r,n],t[39]=r,t[40]=n,t[41]=z,t[42]=G):(z=t[41],G=t[42]),l.useEffect(z,G);let J;e:{if(!i?.all){let Se;t[43]===Symbol.for("react.memo_cache_sentinel")?(Se=[],t[43]=Se):Se=t[43],J=Se;break e}let Ae;t[44]!==i.all?(Ae=i.all.filter(Hb).sort(),t[44]=i.all,t[45]=Ae):Ae=t[45],J=Ae}const Z=J;let re;e:{if(!i?.all){let Se;t[46]===Symbol.for("react.memo_cache_sentinel")?(Se=[],t[46]=Se):Se=t[46],re=Se;break e}let Ae;t[47]!==i.all?(Ae=i.all.filter(Kb).map(Gb).sort(),t[47]=i.all,t[48]=Ae):Ae=t[48],re=Ae}const ee=re;let he;t[49]!==ee||t[50]!==K||t[51]!==_||t[52]!==o?.tracking?(he=()=>{if(_.length>0)return _;const Ae=new Set,Se=o?.tracking?.trim();Se&&Se.includes("/")&&Ae.add(Se.split("/")[0]);for(const Oe of ee){const ne=Oe.indexOf("/");ne>0&&Ae.add(Oe.slice(0,ne))}return Ae.size===0&&K&&Ae.add("origin"),Array.from(Ae).map(Oe=>({name:Oe,fetchUrl:K??"",pushUrl:K??""}))},t[49]=ee,t[50]=K,t[51]=_,t[52]=o?.tracking,t[53]=he):he=t[53],o?.tracking;let be;t[54]!==he?(be=he(),t[54]=he,t[55]=be):be=t[55];const Y=be,we=o?.current??null;o?.tracking;let me;t[56]!==o?.tracking?(me=o?.tracking?.trim().split("/")[0],t[56]=o?.tracking,t[57]=me):me=t[57];const Q=me,pe=(Q&&i?.defaultBranches?.[Q])??i?.defaultBranches?.origin;let ve;t[58]!==we||t[59]!==pe||t[60]!==Y||t[61]!==Z||t[62]!==C||t[63]!==N?.createdFromBranch?(ve=()=>Lb({remoteNames:new Set(Y.map(qb)),localBranches:Z,worktreeCreatedFromBranch:N?.createdFromBranch,rootBranchHint:C,defaultBranch:pe,headBranch:we}),t[58]=we,t[59]=pe,t[60]=Y,t[61]=Z,t[62]=C,t[63]=N?.createdFromBranch,t[64]=ve):ve=t[64],N?.createdFromBranch;let Te;t[65]!==ve?(Te=ve(),t[65]=ve,t[66]=Te):Te=t[66];const ke=Te;if(!r||!we){let Ae;t[67]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx(R,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=Ae):Ae=t[67];let Se;t[68]!==e?(Se=e("gitView.pullRequest.title"),t[68]=e,t[69]=Se):Se=t[69];let Oe;t[70]!==Se?(Oe=s.jsx("div",{className:"typography-ui-header text-foreground",children:Se}),t[70]=Se,t[71]=Oe):Oe=t[71];let ne;t[72]!==e?(ne=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=ne):ne=t[73];let ce;t[74]!==ne?(ce=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ne}),t[74]=ne,t[75]=ce):ce=t[75];let Re;return t[76]!==Oe||t[77]!==ce?(Re=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[Ae,Oe,ce]}),t[76]=Oe,t[77]=ce,t[78]=Re):Re=t[78],Re}const Ie=o?.tracking??void 0;let Ne;return t[79]!==ke||t[80]!==we||t[81]!==r||t[82]!==ee||t[83]!==_||t[84]!==Ie?(Ne=s.jsx(Yn,{as:ll,outerClassName:"h-full min-h-0",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(Bb,{directory:r,branch:we,baseBranch:ke,trackingBranch:Ie,remotes:_,remoteBranches:ee})}),t[79]=ke,t[80]=we,t[81]=r,t[82]=ee,t[83]=_,t[84]=Ie,t[85]=Ne):Ne=t[85],Ne};function $b(t){return{ensureAll:t.ensureAll}}function zb(t){return t.currentSessionId}function Ub(t){return t.newSessionDraft}function Wb(t){return t.worktreeMetadata}function Vb(t){return t.availableWorktrees}function Hb(t){return!t.startsWith("remotes/")}function Kb(t){return t.startsWith("remotes/")}function Gb(t){return t.replace(/^remotes\//,"")}function qb(t){return t.name}const Ua=5e3,Yb=(t,e)=>{if(!t)return 1;let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(n+=1,n>e))return n;return n},Ko=(t,e)=>Nh(Ah.getState().dictionary,t,e),Qb=t=>{const n=(t instanceof Error?t.message:String(t??"")).toLowerCase();return n.includes("file not found")||n.includes("not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")?"missing":"unreadable"},Xb=async(t,e,n)=>{if(t.readFile)return(await t.readFile(e,{optional:!0,directory:n?.directory})).content??"";const r=new URLSearchParams({path:e,optional:"true"});n?.directory&&r.set("directory",n.directory);const o=await ms(`/api/fs/read?${r.toString()}`,{cache:"no-store",headers:n?.directory?{"x-opencode-directory":n.directory}:void 0});if(!o.ok){const i=await o.json().catch(()=>({error:o.statusText}));throw new Error(i.error||"Failed to read file")}return o.text()},pf=async(t,e,n)=>{if(Sh(e)||jh(e)||kh(e))return{ok:!0};try{const r=await Xb(t,e,n);return Ch(r)?{ok:!1,reason:"binary"}:Yb(r,Ua)>Ua?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:Qb(r)}}},gf=t=>{if(t==="too-large"){const e=Ua.toLocaleString(Co());return Ko("contextFileOpen.failure.tooLarge",{count:e})}return Ko(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},Jb=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),ws=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},xf=(t,e)=>{const n=ws(e),r=ws(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Zb=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),ey=new Set(["node_modules"]),ty=t=>ey.has(t),sy=t=>{const e=ws(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},ny=8,Ln=new Map,jl=t=>JSON.stringify([xn(),t]),ry=t=>{const e=jl(t),n=Ln.get(e);return n?(n.touchedAt=Date.now(),Ln.delete(e),Ln.set(e,n),n):null},xa=t=>{const e=jl(t),n=Ln.get(e);if(n)return n.touchedAt=Date.now(),n;if(Ln.size>=ny){const o=Ln.keys().next().value;o!==void 0&&Ln.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Ln.set(e,r),r},oy=t=>{Ln.delete(jl(t))},bf=(t,e)=>s.jsx(cl,{filePath:t,extension:e}),iy=t=>{const e=tt.c(3),{status:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=r):r=e[0];const o=r[n];let i;return e[1]!==o?(i=s.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:o}}),e[1]=o,e[2]=i):i=e[2],i},ay=t=>{const e=tt.c(66),{node:n,root:r,isExpanded:o,isActive:i,isBrowserClient:c,status:a,badge:d,permissions:u,downloadFile:h,onSelect:f,onToggle:g,onRevealPath:b,onOpenDialog:S}=t,{t:v}=mt(),p=n.type==="directory",{canRename:m,canCreateFile:x,canCreateFolder:w,canDelete:j,canReveal:N}=u,A=!p&&!!h,k=N&&!c,C=m||x||w||j||A||k,[P,D]=l.useState(!1),[F,B]=l.useState(!1);let E;e[0]!==C?(E=Te=>{C&&(Te?.preventDefault(),B(!0))},e[0]=C,e[1]=E):E=e[1];const _=E;let W;e[2]!==p||e[3]!==n||e[4]!==f||e[5]!==g?(W=()=>{p?g(n.path):f(n)},e[2]=p,e[3]=n,e[4]=f,e[5]=g,e[6]=W):W=e[6];const V=W;let K;e[7]===Symbol.for("react.memo_cache_sentinel")?(K=Te=>{Te.stopPropagation(),B(!1),D(!0)},e[7]=K):K=e[7];const y=K;let I;e[8]!==x||e[9]!==w||e[10]!==j||e[11]!==m||e[12]!==k||e[13]!==h||e[14]!==c||e[15]!==p||e[16]!==n||e[17]!==S||e[18]!==b||e[19]!==v?(I=Te=>{const{Item:ke,Separator:Ie}=Te;return s.jsxs(s.Fragment,{children:[m&&s.jsxs(ke,{onClick:Ne=>{Ne.stopPropagation(),S("rename",n)},children:[s.jsx(R,{name:"edit",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.rename")]}),s.jsxs(ke,{onClick:Ne=>{Ne.stopPropagation(),Xn(n.path).then(Ae=>{if(Ae.ok){Ee.success(v("sidebarFilesTree.toast.pathCopied"));return}Ee.error(v("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(R,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.copyPath")]}),!p&&h&&s.jsxs(ke,{onClick:Ne=>{Ne.stopPropagation(),h(n.path).catch(Ae=>{console.error("Download failed:",Ae),Ee.error(v("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(R,{name:"download",className:"mr-2 h-4 w-4"})," ",v(c?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),k&&s.jsxs(ke,{onClick:Ne=>{Ne.stopPropagation(),b(n.path)},children:[s.jsx(R,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",v(ou())]}),p&&(x||w)&&s.jsxs(s.Fragment,{children:[s.jsx(Ie,{}),x&&s.jsxs(ke,{onClick:Ne=>{Ne.stopPropagation(),S("createFile",n)},children:[s.jsx(R,{name:"file-add",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.newFile")]}),w&&s.jsxs(ke,{onClick:Ne=>{Ne.stopPropagation(),S("createFolder",n)},children:[s.jsx(R,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.newFolder")]})]}),j&&s.jsxs(s.Fragment,{children:[s.jsx(Ie,{}),s.jsxs(ke,{onClick:Ne=>{Ne.stopPropagation(),S("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(R,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.delete")]})]})]})},e[8]=x,e[9]=w,e[10]=j,e[11]=m,e[12]=k,e[13]=h,e[14]=c,e[15]=p,e[16]=n,e[17]=S,e[18]=b,e[19]=v,e[20]=I):I=e[20];const $=I;let z;e[21]!==n.path||e[22]!==r?(z=Te=>{const ke=xf(r,n.path);!ke||ke==="."||(Te.dataTransfer.setData("application/x-openchamber-file-path",ke),Te.dataTransfer.effectAllowed="copy")},e[21]=n.path,e[22]=r,e[23]=z):z=e[23];const G=z;let J;e[24]!==_?(J=s.jsx("div",{className:"group relative flex items-center",onContextMenu:_}),e[24]=_,e[25]=J):J=e[25];const Z=i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let re;e[26]!==Z?(re=ye("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",Z,"cursor-grab active:cursor-grabbing"),e[26]=Z,e[27]=re):re=e[27];let ee;e[28]!==p||e[29]!==o||e[30]!==n.extension||e[31]!==n.path?(ee=p?o?s.jsx(R,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(R,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):bf(n.path,n.extension),e[28]=p,e[29]=o,e[30]=n.extension,e[31]=n.path,e[32]=ee):ee=e[32];let he;e[33]!==n.name||e[34]!==n.path?(he=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[33]=n.name,e[34]=n.path,e[35]=he):he=e[35];let be;e[36]!==p||e[37]!==a?(be=!p&&a&&s.jsx(iy,{status:a}),e[36]=p,e[37]=a,e[38]=be):be=e[38];let Y;e[39]!==d||e[40]!==p?(Y=p&&d&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[d.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",d.modified]}),d.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",d.added]})]}),e[39]=d,e[40]=p,e[41]=Y):Y=e[41];let we;e[42]!==_||e[43]!==G||e[44]!==V||e[45]!==he||e[46]!==be||e[47]!==Y||e[48]!==re||e[49]!==ee?(we=s.jsxs("button",{type:"button",onClick:V,onContextMenu:_,draggable:!0,onDragStart:G,className:re,children:[ee,he,be,Y]}),e[42]=_,e[43]=G,e[44]=V,e[45]=he,e[46]=be,e[47]=Y,e[48]=re,e[49]=ee,e[50]=we):we=e[50];let me;e[51]!==P||e[52]!==C||e[53]!==$||e[54]!==v?(me=C&&s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:s.jsxs(vn,{open:P,onOpenChange:D,children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(bn,{asChild:!0,children:s.jsx(nt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:y,title:v("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":v("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(R,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(ft,{side:"bottom",sideOffset:6,children:v("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(yn,{align:"end",side:"bottom",onCloseAutoFocus:()=>D(!1),children:$({Item:Gt,Separator:gn})})]})}),e[51]=P,e[52]=C,e[53]=$,e[54]=v,e[55]=me):me=e[55];let Q;e[56]!==we||e[57]!==me||e[58]!==J?(Q=s.jsxs(zu,{render:J,children:[we,me]}),e[56]=we,e[57]=me,e[58]=J,e[59]=Q):Q=e[59];let pe;e[60]!==$?(pe=s.jsx(_u,{className:"min-w-[180px]",children:$({Item:$u,Separator:Ng})}),e[60]=$,e[61]=pe):pe=e[61];let ve;return e[62]!==F||e[63]!==Q||e[64]!==pe?(ve=s.jsxs(Uu,{open:F,onOpenChange:B,children:[Q,pe]}),e[62]=F,e[63]=Q,e[64]=pe,e[65]=ve):ve=e[65],ve},ly=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.status===e.status&&t.badge===e.badge&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog,cy=l.memo(ay,ly),dy=()=>{const{t}=mt(),{files:e,runtime:n}=tr(),r=Mm(n.platform),o=Io()??"",i=ws(o.trim()),c=Om(),a=Fm(),d=su(M=>M.searchFiles),u=xe(M=>M.openContextFile),h=al(o),[f,g]=l.useState(""),b=dl(f,200),S=l.useRef(null),[v,p]=l.useState([]),[m,x]=l.useState(!1),[w,j]=l.useState({}),[N,A]=l.useState({}),k=l.useRef(new Set),C=l.useRef(new Set),P=l.useRef(null);l.useEffect(()=>{if(!i){j({}),A({}),k.current=new Set;return}const M=ry(i);M?(j({...M.childrenByDir}),A({...M.loadErrorsByDir}),k.current=new Set(M.loadedDirs)):(j({}),A({}),k.current=new Set)},[i]),l.useEffect(()=>{if(!i)return;const M=xa(i);M.childrenByDir=w},[i,w]),l.useEffect(()=>{if(!i)return;const M=xa(i);M.loadErrorsByDir=N},[i,N]),l.useEffect(()=>{if(!i)return;const M=xa(i);M.loadedDirs=new Set(k.current)},[i,w,N]),l.useEffect(()=>()=>{if(!i)return;const M=Ln.get(i);M&&M.loadedDirs.size===0&&Object.keys(M.childrenByDir).length===0&&oy(i)},[i]);const D=l.useMemo(()=>[],[]),F=l.useMemo(()=>[],[]),B=Bn(M=>i?M.byRoot[i]?.expandedPaths??D:D),E=Bn(M=>i?M.byRoot[i]?.selectedPath??null:null),_=Bn(M=>M.setSelectedPath),W=Bn(M=>M.addOpenPath),V=Bn(M=>M.removeOpenPathsByPrefix),K=Bn(M=>M.toggleExpandedPath),y=Bn(M=>M.collapseAllExpandedPaths),I=xe(M=>i?M.contextPanelByDirectory[i]?.tabs??F:F),$=l.useMemo(()=>new Set(I.map(M=>M.mode==="file"?M.targetPath:null).filter(M=>typeof M=="string"&&M.length>0).map(M=>ws(M))),[I]),[z,G]=l.useState(null),[J,Z]=l.useState(null),[re,ee]=l.useState(""),[he,be]=l.useState(!1),Y=!!e.writeFile,we=!!e.createDirectory,me=!!e.rename,Q=!!e.delete,pe=!!e.revealPath,ve=l.useMemo(()=>({canRename:me,canCreateFile:Y,canCreateFolder:we,canDelete:Q,canReveal:pe}),[me,Y,we,Q,pe]),Te=l.useCallback(M=>{e.revealPath&&e.revealPath(M).catch(()=>{Ee.error(t("sidebarFilesTree.toast.revealFailed"))})},[e,t]),ke=l.useCallback((M,oe)=>{G(M),Z(oe),ee(M==="rename"&&oe.name||""),be(!1)},[]),Ie=l.useCallback((M,oe)=>{const De=oe.filter(fe=>fe&&typeof fe.name=="string"&&fe.name.length>0).filter(fe=>c||!fe.name.startsWith(".")).filter(fe=>a||!ty(fe.name)).map(fe=>{const X=fe.name,le=ws(fe.path||""),se=le?Zb(le)?le:ws(`${M}/${le}`):ws(`${M}/${X}`),T=fe.isDirectory?"directory":"file",ie=T==="file"&&X.includes(".")?X.split(".").pop()?.toLowerCase():void 0;return{name:X,path:se,type:T,extension:ie}});return Jb(De)},[a,c]),Ne=l.useCallback(async(M,oe)=>{const De=ws(M.trim());if(!De||k.current.has(De)||C.current.has(De))return;C.current=new Set(C.current),C.current.add(De);const fe=e.listDirectory?e.listDirectory(De).then(X=>X.entries.map(le=>({name:le.name,path:le.path,isDirectory:le.isDirectory}))):Xs.listLocalDirectory(De).then(X=>X.map(le=>({name:le.name,path:le.path,isDirectory:le.isDirectory})));try{const X=await fe;if(oe?.())return;const le=Ie(De,X);k.current=new Set(k.current),k.current.add(De),A(se=>{if(!se[De])return se;const T={...se};return delete T[De],T}),j(se=>({...se,[De]:le}))}catch(X){if(oe?.())return;const le=X instanceof Error?X.message:String(X??"");console.error("Failed to load sidebar directory:",X),A(se=>({...se,[De]:le}))}finally{C.current=new Set(C.current),C.current.delete(De)}},[e,Ie]),Ae=l.useCallback(async()=>{if(!i)return;P.current?.abort();const M=new AbortController;P.current=M;try{const De=(Bn.getState().byRoot[i]?.expandedPaths??[]).map(le=>ws(le)).filter(le=>!!le&&le!==i&&le.startsWith(`${i}/`)),fe=[i,...De];k.current=new Set(k.current);for(const le of fe)k.current.delete(le);A(le=>{if(Object.keys(le).length===0)return le;const se={...le};let T=!1;for(const ie of fe)ie in se&&(delete se[ie],T=!0);return T?se:le});const X=()=>M.signal.aborted;await Ne(i,X);for(let le=0;le<De.length&&!M.signal.aborted;le+=3){const se=De.slice(le,le+3);await Promise.all(se.map(T=>Ne(T,X)))}}catch(oe){if(M.signal.aborted)return;console.error("Failed to refresh sidebar tree:",oe)}finally{P.current===M&&(P.current=null)}},[Ne,i]),Se=l.useCallback(async M=>{if(!M){await Ae();return}const oe=ws(M);k.current=new Set(k.current),k.current.delete(oe),C.current=new Set(C.current),C.current.delete(oe),await Ne(oe)},[Ne,Ae]);l.useEffect(()=>{i&&(P.current?.abort(),k.current=new Set,C.current=new Set,A({}),j(M=>Object.keys(M).length===0?M:{}),Ne(i))},[Ne,i,c,a]),l.useEffect(()=>{if(!i||B.length===0)return;const M=B.map(fe=>ws(fe)).filter(fe=>!!fe&&fe!==i&&fe.startsWith(`${i}/`)&&!k.current.has(fe)&&!C.current.has(fe)).sort((fe,X)=>fe.split("/").length-X.split("/").length);if(M.length===0)return;let oe=!1;const De=()=>oe;return(async()=>{for(let fe=0;fe<M.length&&!oe;fe+=3){const X=M.slice(fe,fe+3);await Promise.all(X.map(le=>Ne(le,De)))}})(),()=>{oe=!0}},[B,Ne,i]),l.useEffect(()=>{if(!o){p([]),x(!1);return}const M=b.trim();if(!M){p([]),x(!1);return}let oe=!1;return x(!0),d(o,M,150,{includeHidden:c,respectGitignore:!a,type:"file"}).then(De=>{if(oe)return;const X=De.filter(le=>a||!sy(le.path)).map(le=>({name:le.name,path:ws(le.path),type:"file",extension:le.extension,relativePath:le.relativePath}));p(X)}).catch(()=>{oe||p([])}).finally(()=>{oe||x(!1)}),()=>{oe=!0}},[o,b,d,c,a]);const Oe=l.useMemo(()=>{const M=new Map;if(!h?.files)return M;for(const oe of h.files)oe.index==="A"||oe.working_dir==="?"?M.set(oe.path,"git-added"):oe.index==="D"?M.set(oe.path,"git-deleted"):(oe.index==="M"||oe.working_dir==="M")&&M.set(oe.path,"git-modified");return M},[h]),ne=l.useMemo(()=>{const M=new Map;if(!h?.files||!i)return M;for(const oe of h.files){const De=oe.index==="M"||oe.working_dir==="M",fe=oe.index==="A"||oe.working_dir==="?";if(!De&&!fe)continue;const X=oe.path.split("/");if(X.length<=1)continue;let le=i;for(let se=0;se<X.length-1;se++){le=`${le}/${X[se]}`;let T=M.get(le);T||(T={modified:0,added:0},M.set(le,T)),De&&T.modified++,fe&&T.added++}}return M},[h,i]),ce=l.useCallback(M=>{if($.has(M))return"open";if(Oe.size===0)return null;const oe=M.startsWith(i+"/")?M.slice(i.length+1):M;return Oe.get(oe)??null},[$,Oe,i]),Re=l.useCallback(M=>{if(ne.size===0)return null;const oe=ne.get(M);return oe&&oe.modified+oe.added>0?oe:null},[ne]),te=l.useCallback(async M=>{if(!i)return;const oe=await pf(e,M.path,{directory:i});if(!oe.ok){Ee.error(gf(oe.reason));return}_(i,M.path),W(i,M.path),u(i,M.path)},[W,e,u,i,_]),ae=l.useCallback(async M=>{const oe=ws(M);i&&(K(i,oe),k.current.has(oe)||await Ne(oe))},[Ne,i,K]),de=l.useCallback(async M=>{if(M?.preventDefault(),!J||!z)return;be(!0);const oe=()=>be(!1),De=()=>G(null);if(z==="createFile"){if(!re.trim()){Ee.error(t("sidebarFilesTree.toast.filenameRequired")),oe();return}if(!e.writeFile){Ee.error(t("sidebarFilesTree.toast.writeNotSupported")),oe();return}const fe=J.path,X=fe?`${fe}/`:"",le=ws(`${X}${re.trim()}`);await e.writeFile(le,"").then(async se=>{se.success&&(Ee.success(t("sidebarFilesTree.toast.fileCreated")),await Se(fe)),De()}).catch(()=>Ee.error(t("sidebarFilesTree.toast.operationFailed"))).finally(oe);return}if(z==="createFolder"){if(!re.trim()){Ee.error(t("sidebarFilesTree.toast.folderNameRequired")),oe();return}const fe=J.path,X=fe?`${fe}/`:"",le=ws(`${X}${re.trim()}`);await e.createDirectory(le).then(async se=>{se.success&&(Ee.success(t("sidebarFilesTree.toast.folderCreated")),await Se(fe)),De()}).catch(()=>Ee.error(t("sidebarFilesTree.toast.operationFailed"))).finally(oe);return}if(z==="rename"){if(!re.trim()){Ee.error(t("sidebarFilesTree.toast.nameRequired")),oe();return}if(!e.rename){Ee.error(t("sidebarFilesTree.toast.renameNotSupported")),oe();return}const fe=J.path,X=fe.split("/").slice(0,-1).join("/"),le=X?`${X}/`:"",se=ws(`${le}${re.trim()}`);await e.rename(fe,se).then(async T=>{T.success&&(Ee.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await Se(X),i&&V(i,fe),(E===fe||E&&E.startsWith(`${fe}/`))&&_(i,null)),De()}).catch(()=>Ee.error(t("sidebarFilesTree.toast.operationFailed"))).finally(oe);return}if(z==="delete"){if(!e.delete){Ee.error(t("sidebarFilesTree.toast.deleteNotSupported")),oe();return}const fe=J.path,X=fe.split("/").slice(0,-1).join("/");await e.delete(fe).then(async le=>{le.success&&(Ee.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await Se(X),i&&V(i,fe),(E===fe||E&&E.startsWith(fe+"/"))&&_(i,null)),De()}).catch(()=>Ee.error(t("sidebarFilesTree.toast.operationFailed"))).finally(oe);return}oe()},[z,J,re,e,Se,V,i,E,_,t]);function H(M,oe){const De=w[M]??[];return De.map((fe,X)=>{const le=fe.type==="directory",se=le&&B.includes(fe.path),T=E===fe.path,ie=X===De.length-1;return s.jsxs("li",{className:"relative",children:[oe>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),ie&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(cy,{node:fe,root:i,isExpanded:se,isActive:T,isBrowserClient:r,status:le?void 0:ce(fe.path),badge:le?Re(fe.path):void 0,permissions:ve,downloadFile:e.downloadFile,onSelect:te,onToggle:ae,onRevealPath:Te,onOpenDialog:ke}),le&&se&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[N[fe.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:N[fe.path],children:N[fe.path]}),s.jsxs(nt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Se(fe.path)},children:[s.jsx(R,{name:"refresh",className:"h-3.5 w-3.5"}),t("sidebarFilesTree.actions.refreshTitle")]})]}):null,H(fe.path,oe+1)]})]},fe.path)})}const ge=!!(i&&w[i]),ue=i?N[i]:null;return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Y&&s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>ke("createFile",{path:o,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.newFileTitle"),"aria-label":t("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(R,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(ft,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.newFileTitle")})]}),we&&s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>ke("createFolder",{path:o,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.newFolderTitle"),"aria-label":t("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(R,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(ft,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.newFolderTitle")})]}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>{Ae()},className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.refreshTitle"),"aria-label":t("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(R,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(ft,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>{i&&y(i)},className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":t("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(R,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(ft,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(Jn,{ref:S,value:f,onChange:M=>g(M.target.value),placeholder:t("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),f.trim().length>0?s.jsx("button",{type:"button","aria-label":t("sidebarFilesTree.search.clearAria"),className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{g(""),S.current?.focus()},children:s.jsx(R,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsx(Yn,{outerClassName:"flex-1 min-h-0",className:"p-2",children:s.jsx("ul",{className:"flex flex-col",children:m?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("sidebarFilesTree.state.searching")]}):v.length>0?v.map(M=>{const oe=E===M.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>te(M),draggable:!0,onDragStart:De=>{const fe=M.relativePath||xf(i??"",M.path);!fe||fe==="."||(De.dataTransfer.setData("application/x-openchamber-file-path",fe),De.dataTransfer.effectAllowed="copy")},className:ye("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors cursor-grab active:cursor-grabbing",oe?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:M.path,children:[bf(M.path,M.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:M.relativePath??M.path})]})},M.path)}):ue?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:ue}),s.jsxs(nt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Ae()},children:[s.jsx(R,{name:"refresh",className:"h-3.5 w-3.5"}),t("sidebarFilesTree.actions.refreshTitle")]})]}):ge&&i?H(i,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("sidebarFilesTree.state.loading")})})}),s.jsx(Ws,{open:!!z,onOpenChange:M=>!M&&G(null),children:s.jsxs(Vs,{children:[s.jsxs(Rn,{children:[s.jsxs(wn,{children:[z==="createFile"&&t("sidebarFilesTree.dialog.createFile.title"),z==="createFolder"&&t("sidebarFilesTree.dialog.createFolder.title"),z==="rename"&&t("sidebarFilesTree.dialog.rename.title"),z==="delete"&&t("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Sn,{children:[z==="createFile"&&t("sidebarFilesTree.dialog.createFile.description",{path:J?.path??t("sidebarFilesTree.dialog.rootFallback")}),z==="createFolder"&&t("sidebarFilesTree.dialog.createFolder.description",{path:J?.path??t("sidebarFilesTree.dialog.rootFallback")}),z==="rename"&&t("sidebarFilesTree.dialog.rename.description",{name:J?.name??""}),z==="delete"&&t("sidebarFilesTree.dialog.delete.description",{name:J?.name??""})]})]}),z!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Jn,{value:re,onChange:M=>ee(M.target.value),placeholder:t(z==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:M=>{M.key==="Enter"&&de()},autoFocus:!0})}),s.jsxs(gr,{children:[s.jsx(nt,{variant:"outline",onClick:()=>G(null),disabled:he,children:t("sidebarFilesTree.dialog.cancel")}),s.jsx(nt,{variant:z==="delete"?"destructive":"default",onClick:()=>{de()},disabled:he||z!=="delete"&&!re.trim(),children:he?s.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t(z==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})},Uc=60,uy=t=>{try{return new URL(t).origin}catch{return""}},ba=new Set,yf=xr()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const o=uy(n);!o||!r||e().byOrigin[o]||ba.has(o)||(ba.add(o),yo("desktop_browser_fetch_favicon",{url:r}).then(i=>{const c=typeof i?.dataUrl=="string"?i.dataUrl:"";c&&t(a=>{const d={...a.byOrigin,[o]:c},u=Object.keys(d);if(u.length<=Uc)return{byOrigin:d};for(const h of u.slice(0,u.length-Uc))delete d[h];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{ba.delete(o)}))}})),kl=t=>t,Wa=t=>{const e=kl(t).type;return typeof e=="string"?e:""},fy=t=>{const e=kl(t).tool;return typeof e=="string"?e:""},my=t=>{const e=kl(t).text;return typeof e=="string"?e:""},hy=t=>{const e=Wa(t);return e==="tool"?fy(t).trim().toLowerCase()||"tool":e||"unknown"},py=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=hy(n);e.includes(r)||e.push(r)}return e.join(" + ")},gy=t=>t.replace(/\s+/g," ").trim(),xy=t=>{for(const n of t)if(Wa(n)==="text"){const r=gy(my(n));if(r.length===0)continue;return r}const e=t.filter(n=>Wa(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},by=(t,e,n)=>`${n(t)} / ${n(e)}`,yy=t=>{if(t==="12h")return!0;if(t==="24h")return!1},vy=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=yy(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},Va={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},ai={user:0,assistant:0,tool:0,other:0},Ir=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,ya=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(u=>u.tokens!==void 0)?.tokens;if(typeof n=="number")return{...Va,total:Ir(n)};if(!n||typeof n!="object")return Va;const r=n,o=Ir(r.input),i=Ir(r.output),c=Ir(r.reasoning),a=Ir(r.cache?.read),d=Ir(r.cache?.write);return{input:o,output:i,reasoning:c,cacheRead:a,cacheWrite:d,total:o+i+c+a+d}},wy=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Qs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+Qs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+Qs(n),0):0,Sy=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...ai,assistant:Qs(n.text)+Qs(n.content)};const o=wy(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Qs(n.input)+Qs(n.output)+Qs(n.error)+Qs(n.call?.input)+Qs(n.call?.output)+Qs(n.call?.error)+Qs(n.raw)+Math.round(Qs(n.metadata)*.25)+Math.round(Qs(n.state)*.1),other:0}:e==="user"?{user:o.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:o.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:o.length}},Wc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),jy=t=>{const e=Ro(t.info);return e.isUser?"user":e.role==="assistant"?"assistant":e.role==="tool"?"tool":"other"},ky=(t,e)=>{if(t.length===0)return{...ai};const n=t.reduce((r,o)=>{const i=jy(o);let c={...ai};for(const a of o.parts)c=Wc(c,Sy(a,i));return Wc(r,c)},{...ai});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},Rr=t=>t.toLocaleString(Co()),Cy=t=>!Number.isFinite(t)||t<=0?new Intl.NumberFormat(Co(),{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(0):new Intl.NumberFormat(Co(),{style:"currency",currency:"USD",minimumFractionDigits:t<.01?4:2,maximumFractionDigits:t<.01?4:2}).format(t),Ny=(t,e)=>!t||!Number.isFinite(t)?"-":gu(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Ay=(t,e,n)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===n);return{providerName:r?.name||e||"-",modelName:o?.name||n||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},Dy=()=>{const t=tt.c(203),{t:e}=mt(),n=xe(Py);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[o,i]=l.useState(r),[c,a]=l.useState(null),d=l.useRef(null),u=Je(Ey),h=Je(Ty),f=bu(h??void 0),g=Dh(u??"",h??void 0),b=Vt(Iy);let S;t[1]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(Ry),a(null)},t[1]=S):S=t[1];let v;t[2]!==h||t[3]!==u?(v=[h,u],t[2]=h,t[3]=u,t[4]=v):v=t[4],l.useEffect(S,v);let p,m;t[5]===Symbol.for("react.memo_cache_sentinel")?(p=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},m=[],t[5]=p,t[6]=m):(p=t[5],m=t[6]),l.useEffect(p,m);let x;t[7]===Symbol.for("react.memo_cache_sentinel")?(x=async(Qe,ht)=>{(await Xn(ht)).ok?(a(Qe),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{a($e=>$e===Qe?null:$e),d.current=null},2e3)):a(null)},t[7]=x):x=t[7];const w=x;let j;t[8]!==u||t[9]!==f?(j=u?f.find(Qe=>Qe.id===u)??null:null,t[8]=u,t[9]=f,t[10]=j):j=t[10];const N=j;let A,k,C,P,D,F;if(t[11]!==b||t[12]!==g){A=g.filter(My);let Qe;t[19]!==g?(Qe=g.filter(Oy),t[19]=g,t[20]=Qe):Qe=t[20],F=Qe;let ht=null;for(let $e=A.length-1;$e>=0;$e=$e-1,$e){const St=A[$e];if(ya(St).total>0){ht=St;break}}P=ht?ya(ht):Va,k=Ph({input:P.input,cache:{read:P.cacheRead,write:P.cacheWrite}}),D=A.reduce(Fy,0);const Ze=ht?.info??null;C=Ay(b,Ze?.providerID||"",Ze?.modelID||""),t[11]=b,t[12]=g,t[13]=A,t[14]=k,t[15]=C,t[16]=P,t[17]=D,t[18]=F}else A=t[13],k=t[14],C=t[15],P=t[16],D=t[17],F=t[18];const B=C,E=B.contextLimit,_=E&&E>0?Math.min(999,P.total/E*100):0;let W;if(t[21]!==g){const Qe=[...g].reverse().find(By)?.info?.system||"";W=ky(g,Qe),t[21]=g,t[22]=W}else W=t[22];const V=W,K=V.user,y=V.assistant,I=V.tool,$=Math.max(0,P.input-K-y-I),z=K+y+I+$,G=g[0]?.info?.time?.created,J=g.length>0?g[g.length-1]?.info?.time?.created:null;let Z;t[23]!==N?.title||t[24]!==e?(Z=N?.title||e("contextSidebar.session.untitled"),t[23]=N?.title,t[24]=e,t[25]=Z):Z=t[25];const re=N?.time?.created??G??null,ee=J??N?.time?.created??null;let he;t[26]!==y||t[27]!==$||t[28]!==I||t[29]!==K?(he={user:K,assistant:y,tool:I,other:$},t[26]=y,t[27]=$,t[28]=I,t[29]=K,t[30]=he):he=t[30];let be;t[31]!==A.length||t[32]!==z||t[33]!==k||t[34]!==E||t[35]!==B||t[36]!==g.length||t[37]!==re||t[38]!==ee||t[39]!==he||t[40]!==Z||t[41]!==P||t[42]!==D||t[43]!==_||t[44]!==F.length?(be={sessionTitle:Z,messagesCount:g.length,userMessagesCount:F.length,assistantMessagesCount:A.length,createdAt:re,lastActivityAt:ee,providerModel:B,tokenBreakdown:P,usagePercent:_,cacheHitRate:k,totalAssistantCost:D,contextLimit:E,breakdown:he,breakdownTotal:z},t[31]=A.length,t[32]=z,t[33]=k,t[34]=E,t[35]=B,t[36]=g.length,t[37]=re,t[38]=ee,t[39]=he,t[40]=Z,t[41]=P,t[42]=D,t[43]=_,t[44]=F.length,t[45]=be):be=t[45];const Y=be;if(!u){let Qe;t[46]!==e?(Qe=e("contextSidebar.empty.openSession"),t[46]=e,t[47]=Qe):Qe=t[47];let ht;return t[48]!==Qe?(ht=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Qe}),t[48]=Qe,t[49]=ht):ht=t[49],ht}let we;t[50]!==e?(we=e("contextSidebar.breakdown.user"),t[50]=e,t[51]=we):we=t[51];let me;t[52]!==we||t[53]!==Y.breakdown.user?(me={key:"user",label:we,value:Y.breakdown.user,color:"var(--status-success)"},t[52]=we,t[53]=Y.breakdown.user,t[54]=me):me=t[54];let Q;t[55]!==e?(Q=e("contextSidebar.breakdown.assistant"),t[55]=e,t[56]=Q):Q=t[56];let pe;t[57]!==Q||t[58]!==Y.breakdown.assistant?(pe={key:"assistant",label:Q,value:Y.breakdown.assistant,color:"var(--primary-base)"},t[57]=Q,t[58]=Y.breakdown.assistant,t[59]=pe):pe=t[59];let ve;t[60]!==e?(ve=e("contextSidebar.breakdown.toolCalls"),t[60]=e,t[61]=ve):ve=t[61];let Te;t[62]!==ve||t[63]!==Y.breakdown.tool?(Te={key:"tool",label:ve,value:Y.breakdown.tool,color:"var(--status-warning)"},t[62]=ve,t[63]=Y.breakdown.tool,t[64]=Te):Te=t[64];let ke;t[65]!==e?(ke=e("contextSidebar.breakdown.other"),t[65]=e,t[66]=ke):ke=t[66];let Ie;t[67]!==ke||t[68]!==Y.breakdown.other?(Ie={key:"other",label:ke,value:Y.breakdown.other,color:"var(--surface-muted-foreground)"},t[67]=ke,t[68]=Y.breakdown.other,t[69]=Ie):Ie=t[69];let Ne;t[70]!==me||t[71]!==pe||t[72]!==Te||t[73]!==Ie?(Ne=[me,pe,Te,Ie],t[70]=me,t[71]=pe,t[72]=Te,t[73]=Ie,t[74]=Ne):Ne=t[74];const Ae=Ne;let Se;t[75]!==Y.sessionTitle?(Se=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:Y.sessionTitle}),t[75]=Y.sessionTitle,t[76]=Se):Se=t[76];let Oe;t[77]!==Y.providerModel.modelName||t[78]!==Y.providerModel.providerName?(Oe=s.jsxs("span",{children:[Y.providerModel.providerName," / ",Y.providerModel.modelName]}),t[77]=Y.providerModel.modelName,t[78]=Y.providerModel.providerName,t[79]=Oe):Oe=t[79];let ne;t[80]!==n||t[81]!==Y.createdAt?(ne=Y.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:Ny(Y.createdAt,n)})]}),t[80]=n,t[81]=Y.createdAt,t[82]=ne):ne=t[82];let ce;t[83]!==Oe||t[84]!==ne?(ce=s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[Oe,ne]}),t[83]=Oe,t[84]=ne,t[85]=ce):ce=t[85];let Re;t[86]!==Se||t[87]!==ce?(Re=s.jsxs("div",{className:"mb-6",children:[Se,ce]}),t[86]=Se,t[87]=ce,t[88]=Re):Re=t[88];let te;t[89]!==e?(te=e("contextSidebar.section.context"),t[89]=e,t[90]=te):te=t[90];let ae;t[91]!==te?(ae=s.jsx("span",{className:"typography-micro text-muted-foreground",children:te}),t[91]=te,t[92]=ae):ae=t[92];let de;t[93]!==Y.tokenBreakdown.total?(de=Rr(Y.tokenBreakdown.total),t[93]=Y.tokenBreakdown.total,t[94]=de):de=t[94];let H;t[95]!==Y.contextLimit?(H=Y.contextLimit?` / ${Rr(Y.contextLimit)}`:"",t[95]=Y.contextLimit,t[96]=H):H=t[96];let ge;t[97]!==de||t[98]!==H?(ge=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[de,H]}),t[97]=de,t[98]=H,t[99]=ge):ge=t[99];let ue;t[100]!==ae||t[101]!==ge?(ue=s.jsxs("div",{className:"flex items-baseline justify-between",children:[ae,ge]}),t[100]=ae,t[101]=ge,t[102]=ue):ue=t[102];let M;t[103]!==Y.usagePercent?(M=Y.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,Y.usagePercent)}%`,backgroundColor:Y.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[103]=Y.usagePercent,t[104]=M):M=t[104];let oe;t[105]!==M?(oe=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:M}),t[105]=M,t[106]=oe):oe=t[106];let De;t[107]!==e||t[108]!==Y.usagePercent?(De=e("contextSidebar.context.percentUsed",{percent:Y.usagePercent.toFixed(1)}),t[107]=e,t[108]=Y.usagePercent,t[109]=De):De=t[109];let fe;t[110]!==De?(fe=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:De}),t[110]=De,t[111]=fe):fe=t[111];let X;t[112]!==ue||t[113]!==oe||t[114]!==fe?(X=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ue,oe,fe]}),t[112]=ue,t[113]=oe,t[114]=fe,t[115]=X):X=t[115];let le;t[116]!==e?(le=e("contextSidebar.stats.messages"),t[116]=e,t[117]=le):le=t[117];let se;t[118]!==Y.messagesCount?(se=Rr(Y.messagesCount),t[118]=Y.messagesCount,t[119]=se):se=t[119];let T;t[120]!==le||t[121]!==se?(T={label:le,value:se},t[120]=le,t[121]=se,t[122]=T):T=t[122];let ie;t[123]!==e?(ie=e("contextSidebar.stats.user"),t[123]=e,t[124]=ie):ie=t[124];let je;t[125]!==Y.userMessagesCount?(je=Rr(Y.userMessagesCount),t[125]=Y.userMessagesCount,t[126]=je):je=t[126];let Pe;t[127]!==ie||t[128]!==je?(Pe={label:ie,value:je},t[127]=ie,t[128]=je,t[129]=Pe):Pe=t[129];let U;t[130]!==e?(U=e("contextSidebar.stats.assistant"),t[130]=e,t[131]=U):U=t[131];let Be;t[132]!==Y.assistantMessagesCount?(Be=Rr(Y.assistantMessagesCount),t[132]=Y.assistantMessagesCount,t[133]=Be):Be=t[133];let Fe;t[134]!==U||t[135]!==Be?(Fe={label:U,value:Be},t[134]=U,t[135]=Be,t[136]=Fe):Fe=t[136];let Ye;t[137]!==e?(Ye=e("contextSidebar.stats.cost"),t[137]=e,t[138]=Ye):Ye=t[138];let at;t[139]!==Y.totalAssistantCost?(at=Cy(Y.totalAssistantCost),t[139]=Y.totalAssistantCost,t[140]=at):at=t[140];let st;t[141]!==Ye||t[142]!==at?(st={label:Ye,value:at},t[141]=Ye,t[142]=at,t[143]=st):st=t[143];let ct;t[144]!==T||t[145]!==Pe||t[146]!==Fe||t[147]!==st?(ct=[T,Pe,Fe,st],t[144]=T,t[145]=Pe,t[146]=Fe,t[147]=st,t[148]=ct):ct=t[148];const bt=ct;let rt;t[149]!==bt?(rt=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:bt.map(Ly)}),t[149]=bt,t[150]=rt):rt=t[150];let gt;t[151]!==e?(gt=e("contextSidebar.section.lastAssistantMessage"),t[151]=e,t[152]=gt):gt=t[152];let it;t[153]!==gt?(it=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:gt}),t[153]=gt,t[154]=it):it=t[154];let Et;t[155]!==e||t[156]!==Y.cacheHitRate.hasInput||t[157]!==Y.cacheHitRate.percent||t[158]!==Y.tokenBreakdown.cacheRead||t[159]!==Y.tokenBreakdown.cacheWrite||t[160]!==Y.tokenBreakdown.input||t[161]!==Y.tokenBreakdown.output||t[162]!==Y.tokenBreakdown.reasoning?(Et=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:Y.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:Y.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:Y.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:Y.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:Y.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:Y.cacheHitRate.hasInput?Y.cacheHitRate.percent:null,format:"percent"}].map(_y)}),t[155]=e,t[156]=Y.cacheHitRate.hasInput,t[157]=Y.cacheHitRate.percent,t[158]=Y.tokenBreakdown.cacheRead,t[159]=Y.tokenBreakdown.cacheWrite,t[160]=Y.tokenBreakdown.input,t[161]=Y.tokenBreakdown.output,t[162]=Y.tokenBreakdown.reasoning,t[163]=Et):Et=t[163];let Ft;t[164]!==it||t[165]!==Et?(Ft=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[it,Et]}),t[164]=it,t[165]=Et,t[166]=Ft):Ft=t[166];let Dt;t[167]!==Ae||t[168]!==Y.breakdownTotal?(Dt=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Ae.map(Qe=>Qe.value<=0||Y.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${Qe.value/Y.breakdownTotal*100}%`,backgroundColor:Qe.color}},Qe.key))}),t[167]=Ae,t[168]=Y.breakdownTotal,t[169]=Dt):Dt=t[169];let Bt;t[170]!==Ae||t[171]!==Y.breakdownTotal?(Bt=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:Ae.map(Qe=>{const ht=Y.breakdownTotal>0?Qe.value/Y.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Qe.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[Qe.label," ",s.jsxs("span",{className:"tabular-nums",children:[ht.toFixed(0),"%"]})]})]},Qe.key)})}),t[170]=Ae,t[171]=Y.breakdownTotal,t[172]=Bt):Bt=t[172];let qe;t[173]!==Dt||t[174]!==Bt?(qe=s.jsxs("div",{className:"mb-6",children:[Dt,Bt]}),t[173]=Dt,t[174]=Bt,t[175]=qe):qe=t[175];let zt;t[176]!==e?(zt=e("contextSidebar.section.rawMessages"),t[176]=e,t[177]=zt):zt=t[177];let Nt;t[178]!==zt?(Nt=s.jsx("div",{className:"typography-micro text-muted-foreground",children:zt}),t[178]=zt,t[179]=Nt):Nt=t[179];let xt;if(t[180]!==c||t[181]!==o||t[182]!==g||t[183]!==e||t[184]!==n){let Qe;t[186]!==c||t[187]!==o||t[188]!==e||t[189]!==n?(Qe=ht=>{const $e=Ro(ht.info).role,St=$e==="assistant",Lt=$e==="user",Ot=o[ht.info.id]===!0,ss=c===ht.info.id,_t=ht.info.time?.created??null,Ct=py(ht.parts),os=St?ya({info:ht.info,parts:ht.parts}):null,hs=Lt?xy(ht.parts):"",Rt=vy(_t,n),$t=Ct||"—",Wt=os?by(os.input,os.output,Rr):"",is=$e||"unknown",Me=Ct?`${is}: ${Ct}`:is,Ke=Ot?JSON.stringify({info:ht.info,parts:ht.parts},null,2):"";return s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[s.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":Ot,onClick:()=>{i(ze=>({...ze,[ht.info.id]:ze[ht.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:St?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Lt?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",hs]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:St?$t:Me}),St&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Wt})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Rt})]})}),Ot&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[s.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:ze=>{ze.stopPropagation(),w(ht.info.id,Ke)},"aria-label":e(ss?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(ss?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:ss?s.jsx(R,{name:"check",className:"size-3.5"}):s.jsx(R,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Eh,{language:"json",code:Ke,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},ht.info.id)},t[186]=c,t[187]=o,t[188]=e,t[189]=n,t[190]=Qe):Qe=t[190],xt=[...g].reverse().map(Qe),t[180]=c,t[181]=o,t[182]=g,t[183]=e,t[184]=n,t[185]=xt}else xt=t[185];let Pt;t[191]!==xt?(Pt=s.jsx("div",{className:"mt-2.5 space-y-1",children:xt}),t[191]=xt,t[192]=Pt):Pt=t[192];let Mt;t[193]!==Nt||t[194]!==Pt?(Mt=s.jsxs("div",{children:[Nt,Pt]}),t[193]=Nt,t[194]=Pt,t[195]=Mt):Mt=t[195];let Xt;return t[196]!==Re||t[197]!==X||t[198]!==rt||t[199]!==Ft||t[200]!==qe||t[201]!==Mt?(Xt=s.jsx("div",{className:"h-full overflow-y-auto bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[Re,X,rt,Ft,qe,Mt]})}),t[196]=Re,t[197]=X,t[198]=rt,t[199]=Ft,t[200]=qe,t[201]=Mt,t[202]=Xt):Xt=t[202],Xt};function Py(t){return t.timeFormatPreference}function Ey(t){return t.currentSessionId}function Ty(t){return t.currentSessionDirectory}function Iy(t){return t.providers}function Ry(t){return Object.keys(t).length>0?{}:t}function My(t){return Ro(t.info).role==="assistant"}function Oy(t){return Ro(t.info).isUser}function Fy(t,e){const n=Ir(e.info.cost);return t+n}function By(t){return Ro(t.info).isUser&&typeof t.info.system=="string"}function Ly(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function _y(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value!==null&&t.value!==void 0?t.format==="percent"?`${t.value.toFixed(1)}%`:Rr(t.value):"—"})]},t.label)}const vf=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),$y=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return vf.has(n.toLowerCase())},pn="about:blank",Qr=t=>{const e=t.trim();if(!e)return pn;const n=e.includes("://")?e:`${$y(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?pn:r.toString()}catch{return pn}},so=t=>{try{return vf.has(new URL(t).hostname.toLowerCase())}catch{return!1}},Cl=t=>{if(!t||t===pn)return"";try{return new URL(t).host||t}catch{return t}},zy=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),Uy=(t,e)=>zy.has(t)&&so(e),Wy=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"},Vy=async t=>{try{const e=await ms("/api/dev-servers",{signal:t});if(!e.ok)return{kind:"unavailable"};const n=await e.json();if(!n||typeof n!="object")return{kind:"unavailable"};const r=n.servers;return Array.isArray(r)?{kind:"ready",servers:r.filter(Wy)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Hy=async t=>{try{const e=await ms("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},Ky=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},Gy=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const o=Ky(r);o!==null&&!n.has(o)&&n.set(o,r)}return e?e.map(r=>{const o=n.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...n.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},Ha="__openchamberBrowserAnnotationActive",qy=`(() => {
|
|
47
|
-
try {
|
|
48
|
-
var host = document.querySelector('[data-openchamber-annotation]');
|
|
49
|
-
if (host && host.parentNode) host.parentNode.removeChild(host);
|
|
50
|
-
} catch (error) { /* page navigated away */ }
|
|
51
|
-
try {
|
|
52
|
-
var cursor = document.getElementById('openchamber-annotation-cursor');
|
|
53
|
-
if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
|
|
54
|
-
} catch (error) { /* page navigated away */ }
|
|
55
|
-
try { delete window['${Ha}']; } catch (error) { /* non-configurable */ }
|
|
56
|
-
})();`,Yy=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
|
|
57
|
-
var CONFIG = ${n};
|
|
58
|
-
var THEME = CONFIG.theme;
|
|
59
|
-
var LABELS = CONFIG.labels;
|
|
60
|
-
var OVERLAY_ATTR = 'data-openchamber-annotation';
|
|
61
|
-
var Z_OVERLAY = 2147483646;
|
|
62
|
-
var MAX_TEXT = 400;
|
|
63
|
-
var MIN_RECT = 3;
|
|
64
|
-
var EDITOR_GAP = 10;
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
|
|
68
|
-
if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
|
|
69
|
-
} catch (error) { /* nothing to clean */ }
|
|
70
|
-
|
|
71
|
-
window['${Ha}'] = true;
|
|
72
|
-
|
|
73
|
-
var counter = 0;
|
|
74
|
-
var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
|
|
75
|
-
|
|
76
|
-
var selected = null;
|
|
77
|
-
var regions = [];
|
|
78
|
-
var strokes = [];
|
|
79
|
-
var tool = 'select';
|
|
80
|
-
var settled = false;
|
|
81
|
-
|
|
82
|
-
// ---------------------------------------------------------------- geometry
|
|
83
|
-
|
|
84
|
-
var rectFrom = function (domRect) {
|
|
85
|
-
return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
|
|
86
|
-
};
|
|
87
|
-
var normalizeRect = function (ax, ay, bx, by) {
|
|
88
|
-
return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
|
|
89
|
-
};
|
|
90
|
-
var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
|
|
91
|
-
|
|
92
|
-
// ------------------------------------------------------------- description
|
|
93
|
-
|
|
94
|
-
var isOverlayNode = function (element) {
|
|
95
|
-
var node = element;
|
|
96
|
-
while (node) {
|
|
97
|
-
if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
|
|
98
|
-
node = node.parentNode || (node.host || null);
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
var elementFromPoint = function (x, y) {
|
|
104
|
-
var found = document.elementFromPoint(x, y);
|
|
105
|
-
if (!found || isOverlayNode(found)) return null;
|
|
106
|
-
return found;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
var selectorPart = function (element) {
|
|
110
|
-
var part = element.tagName.toLowerCase();
|
|
111
|
-
if (element.id) return part + '#' + element.id;
|
|
112
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
113
|
-
if (className) {
|
|
114
|
-
var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
|
|
115
|
-
if (first) part += '.' + first;
|
|
116
|
-
}
|
|
117
|
-
return part;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
var buildSelector = function (element) {
|
|
121
|
-
if (element.id) return '#' + element.id;
|
|
122
|
-
var parts = [];
|
|
123
|
-
var node = element;
|
|
124
|
-
var depth = 0;
|
|
125
|
-
while (node && node.nodeType === 1 && depth < 5) {
|
|
126
|
-
var part = selectorPart(node);
|
|
127
|
-
var parent = node.parentElement;
|
|
128
|
-
if (parent) {
|
|
129
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
130
|
-
return child.tagName === node.tagName;
|
|
131
|
-
});
|
|
132
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
133
|
-
}
|
|
134
|
-
parts.unshift(part);
|
|
135
|
-
if (node.id) break;
|
|
136
|
-
node = parent;
|
|
137
|
-
depth += 1;
|
|
138
|
-
}
|
|
139
|
-
return parts.join(' > ');
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
|
|
143
|
-
var STYLE_PROPS = [
|
|
144
|
-
'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
|
|
145
|
-
'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
|
|
146
|
-
'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
|
|
147
|
-
];
|
|
148
|
-
|
|
149
|
-
var describe = function (element) {
|
|
150
|
-
var computed = window.getComputedStyle(element);
|
|
151
|
-
var attributes = {};
|
|
152
|
-
for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
|
|
153
|
-
var name = INTERESTING_ATTRS[i];
|
|
154
|
-
var value = element.getAttribute(name);
|
|
155
|
-
if (value) attributes[name] = String(value).slice(0, 200);
|
|
156
|
-
}
|
|
157
|
-
var computedStyle = {};
|
|
158
|
-
for (var j = 0; j < STYLE_PROPS.length; j += 1) {
|
|
159
|
-
var prop = STYLE_PROPS[j];
|
|
160
|
-
computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
|
|
161
|
-
}
|
|
162
|
-
var ancestry = [];
|
|
163
|
-
var node = element.parentElement;
|
|
164
|
-
var depth = 0;
|
|
165
|
-
while (node && node.nodeType === 1 && depth < 4) {
|
|
166
|
-
var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
|
|
167
|
-
if (node.id) entry.id = node.id;
|
|
168
|
-
var cls = typeof node.className === 'string' ? node.className.trim() : '';
|
|
169
|
-
if (cls) entry.className = cls.slice(0, 200);
|
|
170
|
-
ancestry.unshift(entry);
|
|
171
|
-
node = node.parentElement;
|
|
172
|
-
depth += 1;
|
|
173
|
-
}
|
|
174
|
-
var box = element.getBoundingClientRect();
|
|
175
|
-
var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
|
|
176
|
-
return {
|
|
177
|
-
tag: element.tagName.toLowerCase(),
|
|
178
|
-
text: text.slice(0, MAX_TEXT),
|
|
179
|
-
selector: buildSelector(element),
|
|
180
|
-
path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
|
|
181
|
-
bounds: rectFrom(box),
|
|
182
|
-
center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
|
|
183
|
-
attributes: attributes,
|
|
184
|
-
computedStyle: computedStyle,
|
|
185
|
-
ancestry: ancestry
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
// ------------------------------------------------------------------ chrome
|
|
190
|
-
|
|
191
|
-
var host = document.createElement('div');
|
|
192
|
-
host.setAttribute(OVERLAY_ATTR, '');
|
|
193
|
-
host.style.cssText = 'position:fixed;inset:0;z-index:' + Z_OVERLAY + ';pointer-events:none';
|
|
194
|
-
var shadow = host.attachShadow({ mode: 'closed' });
|
|
195
|
-
|
|
196
|
-
var style = document.createElement('style');
|
|
197
|
-
style.textContent = [
|
|
198
|
-
':host{all:initial}',
|
|
199
|
-
'*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
|
|
200
|
-
'.layer{position:fixed;inset:0;pointer-events:none}',
|
|
201
|
-
'.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
|
|
202
|
-
'.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}',
|
|
203
|
-
'.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}',
|
|
204
|
-
'.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}',
|
|
205
|
-
'.tools button:hover{background:' + THEME.primaryFaint + '}',
|
|
206
|
-
'.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
|
|
207
|
-
'.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}',
|
|
208
|
-
'.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}',
|
|
209
|
-
'.editor textarea::placeholder{color:' + THEME.mutedText + '}',
|
|
210
|
-
'.editor button{appearance:none;border:none;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';border-radius:999px;padding:8px 18px;font-size:12px;line-height:18px;font-weight:600;cursor:pointer;white-space:nowrap}',
|
|
211
|
-
'.editor button[disabled]{opacity:.5;cursor:default}'
|
|
212
|
-
].join('');
|
|
213
|
-
shadow.appendChild(style);
|
|
214
|
-
|
|
215
|
-
var cursorStyle = document.createElement('style');
|
|
216
|
-
cursorStyle.id = 'openchamber-annotation-cursor';
|
|
217
|
-
document.head.appendChild(cursorStyle);
|
|
218
|
-
var setCursor = function (value) {
|
|
219
|
-
cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
var svgNS = 'http://www.w3.org/2000/svg';
|
|
223
|
-
var svg = document.createElementNS(svgNS, 'svg');
|
|
224
|
-
svg.setAttribute('class', 'layer');
|
|
225
|
-
svg.style.overflow = 'visible';
|
|
226
|
-
shadow.appendChild(svg);
|
|
227
|
-
|
|
228
|
-
var hoverBox = document.createElement('div');
|
|
229
|
-
hoverBox.className = 'box';
|
|
230
|
-
var hoverLabel = document.createElement('div');
|
|
231
|
-
hoverLabel.className = 'label';
|
|
232
|
-
var marqueeBox = document.createElement('div');
|
|
233
|
-
marqueeBox.className = 'box';
|
|
234
|
-
shadow.append(hoverBox, hoverLabel, marqueeBox);
|
|
235
|
-
|
|
236
|
-
var positionBox = function (node, rect) {
|
|
237
|
-
node.style.display = 'block';
|
|
238
|
-
node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
|
|
239
|
-
node.style.width = rect.width + 'px';
|
|
240
|
-
node.style.height = rect.height + 'px';
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
var tools = document.createElement('div');
|
|
244
|
-
tools.className = 'tools';
|
|
245
|
-
shadow.appendChild(tools);
|
|
246
|
-
|
|
247
|
-
var toolButtons = {};
|
|
248
|
-
[['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
|
|
249
|
-
var button = document.createElement('button');
|
|
250
|
-
button.type = 'button';
|
|
251
|
-
button.textContent = entry[1];
|
|
252
|
-
button.addEventListener('click', function () { setTool(entry[0]); });
|
|
253
|
-
toolButtons[entry[0]] = button;
|
|
254
|
-
tools.appendChild(button);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
var editor = document.createElement('div');
|
|
258
|
-
editor.className = 'editor';
|
|
259
|
-
shadow.appendChild(editor);
|
|
260
|
-
|
|
261
|
-
var comment = document.createElement('textarea');
|
|
262
|
-
comment.rows = 1;
|
|
263
|
-
comment.placeholder = LABELS.commentPlaceholder;
|
|
264
|
-
var submit = document.createElement('button');
|
|
265
|
-
submit.type = 'button';
|
|
266
|
-
submit.textContent = LABELS.submit;
|
|
267
|
-
editor.append(comment, submit);
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Grows the box with its content.
|
|
271
|
-
*
|
|
272
|
-
* A hidden element reports scrollHeight 0, so measuring one collapses the
|
|
273
|
-
* field to nothing — which is what left a sliver of a click target and an
|
|
274
|
-
* invisible caret. Measuring only while visible, and never below the CSS
|
|
275
|
-
* min-height, keeps it usable.
|
|
276
|
-
*/
|
|
277
|
-
var resizeComment = function () {
|
|
278
|
-
if (editor.style.display === 'none') return;
|
|
279
|
-
comment.style.height = 'auto';
|
|
280
|
-
comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
|
|
281
|
-
};
|
|
282
|
-
comment.addEventListener('input', resizeComment);
|
|
283
|
-
|
|
284
|
-
// -------------------------------------------------------------- selection
|
|
285
|
-
|
|
286
|
-
var lastTargetRect = null;
|
|
287
|
-
|
|
288
|
-
/** Places the comment box under whatever was just marked, kept on screen. */
|
|
289
|
-
var positionEditor = function () {
|
|
290
|
-
if (!lastTargetRect) {
|
|
291
|
-
editor.style.display = 'none';
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
var wasHidden = editor.style.display === 'none';
|
|
295
|
-
editor.style.display = 'flex';
|
|
296
|
-
// Measured now that it is laid out, not while it was still hidden.
|
|
297
|
-
if (wasHidden) resizeComment();
|
|
298
|
-
var box = editor.getBoundingClientRect();
|
|
299
|
-
var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
|
|
300
|
-
var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
|
|
301
|
-
// Above the target when there is no room below, so the box is never left
|
|
302
|
-
// half off the bottom of the page.
|
|
303
|
-
if (top + box.height > window.innerHeight - 8) {
|
|
304
|
-
top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
|
|
305
|
-
}
|
|
306
|
-
left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
|
|
307
|
-
editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
/** Focus after layout: focusing a zero-height field puts the caret nowhere. */
|
|
311
|
-
var focusComment = function () {
|
|
312
|
-
requestAnimationFrame(function () {
|
|
313
|
-
try {
|
|
314
|
-
comment.focus({ preventScroll: true });
|
|
315
|
-
comment.setSelectionRange(comment.value.length, comment.value.length);
|
|
316
|
-
} catch (error) { /* field went away */ }
|
|
317
|
-
});
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
var hasTargets = function () {
|
|
321
|
-
return Boolean(selected) || regions.length > 0 || strokes.length > 0;
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
var syncChrome = function () {
|
|
325
|
-
submit.disabled = !hasTargets();
|
|
326
|
-
if (!hasTargets()) {
|
|
327
|
-
lastTargetRect = null;
|
|
328
|
-
editor.style.display = 'none';
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
positionEditor();
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
var syncSelectionVisuals = function () {
|
|
335
|
-
if (!selected) return;
|
|
336
|
-
var rect = rectFrom(selected.element.getBoundingClientRect());
|
|
337
|
-
if (!usableRect(rect)) {
|
|
338
|
-
selected.outline.style.display = 'none';
|
|
339
|
-
selected.badge.style.display = 'none';
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
positionBox(selected.outline, rect);
|
|
343
|
-
selected.badge.style.display = 'block';
|
|
344
|
-
selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
345
|
-
lastTargetRect = rect;
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
var dropSelection = function () {
|
|
349
|
-
if (!selected) return;
|
|
350
|
-
selected.outline.remove();
|
|
351
|
-
selected.badge.remove();
|
|
352
|
-
selected = null;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
var selectElement = function (element) {
|
|
356
|
-
var wasSelected = selected && selected.element === element;
|
|
357
|
-
dropSelection();
|
|
358
|
-
if (wasSelected) {
|
|
359
|
-
// Clicking the chosen element again clears it, so a misclick costs one
|
|
360
|
-
// click rather than starting over.
|
|
361
|
-
lastTargetRect = null;
|
|
362
|
-
syncChrome();
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
var outline = document.createElement('div');
|
|
366
|
-
outline.className = 'box';
|
|
367
|
-
var badge = document.createElement('div');
|
|
368
|
-
badge.className = 'label';
|
|
369
|
-
badge.textContent = selectorPart(element);
|
|
370
|
-
shadow.append(outline, badge);
|
|
371
|
-
selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
|
|
372
|
-
syncSelectionVisuals();
|
|
373
|
-
syncChrome();
|
|
374
|
-
focusComment();
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
var setTool = function (next) {
|
|
378
|
-
tool = next;
|
|
379
|
-
hoverBox.style.display = 'none';
|
|
380
|
-
hoverLabel.style.display = 'none';
|
|
381
|
-
marqueeBox.style.display = 'none';
|
|
382
|
-
setCursor(next === 'select' ? '' : 'crosshair');
|
|
383
|
-
for (var key in toolButtons) {
|
|
384
|
-
if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
|
|
385
|
-
toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
// ------------------------------------------------------------- interaction
|
|
391
|
-
|
|
392
|
-
var drag = null;
|
|
393
|
-
|
|
394
|
-
var onPointerMove = function (event) {
|
|
395
|
-
if (drag) {
|
|
396
|
-
if (drag.kind === 'marquee') {
|
|
397
|
-
drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
|
|
398
|
-
positionBox(marqueeBox, drag.rect);
|
|
399
|
-
} else if (drag.kind === 'draw') {
|
|
400
|
-
drag.points.push({ x: event.clientX, y: event.clientY });
|
|
401
|
-
drag.path.setAttribute('d', drag.points.map(function (point, index) {
|
|
402
|
-
return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
|
|
403
|
-
}).join(' '));
|
|
404
|
-
}
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (tool !== 'select') return;
|
|
409
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
410
|
-
if (!element) {
|
|
411
|
-
hoverBox.style.display = 'none';
|
|
412
|
-
hoverLabel.style.display = 'none';
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
var rect = rectFrom(element.getBoundingClientRect());
|
|
416
|
-
positionBox(hoverBox, rect);
|
|
417
|
-
hoverLabel.textContent = selectorPart(element);
|
|
418
|
-
hoverLabel.style.display = 'block';
|
|
419
|
-
hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
var onPointerDown = function (event) {
|
|
423
|
-
if (event.button !== 0) return;
|
|
424
|
-
if (isOverlayNode(event.target)) return;
|
|
425
|
-
event.preventDefault();
|
|
426
|
-
event.stopPropagation();
|
|
427
|
-
|
|
428
|
-
if (tool === 'select') {
|
|
429
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
430
|
-
if (element) selectElement(element);
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
if (tool === 'marquee') {
|
|
435
|
-
drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
var path = document.createElementNS(svgNS, 'path');
|
|
440
|
-
path.setAttribute('fill', 'none');
|
|
441
|
-
path.setAttribute('stroke', THEME.primary);
|
|
442
|
-
path.setAttribute('stroke-width', '2.5');
|
|
443
|
-
path.setAttribute('stroke-linecap', 'round');
|
|
444
|
-
path.setAttribute('stroke-linejoin', 'round');
|
|
445
|
-
svg.appendChild(path);
|
|
446
|
-
drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
var onPointerUp = function () {
|
|
450
|
-
if (!drag) return;
|
|
451
|
-
var finished = drag;
|
|
452
|
-
drag = null;
|
|
453
|
-
|
|
454
|
-
if (finished.kind === 'marquee') {
|
|
455
|
-
marqueeBox.style.display = 'none';
|
|
456
|
-
var rect = finished.rect;
|
|
457
|
-
if (!rect || !usableRect(rect)) return;
|
|
458
|
-
// A region marks an area, not the elements inside it: expanding it into a
|
|
459
|
-
// selection made the result depend on the page's markup rather than on
|
|
460
|
-
// what was drawn.
|
|
461
|
-
regions.push({ id: nextId('region'), rect: rect });
|
|
462
|
-
var outline = document.createElementNS(svgNS, 'rect');
|
|
463
|
-
outline.setAttribute('x', String(rect.x));
|
|
464
|
-
outline.setAttribute('y', String(rect.y));
|
|
465
|
-
outline.setAttribute('width', String(rect.width));
|
|
466
|
-
outline.setAttribute('height', String(rect.height));
|
|
467
|
-
outline.style.fill = THEME.primarySoft;
|
|
468
|
-
outline.setAttribute('stroke', THEME.primary);
|
|
469
|
-
outline.setAttribute('stroke-width', '1.5');
|
|
470
|
-
outline.setAttribute('rx', '2');
|
|
471
|
-
svg.appendChild(outline);
|
|
472
|
-
lastTargetRect = rect;
|
|
473
|
-
syncChrome();
|
|
474
|
-
focusComment();
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
var points = finished.points;
|
|
479
|
-
if (points.length < 2) {
|
|
480
|
-
if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
|
|
484
|
-
for (var p = 1; p < points.length; p += 1) {
|
|
485
|
-
minX = Math.min(minX, points[p].x);
|
|
486
|
-
minY = Math.min(minY, points[p].y);
|
|
487
|
-
maxX = Math.max(maxX, points[p].x);
|
|
488
|
-
maxY = Math.max(maxY, points[p].y);
|
|
489
|
-
}
|
|
490
|
-
var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
491
|
-
strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
|
|
492
|
-
lastTargetRect = bounds;
|
|
493
|
-
syncChrome();
|
|
494
|
-
focusComment();
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Swallows the page's own mouse handling while annotating.
|
|
499
|
-
*
|
|
500
|
-
* Blocking pointerdown is not enough: a click still follows it, so marking a
|
|
501
|
-
* button pressed that button and marking a link navigated away from the page
|
|
502
|
-
* being annotated. These are the events that reach page code, so these are
|
|
503
|
-
* the ones that have to stop.
|
|
504
|
-
*/
|
|
505
|
-
var blockPageInteraction = function (event) {
|
|
506
|
-
if (isOverlayNode(event.target)) return;
|
|
507
|
-
event.preventDefault();
|
|
508
|
-
event.stopPropagation();
|
|
509
|
-
};
|
|
510
|
-
var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
|
|
511
|
-
|
|
512
|
-
var onScrollOrResize = function () {
|
|
513
|
-
syncSelectionVisuals();
|
|
514
|
-
positionEditor();
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
var onKeyDown = function (event) {
|
|
518
|
-
if (event.key === 'Escape') {
|
|
519
|
-
event.preventDefault();
|
|
520
|
-
event.stopImmediatePropagation();
|
|
521
|
-
finish(null);
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
if (event.key === 'Enter' && !event.shiftKey && event.target === comment) {
|
|
525
|
-
event.preventDefault();
|
|
526
|
-
attach();
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
document.addEventListener('pointermove', onPointerMove, true);
|
|
531
|
-
document.addEventListener('pointerdown', onPointerDown, true);
|
|
532
|
-
document.addEventListener('pointerup', onPointerUp, true);
|
|
533
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
534
|
-
window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
|
|
535
|
-
});
|
|
536
|
-
window.addEventListener('scroll', onScrollOrResize, true);
|
|
537
|
-
window.addEventListener('resize', onScrollOrResize, true);
|
|
538
|
-
window.addEventListener('keydown', onKeyDown, true);
|
|
539
|
-
|
|
540
|
-
// ------------------------------------------------------------------ finish
|
|
541
|
-
|
|
542
|
-
var teardown = function () {
|
|
543
|
-
document.removeEventListener('pointermove', onPointerMove, true);
|
|
544
|
-
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
545
|
-
document.removeEventListener('pointerup', onPointerUp, true);
|
|
546
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
547
|
-
window.removeEventListener(name, blockPageInteraction, true);
|
|
548
|
-
});
|
|
549
|
-
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
550
|
-
window.removeEventListener('resize', onScrollOrResize, true);
|
|
551
|
-
window.removeEventListener('keydown', onKeyDown, true);
|
|
552
|
-
setCursor('');
|
|
553
|
-
if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
|
|
554
|
-
if (host.parentNode) host.parentNode.removeChild(host);
|
|
555
|
-
try { delete window['${Ha}']; } catch (error) { /* non-configurable */ }
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
var finish = function (payload) {
|
|
559
|
-
if (settled) return;
|
|
560
|
-
settled = true;
|
|
561
|
-
teardown();
|
|
562
|
-
// Removing the chrome is not enough: the host screenshots this page right
|
|
563
|
-
// after we resolve, and the compositor can still hold a frame containing
|
|
564
|
-
// our outlines. Yield two frames so the page has actually repainted.
|
|
565
|
-
requestAnimationFrame(function () {
|
|
566
|
-
requestAnimationFrame(function () { resolve(payload); });
|
|
567
|
-
});
|
|
568
|
-
};
|
|
569
|
-
|
|
570
|
-
var attach = function () {
|
|
571
|
-
if (!hasTargets()) return;
|
|
572
|
-
finish({
|
|
573
|
-
id: 'annotation-' + Date.now(),
|
|
574
|
-
pageUrl: String(location.href),
|
|
575
|
-
pageTitle: String(document.title || ''),
|
|
576
|
-
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
577
|
-
devicePixelRatio: window.devicePixelRatio || 1,
|
|
578
|
-
comment: comment.value,
|
|
579
|
-
// Zero or one element, never more. Kept as a list so elements, regions
|
|
580
|
-
// and strokes stay one uniform shape for everything downstream.
|
|
581
|
-
elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
|
|
582
|
-
regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
|
|
583
|
-
strokes: strokes.map(function (entry) {
|
|
584
|
-
return { id: entry.id, points: entry.points, bounds: entry.bounds };
|
|
585
|
-
})
|
|
586
|
-
});
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
submit.addEventListener('click', attach);
|
|
590
|
-
|
|
591
|
-
(document.body || document.documentElement).appendChild(host);
|
|
592
|
-
setTool('select');
|
|
593
|
-
syncChrome();
|
|
594
|
-
});`},Qy={kind:"idle"},zn=t=>typeof t=="object"&&t!==null,Qn=t=>typeof t=="number"&&Number.isFinite(t),Vc=t=>zn(t)&&Object.values(t).every(e=>typeof e=="string"),Nl=t=>zn(t)&&Qn(t.x)&&Qn(t.y)&&Qn(t.width)&&Qn(t.height),wf=t=>zn(t)&&Qn(t.x)&&Qn(t.y),Xy=t=>zn(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"),Jy=t=>zn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&Nl(t.bounds)&&wf(t.center)&&Vc(t.attributes)&&Vc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(Xy),Zy=t=>zn(t)&&typeof t.id=="string"&&Jy(t.element),ev=t=>zn(t)&&typeof t.id=="string"&&Nl(t.rect),tv=t=>zn(t)&&typeof t.id=="string"&&Nl(t.bounds)&&Array.isArray(t.points)&&t.points.every(wf),sv=t=>zn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&zn(t.viewport)&&Qn(t.viewport.width)&&Qn(t.viewport.height)&&Qn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(Zy)&&Array.isArray(t.regions)&&t.regions.every(ev)&&Array.isArray(t.strokes)&&t.strokes.every(tv),nv=1600,rv=t=>new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>n(new Error("Failed to decode browser page capture")),r.src=t}),ov=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:o,cssHeight:i,payload:c,accentColor:a,accentFill:d})=>{if(!t)return null;try{const u=await rv(`data:${e};base64,${t}`),h=Math.max(1,u.naturalWidth||n),f=Math.max(1,u.naturalHeight||r),g=h/Math.max(1,o||h),b=f/Math.max(1,i||f),S=Math.min(1,nv/h),v=document.createElement("canvas");v.width=Math.max(1,Math.floor(h*S)),v.height=Math.max(1,Math.floor(f*S));const p=v.getContext("2d");if(!p)return null;p.scale(S,S),p.drawImage(u,0,0,h,f);const m=N=>({x:N.x*g,y:N.y*b,width:N.width*g,height:N.height*b}),x=Math.max(2,2.5*g/Math.max(S,.2));p.strokeStyle=a,p.fillStyle=d;const w=N=>{const A=m(N);p.lineWidth=x,p.fillRect(A.x,A.y,A.width,A.height),p.strokeRect(A.x,A.y,A.width,A.height)};for(const N of c.elements)w(N.element.bounds);for(const N of c.regions)w(N.rect);for(const N of c.strokes)N.points.length<2||(p.beginPath(),N.points.forEach((A,k)=>{const C=A.x*g,P=A.y*b;k===0?p.moveTo(C,P):p.lineTo(C,P)}),p.lineCap="round",p.lineJoin="round",p.lineWidth=x*1.4,p.stroke());const j=await new Promise(N=>v.toBlob(N,"image/jpeg",.85));return j?new File([j],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},iv="({ width: window.innerWidth, height: window.innerHeight })",av=async t=>{try{const e=await t.executeJavaScript(iv,!0);if(!e||typeof e!="object")return null;const n=e;return typeof n.width!="number"||typeof n.height!="number"||!Number.isFinite(n.width)||!Number.isFinite(n.height)?null:{width:n.width,height:n.height}}catch{return null}},li=async t=>{try{await t.executeJavaScript(qy,!1)}catch{}},lv=async({host:t,theme:e,labels:n})=>{const r=Yy(e,n),o=await t.executeJavaScript(r,!0);if(o==null)return null;if(!sv(o))return await li(t),null;const i=o;try{const c=await av(t)??i.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:i,screenshot:null};const d=await ov({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:c.width,cssHeight:c.height,payload:i,accentColor:e.primary,accentFill:e.primarySoft});return{payload:i,screenshot:d}}catch{return{payload:i,screenshot:null}}},un={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)"},cv=()=>{if(typeof document>"u"||!document.body)return null;const t=document.createElement("div");return t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;pointer-events:none",document.body.appendChild(t),{read:e=>{t.style.backgroundColor="",t.style.backgroundColor=e;const n=window.getComputedStyle(t).backgroundColor;return n&&n!=="rgba(0, 0, 0, 0)"?n:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},dv=t=>{const e=cv();if(!e)return{...un,colorScheme:t};try{const n=(a,d)=>e.read(`var(${a})`)||d,r=(a,d,u)=>e.read(`color-mix(in srgb, var(${a}) ${d}%, transparent)`)||u,o=e.readVariable("--oc-glass-tooltip-opacity")||"62%",i=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) ${o}, transparent)`)||un.glassSurface,glassFilter:`blur(${i}) saturate(${c})`,primary:n("--primary",un.primary),primarySoft:r("--primary",16,un.primarySoft),primaryFaint:r("--primary",10,un.primaryFaint),primaryContrast:n("--primary-foreground",un.primaryContrast),surface:n("--surface-background",un.surface),surfaceElevated:n("--surface-elevated",un.surfaceElevated),border:n("--border",un.border),text:n("--foreground",un.text),mutedText:n("--muted-foreground",un.mutedText)}}catch{return{...un,colorScheme:t}}finally{e.dispose()}};let Xr=null,Jr=null,ci=null,Do=0,Ni=null;const Zn=new Set,uv=3e4,fv=45e3,Sf=()=>{ci&&(clearTimeout(ci),ci=null)},jf=()=>{if(Jr||Zn.size===0)return;const t=Math.min(1e3*Math.pow(2,Math.min(Do,5)),uv);Jr=setTimeout(()=>{Jr=null,Do+=1,Al()},t)},Po=()=>{Sf(),Xr&&Xr.close(),Xr=null},Hc=()=>{Sf(),Zn.size!==0&&(ci=setTimeout(()=>{Po(),jf()},fv))},mv=t=>{if(!t||t.trim().length===0)return null;try{const e=JSON.parse(t),n=typeof e?.type=="string"?e.type:"",r=e?.properties;return n?{type:n,properties:r}:null}catch{return null}},va=t=>!t||typeof t!="object"?null:t,hv=t=>{if(t.type==="openchamber:event-stream-ready"){Do=0;return}if(t.type==="openchamber:heartbeat")return;if(t.type==="openchamber:session-created"){const d=va(t.properties),u=typeof d?.sessionId=="string"?d.sessionId:"",h=typeof d?.directory=="string"?d.directory:"";if(!u||!h)return;const f={type:"session-created",sessionId:u,directory:h,createdAt:typeof d?.createdAt=="number"?d.createdAt:Date.now(),promptDispatched:d?.promptDispatched===!0,dispatchedAsCommand:d?.dispatchedAsCommand===!0,...typeof d?.projectId=="string"&&d.projectId.length>0?{projectId:d.projectId}:{}};for(const g of Zn)g(f);return}if(t.type==="openchamber:browser-control-request"){const d=va(t.properties),u=typeof d?.requestId=="string"?d.requestId:"",h=typeof d?.action=="string"?d.action:"";if(!u||!h)return;const f=d?.parameters,g={type:"browser-control-request",requestId:u,action:h,parameters:f&&typeof f=="object"&&!Array.isArray(f)?f:{}};for(const b of Zn)b(g);return}if(t.type!=="openchamber:scheduled-task-ran")return;const e=va(t.properties),n=typeof e?.projectId=="string"?e.projectId:"",r=typeof e?.taskId=="string"?e.taskId:"",o=typeof e?.ranAt=="number"?e.ranAt:Date.now(),i=e?.status,c=i==="running"||i==="error"?i:"success";if(!n||!r)return;const a={type:"scheduled-task-ran",projectId:n,taskId:r,ranAt:o,status:c,...typeof e?.sessionId=="string"&&e.sessionId.length>0?{sessionId:e.sessionId}:{}};for(const d of Zn)d(a)},Al=()=>{if(typeof window>"u"||Zn.size===0||typeof EventSource!="function"||Xr&&Xr.readyState!==EventSource.CLOSED)return;Po();const t=typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,e=new EventSource(nu().sse("/api/openchamber/events",t?{browser:"1"}:void 0));e.onopen=()=>{Hc()},e.onmessage=n=>{Hc();const r=mv(n.data);r&&hv(r)},e.onerror=()=>{Po(),jf()},Xr=e},pv=()=>{Ni||typeof window>"u"||(Ni=Mi(()=>{Po(),Do=0,Al()}))},gv=()=>{Ni?.(),Ni=null},Dl=t=>(Zn.add(t),pv(),Al(),()=>{Zn.delete(t),Zn.size===0&&(Jr&&(clearTimeout(Jr),Jr=null),Do=0,Po(),gv())}),xv=2e3,bv=50;let Br=null,Zr=null,wo=null;const yv=async t=>{try{const e=await ms("/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}},Wr=async(t,e)=>{try{const n=await ms("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},vv=async(t=xv)=>{const e=Date.now()+t;for(;!Br&&Date.now()<e;)await new Promise(n=>setTimeout(n,bv));return Br},wv=async t=>{const e=t.action==="browser.open",n=Br;if(!(!n&&!(e&&Zr))&&await yv(t.requestId))try{if(e&&!n){const o=typeof t.parameters.url=="string"?t.parameters.url:"";if(!o){await Wr(t.requestId,{ok:!1,error:"url is required"});return}Zr?.(o);const i=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!i||i==="fill"){await Wr(t.requestId,{ok:!0,data:{url:o,opened:!0}});return}const c=await vv();if(!c){await Wr(t.requestId,{ok:!0,data:{url:o,opened:!0,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const a=await c.run("browser.resize",{viewport:i}),d=a&&typeof a=="object"?a.viewport??null:null;await Wr(t.requestId,{ok:!0,data:{url:o,opened:!0,viewportApplied:!0,viewport:d}});return}const r=await n.run(t.action,t.parameters);await Wr(t.requestId,{ok:!0,data:r})}catch(r){await Wr(t.requestId,{ok:!1,error:r instanceof Error?r.message:String(r)})}},kf=()=>{wo||(wo=Dl(t=>{t.type==="browser-control-request"&&wv({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Cf=()=>{Br||Zr||!wo||(wo(),wo=null)},Sv=t=>(Br=t,kf(),()=>{Br===t&&(Br=null),Cf()}),jv=t=>(Zr=t,kf(),()=>{Zr===t&&(Zr=null),Cf()}),kv=50,Cv=6,Nv=2048,Av=200,Nf=t=>{const e=Qr(String(t??"").trim());if(!e||e.length>Nv)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},Dv=(t,e)=>{const n=Nf(e.url);if(!n)return t;const r=t.find(c=>c.url===n),o=String(e.title??"").trim().slice(0,Av)||r?.title||"";return[{url:n,title:o,lastVisitedAt:e.at},...t.filter(c=>c.url!==n)].slice(0,kv)},Pv=(t,e)=>{const n=Nf(e);return t.filter(r=>r.url!==n)},Ev=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Af=(t,e,n=Cv)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((c,a)=>a.lastVisitedAt-c.lastVisitedAt);if(!r)return o.slice(0,n);const i=r.replace(/^https?:\/\//,"");return o.filter(c=>{const a=Ev(c);return c.url===r||a===i?!1:a.includes(i)}).slice(0,n)},Kc=20,di=t=>{const e=wt((t||"").trim());return e?JSON.stringify([xn(),e]):""},Tv=t=>{const e=Object.keys(t);if(e.length<=Kc)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,Kc);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},eo=xr()(Yu(t=>({byProject:{},recordVisit:(e,n)=>{const r=di(e);r&&t(o=>{const i=o.byProject[r]??[],c=Dv(i,{...n,at:Date.now()});return c===i?o:{byProject:Tv({...o.byProject,[r]:c})}})},forget:(e,n)=>{const r=di(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:Pv(i,n)}}:o})},clear:e=>{const n=di(e);n&&t(r=>{if(!(n in r.byProject))return r;const o={...r.byProject};return delete o[n],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Bm(),partialize:t=>({byProject:t.byProject})})),Iv=[],Df=t=>e=>{const n=di(t);return(n?e.byProject[n]:void 0)??Iv},Ka=new Map,Eo=new Map,Pf=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Ef=t=>{if(!t)return!1;try{const e=new URL(t,typeof window<"u"?window.location.href:void 0),n=typeof window<"u"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"";return n&&e.origin===n?!1:!so(e.toString())}catch{return!1}},Tf=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:0}catch{return 0}},Gc=(t,e)=>{try{const n=new URL(t);return n.protocol="http:",n.hostname="127.0.0.1",n.port=String(e),n.toString()}catch{return t}};class So extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const qc=async t=>{if(!t||!Pf()||!so(t))return t;const e=fr();if(!Ef(e))return t;const n=Tf(t);if(!n)return t;const r=`${e}|${n}`,o=Ka.get(r);if(o){try{Eo.set(o,new URL(t).origin)}catch{}return Gc(t,o)}try{const i=await yo("desktop_dev_tunnel_open",{baseUrl:e,port:n,clientToken:ko(),requestHeaders:ru()});if(!i||!Number.isInteger(i.localPort)||i.localPort<=0)throw new So(t);Ka.set(r,i.localPort);try{Eo.set(i.localPort,new URL(t).origin)}catch{}return Gc(t,i.localPort)}catch(i){throw i instanceof So?i:new So(t)}},Yc=t=>{if(!t||!Pf()||!so(t)||!Ef(fr()))return!1;const e=Tf(t);return e>0&&!Eo.has(e)},po=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!=="127.0.0.1")return t;const n=Eo.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},Rv=()=>{Ka.clear(),Eo.clear()};typeof window<"u"&&Mi(Rv);const Qc=6e3,Mv=120,Ov=80,Fv=`
|
|
595
|
-
var MAX_ELEMENTS = ${Mv};
|
|
596
|
-
var MAX_LABEL_CHARS = ${Ov};
|
|
597
|
-
var visible = function (element) {
|
|
598
|
-
var rect = element.getBoundingClientRect();
|
|
599
|
-
if (rect.width < 1 || rect.height < 1) return false;
|
|
600
|
-
var style = window.getComputedStyle(element);
|
|
601
|
-
return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
|
|
602
|
-
};
|
|
603
|
-
var label = function (element) {
|
|
604
|
-
var aria = element.getAttribute('aria-label');
|
|
605
|
-
if (aria) return aria.trim();
|
|
606
|
-
var value = element.getAttribute('value');
|
|
607
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
608
|
-
if (text) return text.slice(0, MAX_LABEL_CHARS);
|
|
609
|
-
if (value) return String(value).slice(0, MAX_LABEL_CHARS);
|
|
610
|
-
var placeholder = element.getAttribute('placeholder');
|
|
611
|
-
return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
|
|
612
|
-
};
|
|
613
|
-
var isUnique = function (selector) {
|
|
614
|
-
try {
|
|
615
|
-
return document.querySelectorAll(selector).length === 1;
|
|
616
|
-
} catch (error) {
|
|
617
|
-
return false;
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* Names an element by what it is, falling back to where it sits.
|
|
623
|
-
*
|
|
624
|
-
* A positional chain like 'main > section:nth-of-type(3) > div > a' survives
|
|
625
|
-
* only until the markup shifts, and says nothing about what it points at.
|
|
626
|
-
* Anything the page states about identity — an id, a test id, an accessible
|
|
627
|
-
* name — outlives edits and reads as the thing it selects. The chain remains
|
|
628
|
-
* as the last resort, because something always has to work.
|
|
629
|
-
*/
|
|
630
|
-
var cssPath = function (element) {
|
|
631
|
-
var tag = element.tagName.toLowerCase();
|
|
632
|
-
|
|
633
|
-
if (element.id) {
|
|
634
|
-
var byId = '#' + CSS.escape(element.id);
|
|
635
|
-
if (isUnique(byId)) return byId;
|
|
636
|
-
}
|
|
637
|
-
var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
|
|
638
|
-
for (var a = 0; a < stableAttrs.length; a += 1) {
|
|
639
|
-
var value = element.getAttribute(stableAttrs[a]);
|
|
640
|
-
if (!value) continue;
|
|
641
|
-
var raw = String(value);
|
|
642
|
-
// A value containing a quote would need escaping for no real gain: such
|
|
643
|
-
// attributes are rare, and the positional chain still covers them.
|
|
644
|
-
if (raw.indexOf('"') !== -1) continue;
|
|
645
|
-
var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
|
|
646
|
-
if (isUnique(byAttr)) return byAttr;
|
|
647
|
-
}
|
|
648
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
649
|
-
if (className) {
|
|
650
|
-
var classes = className.split(/\\s+/).filter(Boolean);
|
|
651
|
-
for (var c = 0; c < classes.length; c += 1) {
|
|
652
|
-
var byClass = tag + '.' + CSS.escape(classes[c]);
|
|
653
|
-
if (isUnique(byClass)) return byClass;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
var parts = [];
|
|
658
|
-
var node = element;
|
|
659
|
-
var depth = 0;
|
|
660
|
-
while (node && node.nodeType === 1 && depth < 6) {
|
|
661
|
-
var part = node.tagName.toLowerCase();
|
|
662
|
-
var parent = node.parentElement;
|
|
663
|
-
if (!parent) { parts.unshift(part); break; }
|
|
664
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
665
|
-
return child.tagName === node.tagName;
|
|
666
|
-
});
|
|
667
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
668
|
-
parts.unshift(part);
|
|
669
|
-
if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
|
|
670
|
-
node = parent;
|
|
671
|
-
depth += 1;
|
|
672
|
-
}
|
|
673
|
-
return parts.join(' > ');
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
/** What a screen reader would announce, or '' when there is nothing to say. */
|
|
677
|
-
var accessibleName = function (element) {
|
|
678
|
-
var aria = element.getAttribute('aria-label');
|
|
679
|
-
if (aria && aria.trim()) return aria.trim();
|
|
680
|
-
var labelled = element.getAttribute('aria-labelledby');
|
|
681
|
-
if (labelled) {
|
|
682
|
-
var source = document.getElementById(labelled.split(/\\s+/)[0]);
|
|
683
|
-
if (source && (source.innerText || '').trim()) return source.innerText.trim();
|
|
684
|
-
}
|
|
685
|
-
var title = element.getAttribute('title');
|
|
686
|
-
if (title && title.trim()) return title.trim();
|
|
687
|
-
var alt = element.getAttribute('alt');
|
|
688
|
-
if (alt && alt.trim()) return alt.trim();
|
|
689
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
690
|
-
if (text) return text;
|
|
691
|
-
var value = element.getAttribute('value');
|
|
692
|
-
return value && String(value).trim() ? String(value).trim() : '';
|
|
693
|
-
};
|
|
694
|
-
var findByText = function (needle) {
|
|
695
|
-
var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
|
|
696
|
-
var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
|
|
697
|
-
var exact = null;
|
|
698
|
-
var partial = null;
|
|
699
|
-
for (var i = 0; i < candidates.length; i += 1) {
|
|
700
|
-
var element = candidates[i];
|
|
701
|
-
if (!visible(element)) continue;
|
|
702
|
-
var text = label(element).toLowerCase();
|
|
703
|
-
if (!text) continue;
|
|
704
|
-
if (text === wanted) { exact = element; break; }
|
|
705
|
-
if (!partial && text.indexOf(wanted) !== -1) partial = element;
|
|
706
|
-
}
|
|
707
|
-
return exact || partial;
|
|
708
|
-
};
|
|
709
|
-
`,Mo=t=>`(() => {
|
|
710
|
-
${Fv}
|
|
711
|
-
${t}
|
|
712
|
-
})()`,Bv=({selector:t}={})=>Mo(`
|
|
713
|
-
var scopeSelector = ${JSON.stringify(t??"")};
|
|
714
|
-
var root = document;
|
|
715
|
-
if (scopeSelector) {
|
|
716
|
-
try { root = document.querySelector(scopeSelector); }
|
|
717
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
|
|
718
|
-
if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
|
|
719
|
-
}
|
|
720
|
-
var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
|
|
721
|
-
var elements = [];
|
|
722
|
-
var visibleTotal = 0;
|
|
723
|
-
for (var i = 0; i < interactive.length; i += 1) {
|
|
724
|
-
var element = interactive[i];
|
|
725
|
-
if (!visible(element)) continue;
|
|
726
|
-
visibleTotal += 1;
|
|
727
|
-
if (elements.length >= MAX_ELEMENTS) continue;
|
|
728
|
-
|
|
729
|
-
var rect = element.getBoundingClientRect();
|
|
730
|
-
// Empty and default-valued fields are left out rather than serialized as
|
|
731
|
-
// "" and false. Repeated across a hundred entries that overhead dwarfed
|
|
732
|
-
// the information it carried.
|
|
733
|
-
var entry = {
|
|
734
|
-
selector: cssPath(element),
|
|
735
|
-
tag: element.tagName.toLowerCase(),
|
|
736
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
737
|
-
};
|
|
738
|
-
// The list covers the whole document so anything can be clicked without
|
|
739
|
-
// scrolling to it first, which means bounds alone do not say what is on
|
|
740
|
-
// screen — a negative y reads as a bug otherwise.
|
|
741
|
-
if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
|
|
742
|
-
var type = element.getAttribute('type');
|
|
743
|
-
if (type) entry.type = type;
|
|
744
|
-
var role = element.getAttribute('role');
|
|
745
|
-
if (role) entry.role = role;
|
|
746
|
-
var labelText = label(element);
|
|
747
|
-
if (labelText) entry.label = labelText;
|
|
748
|
-
if (element.disabled === true) entry.disabled = true;
|
|
749
|
-
// Flagged rather than described: reporting the accessible name of every
|
|
750
|
-
// element would cost more than it tells, while its absence on something
|
|
751
|
-
// clickable is a defect worth naming.
|
|
752
|
-
if (!accessibleName(element)) entry.missingAccessibleName = true;
|
|
753
|
-
elements.push(entry);
|
|
754
|
-
}
|
|
755
|
-
var body = document.body ? (document.body.innerText || '') : '';
|
|
756
|
-
var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
|
|
757
|
-
var docEl = document.documentElement;
|
|
758
|
-
var result = {
|
|
759
|
-
ok: true,
|
|
760
|
-
url: String(location.href),
|
|
761
|
-
title: String(document.title || ''),
|
|
762
|
-
scope: scopeSelector || 'document',
|
|
763
|
-
scrollY: Math.round(window.scrollY),
|
|
764
|
-
maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
|
|
765
|
-
text: text.slice(0, ${Qc}),
|
|
766
|
-
elements: elements
|
|
767
|
-
};
|
|
768
|
-
// State what was dropped. A capped list that reports only its own length
|
|
769
|
-
// reads as the whole page, and the agent acts as if it had seen everything.
|
|
770
|
-
if (text.length > ${Qc}) {
|
|
771
|
-
result.textTruncated = true;
|
|
772
|
-
result.textTotalChars = text.length;
|
|
773
|
-
}
|
|
774
|
-
if (visibleTotal > elements.length) {
|
|
775
|
-
result.elementsTruncated = true;
|
|
776
|
-
result.interactiveElementsOnPage = visibleTotal;
|
|
777
|
-
}
|
|
778
|
-
return result;
|
|
779
|
-
`),Lv=({selector:t,text:e})=>Mo(`
|
|
780
|
-
var selector = ${JSON.stringify(t??"")};
|
|
781
|
-
var text = ${JSON.stringify(e??"")};
|
|
782
|
-
var target = null;
|
|
783
|
-
if (selector) {
|
|
784
|
-
try { target = document.querySelector(selector); }
|
|
785
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
786
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
787
|
-
} else {
|
|
788
|
-
target = findByText(text);
|
|
789
|
-
if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
|
|
790
|
-
}
|
|
791
|
-
if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
|
|
792
|
-
target.scrollIntoView({ block: 'center', inline: 'center' });
|
|
793
|
-
target.click();
|
|
794
|
-
return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
|
|
795
|
-
`),_v=({selector:t,value:e,submit:n})=>Mo(`
|
|
796
|
-
var selector = ${JSON.stringify(t)};
|
|
797
|
-
var value = ${JSON.stringify(e)};
|
|
798
|
-
var target = null;
|
|
799
|
-
try { target = document.querySelector(selector); }
|
|
800
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
801
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
802
|
-
|
|
803
|
-
var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
804
|
-
if (!editable) return { ok: false, error: selector + ' is not a text field' };
|
|
805
|
-
if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
|
|
806
|
-
|
|
807
|
-
target.scrollIntoView({ block: 'center' });
|
|
808
|
-
target.focus();
|
|
809
|
-
if (target.isContentEditable) {
|
|
810
|
-
target.textContent = value;
|
|
811
|
-
} else {
|
|
812
|
-
// Frameworks track the value through the native setter; assigning the
|
|
813
|
-
// property directly leaves React and friends unaware of the change.
|
|
814
|
-
var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
815
|
-
var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
|
|
816
|
-
if (setter && setter.set) setter.set.call(target, value);
|
|
817
|
-
else target.value = value;
|
|
818
|
-
}
|
|
819
|
-
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
820
|
-
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
821
|
-
|
|
822
|
-
if (${n?"true":"false"}) {
|
|
823
|
-
var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
|
|
824
|
-
target.dispatchEvent(new KeyboardEvent('keydown', enter));
|
|
825
|
-
target.dispatchEvent(new KeyboardEvent('keyup', enter));
|
|
826
|
-
var form = target.form;
|
|
827
|
-
if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
|
|
828
|
-
}
|
|
829
|
-
return { ok: true, selector: cssPath(target), url: String(location.href) };
|
|
830
|
-
`),$v=({selector:t,direction:e})=>Mo(`
|
|
831
|
-
var selector = ${JSON.stringify(t??"")};
|
|
832
|
-
var direction = ${JSON.stringify(e??"")};
|
|
833
|
-
|
|
834
|
-
var settle = function (extra) {
|
|
835
|
-
return new Promise(function (resolve) {
|
|
836
|
-
requestAnimationFrame(function () {
|
|
837
|
-
requestAnimationFrame(function () {
|
|
838
|
-
var doc = document.documentElement;
|
|
839
|
-
var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
840
|
-
var scrollY = Math.round(window.scrollY);
|
|
841
|
-
var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
|
|
842
|
-
result.atTop = scrollY <= 1;
|
|
843
|
-
result.atBottom = scrollY >= maxScrollY - 1;
|
|
844
|
-
for (var key in extra) {
|
|
845
|
-
if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
|
|
846
|
-
}
|
|
847
|
-
resolve(result);
|
|
848
|
-
});
|
|
849
|
-
});
|
|
850
|
-
});
|
|
851
|
-
};
|
|
852
|
-
|
|
853
|
-
if (selector) {
|
|
854
|
-
var target = null;
|
|
855
|
-
try { target = document.querySelector(selector); }
|
|
856
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
857
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
858
|
-
// Instant on purpose: the page's own smooth scrolling would still be
|
|
859
|
-
// animating when the next action runs against it.
|
|
860
|
-
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
861
|
-
return settle({ scrolledTo: cssPath(target) });
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
var doc = document.documentElement;
|
|
865
|
-
var page = Math.round(window.innerHeight * 0.85);
|
|
866
|
-
var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
867
|
-
if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
|
|
868
|
-
else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
|
|
869
|
-
else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
|
|
870
|
-
else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
|
|
871
|
-
else return { ok: false, error: 'Unknown scroll direction: ' + direction };
|
|
872
|
-
return settle({ direction: direction });
|
|
873
|
-
`),zv=["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"],Uv=({selector:t})=>Mo(`
|
|
874
|
-
var selector = ${JSON.stringify(t)};
|
|
875
|
-
var target = null;
|
|
876
|
-
try { target = document.querySelector(selector); }
|
|
877
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
878
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
879
|
-
|
|
880
|
-
var computed = window.getComputedStyle(target);
|
|
881
|
-
var styles = {};
|
|
882
|
-
var props = ${JSON.stringify(zv)};
|
|
883
|
-
for (var i = 0; i < props.length; i += 1) {
|
|
884
|
-
var value = computed.getPropertyValue(props[i]);
|
|
885
|
-
if (value) styles[props[i]] = String(value).trim();
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
var rect = target.getBoundingClientRect();
|
|
889
|
-
return {
|
|
890
|
-
ok: true,
|
|
891
|
-
selector: cssPath(target),
|
|
892
|
-
tag: target.tagName.toLowerCase(),
|
|
893
|
-
label: label(target),
|
|
894
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
895
|
-
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
896
|
-
styles: styles
|
|
897
|
-
};
|
|
898
|
-
`),Wv=t=>{const e=tt.c(18),{entries:n,activeIndex:r,onSelect:o,onForget:i,onHighlight:c}=t,{t:a}=mt();if(n.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]!==n||e[4]!==i||e[5]!==c||e[6]!==o||e[7]!==a){let f;e[9]!==r||e[10]!==i||e[11]!==c||e[12]!==o||e[13]!==a?(f=(g,b)=>s.jsxs("div",{role:"option","aria-selected":b===r,className:ye("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",b===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:S=>{S.preventDefault(),o(g.url)},onPointerEnter:()=>c(b),children:[s.jsx(R,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:g.title||Cl(g.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:g.url})]}),s.jsx("button",{type:"button",className:ye("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:S=>{S.preventDefault(),S.stopPropagation(),i(g.url)},children:s.jsx(R,{name:"close",className:"size-3","aria-hidden":"true"})})]},g.url),e[9]=r,e[10]=i,e[11]=c,e[12]=o,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=i,e[5]=c,e[6]=o,e[7]=a,e[8]=u}else u=e[8];let h;return e[15]!==d||e[16]!==u?(h=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=h):h=e[17],h},fn=t=>{const e=tt.c(17),{icon:n,label:r,onClick:o,disabled:i,pressed:c}=t,a=c?"secondary":"ghost",d=c&&"text-foreground";let u;e[0]!==d?(u=ye("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 h;e[2]!==n?(h=s.jsx(R,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=h):h=e[3];let f;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==c||e[8]!==a||e[9]!==u||e[10]!==h?(f=s.jsx(ut,{asChild:!0,children:s.jsx(nt,{type:"button",variant:a,size:"xs",className:u,onClick:o,disabled:i,"aria-label":r,"aria-pressed":c,children:h})}),e[4]=i,e[5]=r,e[6]=o,e[7]=c,e[8]=a,e[9]=u,e[10]=h,e[11]=f):f=e[11];let g;e[12]!==r?(g=s.jsx(ft,{sideOffset:6,children:r}),e[12]=r,e[13]=g):g=e[13];let b;return e[14]!==f||e[15]!==g?(b=s.jsxs(dt,{children:[f,g]}),e[14]=f,e[15]=g,e[16]=b):b=e[16],b},If=t=>{const e=tt.c(104),{address:n,suggestions:r,onForgetSuggestion:o,onAddressChange:i,onSubmit:c,onBack:a,onForward:d,onReload:u,onOpenExternal:h,canGoBack:f,canGoForward:g,isLoading:b,onAnnotate:S,onOpenDevTools:v,isAnnotating:p,onHardReload:m,onZoomIn:x,onZoomOut:w,onZoomReset:j,zoomPercent:N,onClearCookies:A,onClearCache:k,onToggleDeviceBar:C,isDeviceBarOpen:P}=t;let D;e[0]!==r?(D=r===void 0?[]:r,e[0]=r,e[1]=D):D=e[1];const F=D,B=N===void 0?100:N,{t:E}=mt(),[_,W]=l.useState(!1),[V,K]=l.useState(-1);let y;e[2]!==_||e[3]!==F?(y=_?F:[],e[2]=_,e[3]=F,e[4]=y):y=e[4];const I=y;let $;e[5]===Symbol.for("react.memo_cache_sentinel")?($=()=>{K(-1)},e[5]=$):$=e[5];let z;e[6]!==n||e[7]!==_?(z=[n,_],e[6]=n,e[7]=_,e[8]=z):z=e[8],l.useEffect($,z);let G;e[9]!==c?(G=X=>{W(!1),K(-1),c(X)},e[9]=c,e[10]=G):G=e[10];const J=G;let Z;e[11]!==V||e[12]!==J||e[13]!==I?(Z=X=>{if(I.length!==0){if(X.key==="ArrowDown"||X.key==="ArrowUp"){X.preventDefault();const le=X.key==="ArrowDown"?1:-1,se=I.length;K(T=>{const ie=T+le;return ie<-1?se-1:ie>=se?-1:ie});return}if(X.key==="Escape"&&V>=0){X.preventDefault(),K(-1);return}if(X.key==="Enter"&&V>=0){X.preventDefault();const le=I[V];le&&J(le.url)}}},e[11]=V,e[12]=J,e[13]=I,e[14]=Z):Z=e[14];const re=Z;let ee;e[15]!==E?(ee=E("contextPanel.browser.back"),e[15]=E,e[16]=ee):ee=e[16];const he=!f;let be;e[17]!==a||e[18]!==he||e[19]!==ee?(be=s.jsx(fn,{icon:"arrow-left",label:ee,onClick:a,disabled:he}),e[17]=a,e[18]=he,e[19]=ee,e[20]=be):be=e[20];let Y;e[21]!==E?(Y=E("contextPanel.browser.forward"),e[21]=E,e[22]=Y):Y=e[22];const we=!g;let me;e[23]!==d||e[24]!==Y||e[25]!==we?(me=s.jsx(fn,{icon:"arrow-right",label:Y,onClick:d,disabled:we}),e[23]=d,e[24]=Y,e[25]=we,e[26]=me):me=e[26];let Q;e[27]!==b||e[28]!==E?(Q=E(b?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=b,e[28]=E,e[29]=Q):Q=e[29];let pe;e[30]!==u||e[31]!==Q?(pe=s.jsx(fn,{icon:"refresh",label:Q,onClick:u}),e[30]=u,e[31]=Q,e[32]=pe):pe=e[32];let ve;e[33]!==m||e[34]!==E?(ve=m?s.jsx(fn,{icon:"restart",label:E("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=E,e[35]=ve):ve=e[35];let Te;e[36]!==n||e[37]!==J?(Te=X=>{X.preventDefault(),J(n)},e[36]=n,e[37]=J,e[38]=Te):Te=e[38];let ke;e[39]!==i?(ke=X=>i(X.target.value),e[39]=i,e[40]=ke):ke=e[40];let Ie,Ne;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>W(!0),Ne=()=>W(!1),e[41]=Ie,e[42]=Ne):(Ie=e[41],Ne=e[42]);const Ae=I.length>0;let Se;e[43]===Symbol.for("react.memo_cache_sentinel")?(Se=ye("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=Se):Se=e[43];let Oe;e[44]!==E?(Oe=E("contextPanel.browser.addressAria"),e[44]=E,e[45]=Oe):Oe=e[45];let ne;e[46]!==n||e[47]!==re||e[48]!==ke||e[49]!==Ae||e[50]!==Oe?(ne=s.jsx("input",{value:n,onChange:ke,onFocus:Ie,onBlur:Ne,onKeyDown:re,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Ae,"aria-controls":"openchamber-browser-address-suggestions",className:Se,"aria-label":Oe}),e[46]=n,e[47]=re,e[48]=ke,e[49]=Ae,e[50]=Oe,e[51]=ne):ne=e[51];let ce;e[52]!==o?(ce=X=>o?.(X),e[52]=o,e[53]=ce):ce=e[53];let Re;e[54]!==V||e[55]!==J||e[56]!==ce||e[57]!==I?(Re=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(Wv,{entries:I,activeIndex:V,onSelect:J,onForget:ce,onHighlight:K})}),e[54]=V,e[55]=J,e[56]=ce,e[57]=I,e[58]=Re):Re=e[58];let te;e[59]!==Te||e[60]!==ne||e[61]!==Re?(te=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:Te,children:[ne,Re]}),e[59]=Te,e[60]=ne,e[61]=Re,e[62]=te):te=e[62];let ae;e[63]!==x||e[64]!==w||e[65]!==j||e[66]!==E||e[67]!==B?(ae=w&&x?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(fn,{icon:"subtract",label:E("contextPanel.browser.zoomOut"),onClick:w}),B!==100&&j?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsxs(nt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:j,"aria-label":E("contextPanel.browser.zoomReset"),children:[B,"%"]})}),s.jsx(ft,{sideOffset:6,children:E("contextPanel.browser.zoomReset")})]}):null,s.jsx(fn,{icon:"add",label:E("contextPanel.browser.zoomIn"),onClick:x})]}):null,e[63]=x,e[64]=w,e[65]=j,e[66]=E,e[67]=B,e[68]=ae):ae=e[68];let de;e[69]!==A||e[70]!==E?(de=A?s.jsx(fn,{icon:"delete-bin",label:E("contextPanel.browser.clearCookies"),onClick:A}):null,e[69]=A,e[70]=E,e[71]=de):de=e[71];let H;e[72]!==k||e[73]!==E?(H=k?s.jsx(fn,{icon:"database-2",label:E("contextPanel.browser.clearCache"),onClick:k}):null,e[72]=k,e[73]=E,e[74]=H):H=e[74];let ge;e[75]!==P||e[76]!==C||e[77]!==E?(ge=C?s.jsx(fn,{icon:"smartphone",label:E("contextPanel.browser.deviceToolbar"),onClick:C,pressed:P}):null,e[75]=P,e[76]=C,e[77]=E,e[78]=ge):ge=e[78];let ue;e[79]!==p||e[80]!==S||e[81]!==E?(ue=S?s.jsx(fn,{icon:"cursor",label:E("contextPanel.browser.annotate.toggle"),onClick:S,pressed:p}):null,e[79]=p,e[80]=S,e[81]=E,e[82]=ue):ue=e[82];let M;e[83]!==v||e[84]!==E?(M=v?s.jsx(fn,{icon:"terminal-box",label:E("contextPanel.browser.devTools"),onClick:v}):null,e[83]=v,e[84]=E,e[85]=M):M=e[85];let oe;e[86]!==E?(oe=E("contextPanel.browser.openExternal"),e[86]=E,e[87]=oe):oe=e[87];let De;e[88]!==h||e[89]!==oe?(De=s.jsx(fn,{icon:"external-link",label:oe,onClick:h}),e[88]=h,e[89]=oe,e[90]=De):De=e[90];let fe;return e[91]!==be||e[92]!==me||e[93]!==pe||e[94]!==ve||e[95]!==te||e[96]!==ae||e[97]!==de||e[98]!==H||e[99]!==ge||e[100]!==ue||e[101]!==M||e[102]!==De?(fe=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[be,me,pe,ve,te,ae,de,H,ge,ue,M,De]}),e[91]=be,e[92]=me,e[93]=pe,e[94]=ve,e[95]=te,e[96]=ae,e[97]=de,e[98]=H,e[99]=ge,e[100]=ue,e[101]=M,e[102]=De,e[103]=fe):fe=e[103],fe},Ai={kind:"fill"},Xc=240,Vv=3840,Rf=[{id:"iphone-se",label:"iPhone SE",width:375,height:667},{id:"iphone-14",label:"iPhone 14",width:390,height:844},{id:"iphone-14-pro-max",label:"iPhone 14 Pro Max",width:430,height:932},{id:"pixel-7",label:"Pixel 7",width:412,height:915},{id:"ipad-mini",label:"iPad mini",width:768,height:1024},{id:"ipad-pro",label:"iPad Pro",width:1024,height:1366},{id:"laptop",label:"Laptop",width:1280,height:800},{id:"desktop",label:"Desktop",width:1440,height:900}],Jc=t=>Number.isFinite(t)?Math.round(Math.min(Vv,Math.max(Xc,t))):Xc,Di=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Mf=t=>{const e=Rf.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Hv=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},Kv=(t,e)=>{const n=Di(t);if(!n)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/n.width,o/n.height);return{width:n.width,height:n.height,scale:i}},Gv=["mobile","tablet","desktop","fill"],qv={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Zc=t=>typeof t=="string"&&Gv.includes(t),Ga=t=>t==="fill"?Ai:Mf(qv[t])??Ai,Go=t=>{const e=Di(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=Ga(n),o=Di(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},Yv=t=>{const e=tt.c(70),{viewport:n,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:c}=t,{t:a}=mt();let d;e[0]!==n?(d=Di(n),e[0]=n,e[1]=d):d=e[1];const u=d,h=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==u?(f=(he,be)=>{const Y=Number.parseInt(be,10);if(!Number.isFinite(Y))return;const we=u??{width:1280,height:800};r({kind:"custom",width:Jc(he==="width"?Y:we.width),height:Jc(he==="height"?Y:we.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const g=f;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=ye("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=b):b=e[5];const S=b;let v;e[6]!==r?(v=he=>{const be=Mf(he.target.value);r(be??Ai)},e[6]=r,e[7]=v):v=e[7];let p;e[8]!==a?(p=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=p):p=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=ye("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]=m):m=e[10];let x;e[11]!==a?(x=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=x):x=e[12];let w;e[13]!==x?(w=s.jsx("option",{value:"",children:x}),e[13]=x,e[14]=w):w=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=Rf.map(Qv),e[15]=j):j=e[15];let N;e[16]!==h||e[17]!==v||e[18]!==p||e[19]!==w?(N=s.jsxs("select",{value:h,onChange:v,"aria-label":p,className:m,children:[w,j]}),e[16]=h,e[17]=v,e[18]=p,e[19]=w,e[20]=N):N=e[20];const A=u?String(u.width):"";let k;e[21]!==g?(k=he=>g("width",he.target.value),e[21]=g,e[22]=k):k=e[22];let C;e[23]!==a?(C=a("contextPanel.browser.device.width"),e[23]=a,e[24]=C):C=e[24];let P;e[25]!==A||e[26]!==k||e[27]!==C?(P=s.jsx("input",{value:A,onChange:k,placeholder:"—",inputMode:"numeric","aria-label":C,className:S}),e[25]=A,e[26]=k,e[27]=C,e[28]=P):P=e[28];let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=D):D=e[29];const F=u?String(u.height):"";let B;e[30]!==g?(B=he=>g("height",he.target.value),e[30]=g,e[31]=B):B=e[31];let E;e[32]!==a?(E=a("contextPanel.browser.device.height"),e[32]=a,e[33]=E):E=e[33];let _;e[34]!==F||e[35]!==B||e[36]!==E?(_=s.jsx("input",{value:F,onChange:B,placeholder:"—",inputMode:"numeric","aria-label":E,className:S}),e[34]=F,e[35]=B,e[36]=E,e[37]=_):_=e[37];let W;e[38]!==r||e[39]!==n?(W=()=>r(Hv(n)),e[38]=r,e[39]=n,e[40]=W):W=e[40];const V=!u;let K;e[41]!==a?(K=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=K):K=e[42];let y;e[43]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(R,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=y):y=e[43];let I;e[44]!==W||e[45]!==V||e[46]!==K?(I=s.jsx(ut,{asChild:!0,children:s.jsx(nt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:W,disabled:V,"aria-label":K,children:y})}),e[44]=W,e[45]=V,e[46]=K,e[47]=I):I=e[47];let $;e[48]!==a?($=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=$):$=e[49];let z;e[50]!==$?(z=s.jsx(ft,{sideOffset:6,children:$}),e[50]=$,e[51]=z):z=e[51];let G;e[52]!==I||e[53]!==z?(G=s.jsxs(dt,{children:[I,z]}),e[52]=I,e[53]=z,e[54]=G):G=e[54];let J;e[55]!==c||e[56]!==u?(J=u&&c<1?s.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]=J):J=e[57];let Z;e[58]===Symbol.for("react.memo_cache_sentinel")?(Z=["system","light","dark"],e[58]=Z):Z=e[58];let re;e[59]!==o||e[60]!==i||e[61]!==a?(re=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:Z.map(he=>s.jsx(nt,{type:"button",variant:o===he?"secondary":"ghost",size:"xs",className:ye("shrink-0 rounded-full px-2.5 typography-micro",o===he?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(he),"aria-pressed":o===he,children:a(he==="system"?"contextPanel.browser.device.schemeSystem":he==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},he))}),e[59]=o,e[60]=i,e[61]=a,e[62]=re):re=e[62];let ee;return e[63]!==N||e[64]!==P||e[65]!==_||e[66]!==G||e[67]!==J||e[68]!==re?(ee=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,P,D,_,G,J,re]}),e[63]=N,e[64]=P,e[65]=_,e[66]=G,e[67]=J,e[68]=re,e[69]=ee):ee=e[69],ee};function Qv(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Xv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},Jv=2e3,Zv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=fr();if(!t)return!1;try{return!so(new URL(t,window.location.href).toString())}catch{return!1}},Of=t=>{const e=tt.c(33),{onOpen:n,directory:r}=t,o=r===void 0?"":r,{t:i}=mt();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=Nx(o),[h]=l.useState(Zv);let f,g;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let P=!0,D=null;const F=new AbortController,B=()=>{Vy(F.signal).then(E=>{P&&(d(E),D=setTimeout(B,Jv))})};return B(),()=>{P=!1,D&&clearTimeout(D),F.abort()}},g=[],e[1]=f,e[2]=g):(f=e[1],g=e[2]),l.useEffect(f,g);const b=a.kind==="ready"?a.servers:null;let S;e[3]!==u||e[4]!==b?(S=Gy({announced:u,discovered:b}),e[3]=u,e[4]=b,e[5]=S):S=e[5];const v=S;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(yu,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=p):p=e[6];let m;e[7]!==i?(m=i("contextPanel.browser.empty"),e[7]=i,e[8]=m):m=e[8];let x;e[9]!==m?(x=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=x):x=e[10];let w;e[11]!==i?(w=i("contextPanel.browser.emptyHint"),e[11]=i,e[12]=w):w=e[12];let j;e[13]!==w?(j=s.jsx("span",{className:"typography-micro text-muted-foreground",children:w}),e[13]=w,e[14]=j):j=e[14];let N;e[15]!==j||e[16]!==x?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[x,j]}),e[15]=j,e[16]=x,e[17]=N):N=e[17];let A;e[18]!==u||e[19]!==v||e[20]!==o||e[21]!==n||e[22]!==h||e[23]!==i?(A=v.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?i("contextPanel.browser.devServers.justStarted"):i("contextPanel.browser.devServers.title")}),h?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:v.map(P=>s.jsxs(nt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{jx(o),n(P.url)},children:[s.jsx(R,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:Cl(P.url)||P.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:Xv(P.url)})]},P.port))})]}):null,e[18]=u,e[19]=v,e[20]=o,e[21]=n,e[22]=h,e[23]=i,e[24]=A):A=e[24];let k;e[25]!==v.length||e[26]!==a.kind||e[27]!==i?(k=v.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.unavailable")}):null,e[25]=v.length,e[26]=a.kind,e[27]=i,e[28]=k):k=e[28];let C;return e[29]!==N||e[30]!==A||e[31]!==k?(C=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[p,N,A,k]}),e[29]=N,e[30]=A,e[31]=k,e[32]=C):C=e[32],C},zs=t=>Math.round(t),ew=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),o=t.ancestry.map(a=>a.selectorPart).join(" > "),i=t.computedStyle,c=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,o?`- Ancestry: ${o}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${zs(c.x)}, y=${zs(c.y)}, width=${zs(c.width)}, height=${zs(c.height)}`,`- Styles: display=${i.display??""}; position=${i.position??""}; font=${i.fontWeight??""} ${i.fontSize??""} / ${i.lineHeight??""} ${i.fontFamily??""}; color=${i.color??""}; background=${i.backgroundColor??""}`].filter(a=>typeof a=="string")},tw=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${zs(n.x)}, y=${zs(n.y)}, width=${zs(n.width)}, height=${zs(n.height)}`},sw=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${zs(n.x)}, y=${zs(n.y)}, width=${zs(n.width)}, height=${zs(n.height)}`},nw=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),o=t.comment.trim(),i=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${zs(t.viewport.width)}x${zs(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,o?`Comment: ${o}`:null];for(const[c,a]of t.elements.entries())i.push("",...ew(a.element,c));return t.regions.length>0&&(i.push(""),t.regions.forEach((c,a)=>i.push(tw(c,a)))),t.strokes.length>0&&(i.push(""),t.strokes.forEach((c,a)=>i.push(sw(c,a)))),i.filter(c=>typeof c=="string").join(`
|
|
899
|
-
`)},rw=t=>{const e=tt.c(7),{t:n}=mt(),r=Je(iw),o=Je(aw),i=Ia(lw),c=Th(cw);let a;return e[0]!==c||e[1]!==i||e[2]!==r||e[3]!==t||e[4]!==o||e[5]!==n?(a=async d=>{const u=r??(o?"draft":null);if(!u){Ee.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(d.screenshot)try{await c(d.screenshot),h=!0}catch{h=!1}i({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:nw({payload:d.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Ee.success(n("contextPanel.browser.annotate.attached"))},e[0]=c,e[1]=i,e[2]=r,e[3]=t,e[4]=o,e[5]=n,e[6]=a):a=e[6],a},ow=()=>{const t=tt.c(16),{t:e}=mt();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let o;t[4]!==e?(o=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=i):i=t[7];let c;t[8]!==e?(c=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=c):c=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==o||t[13]!==i||t[14]!==c?(a={select:n,marquee:r,draw:o,commentPlaceholder:i,submit:c},t[10]=n,t[11]=r,t[12]=o,t[13]=i,t[14]=c,t[15]=a):a=t[15],a};function iw(t){return t.currentSessionId}function aw(t){return t.newSessionDraft?.open}function lw(t){return t.addDraft}function cw(t){return t.addAttachedFile}const dw=3e4,uw=3,fw=250,mw={attempts:0,windowStartedAt:null},hw=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=dw,r=n?0:t.attempts;return r>=uw?null:{delayMs:fw*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},pw=-3,qo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",Gr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},gw=(t,{initialUrl:e,onUrlChange:n})=>{const[r,o]=l.useState(e?{kind:"loading",url:e}:Qy),[i,c]=l.useState(e),[a,d]=l.useState(""),[u,h]=l.useState(!1),[f,g]=l.useState(!1),b=l.useRef(n);b.current=n;const S=l.useRef(mw);return l.useEffect(()=>{if(!t)return;const v=()=>{try{const D=t.getURL();return qo(D)?D:""}catch{return""}},p=()=>{try{h(t.canGoBack()),g(t.canGoForward())}catch{}},m=D=>{qo(D)&&(c(D),b.current(D))},x=()=>{const D=v();o({kind:"loading",url:D})},w=()=>{const D=v();let F="";try{F=t.getTitle()||""}catch{F=""}d(F),m(D),p(),o(B=>B.kind==="failed"&&B.url===D?B:{kind:"ready",url:D,title:F})},j=D=>{const F=Gr(D);qo(F.url)&&(m(F.url),p())},N=D=>{const F=Gr(D),B=Array.isArray(F.favicons)?F.favicons.find(Boolean):"",E=v();B&&E&&yf.getState().resolve(E,B)},A=D=>{const F=Gr(D);typeof F.title=="string"&&d(F.title)},k=D=>{const F=Gr(D);if(F.isMainFrame===!1)return;const B=typeof F.errorCode=="number"?F.errorCode:0;B!==pw&&o({kind:"failed",url:qo(F.validatedURL)?F.validatedURL:v(),code:B,description:typeof F.errorDescription=="string"?F.errorDescription:""})};let C=null;const P=()=>{const D=v(),F=hw(S.current,Date.now());if(!F){o({kind:"failed",url:D,code:0,description:"",crashed:!0});return}S.current=F.state,o({kind:"loading",url:D}),C=setTimeout(()=>{C=null;try{t.reload()}catch{o({kind:"failed",url:D,code:0,description:"",crashed:!0})}},F.delayMs)};t.addEventListener("did-start-loading",x),t.addEventListener("did-stop-loading",w),t.addEventListener("did-navigate",j),t.addEventListener("did-navigate-in-page",j),t.addEventListener("page-title-updated",A),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",k),t.addEventListener("render-process-gone",P),t.addEventListener("crashed",P);try{!t.isLoading()&&v()&&w()}catch{}return()=>{C!==null&&clearTimeout(C),t.removeEventListener("render-process-gone",P),t.removeEventListener("crashed",P),t.removeEventListener("did-start-loading",x),t.removeEventListener("did-stop-loading",w),t.removeEventListener("did-navigate",j),t.removeEventListener("did-navigate-in-page",j),t.removeEventListener("page-title-updated",A),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",k)}},[t]),{status:r,url:i,title:a,canGoBack:u,canGoForward:f}},xw=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,bw=4e4,ed=.5,yw=-3,vw=4,ww="persist:openchamber-browser",td=20,Sw=600,jw=2e4,kw=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=mt(),{currentTheme:o}=_r(),i=l.useRef(null),[c,a]=l.useState(null),d=l.useCallback(te=>{i.current=te,a(te)},[]),u=xe(te=>te.setContextPanelTabTargetPath),h=l.useRef(Qr(t)),f=h.current!==pn?h.current:"",[g,b]=l.useState(f?null:pn),[S,v]=l.useState(f),[p,m]=l.useState(!1),[x,w]=l.useState(!1),[j,N]=l.useState(0),[A,k]=l.useState(!1),[C,P]=l.useState(Ai),D=l.useRef(C);D.current=C;const F=l.useRef([]),[B,E]=l.useState("system"),[_,W]=l.useState({width:0,height:0}),V=l.useRef(null),K=l.useRef(null),y=l.useRef(!1),I=l.useRef(Date.now()),$=l.useCallback(te=>{!te||te===pn||!e||!n||u(e,n,te)},[e,n,u]),z=gw(c,{initialUrl:f,onUrlChange:l.useCallback(te=>{const ae=po(te);v(ae),$(ae)},[$])}),[G,J]=l.useState(null),Z=rw(e),re=ow(),ee=z.status.kind==="loading",he=eo(Df(e)),be=eo(te=>te.recordVisit),Y=eo(te=>te.forget);l.useEffect(()=>{z.status.kind==="ready"&&be(e,{url:po(z.status.url),title:z.status.title})},[e,z.status,be]);const we=l.useMemo(()=>Af(he,S),[he,S]),me=l.useCallback(te=>{const ae=Qr(te);ae!==pn&&(v(ae),J(null),qc(ae).then(de=>{const H=i.current;if(!H){b(de);return}try{H.loadURL(de)}catch{b(de)}}).catch(de=>{de instanceof So&&J(ae)}))},[]);l.useEffect(()=>{if(!f)return;let te=!0;return qc(f).then(ae=>{te&&b(ae)}).catch(ae=>{if(te){if(ae instanceof So){J(f),b(pn);return}b(f)}}),()=>{te=!1}},[]);const Q=l.useMemo(()=>({executeJavaScript:async(te,ae)=>{const de=i.current;if(!de)throw new Error("Browser view is not available");return de.executeJavaScript(te,ae)},capturePage:async()=>{const te=i.current;if(!te)return null;const ae=te.getWebContentsId();return Number.isFinite(ae)?await yo("desktop_browser_capture_page",{webContentsId:ae}):null}}),[]),pe=l.useCallback(()=>{if(p){m(!1),li(Q);return}if(!z.url){Ee.error(r("contextPanel.browser.annotate.noPage"));return}const te=dv(o.metadata.variant==="light"?"light":"dark");m(!0),lv({host:Q,theme:te,labels:re}).then(async ae=>{m(!1),ae&&await Z(ae)}).catch(()=>{m(!1),Ee.error(r("contextPanel.browser.annotate.failed"))})},[Q,Z,o,p,z.url,re,r]);l.useEffect(()=>{if(!p)return;const te=ae=>{ae.key==="Escape"&&(ae.preventDefault(),ae.stopImmediatePropagation(),m(!1),li(Q))};return window.addEventListener("keydown",te,!0),()=>window.removeEventListener("keydown",te,!0)},[Q,p]);const ve=l.useCallback(async(te=8e3)=>{const ae=Date.now();for(;;){const de=i.current;if(!de)return!1;let H=!1;try{H=de.isLoading()}catch{return!1}if(!H)return!0;if(Date.now()-ae>te)return!1;await new Promise(ge=>setTimeout(ge,120))}},[]),Te=l.useCallback(async(te,ae)=>{const de=i.current;if(!de)throw new Error("The browser panel is not ready");const H=()=>{Zc(ae.viewport)&&(P(Ga(ae.viewport)),k(!0))};if(te==="browser.back"||te==="browser.forward"){const fe=te==="browser.back";if(!(fe?de.canGoBack():de.canGoForward()))throw new Error(fe?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");fe?de.goBack():de.goForward(),await new Promise(se=>setTimeout(se,150)),await ve();let le="";try{le=de.getTitle()||""}catch{le=""}return{url:po(de.getURL()),title:le}}if(te==="browser.capture"){await ve();const fe=await Q.capturePage();if(!fe)throw new Error("The page could not be captured");let X="";try{X=de.getTitle()||""}catch{X=""}return{...fe,url:po(de.getURL()),title:X,viewport:Go(D.current)}}if(te==="browser.resize"){if(!Zc(ae.viewport))throw new Error("viewport is required");return H(),await new Promise(fe=>setTimeout(fe,200)),await ve(),{viewport:Go(Ga(ae.viewport))}}if(te==="browser.open"){const fe=typeof ae.url=="string"?ae.url:"";if(!fe)throw new Error("url is required");H(),me(fe),await new Promise(se=>setTimeout(se,150));const X=await ve(25e3);let le="";try{le=de.getTitle()||""}catch{le=""}return{url:Qr(fe),title:le,opened:!0,settled:X,viewport:Go(D.current)}}await ve();const ge=fe=>typeof fe=="string"&&fe?fe:void 0,M=(()=>{switch(te){case"browser.snapshot":return Bv({selector:ge(ae.selector)});case"browser.click":return Lv({selector:ge(ae.selector),text:ge(ae.text)});case"browser.type":return _v({selector:String(ae.selector??""),value:String(ae.value??""),submit:ae.submit===!0});case"browser.inspect":return Uv({selector:String(ae.selector??"")});case"browser.scroll":return $v({selector:ge(ae.selector),direction:ge(ae.direction)});default:return null}})();if(!M)throw new Error(`Unsupported browser action: ${te}`);const oe=await de.executeJavaScript(M,!0);if(!oe||typeof oe!="object")throw new Error("The page returned no result");const De=oe;if(De.ok!==!0)throw new Error(typeof De.error=="string"&&De.error?De.error:"Browser action failed");if(te==="browser.snapshot"){const fe=F.current;return{...De,viewport:Go(D.current),...fe.length>0?{consoleProblems:[...fe]}:{}}}return(te==="browser.click"||te==="browser.type"&&ae.submit===!0)&&(await new Promise(fe=>setTimeout(fe,150)),await ve()),oe},[Q,me,ve]);l.useEffect(()=>Sv({run:Te}),[Te]),l.useEffect(()=>{const te=Q;return()=>{li(te)}},[Q]),l.useEffect(()=>{if(!c)return;const te=de=>{const H=de;if(typeof H.level!="number"||H.level<2)return;const ge=H.sourceId?`${H.sourceId}${H.line?`:${H.line}`:""}`:"";F.current.push({level:H.level>=3?"error":"warning",message:String(H.message??"").slice(0,400),source:ge}),F.current.length>td&&F.current.splice(0,F.current.length-td)},ae=()=>{F.current=[]};return c.addEventListener("console-message",te),c.addEventListener("did-start-loading",ae),()=>{c.removeEventListener("console-message",te),c.removeEventListener("did-start-loading",ae)}},[c]);const ke=l.useRef(new Set),Ie=l.useCallback(te=>{ke.current.clear(),me(te)},[me]);l.useEffect(()=>{if(!c)return;const te=de=>{const H=Gr(de),ge=typeof H.url=="string"?H.url:"";!ge||!Yc(ge)||(de.preventDefault(),me(ge))},ae=de=>{const H=Gr(de);if(H.isMainFrame===!1||H.errorCode===-3)return;const ge=typeof H.validatedURL=="string"?H.validatedURL:"";!ge||!Yc(ge)||ke.current.has(ge)||(ke.current.add(ge),me(ge))};return c.addEventListener("will-navigate",te),c.addEventListener("did-fail-load",ae),()=>{c.removeEventListener("will-navigate",te),c.removeEventListener("did-fail-load",ae)}},[me,c]),l.useEffect(()=>{if(!c)return;const te=ae=>{const de=ae.detail;ae.preventDefault(),de?.url&&me(de.url)};return c.addEventListener("new-window",te),()=>c.removeEventListener("new-window",te)},[me,c]);const Ne=l.useCallback(te=>{const ae=Math.min(vw,Math.max(yw,te));N(ae);try{i.current?.setZoomLevel(ae)}catch{}},[]),Ae=l.useCallback(te=>{yo("desktop_browser_clear_data",{partition:ww,cookies:te==="cookies",cache:te==="cache"}).then(()=>{Ee.success(r(te==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{i.current?.reloadIgnoringCache()}catch{}}).catch(()=>Ee.error(r("contextPanel.browser.clearFailed")))},[r]);l.useEffect(()=>{const te=V.current;if(!te||typeof ResizeObserver>"u")return;const ae=new ResizeObserver(de=>{const H=de[0]?.contentRect;H&&W({width:H.width,height:H.height})});return ae.observe(te),()=>ae.disconnect()},[]);const Se=l.useCallback(te=>{E(te);const ae=i.current;if(!ae)return;let de=-1;try{de=ae.getWebContentsId()}catch{return}yo("desktop_browser_set_color_scheme",{webContentsId:de,scheme:te}).catch(H=>{E("system"),Ee.error(H instanceof Error?H.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),Oe=l.useCallback(()=>{try{ee?i.current?.stop():i.current?.reload()}catch{}},[ee]),ne=z.status;l.useEffect(()=>{const te=()=>{w(!0);const H=setTimeout(()=>{try{i.current?.reload()}catch{}},Sw);return()=>clearTimeout(H)};if(ne.kind==="failed"){if(!Uy(ne.code,ne.url)){w(!1);return}const H=Date.now(),ge=K.current?.url===ne.url?K.current:{url:ne.url,startedAt:H};if(K.current=ge,H-ge.startedAt>bw){w(!1);return}return te()}if(ne.kind==="loading")return;if(K.current=null,ne.kind!=="ready"||!ne.url||!so(ne.url)){y.current=!0,w(!1);return}if(y.current||Date.now()-I.current>jw){y.current=!0,w(!1);return}let ae=!1,de=null;return Hy(po(ne.url)).then(H=>{if(!ae){if(H===null||H<500){y.current=!0,w(!1);return}de=te()}}),()=>{ae=!0,de?.()}},[ne]);const ce=z.status.kind==="failed"&&!x?z.status:null,Re=Kv(C,_);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(If,{address:S,onAddressChange:v,onSubmit:Ie,suggestions:we,onForgetSuggestion:te=>Y(e,te),onBack:()=>{try{i.current?.goBack()}catch{}},onForward:()=>{try{i.current?.goForward()}catch{}},onReload:Oe,onOpenExternal:()=>{Oi(z.url||S)},canGoBack:z.canGoBack,canGoForward:z.canGoForward,isLoading:ee,onAnnotate:pe,isAnnotating:p,onOpenDevTools:()=>{try{i.current?.openDevTools()}catch{}},onHardReload:()=>{try{i.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ne(j+ed),onZoomOut:()=>Ne(j-ed),onZoomReset:()=>Ne(0),zoomPercent:Math.round(Math.pow(1.2,j)*100),onClearCookies:()=>Ae("cookies"),onClearCache:()=>Ae("cache"),onToggleDeviceBar:()=>k(te=>!te),isDeviceBarOpen:A}),A?s.jsx(Yv,{viewport:C,onViewportChange:P,colorScheme:B,onColorSchemeChange:Se,scale:Re?.scale??1}):null,s.jsxs("div",{ref:V,className:ye("relative min-h-0 flex-1 bg-background",Re&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null?s.jsx("webview",{ref:d,src:g,partition:"persist:openchamber-browser",allowpopups:!0,style:Re?{width:`${Re.width}px`,height:`${Re.height}px`,transform:`scale(${Re.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!f&&!z.url&&!ee?s.jsx(Of,{onOpen:Ie,directory:e}):null,x?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,G?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:G})})]}):null,ce&&!G?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:ce.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ce.crashed?r("contextPanel.browser.crashedHint"):ce.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ee?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},Cw=t=>{const e=tt.c(49),{initialUrl:n,directory:r,tabID:o}=t,{t:i}=mt(),c=xe(Aw);let a;e[0]!==n?(a=Qr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==pn?d:"",[h,f]=l.useState(u),[g,b]=l.useState(u);let S;e[2]!==u?(S=u?[u]:[],e[2]=u,e[3]=S):S=e[3];const[v,p]=l.useState(S),[m,x]=l.useState(u?0:-1),[w,j]=l.useReducer(Dw,0);let N;e[4]!==r||e[5]!==c||e[6]!==o?(N=ee=>{!ee||ee===pn||!r||!o||c(r,o,ee)},e[4]=r,e[5]=c,e[6]=o,e[7]=N):N=e[7];const A=N;let k;e[8]!==r?(k=Df(r),e[8]=r,e[9]=k):k=e[9];const C=eo(k),P=eo(Pw),D=eo(Ew);let F;e[10]!==h||e[11]!==C?(F=Af(C,h),e[10]=h,e[11]=C,e[12]=F):F=e[12];const B=F;let E;e[13]!==r||e[14]!==m||e[15]!==A||e[16]!==P?(E=ee=>{const he=Qr(ee);he!==pn&&(f(he),b(he),A(he),P(r,{url:he}),p(be=>{const Y=m>=0?be.slice(0,m+1):[];return Y[Y.length-1]===he?(x(Y.length-1),Y):(x(Y.length),[...Y,he])}))},e[13]=r,e[14]=m,e[15]=A,e[16]=P,e[17]=E):E=e[17];const _=E;let W;e[18]!==v||e[19]!==A?(W=ee=>{const he=v[ee];he&&(x(ee),f(he),b(he),A(he))},e[18]=v,e[19]=A,e[20]=W):W=e[20];const V=W;let K;e[21]!==r||e[22]!==D?(K=ee=>D(r,ee),e[21]=r,e[22]=D,e[23]=K):K=e[23];let y,I;e[24]!==V||e[25]!==m?(I=()=>V(m-1),y=()=>V(m+1),e[24]=V,e[25]=m,e[26]=y,e[27]=I):(y=e[26],I=e[27]);let $;e[28]!==h||e[29]!==g?($=()=>{Oi(g||h)},e[28]=h,e[29]=g,e[30]=$):$=e[30];const z=m>0,G=m>=0&&m<v.length-1;let J;e[31]!==h||e[32]!==_||e[33]!==B||e[34]!==y||e[35]!==$||e[36]!==z||e[37]!==G||e[38]!==K||e[39]!==I?(J=s.jsx(If,{address:h,onAddressChange:f,onSubmit:_,suggestions:B,onForgetSuggestion:K,onBack:I,onForward:y,onReload:j,onOpenExternal:$,canGoBack:z,canGoForward:G,isLoading:!1}),e[31]=h,e[32]=_,e[33]=B,e[34]=y,e[35]=$,e[36]=z,e[37]=G,e[38]=K,e[39]=I,e[40]=J):J=e[40];let Z;e[41]!==g||e[42]!==_||e[43]!==w||e[44]!==i?(Z=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:g?s.jsx("iframe",{src:g,title:i("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${w}`):s.jsx(Of,{onOpen:_})}),e[41]=g,e[42]=_,e[43]=w,e[44]=i,e[45]=Z):Z=e[45];let re;return e[46]!==J||e[47]!==Z?(re=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[J,Z]}),e[46]=J,e[47]=Z,e[48]=re):re=e[48],re},Nw=t=>{const e=tt.c(3),[n]=l.useState(xw);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(kw,{...t}):s.jsx(Cw,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Aw(t){return t.setContextPanelTabTargetPath}function Dw(t){return t+1}function Pw(t){return t.recordVisit}function Ew(t){return t.forget}const Tw=Zs(()=>Js(()=>import("./WalkthroughView-5DyvN03T.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])).then(t=>({default:t.WalkthroughView}))),Iw=Zs(()=>Js(()=>import("./DiffView-DZIoOnV7.js"),__vite__mapDeps([121,1,2,4,5,6,7,8,3,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])).then(t=>({default:t.DiffView}))),Rw=Zs(()=>Js(()=>import("./FilesView-BKL6YlKG.js"),__vite__mapDeps([122,1,2,4,5,6,7,8,3,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,113,123,124,125,126,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,127,128,114,115,129,130,112,131,118])).then(t=>({default:t.FilesView}))),Mw=Zs(()=>Js(()=>import("./GitView-DBFrDDBv.js"),__vite__mapDeps([132,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,113,133,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,114,115,117,118,119,120])).then(t=>({default:t.GitView}))),Ow=Zs(()=>Js(()=>import("./PlanView-ZYEJn8A_.js"),__vite__mapDeps([134,1,2,4,5,6,7,8,123,50,51,52,53,54,55,72,48,49,56,124,125,3,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,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,73,74,75,76,77,78,79,80,112,113,131,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(t=>({default:t.PlanView}))),Fw=380,Bw=1400,Ff=600,Lw=100,_w=24,Pi=new Map,$w=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},sd=t=>Number.isFinite(t)?Math.min(Bw,Math.max(Fw,Math.round(t))):Ff,zw=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Uw=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Bf=(t,e)=>e(t==="chat"?"contextPanel.mode.chat":t==="file"?"contextPanel.mode.files":t==="diff"?"contextPanel.mode.diff":t==="walkthrough"?"contextPanel.mode.walkthrough":t==="plan"?"contextPanel.mode.plan":t==="browser"?"contextPanel.mode.browser":t==="git"?"layout.rightSidebar.git":t==="pr"?"contextPanel.mode.pr":t==="notes"?"contextRail.surface.notes":t==="terminal"?"layout.mainTab.terminal":"contextPanel.mode.context"),Ww=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},Vw=(t,e,n)=>{if(t.mode==="chat"){const r=qa(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||n("contextPanel.mode.chat")}return t.mode==="browser"?Cl(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Ww(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Bf(t.mode,n)},nd=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(cl,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(Ju,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(R,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(R,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(R,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(R,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(R,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(R,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(R,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="browser"){const n=Hw(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(R,{name:"global",className:"h-3.5 w-3.5"})}},Hw=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Kw=200,Gw=480,qw=({visible:t})=>{const{t:e}=mt(),n=xe(m=>m.contextEditorTreeWidth),r=xe(m=>m.setContextEditorTreeWidth),[o,i]=l.useState(!1),c=l.useRef(0),a=l.useRef(n),d=l.useRef(null),u=l.useRef(null),h=l.useRef(null),f=l.useCallback(m=>Math.min(Gw,Math.max(Kw,Math.round(m))),[]),g=l.useCallback(m=>{const x=h.current;x&&(x.style.width=`${m}px`,x.style.setProperty("--oc-editor-tree-width",`${m}px`))},[]),b=m=>{if(t){try{m.currentTarget.setPointerCapture(m.pointerId)}catch{}u.current=m.pointerId,i(!0),c.current=m.clientX,a.current=n,d.current=n,m.preventDefault()}},S=m=>{if(!o||u.current!==m.pointerId)return;const x=c.current-m.clientX,w=f(a.current+x);d.current!==w&&(d.current=w,g(w))},v=m=>{if(u.current!==m.pointerId)return;try{m.currentTarget.releasePointerCapture(m.pointerId)}catch{}const x=f(d.current??n);u.current=null,d.current=null,i(!1),r(x)},p=t?n:0;return s.jsxs("div",{ref:h,className:ye("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${o?d.current??p:p}px`,"--oc-editor-tree-width":`${o?d.current??n:n}px`,overflowX:"clip",transitionProperty:o?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&s.jsx("div",{className:ye("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",o&&"bg-[var(--interactive-border)]"),onPointerDown:b,onPointerMove:S,onPointerUp:v,onPointerCancel:v,role:"separator","aria-orientation":"vertical","aria-label":e("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:ye("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",o&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:s.jsx(dy,{})})]})},qa=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Yw=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},Qw=(t,e)=>{if(e.length===0)return Pi;const n=new Set(e),r=new Map;for(const o of t){if(!n.has(o.id))continue;const i=o.title?.trim();i&&r.set(o.id,i)}return r.size===0?Pi:r},Xw=(t,e)=>{const n=ol(t),r=l.useRef(Pi),o=l.useRef(e);return o.current=e,l.useSyncExternalStore(n.subscribe,l.useCallback(()=>{const i=Qw(n.getState().session,o.current);return Yw(r.current,i)?r.current:(r.current=i,i)},[n]),()=>Pi)},Jw=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,Zw=()=>{const{t}=mt(),e=Io()??"",n=l.useMemo(()=>$w(e),[e]),r=xe(U=>n?U.contextPanelByDirectory[n]:void 0),o=xe(U=>U.closeContextPanel),i=xe(U=>U.closeContextPanelTab),c=xe(U=>U.openContextPanelTab),a=xe(U=>U.toggleContextPanelExpanded),d=xe(U=>U.setContextPanelWidth),u=xe(U=>U.setActiveContextPanelTab),h=xe(U=>U.openContextBrowser);l.useEffect(()=>{if(e)return jv(U=>h(e,U))},[e,h]);const f=xe(U=>U.reorderContextPanelTabs),g=Bn(U=>U.setSelectedPath),b=xe(U=>U.contextEditorTreeVisible),S=xe(U=>U.toggleContextEditorTree),v=xe(U=>U.openNewContextBrowserTab),p=yf(U=>U.byOrigin),m=xe(U=>U.allowPromptingSubagentSessions),{themeMode:x,setThemeMode:w,lightThemeId:j,darkThemeId:N,currentTheme:A}=_r(),k=l.useMemo(()=>r?.tabs??[],[r?.tabs]),C=k.find(U=>U.id===r?.activeTabId)??k[k.length-1]??null,P=!!(r?.isOpen&&C),D=!!(P&&r?.expanded),[F,B]=l.useState(null),E=C?.mode??null,_=E?r?.widthByMode?.[E]:void 0,W=E?Ih(E):.5,V=F??(typeof window<"u"?window.innerWidth:Ff*2),K=sd(_??Math.round(W*V)),y=l.useMemo(()=>{const U=[];for(const Be of k){if(Be.mode!=="chat")continue;const Fe=qa(Be.dedupeKey);Fe&&!U.includes(Fe)&&U.push(Fe)}return U},[k]),I=Xw(n||void 0,y),[$,z]=l.useState(!1),G=l.useRef(0),J=l.useRef(K),Z=l.useRef(null),re=l.useRef(null),ee=l.useRef(null),he=l.useRef(new Map),be=l.useRef(new Map),Y=l.useRef(!1);l.useLayoutEffect(()=>{const U=ee.current?.parentElement;if(!U||typeof ResizeObserver>"u")return;const Be=new ResizeObserver(()=>{B(U.clientWidth||null)});return Be.observe(U),B(U.clientWidth||null),()=>Be.disconnect()},[]),l.useEffect(()=>{if(!P||Y.current){Y.current=P;return}const U=window.requestAnimationFrame(()=>{ee.current?.focus({preventScroll:!0})});return Y.current=!0,()=>window.cancelAnimationFrame(U)},[P]);const we=l.useRef(null),me=l.useRef(null),Q=l.useCallback(()=>{me.current=null;const U=ee.current,Be=Z.current;!U||Be===null||U.style.setProperty("--oc-context-panel-width",`${Be}px`)},[]);l.useEffect(()=>()=>{me.current!==null&&clearTimeout(me.current)},[]);const pe=l.useCallback(U=>{const Be=sd(U),Fe=we.current;return Fe===null?Be:Math.min(Be,Math.max(1,Fe))},[]),ve=l.useCallback(U=>{!P||D||!n||(re.current=U.pointerId,z(!0),G.current=U.clientX,J.current=K,Z.current=K,we.current=zw(ee.current),document.documentElement.style.cursor="col-resize",U.preventDefault())},[n,D,P,K]),Te=l.useCallback(()=>{const U=pe(Z.current??K);Z.current=null,we.current=null,me.current!==null&&(clearTimeout(me.current),me.current=null),document.documentElement.style.cursor="",n&&E&&d(n,E,U),z(!1),re.current=null},[E,pe,n,d,K]);l.useEffect(()=>{if(!$)return;const U=Ye=>{if(re.current!==Ye.pointerId)return;const at=G.current-Ye.clientX,st=pe(J.current+at);Z.current!==st&&(Z.current=st,me.current===null&&(me.current=setTimeout(Q,Lw)))},Be=Ye=>{re.current===Ye.pointerId&&Te()},Fe=()=>{Te()};return window.addEventListener("pointermove",U),window.addEventListener("pointerup",Be),window.addEventListener("pointercancel",Be),window.addEventListener("blur",Fe),()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",Be),window.removeEventListener("pointercancel",Be),window.removeEventListener("blur",Fe)}},[Q,pe,Te,$]),l.useEffect(()=>{$||(Z.current=null,document.documentElement.style.cursor="")},[$]);const ke=l.useCallback(()=>{n&&o(n)},[o,n]),Ie=l.useCallback(()=>{n&&a(n)},[n,a]),Ne=l.useCallback(U=>{U.key==="Escape"&&(Rh(U.target)||(U.preventDefault(),U.stopPropagation(),ke()))},[ke]);l.useEffect(()=>{if(!(!n||!C)&&C.mode==="file"&&C.targetPath){g(n,C.targetPath,{allowOutsideRoot:!0});return}},[C,n,g]);const Ae=l.useMemo(()=>k.filter(U=>U.mode==="chat"),[k]),Se=P&&C?.mode==="chat"?C.id:null,Oe=P&&C?.mode==="chat"?qa(C.dedupeKey):null,ne=qg(Ae,Se);l.useEffect(()=>{if(!P||!n||!Oe||typeof window>"u")return;const U=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ia(n,Oe,!1);return}vu(Oe),ia(n,Oe,!0)};U();const Be=window.setInterval(U,1e4);return window.addEventListener("focus",U),window.addEventListener("blur",U),document.addEventListener("visibilitychange",U),()=>{window.clearInterval(Be),window.removeEventListener("focus",U),window.removeEventListener("blur",U),document.removeEventListener("visibilitychange",U),ia(n,Oe,!1)}},[Oe,n,P]);const ce=l.useCallback((U,Be,Fe)=>Yg(be.current,U,Be,n||null,Fe,{mode:x,lightThemeId:j,darkThemeId:N,currentTheme:A},{allowPromptingSubagentSessions:m}),[m,A,N,n,j,x]),Re=ne&&Oe?ce(ne.id,Oe,ne.readOnly):null;l.useEffect(()=>{const U=new Set(k.map(Be=>Be.id));for(const Be of be.current.keys())U.has(Be)||be.current.delete(Be)},[k]);const te=l.useCallback(U=>{!n||C?.mode!=="diff"||c(n,{mode:"diff",targetPath:C.targetPath,stagedDiff:U==="staged",diffScope:U})},[C,n,c]),ae=l.useCallback(()=>{if(typeof window>"u")return;const U={themeMode:x,lightThemeId:j,darkThemeId:N,currentTheme:A};for(const Be of he.current.values()){const Fe=Be.contentWindow;Fe&&Fe.postMessage({type:"openchamber:theme-sync",payload:U},window.location.origin)}},[A,N,j,x]),de=l.useCallback(()=>{if(typeof window>"u")return;const U={allowPromptingSubagentSessions:m};for(const Be of he.current.values()){const Fe=Be.contentWindow;Fe&&Fe.postMessage({type:"openchamber:chat-settings-sync",payload:U},window.location.origin)}},[m]),H=l.useCallback(()=>{if(!(typeof window>"u"))for(const[U,Be]of he.current.entries()){const Fe=Be.contentWindow;if(!Fe)continue;const Ye={visible:Se===U};Fe.postMessage({type:"openchamber:embedded-visibility",payload:Ye},window.location.origin)}},[Se]);l.useEffect(()=>{if(typeof window>"u")return;const U=Be=>{if(Be.origin!==window.location.origin||!Array.from(he.current.values()).some(bt=>bt.contentWindow===Be.source))return;const Ye=Be.data;if(Ye?.type===Qg){if(typeof Ye.requestId!="string"||!Ye.requestId)return;const bt=xn(),rt={apiBaseUrl:fr(),clientToken:ko(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:ru(),relayHostId:bt.startsWith("host:")?bt.slice(5):"",relay:Lm()??void 0};Be.source?.postMessage({type:Xg,requestId:Ye.requestId,payload:rt},Be.origin);return}if(Ye?.type==="openchamber:theme-sync-request"){ae();return}if(Ye?.type==="openchamber:chat-settings-request"){de();return}if(Ye?.type!=="openchamber:cycle-theme-request")return;const at=["light","dark","system"],ct=(at.indexOf(x)+1)%at.length;w(at[ct])};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[de,ae,w,x]),l.useLayoutEffect(()=>{k.some(Be=>Be.mode==="chat")&&(ae(),de(),H())},[N,j,de,H,ae,k,x]);const ge=C?.mode==="file"||C?.mode==="chat"||C?.mode==="browser",ue=l.useMemo(()=>C?k.filter(U=>U.mode===C.mode):[],[C,k]),M=l.useMemo(()=>ue.map(U=>{const Be=Vw(U,I,t),Fe=Jw(Be,_w),Ye=Uw(U.targetPath,e);return{id:U.id,label:Fe,icon:nd(U,p),title:Ye?`${Be}: ${Ye}`:Be,closeLabel:t("contextPanel.tab.closeTabAria",{label:Fe})}}),[ue,e,p,I,t]),oe=C?.mode==="context"?s.jsx(Dy,{}):C?.mode==="git"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Mw,{isActive:P})}):C?.mode==="pr"?s.jsx(_b,{}):C?.mode==="notes"?s.jsx(Wu,{}):C?.mode==="plan"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Ow,{targetPath:C.targetPath})}):null,De=l.useMemo(()=>k.filter(U=>U.mode==="browser"),[k]),fe=l.useMemo(()=>k.filter(U=>U.mode==="diff"),[k]),X=l.useMemo(()=>k.some(U=>U.mode==="terminal"),[k]),le=l.useMemo(()=>k.some(U=>U.mode==="walkthrough"),[k]),se=l.useMemo(()=>k.some(U=>U.mode==="file"),[k]),T=l.useMemo(()=>k.some(U=>U.mode==="file"&&U.targetPath),[k]),ie=C?.mode==="file",je=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ge?s.jsx(gl,{items:M,activeId:C?.id??null,onSelect:U=>{n&&u(n,U)},onClose:U=>{n&&i(n,U)},onReorder:(U,Be)=>{n&&f(n,U,Be)},layoutMode:"scrollable",variant:"default"}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[C?nd(C,p):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:C?Bf(C.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[C?.mode==="browser"?s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&v(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(R,{name:"add",className:"h-3.5 w-3.5"})}):null,ie?s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:S,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(R,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:Ie,className:"h-7 w-7 p-0",title:t(D?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(D?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:D?s.jsx(R,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:ke,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Pe=P?D?{"--oc-context-panel-width":F!==null?`${F}px`:"100%",width:F!==null?`${F}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${K}px`}:{"--oc-context-panel-width":`${K}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:ee,"data-context-panel":"true",tabIndex:-1,inert:!P||void 0,className:ye("flex min-h-0 flex-col overflow-hidden bg-background",D?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!P&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:Ne,style:Pe,children:[P&&!D&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),P&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!D&&s.jsx("div",{className:ye("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",$&&"bg-[var(--interactive-border)]"),onPointerDown:ve,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:ye("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!P&&"pointer-events-none select-none opacity-0"),style:{width:D?F!==null?`${F}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!P,children:[je,s.jsxs("div",{className:ye("relative min-h-0 flex-1 overflow-hidden",$&&"pointer-events-none"),children:[se?s.jsxs("div",{className:ye("absolute inset-0 flex",ie?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:T?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Rw,{mode:"editor-only"})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(R,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}),s.jsx(qw,{visible:b})]}):null,ne&&Oe&&Re?s.jsx("iframe",{ref:U=>{if(!U){he.current.delete(ne.id);return}he.current.set(ne.id,U)},src:Re,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:Oe}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{ae(),de(),H()}},ne.id):null,De.map(U=>s.jsx("div",{className:ye("absolute inset-0",C?.id!==U.id&&"hidden"),children:s.jsx(Nw,{initialUrl:U.targetPath??"",directory:n,tabID:U.id})},U.id)),fe.map(U=>s.jsx("div",{className:ye("absolute inset-0",C?.id!==U.id&&"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(Iw,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:U.diffScope??(U.stagedDiff?"staged":"working"),onDiffScopeChange:te,targetFilePath:U.targetPath,flushContent:!0})})},U.id)),X?s.jsx("div",{className:ye("absolute inset-0",C?.mode==="terminal"?"block":"hidden"),children:s.jsx(Vu,{visible:P&&C?.mode==="terminal"})}):null,le?s.jsx("div",{className:ye("absolute inset-0",C?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(Tw,{directory:e})})}):null,C?.mode!=="chat"&&!ie&&C?.mode!=="browser"&&C?.mode!=="diff"&&C?.mode!=="terminal"&&C?.mode!=="walkthrough"?oe:null]})]})]})},e1=150,t1=500,s1=[],n1=t=>t>99?"99+":String(t),r1=t=>{const e=tt.c(51),{surface:n,isActive:r,showActivityDot:o,label:i,description:c,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:h,showOrderNumber:f,onSelect:g}=t;let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:S,listeners:v,setNodeRef:p,transform:m,transition:x,isDragging:w}=bl(b);let j;e[2]!==a?(j=a!=null&&a>0?n1(a):null,e[2]=a,e[3]=j):j=e[3];const N=j;let A;e[4]!==m?(A=yl.Translate.toString(m),e[4]=m,e[5]=A):A=e[5];let k;e[6]!==A||e[7]!==x?(k={transform:A,transition:x},e[6]=A,e[7]=x,e[8]=k):k=e[8];const C=w&&"z-10 opacity-70";let P;e[9]!==C?(P=ye("relative",C),e[9]=C,e[10]=P):P=e[10];let D;e[11]!==g||e[12]!==n?(D=()=>g(n),e[11]=g,e[12]=n,e[13]=D):D=e[13];const F=d??i,B=r?"text-primary":"text-muted-foreground hover:text-foreground";let E;e[14]!==B?(E=ye("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",B),e[14]=B,e[15]=E):E=e[15];let _;e[16]!==n.icon||e[17]!==n.id?(_=n.id==="diff"?s.jsx(Ju,{}):s.jsx(R,{name:n.icon,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.id,e[18]=_):_=e[18];let W;e[19]!==N||e[20]!==h||e[21]!==o||e[22]!==f?(W=f&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):N?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:N}):o?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[19]=N,e[20]=h,e[21]=o,e[22]=f,e[23]=W):W=e[23];let V;e[24]!==S||e[25]!==r||e[26]!==v||e[27]!==E||e[28]!==_||e[29]!==W||e[30]!==D||e[31]!==F?(V=s.jsx(ut,{asChild:!0,children:s.jsxs("button",{type:"button",...S,...v,onClick:D,"aria-label":F,"aria-pressed":r,className:E,children:[_,W]})}),e[24]=S,e[25]=r,e[26]=v,e[27]=E,e[28]=_,e[29]=W,e[30]=D,e[31]=F,e[32]=V):V=e[32];let K;e[33]!==i?(K=s.jsx("span",{children:i}),e[33]=i,e[34]=K):K=e[34];let y;e[35]!==c?(y=s.jsx("span",{className:"typography-micro text-muted-foreground",children:c}),e[35]=c,e[36]=y):y=e[36];let I;e[37]!==u?(I=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[37]=u,e[38]=I):I=e[38];let $;e[39]!==K||e[40]!==y||e[41]!==I?($=s.jsx(ft,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[K,y,I]})}),e[39]=K,e[40]=y,e[41]=I,e[42]=$):$=e[42];let z;e[43]!==V||e[44]!==$?(z=s.jsxs(dt,{delayDuration:e1,children:[V,$]}),e[43]=V,e[44]=$,e[45]=z):z=e[45];let G;return e[46]!==p||e[47]!==z||e[48]!==k||e[49]!==P?(G=s.jsx("div",{ref:p,style:k,className:P,children:z}),e[46]=p,e[47]=z,e[48]=k,e[49]=P,e[50]=G):G=e[50],G},o1=()=>{const t=tt.c(52),{t:e}=mt(),n=Io();let r;t[0]!==n?(r=n?Vr(n):"",t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=J=>o?J.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const c=xe(i),a=xe(i1),d=xe(a1),u=xe(l1),h=xe(c1),f=xe(d1),g=il(u1),{screenWidth:b}=pr(),S=al(o||null);let v;t[4]!==f?(v=Mh("switch_context_surface",f),t[4]=f,t[5]=v):v=t[5];const p=v,[m,x]=l.useState(!1);let w,j;t[6]!==p?(w=()=>{const J=new Set;let Z=null,re=!1;const ee=f1,he=()=>{ec(p,J)?!re&&Z===null&&(Z=setTimeout(()=>x(!0),t1)):(re=!1,Z!==null&&(clearTimeout(Z),Z=null),x(!1))},be=me=>{if(J.add(me.key.toLowerCase()),ee(me.key)&&ec(p,J)){re=!0,Z!==null&&(clearTimeout(Z),Z=null),x(!1);return}he()},Y=me=>{J.delete(me.key.toLowerCase()),he()},we=()=>{J.clear(),re=!1,Z!==null&&(clearTimeout(Z),Z=null),x(!1)};return window.addEventListener("keydown",be,!0),window.addEventListener("keyup",Y,!0),window.addEventListener("blur",we),()=>{window.removeEventListener("keydown",be,!0),window.removeEventListener("keyup",Y,!0),window.removeEventListener("blur",we),Z!==null&&clearTimeout(Z)}},j=[p],t[6]=p,t[7]=w,t[8]=j):(w=t[7],j=t[8]),l.useEffect(w,j);let N;t[9]===Symbol.for("react.memo_cache_sentinel")?(N={activationConstraint:{distance:8}},t[9]=N):N=t[9];let A;t[10]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{delay:200,tolerance:6}},t[10]=A):A=t[10];const k=wi(Yr(ex,N),Yr(Zg,A)),C=c?.tabs??s1;let P;t[11]!==c?.activeTabId||t[12]!==C?(P=C.find(J=>J.id===c?.activeTabId)??null,t[11]=c?.activeTabId,t[12]=C,t[13]=P):P=t[13];const D=P,F=c?.isOpen?D?.mode??null:null,B=S?.files.length??0;let E;t[14]!==d||t[15]!==g||t[16]!==b||t[17]!==C?(E=Oh({railOrder:d,planModeEnabled:g,isVSCode:er(),screenWidth:b,tabs:C}),t[14]=d,t[15]=g,t[16]=b,t[17]=C,t[18]=E):E=t[18];const _=E;let W;t[19]!==u?(W=J=>{const{active:Z,over:re}=J;if(!re||Z.id===re.id)return;const ee=Fh(xe.getState().contextRailOrder).map(m1),he=ee.indexOf(Z.id),be=ee.indexOf(re.id);he===-1||be===-1||u(Qu(ee,he,be))},t[19]=u,t[20]=W):W=t[20];const V=W;if(!o)return null;let K;t[21]!==e?(K=e("contextRail.aria.rail"),t[21]=e,t[22]=K):K=t[22];let y;t[23]!==_?(y=_.map(h1),t[23]=_,t[24]=y):y=t[24];let I;if(t[25]!==F||t[26]!==B||t[27]!==o||t[28]!==h||t[29]!==m||t[30]!==_||t[31]!==e||t[32]!==a){let J;t[34]!==F||t[35]!==B||t[36]!==o||t[37]!==h||t[38]!==m||t[39]!==e||t[40]!==a?(J=(Z,re)=>{const ee=e(Z.labelKey),he=Z.id==="git"&&!a?B:0,be=he>0?he:null;return s.jsx(r1,{surface:Z,isActive:F===Z.mode,showActivityDot:!1,label:ee,description:e(Z.descriptionKey),badgeCount:be,badgeAriaLabel:be!==null?e(be===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ee,count:be}):null,badgeDescription:be!==null?e(be===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:be}):null,orderNumber:re+1,showOrderNumber:m,onSelect:Y=>h(o,Y.mode)},Z.id)},t[34]=F,t[35]=B,t[36]=o,t[37]=h,t[38]=m,t[39]=e,t[40]=a,t[41]=J):J=t[41],I=_.map(J),t[25]=F,t[26]=B,t[27]=o,t[28]=h,t[29]=m,t[30]=_,t[31]=e,t[32]=a,t[33]=I}else I=t[33];let $;t[42]!==y||t[43]!==I?($=s.jsx(_a,{items:y,strategy:$a,children:I}),t[42]=y,t[43]=I,t[44]=$):$=t[44];let z;t[45]!==V||t[46]!==k||t[47]!==$?(z=s.jsx(Si,{sensors:k,collisionDetection:ji,onDragEnd:V,children:$}),t[45]=V,t[46]=k,t[47]=$,t[48]=z):z=t[48];let G;return t[49]!==K||t[50]!==z?(G=s.jsx("nav",{"aria-label":K,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:z}),t[49]=K,t[50]=z,t[51]=G):G=t[51],G};function i1(t){return t.workStatusPanelVisible}function a1(t){return t.contextRailOrder}function l1(t){return t.setContextRailOrder}function c1(t){return t.openContextSurface}function d1(t){return t.shortcutOverrides}function u1(t){return t.planModeEnabled}function f1(t){return t.length===1&&t>="0"&&t<="9"}function m1(t){return t.id}function h1(t){return t.id}const p1=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),g1=(t,e,n,r)=>!n||r!==n||t.length===0?[]:xo(t,e,o=>o.name,{limit:10,threshold:.4}),x1=new Set,b1=[],Ya=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const o=r==="/",i=/^[A-Za-z]:\/$/.test(r);return!o&&!i&&(r=r.replace(/\/+$/,"")),r},y1=()=>{const t=tt.c(178),{t:e}=mt(),n=xe(v1),r=xe(w1),o=xe(S1),i=xe(j1),c=xe(k1),a=xe(C1),d=xe(N1),u=xe(A1),h=xe(D1),f=xe(P1),g=xe(E1),b=Je(T1),S=Je(I1);let v;t[0]!==n?(v=Ze=>n?Ze.activeSessions:b1,t[0]=n,t[1]=v):v=t[1];const p=Rs(v);let m;t[2]!==n?(m=Ze=>n?Ze.ids:x1,t[2]=n,t[3]=m):m=t[3];const x=No(m);let w;t[4]!==n?(w=Ze=>n?Ze.rankById:ul,t[4]=n,t[5]=w):w=t[5];const j=zi(w),N=ls(R1),A=qt(M1),k=qt(O1),C=Io(),P=su(F1),{files:D,git:F}=tr(),B=mr(B1),{isMobile:E}=pr();let _;t[6]!==C?(_=C?Ya(C):null,t[6]=C,t[7]=_):_=t[7];const W=_,[V,K]=l.useState(""),I=dl(V,200).trim();let $;t[8]!==V?($=V.trim(),t[8]=V,t[9]=$):$=t[9];const z=$;let G,J;t[10]!==n?(G=()=>{n&&K("")},J=[n],t[10]=n,t[11]=G,t[12]=J):(G=t[11],J=t[12]),l.useEffect(G,J);let Z,re;t[13]!==p||t[14]!==B||t[15]!==F||t[16]!==n?(Z=()=>{if(!n||!F)return;const Ze=setTimeout(()=>{const $e=new Set;for(const St of p){const Lt=Us(St);!Lt||$e.has(Lt)||($e.add(Lt),B(Lt,F))}},0);return()=>clearTimeout(Ze)},re=[n,p,F,B],t[13]=p,t[14]=B,t[15]=F,t[16]=n,t[17]=Z,t[18]=re):(Z=t[17],re=t[18]),l.useEffect(Z,re);let ee;t[19]!==r?(ee=()=>r(!1),t[19]=r,t[20]=ee):ee=t[20];const he=ee;let be;t[21]!==he?(be=Ze=>()=>{he(),Ze()},t[21]=he,t[22]=be):be=t[22];const Y=be;let we;t[23]!==A?.id||t[24]!==A?.path||t[25]!==N||t[26]!==E||t[27]!==u||t[28]!==h||t[29]!==b||t[30]!==Y||t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==e||t[35]!==d?(we=()=>{const Ze=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(R,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:Y(()=>{o("chat"),a(!1),b()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(R,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:Y(L1)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(R,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:Y(_1)},{id:"toggle-sidebar",title:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(R,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:Y(()=>{if(E){const{isSessionSwitcherOpen:$e}=xe.getState();a(!$e)}else d()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(R,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:Y(()=>{N&&h(N,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(R,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:Y(()=>{N&&u(N)})},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(R,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:Y(()=>i(!0))}];return Ri()&&Ze.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(R,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:Y(()=>{ur("desktop_open_draft_mini_chat_window",{directory:Ya(N||A?.path||""),projectId:A?.id??null}).catch($1)})}),Ze},t[23]=A?.id,t[24]=A?.path,t[25]=N,t[26]=E,t[27]=u,t[28]=h,t[29]=b,t[30]=Y,t[31]=o,t[32]=a,t[33]=i,t[34]=e,t[35]=d,t[36]=we):we=t[36],A?.id,A?.path;let me;t[37]!==we?(me=we(),t[37]=we,t[38]=me):me=t[38];const Q=me;let pe;t[39]===Symbol.for("react.memo_cache_sentinel")?(pe=$n(),t[39]=pe):pe=t[39];const ve=pe;let Te,ke;t[40]===Symbol.for("react.memo_cache_sentinel")?(Te=er(),ke=!ve&&rl(),t[40]=Te,t[41]=ke):(Te=t[40],ke=t[41]);let Ie;t[42]!==E?(Ie={isVSCode:Te,isWeb:ke,isDesktop:ve,isMobile:E},t[42]=E,t[43]=Ie):Ie=t[43];const Ne=Ie;let Ae;if(t[44]!==Y||t[45]!==i||t[46]!==c||t[47]!==Ne){let Ze;t[49]!==Ne?(Ze=St=>St.isAvailable?St.isAvailable(Ne):!0,t[49]=Ne,t[50]=Ze):Ze=t[50];let $e;t[51]!==Y||t[52]!==i||t[53]!==c?($e=St=>{const Lt=Dg(St.slug)??"settings-3",Ot=(St.keywords??[]).join(" ");return{id:`settings:${St.slug}`,title:St.title,icon:St.slug==="mcp"?s.jsx(fu,{className:"mr-2 h-4 w-4"}):s.jsx(R,{name:Lt,className:"mr-2 h-4 w-4"}),searchText:`${St.title} ${St.group} ${Ot}`,onSelect:Y(()=>{c(St.slug),i(!0)})}},t[51]=Y,t[52]=i,t[53]=c,t[54]=$e):$e=t[54],Ae=Ag.filter(z1).filter(Ze).map($e),t[44]=Y,t[45]=i,t[46]=c,t[47]=Ne,t[48]=Ae}else Ae=t[48];const Se=Ae;let Oe;t[55]!==p||t[56]!==x||t[57]!==j?(Oe=wu(p,x,j),t[55]=p,t[56]=x,t[57]=j,t[58]=Oe):Oe=t[58];const ne=Oe,ce=Su(),Re=Je(U1);let te;t[59]!==ce||t[60]!==Re?(te=(Ze,$e)=>{const St=Re.get(Ze);return St?.branch?St.branch.trim()||null:$e&&ce.get($e)?.trim()||null},t[59]=ce,t[60]=Re,t[61]=te):te=t[61];const ae=te;let de;t[62]===Symbol.for("react.memo_cache_sentinel")?(de=[],t[62]=de):de=t[62];const[H,ge]=l.useState(de),[ue,M]=l.useState(""),oe=p1(W,I);let De;t[63]!==W||t[64]!==oe||t[65]!==n||t[66]!==P||t[67]!==ge||t[68]!==M||t[69]!==I?(De=()=>{if(!n){ge([]),M("");return}if(!oe){ge([]),M("");return}if(!W){ge([]),M("");return}let Ze=!1;return P(W,I,10,{type:"file"}).then($e=>{Ze||(ge($e.map(W1)),M(oe))}).catch(()=>{Ze||(ge([]),M(oe))}),()=>{Ze=!0}},t[63]=W,t[64]=oe,t[65]=n,t[66]=P,t[67]=ge,t[68]=M,t[69]=I,t[70]=De):De=t[70];let fe;t[71]!==W||t[72]!==oe||t[73]!==n||t[74]!==P||t[75]!==I?(fe=[n,W,I,oe,P],t[71]=W,t[72]=oe,t[73]=n,t[74]=P,t[75]=I,t[76]=fe):fe=t[76],l.useEffect(De,fe);const X=z.length>0;let le;e:{if(!X){let $e;t[77]!==Q?($e=Q.map(V1),t[77]=Q,t[78]=$e):$e=t[78],le=$e;break e}let Ze;t[79]!==Q||t[80]!==z?(Ze=xo(Q,z,H1,{limit:7,noFuzzy:!0}),t[79]=Q,t[80]=z,t[81]=Ze):Ze=t[81],le=Ze}const se=le;let T;e:{if(!X){let $e;t[82]===Symbol.for("react.memo_cache_sentinel")?($e=[],t[82]=$e):$e=t[82],T=$e;break e}let Ze;t[83]!==z||t[84]!==Se?(Ze=xo(Se,z,K1,{limit:7,noFuzzy:!0}),t[83]=z,t[84]=Se,t[85]=Ze):Ze=t[85],T=Ze}const ie=T;let je;e:{if(!X){let $e;t[86]!==ne?($e=ne.slice(0,5).map(G1),t[86]=ne,t[87]=$e):$e=t[87],je=$e;break e}let Ze;t[88]!==z||t[89]!==ne?(Ze=xo(ne,z,q1,{limit:7,threshold:.2}),t[88]=z,t[89]=ne,t[90]=Ze):Ze=t[90],je=Ze}const Pe=je;let U;e:{if(!n){let $e;t[91]===Symbol.for("react.memo_cache_sentinel")?($e=[],t[91]=$e):$e=t[91],U=$e;break e}let Ze;t[92]!==H||t[93]!==ue||t[94]!==oe||t[95]!==I?(Ze=g1(H,I,oe,ue),t[92]=H,t[93]=ue,t[94]=oe,t[95]=I,t[96]=Ze):Ze=t[96],U=Ze}const Be=U,Fe=n&&oe.length>0&&ue!==oe;let Ye;e:{if(!X){let $e;t[97]===Symbol.for("react.memo_cache_sentinel")?($e=[],t[97]=$e):$e=t[97],Ye=$e;break e}let Ze;if(t[98]!==z||t[99]!==k){const $e=k.map(Y1);Ze=xo($e,z,Q1,{limit:7,threshold:.4}),t[98]=z,t[99]=k,t[100]=Ze}else Ze=t[100];Ye=Ze}const at=Ye;let st,ct,bt,rt,gt,it,Et,Ft,Dt,Bt,qe,zt,Nt,xt;if(t[101]!==ae||t[102]!==he||t[103]!==W||t[104]!==D||t[105]!==X||t[106]!==n||t[107]!==f||t[108]!==b||t[109]!==V||t[110]!==se||t[111]!==Be||t[112]!==at||t[113]!==Pe||t[114]!==ie||t[115]!==r||t[116]!==S||t[117]!==g||t[118]!==e){const Ze=se.map(X1),$e=ie.map(J1),St=Pe.map(Z1),Lt=X?Be.map(eS):[],Ot=X?at.map(tS):[];let ss;e:{if(!X){ss=["commands","sessions"];break e}const He=sS,Ve=[{key:"commands",score:He(se)},{key:"settings",score:He(ie)},{key:"sessions",score:He(Pe)},{key:"files",score:He(Be)},{key:"projects",score:He(at)}];Ve.sort(nS),ss=Ve.map(rS)}const _t=ss,Ct=He=>{he(),S(He.id,Us(He))},os=async He=>{if(!W)return;const Ve=await pf(D,He,{directory:W});if(!Ve.ok){Ee.error(gf(Ve.reason));return}f(W,He),he()},hs=(He,Ve)=>{he(),b({selectedProjectId:He,directoryOverride:Ve})},Rt=He=>Bi(Or(He,g));rt=Ws,zt=n,Nt=r;let $t;t[133]!==e?($t=e("commandPalette.title"),t[133]=e,t[134]=$t):$t=t[134];let Wt;t[135]!==$t?(Wt=s.jsx(wn,{children:$t}),t[135]=$t,t[136]=Wt):Wt=t[136];let is;t[137]!==e?(is=e("commandPalette.description"),t[137]=e,t[138]=is):is=t[138];let Me;t[139]!==is?(Me=s.jsx(Sn,{children:is}),t[139]=is,t[140]=Me):Me=t[140],t[141]!==Wt||t[142]!==Me?(xt=s.jsxs(Rn,{className:"sr-only",children:[Wt,Me]}),t[141]=Wt,t[142]=Me,t[143]=xt):xt=t[143],bt=Vs,Bt="overflow-hidden p-0",qe=!0,ct=_h,Et=!1,Ft="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let Ke;t[144]!==e?(Ke=e("commandPalette.input.placeholder"),t[144]=e,t[145]=Ke):Ke=t[145],t[146]!==V||t[147]!==Ke?(Dt=s.jsx($h,{value:V,onValueChange:K,placeholder:Ke}),t[146]=V,t[147]=Ke,t[148]=Dt):Dt=t[148],st=zh;let ze;t[149]!==e?(ze=e("commandPalette.empty.noResults"),t[149]=e,t[150]=ze):ze=t[150],t[151]!==ze?(gt=s.jsx(Uh,{children:ze}),t[151]=ze,t[152]=gt):gt=t[152],it=_t.map(He=>He==="commands"&&Ze.length>0?s.jsx(uo,{children:Ze.map(Ve=>s.jsxs(bo,{value:Ve.id,onSelect:Ve.onSelect,children:[Ve.icon,s.jsx("span",{children:Ve.title}),Ve.shortcutId?s.jsx(Bh,{children:Rt(Ve.shortcutId)}):null]},Ve.id))},"commands"):He==="settings"&&$e.length>0?s.jsx(uo,{children:$e.map(oS)},"settings"):He==="sessions"&&St.length>0?s.jsx(uo,{children:St.map(Ve=>{const jt=Ve.title||e("commandPalette.session.untitled"),Jt=Us(Ve),yt=ae(Ve.id,Jt);return s.jsxs(bo,{value:`session:${Ve.id}`,onSelect:()=>Ct(Ve),children:[s.jsx(R,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:jt}),yt?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(R,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:yt})]}):null]},Ve.id)})},"sessions"):He==="files"&&Lt.length>0?s.jsx(uo,{children:Lt.map(Ve=>{const jt=Lh(Ve.relativePath||Ve.name,{maxLength:80});return s.jsxs(bo,{value:`file:${Ve.path}`,onSelect:()=>{os(Ve.path)},children:[s.jsx(cl,{filePath:Ve.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":Ve.relativePath,children:jt})]},`file:${Ve.path}`)})},"files"):He==="projects"&&Ot.length>0?s.jsx(uo,{children:Ot.map(Ve=>{const jt=Ve.displayName;return s.jsxs(bo,{value:`project:${Ve.id}`,onSelect:()=>hs(Ve.id,Ve.path),children:[s.jsx(R,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:jt}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:Ve.path})]},`project:${Ve.id}`)})},"projects"):null),t[101]=ae,t[102]=he,t[103]=W,t[104]=D,t[105]=X,t[106]=n,t[107]=f,t[108]=b,t[109]=V,t[110]=se,t[111]=Be,t[112]=at,t[113]=Pe,t[114]=ie,t[115]=r,t[116]=S,t[117]=g,t[118]=e,t[119]=st,t[120]=ct,t[121]=bt,t[122]=rt,t[123]=gt,t[124]=it,t[125]=Et,t[126]=Ft,t[127]=Dt,t[128]=Bt,t[129]=qe,t[130]=zt,t[131]=Nt,t[132]=xt}else st=t[119],ct=t[120],bt=t[121],rt=t[122],gt=t[123],it=t[124],Et=t[125],Ft=t[126],Dt=t[127],Bt=t[128],qe=t[129],zt=t[130],Nt=t[131],xt=t[132];let Pt;t[153]!==Fe||t[154]!==e?(Pt=Fe?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[153]=Fe,t[154]=e,t[155]=Pt):Pt=t[155];let Mt;t[156]!==st||t[157]!==gt||t[158]!==it||t[159]!==Pt?(Mt=s.jsxs(st,{children:[gt,it,Pt]}),t[156]=st,t[157]=gt,t[158]=it,t[159]=Pt,t[160]=Mt):Mt=t[160];let Xt;t[161]!==ct||t[162]!==Et||t[163]!==Ft||t[164]!==Dt||t[165]!==Mt?(Xt=s.jsxs(ct,{shouldFilter:Et,className:Ft,children:[Dt,Mt]}),t[161]=ct,t[162]=Et,t[163]=Ft,t[164]=Dt,t[165]=Mt,t[166]=Xt):Xt=t[166];let Qe;t[167]!==bt||t[168]!==Bt||t[169]!==qe||t[170]!==Xt?(Qe=s.jsx(bt,{className:Bt,showCloseButton:qe,children:Xt}),t[167]=bt,t[168]=Bt,t[169]=qe,t[170]=Xt,t[171]=Qe):Qe=t[171];let ht;return t[172]!==rt||t[173]!==zt||t[174]!==Nt||t[175]!==xt||t[176]!==Qe?(ht=s.jsxs(rt,{open:zt,onOpenChange:Nt,children:[xt,Qe]}),t[172]=rt,t[173]=zt,t[174]=Nt,t[175]=xt,t[176]=Qe,t[177]=ht):ht=t[177],ht};function v1(t){return t.isCommandPaletteOpen}function w1(t){return t.setCommandPaletteOpen}function S1(t){return t.setActiveMainTab}function j1(t){return t.setSettingsDialogOpen}function k1(t){return t.setSettingsPage}function C1(t){return t.setSessionSwitcherOpen}function N1(t){return t.toggleSidebar}function A1(t){return t.openContextOverview}function D1(t){return t.openContextSurface}function P1(t){return t.openContextFile}function E1(t){return t.shortcutOverrides}function T1(t){return t.openNewSessionDraft}function I1(t){return t.setCurrentSession}function R1(t){return t.currentDirectory}function M1(t){return t.getActiveProject()}function O1(t){return t.projects}function F1(t){return t.searchFiles}function B1(t){return t.ensureStatus}function L1(){ju()}function _1(){_n.requestDirectoryDialog()}function $1(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function z1(t){return t.slug!=="home"}function U1(t){return t.worktreeMetadata}function W1(t){return{path:Ya(t.path),name:t.name,relativePath:t.relativePath}}function V1(t){return{item:t,score:0}}function H1(t){return t.searchText}function K1(t){return t.searchText}function G1(t){return{item:t,score:0}}function q1(t){return t.title||""}function Y1(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Q1(t){return t.searchText}function X1(t){return t.item}function J1(t){return t.item}function Z1(t){return t.item}function eS(t){return t.item}function tS(t){return t.item}function sS(t){return t.length?t[0].score:1/0}function nS(t,e){return t.score-e.score}function rS(t){return t.key}function oS(t){return s.jsxs(bo,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const rd=(t,e,n)=>Vh(t)?Bi(Or(t,n)):e,iS=()=>{const t=tt.c(69),{t:e}=mt(),n=xe(aS),r=xe(lS),o=xe(cS);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=Wh(),t[0]=i):i=t[0];const c=i;let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=er(),t[1]=a):a=t[1];const d=a;let u,h,f,g,b,S,v,p,m;if(t[2]!==n||t[3]!==r||t[4]!==o||t[5]!==e){const K=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[`Shift + Alt + ${c} + N`],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_right_sidebar",descriptionKey:"helpDialog.item.toggleRightSidebar",icon:"layout-right",keys:""},{id:"open_right_sidebar_git",descriptionKey:"helpDialog.item.openRightSidebarGitTab",icon:"git-branch",keys:""},{id:"open_right_sidebar_files",descriptionKey:"helpDialog.item.openRightSidebarFilesTab",icon:"layout-right",keys:""},{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{id:"toggle_context_plan",descriptionKey:"helpDialog.item.togglePlanContextPanel",icon:"time",keys:""},{keys:[`${c} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"cycle_services_tab",descriptionKey:"helpDialog.item.cycleServicesTab",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];h=Ws,p=n,m=r,u=Vs,S="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let y;t[15]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(R,{name:"command",className:"h-5 w-5"}),t[15]=y):y=t[15];let I;t[16]!==e?(I=e("helpDialog.title"),t[16]=e,t[17]=I):I=t[17];let $;t[18]!==I?($=s.jsxs(wn,{className:"flex items-center gap-2",children:[y,I]}),t[18]=I,t[19]=$):$=t[19];let z;t[20]!==e?(z=e("helpDialog.description"),t[20]=e,t[21]=z):z=t[21];let G;t[22]!==z?(G=s.jsx(Sn,{children:z}),t[22]=z,t[23]=G):G=t[23],t[24]!==$||t[25]!==G?(v=s.jsxs(Rn,{children:[$,G]}),t[24]=$,t[25]=G,t[26]=v):v=t[26],b="flex-1 overflow-y-auto mt-3 pr-1",f="space-y-4",g=K.map(J=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(J.categoryKey)}),s.jsx("div",{className:"space-y-1",children:J.items.filter(Z=>!(d&&Z.id==="toggle_prompt_navigator")).map(Z=>{const re=Z.id?rd(Z.id,Array.isArray(Z.keys)?Z.keys[0]:Z.keys,o):Array.isArray(Z.keys)?Z.keys:Z.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Z.icon&&s.jsx(R,{name:Z.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(Z.descriptionKey)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(re)?re:[re]).map((ee,he)=>s.jsxs(l.Fragment,{children:[he>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:ee})]},`${ee}-${he}`))})]},Z.id||Z.descriptionKey)})})]},J.categoryKey)),t[2]=n,t[3]=r,t[4]=o,t[5]=e,t[6]=u,t[7]=h,t[8]=f,t[9]=g,t[10]=b,t[11]=S,t[12]=v,t[13]=p,t[14]=m}else u=t[6],h=t[7],f=t[8],g=t[9],b=t[10],S=t[11],v=t[12],p=t[13],m=t[14];let x;t[27]!==f||t[28]!==g?(x=s.jsx("div",{className:f,children:g}),t[27]=f,t[28]=g,t[29]=x):x=t[29];let w;t[30]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(R,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[30]=w):w=t[30];let j;t[31]!==e?(j=e("helpDialog.proTips.title"),t[31]=e,t[32]=j):j=t[32];let N;t[33]!==j?(N=s.jsx("p",{className:"font-medium mb-1",children:j}),t[33]=j,t[34]=N):N=t[34];let A;t[35]!==o||t[36]!==e?(A=e("helpDialog.proTips.commandPalette",{shortcut:rd("open_command_palette",`${c} P`,o)}),t[35]=o,t[36]=e,t[37]=A):A=t[37];let k;t[38]!==A?(k=s.jsxs("li",{children:["• ",A]}),t[38]=A,t[39]=k):k=t[39];let C;t[40]!==e?(C=e("helpDialog.proTips.recentSessions"),t[40]=e,t[41]=C):C=t[41];let P;t[42]!==C?(P=s.jsxs("li",{children:["• ",C]}),t[42]=C,t[43]=P):P=t[43];let D;t[44]!==e?(D=e("helpDialog.proTips.themeCycling"),t[44]=e,t[45]=D):D=t[45];let F;t[46]!==D?(F=s.jsxs("li",{children:["• ",D]}),t[46]=D,t[47]=F):F=t[47];let B;t[48]!==k||t[49]!==P||t[50]!==F?(B=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[k,P,F]}),t[48]=k,t[49]=P,t[50]=F,t[51]=B):B=t[51];let E;t[52]!==N||t[53]!==B?(E=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[w,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[N,B]})]})}),t[52]=N,t[53]=B,t[54]=E):E=t[54];let _;t[55]!==E||t[56]!==b||t[57]!==x?(_=s.jsxs("div",{className:b,children:[x,E]}),t[55]=E,t[56]=b,t[57]=x,t[58]=_):_=t[58];let W;t[59]!==u||t[60]!==_||t[61]!==S||t[62]!==v?(W=s.jsxs(u,{className:S,children:[v,_]}),t[59]=u,t[60]=_,t[61]=S,t[62]=v,t[63]=W):W=t[63];let V;return t[64]!==h||t[65]!==W||t[66]!==p||t[67]!==m?(V=s.jsx(h,{open:p,onOpenChange:m,children:W}),t[64]=h,t[65]=W,t[66]=p,t[67]=m,t[68]=V):V=t[68],V};function aS(t){return t.isHelpDialogOpen}function lS(t){return t.setHelpDialogOpen}function cS(t){return t.shortcutOverrides}const dS=()=>{const t=tt.c(32),{t:e}=mt(),n=xe(uS),r=xe(fS),o=xe(mS);let i;t[0]!==o||t[1]!==e?(i=async()=>{if(!o)return;if((await Xn(o)).ok){Ee.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Ee.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=o,t[1]=e,t[2]=i):i=t[2];const c=i;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(wn,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let h;t[9]!==u?(h=s.jsx(Sn,{children:u}),t[9]=u,t[10]=h):h=t[10];let f;t[11]!==d||t[12]!==h?(f=s.jsxs(Rn,{children:[d,h]}),t[11]=d,t[12]=h,t[13]=f):f=t[13];let g;t[14]!==e?(g=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=g):g=t[15];let b;t[16]!==c||t[17]!==g?(b=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:c,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:g})}),t[16]=c,t[17]=g,t[18]=b):b=t[18];let S;t[19]!==o||t[20]!==e?(S=o||e("openCodeStatusDialog.empty.noData"),t[19]=o,t[20]=e,t[21]=S):S=t[21];let v;t[22]!==S?(v=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:S}),t[22]=S,t[23]=v):v=t[23];let p;t[24]!==f||t[25]!==b||t[26]!==v?(p=s.jsxs(Vs,{className:"max-w-2xl",children:[f,b,v]}),t[24]=f,t[25]=b,t[26]=v,t[27]=p):p=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==p?(m=s.jsx(Ws,{open:n,onOpenChange:r,children:p}),t[28]=n,t[29]=r,t[30]=p,t[31]=m):m=t[31],m};function uS(t){return t.isOpenCodeStatusDialogOpen}function fS(t){return t.setOpenCodeStatusDialogOpen}function mS(t){return t.openCodeStatusText}const hS=180,od=600,pS=1,gS=6,xS=t=>{const e=t?.directory;return typeof e=="string"&&e.trim()?e:null},bS=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:o})=>{const i=l.useRef(new Map),c=l.useRef([]),a=l.useRef(new Set),d=l.useRef(0),u=l.useMemo(()=>er(),[]),h=l.useCallback(S=>`${S.directory}
|
|
900
|
-
${S.sessionId}`,[]),f=l.useCallback(()=>{d.current+=1,c.current=[],i.current.forEach(S=>window.clearTimeout(S)),i.current.clear()},[]),g=l.useCallback(()=>{if(!(!t||u||typeof window>"u"))for(;a.current.size<pS&&c.current.length>0;){const S=c.current.shift();if(!S)break;if(S.generation!==d.current||Je.getState().currentSessionId===S.sessionId||tc(S.sessionId,S.directory).renderable)continue;const p=h(S);a.current.add(p),o(S.sessionId,S.directory).catch(()=>{}).finally(()=>{a.current.delete(p),g()})}},[t,u,o,h]),b=l.useCallback(S=>{const v=S?.id,p=xS(S);if(!t||u||!v||!p||v===e||typeof window>"u")return;const m={sessionId:v,directory:p,generation:d.current},x=h(m);if(tc(v,p).renderable||a.current.has(x)||c.current.some(N=>h(N)===x))return;const w=i.current.get(x);w!==void 0&&window.clearTimeout(w);const j=window.setTimeout(()=>{if(i.current.delete(x),m.generation!==d.current)return;const N=c.current;N.length>=gS&&N.shift(),N.push(m),g()},hS);i.current.set(x,j)},[e,t,u,g,h]);l.useEffect(()=>{f()},[f,e,t,u]),l.useEffect(()=>{if(!t||u||!e||n.length===0)return;const S=window.setTimeout(()=>{const v=n.findIndex(p=>p.id===e);v<0||(b(n[v-1]),b(n[v+1]))},od);return()=>window.clearTimeout(S)},[e,t,u,b,n]),l.useEffect(()=>{if(!t||u||!e||r.length===0)return;const S=window.setTimeout(()=>{const v=r.findIndex(p=>p.id===e);v<0||(b(r[v-1]),b(r[v+1]))},od);return()=>window.clearTimeout(S)},[e,t,u,r,b]),l.useEffect(()=>f,[f])},yS=t=>{const e=tt.c(3),n=Je(vS);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],bS(r),null};function vS(t){return t.currentSessionId}const wS=t=>{const e=tt.c(12),{normalizedProjects:n,enabled:r,ownership:o,isSessionsLoading:i,hasAuthoritativeGlobalSessions:c,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:h,addSessionToFolder:f}=t,g=r===void 0?!0:r;let b,S;e[0]!==f||e[1]!==h||e[2]!==g||e[3]!==u||e[4]!==c||e[5]!==i||e[6]!==a||e[7]!==n||e[8]!==o||e[9]!==d?(b=()=>{!g||i||!c||a||n.forEach(v=>{if(d.has(v.normalizedPath))return;const p=ku(v.normalizedPath),m=o.archivedSessionsByProject.get(v.id)??[],x=u[p]??[],w=new Map(x.map(SS));m.forEach(j=>{const N=Hh(j,v.normalizedPath),A=N.toLowerCase();let k=w.get(A);k||(k=h(p,N),w.set(A,k)),k.sessionIds.includes(j.id)||f(p,k.id,j.id)})})},S=[n,g,o,i,c,a,d,u,h,f],e[0]=f,e[1]=h,e[2]=g,e[3]=u,e[4]=c,e[5]=i,e[6]=a,e[7]=n,e[8]=o,e[9]=d,e[10]=b,e[11]=S):(b=e[10],S=e[11]),l.useEffect(b,S)};function SS(t){return[t.name.toLowerCase(),t]}const jS=t=>{const e=tt.c(4);let n;e[0]!==t?(n=(i,c)=>{const a=t.get(i);if(!a||a.length===0)return c;const d=new Map(c.map(kS)),u=[];a.forEach(g=>{const b=d.get(g);b&&(u.push(b),d.delete(g))});const h=[],f=[];return c.forEach(g=>{d.has(g.id)&&(g.isArchivedBucket?f.push(g):h.push(g))}),[...h,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let o;return e[2]!==r?(o={getOrderedGroups:r},e[2]=r,e[3]=o):o=e[3],o};function kS(t){return[t.id,t]}const CS=[],NS=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:o,projectRepoStatus:i,projectRootBranches:c,lastRepoStatus:a,buildGroupedSessions:d,hasSessionSearchQuery:u,normalizedSessionSearchQuery:h,filterSessionNodesForSearch:f,buildGroupSearchText:g,foldersMap:b}=t,S=l.useRef(new Map),v=l.useMemo(()=>{const k=S.current,C=new Map;let P=0,D=0;const F=(E,_)=>E.length===_.length&&E.every((W,V)=>W===_[V]),B=e.map(E=>{const _=n(E.id),W=r(E.id),V=o.get(E.normalizedPath)??CS,K=i.has(E.id)?!!i.get(E.id):a,y=c.get(E.id)??null,I=k.get(E.id);if(I&&I.project===E&&F(I.activeSessions,_)&&F(I.archivedSessions,W)&&I.availableWorktrees===V&&I.rootBranch===y&&I.isRepo===K&&I.buildGroupedSessions===d)return P+=1,C.set(E.id,I),I.section;D+=1;const $=Cu([..._,...W]),z=d($,E.normalizedPath,V,y,K),G={project:E,groups:z};return C.set(E.id,{project:E,activeSessions:_,archivedSessions:W,availableWorktrees:V,rootBranch:y,isRepo:K,buildGroupedSessions:d,section:G}),G});return S.current=C,P>0&&In("ui.sidebar.project_section.reused",P),D>0&&In("ui.sidebar.project_section.rebuilt",D),B},[e,n,r,o,i,a,d,c]),p=l.useMemo(()=>v,[v]),m=l.useMemo(()=>{const k=new WeakMap;if(!u)return k;const C=P=>P.reduce((D,F)=>D+1+C(F.children),0);return p.forEach(P=>{P.groups.forEach(D=>{const F=f(D.sessions,h),B=C(F),E=g(D).includes(h),_=wt(D.directory??null),V=(_?b[_]??[]:[]).filter(K=>K.name.toLowerCase().includes(h)).length;k.set(D,{filteredNodes:F,matchedSessionCount:B,folderNameMatchCount:V,groupMatches:E,hasMatch:E||B>0||V>0})})}),k},[u,p,f,h,g,b]),x=l.useMemo(()=>u?p.map(k=>({...k,groups:k.groups.filter(C=>m.get(C)?.hasMatch===!0)})).filter(k=>k.groups.length>0):p,[u,p,m]),w=u?x:p,j=l.useRef(new WeakMap),N=l.useMemo(()=>{const k=j.current;return w.map(C=>{const P=k.get(C);if(P&&P.query===h)return P.section;const D=C.groups.filter(K=>!K.isArchivedBucket),F=C.groups.filter(K=>K.isArchivedBucket),B=D.flatMap(K=>u?m.get(K)?.filteredNodes??[]:K.sessions),E=D.map(K=>({scopeKey:K.folderScopeKey??wt(K.directory??null),directory:K.directory??null})).filter(K=>!!K.scopeKey),_=D.find(K=>K.isMain)??null,W={id:"flat",label:_?.label??"",branch:_?.branch??null,description:_?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:_?.directory??C.project.normalizedPath,folderScopeKey:_?.folderScopeKey??C.project.normalizedPath,folderScopes:E,sessions:B};if(u){const K=D.map(y=>m.get(y)).filter(y=>!!y);m.set(W,{filteredNodes:B,matchedSessionCount:K.reduce((y,I)=>y+I.matchedSessionCount,0),folderNameMatchCount:K.reduce((y,I)=>y+I.folderNameMatchCount,0),groupMatches:K.some(y=>y.groupMatches),hasMatch:K.some(y=>y.hasMatch)})}const V={project:C.project,groups:[W,...F]};return k.set(C,{query:h,section:V}),V})},[m,u,h,w]),A=l.useMemo(()=>u?w.reduce((k,C)=>k+C.groups.reduce((P,D)=>{const F=m.get(D);if(!F)return P;const B=F.folderNameMatchCount+(F.groupMatches?1:0);return P+F.matchedSessionCount+B},0),0):0,[u,w,m]);return{projectSections:v,visibleProjectSections:p,groupSearchDataByGroup:m,searchableProjectSections:x,sectionsForRender:w,flatSectionsForRender:N,searchMatchCount:A}};function AS({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:o,rememberedSessionId:i,fallbackSessionId:c}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(o.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(i&&r.has(i)?i:null)??c;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const DS=t=>{const e=tt.c(27),{projectSections:n,activeProjectId:r,activeSessionByProject:o,setActiveSessionByProject:i,currentSessionId:c,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:h,openNewSessionDraft:f,setActiveMainTab:g,setSessionSwitcherOpen:b}=t;let S,v;if(e[0]!==n){v=new Map,S=new Map;const k=(C,P,D,F)=>{v.has(C)||v.set(C,new Map);const B=v.get(C);F.forEach(E=>{const _=wt(E.worktree?.path??E.session.directory??D??P);B.set(E.session.id,{directory:_}),S.has(C)||S.set(C,{id:E.session.id,directory:_}),E.children.length>0&&k(C,P,_,E.children)})};n.forEach(C=>{C.groups.forEach(P=>{k(C.project.id,C.project.normalizedPath,P.directory,P.sessions)})}),e[0]=n,e[1]=S,e[2]=v}else S=e[1],v=e[2];let p;e[3]!==S||e[4]!==v?(p={metaByProject:v,firstSessionByProject:S},e[3]=S,e[4]=v,e[5]=p):p=e[5];const m=p,x=l.useRef(null);let w,j;e[6]!==r||e[7]!==o||e[8]!==c||e[9]!==a||e[10]!==d||e[11]!==h||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==m||e[16]!==g||e[17]!==i||e[18]!==b?(w=()=>{if(!r||u||xe.getState().isNewWorktreeDialogOpen||x.current===r)return;const k=n.find(F=>F.project.id===r);if(!k)return;const C=m.metaByProject.get(r);if(c&&C&&C.has(c)){x.current=r,i(F=>{if(F.get(r)===c)return F;const B=new Map(F);return B.set(r,c),B});return}const P=AS({activeProjectId:r,currentSessionId:c,currentSessionOwnerProjectId:a,projectMap:C,metaByProject:m.metaByProject,rememberedSessionId:o.get(r),fallbackSessionId:m.firstSessionByProject.get(r)?.id??null});if(P.kind==="preserve-current"){a===r&&(x.current=r);return}if(x.current=r,P.kind==="open-draft"){g("chat"),h&&b(!1),f({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(P.kind!=="select-session")return;const D=C?.get(P.sessionId)?.directory??null;d(P.sessionId,D)},j=[r,o,c,a,d,u,h,f,n,m,g,b,i],e[6]=r,e[7]=o,e[8]=c,e[9]=a,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=n,e[15]=m,e[16]=g,e[17]=i,e[18]=b,e[19]=w,e[20]=j):(w=e[19],j=e[20]),l.useLayoutEffect(w,j);let N,A;e[21]!==r||e[22]!==c||e[23]!==m||e[24]!==i?(N=()=>{if(!r||!c)return;const k=m.metaByProject.get(r);!k||!k.has(c)||i(C=>{if(C.get(r)===c)return C;const P=new Map(C);return P.set(r,c),P})},A=[r,c,m,i],e[21]=r,e[22]=c,e[23]=m,e[24]=i,e[25]=N,e[26]=A):(N=e[25],A=e[26]),l.useEffect(N,A)},PS=t=>{const e=tt.c(20);let n,r,o,i;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:o,sessionOwnerBySessionId:i,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=i):(n=e[1],r=e[2],o=e[3],i=e[4]);const c=Je(ES),a=Je(TS);let d;e[5]!==c||e[6]!==i?(d=c?i?.get(c)?.projectId??null:null,e[5]=c,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[f,g]=l.useState(h);let b;e[10]!==f||e[11]!==n||e[12]!==c||e[13]!==u||e[14]!==a?(b={...n,activeSessionByProject:f,setActiveSessionByProject:g,currentSessionId:c,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=c,e[13]=u,e[14]=a,e[15]=b):b=e[15],DS(b);let S,v;return e[16]!==f||e[17]!==o?(S=()=>{o(f)},v=[f,o],e[16]=f,e[17]=o,e[18]=S,e[19]=v):(S=e[18],v=e[19]),l.useEffect(S,v),null};function ES(t){return t.currentSessionId}function TS(t){return!!t.newSessionDraft?.open}const Qa=new Map,IS=(t,e)=>{for(const n of t){const r=wt(n??null);r&&!Qa.has(r)&&Qa.set(r,e)}},id=t=>{const e=wt(t??null);return e?Qa.get(e)??0:0},Yo=t=>!!t.time?.archived,RS=t=>{const{t:e}=mt(),n=l.useCallback(c=>[c.label,c.branch??"",c.description??"",c.directory??""].join(" ").toLowerCase(),[]),r=l.useCallback(c=>{const a=wt(c.directory??null)??"";return`${(c.title||e("sessions.sidebar.session.untitled")).trim()} ${a}`.toLowerCase()},[e]),o=l.useCallback((c,a)=>a?c.flatMap(d=>{if(r(d.session).includes(a))return[d];const h=o(d.children,a);return h.length===0?[]:[{...d,children:h}]}):c,[r]),i=l.useCallback((c,a,d,u,h)=>{const f=wt(a??null),g=Cu(c).sort((B,E)=>to(B,E,t.pinnedSessionIds,t.sessionOrderRanks)),b=new Map(g.map(B=>[B.id,B])),S=new Map;g.forEach(B=>{const E=B.parentID;if(!E)return;const _=b.get(E);if(!_||Yo(_)!==Yo(B))return;const W=S.get(E)??[];W.push(B),S.set(E,W)}),S.forEach(B=>B.sort((E,_)=>to(E,_,t.pinnedSessionIds,t.sessionOrderRanks)));const v=new Map;d.forEach(B=>{if(B.path){const E=wt(B.path)??B.path;v.set(E,B)}});const p=B=>{const E=wt(B.directory??null),_=t.worktreeMetadata.get(B.id)??null;if(_)return _;if(E){const W=v.get(E)??null;if(W&&E!==f)return W}return null},m=B=>{const E=S.get(B.id)??[];return{session:B,children:E.map(_=>m(_)),worktree:p(B)}},x=g.filter(B=>{const E=B.parentID;if(!E)return!0;const _=b.get(E);return _?Yo(_)!==Yo(B):!0}),w=new Map,j="__archived__",N=B=>{if(B.time?.archived)return j;if(t.isVSCode)return f??"__project_root__";const _=wt(t.worktreeMetadata.get(B.id)?.path??null)??Us(B);return _?_!==f&&v.has(_)?_:_===f?f??"__project_root__":j:j};x.forEach(B=>{const E=m(B),_=N(B);w.has(_)||w.set(_,[]),w.get(_)?.push(E)});const A=f??"__project_root__",k=[{id:"root",label:h&&u&&u!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:u}):e("sessions.sidebar.grouping.projectRoot"),branch:u??null,description:f?gi(f,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:f,folderScopeKey:f,sessions:w.get(A)??[]}],C=new Map;d.forEach(B=>{const E=wt(B.path)??B.path,_=w.get(E)??[],W=_.length>0,V=_.reduce((K,y)=>{const I=Kh(y.session,t.sessionOrderRanks);return Number.isFinite(I)?Math.max(K,I):K},0);C.set(E,{hasActiveSession:W,lastUpdatedAt:V})});const P=[...d].sort((B,E)=>{const _=wt(B.path)??B.path,W=wt(E.path)??E.path,V=C.get(_)??{hasActiveSession:!1,lastUpdatedAt:0},K=C.get(W)??{hasActiveSession:!1,lastUpdatedAt:0};if(V.hasActiveSession!==K.hasActiveSession)return V.hasActiveSession?-1:1;if(V.hasActiveSession&&K.hasActiveSession)return K.lastUpdatedAt-V.lastUpdatedAt;const y=id(B.path),I=id(E.path);if(y!==I)return I-y;const $=(B.label||B.branch||B.name||B.path||"").toLowerCase(),z=(E.label||E.branch||E.name||E.path||"").toLowerCase();return $.localeCompare(z)});(t.isVSCode?[]:P).forEach(B=>{const E=wt(B.path)??B.path,_=t.gitBranches.get(E)?.trim()||null,W=B.branch?.trim()||null,K=!!(_&&W&&B.label&&sc(B.label)===sc(W))?_:B.label||B.name||hr(E,t.homeDirectory)||E;k.push({id:`worktree:${E}`,label:K,branch:_||W,description:gi(E,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:B,directory:E,folderScopeKey:E,sessions:w.get(E)??[]})});const F=w.get(j)??[];return F.length>0&&k.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&&f?ku(f):null,sessions:F}),k},[t.homeDirectory,t.worktreeMetadata,t.pinnedSessionIds,t.sessionOrderRanks,t.gitBranches,t.isVSCode,e]);return{buildGroupSearchText:n,buildSessionSearchText:r,filterSessionNodesForSearch:o,buildGroupedSessions:i}},MS=t=>{const e=tt.c(11),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:o,sessionSearchInputRef:i,sessionSearchContainerRef:c}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==i?(d=()=>{if(!a||!r||typeof window>"u")return;const g=window.requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()});return()=>window.cancelAnimationFrame(g)},u=[a,r,i],e[0]=a,e[1]=r,e[2]=i,e[3]=d,e[4]=u):(d=e[3],u=e[4]),l.useEffect(d,u);let h,f;e[5]!==a||e[6]!==r||e[7]!==c||e[8]!==o?(h=()=>{if(!a||!r||typeof document>"u")return;const g=b=>{c.current&&(c.current.contains(b.target)||o(!1))};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},f=[a,r,o,c],e[5]=a,e[6]=r,e[7]=c,e[8]=o,e[9]=h,e[10]=f):(h=e[9],f=e[10]),l.useEffect(h,f)},OS=t=>{const e=tt.c(50),{t:n}=mt(),[r,o]=l.useState(null),i=l.useRef(null);let c,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>()=>{i.current&&clearTimeout(i.current)},a=[],e[0]=c,e[1]=a):(c=e[0],a=e[1]),l.useEffect(c,a);let d;e[2]!==t?(d=(G,J)=>{Da("navigation.session_select"),xe.getState().closeMainSurfaces();const Z=()=>{!t.isSessionSearchOpen&&t.sessionSearchQuery.length===0||(t.setSessionSearchQuery(""),t.setIsSessionSearchOpen(!1))};if(t.mobileVariant&&(t.setActiveMainTab("chat"),t.setSessionSwitcherOpen(!1)),G===Je.getState().currentSessionId){t.allowReselect&&t.onSessionSelected?.(G),Z();return}Da("navigation.session_state_set"),t.setCurrentSession(G,J??null),t.onSessionSelected?.(G),Z()},e[2]=t,e[3]=d):d=e[3];const u=d;let h;e[4]!==t?(h=(G,J)=>{t.setEditingId(G),t.setEditTitle(J)},e[4]=t,e[5]=h):h=e[5];const f=h;let g;e[6]!==t?(g=async G=>{if(!t.editingId)return;const J=(G??t.editTitle).trim();J&&await t.updateSessionTitle(t.editingId,J),t.setEditingId(null),t.setEditTitle("")},e[6]=t,e[7]=g):g=e[7];const b=g;let S;e[8]!==t?(S=()=>{t.setEditingId(null),t.setEditTitle("")},e[8]=t,e[9]=S):S=e[9];const v=S;let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=async(G,J)=>{try{return(await Xn(G)).ok?(o(J),i.current&&clearTimeout(i.current),i.current=window.setTimeout(()=>{o(null),i.current=null},2e3),!0):!1}catch{return!1}},e[10]=p):p=e[10];const m=p;let x;e[11]!==t||e[12]!==n?(x=async G=>{const J=await t.shareSession(G.id);if(!J?.share?.url){Ee.error(n("sessions.sidebar.session.share.error"));return}const Z=await m(J.share.url,G.id);Ee[Z?"success":"warning"](n("sessions.sidebar.session.share.successTitle"),{description:n(Z?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")})},e[11]=t,e[12]=n,e[13]=x):x=e[13];const w=x;let j;e[14]!==n?(j=(G,J)=>{m(G,J).then(Z=>{Z||Ee.error(n("sessions.sidebar.session.share.copyUrlError"))})},e[14]=n,e[15]=j):j=e[15];const N=j;let A;e[16]!==n?(A=G=>{Xn(G).then(J=>{if(J.ok){Ee.success(n("sessions.sidebar.session.copyId.success"));return}Ee.error(n("sessions.sidebar.session.copyId.error"))}).catch(()=>Ee.error(n("sessions.sidebar.session.copyId.error")))},e[16]=n,e[17]=A):A=e[17];const k=A;let C;e[18]!==t||e[19]!==n?(C=async G=>{await t.unshareSession(G)?Ee.success(n("sessions.sidebar.session.unshare.success")):Ee.error(n("sessions.sidebar.session.unshare.error"))},e[18]=t,e[19]=n,e[20]=C):C=e[20];const P=C;let D;e[21]!==t.childrenMap?(D=G=>{const J=[],Z=re=>{(t.childrenMap.get(re)??[]).forEach(he=>{J.push(he),Z(he.id)})};return Z(G),J},e[21]=t.childrenMap,e[22]=D):D=e[22];const F=D,B=BS;let E;e[23]!==t||e[24]!==F||e[25]!==n?(E=async(G,J,Z)=>{const re=J?.archivedBucket===!0||J?.hardDelete===!0,ee=Z?.descendantIds??B(F(G.id),re).map(LS);if(ee.length===0){(re?await t.deleteSession(G.id):await t.archiveSession(G.id))?Ee.success(n(re?"sessions.sidebar.session.delete.success":"sessions.sidebar.session.archive.success")):Ee.error(n(re?"sessions.sidebar.session.delete.error":"sessions.sidebar.session.archive.error"));return}const he=[G.id,...ee];if(re){const{deletedIds:we,failedIds:me}=await t.deleteSessions(he);if(me.length===0){const Q=we.length;Ee.success(Q===1?n("sessions.sidebar.bulkActions.deletedSingle",{count:Q}):n("sessions.sidebar.bulkActions.deletedPlural",{count:Q}))}else Ee.error(n("sessions.sidebar.session.delete.error"));return}const{archivedIds:be,failedIds:Y}=await t.archiveSessions(he);be.length>0&&Ee.success(be.length===1?n("sessions.sidebar.bulkActions.archivedSingle",{count:be.length}):n("sessions.sidebar.bulkActions.archivedPlural",{count:be.length})),Y.length>0&&Ee.error(Y.length===1?n("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Y.length}):n("sessions.sidebar.bulkActions.failedArchivePlural",{count:Y.length}))},e[23]=t,e[24]=F,e[25]=n,e[26]=E):E=e[26];const _=E;let W;e[27]!==t||e[28]!==F||e[29]!==_?(W=(G,J)=>{const Z=J?.archivedBucket===!0||J?.hardDelete===!0,re=B(F(G.id),Z).map(_S);if(!t.showDeletionDialog||J?.skipConfirm===!0){_(G,J,{descendantIds:re});return}t.setDeleteSessionConfirm({session:G,descendantCount:re.length,descendantIds:re,archivedBucket:Z})},e[27]=t,e[28]=F,e[29]=_,e[30]=W):W=e[30];const V=W;let K;e[31]!==t||e[32]!==_?(K=async()=>{if(!t.deleteSessionConfirm)return;const{session:G,archivedBucket:J,descendantIds:Z}=t.deleteSessionConfirm;t.setDeleteSessionConfirm(null),await _(G,{archivedBucket:J},{descendantIds:Z})},e[31]=t,e[32]=_,e[33]=K):K=e[33];const y=K;let I;e[34]!==t||e[35]!==n?(I=async G=>{await t.unarchiveSession(G.id)?Ee.success(n("sessions.sidebar.session.restore.success")):Ee.error(n("sessions.sidebar.session.restore.error"))},e[34]=t,e[35]=n,e[36]=I):I=e[36];const $=I;let z;return e[37]!==y||e[38]!==r||e[39]!==v||e[40]!==k||e[41]!==N||e[42]!==V||e[43]!==$||e[44]!==b||e[45]!==f||e[46]!==u||e[47]!==w||e[48]!==P?(z={copiedSessionId:r,handleSessionSelect:u,handleSessionDoubleClick:f,handleSaveEdit:b,handleCancelEdit:v,handleShareSession:w,handleCopyShareUrl:N,handleCopySessionId:k,handleUnshareSession:P,handleDeleteSession:V,handleRestoreSession:$,confirmDeleteSession:y},e[37]=y,e[38]=r,e[39]=v,e[40]=k,e[41]=N,e[42]=V,e[43]=$,e[44]=b,e[45]=f,e[46]=u,e[47]=w,e[48]=P,e[49]=z):z=e[49],z};function FS(t){return!t.time?.archived}function BS(t,e){return e?t:t.filter(FS)}function LS(t){return t.id}function _S(t){return t.id}const $S=t=>{const e=tt.c(26),{isVSCode:n,safeStorage:r,keys:o,groupOrderByProject:i,collapsedGroups:c,setExpandedParents:a,setCollapsedProjects:d}=t,u=l.useRef(null),h=l.useRef(null);let f;e[0]!==n?(f=()=>{if(n)return;const C=h.current;if(h.current=null,u.current=null,!C)return;const{projects:P}=qt.getState(),D=P.map(F=>({...F,sidebarCollapsed:C.has(F.id)}));tu({projects:D}).catch(zS)},e[0]=n,e[1]=f):f=e[1];const g=f;let b;e[2]!==g||e[3]!==n?(b=C=>{typeof window>"u"||n||(h.current=C,u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{g()},700))},e[2]=g,e[3]=n,e[4]=b):b=e[4];const S=b;let v,p;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>{typeof window<"u"&&u.current!==null&&window.clearTimeout(u.current),u.current=null,h.current=null},p=[],e[5]=v,e[6]=p):(v=e[5],p=e[6]),l.useEffect(v,p);let m,x;e[7]!==o.projectCollapse||e[8]!==o.sessionExpanded||e[9]!==r||e[10]!==d||e[11]!==a?(m=()=>{try{const C=r.getItem(o.sessionExpanded);if(C){const D=JSON.parse(C);Array.isArray(D)&&a(new Set(D.filter(US)))}const P=r.getItem(o.projectCollapse);if(P){const D=JSON.parse(P);Array.isArray(D)&&d(new Set(D.filter(WS)))}}catch{}},x=[o.projectCollapse,o.sessionExpanded,r,d,a],e[7]=o.projectCollapse,e[8]=o.sessionExpanded,e[9]=r,e[10]=d,e[11]=a,e[12]=m,e[13]=x):(m=e[12],x=e[13]),l.useEffect(m,x);let w,j;e[14]!==i||e[15]!==o.groupOrder||e[16]!==r?(w=()=>{try{const C=Object.fromEntries(i.entries());r.setItem(o.groupOrder,JSON.stringify(C))}catch{}},j=[i,o.groupOrder,r],e[14]=i,e[15]=o.groupOrder,e[16]=r,e[17]=w,e[18]=j):(w=e[17],j=e[18]),l.useEffect(w,j);let N,A;e[19]!==c||e[20]!==o.groupCollapse||e[21]!==r?(N=()=>{try{r.setItem(o.groupCollapse,JSON.stringify(Array.from(c)))}catch{}},A=[c,o.groupCollapse,r],e[19]=c,e[20]=o.groupCollapse,e[21]=r,e[22]=N,e[23]=A):(N=e[22],A=e[23]),l.useEffect(N,A);let k;return e[24]!==S?(k={scheduleCollapsedProjectsPersist:S},e[24]=S,e[25]=k):k=e[25],k};function zS(){}function US(t){return typeof t=="string"}function WS(t){return typeof t=="string"}const VS=5*6e4,HS=t=>{const e=tt.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:o,setProjectRepoStatus:i,setProjectRootBranches:c}=t,a=r===void 0?!0:r,{git:d}=tr(),u=mr(KS);let h,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==i?(h=()=>{if(!a||!d||n.length===0){i(new Map);return}n.forEach(A=>{Ra(()=>u(A.normalizedPath,d))})},f=[a,n,d,u,i],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=i,e[5]=h,e[6]=f):(h=e[5],f=e[6]),l.useEffect(h,f);let g,b;e[7]!==a||e[8]!==o||e[9]!==n||e[10]!==i?(g=()=>{if(!a)return;const A=new Map;n.forEach(k=>{A.set(k.id,o.get(k.normalizedPath)?.isGitRepo??null)}),i(A)},b=[a,n,o,i],e[7]=a,e[8]=o,e[9]=n,e[10]=i,e[11]=g,e[12]=b):(g=e[11],b=e[12]),l.useEffect(g,b);let S;if(e[13]!==o||e[14]!==n){let A;e[16]!==o?(A=k=>{const C=o.get(k.normalizedPath)?.branch??"";return`${k.id}:${C}`},e[16]=o,e[17]=A):A=e[17],S=n.map(A).join("|"),e[13]=o,e[14]=n,e[15]=S}else S=e[15];const v=S;let p;e[18]===Symbol.for("react.memo_cache_sentinel")?(p=new Map,e[18]=p):p=e[18];const m=l.useRef(p);let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[19]=x):x=e[19];const w=l.useRef(x);let j;e[20]!==a||e[21]!==o||e[22]!==n||e[23]!==c?(j=()=>{if(!a)return;let A=!1;const k=setTimeout(()=>{(async()=>{const P=new Set(n.map(GS));for(const W of m.current.keys())P.has(W)||(m.current.delete(W),w.current.delete(W));const D=Date.now(),F=n.filter(W=>{const V=o.get(W.normalizedPath);if(V?.isGitRepo===!1)return m.current.delete(W.id),w.current.delete(W.id),!1;if(V?.isGitRepo!==!0||V.branch===null)return!1;const K=V.branch.trim(),y=`${W.normalizedPath}\0${K}`,I=m.current.get(W.id);if(I===y){const $=w.current.get(W.id);return $&&($.at=D),!1}return!(I!==void 0&&D-(w.current.get(W.id)?.at??0)<VS)});if(F.length===0)return;const B=await Gh(F,2,async W=>{const V=o.get(W.normalizedPath)?.branch?.trim()??"",K=`${W.normalizedPath}\0${V}`,y=await Ra(()=>$i(W.normalizedPath,V?{knownBranch:V}:void 0)).catch(qS);return{id:W.id,inputKey:K,branch:y}});if(A)return;const E=B.filter(YS);if(E.length===0)return;const _=Date.now();c(W=>{const V=new Map(W);return E.forEach(K=>{const{id:y,branch:I}=K;I&&V.set(y,I)}),V}),E.forEach(W=>{const{id:V,inputKey:K,branch:y}=W;m.current.set(V,K),y&&w.current.set(V,{branch:y,at:_})})})()},150);return()=>{A=!0,clearTimeout(k)}},e[20]=a,e[21]=o,e[22]=n,e[23]=c,e[24]=j):j=e[24];let N;e[25]!==a||e[26]!==o||e[27]!==n||e[28]!==v||e[29]!==c?(N=[a,n,v,o,c],e[25]=a,e[26]=o,e[27]=n,e[28]=v,e[29]=c,e[30]=N):N=e[30],l.useEffect(j,N)};function KS(t){return t.ensureStatus}function GS(t){return t.id}function qS(){return null}function YS(t){return t.branch}const QS=t=>{const e=tt.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const o=r;let i;e[2]!==n?(i=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=i):i=e[3];const c=i;let a;return e[4]!==c||e[5]!==o?(a={getSessionsForProject:o,getArchivedSessionsForProject:c},e[4]=c,e[5]=o,e[6]=a):a=e[6],a},XS=t=>{const e=new Map;for(const n of t){const r=Us(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},JS=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,o)=>{e.has(o)||n.push(r)}),n},ZS=t=>{const e=tt.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:o}=t,i=n===void 0?!0:n,c=l.useRef(null);let a,d;e[0]!==i||e[1]!==r||e[2]!==o?(a=()=>{if(!i||!r)return;const u=xn(),h=XS(o),f=c.current?.runtimeKey===u?c.current.identities:null;for(const g of JS(f,h))qh({runtimeKey:u,...g});c.current={runtimeKey:u,identities:h}},d=[i,r,o],e[0]=i,e[1]=r,e[2]=o,e[3]=a,e[4]=d):(a=e[3],d=e[4]),l.useEffect(a,d)},e0=(t,e)=>t?e.kind!==t.kind?e.kind==="project":e.projectRoot.length!==t.projectRoot.length?e.projectRoot.length>t.projectRoot.length:e.projectId.localeCompare(t.projectId)<0:!0,ad=(t,e,n)=>{e0(t.get(e),n)&&t.set(e,n)},t0=t=>{const e=t;return wt(e.directory)??wt(e.project?.worktree)},s0=t=>{if(t==="/"||/^[A-Z]:$/.test(t))return null;const e=t.lastIndexOf("/");return e<0?null:e===0?"/":e===2&&/^[A-Z]:\//.test(t)?t.slice(0,2):t.slice(0,e)},n0=(t,e,n,r,o=[])=>{const i=new Map,c=new Map;for(const S of e){const v=wt(S.normalizedPath);if(!v)continue;const p=c.get(v);(!p||S.id.localeCompare(p.id)<0)&&c.set(v,S),ad(i,v,{projectId:S.id,projectRoot:v,scopeDirectory:v,kind:"project"})}if(!r)for(const[S,v]of n){const p=wt(S),m=p?c.get(p):void 0;if(!(!m||!p))for(const x of v){const w=wt(x.path);w&&ad(i,w,{projectId:m.id,projectRoot:p,scopeDirectory:w,kind:"worktree"})}}const a=new Map,d=new Map,u=new Map,h=new Map,f=new Map,g=S=>{if(!S)return null;if(a.has(S))return a.get(S)??null;if(r){const x=i.get(S)??null;return a.set(S,x),x}const v=[];let p=S,m=null;for(;p;){if(a.has(p)){m=a.get(p)??null;break}if(v.push(p),m=i.get(p)??null,m)break;p=s0(p)}for(const x of v)a.set(x,m);return m},b=(S,v,p)=>{for(const m of S){const x=g(t0(m));if(!x)continue;d.set(m.id,x);const w=v.get(x.projectId);if(w?w.push(m):v.set(x.projectId,[m]),!p)continue;const j=p.get(x.scopeDirectory);j?j.add(m.id):p.set(x.scopeDirectory,new Set([m.id]))}};return b(t,u,f),b(o,h),{bySessionId:d,sessionsByProject:u,archivedSessionsByProject:h,sessionsByScope:f,directoryResolutions:a.size}},r0=t=>{const e=tt.c(10),{enabled:n,isDesktopShellRuntime:r,projectSections:o,projectHeaderSentinelRefs:i}=t,c=n===void 0?!0:n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,e[0]=a):a=e[0];const[d,u]=l.useState(a);let h;e[1]!==c||e[2]!==r||e[3]!==i?(h=()=>{if(!c||!r){u(o0);return}const b=Array.from(i.current.values()).find(i0)?.closest(".oc-sidebar-scroller")??null;if(!b)return;const S=new IntersectionObserver(v=>{u(p=>{const m=new Set(p);let x=!1;for(const w of v){const j=w.target.dataset.projectId;if(!j)continue;const N=w.rootBounds?.top??b.getBoundingClientRect().top,A=!w.isIntersecting&&w.boundingClientRect.top<N;m.has(j)!==A&&(x=!0,A?m.add(j):m.delete(j))}return x?m:p})},{root:b,threshold:0});return i.current.forEach(v=>{v&&S.observe(v)}),()=>S.disconnect()},e[1]=c,e[2]=r,e[3]=i,e[4]=h):h=e[4];let f;return e[5]!==c||e[6]!==r||e[7]!==i||e[8]!==o?(f=[c,r,i,o],e[5]=c,e[6]=r,e[7]=i,e[8]=o,e[9]=f):f=e[9],l.useEffect(h,f),d};function o0(t){return t.size===0?t:new Set}function i0(t){return t!==null}const a0=t=>{const e=tt.c(10),{open:n,onOpenChange:r,project:o,onSave:i}=t;let c;e[0]!==i||e[1]!==n||e[2]!==o?(c=n&&o?s.jsx(Pg,{project:o,onIdentitySave:i,showWorktrees:!1}):null,e[0]=i,e[1]=n,e[2]=o,e[3]=c):c=e[3];let a;e[4]!==c?(a=s.jsx(Vs,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(Yn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-background",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:c})})}),e[4]=c,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(Ws,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function Lf(t){const e=tt.c(6),{state:n,activeLabel:r,unreadLabel:o,className:i}=t,c=n==="active"?r:o,a=n==="active"?"bg-primary":"bg-[var(--status-info)]";let d;e[0]!==i||e[1]!==a?(d=ye("h-1.5 w-1.5 shrink-0 rounded-full",a,i),e[0]=i,e[1]=a,e[2]=d):d=e[2];let u;return e[3]!==c||e[4]!==d?(u=s.jsx("span",{className:d,"aria-label":c,title:c}),e[3]=c,e[4]=d,e[5]=u):u=e[5],u}const l0=t=>{const e=tt.c(86),{folder:n,displayName:r,sessions:o,subFolderItems:i,isCollapsed:c,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:h,renderSessionNode:f,getRenderExtras:g,groupDirectory:b,projectId:S,mobileVariant:v,alwaysShowActions:p,isRenaming:m,renameDraft:x,onRenameDraftChange:w,onRenameSave:j,onRenameCancel:N,droppableRef:A,isDropTarget:k,onNewSession:C,depth:P,hideActions:D,archivedBucket:F}=t,B=a===void 0?null:a,_=p===void 0?v===void 0?!1:v:p,W=m===void 0?!1:m,V=x===void 0?"":x,K=k===void 0?!1:k,y=D===void 0?!1:D,I=F===void 0?!1:F,{t:$}=mt(),[z,G]=l.useState(!1),[J,Z]=l.useState(""),re=l.useRef(null),ee=W||z,he=W?V:J;let be;e[0]!==n.name?(be=()=>{Z(n.name),G(!0)},e[0]=n.name,e[1]=be):be=e[1];const Y=be;let we;e[2]!==he||e[3]!==n.name||e[4]!==W||e[5]!==u||e[6]!==j?(we=()=>{const se=he.trim();se&&se!==n.name&&u(se),W&&j&&j(),G(!1),Z("")},e[2]=he,e[3]=n.name,e[4]=W,e[5]=u,e[6]=j,e[7]=we):we=e[7];const me=we;let Q;e[8]!==W||e[9]!==N?(Q=()=>{W&&N&&N(),G(!1),Z("")},e[8]=W,e[9]=N,e[10]=Q):Q=e[10];const pe=Q;let ve;e[11]!==W||e[12]!==w?(ve=se=>{W&&w?w(se):Z(se)},e[11]=W,e[12]=w,e[13]=ve):ve=e[13];const Te=ve;let ke,Ie;e[14]!==W?(ke=()=>{if(!W)return;const se=()=>{const je=re.current;je&&(je.focus(),je.select())},T=requestAnimationFrame(se),ie=window.setTimeout(se,0);return()=>{cancelAnimationFrame(T),window.clearTimeout(ie)}},Ie=[W],e[14]=W,e[15]=ke,e[16]=Ie):(ke=e[15],Ie=e[16]),l.useEffect(ke,Ie);const Ne=c?"folder":"folder-open",Ae=K&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let Se;e[17]!==Ae?(Se=ye("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",Ae),e[17]=Ae,e[18]=Se):Se=e[18];let Oe;e[19]!==d||e[20]!==ee?(Oe=ee?void 0:se=>{se.currentTarget.blur(),d()},e[19]=d,e[20]=ee,e[21]=Oe):Oe=e[21];const ne=ee?void 0:"button",ce=ee?void 0:0;let Re;e[22]!==d||e[23]!==ee?(Re=ee?void 0:se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),d())},e[22]=d,e[23]=ee,e[24]=Re):Re=e[24];let te;e[25]!==n.name||e[26]!==c||e[27]!==$?(te=c?$("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):$("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=c,e[27]=$,e[28]=te):te=e[28];const ae=I?_?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":_?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let de;e[29]!==ae?(de=ye("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",ae),e[29]=ae,e[30]=de):de=e[30];const H=K?"text-primary":"text-muted-foreground";let ge;e[31]!==H?(ge=ye("h-3.5 w-3.5 flex-shrink-0",H),e[31]=H,e[32]=ge):ge=e[32];let ue;e[33]!==Ne||e[34]!==ge?(ue=s.jsx(R,{name:Ne,className:ge}),e[33]=Ne,e[34]=ge,e[35]=ue):ue=e[35];let M;e[36]!==B||e[37]!==r||e[38]!==he||e[39]!==n.name||e[40]!==pe||e[41]!==Te||e[42]!==me||e[43]!==c||e[44]!==K||e[45]!==ee||e[46]!==o||e[47]!==$?(M=ee?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:d0,onMouseDown:u0,onSubmit:se=>{se.preventDefault(),me()},children:[s.jsx("input",{ref:re,value:he,onChange:se=>Te(se.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:$("sessions.sidebar.folderItem.namePlaceholder"),onClick:f0,onPointerDown:m0,onMouseDown:h0,onKeyDown:se=>{if(se.key==="Escape"){se.stopPropagation(),pe();return}(se.key===" "||se.key==="Enter")&&se.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:p0,onPointerDown:g0,onMouseDown:x0,children:s.jsx(R,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),pe()},onPointerDown:b0,onMouseDown:y0,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("span",{className:ye("typography-ui-label font-semibold truncate",K?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(ft,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",o.length]}),B?s.jsx(Lf,{state:B,activeLabel:$("sessions.sidebar.session.status.active"),unreadLabel:$("sessions.sidebar.session.status.unread")}):null,c?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=B,e[37]=r,e[38]=he,e[39]=n.name,e[40]=pe,e[41]=Te,e[42]=me,e[43]=c,e[44]=K,e[45]=ee,e[46]=o,e[47]=$,e[48]=M):M=e[48];let oe;e[49]!==de||e[50]!==ue||e[51]!==M?(oe=s.jsxs("div",{className:de,children:[ue,M]}),e[49]=de,e[50]=ue,e[51]=M,e[52]=oe):oe=e[52];let De;e[53]!==_||e[54]!==I||e[55]!==n.name||e[56]!==Y||e[57]!==y||e[58]!==h||e[59]!==C||e[60]!==ee||e[61]!==$?(De=!ee&&(!y||I)?s.jsx("div",{className:ye("absolute right-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-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!I&&C?s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),C()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":$("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:$("sessions.sidebar.project.actions.newSession"),children:s.jsx(R,{name:"add",className:"h-3.5 w-3.5"})}):null,I?null:s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),Y()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":$("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(R,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),h()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":I?$("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):$("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=_,e[54]=I,e[55]=n.name,e[56]=Y,e[57]=y,e[58]=h,e[59]=C,e[60]=ee,e[61]=$,e[62]=De):De=e[62];let fe;e[63]!==A||e[64]!==Se||e[65]!==Oe||e[66]!==ne||e[67]!==ce||e[68]!==Re||e[69]!==te||e[70]!==oe||e[71]!==De?(fe=s.jsxs("div",{ref:A,className:Se,onClick:Oe,role:ne,tabIndex:ce,onKeyDown:Re,"aria-label":te,children:[oe,De]}),e[63]=A,e[64]=Se,e[65]=Oe,e[66]=ne,e[67]=ce,e[68]=Re,e[69]=te,e[70]=oe,e[71]=De,e[72]=fe):fe=e[72];let X;e[73]!==I||e[74]!==g||e[75]!==b||e[76]!==c||e[77]!==S||e[78]!==f||e[79]!==o||e[80]!==i||e[81]!==$?(X=c?null:s.jsxs("div",{className:"pb-1",children:[i,o.length>0?o.map(se=>f(se,0,b??null,S??null,I,void 0,"project",g?.(se))):i?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:$("sessions.sidebar.folderItem.emptyFolder")})]}),e[73]=I,e[74]=g,e[75]=b,e[76]=c,e[77]=S,e[78]=f,e[79]=o,e[80]=i,e[81]=$,e[82]=X):X=e[82];let le;return e[83]!==fe||e[84]!==X?(le=s.jsxs("div",{className:"oc-folder",children:[fe,X]}),e[83]=fe,e[84]=X,e[85]=le):le=e[85],le},c0=l.memo(l0);function d0(t){return t.stopPropagation()}function u0(t){return t.stopPropagation()}function f0(t){return t.stopPropagation()}function m0(t){return t.stopPropagation()}function h0(t){return t.stopPropagation()}function p0(t){return t.stopPropagation()}function g0(t){return t.stopPropagation()}function x0(t){return t.stopPropagation()}function b0(t){return t.stopPropagation()}function y0(t){return t.stopPropagation()}const v0=t=>{const e=tt.c(15),{sessionId:n,sessionDirectory:r,sessionTitle:o,children:i}=t,c=`session-drag:${n}`;let a;e[0]!==r||e[1]!==n||e[2]!==o?(a={type:"session",sessionId:n,sessionDirectory:r,sessionTitle:o},e[0]=r,e[1]=n,e[2]=o,e[3]=a):a=e[3];let d;e[4]!==c||e[5]!==a?(d={id:c,data:a},e[4]=c,e[5]=a,e[6]=d):d=e[6];const{attributes:u,listeners:h,setNodeRef:f,isDragging:g}=sx(d);let b;e[7]!==h?(b=m=>{m.stopPropagation(),h?.onPointerDown&&h.onPointerDown(m)},e[7]=h,e[8]=b):b=e[8];const S=b,v=g?"opacity-30":void 0;let p;return e[9]!==u||e[10]!==i||e[11]!==S||e[12]!==f||e[13]!==v?(p=s.jsx("div",{ref:f,...u,onPointerDown:S,className:v,children:i}),e[9]=u,e[10]=i,e[11]=S,e[12]=f,e[13]=v,e[14]=p):p=e[14],p},w0=t=>{const e=tt.c(11),{folderId:n,children:r}=t,o=`folder-drop:${n}`;let i;e[0]!==n?(i={type:"folder",folderId:n},e[0]=n,e[1]=i):i=e[1];let c;e[2]!==o||e[3]!==i?(c={id:o,data:i},e[2]=o,e[3]=i,e[4]=c):c=e[4];const{setNodeRef:a,isOver:d}=tx(c);let u;e[5]!==r||e[6]!==d||e[7]!==a?(u=r(a,d),e[5]=r,e[6]=d,e[7]=a,e[8]=u):u=e[8];let h;return e[9]!==u?(h=s.jsx(s.Fragment,{children:u}),e[9]=u,e[10]=h):h=e[10],h},S0=t=>{const e=tt.c(20),{scopeKey:n,hasFolders:r,onSessionDroppedOnFolder:o,children:i}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activationConstraint:{distance:8}},e[0]=c):c=e[0];const a=wi(Yr(Ba,c)),[d,u]=l.useState(null),[h,f]=l.useState("Session"),[g,b]=l.useState(null),[S,v]=l.useState(null);if(!n){let k;return e[1]!==i?(k=s.jsx(s.Fragment,{children:i}),e[1]=i,e[2]=k):k=e[2],k}let p;e[3]!==o?(p=k=>{u(null),b(null),v(null);const{active:C,over:P}=k;if(!P)return;const D=C.data.current,F=P.data.current;D?.type==="session"&&D.sessionId&&F?.type==="folder"&&F.folderId&&o(D.sessionId,F.folderId)},e[3]=o,e[4]=p):p=e[4];const m=p;let x,w;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=k=>{const C=k.active.data.current;if(C?.type==="session"&&C.sessionId){u(C.sessionId),f(C.sessionTitle??"Session");const P=k.active.rect.current.initial?.width,D=k.active.rect.current.initial?.height;b(typeof P=="number"?P:null),v(typeof D=="number"?D:null)}},w=()=>{u(null),b(null),v(null)},e[5]=x,e[6]=w):(x=e[5],w=e[6]);let j;e[7]!==S||e[8]!==d||e[9]!==h||e[10]!==g||e[11]!==r?(j=d&&r?s.jsxs("div",{style:{width:g?`${g}px`:"auto",height:S?`${S}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(R,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:h})]}):null,e[7]=S,e[8]=d,e[9]=h,e[10]=g,e[11]=r,e[12]=j):j=e[12];let N;e[13]!==j?(N=s.jsx(La,{children:j}),e[13]=j,e[14]=N):N=e[14];let A;return e[15]!==i||e[16]!==m||e[17]!==a||e[18]!==N?(A=s.jsxs(Si,{sensors:a,collisionDetection:ji,onDragStart:x,onDragCancel:w,onDragEnd:m,children:[i,N]}),e[15]=i,e[16]=m,e[17]=a,e[18]=N,e[19]=A):A=e[19],A},Xa=(t,e,n)=>{if(!e)return;const r=o=>{let i=o.session.id===e;for(const c of o.children)i=r(c)||i;return i&&n.add(o.session.id),i};for(const o of t)r(o)},Gn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Gn(n,e))return!0;return!1},j0=(t,e,n)=>{const r=new Map,o=i=>{const c=Us(i.session)??wt(i.worktree?.path)??n;if(c){const a=r.get(c)??[];a.push(i.session.id),r.set(c,a)}if(!(i===t&&e))for(const a of i.children)o(a)};return o(t),[...r].map(([i,c])=>({directory:i,sessionIDs:c}))},k0=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const o=new Set;let i=r.session.parentID??null;for(;i&&!o.has(i);){if(n.has(i)&&e.has(i))return!1;o.add(i),i=e.get(i)?.session?.parentID??null}return!0})},ld=new WeakMap;let cd=1;const C0=t=>{const e=ld.get(t);if(e!==void 0)return e;const n=cd;return cd+=1,ld.set(t,n),n},Ei=t=>t.children.length===0?"":t.children.map(n=>{const r=C0(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Ei(n)}`}).join("|"),_f=(t,e,n,r,o,i)=>{const c=xn(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const h=d.session.directory??o,f=u.session.directory??i,g=nc(c,h??"",d.session.id),b=nc(c,f??"",u.session.id);return(g?n.has(g):!1)!==(b?r.has(b):!1)?!0:d.children.some((S,v)=>a(S,u.children[v]))};return a(t,e)},To=(t,e,n,r)=>{if(!e)return null;const o=r?"archived":"active";let i=null;const c=a=>{if(`${n}:${o}:${a.session.id}`===e)return i=a.session.id,!0;for(const u of a.children)if(c(u))return!0;return!1};return t.forEach(a=>c(a)),i},Pl=(t,e)=>t==="active"||e==="active"?"active":t==="unread"||e==="unread"?"unread":null,$f=(t,e,n,r)=>{if(e.has(t.session.id))return"active";let o=null;const i=!!t.session.parentID;n.has(t.session.id)&&(r||!i)&&(o="unread");for(const c of t.children)if(o=Pl(o,$f(c,e,n,r)),o==="active")return o;return o},dd=(t,e,n,r)=>{let o=null;for(const i of t)if(o=Pl(o,$f(i,e,n,r)),o==="active")return o;return o},N0=50,A0=28,Qo=(t,e)=>e?t.sessions.some(n=>Gn(n,e)):!1,D0=(t,e,n)=>t.sessions.some(r=>_f(r,r,e,n,t.directory,t.directory)),P0=(t,e,n)=>{const r=o=>{const i=o.session.id;return e.get(i)!==n.get(i)?!0:o.children.some(r)};return t.sessions.some(r)},ud=(t,e,n)=>{const r=o=>e.has(o.session.id)!==n.has(o.session.id)?!0:o.children.some(r);return t.sessions.some(r)},E0=(t,e)=>{const n=r=>e.has(r.session.id)?!0:r.children.some(n);return t.sessions.some(n)},T0=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",o=i=>{const c=`project:${r}:${i.session.id}`;return e.has(c)!==n.has(c)?!0:i.children.some(o)};return t.sessions.some(o)},I0=(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.collapsedGroups!==e.collapsedGroups&&t.collapsedGroups.has(t.groupKey)!==e.collapsedGroups.has(e.groupKey)||t.pinnedSessionIds!==e.pinnedSessionIds&&D0(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.expandedParents!==e.expandedParents&&T0(e.group,t.expandedParents,e.expandedParents)||t.sessionOrderIndex!==e.sessionOrderIndex&&P0(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.editingId!==e.editingId&&(Qo(t.group,t.editingId)||Qo(e.group,e.editingId))||t.editTitle!==e.editTitle&&(Qo(t.group,t.editingId)||Qo(e.group,e.editingId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=To(t.group.sessions,t.openSidebarMenuKey,"project",!!t.group.isArchivedBucket),r=To(e.group.sessions,e.openSidebarMenuKey,"project",!!e.group.isArchivedBucket);if(n||r)return!1}return t.activeActivitySessionIds!==e.activeActivitySessionIds&&ud(e.group,t.activeActivitySessionIds,e.activeActivitySessionIds)||t.unreadActivitySessionIds!==e.unreadActivitySessionIds&&ud(e.group,t.unreadActivitySessionIds,e.unreadActivitySessionIds)||t.notifyOnSubtasks!==e.notifyOnSubtasks&&E0(e.group,e.unreadActivitySessionIds)?!1:t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.collapsedFolderIds===e.collapsedFolderIds&&t.toggleFolderCollapse===e.toggleFolderCollapse&&t.renameFolder===e.renameFolder&&t.deleteFolder===e.deleteFolder&&t.showDeletionDialog===e.showDeletionDialog&&t.setDeleteFolderConfirm===e.setDeleteFolderConfirm&&t.renderSessionNode===e.renderSessionNode&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.activeProjectId===e.activeProjectId&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setActiveMainTab===e.setActiveMainTab&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.addSessionToFolder===e.addSessionToFolder&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.renamingFolderId===e.renamingFolderId&&t.renameFolderDraft===e.renameFolderDraft&&t.setRenameFolderDraft===e.setRenameFolderDraft&&t.setRenamingFolderId===e.setRenamingFolderId&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.scrollContainerRef===e.scrollContainerRef};function R0(t){const{t:e}=mt(),{group:n,groupKey:r,projectId:o,hideGroupLabel:i,hasSessionSearchQuery:c,normalizedSessionSearchQuery:a,groupSearchDataByGroup:d,visibleSessionCount:u,collapsedGroups:h,hideDirectoryControls:f,collapsedFolderIds:g,toggleFolderCollapse:b,renameFolder:S,deleteFolder:v,showDeletionDialog:p,setDeleteFolderConfirm:m,renderSessionNode:x,showMoreGroupSessions:w,resetGroupSessionLimit:j,mobileVariant:N,alwaysShowActions:A,activeProjectId:k,setActiveProjectIdOnly:C,setActiveMainTab:P,setSessionSwitcherOpen:D,openNewSessionDraft:F,addSessionToFolder:B,createFolderAndStartRename:E,renamingFolderId:_,renameFolderDraft:W,setRenameFolderDraft:V,setRenamingFolderId:K,pinnedSessionIds:y,expandedParents:I,sessionOrderIndex:$,editingId:z,openSidebarMenuKey:G,activeActivitySessionIds:J,unreadActivitySessionIds:Z,notifyOnSubtasks:re,onToggleCollapsedGroup:ee,dragHandleProps:he,compactBodyPadding:be=!1,scrollContainerRef:Y}=t,we=l.useCallback((Me,Ke)=>{const ze=$.get(Me.session.id),He=$.get(Ke.session.id);if(ze!==void 0||He!==void 0){if(ze===void 0)return 1;if(He===void 0)return-1;if(ze!==He)return ze-He}return to(Me.session,Ke.session,y,ul)},[y,$]),me=c?d.get(n):null,Q=Fs(Me=>Me.foldersMap),pe=c?!1:h.has(r),ve=l.useMemo(()=>{if(n.isMain||n.isArchivedBucket||i)return null;const Me=wt(n.directory??null),Ke=n.branch?.trim();return Me&&Ke?Li(Me,Ke):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,i]),Te=Nu(ve),ke=Te?`var(--pr-${Te.visualState})`:void 0,Ie=Au(),Ne=l.useMemo(()=>{const Me=n.folderScopes?.map(Ke=>wt(Ke.directory))??[wt(n.directory??null)];return[...new Set(Me.filter(Ke=>!!Ke))]},[n.directory,n.folderScopes]);l.useSyncExternalStore(l.useCallback(Me=>Ne.length>0?Ie.subscribeBootstrap(Me):()=>{},[Ne.length,Ie]),l.useCallback(()=>Ne.map(Me=>`${Me}\0${Ie.getBootstrapState(Me)??""}\0${Ie.getBootstrapFailure(Me)??""}`).join(""),[Ne,Ie]),l.useCallback(()=>"",[]));const Ae=Ne.some(Me=>{const Ke=Ie.getBootstrapState(Me);return Ke==="queued"||Ke==="running"}),Se=Ne.find(Me=>Ie.getBootstrapState(Me)==="failed")??null,Oe=Se?Ie.getBootstrapFailure(Se):void 0,ne=Oe==="os-permission"&&_m(),[ce,Re]=l.useState(!1),te=l.useCallback(()=>{Se&&Ie.requestBootstrap({directory:Se,priority:pe?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[Ie,Se,n.isMain,pe]),ae=l.useCallback(async()=>{if(!(!Se||!ne||ce)){Re(!0);try{(await $m(Se)).success&&te()}finally{Re(!1)}}},[ne,Se,ce,te]),de=f?10:5,H=Math.max(de,u??de),ge=c?me?.groupMatches===!0:!1,ue=c,M=l.useMemo(()=>[...ue?me?.filteredNodes??[]:n.sessions].sort(we),[we,n.sessions,me?.filteredNodes,ue]),oe=n.folderScopeKey??wt(n.directory??null),De=l.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:oe?[{scopeKey:oe,directory:n.directory??null}]:[],[oe,n.directory,n.folderScopes]),fe=l.useMemo(()=>De.flatMap(({scopeKey:Me,directory:Ke})=>(Q[Me]??[]).map(ze=>({folder:ze,scopeKey:Me,scopeDirectory:Ke}))),[De,Q]),X=l.useMemo(()=>{const Me=new Map,Ke=ze=>{ze.forEach(He=>{Me.set(He.session.id,He),He.children.length>0&&Ke(He.children)})};return Ke(M),Me},[M]),le=l.useMemo(()=>fe.map(({folder:Me,scopeKey:Ke,scopeDirectory:ze})=>{const He=k0(Me.sessionIds,X).sort(we);return{folder:Me,scopeKey:Ke,scopeDirectory:ze,nodes:He}}),[fe,X,we]),se=l.useMemo(()=>{const Me=new Map(le.map(Ve=>[Ve.folder.id,Ve])),Ke=new Map;for(const{folder:Ve}of le){if(!Ve.parentId)continue;const jt=Ke.get(Ve.parentId);jt?jt.push(Ve.id):Ke.set(Ve.parentId,[Ve.id])}const ze=new Map,He=Ve=>{const jt=ze.get(Ve);if(jt!==void 0)return jt;const Jt=Me.get(Ve);if(!Jt)return ze.set(Ve,!1),!1;const yt=Ke.get(Ve)??[];if(n.isArchivedBucket&&Jt.nodes.length===0){const Zt=yt.some(Ss=>He(Ss));return ze.set(Ve,Zt),Zt}if(!c||Jt.folder.name.toLowerCase().includes(a)||Jt.nodes.length>0)return ze.set(Ve,!0),!0;const ps=yt.some(Zt=>He(Zt));return ze.set(Ve,ps),ps};return le.filter(({folder:Ve})=>He(Ve.id))},[le,n.isArchivedBucket,c,a]),T=l.useMemo(()=>new Set(se.flatMap(Me=>Me.folder.sessionIds)),[se]),ie=l.useMemo(()=>M.filter(Me=>!T.has(Me.session.id)),[M,T]),je=l.useMemo(()=>se.filter(({folder:Me})=>!Me.parentId),[se]),Pe=l.useMemo(()=>{const Me=new Map;return se.forEach(Ke=>{if(!Ke.folder.parentId)return;const ze=Me.get(Ke.folder.parentId)??[];ze.push(Ke),Me.set(Ke.folder.parentId,ze)}),Me},[se]),U=l.useMemo(()=>{const Me=new Map(se.map(He=>[He.folder.id,He])),Ke=new Map,ze=(He,Ve)=>{const jt=Ke.get(He);if(jt!==void 0)return jt;if(Ve.has(He))return null;Ve.add(He);const Jt=Me.get(He);let yt=Jt?dd(Jt.nodes,J,Z,re):null;for(const Yt of Pe.get(He)??[])if(yt=Pl(yt,ze(Yt.folder.id,Ve)),yt==="active")break;return Ke.set(He,yt),yt};return se.forEach(({folder:He})=>ze(He.id,new Set)),Ke},[J,se,Pe,re,Z]),Be="project",Fe=l.useMemo(()=>{const Me=new Set;return Xa(M,z,Me),se.forEach(({nodes:Ke})=>{Xa(Ke,z,Me)}),Me},[M,se,z]),Ye=l.useMemo(()=>{if(!G)return null;const Me=To(M,G,Be,!!n.isArchivedBucket);if(Me)return Me;for(const{nodes:Ke}of se){const ze=To(Ke,G,Be,!!n.isArchivedBucket);if(ze)return ze}return null},[G,M,se,n.isArchivedBucket]),at=l.useCallback(Me=>{const Ke=new WeakMap,ze=He=>{Ke.set(He,Ei(He));for(const Ve of He.children)ze(Ve)};return Me.forEach(ze),Ke},[]),st=l.useMemo(()=>at(M),[at,M]),ct=l.useMemo(()=>{const Me=new WeakMap;return se.forEach(({nodes:Ke})=>{Ke.forEach(ze=>Me.set(ze,Ei(ze)))}),Me},[se]),bt=l.useCallback(Me=>st.get(Me)??ct.get(Me)??"",[st,ct]),rt=l.useCallback(Me=>({subtreeContainsEditing:Fe,menuOpenSessionId:Ye,nodeStructureKey:bt(Me)}),[Fe,Ye,bt]),gt=ie.length,it=n.isArchivedBucket||c?ie:ie.slice(0,H),Et=gt-it.length,Ft=!n.isArchivedBucket&&!c&>>de&&Et===0,Dt=n.isArchivedBucket===!0&&!c&&it.length>=N0,Bt=n.isArchivedBucket?"archived":"active",qe=Dt&&it.some(Me=>{if(Me.children.length===0)return!1;const Ke=`project:${Bt}:${Me.session.id}`;return I.has(Ke)}),zt=l.useRef(null),[Nt,xt]=l.useState(null),[Pt,Mt]=l.useState(0),[,Xt]=l.useState(0);l.useEffect(()=>{if(!Dt)return;const Me=zt.current;if(!Me||typeof ResizeObserver>"u")return;const Ke=new ResizeObserver(()=>Xt(ze=>ze+1));return Ke.observe(Me),()=>Ke.disconnect()},[Dt]),l.useLayoutEffect(()=>{if(!Dt){Nt!==null&&xt(null),Pt!==0&&Mt(0);return}const Me=zt.current;if(!Me)return;let Ke=Nt;const ze=Y?.current??null;if(ze&&ze.contains(Me)){if(Ke=ze,Ke!==Nt){xt(Ke);return}}else if(!Ke||!Ke.contains(Me)){let Ve=Me.parentElement;for(;Ve;){const jt=window.getComputedStyle(Ve);if(jt.overflowY==="auto"||jt.overflowY==="scroll"){Ke=Ve;break}Ve=Ve.parentElement}if(Ke!==Nt){xt(Ke);return}}if(!Ke)return;const He=Me.getBoundingClientRect().top-Ke.getBoundingClientRect().top+Ke.scrollTop;Mt(Ve=>Math.abs(Ve-He)<1?Ve:He)});const Qe=Dt&&Nt!==null,ht=ox({count:it.length,enabled:Qe,getScrollElement:()=>Nt,initialOffset:()=>Nt?.scrollTop??0,estimateSize:()=>A0,overscan:qe?20:8,scrollMargin:Pt,getItemKey:Me=>it[Me]?.session.id??Me}),Ze=l.useCallback(Me=>{const Ke=[],ze=He=>{He.forEach(Ve=>{Ke.push(Ve.session),Ve.children.length>0&&ze(Ve.children)})};return ze(Me),Ke},[]),$e=l.useMemo(()=>Ze(M),[Ze,M]),St=l.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const Me=new Map,Ke=new Map;for(const{folder:He}of se){if(!He.parentId)continue;const Ve=Ke.get(He.parentId)??[];Ve.push(He.id),Ke.set(He.parentId,Ve)}const ze=(He,Ve)=>{if(Ve.has(He))return[];Ve.add(He);const jt=se.find(({folder:Yt})=>Yt.id===He),Jt=jt?Ze(jt.nodes):[],yt=Ke.get(He)??[];for(const Yt of yt)Jt.push(...ze(Yt,Ve));return Jt};for(const{folder:He}of se)Me.set(He.id,ze(He.id,new Set));return Me},[se,Ze,n.isArchivedBucket]);if(c&&!ge&&je.length===0&&ie.length===0)return null;const Lt=!n.isMain&&!!n.branch,Ot=n.branch&&Yh(n.branch,n.label)?{label:n.branch}:null,ss=pe?dd(M,J,Z,re):null,_t=ss?s.jsx(Lf,{state:ss,activeLabel:e("sessions.sidebar.session.status.active"),unreadLabel:e("sessions.sidebar.session.status.unread")}):null,Ct=(Me,Ke)=>{const{folder:ze,scopeKey:He,scopeDirectory:Ve,nodes:jt}=Me,Jt=St.get(ze.id)??[],yt=c?!1:g.has(ze.id);return s.jsx(w0,{folderId:ze.id,children:(Yt,ps)=>s.jsx(c0,{folder:ze,displayName:Ke,sessions:jt,isCollapsed:yt,collapsedActivityState:yt?U.get(ze.id)??null:null,onToggle:()=>b(ze.id),onRename:Zt=>{S(He,ze.id,Zt)},onDelete:()=>{if(n.isArchivedBucket){_n.requestDelete({sessions:Jt,mode:"session"});return}if(!p){v(He,ze.id);return}const Zt=se.filter(({folder:en})=>en.parentId===ze.id).length,Ss=jt.length;m({scopeKey:He,folderId:ze.id,folderName:ze.name,subFolderCount:Zt,sessionCount:Ss})},renderSessionNode:x,getRenderExtras:bt?Zt=>({subtreeContainsEditing:Fe,menuOpenSessionId:Ye,nodeStructureKey:bt(Zt),childRenderExtrasFor:rt}):void 0,groupDirectory:Ve??n.directory,projectId:o,mobileVariant:N,alwaysShowActions:A,isRenaming:_===ze.id,renameDraft:_===ze.id?W:void 0,onRenameDraftChange:Zt=>V(Zt),onRenameSave:()=>{const Zt=W.trim();Zt&&S(He,ze.id,Zt),K(null),V("")},onRenameCancel:()=>{K(null),V("")},droppableRef:Yt,isDropTarget:ps,depth:0,onNewSession:()=>{o&&o!==k&&C(o),P("chat"),N&&D(!1),F({selectedProjectId:o,directoryOverride:Ve??n.directory,targetFolderId:ze.id})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0})},ze.id)},os=()=>{const Me=new Map;for(const He of se){const Ve=He.folder.parentId;if(!Ve)continue;const jt=Me.get(Ve);jt?jt.push(He):Me.set(Ve,[He])}const Ke=[],ze=(He,Ve)=>{const jt=Ve?`${Ve} / ${He.folder.name}`:He.folder.name;Ke.push(Ct(He,jt)),!(!c&&g.has(He.folder.id))&&(Me.get(He.folder.id)??[]).forEach(yt=>ze(yt,jt))};return je.forEach(He=>ze(He,"")),Ke},hs=!!(!n.isMain&&n.worktree),Rt=A?hs?"pr-14":"pr-7":hs?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",$t=Se?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Oe==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":"sessions.sidebar.group.empty.loadFailed"),ne?s.jsx(nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:ce,onClick:()=>{ae()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:te,children:e("sessions.sidebar.group.empty.retry")})]}):null,Wt=s.jsxs(S0,{scopeKey:De[0]?.scopeKey??oe,hasFolders:se.length>0,onSessionDroppedOnFolder:(Me,Ke)=>{const ze=se.find(({folder:Ve})=>Ve.id===Ke);if(!ze)return;const He=Fs.getState();for(const{scopeKey:Ve}of De)Ve!==ze.scopeKey&&He.getSessionFolderId(Ve,Me)&&He.removeSessionFromFolder(Ve,Me);B(ze.scopeKey,Ke,Me)},children:[os(),Dt?s.jsx("div",{ref:zt,children:Qe?s.jsx("div",{style:{height:ht.getTotalSize(),position:"relative"},children:ht.getVirtualItems().map(Me=>{const Ke=it[Me.index];return Ke?s.jsx("div",{"data-index":Me.index,ref:ht.measureElement,className:"[&_[data-session-row]]:my-px",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${Me.start-Pt}px)`},children:x(Ke,0,n.directory,o,n.isArchivedBucket===!0,void 0,"project",{subtreeContainsEditing:Fe,menuOpenSessionId:Ye,nodeStructureKey:bt(Ke),childRenderExtrasFor:rt})},Ke.session.id):null})}):it.map(Me=>x(Me,0,n.directory,o,n.isArchivedBucket===!0,void 0,"project",{subtreeContainsEditing:Fe,menuOpenSessionId:Ye,nodeStructureKey:bt(Me),childRenderExtrasFor:rt}))}):it.map(Me=>x(Me,0,n.directory,o,n.isArchivedBucket===!0,void 0,"project",{subtreeContainsEditing:Fe,menuOpenSessionId:Ye,nodeStructureKey:bt(Me),childRenderExtrasFor:rt})),gt===0&&se.length===0?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):Ae?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(R,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):$t||e("sessions.sidebar.group.empty.noSessionsInWorkspace")}):null,gt>0&&$t?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:$t}):null,Et>0?s.jsx("button",{type:"button",onClick:()=>w(r,it.length),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,Ft?s.jsx("button",{type:"button",onClick:()=>j(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),is="pb-2";return i?s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:ye("oc-group-body",is),children:Wt})}):s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:ye("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>ee(r),role:"button",tabIndex:0,onKeyDown:Me=>{(Me.key==="Enter"||Me.key===" ")&&(Me.preventDefault(),ee(r))},"aria-label":pe?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!pe,children:[s.jsx("div",{ref:he?.setActivatorNodeRef,className:ye("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",Rt),...he?.listeners??{},children:s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[s.jsx("p",{className:"text-[14px] font-normal truncate text-foreground/92",children:n.isArchivedBucket?s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(R,{name:"archive",className:ye("h-3.5 w-3.5 shrink-0 text-muted-foreground",A?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:ye("text-muted-foreground h-3.5 w-3.5 items-center justify-center",A?"inline-flex":"hidden group-hover/gh:inline-flex"),children:pe?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:oi(n.label,a)}),_t]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(R,{name:"git-branch",className:ye("h-3.5 w-3.5 shrink-0",!ke&&"text-muted-foreground",A?"hidden":"group-hover/gh:hidden"),style:ke?{color:ke}:void 0}),s.jsx("span",{className:ye("text-muted-foreground h-3.5 w-3.5 items-center justify-center",A?"inline-flex":"hidden group-hover/gh:inline-flex"),children:pe?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:oi(n.label,a)}),_t,Te?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:ke?{color:ke}:void 0,children:["#",Te.number]}):null]}):s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsx("span",{className:"min-w-0 truncate",children:oi(n.label,a)}),_t]})}),Lt&&Ot?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(R,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:Ot.label})]}):null]})}),n.isArchivedBucket&&$e.length>0?s.jsx("div",{className:ye("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",A?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),_n.requestDelete({sessions:$e,mode:"session"})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree?s.jsx("div",{className:ye("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",A?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),_n.requestDelete({sessions:$e,mode:"worktree",worktree:n.worktree})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:ye("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",A?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),o&&o!==k&&C(o),P("chat"),N&&D(!1),F({selectedProjectId:o,directoryOverride:n.directory})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(R,{name:"add",className:"h-4 w-4"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),pe?null:s.jsx("div",{className:ye("oc-group-body",is),children:Wt})]})}const M0=l.memo(R0,I0),O0=(t,e)=>{const n=t??{};return e<2&&(n.projectSortOrder="manual"),e<3&&n.projectSortOrder==="recent"&&(n.projectSortOrder="manual"),e<4&&delete n.displayMode,n},As=xr()(Yu(t=>({sessionGroupingMode:"by-worktree",setSessionGroupingMode:e=>t({sessionGroupingMode:e}),stickyZoneHeaders:!0,toggleStickyZoneHeaders:()=>t(e=>({stickyZoneHeaders:!e.stickyZoneHeaders})),showRecentSection:!0,showArchivedSessions:!1,projectSortOrder:"manual",setShowRecentSection:e=>t({showRecentSection:e}),setShowArchivedSessions:e=>t({showArchivedSessions:e}),toggleRecentSection:()=>t(e=>({showRecentSection:!e.showRecentSection})),toggleArchivedSessions:()=>t(e=>({showArchivedSessions:!e.showArchivedSessions})),setProjectSortOrder:e=>t({projectSortOrder:e})}),{name:"session-display-mode",version:4,migrate:O0}));function F0(t){const e=tt.c(219),{t:n}=mt(),{hideDirectoryControls:r,showRecentControls:o,handleOpenDirectoryDialog:i,onOpenScheduled:c,onOpenMultiRun:a,canOpenMultiRun:d,onOpenArchive:u,headerActionIconClass:h,headerActionButtonClass:f,isSessionSearchOpen:g,setIsSessionSearchOpen:b,sessionSearchInputRef:S,sessionSearchQuery:v,setSessionSearchQuery:p,hasSessionSearchQuery:m,searchMatchCount:x,collapseAllProjects:w,expandAllProjects:j,selectionModeEnabled:N,onToggleSelectionMode:A}=t,k=As(H0),C=As(V0),P=As(W0),D=As(U0),F=As(z0),B=As($0),E=As(_0),_=As(L0);if(r)return null;let W;e[0]!==f?(W=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=f,e[1]=W):W=e[1];let V;e[2]!==n?(V=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=V):V=e[3];let K;e[4]!==h?(K=s.jsx(R,{name:"folder-add",className:h}),e[4]=h,e[5]=K):K=e[5];let y;e[6]!==i||e[7]!==W||e[8]!==V||e[9]!==K?(y=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:W,"aria-label":V,children:K})}),e[6]=i,e[7]=W,e[8]=V,e[9]=K,e[10]=y):y=e[10];let I;e[11]!==n?(I=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=I):I=e[12];let $;e[13]!==I?($=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:I})}),e[13]=I,e[14]=$):$=e[14];let z;e[15]!==y||e[16]!==$?(z=s.jsxs(dt,{children:[y,$]}),e[15]=y,e[16]=$,e[17]=z):z=e[17];let G;e[18]!==f?(G=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=f,e[19]=G):G=e[19];let J;e[20]!==n?(J=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=J):J=e[21];let Z;e[22]!==h?(Z=s.jsx(R,{name:"calendar-schedule",className:h}),e[22]=h,e[23]=Z):Z=e[23];let re;e[24]!==c||e[25]!==G||e[26]!==J||e[27]!==Z?(re=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:c,className:G,"aria-label":J,children:Z})}),e[24]=c,e[25]=G,e[26]=J,e[27]=Z,e[28]=re):re=e[28];let ee;e[29]!==n?(ee=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=ee):ee=e[30];let he;e[31]!==ee?(he=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ee})}),e[31]=ee,e[32]=he):he=e[32];let be;e[33]!==re||e[34]!==he?(be=s.jsxs(dt,{children:[re,he]}),e[33]=re,e[34]=he,e[35]=be):be=e[35];let Y;e[36]!==f?(Y=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=f,e[37]=Y):Y=e[37];let we;e[38]!==n?(we=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=we):we=e[39];const me=!d;let Q;e[40]!==h?(Q=s.jsx(Qh,{className:h}),e[40]=h,e[41]=Q):Q=e[41];let pe;e[42]!==a||e[43]!==Y||e[44]!==we||e[45]!==me||e[46]!==Q?(pe=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:Y,"aria-label":we,disabled:me,children:Q})}),e[42]=a,e[43]=Y,e[44]=we,e[45]=me,e[46]=Q,e[47]=pe):pe=e[47];let ve;e[48]!==n?(ve=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=ve):ve=e[49];let Te;e[50]!==ve?(Te=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ve})}),e[50]=ve,e[51]=Te):Te=e[51];let ke;e[52]!==pe||e[53]!==Te?(ke=s.jsxs(dt,{children:[pe,Te]}),e[52]=pe,e[53]=Te,e[54]=ke):ke=e[54];let Ie;e[55]!==f?(Ie=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=f,e[56]=Ie):Ie=e[56];let Ne;e[57]!==n?(Ne=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=Ne):Ne=e[58];let Ae;e[59]!==h?(Ae=s.jsx(R,{name:"archive",className:h}),e[59]=h,e[60]=Ae):Ae=e[60];let Se;e[61]!==u||e[62]!==Ie||e[63]!==Ne||e[64]!==Ae?(Se=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:Ie,"aria-label":Ne,children:Ae})}),e[61]=u,e[62]=Ie,e[63]=Ne,e[64]=Ae,e[65]=Se):Se=e[65];let Oe;e[66]!==n?(Oe=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=Oe):Oe=e[67];let ne;e[68]!==Oe?(ne=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Oe})}),e[68]=Oe,e[69]=ne):ne=e[69];let ce;e[70]!==Se||e[71]!==ne?(ce=s.jsxs(dt,{children:[Se,ne]}),e[70]=Se,e[71]=ne,e[72]=ce):ce=e[72];let Re;e[73]!==be||e[74]!==ke||e[75]!==ce||e[76]!==z?(Re=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[z,be,ke,ce]}),e[73]=be,e[74]=ke,e[75]=ce,e[76]=z,e[77]=Re):Re=e[77];let te;e[78]!==b?(te=()=>b(B0),e[78]=b,e[79]=te):te=e[79];let ae;e[80]!==f?(ae=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[80]=f,e[81]=ae):ae=e[81];let de;e[82]!==n?(de=n("sessions.sidebar.header.actions.searchSessions"),e[82]=n,e[83]=de):de=e[83];let H;e[84]!==h?(H=s.jsx(R,{name:"search",className:h}),e[84]=h,e[85]=H):H=e[85];let ge;e[86]!==g||e[87]!==te||e[88]!==ae||e[89]!==de||e[90]!==H?(ge=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:te,className:ae,"aria-label":de,"aria-expanded":g,children:H})}),e[86]=g,e[87]=te,e[88]=ae,e[89]=de,e[90]=H,e[91]=ge):ge=e[91];let ue;e[92]!==n?(ue=n("sessions.sidebar.header.actions.searchSessions"),e[92]=n,e[93]=ue):ue=e[93];let M;e[94]!==ue?(M=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ue})}),e[94]=ue,e[95]=M):M=e[95];let oe;e[96]!==ge||e[97]!==M?(oe=s.jsxs(dt,{children:[ge,M]}),e[96]=ge,e[97]=M,e[98]=oe):oe=e[98];const De=N&&"bg-interactive-hover text-primary";let fe;e[99]!==f||e[100]!==De?(fe=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent",De),e[99]=f,e[100]=De,e[101]=fe):fe=e[101];let X;e[102]!==N||e[103]!==n?(X=n(N?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[102]=N,e[103]=n,e[104]=X):X=e[104];let le;e[105]!==h?(le=s.jsx(R,{name:"checkbox-multiple",className:h}),e[105]=h,e[106]=le):le=e[106];let se;e[107]!==A||e[108]!==N||e[109]!==fe||e[110]!==X||e[111]!==le?(se=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:A,className:fe,"aria-label":X,"aria-pressed":N,children:le})}),e[107]=A,e[108]=N,e[109]=fe,e[110]=X,e[111]=le,e[112]=se):se=e[112];let T;e[113]!==N||e[114]!==n?(T=n(N?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[113]=N,e[114]=n,e[115]=T):T=e[115];let ie;e[116]!==T?(ie=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:T})}),e[116]=T,e[117]=ie):ie=e[117];let je;e[118]!==se||e[119]!==ie?(je=s.jsxs(dt,{children:[se,ie]}),e[118]=se,e[119]=ie,e[120]=je):je=e[120];let Pe;e[121]!==f?(Pe=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[121]=f,e[122]=Pe):Pe=e[122];let U;e[123]!==n?(U=n("sessions.sidebar.header.displayMode.label"),e[123]=n,e[124]=U):U=e[124];let Be;e[125]!==h?(Be=s.jsx(R,{name:"equalizer-2",className:h}),e[125]=h,e[126]=Be):Be=e[126];let Fe;e[127]!==Pe||e[128]!==U||e[129]!==Be?(Fe=s.jsx(ut,{asChild:!0,children:s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe,"aria-label":U,children:Be})})}),e[127]=Pe,e[128]=U,e[129]=Be,e[130]=Fe):Fe=e[130];let Ye;e[131]!==n?(Ye=n("sessions.sidebar.header.displayMode.label"),e[131]=n,e[132]=Ye):Ye=e[132];let at;e[133]!==Ye?(at=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ye})}),e[133]=Ye,e[134]=at):at=e[134];let st;e[135]!==Fe||e[136]!==at?(st=s.jsxs(dt,{children:[Fe,at]}),e[135]=Fe,e[136]=at,e[137]=st):st=e[137];let ct;e[138]!==n?(ct=n("sessions.sidebar.header.actions.sortProjects"),e[138]=n,e[139]=ct):ct=e[139];let bt;e[140]!==ct?(bt=s.jsx(Pa,{children:ct}),e[140]=ct,e[141]=bt):bt=e[141];let rt;e[142]!==P||e[143]!==D||e[144]!==n?(rt=[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(Rt=>{const[$t,Wt]=Rt;return s.jsxs(Gt,{onClick:()=>D($t),className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Wt)}),P===$t?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]},$t)}),e[142]=P,e[143]=D,e[144]=n,e[145]=rt):rt=e[145];let gt;e[146]===Symbol.for("react.memo_cache_sentinel")?(gt=s.jsx(gn,{}),e[146]=gt):gt=e[146];let it;e[147]!==n?(it=n("sessions.sidebar.header.grouping.label"),e[147]=n,e[148]=it):it=e[148];let Et;e[149]!==it?(Et=s.jsx(Pa,{children:it}),e[149]=it,e[150]=Et):Et=e[150];let Ft;e[151]!==F||e[152]!==B||e[153]!==n?(Ft=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(Rt=>{const[$t,Wt]=Rt;return s.jsxs(Gt,{onClick:()=>B($t),className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Wt)}),F===$t?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]},$t)}),e[151]=F,e[152]=B,e[153]=n,e[154]=Ft):Ft=e[154];let Dt;e[155]===Symbol.for("react.memo_cache_sentinel")?(Dt=s.jsx(gn,{}),e[155]=Dt):Dt=e[155];let Bt;e[156]!==o||e[157]!==k||e[158]!==n||e[159]!==C?(Bt=o?s.jsxs(Gt,{onClick:C,className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),k?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[156]=o,e[157]=k,e[158]=n,e[159]=C,e[160]=Bt):Bt=e[160];let qe;e[161]!==n?(qe=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[161]=n,e[162]=qe):qe=e[162];let zt;e[163]!==qe?(zt=s.jsx("span",{children:qe}),e[163]=qe,e[164]=zt):zt=e[164];let Nt;e[165]!==E?(Nt=E?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null,e[165]=E,e[166]=Nt):Nt=e[166];let xt;e[167]!==zt||e[168]!==Nt||e[169]!==_?(xt=s.jsxs(Gt,{onClick:_,className:"flex items-center justify-between",children:[zt,Nt]}),e[167]=zt,e[168]=Nt,e[169]=_,e[170]=xt):xt=e[170];let Pt;e[171]===Symbol.for("react.memo_cache_sentinel")?(Pt=s.jsx(gn,{}),e[171]=Pt):Pt=e[171];let Mt;e[172]===Symbol.for("react.memo_cache_sentinel")?(Mt=s.jsx(R,{name:"contract-up-down",className:"h-4 w-4"}),e[172]=Mt):Mt=e[172];let Xt;e[173]!==n?(Xt=n("sessions.sidebar.header.displayMode.collapseAll"),e[173]=n,e[174]=Xt):Xt=e[174];let Qe;e[175]!==Xt?(Qe=s.jsx("span",{children:Xt}),e[175]=Xt,e[176]=Qe):Qe=e[176];let ht;e[177]!==w||e[178]!==Qe?(ht=s.jsxs(Gt,{onClick:w,className:"flex items-center gap-2",children:[Mt,Qe]}),e[177]=w,e[178]=Qe,e[179]=ht):ht=e[179];let Ze;e[180]===Symbol.for("react.memo_cache_sentinel")?(Ze=s.jsx(R,{name:"expand-up-down",className:"h-4 w-4"}),e[180]=Ze):Ze=e[180];let $e;e[181]!==n?($e=n("sessions.sidebar.header.displayMode.expandAll"),e[181]=n,e[182]=$e):$e=e[182];let St;e[183]!==$e?(St=s.jsx("span",{children:$e}),e[183]=$e,e[184]=St):St=e[184];let Lt;e[185]!==j||e[186]!==St?(Lt=s.jsxs(Gt,{onClick:j,className:"flex items-center gap-2",children:[Ze,St]}),e[185]=j,e[186]=St,e[187]=Lt):Lt=e[187];let Ot;e[188]!==bt||e[189]!==rt||e[190]!==Et||e[191]!==Ft||e[192]!==Bt||e[193]!==xt||e[194]!==ht||e[195]!==Lt?(Ot=s.jsxs(yn,{align:"end",className:"min-w-[180px]",children:[bt,rt,gt,Et,Ft,Dt,Bt,xt,Pt,ht,Lt]}),e[188]=bt,e[189]=rt,e[190]=Et,e[191]=Ft,e[192]=Bt,e[193]=xt,e[194]=ht,e[195]=Lt,e[196]=Ot):Ot=e[196];let ss;e[197]!==st||e[198]!==Ot?(ss=s.jsxs(vn,{children:[st,Ot]}),e[197]=st,e[198]=Ot,e[199]=ss):ss=e[199];let _t;e[200]!==oe||e[201]!==je||e[202]!==ss?(_t=s.jsxs("div",{className:"flex items-center gap-1.5",children:[oe,je,ss]}),e[200]=oe,e[201]=je,e[202]=ss,e[203]=_t):_t=e[203];let Ct;e[204]!==Re||e[205]!==_t?(Ct=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[Re,_t]}),e[204]=Re,e[205]=_t,e[206]=Ct):Ct=e[206];let os;e[207]!==m||e[208]!==g||e[209]!==x||e[210]!==S||e[211]!==v||e[212]!==b||e[213]!==p||e[214]!==n?(os=g?s.jsxs("div",{className:"pb-1",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80",children:[m?s.jsx("span",{children:x===1?n("sessions.sidebar.header.search.matchCountSingle",{count:x}):n("sessions.sidebar.header.search.matchCountPlural",{count:x})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsxs("div",{className:"relative",children:[s.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:S,value:v,onChange:Rt=>p(Rt.target.value),placeholder:n("sessions.sidebar.header.search.placeholder"),className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-8 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50",onKeyDown:Rt=>{Rt.key==="Escape"&&(Rt.stopPropagation(),m?p(""):b(!1))}}),v.length>0?s.jsx("button",{type:"button",onClick:()=>p(""),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":n("sessions.sidebar.header.search.clear"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null]})]}):null,e[207]=m,e[208]=g,e[209]=x,e[210]=S,e[211]=v,e[212]=b,e[213]=p,e[214]=n,e[215]=os):os=e[215];let hs;return e[216]!==Ct||e[217]!==os?(hs=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[Ct,os]})}),e[216]=Ct,e[217]=os,e[218]=hs):hs=e[218],hs}function B0(t){return!t}function L0(t){return t.toggleStickyZoneHeaders}function _0(t){return t.stickyZoneHeaders}function $0(t){return t.setSessionGroupingMode}function z0(t){return t.sessionGroupingMode}function U0(t){return t.setProjectSortOrder}function W0(t){return t.projectSortOrder}function V0(t){return t.toggleRecentSection}function H0(t){return t.showRecentSection}function K0(t){const e=tt.c(8),{t:n}=mt(),r=t.onNewSession;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(R,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=o):o=e[0];let i;e[1]!==n?(i=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=i):i=e[2];let c;e[3]!==i?(c=s.jsx("span",{className:"truncate",children:i}),e[3]=i,e[4]=c):c=e[4];let a;return e[5]!==t.onNewSession||e[6]!==c?(a=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 pt-1.5",children:s.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left typography-ui-label font-normal text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[o,c]})}),e[5]=t.onNewSession,e[6]=c,e[7]=a):a=e[7],a}const fd=7;function G0(t){const{sections:e,renderSessionNode:n,editingId:r,openSidebarMenuKey:o,variant:i="section",initialVisibleCount:c=fd,batchSize:a=fd}=t,{t:d}=mt(),u=As(j=>j.stickyZoneHeaders),[h,f]=l.useState(new Set),[g,b]=l.useState(new Map),S=i==="flat",v=l.useCallback(j=>{b(N=>{if(!N.has(j))return N;const A=new Map(N);return A.delete(j),A})},[]),p=l.useCallback(j=>{v(j),f(N=>{const A=new Set(N);return A.has(j)?A.delete(j):A.add(j),A})},[v]),m=l.useCallback((j,N,A)=>{b(k=>{const C=Math.min(A,N+a),P=new Map(k);return P.set(j,C),P})},[a]),x=l.useCallback(j=>{const N=new Set;Xa(j,r,N);const A=To(j,o,"recent",!1),k=new WeakMap,C=D=>{k.set(D,Ei(D)),D.children.forEach(C)};j.forEach(C);const P=D=>({subtreeContainsEditing:N,menuOpenSessionId:A,nodeStructureKey:k.get(D)??"",childRenderExtrasFor:P});return D=>({subtreeContainsEditing:N,menuOpenSessionId:A,nodeStructureKey:k.get(D)??"",childRenderExtrasFor:P})},[r,o]),w=e.filter(j=>j.items.length>0);return w.length===0?null:s.jsx("div",{className:ye(S?"space-y-0.5 pb-2":"space-y-2 pb-2"),children:w.map(j=>{const N=h.has(j.key),A=Math.max(c,g.get(j.key)??c),k=j.items.slice(0,A),C=j.items.length-k.length,P=!S&&j.items.length>c&&C===0,D=x(k.map(B=>B.node)),F=B=>n(B.node,0,B.groupDirectory,B.projectId,!1,B.secondaryMeta,"recent",D(B.node));return S?s.jsxs("div",{className:"space-y-0.5",children:[k.map(F),C>0?s.jsx("button",{type:"button",onClick:()=>m(j.key,k.length,j.items.length),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:d("sessions.sidebar.group.showMore")}):null]},j.key):s.jsxs("div",{className:"relative space-y-1",children:[s.jsx("div",{className:ye("-ml-2.5 -mr-2",u&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":u?"true":void 0,children:s.jsxs("button",{type:"button",onClick:()=>p(j.key),className:"group flex w-full items-center gap-1.5 py-1 pl-4 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-expanded":!N,children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[s.jsx(R,{name:"history",className:ye("h-3.5 w-3.5 text-muted-foreground/80","group-hover:hidden")}),s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:N?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"text-[14px] font-semibold lowercase text-foreground",children:j.title})]})}),N?null:s.jsxs("div",{className:ye("space-y-0.5"),children:[k.map(F),C>0?s.jsx("button",{type:"button",onClick:()=>m(j.key,k.length,j.items.length),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:d("sessions.sidebar.group.showMore")}):null,P?s.jsx("button",{type:"button",onClick:()=>v(j.key),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:d("sessions.sidebar.group.showFewer")}):null]})]},j.key)})})}const wa="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50";function q0(t){const e=tt.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:o,onOpenUpdate:i,showRuntimeButtons:c,showUpdateButton:a}=t,d=c===void 0?!0:c,u=a===void 0?!0:a,{t:h}=mt();if(!d&&!u)return null;let f;e[0]!==o||e[1]!==n||e[2]!==r||e[3]!==d||e[4]!==h?(f=d?s.jsxs(s.Fragment,{children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:wa,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(R,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:wa,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(R,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:wa,"aria-label":h("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(R,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=r,e[3]=d,e[4]=h,e[5]=f):f=e[5];let g;e[6]!==i||e[7]!==u||e[8]!==h?(g=u?s.jsx(nt,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:i,children:h("sessions.sidebar.footer.actions.update")}):null,e[6]=i,e[7]=u,e[8]=h,e[9]=g):g=e[9];let b;return e[10]!==f||e[11]!==g?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[f,g]}),e[10]=f,e[11]=g,e[12]=b):b=e[12],b}const zf=t=>{const e=tt.c(22),{id:n,projectLabel:r,projectIcon:o,projectColor:i,projectIconImage:c,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u}=t,h=u===void 0?!1:u,{currentTheme:f}=_r(),g=o?fl[o]:null,b=i?ml[i]??null:null,S=d!==void 0,v=S?h?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let p;e[0]!==h||e[1]!==S||e[2]!==d?(p=S?s.jsx("span",{className:ye("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(R,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=h,e[1]=S,e[2]=d,e[3]=p):p=e[3];let m;e[4]!==h||e[5]!==f||e[6]!==S||e[7]!==b||e[8]!==v||e[9]!==n||e[10]!==a||e[11]!==c||e[12]!==g?(m=c?s.jsx("span",{className:ye("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",S&&h?"hidden":"inline-flex",v),style:a?{backgroundColor:a}:void 0,children:s.jsx(hl,{project:{id:n,iconImage:c},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?s.jsx(R,{name:g,className:"h-3.5 w-3.5",style:b?{color:b}:void 0}):s.jsx(R,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:b?{color:b}:void 0})})}):g?s.jsx(R,{name:g,className:ye("h-3.5 w-3.5",v),style:b?{color:b}:void 0}):s.jsx(R,{name:"folder",className:ye("h-3.5 w-3.5 text-muted-foreground/80",v),style:b?{color:b}:void 0}),e[4]=h,e[5]=f,e[6]=S,e[7]=b,e[8]=v,e[9]=n,e[10]=a,e[11]=c,e[12]=g,e[13]=m):m=e[13];let x;e[14]!==p||e[15]!==m?(x=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[p,m]}),e[14]=p,e[15]=m,e[16]=x):x=e[16];let w;e[17]!==r?(w=s.jsx("span",{className:"truncate text-[14px] font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=w):w=e[18];let j;return e[19]!==x||e[20]!==w?(j=s.jsxs(s.Fragment,{children:[x,w]}),e[19]=x,e[20]=w,e[21]=j):j=e[21],j},Y0=t=>{const e=tt.c(59),{id:n,disabled:r,projectLabel:o,projectDescription:i,projectIcon:c,projectColor:a,projectIconImage:d,projectIconBackground:u,isCollapsed:h,isRepo:f,isDesktopShell:g,hideDirectoryControls:b,alwaysShowActions:S,onToggle:v,onNewSession:p,onNewWorktreeSession:m,onManageWorktrees:x,onRenameStart:w,onClose:j,sentinelRef:N,children:A,showCreateButtons:k,hideHeader:C,openSidebarMenuKey:P,setOpenSidebarMenuKey:D,statusIndicator:F}=t,B=r===void 0?!1:r,E=k===void 0?!0:k,_=C===void 0?!1:C,W=F===void 0?null:F,{t:V}=mt(),K=As(J0);let y;e[0]!==B||e[1]!==n?(y={id:n,disabled:B},e[0]=B,e[1]=n,e[2]=y):y=e[2];const{attributes:I,listeners:$,setNodeRef:z,transform:G,transition:J,isDragging:Z}=bl(y),re=l.useRef(!1),ee=`project:${n}`,he=P===ee,[be,Y]=l.useState(!1);let we;e[3]!==ee||e[4]!==D?(we=de=>{de&&Y(!1),D(de?ee:null)},e[3]=ee,e[4]=D,e[5]=we):we=e[5];const me=we;let Q;e[6]!==b||e[7]!==f||e[8]!==j||e[9]!==x||e[10]!==p||e[11]!==w||e[12]!==E||e[13]!==V?(Q=de=>s.jsxs(s.Fragment,{children:[E&&!f&&!b&&p&&s.jsxs(de,{onClick:p,children:[s.jsx(R,{name:"add",className:"mr-1.5 h-4 w-4"}),V("sessions.sidebar.project.actions.newSession")]}),f&&!b&&x&&s.jsxs(de,{onClick:x,children:[s.jsx(R,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),V("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(de,{onClick:w,children:[s.jsx(R,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),V("sessions.sidebar.project.actions.edit")]}),s.jsxs(de,{onClick:j,className:"text-destructive focus:text-destructive",children:[s.jsx(R,{name:"close",className:"mr-1.5 h-4 w-4"}),V("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=b,e[7]=f,e[8]=j,e[9]=x,e[10]=p,e[11]=w,e[12]=E,e[13]=V,e[14]=Q):Q=e[14];const pe=Q,ve=Z0,Te=ej,ke=tj;let Ie;e[15]===Symbol.for("react.memo_cache_sentinel")?(Ie=de=>{(de.button===2||de.button===0&&de.ctrlKey)&&(re.current=!0)},e[15]=Ie):Ie=e[15];const Ne=Ie;let Ae;e[16]!==v?(Ae=de=>{if(de.currentTarget.blur(),re.current){re.current=!1;return}v()},e[16]=v,e[17]=Ae):Ae=e[17];const Se=Ae;let Oe;e[18]!==G?(Oe=yl.Transform.toString(G),e[18]=G,e[19]=Oe):Oe=e[19];let ne;e[20]!==Oe||e[21]!==J?(ne={transform:Oe,transition:J},e[20]=Oe,e[21]=J,e[22]=ne):ne=e[22];const ce=Z&&"opacity-30";let Re;e[23]!==ce?(Re=ye("relative",ce),e[23]=ce,e[24]=Re):Re=e[24];let te;e[25]!==S||e[26]!==I||e[27]!==me||e[28]!==Se||e[29]!==b||e[30]!==_||e[31]!==n||e[32]!==h||e[33]!==be||e[34]!==g||e[35]!==he||e[36]!==f||e[37]!==$||e[38]!==p||e[39]!==m||e[40]!==a||e[41]!==i||e[42]!==c||e[43]!==u||e[44]!==d||e[45]!==o||e[46]!==pe||e[47]!==N||e[48]!==E||e[49]!==W||e[50]!==K||e[51]!==V?(te=_?null:s.jsxs(s.Fragment,{children:[g&&s.jsx("div",{ref:N,"data-project-id":n,className:"absolute top-0 h-px w-full pointer-events-none","aria-hidden":"true"}),s.jsxs(Uu,{open:be,onOpenChange:Y,children:[s.jsx(zu,{render:s.jsx("div",{className:ye("-ml-2.5 -mr-2 text-left group/project select-none",K&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":K?"true":void 0,onContextMenu:de=>{b||(de.preventDefault(),Y(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...I,children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:Ne,onClick:Se,...$,className:ye("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 rounded-md cursor-grab active:cursor-grabbing transition-[padding]",f&&!b?S?"pr-20":"pr-7 group-hover/project:pr-20 group-focus-within/project:pr-20":S?"pr-14":"pr-7 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(zf,{id:n,projectLabel:o,projectIcon:c,projectColor:a,projectIconImage:d,projectIconBackground:u,isCollapsed:h,alwaysShowActions:S}),W?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:W}):null]})}),s.jsx(ft,{side:"right",sideOffset:8,children:i})]}),s.jsxs("div",{className:ye("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",E?"right-7":"right-0.5"),children:[E&&f&&!b&&m?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:de=>{de.stopPropagation(),m()},className:ye("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground transition-opacity",S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":V("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(R,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:V("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,b?null:s.jsxs(vn,{open:he,onOpenChange:me,children:[s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:ye("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground",he?"opacity-100 pointer-events-auto":S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":V("sessions.sidebar.project.actions.projectMenu"),onPointerDown:Te,onMouseDown:ke,onClick:ve,children:s.jsx(R,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(yn,{align:"end",className:"min-w-[180px]",children:pe(Gt)})]})]}),E&&p?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:de=>{de.stopPropagation(),p()},className:ye("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":V(f?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(R,{name:"add",className:"h-4 w-4"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:V(f?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(_u,{className:"min-w-[180px]",children:pe($u)})]})]}),e[25]=S,e[26]=I,e[27]=me,e[28]=Se,e[29]=b,e[30]=_,e[31]=n,e[32]=h,e[33]=be,e[34]=g,e[35]=he,e[36]=f,e[37]=$,e[38]=p,e[39]=m,e[40]=a,e[41]=i,e[42]=c,e[43]=u,e[44]=d,e[45]=o,e[46]=pe,e[47]=N,e[48]=E,e[49]=W,e[50]=K,e[51]=V,e[52]=te):te=e[52];let ae;return e[53]!==A||e[54]!==z||e[55]!==ne||e[56]!==Re||e[57]!==te?(ae=s.jsxs("div",{ref:z,style:ne,className:Re,children:[te,A]}),e[53]=A,e[54]=z,e[55]=ne,e[56]=Re,e[57]=te,e[58]=ae):ae=e[58],ae},Q0=t=>{const e=tt.c(21),{id:n,disabled:r,children:o}=t,i=r===void 0?!1:r;let c;e[0]!==i||e[1]!==n?(c={id:n,disabled:i},e[0]=i,e[1]=n,e[2]=c):c=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:h,transition:f,isDragging:g}=bl(c);let b;e[3]!==a||e[4]!==u?(b={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=b):b=e[5];const S=b;let v;e[6]!==h?(v=yl.Transform.toString(h),e[6]=h,e[7]=v):v=e[7];let p;e[8]!==v||e[9]!==f?(p={transform:v,transition:f},e[8]=v,e[9]=f,e[10]=p):p=e[10];const m=g&&"opacity-50";let x;e[11]!==m?(x=ye("space-y-0.5 rounded-md",m),e[11]=m,e[12]=x):x=e[12];let w;e[13]!==o||e[14]!==S?(w=typeof o=="function"?o(S):o,e[13]=o,e[14]=S,e[15]=w):w=e[15];let j;return e[16]!==d||e[17]!==p||e[18]!==x||e[19]!==w?(j=s.jsx("div",{ref:d,style:p,className:x,children:w}),e[16]=d,e[17]=p,e[18]=x,e[19]=w,e[20]=j):j=e[20],j},X0=l.memo(Q0);function J0(t){return t.stickyZoneHeaders}function Z0(t){t.stopPropagation()}function ej(t){t.stopPropagation()}function tj(t){t.stopPropagation()}const sj=48,nj=32,rj=24,md=(t,e)=>pl(t.label?.trim()||hr(t.normalizedPath,e)||t.normalizedPath);function oj(t){In("ui.sidebar_projects_list.render");const{t:e}=mt(),n=t.isDesktopShellRuntime&&t.stickyZoneHeaders,r=wi(Yr(Ba,{activationConstraint:{distance:8}}),Yr(nx,{coordinateGetter:rx})),o=wi(Yr(Ba,{activationConstraint:{distance:8}})),i=l.useRef(new Map),c=l.useRef(t.getOrderedGroups);c.current!==t.getOrderedGroups&&(c.current=t.getOrderedGroups,i.current.clear());const a=(p,m)=>{const x=i.current,w=x.get(p);if(w&&w.groups===m)return w.ordered;const j=t.getOrderedGroups(p,m);if(x.set(p,{groups:m,ordered:j}),x.size>256){const N=x.keys().next().value;N!==void 0&&x.delete(N)}return j},d=l.useRef(null),u=l.useRef(0),h=l.useCallback(p=>{const x=p.scrollTop>1?Math.min(nj+p.scrollTop,sj):0;u.current=x,p.style.setProperty("--scroll-shadow-top-size",`${x}px`),p.style.setProperty("--scroll-shadow-top-clear-size",`${Math.min(Math.max(x-8,0),rj)}px`)},[]),f=l.useCallback(p=>{p.target.closest("[data-overlay-scrollbar-thumb], [data-sidebar-sticky-header]")||p.clientY-p.currentTarget.getBoundingClientRect().top>=u.current||(p.preventDefault(),p.stopPropagation())},[]),g=t.projectSections.length>0&&t.sectionsForRender.length>0;l.useLayoutEffect(()=>{n&&g&&d.current&&h(d.current)},[n,g,h]);let b=null;for(const p of t.projectSections)t.stuckProjectHeaders.has(p.project.id)&&(b=p.project);const S=b??(t.hasSharedSessions?null:t.sectionsForRender[0]?.project??null),v=S?md(S,t.homeDirectory):null;return t.sharedSessionsOnly?s.jsxs(Yn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:ye("space-y-1 pb-1 pr-2",(t.mobileVariant,"")),children:[t.topContent,t.hasSharedSessions?null:t.hasSessionSearchQuery?t.searchEmptyState:t.emptyState]}):t.projectSections.length===0?s.jsxs(Yn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:ye("space-y-1 pb-1 pl-2.5 pr-2",(t.mobileVariant,"")),children:[t.topContent,t.emptyState]}):t.sectionsForRender.length===0?s.jsx(Yn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:ye("space-y-1 pb-1 pl-2.5 pr-2",(t.mobileVariant,"")),children:t.searchEmptyState}):s.jsxs("div",{className:"oc-sticky-fade-root relative flex min-h-0 flex-1",onPointerDownCapture:n?f:void 0,onClickCapture:n?f:void 0,onContextMenuCapture:n?f:void 0,children:[s.jsxs(Yn,{ref:d,useScrollShadow:!0,hideTopScrollShadow:!n,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:ye("oc-sidebar-scroller oc-sticky-fade-scroller space-y-1.5 pb-1 pl-2.5 pr-2 [overflow-anchor:none]",(t.mobileVariant,"")),style:n?{"--scroll-shadow-top-size":"0px"}:void 0,onScroll:n?p=>h(p.currentTarget):void 0,children:[t.topContent,t.showOnlyMainWorkspace?s.jsx("div",{className:"space-y-[0.6rem] py-1",children:(()=>{const p=t.sectionsForRender.find(j=>j.project.id===t.activeProjectId)??t.sectionsForRender[0];if(!p)return t.hasSessionSearchQuery?t.searchEmptyState:t.emptyState;const m=p.groups.find(j=>j.isMain&&j.sessions.length>0)??p.groups.find(j=>j.sessions.length>0)??p.groups.find(j=>j.isMain)??p.groups[0];if(!m)return s.jsx("div",{className:"py-1 text-left typography-micro text-muted-foreground",children:e("sessions.sidebar.empty.noSessions.title")});const x=p.groups.find(j=>j.isArchivedBucket);return[m,...x&&x.id!==m.id?[x]:[]].map(j=>{const N=`${p.project.id}:${j.id}`,A=j.id===m.id;return s.jsx(l.Fragment,{children:t.renderGroupSessions(j,N,p.project.id,A,null,!0,d)},N)})})()}):s.jsxs(Si,{sensors:r,collisionDetection:ji,onDragEnd:p=>{if(t.isInlineEditing||t.projectSortOrder!=="manual")return;const{active:m,over:x}=p;if(!x||m.id===x.id)return;const w=t.sectionsForRender.findIndex(N=>N.project.id===m.id),j=t.sectionsForRender.findIndex(N=>N.project.id===x.id);w===-1||j===-1||w===j||t.reorderProjects(w,j)},children:[s.jsx(_a,{items:t.sectionsForRender.map(p=>p.project.id),strategy:$a,children:t.sectionsForRender.map(p=>{const m=p.project,x=m.id,w=md(m,t.homeDirectory),j=gi(m.normalizedPath,t.homeDirectory),N=t.collapsedProjects.has(x),A=t.projectRepoStatus.get(x);return s.jsx(Y0,{id:x,disabled:t.projectSortOrder!=="manual",projectLabel:w,projectDescription:j,projectIcon:m.icon,projectColor:m.color,projectIconImage:m.iconImage,projectIconBackground:m.iconBackground,isCollapsed:N,isRepo:!!A,isDesktopShell:t.isDesktopShellRuntime,hideDirectoryControls:t.hideDirectoryControls,mobileVariant:t.mobileVariant,alwaysShowActions:t.alwaysShowActions,statusIndicator:N?t.renderProjectStatusIndicator?.(x,p.groups):null,onToggle:()=>t.toggleProject(x),onNewSession:()=>{x!==t.activeProjectId&&t.setActiveProjectIdOnly(x),t.setActiveMainTab("chat"),t.mobileVariant&&t.setSessionSwitcherOpen(!1),t.openNewSessionDraft({selectedProjectId:x,directoryOverride:m.normalizedPath})},onNewWorktreeSession:()=>{x!==t.activeProjectId&&t.setActiveProjectIdOnly(x),t.setActiveMainTab("chat"),t.openNewWorktreeDialog()},onManageWorktrees:()=>t.openWorktreesPage(x),onRenameStart:()=>t.openProjectEditDialog(x),onClose:()=>t.removeProject(x),sentinelRef:k=>{t.projectHeaderSentinelRefs.current.set(x,k)},showCreateButtons:!0,openSidebarMenuKey:t.openSidebarMenuKey,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,children:N?null:s.jsx("div",{className:"space-y-0 pt-0.5 pb-0.5",children:(()=>{const k=a(x,p.groups),C=k.find(D=>D.isMain)??null,P=C?k.filter(D=>D.id!==C.id):k;return s.jsxs(Si,{sensors:o,collisionDetection:ji,onDragEnd:D=>{if(t.isInlineEditing)return;const{active:F,over:B}=D;if(!B||F.id===B.id)return;const E=P.findIndex(K=>K.id===F.id),_=P.findIndex(K=>K.id===B.id);if(E===-1||_===-1||E===_)return;const W=Qu(P,E,_).map(K=>K.id),V=C?[C.id,...W]:W;t.setGroupOrderByProject(K=>{const y=new Map(K);return y.set(x,V),y})},children:[C?t.renderGroupSessions(C,`${x}:${C.id}`,x,!0,null,void 0,d):null,s.jsx(_a,{items:P.map(D=>D.id),strategy:$a,children:P.map(D=>{const F=`${x}:${D.id}`;return s.jsx(X0,{id:D.id,disabled:t.isInlineEditing,children:B=>t.renderGroupSessions(D,F,x,!1,B,void 0,d)},D.id)})}),s.jsx(La,{dropAnimation:null})]})})()})},x)})}),s.jsx(La,{dropAnimation:null})]})]}),n&&(S||t.hasSharedSessions)?s.jsx("div",{className:"oc-sticky-fade-overlay pointer-events-none absolute inset-x-0 top-0 z-30 flex items-center gap-1.5 py-1 pl-4 pr-5","aria-hidden":"true",children:S&&v?s.jsx(zf,{id:S.id,projectLabel:v,projectIcon:S.icon,projectColor:S.color,projectIconImage:S.iconImage,projectIconBackground:S.iconBackground}):s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"history",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:"truncate text-[14px] font-semibold lowercase text-foreground",children:e("sessions.sidebar.activity.recentTitle")})]})}):null]})}const ij=l.memo(oj),aj=(t,e)=>{if(!e)return Array.from(t);const n=[],r=new Set;for(const o of t){r.has(o)||(r.add(o),n.push(o));const i=e.get(o);if(i)for(const c of i)r.has(c)||(r.add(c),n.push(c))}return n},Ns=xr()((t,e)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{e().enabled||t({enabled:!0})},disable:()=>{t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{e().enabled?t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):t({enabled:!0})},toggleSelected:(n,r,o)=>{const i=e(),c=new Set(i.selectedIds);let a=i.scopeKey,d=i.anchorId;r!==null&&i.scopeKey!==null&&r!==i.scopeKey?(c.clear(),a=r,d=null):a===null&&r!==null&&(a=r);const h=o&&o.length>0?[n,...o]:[n];if(c.has(n)){for(const g of h)c.delete(g);d===n&&(d=null)}else{for(const g of h)c.add(g);d=n}c.size===0?t({selectedIds:c,scopeKey:null,anchorId:null}):t({selectedIds:c,scopeKey:a,anchorId:d})},setRange:(n,r,o,i,c)=>{const a=e();if(o.length===0)return;const d=n&&o.includes(n)?n:o[0],u=o.indexOf(d),h=o.indexOf(r);if(u<0||h<0)return;const[f,g]=u<=h?[u,h]:[h,u],b=o.slice(f,g+1),S=aj(b,c),p=i!==null&&a.scopeKey!==null&&i!==a.scopeKey?new Set:new Set(a.selectedIds);for(const m of S)p.add(m);t({selectedIds:p,scopeKey:i??a.scopeKey,anchorId:d})},replaceAll:(n,r)=>{if(n.length===0){t({selectedIds:new Set,scopeKey:null,anchorId:null});return}t({selectedIds:new Set(n),scopeKey:r,anchorId:n[0]??null})},clear:()=>{t({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{const r=e();if(r.selectedIds.size===0||n.length===0)return;const o=new Set(r.selectedIds);for(const i of n)o.delete(i);o.size!==r.selectedIds.size&&(o.size===0?t({selectedIds:o,scopeKey:null,anchorId:null}):t({selectedIds:o}))}}));let Ja=!1;const Za=new Set;let hd=!1;function lj(){for(const t of Za)t()}function El(t){Ja!==t&&(Ja=t,lj())}function cj(t){t.key==="Shift"&&El(!0)}function dj(t){t.key==="Shift"&&El(!1)}function uj(){El(!1)}function fj(){hd||typeof window>"u"||(hd=!0,window.addEventListener("keydown",cj),window.addEventListener("keyup",dj),window.addEventListener("blur",uj))}function mj(t){return fj(),Za.add(t),()=>{Za.delete(t)}}function hj(){return Ja}function pj(){return!1}function gj(){return Ge.useSyncExternalStore(mj,hj,pj)}const xj=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,Uf=/^g[1-9]\d*$/,go=(t,e,n,r,o)=>{if(!xj.test(t)||e!==void 0&&!Uf.test(e)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(o===void 0)return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!1};if(o==="fusion")return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(o))return null;const i=Number.parseInt(o,10);return!Number.isSafeInteger(i)||i<=0?null:{groupSlug:t,runGroup:e,providerID:n,modelID:r,index:i,fusion:!1}},ui=t=>{if(!t)return null;const e=t.split("/");if(e.length<3||e.length>5)return null;const[n]=e;if(e.length===3)return go(n,void 0,e[1],e[2],void 0);if(e.length===4){const[,a,d,u]=e;return Uf.test(a)?go(n,a,d,u,void 0):go(n,void 0,a,d,u)}const[,r,o,i,c]=e;return r===""?go(n,void 0,o,i,c):go(n,r,o,i,c)},bj=t=>{const e=[t.groupSlug];return t.runGroup&&e.push(t.runGroup),e.push(t.providerID,t.modelID),t.index!==void 0&&e.push(String(t.index)),e.join("/")},yj=(t,e,n,r)=>{const o=[t];return r&&o.push(r),o.push(e,n,"fusion"),o.join("/")},Wf=t=>{const e=tt.c(36),{value:n,onChange:r,className:o,disabled:i,id:c,portalToBody:a}=t,{t:d}=mt(),u=Vt(vj),h=Vt(wj),f=Vt(Sj);let g;e[0]!==u?(g=u(),e[0]=u,e[1]=g):g=e[1];const b=g;let S;e[2]!==b?(S=b.filter(jj),e[2]=b,e[3]=S):S=e[3];const v=S;let p,m;e[4]!==b.length||e[5]!==h?(p=()=>{b.length===0&&h()},m=[b.length,h],e[4]=b.length,e[5]=h,e[6]=p,e[7]=m):(p=e[6],m=e[7]),l.useEffect(p,m);let x,w;e[8]!==f||e[9]!==i||e[10]!==r||e[11]!==v||e[12]!==n?(x=()=>{if(i)return;const B=n.trim();if(B.length>0&&v.some(W=>W.name===B))return;const E=typeof f=="string"&&f.trim().length>0?f.trim():null;if(E&&v.some(W=>W.name===E)){r(E);return}const _=v[0]?.name;_&&r(_)},w=[f,i,r,v,n],e[8]=f,e[9]=i,e[10]=r,e[11]=v,e[12]=n,e[13]=x,e[14]=w):(x=e[13],w=e[14]),l.useEffect(x,w);const j=n.trim().length>0?n:void 0;let N;e[15]!==o?(N=ye("max-w-full",o),e[15]=o,e[16]=N):N=e[16];let A;e[17]!==d?(A=d("multirun.agentSelector.placeholder"),e[17]=d,e[18]=A):A=e[18];let k;e[19]!==A?(k=s.jsx(Ds,{placeholder:A}),e[19]=A,e[20]=k):k=e[20];let C;e[21]!==c||e[22]!==N||e[23]!==k?(C=s.jsx(_s,{id:c,size:"lg",className:N,children:k}),e[21]=c,e[22]=N,e[23]=k,e[24]=C):C=e[24];let P;e[25]!==v?(P=v.length>0&&s.jsx(Ma,{children:v.map(kj)}),e[25]=v,e[26]=P):P=e[26];let D;e[27]!==a||e[28]!==P?(D=s.jsx($s,{fitContent:!0,portalToBody:a,children:P}),e[27]=a,e[28]=P,e[29]=D):D=e[29];let F;return e[30]!==i||e[31]!==r||e[32]!==j||e[33]!==C||e[34]!==D?(F=s.jsxs(Ls,{value:j,onValueChange:r,disabled:i,children:[C,D]}),e[30]=i,e[31]=r,e[32]=j,e[33]=C,e[34]=D,e[35]=F):F=e[35],F};function vj(t){return t.getVisibleAgents}function wj(t){return t.loadAgents}function Sj(t){return t.currentAgentName}function jj(t){return Du(t.mode)}function kj(t){return s.jsx(rs,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const Cj="h-7",jo=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Nj=t=>{const e=tt.c(12),{model:n,instanceIndex:r,totalSameModel:o,onRemove:i}=t,c=n.displayName||`${n.providerID}/${n.modelID}`,a=o>1?`${c} (${r})`:c;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=ye("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",Cj),e[0]=d):d=e[0];let u;e[1]!==n.providerID?(u=s.jsx(pi,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=u):u=e[2];let h;e[3]!==a?(h=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(R,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let g;e[6]!==i?(g=s.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=i,e[7]=g):g=e[7];let b;return e[8]!==u||e[9]!==h||e[10]!==g?(b=s.jsxs("div",{className:d,children:[u,h,g]}),e[8]=u,e[9]=h,e[10]=g,e[11]=b):b=e[11],b},Vf=t=>{const e=tt.c(120),{selectedModels:n,onAdd:r,onRemove:o,onUpdate:i,minModels:c,addButtonLabel:a,showChips:d,maxModels:u,addButtonClassName:h,dropdownSide:f,dropdownClassName:g,containerClassName:b,triggerIcon:S}=t,v=d===void 0?!0:d,p=f===void 0?"top":f,{t:m}=mt(),x=Vt(Aj),w=Vt(Dj),j=xe(Pj),N=xe(Ej),{favoriteModelsList:A,recentModelsList:k}=Xh(),C=xe(Tj),P=xe(Ij),[D,F]=l.useState(!1),[B,E]=l.useState(""),[_,W]=l.useState(null),V=l.useRef(null),K=l.useRef(null),y=u===1,I=u===void 0||n.length<u||y;let $;if(e[0]!==n){$=new Map;for(const Pe of n){const U=`${Pe.providerID}:${Pe.modelID}`;$.set(U,($.get(U)||0)+1)}e[0]=n,e[1]=$}else $=e[1];const z=$;let G;e[2]!==n?(G=Pe=>n.filter(Be=>Be.providerID===Pe.providerID&&Be.modelID===Pe.modelID).findIndex(Be=>Be.instanceId===Pe.instanceId)+1,e[2]=n,e[3]=G):G=e[3];const J=G;let Z,re;e[4]!==p||e[5]!==D?(Z=()=>{if(!D||!K.current)return;const Pe=K.current.getBoundingClientRect();if(p==="bottom"){const st=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Pe.bottom-16-112;W(Math.max(160,Math.min(320,st)));return}let U=K.current.parentElement;for(;U&&!(U.getAttribute("role")==="dialog"||U.hasAttribute("data-scroll-shadow"));){const Ye=getComputedStyle(U);if(Ye.overflow==="auto"||Ye.overflow==="hidden"||Ye.overflowY==="auto"||Ye.overflowY==="hidden")break;U=U.parentElement}const Be=U?U.getBoundingClientRect().top:0,Fe=Pe.top-Be-16;W(Math.max(150,Math.min(300,Fe)))},re=[p,D],e[4]=p,e[5]=D,e[6]=Z,e[7]=re):(Z=e[6],re=e[7]),l.useEffect(Z,re);let ee,he;e[8]!==I||e[9]!==D?(ee=()=>{!I&&D&&(F(!1),E(""))},he=[I,D],e[8]=I,e[9]=D,e[10]=ee,e[11]=he):(ee=e[10],he=e[11]),l.useEffect(ee,he);let be,Y;e[12]!==D?(be=()=>{if(!D)return;const Pe=U=>{V.current&&!V.current.contains(U.target)&&(F(!1),E(""))};return document.addEventListener("mousedown",Pe),()=>document.removeEventListener("mousedown",Pe)},Y=[D],e[12]=D,e[13]=be,e[14]=Y):(be=e[13],Y=e[14]),l.useEffect(be,Y);let we;e[15]!==y||e[16]!==r||e[17]!==i||e[18]!==n.length?(we=Pe=>{const U={providerID:Pe.providerID,modelID:Pe.modelID,displayName:Pe.model.name||Pe.modelID,instanceId:jo()};y&&n.length>0&&i?i(0,U):r(U),y&&(F(!1),E(""))},e[15]=y,e[16]=r,e[17]=i,e[18]=n.length,e[19]=we):we=e[19];const me=we;let Q;e[20]!==m?(Q=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=Q):Q=e[21];let pe;e[22]!==m?(pe=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=pe):pe=e[23];let ve;e[24]!==m?(ve=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=ve):ve=e[25];let Te;e[26]!==m?(Te=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=Te):Te=e[27];let ke;e[28]!==m?(ke=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=ke):ke=e[29];let Ie;e[30]!==m?(Ie=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=Ie):Ie=e[31];let Ne;e[32]!==m?(Ne=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=Ne):Ne=e[33];let Ae;e[34]!==m?(Ae=m("chat.modelControls.capabilities"),e[34]=m,e[35]=Ae):Ae=e[35];let Se;e[36]!==m?(Se=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=Se):Se=e[37];let Oe;e[38]!==m?(Oe=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=Oe):Oe=e[39];let ne;e[40]!==m?(ne=m("chat.modelControls.input"),e[40]=m,e[41]=ne):ne=e[41];let ce;e[42]!==m?(ce=m("chat.modelControls.output"),e[42]=m,e[43]=ce):ce=e[43];let Re;e[44]!==m?(Re=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=Re):Re=e[45];let te;e[46]!==Q||e[47]!==pe||e[48]!==ve||e[49]!==Te||e[50]!==ke||e[51]!==Ie||e[52]!==Ne||e[53]!==Ae||e[54]!==Se||e[55]!==Oe||e[56]!==ne||e[57]!==ce||e[58]!==Re?(te={searchPlaceholder:Q,noResults:pe,favorites:ve,recent:Te,keyboardHint:ke,favorite:Ie,unfavorite:Ne,capabilities:Ae,capabilityToolCalling:Se,capabilityReasoning:Oe,input:ne,output:ce,costPerMillion:Re},e[46]=Q,e[47]=pe,e[48]=ve,e[49]=Te,e[50]=ke,e[51]=Ie,e[52]=Ne,e[53]=Ae,e[54]=Se,e[55]=Oe,e[56]=ne,e[57]=ce,e[58]=Re,e[59]=te):te=e[59];const ae=te;let de;e[60]!==b?(de=ye("relative",b),e[60]=b,e[61]=de):de=e[61];const H=D?"":void 0;let ge;e[62]!==h?(ge=ye(Pu({size:"default"}),"w-fit",h),e[62]=h,e[63]=ge):ge=e[63];const ue=!I;let M;e[64]!==D?(M=()=>{F(!D)},e[64]=D,e[65]=M):M=e[65];let oe;e[66]!==S?(oe=S??s.jsx(R,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=S,e[67]=oe):oe=e[67];let De;e[68]!==a||e[69]!==m?(De=a??m("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=m,e[70]=De):De=e[70];let fe;e[71]!==H||e[72]!==ge||e[73]!==ue||e[74]!==M||e[75]!==oe||e[76]!==De?(fe=s.jsxs("button",{ref:K,type:"button","data-popup-open":H,className:ge,disabled:ue,onClick:M,children:[oe,De]}),e[71]=H,e[72]=ge,e[73]=ue,e[74]=M,e[75]=oe,e[76]=De,e[77]=fe):fe=e[77];let X;e[78]!==_||e[79]!==I||e[80]!==g||e[81]!==p||e[82]!==A||e[83]!==me||e[84]!==C||e[85]!==N||e[86]!==D||e[87]!==ae||e[88]!==z||e[89]!==w||e[90]!==P||e[91]!==x||e[92]!==k||e[93]!==B||e[94]!==j?(X=D?s.jsx("div",{className:ye("absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg",p==="top"?"bottom-full mb-1":"top-full mt-1",g),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(Jh,{providers:x,providerOrder:P,favoriteModels:A,recentModels:k,modelsMetadata:w,hiddenModels:C,searchQuery:B,onSearchQueryChange:E,onSelect:me,labels:ae,selectionCount:Pe=>z.get(`${Pe.providerID}:${Pe.modelID}`)||0,disabled:!I,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:_?`${_}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:D,isFavorite:Pe=>N(Pe.providerID,Pe.modelID),onToggleFavorite:Pe=>j(Pe.providerID,Pe.modelID),onEscape:()=>{F(!1),E("")}})}):null,e[78]=_,e[79]=I,e[80]=g,e[81]=p,e[82]=A,e[83]=me,e[84]=C,e[85]=N,e[86]=D,e[87]=ae,e[88]=z,e[89]=w,e[90]=P,e[91]=x,e[92]=k,e[93]=B,e[94]=j,e[95]=X):X=e[95];let le;e[96]!==de||e[97]!==fe||e[98]!==X?(le=s.jsxs("div",{className:de,ref:V,children:[fe,X]}),e[96]=de,e[97]=fe,e[98]=X,e[99]=le):le=e[99];let se;e[100]!==J||e[101]!==z||e[102]!==o||e[103]!==i||e[104]!==x||e[105]!==n||e[106]!==v||e[107]!==m?(se=v&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Pe,U)=>{const Be=`${Pe.providerID}:${Pe.modelID}`,Fe=z.get(Be)||1,Ye=J(Pe),st=x.find(gt=>gt.id===Pe.providerID)?.models?.find(gt=>gt.id===Pe.modelID),ct=st?.variants?Object.keys(st.variants):[],bt=ct.length>0,rt=Pe.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Nj,{model:Pe,instanceIndex:Ye,totalSameModel:Fe,onRemove:()=>o(U)}),bt&&s.jsxs(Ls,{value:rt,onValueChange:gt=>{if(!i)return;i(U,{...Pe,variant:gt==="__default__"?void 0:gt})},children:[s.jsxs(_s,{size:"sm",className:"gap-1.5",children:[s.jsx(R,{name:"brain-ai-3",className:ye("h-3.5 w-3.5 flex-shrink-0",rt==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(Ds,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:gt=>gt==="__default__"?m("multirun.modelMultiSelect.variant.default"):gt})]}),s.jsxs($s,{fitContent:!0,children:[s.jsx(rs,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),ct.map(Rj)]})]})]},Pe.instanceId)})}),e[100]=J,e[101]=z,e[102]=o,e[103]=i,e[104]=x,e[105]=n,e[106]=v,e[107]=m,e[108]=se):se=e[108];let T;e[109]!==le||e[110]!==se?(T=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[le,se]}),e[109]=le,e[110]=se,e[111]=T):T=e[111];let ie;e[112]!==u||e[113]!==c||e[114]!==n.length||e[115]!==m?(ie=c!==void 0&&n.length<c&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:u!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:c,max:u}):m("multirun.modelMultiSelect.validation.minOnly",{min:c})}),e[112]=u,e[113]=c,e[114]=n.length,e[115]=m,e[116]=ie):ie=e[116];let je;return e[117]!==T||e[118]!==ie?(je=s.jsxs("div",{className:"space-y-2",children:[T,ie]}),e[117]=T,e[118]=ie,e[119]=je):je=e[119],je};function Aj(t){return t.providers}function Dj(t){return t.modelsMetadata}function Pj(t){return t.toggleFavoriteModel}function Ej(t){return t.isFavoriteModel}function Tj(t){return t.hiddenModels}function Ij(t){return t.providerOrder}function Rj(t){return s.jsx(rs,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const Mj=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
|
|
901
|
-
|
|
902
|
-
--- RESULT ${n+1}: ${r} ---
|
|
903
|
-
${e.trim()}
|
|
904
|
-
--- END RESULT ${n+1} ---`},pd=(t,e)=>Je.getState().getWorktreeMetadata(t)?.projectDirectory??e,Oj=async t=>{const e=t.directory??void 0,n=ep(t.session.id,e);if(n.length===0&&t.directory){const o=(await Xs.withDirectory(t.directory,()=>Xs.getSdkClient().session.messages({sessionID:t.session.id,directory:t.directory??void 0,limit:50}))).data??[];for(let i=o.length-1;i>=0;i-=1){const c=o[i];if(c.info?.role==="assistant")return oc(c.parts??[]).trim()}return""}for(let r=n.length-1;r>=0;r-=1){const o=n[r];if(o.role==="assistant")return oc(tp(o.id,e)).trim()}return""};function Fj({session:t,open:e,onOpenChange:n}){const{t:r}=mt(),o=Zh(),i=Rs(y=>y.activeSessions),c=Rs(y=>y.archivedSessions),a=Vt(y=>y.providers),d=Vt(y=>y.currentProviderId),u=Vt(y=>y.currentModelId),h=Vt(y=>y.currentAgentName),[f,g]=l.useState(d??""),[b,S]=l.useState(u??""),[v,p]=l.useState(()=>d&&u?[{providerID:d,modelID:u,instanceId:jo()}]:[]),[m,x]=l.useState(""),[w,j]=l.useState(h??""),[N,A]=l.useState([]),[k,C]=l.useState(!1),P=l.useMemo(()=>ui(t.title),[t.title]),D=l.useMemo(()=>{const y=new Map;for(const I of o)y.set(I.id,I);for(const I of i)y.set(I.id,I);for(const I of c)y.set(I.id,I);return t.id&&y.set(t.id,t),Array.from(y.values())},[i,c,o,t]);l.useEffect(()=>{if(!e||!P)return;const y=Je.getState().getDirectoryForSession(t.id),I=pd(t.id,y),$=D.map(z=>{const G=ui(z.title);if(!G||G.groupSlug!==P.groupSlug||G.fusion||(G.runGroup??null)!==(P.runGroup??null))return null;const J=Je.getState().getDirectoryForSession(z.id)??Us(z),Z=pd(z.id,J);return I&&Z&&I!==Z?null:{session:z,directory:J,projectDirectory:Z}}).filter(z=>z!==null).sort((z,G)=>(z.session.time?.created??0)-(G.session.time?.created??0));A($)},[D,e,P,t.id]);const B=a.find(y=>y.id===f)?.models.find(y=>y.id===b),E=B?.variants?Object.keys(B.variants):[],_=!!(P&&f&&b&&N.length>0&&!k),W=l.useCallback(y=>{p([y]),g(y.providerID),S(y.modelID),x("")},[]),V=v[0]?.displayName||v[0]?.modelID||r("multirun.fusion.model.placeholder"),K=async()=>{if(!(!P||!f||!b)){C(!0);try{const y=await Promise.all(N.map(re=>Oj(re))),I=N.map((re,ee)=>({source:re,text:y[ee]??""})).filter(re=>re.text.trim().length>0);if(I.length===0){Ee.error(r("multirun.fusion.toast.noOutputs"));return}const $=N[0]?.projectDirectory??N[0]?.directory??null,z=yj(P.groupSlug,f,b,P.runGroup),[G,J]=await Promise.all([rc("session.fusion.visible"),rc("session.fusion.instructions")]),Z=await Je.getState().createSession(z,$,null);if(!Z)throw new Error("Failed to create fusion session");Je.getState().setCurrentSession(Z.id,$),n(!1),await Xs.sendMessage({id:Z.id,providerID:f,modelID:b,variant:m||void 0,agent:w||void 0,text:G,additionalParts:[{text:J,synthetic:!0},...I.map((re,ee)=>({text:Mj(re.source,re.text,ee),synthetic:!0})),{text:`
|
|
905
|
-
|
|
906
|
-
--- FUSION INPUTS END ---
|
|
907
|
-
Now write the final fused answer.`,synthetic:!0}],directory:$??Xs.getDirectory()})}catch(y){console.error("[MultiRunFusion] Failed to start fusion",y),Ee.error(r("multirun.fusion.toast.failed"))}finally{C(!1)}}};return s.jsx(Ws,{open:e,onOpenChange:n,children:s.jsxs(Vs,{className:"max-w-xl overflow-visible",children:[s.jsxs(Rn,{children:[s.jsx(wn,{children:r("multirun.fusion.title")}),s.jsx(Sn,{children:r("multirun.fusion.description")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"max-w-full",children:s.jsx(Vf,{selectedModels:v,onAdd:W,onUpdate:(y,I)=>W(I),onRemove:()=>{p([]),g(""),S(""),x("")},maxModels:1,addButtonLabel:V,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:f?s.jsx(pi,{providerId:f,className:"h-3.5 w-3.5 mr-1"}):void 0})}),E.length>0?s.jsxs(Ls,{value:m||"__default__",onValueChange:y=>x(y==="__default__"?"":y),children:[s.jsxs(_s,{size:"lg",className:"w-fit",children:[s.jsx(R,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Ds,{children:y=>y==="__default__"?r("multirun.modelMultiSelect.variant.default"):y})]}),s.jsxs($s,{fitContent:!0,portalToBody:!0,children:[s.jsx(rs,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),E.map(y=>s.jsx(rs,{value:y,children:y},y))]})]}):null,s.jsx(Wf,{value:w,onChange:j,portalToBody:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta font-medium text-foreground",children:r("multirun.fusion.sources.label",{count:N.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:N.map(y=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(pi,{providerId:ui(y.session.title)?.providerID??"",className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:y.session.title||y.session.id}),s.jsx("button",{type:"button",onClick:()=>A(I=>I.filter($=>$.session.id!==y.session.id)),className:"text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"h-4 w-4"})})]},y.session.id))})]}),s.jsxs(gr,{children:[s.jsx(nt,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(nt,{onClick:K,disabled:!_,children:r(k?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function Bj(t){const e=tt.c(7);let n,r,o,i,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),r=s.jsx("path",{d:"M9.25 7.25 12 4.5l2.75 2.75",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),o=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),i=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),c=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=o,e[3]=i,e[4]=c):(n=e[0],r=e[1],o=e[2],i=e[3],c=e[4]);let a;return e[5]!==t?(a=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...t,children:[n,r,o,i,c]}),e[5]=t,e[6]=a):a=e[6],a}const el=6,Xo=14,gd=el+14+6,Sa=new WeakMap,Lj=t=>{if(typeof window>"u")return;const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;Sa.get(n)?.();const r=e.getBoundingClientRect().top;let o=3,i=!1,c=null;const a=()=>{i=!0,c!==null&&window.cancelAnimationFrame(c),c=null,Sa.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},d=()=>{if(i||!e.isConnected||!n.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(n.scrollTop+=u,In("ui.sidebar.selection_scroll_anchor_adjustment")),o-=1,o<=0){a();return}c=window.requestAnimationFrame(d)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),Sa.set(n,a),c=window.requestAnimationFrame(d)},_j=l.memo(function(e){const n=tt.c(22),{archiveLabel:r,deleteLabel:o,buttonSizeClass:i,iconSizeClass:c,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:h}=e,f=gj(),g=f?o:r;let b;n[0]!==u||n[1]!==h||n[2]!==f?(b=A=>{if(f||A.shiftKey){h(A);return}u(A)},n[0]=u,n[1]=h,n[2]=f,n[3]=b):b=n[3];const S=b,v=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let p;n[4]!==i||n[5]!==v?(p=ye("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",v,i),n[4]=i,n[5]=v,n[6]=p):p=n[6];const m=f?"delete-bin":"archive";let x;n[7]!==c||n[8]!==m?(x=s.jsx(R,{name:m,className:c}),n[7]=c,n[8]=m,n[9]=x):x=n[9];let w;n[10]!==S||n[11]!==g||n[12]!==d||n[13]!==a||n[14]!==p||n[15]!==x?(w=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",className:p,"aria-label":g,onPointerDown:a,onMouseDown:d,onClick:S,onKeyDown:Kj,children:x})}),n[10]=S,n[11]=g,n[12]=d,n[13]=a,n[14]=p,n[15]=x,n[16]=w):w=n[16];let j;n[17]!==g?(j=s.jsx(ft,{side:"left",sideOffset:8,children:g}),n[17]=g,n[18]=j):j=n[18];let N;return n[19]!==w||n[20]!==j?(N=s.jsxs(dt,{children:[w,j]}),n[19]=w,n[20]=j,n[21]=N):N=n[21],N});function $j(t){In("ui.sidebar_session_node.render");const{t:e}=mt(),{node:n,depth:r=0,groupDirectory:o,projectId:i,archivedBucket:c=!1,pinnedSessionIds:a,expandedParents:d,hasSessionSearchQuery:u,normalizedSessionSearchQuery:h,notifyOnSubtasks:f,editingId:g,setEditingId:b,editTitle:S,setEditTitle:v,handleSaveEdit:p,handleCancelEdit:m,toggleParent:x,handleSessionSelect:w,handleSessionDoubleClick:j,togglePinnedSession:N,handleShareSession:A,copiedSessionId:k,handleCopyShareUrl:C,handleCopySessionId:P,handleUnshareSession:D,openSidebarMenuKey:F,setOpenSidebarMenuKey:B,renamingFolderId:E,getFoldersForScope:_,getSessionFolderId:W,removeSessionFromFolder:V,addSessionToFolder:K,createFolderAndStartRename:y,openContextPanelTab:I,handleDeleteSession:$,handleRestoreSession:z,mobileVariant:G,alwaysShowActions:J,renderSessionNode:Z,secondaryMeta:re,renderContext:ee="project",subtreeContainsEditing:he,menuOpenSessionId:be,childRenderExtrasFor:Y}=t,we=l.useMemo(()=>er(),[]),me=l.useMemo(()=>Ri(),[]),Q=l.useContext(sp),pe=we?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto",ve=we?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",Te=we,ke=!c&&!G,Ie=we?ke&&Te?"group-hover:pr-18":ke||Te?"group-hover:pr-14":"group-hover:pr-8":ke?"group-hover:pr-7 group-focus-within:pr-7":"group-hover:pr-3 group-focus-within:pr-3",Ne=ke?"pr-13":"pr-7",Ae=l.useRef(!1),[Se,Oe]=l.useState(!1),ne=l.useRef(g);ne.current=g;const ce=l.useRef(null),Re=l.useRef(p);Re.current=p;const[te,ae]=l.useState(S),de=l.useRef(te);de.current=te;const H=l.useRef(null),ge=l.useRef(null),ue=n.session,M=ue,oe=qt(l.useCallback(Ce=>{if(re?.projectLabel||!i)return null;const At=Ce.projects.find(Ht=>Ht.id===i);return At?At.label?.trim()||hr(wt(At.path)??At.path,null)||At.path:null},[i,re?.projectLabel])),De=re?.projectLabel??(oe?pl(oe):null),fe=re?.branchLabel??n.worktree?.branch??null,X=l.useMemo(()=>{if(we)return null;const Ce=n.worktree?.branch?.trim(),At=wt(n.worktree?.path??null);return Ce&&At?Li(At,Ce):null},[we,n.worktree]),le=Nu(X),se=le?`var(--pr-${le.visualState})`:void 0,T=As(Ce=>Ce.sessionGroupingMode),ie=!!fe&&(ee==="recent"||T==="flat"),je=l.useMemo(()=>{if(!le)return null;switch(le.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return le.canMerge===!0||le.mergeableState==="clean"||le.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return le.mergeableState==="dirty"?e("sessions.sidebar.group.pr.status.mergeConflicts"):e("sessions.sidebar.group.pr.status.mergeBlocked");case"draft":return e("sessions.sidebar.group.pr.status.draft");case"closed":return e("sessions.sidebar.group.pr.status.closed");default:return null}},[le,e]),Pe=Je(Ce=>Ce.currentSessionId===ue.id),U=wt(ue.directory??null)??wt(o??null),Be=i??U??null,Fe=ol(U??void 0,{bootstrap:!1}),Ye=Fi(),at=Ns(Ce=>Ce.enabled),st=Ns(l.useCallback(Ce=>Ce.selectedIds.has(ue.id),[ue.id])),ct=Ns(Ce=>Ce.toggleSelected),bt=Ns(Ce=>Ce.setRange),rt=l.useCallback(Ce=>{const At=[],Ht=ns=>{ns.children.forEach(gs=>{At.push(gs.session.id),Ht(gs)})};return Ht(Ce),At},[]),gt=l.useCallback(Ce=>{const At=[],Ht=ns=>{ns.children.forEach(gs=>{At.push(gs.session),Ht(gs)})};return Ht(Ce),At},[]),[it,Et]=l.useState(!1),[Ft,Dt]=l.useState(!0),Bt=`${ee}:${c?"archived":"active"}:${ue.id}`,qe=Eu(l.useCallback(Ce=>!!Ce.sessionMemoryState.get(np(ue.id))?.isZombie,[ue.id])),Nt=lu(ue.id)?.type??"idle",xt=Nt==="busy"||Nt==="retry",Pt=rp(ue.id,xt),Mt=cf(ue.id),Xt=op(ue.id,U??void 0,{bootstrap:!1}),Qe=ip(M),ht=Qe?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(ic[Qe.status]),"aria-label":e(ic[Qe.status]),children:s.jsx(R,{name:"target",className:"h-3 w-3",style:{color:ap[Qe.status]}})}):null,Ze=M.title||e("sessions.sidebar.session.untitled"),$e=n.children.length>0,St=lp(a,U,ue.id),Lt=Bt,Ot=u?!0:d.has(Lt),ss=l.useMemo(()=>j0(n,Ot,U),[Ot,n,U]),_t=cp(ss),Ct=!!M.parentID,hs=dp(ue.id)>0&&(!Ct||f),Rt=M.time?.updated||M.time?.created||Date.now(),$t=Tu(Rt),Wt=up(Rt),is=F===Bt,[Me,Ke]=l.useState(!1),ze=is||Me,He=l.useMemo(()=>ui(M.title)!==null,[M.title]),[Ve,jt]=l.useState(!1),Jt=l.useMemo(()=>rt(n).length,[rt,n]),yt=l.useCallback(async Ce=>{const At=[];let Ht=0;for(const ns of Ce)try{if(!U)throw new Error("Session directory is required for export");await Ye.loadCompleteHistory(ns.session.id,U);const gs=Ea(Fe.getState(),ns.session.id).list,us=ns.session.title||e("sessions.sidebar.session.export.untitledSubagent"),on=ns.session.agent,ks=await yt(ns.children);Ht+=ks.skipped,At.push({title:us,agent:on,records:gs,children:ks.children})}catch{Ht+=rt(ns).length+1}return{children:At,skipped:Ht}},[rt,Fe,U,Ye,e]),Yt=l.useCallback(Ce=>{Ce<=0||Ee.warning(Ce===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Ce}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Ce}))},[e]),ps=l.useCallback(async Ce=>{if(!U){Ee.error(e("sessions.sidebar.session.export.nothingToExport"));return}try{await Ye.loadCompleteHistory(ue.id,U)}catch{Ee.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}const At=Ea(Fe.getState(),ue.id).list;if(At.length===0){Ee.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Ht,ns=0;if(Ce&&n.children.length>0){const ks=await yt(n.children);Ht=ks.children,ns=ks.skipped}const gs=rf(At,M.title??null,Ht),us=lf(M.title??null),on=await af(gs,us);if(on){Ee.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Gx()),onClick:()=>{Kx(on).then(ks=>{ks||Ee.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),Yt(ns);return}of(gs,us),Ee.success(e("sessions.sidebar.session.export.success")),Yt(ns)},[yt,Fe,n.children,M.title,ue.id,U,Yt,Ye,e]),Zt=l.useCallback(async()=>{if(n.children.length>0){Dt(!0),Et(!0);return}await ps(!1)},[ps,n.children.length]),Ss=l.useCallback(()=>{U&&ur("desktop_open_session_mini_chat_window",{sessionId:ue.id,directory:U,apiBaseUrl:fr(),clientToken:ko()}).catch(Ce=>{console.warn("[session-sidebar] failed to open mini chat window",Ce)})},[ue.id,U]);if(l.useEffect(()=>{if(g!==ue.id)return;const Ce=At=>{const ns=At.target?.closest?.(`[data-session-rename-form="${CSS.escape(ue.id)}"]`);ge.current&&!ns&&Re.current(de.current)};return document.addEventListener("mousedown",Ce),()=>document.removeEventListener("mousedown",Ce)},[g,ue.id]),l.useLayoutEffect(()=>{if(g!==ue.id){H.current===ue.id&&(H.current=null);return}H.current!==ue.id&&(H.current=ue.id,ae(S))},[g,S,ue.id]),g===ue.id)return s.jsx("div",{style:{paddingLeft:gd+r*Xo},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:s.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:s.jsxs("form",{ref:ge,"data-session-rename-form":ue.id,className:"flex w-full items-center gap-2",onSubmit:Ce=>{Ce.preventDefault(),p(te)},children:[s.jsx("input",{value:te,onChange:Ce=>ae(Ce.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:Ce=>{if(Ce.stopPropagation(),Ce.key==="Escape"){m();return}}}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:m,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"size-4"})})]})})},ue.id);const en=Xt.length,Mn=_t===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:_t}),Un=!Mt&&!xt&&hs&&!Pe,Ps=xt||Un,Ms=e(xt?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),tn=s.jsx("span",{className:ye("h-1.5 w-1.5 rounded-full",xt?"bg-primary":"bg-[var(--status-info)]"),"aria-label":Ms,title:Ms}),jn=(xt||Un)&&Pt,Hs=!J&&$e&&(Mt||Ps||St),Es=St&&!Mt&&!Ps,kn=s.jsx(R,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),sn=Mt||Ps||Es?s.jsx("span",{style:{left:el+r*Xo},className:ye("pointer-events-none absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center transition-opacity",Hs?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:Mt?s.jsx(R,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e("sessions.sidebar.session.status.movingToWorktree")}):Ps?tn:Es?kn:null}):null,Ks=$e&&!J&&(Mt||Ps||St),Gs=$e?s.jsx("span",{role:"button",tabIndex:0,onClick:Ce=>{Ce.stopPropagation(),Ce.currentTarget.blur(),x(Lt)},onKeyDown:Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),Ce.stopPropagation(),x(Lt))},style:{minWidth:14,minHeight:14,left:el+r*Xo},className:ye("absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",Ks?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto":""),"aria-label":e(Ot?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:Ot?s.jsx(R,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(R,{name:"arrow-right-s",className:"h-3 w-3"})}):null,sr=qe?s.jsx(R,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Cn=Ce=>{Ce&&Ke(!1),B(Ce?Bt:null)},q=Ce=>{if(!Ce&&ce.current){const{id:At,title:Ht}=ce.current;ce.current=null,b(At),v(Ht)}},We=Ce=>{Ke(Ce)},et=Ce=>{Ce.preventDefault(),Ce.stopPropagation(),B(is?null:Bt)},lt=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},Tt=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},kt=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},pt=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},ds=Ce=>{Ce.preventDefault(),Ce.stopPropagation(),B(null),$(ue,{archivedBucket:c})},vs=Ce=>{Ce.preventDefault(),Ce.stopPropagation(),B(null),$(ue,{archivedBucket:c,hardDelete:!0,skipConfirm:!0})},es=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},Ts=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},js=Ce=>{Ce.preventDefault(),Ce.stopPropagation(),Q?.vscode?.executeCommand("openchamber.openSessionInEditor",ue.id,Ze)},Wn=Ce=>{if(Ae.current){Ae.current=!1;return}if(at){if(Ce?.preventDefault(),Ce?.stopPropagation(),Ce?.shiftKey){const Ht=(typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[]).map(us=>us.getAttribute("data-session-row")).filter(us=>typeof us=="string"&&us.length>0),ns=Ns.getState().anchorId,gs=new Map;gs.set(ue.id,rt(n)),bt(ns,ue.id,Ht,Be,gs);return}ct(ue.id,Be,rt(n));return}Ce?.currentTarget&&Lj(Ce.currentTarget),w(ue.id,U)},nn=Ce=>{Ce.defaultPrevented||Ce.target?.closest('button, a, input, [role="menuitem"], [role="menu"]')||Wn(Ce)},nr=Ce=>{(Ce.button===2||Ce.button===0&&Ce.ctrlKey&&!at)&&(Ae.current=!0)},rn=Ce=>{G&&Ce.pointerType==="touch"&&Oe(!0)},Nn=Ce=>{G&&Ce.pointerType==="touch"&&Oe(!1)},br=({Item:Ce,Separator:At,Sub:Ht,SubTrigger:ns,SubContent:gs})=>s.jsxs(s.Fragment,{children:[s.jsxs(Ce,{onClick:()=>{ce.current={id:ue.id,title:Ze}},className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsxs(Ce,{onClick:()=>P(ue.id),className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Ce,{onClick:()=>U&&N({directory:U,sessionId:ue.id}),className:"[&>svg]:mr-1",children:[St?s.jsx(R,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(R,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(St?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),M.share?s.jsxs(s.Fragment,{children:[s.jsx(Ce,{onClick:()=>{M.share?.url&&C(M.share.url,ue.id)},className:"[&>svg]:mr-1",children:k===ue.id?s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"check",className:"mr-1 h-4 w-4",style:{color:"var(--status-success)"}}),e("sessions.sidebar.session.menu.copied")]}):s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyLink")]})}),s.jsxs(Ce,{onClick:()=>D(ue.id),className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"link-unlink-m",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Ce,{onClick:()=>A(M),className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"share-2",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.share")]}),s.jsxs(Ce,{onClick:()=>{Zt()},className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),!Ct&&!c&&!we?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Ce,{disabled:!U||xt||Mt,onClick:()=>{!U||xt||Mt||df({root:M,descendants:gt(n),sourceDirectory:U,successMessage:e("sessions.sidebar.session.moveToWorktree.success"),failureMessage:e("sessions.sidebar.session.moveToWorktree.failed")})},className:"w-full [&>svg]:mr-1",children:[s.jsx(R,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(ft,{side:"right",className:"max-w-72",children:e(Mt?"sessions.sidebar.session.moveToWorktree.tooltipMoving":xt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,He?s.jsxs(Ce,{onClick:()=>jt(!0),className:"[&>svg]:mr-1",children:[s.jsx(Bj,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,U&&!c?(()=>{const us=[],on=xs=>{const fs=wt(xs??null);fs&&!us.includes(fs)&&us.push(fs)};if(i&&!we){const xs=qt.getState().projects.find(An=>An.id===i),fs=wt(xs?.path??null);on(fs),fs&&(Je.getState().availableWorktreesByProject.get(fs)??[]).forEach(An=>on(An.path))}on(U);const ks=us.flatMap(xs=>_(xs).map(fs=>({scope:xs,folder:fs}))),qs=ks.find(({scope:xs,folder:fs})=>W(xs,ue.id)===fs.id)??null,wr=us[0]??U;return s.jsxs(s.Fragment,{children:[s.jsx(At,{}),s.jsxs(Ht,{children:[s.jsxs(ns,{className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(gs,{className:"min-w-[180px]",children:[ks.length===0?s.jsx(Ce,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):ks.map(({scope:xs,folder:fs})=>{const An=qs?.folder.id===fs.id;return s.jsxs(Ce,{onClick:()=>{if(An){V(xs,ue.id);return}qs&&qs.scope!==xs&&V(qs.scope,ue.id),K(xs,fs.id,ue.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:fs.name}),An?s.jsx(R,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},fs.id)}),s.jsx(At,{}),s.jsxs(Ce,{onClick:()=>{const xs=y(wr);xs&&(qs&&qs.scope!==wr&&V(qs.scope,ue.id),K(wr,xs.id,ue.id))},children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),qs?s.jsxs(Ce,{onClick:()=>{V(qs.scope,ue.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(R,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,we?null:s.jsxs(Ce,{disabled:!U,onClick:()=>{U&&I(U,{mode:"chat",dedupeKey:`session:${ue.id}`,label:Ze,sessionTitleFallback:Ze})},className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),me?s.jsxs(Ce,{disabled:!U,onClick:Ss,className:"[&>svg]:mr-1",children:[s.jsx(R,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(At,{}),c?null:s.jsxs(Ce,{className:"[&>svg]:mr-1",onClick:()=>$(ue,{archivedBucket:c}),children:[s.jsx(R,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),c?s.jsxs(Ce,{className:"[&>svg]:mr-1",onClick:()=>z(ue),children:[s.jsx(R,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Ce,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>$(ue,{archivedBucket:c,hardDelete:!0}),children:[s.jsx(R,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),yr=s.jsx(yn,{align:"end",className:"min-w-[180px]",finalFocus:()=>!(E||ne.current),children:br({Item:Gt,Separator:gn,Sub:pp,SubTrigger:gp,SubContent:xp})}),vr=s.jsx(vc,{children:s.jsx(wc,{className:"app-region-no-drag z-50",children:s.jsx(Sc,{"data-slot":"dropdown-menu-content",finalFocus:()=>!(E||ne.current),style:{color:"var(--surface-elevated-foreground)"},className:ye(ac,"min-w-[180px]"),children:br({Item:({className:Ce,...At})=>s.jsx(lx,{className:ye(fp,Ce),...At}),Separator:({className:Ce,...At})=>s.jsx(cx,{className:ye(mp,Ce),...At}),Sub:dx,SubTrigger:({className:Ce,children:At,...Ht})=>s.jsxs(ux,{className:ye(hp,Ce),...Ht,children:[At,s.jsx(R,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Ce,children:At,...Ht})=>s.jsx(vc,{children:s.jsx(wc,{className:"app-region-no-drag z-50",children:s.jsx(Sc,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:ye(ac,Ce),...Ht,children:At})})})})})})});return s.jsxs(l.Fragment,{children:[s.jsx(v0,{sessionId:ue.id,sessionDirectory:U??null,sessionTitle:Ze,children:s.jsxs(ix,{open:Me,onOpenChange:We,onOpenChangeComplete:q,children:[s.jsxs(ax,{render:s.jsx("div",{"data-session-row":ue.id,"data-session-scope":Be??"","data-session-archived":c?"1":"0",onClick:nn,style:{paddingLeft:gd+r*Xo},className:ye("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-1.5",Pe&&!st&&"bg-primary/10",st&&"bg-interactive-selection")}),children:[sn,Gs,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onPointerDown:rn,onPointerUp:Nn,onPointerCancel:Nn,onMouseDown:nr,onClick:Ce=>Wn(Ce),onDoubleClick:Ce=>{Ce.stopPropagation(),j(ue.id,Ze)},className:ye("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 text-foreground select-none transition-[padding]",Se&&"bg-interactive-hover/70",J?we?Ie:Ne:Ie),children:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:ye("block min-w-0 flex-1 truncate typography-ui-label font-normal",Pe?"text-primary":hs?"text-foreground":"text-foreground/80"),children:oi(Ze,h)}),J?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 text-[0.72rem] text-muted-foreground/75",children:jn?s.jsx(xc,{sessionId:ue.id,running:xt}):s.jsxs(s.Fragment,{children:[ht,ie?s.jsx(R,{name:"git-branch",className:ye("h-3 w-3",!se&&"text-muted-foreground/60"),style:se?{color:se}:void 0}):null,Wt]})}):jn||ht||ie?s.jsx("div",{className:"relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",children:s.jsx("span",{className:ye("inline-flex items-center gap-1 whitespace-nowrap text-right transition-opacity duration-150",ze?"opacity-0":ve),children:jn?s.jsx(xc,{sessionId:ue.id,running:xt,className:"text-[0.72rem]"}):s.jsxs(s.Fragment,{children:[ht,ie?s.jsx(R,{name:"git-branch",className:ye("h-3 w-3",!se&&"text-muted-foreground/60"),style:se?{color:se}:void 0}):null]})})}):null,en>0?s.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(R,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:en})]}):null,_t>0?s.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info flex-shrink-0",title:Mn,"aria-label":Mn,children:[s.jsx(R,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:_t})]}):null]})})}),we?null:s.jsx(ft,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:Ze}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:$t,children:Wt})]}),De?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(R,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:De})]}):null,fe?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(R,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:se?{color:se}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:fe})]}):null,le&&je?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(R,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:se?{color:se}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:se?{color:se}:void 0,children:["#",le.number," · ",je]})]}):null]})})]})}),sr&&!G?s.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 z-10",children:sr}):null,s.jsxs("div",{className:ye("absolute right-0 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",ze||J&&!we?"opacity-100":ye("opacity-0",pe)),children:[ke?s.jsx(_j,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:J?"h-6 w-6":"h-4 w-4",iconSizeClass:J?"h-3.5 w-3.5":"h-2.5 w-2.5",onPointerDown:kt,onMouseDown:pt,onArchive:ds,onDelete:vs}):null,Te?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",className:ye("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",J?"h-6 w-6":"h-4 w-4"),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:es,onMouseDown:Ts,onClick:js,onKeyDown:Ce=>Ce.stopPropagation(),children:s.jsx(R,{name:"external-link",className:ye(J?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),s.jsx(ft,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(vn,{open:is,onOpenChange:Cn,onOpenChangeComplete:q,children:[s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:ye("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",J?"h-6 w-6 opacity-100":ze?"h-4 w-4 opacity-100":ye("h-4 w-4 opacity-0",pe)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:lt,onMouseDown:Tt,onClick:et,onKeyDown:Ce=>Ce.stopPropagation(),children:s.jsx(R,{name:"more-2",className:ye(J?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),yr]})]})]}),vr]})}),$e&&Ot?n.children.map(Ce=>{const At=Y?Y(Ce):{subtreeContainsEditing:he,menuOpenSessionId:be,nodeStructureKey:""};return Z(Ce,r+1,U??o,i,c,void 0,ee,At)}):null,s.jsx(Ws,{open:it,onOpenChange:Et,children:s.jsxs(Vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Rn,{children:[s.jsx(wn,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Sn,{children:Jt===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:Jt}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:Jt})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Ft,onChange:Ce=>Dt(Ce.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(gr,{children:[s.jsx(nt,{type:"button",onClick:()=>Et(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(nt,{type:"button",onClick:()=>{Et(!1),ps(Ft)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),He?s.jsx(Fj,{session:M,open:Ve,onOpenChange:jt}):null]},ue.id)}const xd=t=>wt(t.session.directory??null),zj=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),Uj=t=>{if(!t.openSidebarMenuKey)return null;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},Jo=t=>t.menuOpenSessionId??Uj(t),Zo=(t,e,n)=>e?n.has(t.node.session.id)?!0:Gn(t.node,e):!1,tl=(t,e,n,r,o)=>{if(t.session.id!==e.session.id)return!0;const i=o(t);if(n.has(i)!==r.has(i)||t.children.length!==e.children.length)return!0;for(let c=0;c<t.children.length;c+=1)if(tl(t.children[c],e.children[c],n,r,o))return!0;return!1},Wj=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return tl(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${t.renderContext??"project"}:${n}:${o.session.id}`)||tl(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${e.renderContext??"project"}:${r}:${o.session.id}`)},Vj=(t,e)=>{if(t.node.session.id!==e.node.session.id||t.node.session!==e.node.session||t.depth!==e.depth||t.groupDirectory!==e.groupDirectory||t.projectId!==e.projectId||t.archivedBucket!==e.archivedBucket||(t.renderContext??"project")!==(e.renderContext??"project")||t.mobileVariant!==e.mobileVariant||t.alwaysShowActions!==e.alwaysShowActions||t.hasSessionSearchQuery!==e.hasSessionSearchQuery||t.normalizedSessionSearchQuery!==e.normalizedSessionSearchQuery||t.notifyOnSubtasks!==e.notifyOnSubtasks||t.nodeStructureKey!==e.nodeStructureKey||xd(t.node)!==xd(e.node)||!zj(t.secondaryMeta,e.secondaryMeta)||t.pinnedSessionIds!==e.pinnedSessionIds&&_f(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory)||t.expandedParents!==e.expandedParents&&Wj(t,e)||t.editingId!==e.editingId&&(Zo(t,t.editingId,t.subtreeContainsEditing)||Zo(e,e.editingId,e.subtreeContainsEditing))||t.editTitle!==e.editTitle&&(Zo(t,t.editingId,t.subtreeContainsEditing)||Zo(e,e.editingId,e.subtreeContainsEditing))||t.copiedSessionId!==e.copiedSessionId&&(Gn(t.node,t.copiedSessionId)||Gn(e.node,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=Jo(t),r=Jo(e);if(Gn(t.node,n)||Gn(e.node,r))return!1}if(t.renamingFolderId!==e.renamingFolderId){const n=Jo(t),r=Jo(e);if(Gn(t.node,n)||Gn(e.node,r))return!1}return t.setEditingId===e.setEditingId&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.togglePinnedSession===e.togglePinnedSession&&t.handleShareSession===e.handleShareSession&&t.handleCopyShareUrl===e.handleCopyShareUrl&&t.handleCopySessionId===e.handleCopySessionId&&t.handleUnshareSession===e.handleUnshareSession&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.getFoldersForScope===e.getFoldersForScope&&t.getSessionFolderId===e.getSessionFolderId&&t.removeSessionFromFolder===e.removeSessionFromFolder&&t.addSessionToFolder===e.addSessionToFolder&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.openContextPanelTab===e.openContextPanelTab&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.renderSessionNode===e.renderSessionNode},Hj=l.memo($j,Vj);function Kj(t){return t.stopPropagation()}function Gj(t){const e=tt.c(71),{t:n}=mt(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:c,onConfirm:a}=t;let d,u,h,f,g,b,S,v,p,m;if(e[0]!==o||e[1]!==n||e[2]!==r){const I=n("sessions.sidebar.session.untitled");f=Ws,p=!!r,e[13]!==o?(m=z=>{z||o(null)},e[13]=o,e[14]=m):m=e[14],h=Vs,S=!1,v="max-w-sm gap-5",u=Rn;let $;e[15]!==n||e[16]!==r?.archivedBucket?($=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=$):$=e[17],e[18]!==$?(b=s.jsx(wn,{children:$}),e[18]=$,e[19]=b):b=e[19],d=Sn,g=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||I,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||I,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||I,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||I,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||I}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||I}),e[0]=o,e[1]=n,e[2]=r,e[3]=d,e[4]=u,e[5]=h,e[6]=f,e[7]=g,e[8]=b,e[9]=S,e[10]=v,e[11]=p,e[12]=m}else d=e[3],u=e[4],h=e[5],f=e[6],g=e[7],b=e[8],S=e[9],v=e[10],p=e[11],m=e[12];let x;e[20]!==d||e[21]!==g?(x=s.jsx(d,{children:g}),e[20]=d,e[21]=g,e[22]=x):x=e[22];let w;e[23]!==u||e[24]!==b||e[25]!==x?(w=s.jsxs(u,{children:[b,x]}),e[23]=u,e[24]=b,e[25]=x,e[26]=w):w=e[26];let j;e[27]!==c||e[28]!==i?(j=()=>c(!i),e[27]=c,e[28]=i,e[29]=j):j=e[29];const N=!i;let A;e[30]!==i?(A=i?s.jsx(R,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(R,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=i,e[31]=A):A=e[31];let k;e[32]!==n?(k=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=k):k=e[33];let C;e[34]!==A||e[35]!==k||e[36]!==j||e[37]!==N?(C=s.jsxs("button",{type:"button",onClick:j,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":N,children:[A,k]}),e[34]=A,e[35]=k,e[36]=j,e[37]=N,e[38]=C):C=e[38];let P;e[39]!==o?(P=()=>o(null),e[39]=o,e[40]=P):P=e[40];let D;e[41]!==n?(D=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=D):D=e[42];let F;e[43]!==P||e[44]!==D?(F=s.jsx("button",{type:"button",onClick:P,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:D}),e[43]=P,e[44]=D,e[45]=F):F=e[45];let B;e[46]!==a?(B=()=>{a()},e[46]=a,e[47]=B):B=e[47];let E;e[48]!==n||e[49]!==r?.archivedBucket?(E=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=E):E=e[50];let _;e[51]!==B||e[52]!==E?(_=s.jsx("button",{type:"button",onClick:B,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:E}),e[51]=B,e[52]=E,e[53]=_):_=e[53];let W;e[54]!==F||e[55]!==_?(W=s.jsxs("div",{className:"flex items-center gap-2",children:[F,_]}),e[54]=F,e[55]=_,e[56]=W):W=e[56];let V;e[57]!==C||e[58]!==W?(V=s.jsxs(gr,{className:"w-full sm:items-center sm:justify-between",children:[C,W]}),e[57]=C,e[58]=W,e[59]=V):V=e[59];let K;e[60]!==h||e[61]!==S||e[62]!==V||e[63]!==v||e[64]!==w?(K=s.jsxs(h,{showCloseButton:S,className:v,children:[w,V]}),e[60]=h,e[61]=S,e[62]=V,e[63]=v,e[64]=w,e[65]=K):K=e[65];let y;return e[66]!==f||e[67]!==K||e[68]!==p||e[69]!==m?(y=s.jsx(f,{open:p,onOpenChange:m,children:K}),e[66]=f,e[67]=K,e[68]=p,e[69]=m,e[70]=y):y=e[70],y}function qj(t){const e=tt.c(57),{t:n}=mt(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:c,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let h;e[0]!==d||e[1]!==u||e[2]!==n?(h=n(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]=n,e[3]=h):h=e[3];const f=h;let g;e[4]!==d||e[5]!==u||e[6]!==n?(g=d?u===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=n,e[7]=g):g=e[7];const b=g,S=!!r;let v;e[8]!==o?(v=y=>{y||o(null)},e[8]=o,e[9]=v):v=e[9];let p;e[10]!==f?(p=s.jsx(wn,{children:f}),e[10]=f,e[11]=p):p=e[11];let m;e[12]!==b?(m=s.jsx(Sn,{children:b}),e[12]=b,e[13]=m):m=e[13];let x;e[14]!==p||e[15]!==m?(x=s.jsxs(Rn,{children:[p,m]}),e[14]=p,e[15]=m,e[16]=x):x=e[16];let w;e[17]!==c||e[18]!==i?(w=()=>c(!i),e[17]=c,e[18]=i,e[19]=w):w=e[19];const j=!i;let N;e[20]!==i?(N=i?s.jsx(R,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(R,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=i,e[21]=N):N=e[21];let A;e[22]!==n?(A=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=A):A=e[23];let k;e[24]!==A||e[25]!==w||e[26]!==j||e[27]!==N?(k=s.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-primary/50","aria-pressed":j,children:[N,A]}),e[24]=A,e[25]=w,e[26]=j,e[27]=N,e[28]=k):k=e[28];let C;e[29]!==o?(C=()=>o(null),e[29]=o,e[30]=C):C=e[30];let P;e[31]!==n?(P=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=P):P=e[32];let D;e[33]!==C||e[34]!==P?(D=s.jsx("button",{type:"button",onClick:C,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:P}),e[33]=C,e[34]=P,e[35]=D):D=e[35];let F;e[36]!==a?(F=()=>{a()},e[36]=a,e[37]=F):F=e[37];let B;e[38]!==d||e[39]!==n?(B=n(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=n,e[40]=B):B=e[40];let E;e[41]!==F||e[42]!==B?(E=s.jsx("button",{type:"button",onClick:F,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:B}),e[41]=F,e[42]=B,e[43]=E):E=e[43];let _;e[44]!==D||e[45]!==E?(_=s.jsxs("div",{className:"flex items-center gap-2",children:[D,E]}),e[44]=D,e[45]=E,e[46]=_):_=e[46];let W;e[47]!==k||e[48]!==_?(W=s.jsxs(gr,{className:"w-full sm:items-center sm:justify-between",children:[k,_]}),e[47]=k,e[48]=_,e[49]=W):W=e[49];let V;e[50]!==W||e[51]!==x?(V=s.jsxs(Vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[x,W]}),e[50]=W,e[51]=x,e[52]=V):V=e[52];let K;return e[53]!==S||e[54]!==V||e[55]!==v?(K=s.jsx(Ws,{open:S,onOpenChange:v,children:V}),e[53]=S,e[54]=V,e[55]=v,e[56]=K):K=e[56],K}function Yj(t){const e=tt.c(36),{t:n}=mt(),{value:r,setValue:o,onConfirm:i}=t,c=!!r;let a;e[0]!==o?(a=N=>{N||o(null)},e[0]=o,e[1]=a):a=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=d):d=e[3];let u;e[4]!==d?(u=s.jsx(wn,{children:d}),e[4]=d,e[5]=u):u=e[5];let h;e[6]!==n||e[7]!==r?(h=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=h):h=e[8];let f;e[9]!==h?(f=s.jsx(Sn,{children:h}),e[9]=h,e[10]=f):f=e[10];let g;e[11]!==u||e[12]!==f?(g=s.jsxs(Rn,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=g):g=e[13];let b;e[14]!==o?(b=()=>o(null),e[14]=o,e[15]=b):b=e[15];let S;e[16]!==n?(S=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=S):S=e[17];let v;e[18]!==b||e[19]!==S?(v=s.jsx("button",{type:"button",onClick:b,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:S}),e[18]=b,e[19]=S,e[20]=v):v=e[20];let p;e[21]!==n?(p=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=p):p=e[22];let m;e[23]!==i||e[24]!==p?(m=s.jsx("button",{type:"button",onClick:i,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:p}),e[23]=i,e[24]=p,e[25]=m):m=e[25];let x;e[26]!==m||e[27]!==v?(x=s.jsxs(gr,{children:[v,m]}),e[26]=m,e[27]=v,e[28]=x):x=e[28];let w;e[29]!==x||e[30]!==g?(w=s.jsxs(Vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[g,x]}),e[29]=x,e[30]=g,e[31]=w):w=e[31];let j;return e[32]!==c||e[33]!==a||e[34]!==w?(j=s.jsx(Ws,{open:c,onOpenChange:a,children:w}),e[32]=c,e[33]=a,e[34]=w,e[35]=j):j=e[35],j}const Qj=t=>{const e=tt.c(51),{selectedCount:n,scopeKey:r,scopeFolders:o,archivedBucket:i,onMoveToFolder:c,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:h,onDelete:f,onDone:g}=t,{t:b}=mt(),S=!!r&&!i;let v;e[0]!==i||e[1]!==b?(v=b(i?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[0]=i,e[1]=b,e[2]=v):v=e[2];const p=v;let m;e[3]!==n||e[4]!==b?(m=b("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[3]=n,e[4]=b,e[5]=m):m=e[5];let x;e[6]!==m?(x=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:m}),e[6]=m,e[7]=x):x=e[7];let w;e[8]!==S||e[9]!==u||e[10]!==a||e[11]!==c||e[12]!==d||e[13]!==o||e[14]!==b?(w=S?s.jsxs(vn,{children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":b("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(R,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(yn,{align:"end",className:"min-w-[180px]",children:[o.length===0?s.jsx(Gt,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):o.map(y=>s.jsx(Gt,{onClick:()=>c(y.id),children:s.jsx("span",{className:"flex-1 truncate",children:y.name})},y.id)),s.jsx(gn,{}),s.jsxs(Gt,{onClick:a,children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(Gt,{onClick:d,className:"text-destructive focus:text-destructive",children:[s.jsx(R,{name:"close",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[8]=S,e[9]=u,e[10]=a,e[11]=c,e[12]=d,e[13]=o,e[14]=b,e[15]=w):w=e[15];let j;e[16]!==i||e[17]!==h||e[18]!==b?(j=i?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":b("sessions.sidebar.bulkActions.restore"),children:s.jsx(R,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[16]=i,e[17]=h,e[18]=b,e[19]=j):j=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=ye("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50"),e[20]=N):N=e[20];let A;e[21]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(R,{name:"delete-bin",className:"h-4 w-4"}),e[21]=A):A=e[21];let k;e[22]!==p||e[23]!==f?(k=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:N,"aria-label":p,children:A})}),e[22]=p,e[23]=f,e[24]=k):k=e[24];let C;e[25]!==p?(C=s.jsx(ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:p})}),e[25]=p,e[26]=C):C=e[26];let P;e[27]!==k||e[28]!==C?(P=s.jsxs(dt,{children:[k,C]}),e[27]=k,e[28]=C,e[29]=P):P=e[29];let D;e[30]!==b?(D=b("sessions.sidebar.header.actions.exitSelection"),e[30]=b,e[31]=D):D=e[31];let F;e[32]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(R,{name:"close",className:"h-4 w-4"}),e[32]=F):F=e[32];let B;e[33]!==g||e[34]!==D?(B=s.jsx(ut,{asChild:!0,children:s.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-primary/50","aria-label":D,children:F})}),e[33]=g,e[34]=D,e[35]=B):B=e[35];let E;e[36]!==b?(E=b("sessions.sidebar.header.actions.exitSelection"),e[36]=b,e[37]=E):E=e[37];let _;e[38]!==E?(_=s.jsx(ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:E})}),e[38]=E,e[39]=_):_=e[39];let W;e[40]!==B||e[41]!==_?(W=s.jsxs(dt,{children:[B,_]}),e[40]=B,e[41]=_,e[42]=W):W=e[42];let V;e[43]!==P||e[44]!==W||e[45]!==w||e[46]!==j?(V=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[w,j,P,W]}),e[43]=P,e[44]=W,e[45]=w,e[46]=j,e[47]=V):V=e[47];let K;return e[48]!==V||e[49]!==x?(K=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5",children:[x,V]}),e[48]=V,e[49]=x,e[50]=K):K=e[50],K},Xj=t=>{const{t:e}=mt(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:o,folderScopesByProject:i,addSessionsToFolder:c,removeSessionsFromFolders:a,createFolderAndStartRename:d,archiveSessions:u,unarchiveSessions:h,deleteSessions:f,setBulkDeleteConfirm:g}=t,b=Ns(y=>y.enabled),S=Ns(y=>y.selectedIds.size),v=S>0,p=Ns(y=>y.selectedIds),m=Ns(y=>y.scopeKey),x=l.useCallback(()=>{Ns.getState().toggleMode()},[]),w=l.useCallback(()=>{Ns.getState().disable()},[]),j=l.useMemo(()=>{if(!v||typeof document>"u")return!1;let y=!1,I=!1;for(const $ of p){const z=document.querySelectorAll(`[data-session-row="${CSS.escape($)}"]`);for(const G of z)G.getAttribute("data-session-archived")==="1"?I=!0:y=!0}return I&&!y},[v,p]),N=l.useMemo(()=>{if(m)return m;if(!v||typeof document>"u")return null;for(const y of p){const $=document.querySelector(`[data-session-row="${CSS.escape(y)}"]`)?.getAttribute("data-session-scope");if($&&$.length>0)return $}return null},[v,p,m]),A=l.useMemo(()=>{if(!N)return[];const y=i.get(N);return y&&y.length>0?y.map(I=>I.scopeKey):[N]},[N,i]),k=l.useMemo(()=>A.flatMap(y=>o[y]??[]),[o,A]),C=l.useCallback(y=>{for(const I of A)if((o[I]??[]).some($=>$.id===y))return I;return null},[o,A]),P=l.useMemo(()=>{if(!v)return!1;for(const y of A)for(const I of o[y]??[])for(const $ of I.sessionIds)if(p.has($))return!0;return!1},[o,A,v,p]),D=l.useCallback((y,I)=>{const $=Array.from(p);for(const z of A)z!==y&&a(z,$);c(y,I,$)},[c,a,p,A]),F=l.useCallback(y=>{if(!v)return;const I=C(y);I&&D(I,y)},[v,D,C]),B=l.useCallback(()=>{const y=A[0];if(!y||!v)return;const I=d(y);I&&D(y,I.id)},[d,v,D,A]),E=l.useCallback(()=>{if(!v)return;const y=Array.from(p);for(const I of A)a(I,y)},[a,p,A,v]),_=l.useCallback(async()=>{const y=Array.from(p);if(y.length!==0){if(j){const{deletedIds:I,failedIds:$}=await f(y);I.length>0&&Ee.success(I.length===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:I.length}):e("sessions.sidebar.bulkActions.deletedPlural",{count:I.length})),$.length>0&&Ee.error($.length===1?e("sessions.sidebar.bulkActions.failedDeleteSingle",{count:$.length}):e("sessions.sidebar.bulkActions.failedDeletePlural",{count:$.length}))}else{const{archivedIds:I,failedIds:$}=await u(y);I.length>0&&Ee.success(I.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:I.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:I.length})),$.length>0&&Ee.error($.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:$.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:$.length}))}Ns.getState().clear()}},[u,j,f,p,e]),W=l.useCallback(()=>{if(!v)return;const y=p.size;if(!r){_();return}g({sessionCount:y,archivedBucket:j})},[j,_,p,r,g,v]),V=l.useCallback(async()=>{if(!v||!j)return;const y=Array.from(p),{restoredIds:I,failedIds:$}=await h(y);I.length>0&&Ee.success(I.length===1?e("sessions.sidebar.bulkActions.restoredSingle",{count:I.length}):e("sessions.sidebar.bulkActions.restoredPlural",{count:I.length})),$.length>0&&Ee.error($.length===1?e("sessions.sidebar.bulkActions.failedRestoreSingle",{count:$.length}):e("sessions.sidebar.bulkActions.failedRestorePlural",{count:$.length})),Ns.getState().clear()},[j,v,p,e,h]),K=l.useCallback(async()=>{g(null),await _()},[_]);return l.useEffect(()=>{if(!b)return;const y=typeof navigator<"u"&&/Macintosh|Mac OS X/.test(navigator.userAgent||""),I=$=>{if(n)return;const z=$.target;if(z&&(z.tagName==="INPUT"||z.tagName==="TEXTAREA"||z.isContentEditable))return;const G=y?$.metaKey:$.ctrlKey;if($.key==="Escape"){$.preventDefault(),Ns.getState().disable();return}if(G&&$.key==="Backspace"){$.preventDefault(),W();return}if(G&&($.key==="a"||$.key==="A")){const J=typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[];if(J.length===0)return;$.preventDefault();const re=Ns.getState().scopeKey??J[0]?.getAttribute("data-session-scope")??null,ee=be=>re?be.getAttribute("data-session-scope")===re:!0,he=J.filter(ee).map(be=>be.getAttribute("data-session-row")).filter(be=>typeof be=="string"&&be.length>0);if(he.length===0)return;Ns.getState().replaceAll(he,re||null)}};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[W,n,b]),{selectionModeEnabled:b,hasSelection:v,selectedIdsSize:S,bulkScopeIsArchived:j,derivedSelectionScope:N,bulkScopeFolders:k,bulkCanRemoveFromFolder:P,handleToggleSelectionMode:x,handleExitSelectionMode:w,handleBulkMoveToFolder:F,handleBulkCreateFolderAndMove:B,handleBulkRemoveFromFolder:E,handleBulkDelete:W,handleBulkRestore:V,confirmBulkDelete:K}},Jj=2880*60*1e3,Zj=t=>!!t.parentID,e2=t=>!!t.time?.archived,t2=t=>{const e=t.time?.updated,n=t.time?.created;return typeof e=="number"&&Number.isFinite(e)?e:typeof n=="number"&&Number.isFinite(n)?n:0},s2=(t,e,n=Date.now())=>{const r=n-Jj;return t.filter(o=>e2(o)||Zj(o)?!1:e.has(o.id)||t2(o)>=r)},bd={selected:0,"active-project":1,expanded:2,visible:3,background:4};function n2(t){const e=new Map,n=(r,o,i)=>{const c=wt(r??null);if(!c)return;const a=e.get(c);a&&bd[a.priority]<=bd[o]||e.set(c,{directory:c,priority:o,reason:i})};for(const r of t.projectSections){const o=!t.collapsedProjects.has(r.project.id);let i="background";r.project.id===t.activeProjectId?i="active-project":o&&(i="expanded"),n(r.project.normalizedPath,i,o?"project-expanded":"known-project");for(const c of r.groups){if(!c.directory||c.isArchivedBucket||c.isMain)continue;const a=o&&!t.collapsedGroups.has(`${r.project.id}:${c.id}`);let d="background";a?d="expanded":o&&(d="visible"),n(c.directory,d,a?"worktree-expanded":"known-worktree")}}return n(t.currentDirectory,"selected","current-directory"),n(t.currentSessionDirectory,"selected","selected-session"),[...e.values()]}const ei="oc.sessions.projectCollapse",yd="oc.sessions.groupOrder",vd="oc.sessions.groupCollapse",wd="oc.sessions.activeSessionByProject",Sd="oc.sessions.expandedParents.v3",r2=(t,e,n)=>{const r=new Set;for(const o of t){const i=wt(o.path)?.toLowerCase();i&&r.add(i)}if(n?.includeWorktrees===!1)return r;for(const o of e.values())for(const i of o){const c=wt(i.path)?.toLowerCase();c&&r.add(c)}return r},o2=(t,e,n)=>{if(t.time?.archived)return!0;const r=wt(Us(t))?.toLowerCase();return r?e.size===0?n?.allowEmptyDirectorySet??!0:e.has(r):n?.allowUnknownDirectory??!0},i2=5*6e4,a2=new Set,ja=[],mn=t=>{const e=l.useRef(t);return e.current=t,l.useCallback((...n)=>e.current(...n),[])},l2=t=>{const e=tt.c(14),{owner:n,childStores:r,projectSections:o,activeProjectId:i,collapsedProjects:c,collapsedGroups:a,currentDirectory:d}=t,u=Je(u2);let h,f;e[0]!==i||e[1]!==r||e[2]!==a||e[3]!==c||e[4]!==d||e[5]!==u||e[6]!==n||e[7]!==o?(h=()=>{r.setBootstrapDemand(n,n2({projectSections:o,activeProjectId:i,collapsedProjects:c,collapsedGroups:a,currentDirectory:d,currentSessionDirectory:u}))},f=[i,r,a,c,d,u,n,o],e[0]=i,e[1]=r,e[2]=a,e[3]=c,e[4]=d,e[5]=u,e[6]=n,e[7]=o,e[8]=h,e[9]=f):(h=e[8],f=e[9]),l.useEffect(h,f);let g,b;return e[10]!==r||e[11]!==n?(g=()=>()=>r.clearBootstrapDemand(n),b=[r,n],e[10]=r,e[11]=n,e[12]=g,e[13]=b):(g=e[12],b=e[13]),l.useEffect(g,b),null},c2=t=>{const e=tt.c(20),{directories:n}=t,{t:r}=mt();let o;e[0]!==n?(o=new Set,n.forEach(h=>{const f=wt(h)?.toLowerCase();f&&o.add(f)}),e[0]=n,e[1]=o):o=e[1];const i=o;let c;e[2]!==i?(c=h=>{for(const f of h.statusById.values()){if(f.status.type!=="busy"&&f.status.type!=="retry")continue;const g=wt(f.directory)?.toLowerCase();if(g&&i.has(g))return!0}return!1},e[2]=i,e[3]=c):c=e[3];const a=Ui(c);let d;e[4]!==i?(d=h=>{for(const[f,g]of Object.entries(h.index.project.unseenCount)){if(!g)continue;const b=wt(f)?.toLowerCase();if(b&&i.has(b))return!0}return!1},e[4]=i,e[5]=d):d=e[5];const u=Wi(d);if(a){let h;e[6]!==r?(h=r("sessions.sidebar.session.status.active"),e[6]=r,e[7]=h):h=e[7];let f;e[8]!==r?(f=r("sessions.sidebar.session.status.active"),e[8]=r,e[9]=f):f=e[9];let g;return e[10]!==h||e[11]!==f?(g=s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary","aria-label":h,title:f}),e[10]=h,e[11]=f,e[12]=g):g=e[12],g}if(u){let h;e[13]!==r?(h=r("sessions.sidebar.session.status.unread"),e[13]=r,e[14]=h):h=e[14];let f;e[15]!==r?(f=r("sessions.sidebar.session.status.unread"),e[15]=r,e[16]=f):f=e[16];let g;return e[17]!==h||e[18]!==f?(g=s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":h,title:f}),e[17]=h,e[18]=f,e[19]=g):g=e[19],g}return null},d2=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:o=!1,showOnlyMainWorkspace:i=!1})=>{Da("react.session_sidebar_render"),In("ui.session_sidebar.render"),In(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),In(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:c}=mt(),[a,d]=l.useState(!1),[u,h]=l.useState(""),f=l.useRef(null),g=l.useRef(null),[b,S]=l.useState(null),[v,p]=l.useState(""),[m,x]=l.useState(null),[w,j]=l.useState(new Set),N=l.useMemo(()=>Hr(),[]),[A,k]=l.useState(new Set),[C,P]=l.useState(new Map),[D,F]=l.useState(new Map),B=xe(L=>L.isNewWorktreeDialogOpen),E=xe(L=>L.setNewWorktreeDialogOpen),[_,W]=l.useState(!1),[V,K]=l.useState(null),[y,I]=l.useState(null),[$,z]=l.useState(""),[G,J]=l.useState(null),[Z,re]=l.useState(null),[ee,he]=l.useState(null),be=No(L=>L.ids),Y=zi(l.useCallback(L=>t?L.rankById:ul,[t])),we=Ui(qn(L=>t?[...L.statusById.keys()].sort():ja)),me=l.useMemo(()=>new Set(we),[we]),Q=Wi(qn(L=>t?Object.entries(L.index.session.unseenCount).filter(([,Ue])=>Ue>0).map(([Ue])=>Ue).sort():ja)),pe=l.useMemo(()=>new Set(Q),[Q]),ve=No(L=>L.toggle),[Te,ke]=l.useState(()=>{try{const L=Hr().getItem(vd);if(!L)return new Set;const Ue=JSON.parse(L);return new Set(Array.isArray(Ue)?Ue.filter(_e=>typeof _e=="string"):[])}catch{return new Set}}),[Ie,Ne]=l.useState(()=>{try{const L=Hr().getItem(yd);if(!L)return new Map;const Ue=JSON.parse(L),_e=new Map;return Object.entries(Ue).forEach(([ot,It])=>{Array.isArray(It)&&_e.set(ot,It.filter(Kt=>typeof Kt=="string"))}),_e}catch{return new Map}}),Ae=l.useMemo(()=>{try{const L=Hr().getItem(wd);if(!L)return new Map;const Ue=JSON.parse(L),_e=new Map;return Object.entries(Ue).forEach(([ot,It])=>{typeof It=="string"&&It.length>0&&_e.set(ot,It)}),_e}catch{return new Map}},[]),Se=l.useCallback(L=>{try{N.setItem(wd,JSON.stringify(Object.fromEntries(L.entries())))}catch{}},[N]),[Oe,ne]=l.useState(new Map),ce=l.useRef(new Map),Re=l.useRef(0),te=ls(L=>L.homeDirectory),ae=ls(L=>L.currentDirectory),de=qt(L=>L.projects),H=qt(L=>L.activeProjectId),ge=qt(L=>L.removeProject),ue=qt(L=>L.setActiveProjectIdOnly),M=qt(L=>L.updateProjectMeta),oe=qt(L=>L.reorderProjects),De=xe(L=>L.setActiveMainTab),fe=xe(L=>L.openContextPanelTab),X=xe(L=>L.setSettingsDialogOpen),le=xe(L=>L.toggleHelpDialog),se=xe(L=>L.setAboutDialogOpen),T=xe(L=>L.setSessionSwitcherOpen),ie=xe(L=>L.setScheduledTasksDialogOpen),je=xe(L=>L.setArchivePageOpen),Pe=xe(L=>L.setWorktreesPageProjectId),U=xe(L=>L.openMultiRunLauncher),Be=xe(L=>L.notifyOnSubtasks),Fe=xe(L=>L.showDeletionDialog),Ye=xe(L=>L.setShowDeletionDialog),at=dl(u,120),st=l.useMemo(()=>at.trim().toLowerCase(),[at]),ct=st.length>0,bt=Fs(L=>L.collapsedFolderIds),rt=Fs(L=>L.foldersMap),gt=Fs(L=>L.getFoldersForScope),it=Fs(L=>L.createFolder),Et=Fs(L=>L.renameFolder),Ft=Fs(L=>L.deleteFolder),Dt=Fs(L=>L.addSessionToFolder),Bt=Fs(L=>L.addSessionsToFolder),qe=Fs(L=>L.removeSessionFromFolder),zt=Fs(L=>L.removeSessionsFromFolders),Nt=Fs(L=>L.toggleFolderCollapse),xt=Fs(L=>L.getSessionFolderId);MS({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:f});const Pt=Su(t),Mt=Fi(),Xt=Au(),Qe=`session-sidebar:${l.useId()}`,ht=bp(),Ze=l.useMemo(()=>Array.from(ht.values()),[ht]),$e=l.useMemo(()=>er(),[]),St=Rs(L=>L.status==="ready"),Lt=Rs(qn(L=>L.activeSessions.map(aa).sort())),Ot=Rs(qn(L=>L.archivedSessions.map(aa).sort())),ss=Rs.getState(),_t=ss.activeSessions,Ct=ss.archivedSessions,os=l.useRef({signature:"",sessions:[]}),hs=l.useMemo(()=>new Set(_t.map(L=>L.id)),[_t]),Rt=(()=>{const L=Ze.filter(_e=>!hs.has(_e.id)),Ue=L.map(aa).sort().join(`
|
|
908
|
-
`);return os.current.signature===Ue?os.current.sessions:(os.current={signature:Ue,sessions:L},L)})(),$t=Je(L=>L.setCurrentSession),Wt=Je(L=>L.updateSessionTitle),is=Je(L=>L.shareSession),Me=Je(L=>L.unshareSession),Ke=Je(L=>L.worktreeMetadata),ze=Je(L=>L.availableWorktreesByProject),He=Je(L=>L.openNewSessionDraft),Ve=l.useCallback(L=>{xe.getState().closeMainSurfaces(),He(L),$e&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[$e,He]),jt=vo(qn(L=>({checkForUpdates:L.checkForUpdates,available:L.available,runtimeType:L.runtimeType,info:L.info,downloading:L.downloading,downloaded:L.downloaded,progress:L.progress,error:L.error,downloadUpdate:L.downloadUpdate,restartToUpdate:L.restartToUpdate}))),Jt=l.useMemo(()=>r2(de,ze,{includeWorktrees:!$e}),[ze,$e,de]),yt=l.useMemo(()=>{const L=[..._t],Ue=new Set(L.map(_e=>_e.id));return Rt.forEach(_e=>{Ue.has(_e.id)||L.push(_e)}),L.filter(_e=>o2(_e,Jt,{allowUnknownDirectory:!$e,allowEmptyDirectorySet:!$e}))},[_t,$e,Jt,Rt]),Yt=l.useMemo(()=>[..._t,...Ct],[Ct,_t]),ps=l.useRef(Ze);l.useEffect(()=>{ps.current=Ze},[Ze]);const Zt=xn(),Ss=l.useMemo(()=>`${Zt}|${de.map(L=>`${L.id}:${wt(L.path)??""}`).join("|")}`,[de,Zt]),[en,Mn]=l.useState($e?Ss:null),[Un,Ps]=l.useReducer(L=>L+1,0),Ms=!$e&&en!==Ss,[tn,jn]=l.useState(new Set),Hs=l.useRef(!1);l.useEffect(()=>{Hs.current||(Hs.current=!0,xi(ps.current))},[]),l.useEffect(()=>{let L=!1;return(async()=>{const _e=Zt,ot=qt.getState().projects;if(ot.length===0||$e){L||(jn(new Set),Mn(Ss));return}const It=Je.getState().availableWorktreesByProject,Kt=new Map(It),Os=new Set,ys=3;let or=0;const Pn=Array.from({length:ys},async()=>{for(;;){const Hn=or;if(or+=1,Hn>=ot.length)return;const Vl=ot[Hn],ar=wt(Vl.path);if(ar)try{const ra=await Ra(async()=>mr.getState().directories.get(ar)?.isGitRepo??await Iu(ar)?wp({id:Vl.id,path:ar}):null);if(ra===null){Kt.delete(ar);continue}if(L)return;ra.length===0?Kt.delete(ar):Kt.set(ar,ra)}catch{Os.add(ar)}}});if(await Promise.all(Pn),L||xn()!==_e)return;const Ur=new Set(ot.map(Hn=>wt(Hn.path)).filter(Boolean));for(const Hn of Kt.keys())Ur.has(Hn)||Kt.delete(Hn);const ir=Sp(ot,Kt),Wl=[...ir.values()].flat();IS(Wl.map(Hn=>Hn.path),Date.now()),jp(ir,It)||Je.setState({availableWorktrees:Wl,availableWorktreesByProject:ir}),jn(Os),Mn(Ss)})(),()=>{L=!0}},[$e,Ss,Zt,Un]),l.useEffect(()=>{let L=null,Ue=!1;const _e=new Set,ot=Dl(It=>{if(It.type==="scheduled-task-ran")Ue=!0;else if(It.type==="session-created")_e.add(It.directory),Ps();else return;L&&clearTimeout(L),L=setTimeout(()=>{if(L=null,Ue){Ue=!1,_e.clear(),xi(ps.current);return}const Kt=[..._e];_e.clear(),Kt.length>0&&ri(Kt,ps.current)},500)});return()=>{L&&clearTimeout(L),ot()}},[]);const Es=l.useMemo(()=>$n(),[]),{isTablet:kn}=pr(),sn=e||kn,{buildGroupSearchText:Ks,filterSessionNodesForSearch:Gs,buildGroupedSessions:sr}=RS({homeDirectory:te,worktreeMetadata:Ke,pinnedSessionIds:be,sessionOrderRanks:Y,gitBranches:Pt,isVSCode:$e}),{scheduleCollapsedProjectsPersist:Cn}=$S({isVSCode:$e,safeStorage:N,keys:{sessionExpanded:Sd,projectCollapse:ei,groupOrder:yd,groupCollapse:vd},groupOrderByProject:Ie,collapsedGroups:Te,setExpandedParents:j,setCollapsedProjects:k}),q=l.useMemo(()=>wu(yt,be,Y),[be,Y,yt]),We=l.useMemo(()=>q.map(L=>L.id).join("|"),[q]),et=l.useRef(null),lt=l.useMemo(()=>{const L=et.current;if(L&&L.signature===We)return L.map;const Ue=new Map(q.map((_e,ot)=>[_e.id,ot]));return et.current={signature:We,map:Ue},Ue},[q,We]),Tt=l.useMemo(()=>{const L=new Map;return q.forEach(Ue=>{const _e=Ue.parentID;if(!_e)return;const ot=L.get(_e)??[];ot.push(Ue),L.set(_e,ot)}),L.forEach(Ue=>Ue.sort((_e,ot)=>to(_e,ot,be,Y))),L},[q,be,Y]),kt=l.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:c("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:c("sessions.sidebar.empty.noSessions.description")})]}),[c]),pt=l.useMemo(()=>de.find(L=>L.id===m)??null,[de,m]),ds=l.useCallback(L=>{m&&M(m,{label:L.label,icon:L.icon,color:L.color,iconBackground:L.iconBackground,defaultModel:L.defaultModel??null})},[m,M]),vs=l.useCallback(()=>{E(!0)},[E]),es=l.useCallback(()=>{const L=vo.getState();if(L.available&&L.info){W(!0);return}jt.checkForUpdates().then(()=>{const{available:Ue,error:_e}=vo.getState();if(_e){Ee.error(c("sessions.sidebar.updateCheck.errorTitle"),{description:_e});return}if(!Ue){Ee.success(c("sessions.sidebar.updateCheck.latestVersion"));return}W(!0)})},[c,jt]),Ts=l.useCallback(()=>{e&&T(!1),X(!0)},[e,T,X]),js=jt.available&&(jt.runtimeType==="desktop"||jt.runtimeType==="web"),Wn=Je(L=>L.deleteSession),nn=Je(L=>L.deleteSessions),nr=Je(L=>L.archiveSession),rn=Je(L=>L.archiveSessions),Nn=Je(L=>L.unarchiveSession),br=Je(L=>L.unarchiveSessions),{copiedSessionId:yr,handleSessionSelect:vr,handleSessionDoubleClick:Ce,handleSaveEdit:At,handleCancelEdit:Ht,handleShareSession:ns,handleCopyShareUrl:gs,handleCopySessionId:us,handleUnshareSession:on,handleDeleteSession:ks,handleRestoreSession:qs,confirmDeleteSession:wr}=OS({mobileVariant:e,allowReselect:r,onSessionSelected:n,isSessionSearchOpen:a,sessionSearchQuery:u,setSessionSearchQuery:h,setIsSessionSearchOpen:d,setActiveMainTab:De,setSessionSwitcherOpen:T,setCurrentSession:$t,updateSessionTitle:Wt,shareSession:is,unshareSession:Me,deleteSession:Wn,deleteSessions:nn,archiveSession:nr,archiveSessions:rn,unarchiveSession:Nn,childrenMap:Tt,showDeletionDialog:Fe,setDeleteSessionConfirm:J,deleteSessionConfirm:G,setEditingId:S,setEditTitle:p,editingId:b,editTitle:v}),xs=l.useCallback(()=>{if(!Z)return;const{scopeKey:L,folderId:Ue}=Z;re(null),Ft(L,Ue)},[Z,Ft]),fs=l.useCallback(()=>{_n.requestDirectoryDialog()},[]),An=l.useCallback(L=>{j(Ue=>{const _e=yp(Ue,L);try{N.setItem(Sd,JSON.stringify(Array.from(_e)))}catch{}return _e})},[N]),Sr=l.useCallback((L,Ue)=>{if(!L)return null;Ue&&bt.has(Ue)&&Nt(Ue);const _e=it(L,c("sessions.sidebar.folder.newFolderName"),Ue);return I(_e.id),z(_e.name),_e},[bt,Nt,it,c]),jr=mn(vr),ro=mn(Ce),Ki=mn(At),Gi=mn(Ht),Oo=mn(ns),qi=mn(gs),Yi=mn(us),Fo=mn(on),Qi=mn(ks),kr=mn(qs),oo=mn(Sr),Vn=l.useCallback((L,Ue)=>{F(_e=>{const ot=new Map(_e);return ot.set(L,Ue+7),ot})},[]),$r=l.useCallback(L=>{F(Ue=>{if(!Ue.has(L))return Ue;const _e=new Map(Ue);return _e.delete(L),_e})},[]),io=l.useCallback(L=>{F(Ue=>{let _e=!1;const ot=new Map(Ue),It=`${L}:`;for(const Kt of ot.keys())Kt.startsWith(It)&&(ot.delete(Kt),_e=!0);return _e?ot:Ue})},[]),Bo=l.useRef([]),Xi=l.useCallback(()=>{Re.current=Date.now()+150,F(new Map),ke(()=>{const L=new Set;return Bo.current.forEach(Ue=>{Ue.groups.forEach(_e=>{_e.isMain||L.add(`${Ue.project.id}:${_e.id}`)})}),L}),k(()=>{const L=new Set(de.map(Ue=>Ue.id));try{N.setItem(ei,JSON.stringify(Array.from(L)))}catch{}return $e||Cn(L),L})},[de,$e,N,Cn]),Ji=l.useCallback(()=>{Re.current=Date.now()+150,F(new Map),ke(new Set),k(()=>{const L=new Set;try{N.setItem(ei,JSON.stringify([]))}catch{}return $e||Cn(L),L})},[$e,N,Cn]),Lo=l.useCallback(L=>{Re.current=Date.now()+150,io(L),k(Ue=>{const _e=new Set(Ue);_e.has(L)?_e.delete(L):_e.add(L);try{N.setItem(ei,JSON.stringify(Array.from(_e)))}catch{}return $e||Cn(_e),_e})},[$e,io,N,Cn]),an=l.useMemo(()=>de.map(L=>({...L,normalizedPath:wt(L.path)})).filter(L=>!!L.normalizedPath),[de]),Zi=l.useMemo(()=>an.map(L=>L.normalizedPath),[an]),Cr=l.useMemo(()=>{const L=new Set(an.map(Ue=>Ue.normalizedPath));if(!$e)for(const Ue of ze.values())for(const _e of Ue){const ot=wt(_e.path);ot&&L.add(ot)}return[...L].sort()},[ze,$e,an]),O=l.useRef(null);l.useEffect(()=>{const L=new Set(Cr),Ue=O.current;if(O.current=L,!Ue){$e&&Cr.length>0&&ri(Cr,ps.current);return}const _e=Cr.filter(ot=>!Ue.has(ot));_e.length!==0&&ri(_e,ps.current)},[$e,Cr]);const{github:Le}=tr(),Xe=Lr(L=>L.status),vt=Lr(L=>L.hasChecked),Ut=vp(t?Zi:ja),as=hn(L=>L.ensureEntry),ts=hn(L=>L.setParams),bs=hn(L=>L.refreshTargets);HS({enabled:t,normalizedProjects:an,gitRepoStatus:Ut,setProjectRepoStatus:P,setProjectRootBranches:ne});const Nr=Je(L=>L.isLoading),zr=l.useMemo(()=>n0(yt,an,ze,$e,Ct),[Ct,ze,$e,an,yt]);ZS({enabled:t,hasAuthoritativeGlobalSessions:St,sessions:Yt});const{getSessionsForProject:ea,getArchivedSessionsForProject:ta}=QS({ownership:zr});wS({enabled:t,normalizedProjects:an,ownership:zr,isSessionsLoading:Nr,hasAuthoritativeGlobalSessions:St,isWorktreeTopologyLoading:Ms,unresolvedWorktreeProjectPaths:tn,foldersMap:rt,createFolder:it,addSessionToFolder:Dt});const ao=l.useRef(!1);H&&C.has(H)&&(ao.current=!!C.get(H));const On=As(L=>L.showRecentSection),ln=As(L=>L.showArchivedSessions),Dn=As(L=>L.projectSortOrder),rr=As(L=>L.stickyZoneHeaders),Fn=qt(L=>L.manualProjectOrder),Ar=l.useRef(new Set),lo=l.useRef(new Set),Dr=lc(Ar.current,w,"project"),_o=lc(lo.current,w,"recent");Ar.current=Dr,lo.current=_o;const sa={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:o,showOnlyMainWorkspace:i,t:c,isTablet:kn,liveSessions:Ze,activeSessionStructure:Lt,archivedSessionStructure:Ot,globalActiveSessions:_t,archivedSessions:Ct,projects:de,activeProjectId:H,manualProjectOrder:Fn,currentDirectory:ae,worktreeMetadata:Ke,availableWorktreesByProject:ze,pinnedSessionIds:be,sessionOrderRanks:Y,foldersMap:rt,collapsedFolderIds:bt,gitBranches:Pt,gitRepoStatus:Ut,githubAuthStatus:Xe,githubAuthChecked:vt,updateStore:jt,showRecentSection:On,showArchivedSessions:ln,projectSortOrder:Dn,projectRepoStatus:C,projectRootBranches:Oe,resolvedWorktreeTopologyKey:en,unresolvedWorktreeProjectPaths:tn,isSessionSearchOpen:a,sessionSearchQuery:u,editingId:b,editTitle:v,editingProjectDialogId:m,expandedParents:w,collapsedProjects:A,visibleSessionCountByGroup:D,updateDialogOpen:_,openSidebarMenuKey:V,renamingFolderId:y,renameFolderDraft:$,deleteSessionConfirm:G,deleteFolderConfirm:Z,bulkDeleteConfirm:ee,collapsedGroups:Te},Tl=l.useRef(null),Il=Tl.current;if(Il){let L=!1;for(const Ue of Object.keys(sa))Object.is(Il[Ue],sa[Ue])||(In(`ui.session_sidebar.source.${Ue}`),L=!0);L||In("ui.session_sidebar.source.parent_or_context")}Tl.current=sa;const Zf=l.useMemo(()=>{const L=[...an];switch(Dn){case"a-z":L.sort((Ue,_e)=>{const ot=(Ue.label||Ue.path).toLowerCase(),It=(_e.label||_e.path).toLowerCase();return ot.localeCompare(It)});break;case"z-a":L.sort((Ue,_e)=>{const ot=(Ue.label||Ue.path).toLowerCase();return(_e.label||_e.path).toLowerCase().localeCompare(ot)});break;case"date-added":L.sort((Ue,_e)=>(_e.addedAt??0)-(Ue.addedAt??0));break;case"recent":L.sort((Ue,_e)=>(_e.lastOpenedAt??0)-(Ue.lastOpenedAt??0));break;case"manual":{const Ue=new Map(Fn.map((_e,ot)=>[_e,ot]));L.sort((_e,ot)=>{const It=Ue.get(_e.id)??1/0,Kt=Ue.get(ot.id)??1/0;return It-Kt});break}}return L},[an,Dn,Fn]),{projectSections:cn,groupSearchDataByGroup:Rl,sectionsForRender:Ml,flatSectionsForRender:$o,searchMatchCount:em}=NS({normalizedProjects:Zf,getSessionsForProject:ea,getArchivedSessionsForProject:ta,availableWorktreesByProject:ze,projectRepoStatus:C,projectRootBranches:Oe,lastRepoStatus:ao.current,buildGroupedSessions:sr,hasSessionSearchQuery:ct,normalizedSessionSearchQuery:st,filterSessionNodesForSearch:Gs,buildGroupSearchText:Ks,foldersMap:rt});Bo.current=cn;const tm=l.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:c("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:c("sessions.sidebar.empty.noMatches.description")})]}),[c]),{getOrderedGroups:sm}=jS(Ie),Ol=l.useRef(!1);l.useEffect(()=>{if(Ol.current||cn.length===0)return;const L=cn.flatMap(Ue=>Ue.groups.filter(_e=>_e.isArchivedBucket).map(_e=>`${Ue.project.id}:${_e.id}`));L.length>0&&ke(Ue=>new Set([...Ue,...L])),Ol.current=!0},[cn]);const Fl=l.useMemo(()=>{const L=new Map,Ue=new Map;return cn.forEach(_e=>{const ot=pl(_e.project.label?.trim()||hr(_e.project.normalizedPath,te)||_e.project.normalizedPath);_e.groups.forEach(It=>{const Kt=It.branch&&It.branch!=="HEAD"&&It.branch!==ot?It.branch:null,Os={projectLabel:ot,branchLabel:Kt},ys=or=>{or.forEach(Pn=>{const Ur=_e.project.normalizedPath.length,ir=Ue.get(Pn.session.id)??-1;Ur<ir||(L.set(Pn.session.id,{node:Pn,projectId:_e.project.id,groupDirectory:It.directory,secondaryMeta:Os}),Ue.set(Pn.session.id,Ur),Pn.children.length>0&&ys(Pn.children))})};ys(It.sessions)})}),L},[cn,te]),na=l.useMemo(()=>!On||$e?[]:s2(yt,me).sort((L,Ue)=>to(L,Ue,be,Y)),[me,$e,be,Y,yt,On]),zo=l.useMemo(()=>{if($e||!On)return[];const L=_e=>{const ot=Fl.get(_e.id),It=wt(_e.directory??null),Kt=ot?.node??{session:_e,children:[],worktree:null},ys=(ct?Gs([Kt],st):[Kt])[0];if(!ys)return null;const or=ot?.secondaryMeta?{projectLabel:ot.secondaryMeta.projectLabel,branchLabel:$e?null:ot.secondaryMeta.branchLabel}:null;return{node:ys,projectId:ot?.projectId??null,groupDirectory:ot?.groupDirectory??It,secondaryMeta:or}},Ue=na.map(L).filter(_e=>_e!==null);return[{key:"active-now",title:c("sessions.sidebar.activity.recentTitle"),items:Ue}]},[Gs,ct,$e,st,na,Fl,On,c]),nm=l.useMemo(()=>zo.some(L=>L.items.length>0),[zo]),Bl=$e&&ln,Ll=As(L=>L.sessionGroupingMode)==="by-worktree"&&!$e,rm=l.useMemo(()=>{const L=Ll?Ml:$o;return Bl?L:L.map(Ue=>Ue.groups.some(_e=>_e.isArchivedBucket)?{...Ue,groups:Ue.groups.filter(_e=>!_e.isArchivedBucket)}:Ue)},[$o,Ml,Bl,Ll]),_l=l.useRef(new Set);l.useEffect(()=>{if(!t||!vt||!Xe?.connected||!Le)return;const L=new Map,Ue=Date.now();cn.forEach(_e=>{A.has(_e.project.id)||_e.groups.forEach(ot=>{if(ot.isArchivedBucket||ot.isMain)return;const It=wt(ot.directory??null),Kt=ot.branch?.trim()||Pt.get(It||"")?.trim();if(!It||!Kt)return;const Os=Li(It,Kt),ys=hn.getState().entries[Os],or=!!ys?.status?.pr,Pn=`${It}::${Kt}`,Ur=Math.max(ys?.lastRefreshAt??0,ys?.lastDiscoveryPollAt??0),ir=!!(ys?.isInitialStatusResolved&&!or&&(!_l.current.has(Pn)||Ue-Ur>=i2));(!ys||!ys.isInitialStatusResolved||ir)&&(ir&&_l.current.add(Pn),L.has(Os)||L.set(Os,{directory:It,branch:Kt}))})}),L.size!==0&&(L.forEach((_e,ot)=>{as(ot),ts(ot,{directory:_e.directory,branch:_e.branch,remoteName:null,canShow:!0,github:Le,githubAuthChecked:vt,githubConnected:Xe.connected})}),bs([...L.values()],{silent:!0,markInitialResolved:!0}))},[A,as,Le,vt,Xe?.connected,t,Pt,cn,bs,ts]);const om=e?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed":"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed",im="h-4.5 w-4.5",am=r0({enabled:t&&rr,isDesktopShellRuntime:Es,projectSections:cn,projectHeaderSentinelRefs:ce}),co=mn((L,Ue=0,_e,ot,It=!1,Kt,Os="project",ys)=>s.jsx(Hj,{node:L,depth:Ue,groupDirectory:_e,projectId:ot,archivedBucket:It,pinnedSessionIds:be,expandedParents:Os==="recent"?_o:Dr,hasSessionSearchQuery:ct,normalizedSessionSearchQuery:st,notifyOnSubtasks:Be,editingId:b,setEditingId:S,editTitle:v,setEditTitle:p,handleSaveEdit:Ki,handleCancelEdit:Gi,toggleParent:An,handleSessionSelect:jr,handleSessionDoubleClick:ro,togglePinnedSession:ve,handleShareSession:Oo,copiedSessionId:yr,handleCopyShareUrl:qi,handleCopySessionId:Yi,handleUnshareSession:Fo,openSidebarMenuKey:V,setOpenSidebarMenuKey:K,renamingFolderId:y,getFoldersForScope:gt,getSessionFolderId:xt,removeSessionFromFolder:qe,addSessionToFolder:Dt,createFolderAndStartRename:oo,openContextPanelTab:fe,handleDeleteSession:Qi,handleRestoreSession:kr,mobileVariant:e,alwaysShowActions:sn,renderSessionNode:co,secondaryMeta:Kt,renderContext:Os,subtreeContainsEditing:ys?.subtreeContainsEditing??a2,menuOpenSessionId:ys?.menuOpenSessionId??null,nodeStructureKey:ys?.nodeStructureKey??"",childRenderExtrasFor:ys?.childRenderExtrasFor})),lm=l.useMemo(()=>{const L=new Map;return $o.forEach(Ue=>{const _e=Ue.groups.find(ot=>!ot.isArchivedBucket);_e?.folderScopes&&_e.folderScopes.length>0&&L.set(Ue.project.id,_e.folderScopes)}),L},[$o]),cm=l.useCallback((L,Ue)=>{const _e=[];return Ue.forEach(ot=>{ot.isArchivedBucket||(_e.push(ot.directory),ot.folderScopes?.forEach(It=>_e.push(It.directory)))}),s.jsx(c2,{directories:_e})},[]),$l=l.useCallback(L=>{$r(L),ke(Ue=>{const _e=new Set(Ue);return _e.has(L)?_e.delete(L):_e.add(L),_e})},[$r]),dm=l.useCallback((L,Ue,_e,ot,It,Kt,Os)=>s.jsx(M0,{group:L,groupKey:Ue,projectId:_e,hideGroupLabel:ot,dragHandleProps:It,compactBodyPadding:Kt,hasSessionSearchQuery:ct,normalizedSessionSearchQuery:st,groupSearchDataByGroup:Rl,visibleSessionCount:D.get(Ue),collapsedGroups:Te,hideDirectoryControls:o,collapsedFolderIds:bt,toggleFolderCollapse:Nt,renameFolder:Et,deleteFolder:Ft,showDeletionDialog:Fe,setDeleteFolderConfirm:re,renderSessionNode:co,showMoreGroupSessions:Vn,resetGroupSessionLimit:$r,mobileVariant:e,alwaysShowActions:sn,activeProjectId:H,setActiveProjectIdOnly:ue,setActiveMainTab:De,setSessionSwitcherOpen:T,openNewSessionDraft:Ve,addSessionToFolder:Dt,createFolderAndStartRename:oo,renamingFolderId:y,renameFolderDraft:$,setRenameFolderDraft:z,setRenamingFolderId:I,pinnedSessionIds:be,expandedParents:Dr,sessionOrderIndex:lt,editingId:b,editTitle:v,openSidebarMenuKey:V,activeActivitySessionIds:me,unreadActivitySessionIds:pe,notifyOnSubtasks:Be,onToggleCollapsedGroup:$l,scrollContainerRef:Os}),[ct,st,Rl,D,Te,o,bt,Nt,Et,Ft,Fe,co,Vn,$r,e,sn,H,ue,De,T,Ve,Dt,oo,y,$,be,Dr,lt,b,v,V,me,pe,Be,$l]),um=l.useMemo(()=>!$e&&On&&!ct?s.jsx(G0,{sections:zo,renderSessionNode:co,editingId:b,openSidebarMenuKey:V,expansionState:_o,variant:"section",isDesktopShellRuntime:Es}):null,[zo,b,ct,Es,$e,V,_o,co,On]),zl=!!(y||b||m),{selectionModeEnabled:Ul,hasSelection:fm,selectedIdsSize:mm,bulkScopeIsArchived:hm,derivedSelectionScope:pm,bulkScopeFolders:gm,bulkCanRemoveFromFolder:xm,handleToggleSelectionMode:bm,handleExitSelectionMode:ym,handleBulkMoveToFolder:vm,handleBulkCreateFolderAndMove:wm,handleBulkRemoveFromFolder:Sm,handleBulkDelete:jm,handleBulkRestore:km,confirmBulkDelete:Cm}=Xj({isInlineEditing:zl,showDeletionDialog:Fe,foldersMap:rt,folderScopesByProject:lm,addSessionsToFolder:Bt,removeSessionsFromFolders:zt,createFolderAndStartRename:Sr,archiveSessions:rn,unarchiveSessions:br,deleteSessions:nn,setBulkDeleteConfirm:he}),Nm=l.useCallback(()=>{De("chat"),e&&T(!1),U()},[e,U,De,T]),Am=l.useCallback(()=>{xe.getState().closeMainSurfaces(),De("chat"),e&&T(!1),He()},[e,He,De,T]);return s.jsx(Oa,{delay:0,closeDelay:150,timeout:600,children:s.jsxs("div",{ref:f,className:ye("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[s.jsx(l2,{owner:Qe,childStores:Xt,projectSections:cn,activeProjectId:H,collapsedProjects:A,collapsedGroups:Te,currentDirectory:ae}),s.jsx(PS,{projectSections:cn,activeProjectId:H,initialActiveSessionByProject:Ae,persistActiveSessionByProject:Se,handleSessionSelect:jr,mobileVariant:e,openNewSessionDraft:He,setActiveMainTab:De,setSessionSwitcherOpen:T,sessionOwnerBySessionId:zr.bySessionId}),s.jsx(yS,{enabled:t,sortedSessions:q,recentSessions:na,prefetchSession:Mt.prefetchSession}),!o&&!$e?s.jsx(K0,{onNewSession:Am}):null,s.jsx(F0,{hideDirectoryControls:o,showRecentControls:!$e,handleOpenDirectoryDialog:fs,onOpenScheduled:()=>{e&&T(!1),ie(!0)},onOpenMultiRun:Nm,canOpenMultiRun:de.length>0,onOpenArchive:()=>{e&&T(!1),je(!0)},headerActionIconClass:im,headerActionButtonClass:om,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:u,setSessionSearchQuery:h,hasSessionSearchQuery:ct,searchMatchCount:em,collapseAllProjects:Xi,expandAllProjects:Ji,selectionModeEnabled:Ul,onToggleSelectionMode:bm}),t?s.jsx(ij,{topContent:um,hasSharedSessions:nm,sectionsForRender:rm,projectSections:cn,activeProjectId:H,showOnlyMainWorkspace:i,hasSessionSearchQuery:ct,emptyState:kt,searchEmptyState:tm,renderGroupSessions:dm,homeDirectory:te,collapsedProjects:A,hideDirectoryControls:o,projectRepoStatus:C,isDesktopShellRuntime:Es,stickyZoneHeaders:rr,stuckProjectHeaders:am,mobileVariant:e,alwaysShowActions:sn,toggleProject:Lo,setActiveProjectIdOnly:ue,setActiveMainTab:De,setSessionSwitcherOpen:T,openNewSessionDraft:Ve,openNewWorktreeDialog:vs,openWorktreesPage:L=>{e&&T(!1),Pe(L)},openProjectEditDialog:x,removeProject:ge,projectHeaderSentinelRefs:ce,reorderProjects:oe,projectSortOrder:Dn,getOrderedGroups:sm,setGroupOrderByProject:Ne,renderProjectStatusIndicator:cm,openSidebarMenuKey:V,setOpenSidebarMenuKey:K,isInlineEditing:zl}):null,Ul&&fm?s.jsx(Qj,{selectedCount:mm,scopeKey:pm,scopeFolders:gm,archivedBucket:hm,onMoveToFolder:vm,onCreateFolderAndMove:wm,onRemoveFromFolder:Sm,canRemoveFromFolder:xm,onRestore:km,onDelete:jm,onDone:ym}):null,s.jsx(q0,{onOpenSettings:Ts,onOpenShortcuts:le,onOpenAbout:()=>se(!0),onOpenUpdate:es,showRuntimeButtons:!$e,showUpdateButton:js}),s.jsx(Lu,{open:_,onOpenChange:W,info:jt.info,downloading:jt.downloading,downloaded:jt.downloaded,progress:jt.progress,error:jt.error,onDownload:jt.downloadUpdate,onRestart:jt.restartToUpdate,runtimeType:jt.runtimeType}),s.jsx(a0,{open:!!pt,onOpenChange:L=>{L||x(null)},project:pt,onSave:ds}),s.jsx(Eg,{open:B,onOpenChange:E,onWorktreeCreated:(L,Ue)=>{if(De("chat"),e&&T(!1),Ue?.sessionId){$t(Ue.sessionId,L);return}He({directoryOverride:L,preserveDirectoryOverride:!0})}}),s.jsx(Gj,{value:G,setValue:J,showDeletionDialog:Fe,setShowDeletionDialog:Ye,onConfirm:wr}),s.jsx(Yj,{value:Z,setValue:re,onConfirm:xs}),s.jsx(qj,{value:ee,setValue:he,showDeletionDialog:Fe,setShowDeletionDialog:Ye,onConfirm:Cm})]})})},jd=l.memo(d2);function u2(t){return t.currentSessionDirectory}const Er=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,Tn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},f2=()=>{const{t}=mt(),[e,n]=l.useState(!1),[r,o]=l.useState(!1),[i,c]=l.useState(null),[a,d]=l.useState([]),[u,h]=l.useState(!1),[f,g]=l.useState(!1),[b,S]=l.useState(!1),[v,p]=l.useState(!1),[m,x]=l.useState(new Set),w=Je(ce=>ce.getWorktreeMetadata),j=Je(ce=>ce.newSessionDraft),N=Je(ce=>ce.setNewSessionDraftTarget),A=Je(ce=>ce.setDraftBootstrapPendingDirectory),k=kp,C=Np,P=Je(ce=>ce.deleteSessions),D=Je(ce=>ce.archiveSessions),F=xe(ce=>ce.showDeletionDialog),B=xe(ce=>ce.setShowDeletionDialog),E=ls(ce=>ce.currentDirectory),_=ls(ce=>ce.homeDirectory),W=ls(ce=>ce.isHomeReady),V=qt(ce=>ce.projects),K=qt(ce=>ce.activeProjectId),{isMobile:y,isTablet:I,hasTouchInput:$}=pr(),z=y||I||$,G=l.useMemo(()=>{const Re=(K?V.find(te=>te.id===K)??null:null)?.path??E;return Tn(Re)},[K,E,V]),J=l.useCallback(ce=>{const te=Tn(ce.projectDirectory)||G;return{id:(V.find(de=>Tn(de.path)===te)??null)?.id??`path:${te}`,path:te}},[G,V]),Z=v&&m.size>0,re=l.useMemo(()=>{const ce=i?.worktree;return ce&&typeof ce.branch=="string"&&ce.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:Re})=>typeof Re.branch=="string"&&Re.branch.trim().length>0)},[i?.worktree,a]),ee=i?.mode==="worktree",he=ee,be=b||!ee||!re,Y=b||!ee;l.useEffect(()=>{r||!W||V.length>0||(o(!0),n(!0))},[r,W,V.length]);const we=l.useCallback(ce=>{c({sessions:ce.sessions,dateLabel:ce.dateLabel,mode:ce.mode??"session",worktree:ce.worktree??null})},[]),me=l.useCallback(()=>{c(null),d([]),h(!1),g(!1),S(!1),p(!1),x(new Set)},[]),Q=l.useCallback(async ce=>{if(ce.sessions.length===0)return;if(ce.sessions.length===1){const de=ce.sessions[0];await k(de.id)?Ee.success(t("sessions.sidebar.session.delete.success")):Ee.error(t("sessions.sidebar.session.delete.error"));return}const Re=ce.sessions.map(de=>de.id),{deletedIds:te,failedIds:ae}=await P(Re);if(te.length>0){const de=ae.length>0?ae.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ae.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ae.length}):ce.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:ce.dateLabel}):void 0;Ee.success(te.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:te.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:te.length}),{description:Er(de)})}ae.length>0&&Ee.error(ae.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ae.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ae.length}),{description:Er(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[k,P,t]);l.useEffect(()=>_n.onDeleteRequest(ce=>{if(!F&&(ce.mode??"session")==="session"){Q(ce);return}we(ce)}),[we,F,Q]),l.useEffect(()=>_n.onDirectoryRequest(()=>{n(!0)}),[]),l.useEffect(()=>{if(!i){d([]),h(!1),g(!1),p(!1),x(new Set);return}const ce=i.sessions.map(ae=>{const de=w(ae.id);return de?{session:ae,metadata:de}:null}).filter(ae=>!!ae);d(ce),h(!1),p(!1),x(new Set);const Re=new Map;if(i.worktree?.path&&Re.set(Tn(i.worktree.path),i.worktree),ce.forEach(({metadata:ae})=>{ae.path&&Re.set(Tn(ae.path),ae)}),Re.size===0){p(!0);return}let te=!1;return(async()=>{const ae=new Map,de=new Set;await Promise.all(Array.from(Re.entries()).map(async([H,ge])=>{try{const ue=await Cp(ge.path);ae.set(H,ue),ue?.isDirty&&de.add(H)}catch{ge.status&&(ae.set(H,ge.status),ge.status.isDirty&&de.add(H))}})).catch(H=>{console.warn("Failed to inspect worktree status before deletion:",H)}),!te&&(x(de),p(!0),c(H=>{if(!H?.worktree?.path)return H;const ge=Tn(H.worktree.path),ue=ae.get(ge);if(!ue)return H;const M=H.worktree.status;return M?.isDirty===ue.isDirty&&M?.ahead===ue.ahead&&M?.behind===ue.behind&&M?.upstream===ue.upstream?H:{...H,worktree:{...H.worktree,status:ue}}}),d(H=>H.map(ge=>{const ue=Tn(ge.metadata.path),M=ae.get(ue);return M?{session:ge.session,metadata:{...ge.metadata,status:M}}:ge})))})(),()=>{te=!0}},[i,w]),l.useEffect(()=>{re||h(!1)},[re]);const pe=l.useCallback(async(ce,Re)=>{const te=u&&re,ae=J(ce),de=Tn(ce.path),H=Tn(ae.path);try{await au(ae,ce,{deleteRemoteBranch:te,deleteLocalBranch:Re});const ge=Tn(j?.directoryOverride);return j?.open&&de&&ge===de&&H&&(A(null),N({projectId:ae.id,directoryOverride:H},{force:!0})),Tn(E)===de&&H&&ls.getState().setDirectory(H,{showOverlay:!1}),!0}catch(ge){return Ee.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Er(ge instanceof Error?ge.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[re,E,u,J,j?.directoryOverride,j?.open,A,N,t]),ve=l.useCallback((ce,Re)=>{const te=u&&re;(async()=>{if(!await pe(ce,Re))return;const de=t(te?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Ee.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle"),{description:Er(de)})})()},[re,u,pe,t]),Te=l.useCallback(async()=>{if(i){S(!0);try{const ce=he,Re=ce&&u,te=ce&&f;if(i.sessions.length===0&&ee&&i.worktree){ve(i.worktree,te),me();return}if(i.sessions.length===1){const ae=i.sessions[0];if(!(ee?await C(ae.id):await k(ae.id))){Ee.error(t(ee?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error")),S(!1);return}const H=!ee&&ce?t(Re?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;Ee.success(t(ee?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"),{description:Er(H),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const ae=i.sessions.map(ge=>ge.id);let de=[],H=[];if(ee){const ge=await D(ae);de=ge.archivedIds,H=ge.failedIds}else{const ge=await P(ae);de=ge.deletedIds,H=ge.failedIds}if(ee&&i.worktree&&H.length===0&&ve(i.worktree,te),de.length>0){const ge=!ee&&ce?t(Re?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,M=[H.length>0?ee?H.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToArchive",{count:H.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToArchive",{count:H.length}):H.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:H.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:H.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0,ge].filter(Boolean).join(" ");Ee.success(ee?de.length===1?t("sessions.sidebar.bulkActions.archivedSingle",{count:de.length}):t("sessions.sidebar.bulkActions.archivedPlural",{count:de.length}):de.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:de.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:de.length}),{description:Er(M||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(H.length>0&&(Ee.error(ee?H.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:H.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:H.length}):H.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:H.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:H.length}),{description:Er(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),de.length===0)){S(!1);return}}ee&&i.sessions.length===1&&i.worktree&&ve(i.worktree,te),me()}finally{S(!1)}}},[i,u,f,k,P,C,D,me,he,ee,ve,t]),ke=i?.worktree??a[0]?.metadata??null,Ie=i?i.mode==="worktree"?i.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):i.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:i.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:i.sessions.length}):i.sessions.length===1?i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:i.sessions.length,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:i.sessions.length}):"",Ne=i?s.jsxs("div",{className:ye(ee?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&s.jsxs("div",{className:ye(ee?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[ee&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:i.sessions.length})]}),s.jsxs("ul",{className:ye(ee?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(ce=>s.jsxs("li",{className:ye(ee?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:ye(!ee&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:ce.title||t("sessions.sidebar.session.untitled")})]},ce.id)),i.sessions.length>5&&s.jsx("li",{className:ye(ee?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:i.sessions.length-5})})]})]}),ee?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(R,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),ke?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:ke.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:ke?gi(ke.path,_):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),Z&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Ae=ee?re?s.jsxs("button",{type:"button",onClick:()=>{be||h(ce=>!ce)},disabled:be,className:ye("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",be?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[u?s.jsx(R,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(R,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,Se=ee?s.jsxs("button",{type:"button",onClick:()=>{Y||g(ce=>!ce)},disabled:Y,className:ye("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Y?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[f?s.jsx(R,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(R,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Oe=ee?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[Se,Ae]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nt,{variant:"ghost",onClick:me,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(nt,{variant:"destructive",onClick:Te,disabled:b,children:t(b?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>B(!F),className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":!F,children:[F?s.jsx(R,{name:"checkbox-blank",className:"size-4"}):s.jsx(R,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nt,{variant:"ghost",onClick:me,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(nt,{variant:"destructive",onClick:Te,disabled:b,children:b?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),ne=ee?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[z?s.jsx(_i,{open:!!i,onClose:()=>{b||me()},title:ne,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Oe}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[Ie&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:Ie}),Ne]})}):s.jsx(Ws,{open:!!i,onOpenChange:ce=>{if(!ce){if(b)return;me()}},children:s.jsxs(Vs,{className:ye(ee?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(Rn,{children:[s.jsxs(wn,{className:ye(ee&&"flex items-center gap-2"),children:[ee&&s.jsx(R,{name:"delete-bin",className:"h-5 w-5"}),ne]}),Ie&&s.jsx(Sn,{children:Ie})]}),s.jsx("div",{className:ye(ee&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:Ne}),s.jsx(gr,{className:"mt-2 gap-2 pt-1 pb-1",children:Oe})]})}),s.jsx(Tg,{open:e,onOpenChange:n})]})};function Hf(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return Xu.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function m2(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},o=Xu.CronExpressionParser.parse(t,r),i=[];for(let c=0;c<n;c+=1){const a=o.next();a&&i.push(a.toDate())}return i}catch{return[]}}const h2=[{expression:"*/5 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.every5min"},{expression:"0 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.everyHour"},{expression:"0 9 * * 1",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.monday9am"},{expression:"0 9,17 * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.9am5pm"},{expression:"0 0 1 * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth"}],p2={"Europe/Kiev":"Europe/Kyiv","Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Rangoon":"Asia/Yangon","Asia/Katmandu":"Asia/Kathmandu","America/Godthab":"America/Nuuk","Atlantic/Faeroe":"Atlantic/Faroe","Pacific/Enderbury":"Pacific/Kanton"},Fr=t=>p2[t]??t,Kf=[0,1,2,3,4,5,6],kd="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",sl=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(Fr))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],Cd=()=>{const t=new Date,e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},fi=t=>{const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),i=new Date(n,r-1,o);return Number.isNaN(i.getTime())||i.getFullYear()!==n||i.getMonth()!==r-1||i.getDate()!==o?null:i},Nd=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},g2=(t,e,n)=>{const r=fi(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},Ad=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),x2=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),c=(new Date(n,r,1).getDay()-e+7)%7,a=new Date(n,r+1,0).getDate(),d=new Date(n,r,0).getDate(),u=[];for(let h=0;h<42;h+=1){const f=h-c+1;if(f<=0){const g=d+f;u.push({date:new Date(n,r-1,g),inCurrentMonth:!1});continue}if(f>a){u.push({date:new Date(n,r+1,f-a),inCurrentMonth:!1});continue}u.push({date:new Date(n,r,f),inCurrentMonth:!0})}return u},b2=t=>{const e=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(t);if(!e)return{hour24:"00",hour12:"12",minute:"00",meridiem:"AM"};const n=Number(e[1]),r=e[2],o=n>=12?"PM":"AM",i=n%12===0?12:n%12;return{hour24:String(n).padStart(2,"0"),hour12:String(i).padStart(2,"0"),minute:r,meridiem:o}},Tr=(t,e,n)=>{const r=Number(t),o=Number(e),i=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,c=Number.isFinite(o)?Math.min(59,Math.max(0,o)):0;let a=i%12;return n==="PM"&&(a+=12),`${String(a).padStart(2,"0")}:${String(c).padStart(2,"0")}`},no=(t,e)=>{const{max:n,min:r=0,loop:o=!1}=e;let i=Number.parseInt(t,10);return Number.isFinite(i)?(o?(i>n&&(i=r),i<r&&(i=n)):(i>n&&(i=n),i<r&&(i=r)),String(i).padStart(2,"0")):"00"},Dd=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:no(t,{min:1,max:12}),ti=t=>/^[0-5][0-9]$/.test(t)?t:no(t,{max:59}),y2=(t,e)=>no(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),Pd=(t,e)=>no(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),v2=t=>{try{const e=Intl.Locale;if(typeof e!="function")return 1;const r=new e(t).weekInfo?.firstDay;return typeof r!="number"?1:r%7}catch{return 1}},w2=t=>{try{const e=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions();return typeof e.hour12=="boolean"?!e.hour12:e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!0}},S2=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return Kf.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},j2=(t,e)=>[...t.slice(e),...t.slice(0,e)],Bs=t=>{const e=tt.c(6),{htmlFor:n,required:r,children:o}=t;let i;e[0]!==r?(i=r&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"}),e[0]=r,e[1]=i):i=e[1];let c;return e[2]!==o||e[3]!==n||e[4]!==i?(c=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[o,i]})}),e[2]=o,e[3]=n,e[4]=i,e[5]=c):c=e[5],c},Ed=t=>{const e=tt.c(84),{value:n,onChange:r,use24Hour:o,hourAriaLabel:i,minuteAriaLabel:c,periodAriaLabel:a,amLabel:d,pmLabel:u}=t;let h;e[0]!==n?(h=b2(n),e[0]=n,e[1]=h):h=e[1];const f=h,g=Ge.useRef(null),b=Ge.useRef(null),[S,v]=Ge.useState(null),[p,m]=Ge.useState(null),x=Ge.useRef(null),w=Ge.useRef(null);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=ne=>{x.current=ne,v(ne)},e[2]=j):j=e[2];const N=j;let A;e[3]===Symbol.for("react.memo_cache_sentinel")?(A=ne=>{w.current=ne,m(ne)},e[3]=A):A=e[3];const k=A,C=E2,P=T2,D=I2;let F;e[4]!==r||e[5]!==f.meridiem||e[6]!==f.minute||e[7]!==o?(F=ne=>{const ce=ne.replace(/\D/g,"").slice(0,2);N(ce),ce.length===2&&(r(o?D(C(ce),f.minute):Tr(Dd(ce),f.minute,f.meridiem)),N(null),b.current?.focus())},e[4]=r,e[5]=f.meridiem,e[6]=f.minute,e[7]=o,e[8]=F):F=e[8];const B=F;let E;e[9]!==r||e[10]!==f.meridiem||e[11]!==f.minute||e[12]!==o?(E=()=>{const ne=x.current;if(ne!==null&&(N(null),ne.length!==0)){if(o){r(D(C(ne.padStart(2,"0")),f.minute));return}r(Tr(Dd(ne.padStart(2,"0")),f.minute,f.meridiem))}},e[9]=r,e[10]=f.meridiem,e[11]=f.minute,e[12]=o,e[13]=E):E=e[13];const _=E;let W;e[14]!==r||e[15]!==f.hour12||e[16]!==f.hour24||e[17]!==f.meridiem||e[18]!==o?(W=ne=>{const ce=ne.replace(/\D/g,"").slice(0,2);k(ce),ce.length===2&&(r(o?D(f.hour24,ti(ce)):Tr(f.hour12,ti(ce),f.meridiem)),k(null))},e[14]=r,e[15]=f.hour12,e[16]=f.hour24,e[17]=f.meridiem,e[18]=o,e[19]=W):W=e[19];const V=W;let K;e[20]!==r||e[21]!==f.hour12||e[22]!==f.hour24||e[23]!==f.meridiem||e[24]!==o?(K=()=>{const ne=w.current;ne!==null&&(k(null),ne.length!==0&&r(o?D(f.hour24,ti(ne.padStart(2,"0"))):Tr(f.hour12,ti(ne.padStart(2,"0")),f.meridiem)))},e[20]=r,e[21]=f.hour12,e[22]=f.hour24,e[23]=f.meridiem,e[24]=o,e[25]=K):K=e[25];const y=K;let I;e[26]!==r||e[27]!==f.hour12||e[28]!==f.hour24||e[29]!==f.meridiem||e[30]!==f.minute||e[31]!==o?(I=ne=>r(o?D(P(f.hour24,ne),f.minute):Tr(y2(f.hour12,ne),f.minute,f.meridiem)),e[26]=r,e[27]=f.hour12,e[28]=f.hour24,e[29]=f.meridiem,e[30]=f.minute,e[31]=o,e[32]=I):I=e[32];const $=I;let z;e[33]!==r||e[34]!==f.hour12||e[35]!==f.hour24||e[36]!==f.meridiem||e[37]!==f.minute||e[38]!==o?(z=ne=>r(o?D(f.hour24,Pd(f.minute,ne)):Tr(f.hour12,Pd(f.minute,ne),f.meridiem)),e[33]=r,e[34]=f.hour12,e[35]=f.hour24,e[36]=f.meridiem,e[37]=f.minute,e[38]=o,e[39]=z):z=e[39];const G=z;let J;e[40]!==r||e[41]!==f.hour12||e[42]!==f.meridiem||e[43]!==f.minute?(J=ne=>{ne!==f.meridiem&&r(Tr(f.hour12,f.minute,ne))},e[40]=r,e[41]=f.hour12,e[42]=f.meridiem,e[43]=f.minute,e[44]=J):J=e[44];const Z=J;let re;e[45]!==_||e[46]!==$?(re=ne=>{if(ne.key==="ArrowRight"){ne.preventDefault(),_(),b.current?.focus();return}(ne.key==="ArrowUp"||ne.key==="ArrowDown")&&(ne.preventDefault(),N(null),$(ne.key==="ArrowUp"?1:-1))},e[45]=_,e[46]=$,e[47]=re):re=e[47];const ee=re;let he;e[48]!==y||e[49]!==G?(he=ne=>{if(ne.key==="ArrowLeft"&&(ne.currentTarget.selectionStart??0)===0){ne.preventDefault(),y(),g.current?.focus();return}(ne.key==="ArrowUp"||ne.key==="ArrowDown")&&(ne.preventDefault(),k(null),G(ne.key==="ArrowUp"?1:-1))},e[48]=y,e[49]=G,e[50]=he):he=e[50];const be=he,Y=o?"px-2":"pl-2 pr-1";let we;e[51]!==Y?(we=ye("inline-flex h-9 w-fit items-center gap-1 rounded-md border border-border bg-background focus-within:ring-1 focus-within:ring-interactive-focusRing focus-within:border-interactive-focusRing",Y),e[51]=Y,e[52]=we):we=e[52];const me=S??(o?f.hour24:f.hour12);let Q;e[53]!==B?(Q=ne=>B(ne.target.value),e[53]=B,e[54]=Q):Q=e[54];let pe;e[55]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>N(""),e[55]=pe):pe=e[55];let ve;e[56]!==_||e[57]!==i||e[58]!==ee||e[59]!==me||e[60]!==Q?(ve=s.jsx("input",{ref:g,inputMode:"numeric",value:me,onChange:Q,onKeyDown:ee,onFocus:pe,onBlur:_,maxLength:2,"aria-label":i,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[56]=_,e[57]=i,e[58]=ee,e[59]=me,e[60]=Q,e[61]=ve):ve=e[61];let Te;e[62]===Symbol.for("react.memo_cache_sentinel")?(Te=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=Te):Te=e[62];const ke=p??f.minute;let Ie;e[63]!==V?(Ie=ne=>V(ne.target.value),e[63]=V,e[64]=Ie):Ie=e[64];let Ne;e[65]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>k(""),e[65]=Ne):Ne=e[65];let Ae;e[66]!==y||e[67]!==c||e[68]!==be||e[69]!==ke||e[70]!==Ie?(Ae=s.jsx("input",{ref:b,inputMode:"numeric",value:ke,onChange:Ie,onKeyDown:be,onFocus:Ne,onBlur:y,maxLength:2,"aria-label":c,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[66]=y,e[67]=c,e[68]=be,e[69]=ke,e[70]=Ie,e[71]=Ae):Ae=e[71];let Se;e[72]!==d||e[73]!==f.meridiem||e[74]!==a||e[75]!==u||e[76]!==Z||e[77]!==o?(Se=o?null:s.jsxs(Ls,{value:f.meridiem,onValueChange:ne=>Z(ne),children:[s.jsx(_s,{"aria-label":a,className:"ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0",children:s.jsx(Ds,{})}),s.jsxs($s,{children:[s.jsx(rs,{value:"AM",children:d}),s.jsx(rs,{value:"PM",children:u})]})]}),e[72]=d,e[73]=f.meridiem,e[74]=a,e[75]=u,e[76]=Z,e[77]=o,e[78]=Se):Se=e[78];let Oe;return e[79]!==we||e[80]!==ve||e[81]!==Ae||e[82]!==Se?(Oe=s.jsxs("div",{className:we,children:[ve,Te,Ae,Se]}),e[79]=we,e[80]=ve,e[81]=Ae,e[82]=Se,e[83]=Oe):Oe=e[83],Oe},Td=t=>new Date(t.getFullYear(),t.getMonth(),1),k2=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},Id=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),C2=t=>{if(!t)return["09:00"];const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(o=>typeof o=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(o)).map(o=>o.trim()),r=Array.from(new Set(n)).sort((o,i)=>o.localeCompare(i));return r.length>0?r:["09:00"]},Rd=(t,e)=>{const n=Fr(Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC");return t?{id:t.id,name:t.name,enabled:t.enabled,schedule:{kind:t.schedule.kind==="cron"?"cron":t.schedule.kind==="once"?"once":t.schedule.kind==="weekly"?"weekly":"daily",times:C2(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:Cd(),onceTime:typeof t.schedule.time=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.time)?t.schedule.time:"09:00",weekdays:Array.isArray(t.schedule.weekdays)?t.schedule.weekdays:[1],timezone:Fr(t.schedule.timezone||n),cronExpression:t.schedule.kind==="cron"&&typeof t.schedule.cron=="string"?t.schedule.cron:""},execution:{prompt:t.execution.prompt,providerID:t.execution.providerID,modelID:t.execution.modelID,variant:t.execution.variant||"",agent:t.execution.agent||"",goalEnabled:t.execution.goalEnabled===!0,goalTokenBudget:typeof t.execution.goalTokenBudget=="number"&&t.execution.goalTokenBudget>0?t.execution.goalTokenBudget:null,permissionAutoAccept:t.execution.permissionAutoAccept===!0},state:t.state}:{name:"",enabled:!0,schedule:{kind:"daily",times:["09:00"],onceDate:Cd(),onceTime:"09:00",weekdays:[1],timezone:n,cronExpression:""},execution:{prompt:"",providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:e.agent,goalEnabled:!1,goalTokenBudget:null,permissionAutoAccept:!1}}},N2=(t,e)=>{if(!t.name.trim())return e("sessions.scheduledTasks.editor.validation.taskNameRequired");if(!t.execution.prompt.trim())return e("sessions.scheduledTasks.editor.validation.promptRequired");if(!t.execution.providerID.trim()||!t.execution.modelID.trim())return e("sessions.scheduledTasks.editor.validation.modelRequired");if(t.schedule.kind==="once"){if(!/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.onceDate))return e("sessions.scheduledTasks.editor.validation.dateFormat");if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.onceTime))return e("sessions.scheduledTasks.editor.validation.timeFormat")}else if(t.schedule.kind==="cron"){if(!t.schedule.cronExpression.trim())return e("sessions.scheduledTasks.editor.validation.cronRequired");if(!Hf(t.schedule.cronExpression).valid)return e("sessions.scheduledTasks.editor.validation.cronInvalid")}else if(t.schedule.times.filter(r=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)).length===0)return e("sessions.scheduledTasks.editor.validation.atLeastOneTime");return t.schedule.kind==="weekly"&&t.schedule.weekdays.length===0?e("sessions.scheduledTasks.editor.validation.atLeastOneWeekday"):t.schedule.timezone.trim()?null:e("sessions.scheduledTasks.editor.validation.timezoneRequired")},A2=t=>{const e=t.filter(n=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(n));return Array.from(new Set(e)).sort((n,r)=>n.localeCompare(r))},D2=t=>{const e=tt.c(64),{draft:n,setDraft:r,locale:o,t:i}=t,c=n.schedule.cronExpression;let a;e[0]!==c?(a=c.trim()?Hf(c):null,e[0]=c,e[1]=a):a=e[1];const d=a;let u;e:{if(!d?.valid||!c.trim()){let I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I=[],e[2]=I):I=e[2],u=I;break e}let y;e[3]!==c||e[4]!==n.schedule.timezone?(y=m2(c,n.schedule.timezone),e[3]=c,e[4]=n.schedule.timezone,e[5]=y):y=e[5],u=y}const h=u;let f;e[6]!==n.schedule.timezone||e[7]!==o?(f=y=>new Intl.DateTimeFormat(o,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(y),e[6]=n.schedule.timezone,e[7]=o,e[8]=f):f=e[8];const g=f;let b;e[9]!==i?(b=i("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=i,e[10]=b):b=e[10];let S;e[11]!==b?(S=s.jsx(Bs,{htmlFor:"sched-cron",required:!0,children:b}),e[11]=b,e[12]=S):S=e[12];let v;e[13]!==r?(v=y=>r(I=>({...I,schedule:{...I.schedule,cronExpression:y.target.value}})),e[13]=r,e[14]=v):v=e[14];let p;e[15]!==i?(p=i("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=i,e[16]=p):p=e[16];let m;e[17]!==c||e[18]!==v||e[19]!==p?(m=s.jsx(Jn,{id:"sched-cron",value:c,onChange:v,placeholder:p,className:"w-full max-w-xs font-mono"}),e[17]=c,e[18]=v,e[19]=p,e[20]=m):m=e[20];let x;e[21]!==c||e[22]!==d||e[23]!==i?(x=d&&!d.valid&&c.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:i("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=c,e[22]=d,e[23]=i,e[24]=x):x=e[24];let w;e[25]!==S||e[26]!==m||e[27]!==x?(w=s.jsxs("div",{className:"flex flex-col gap-1",children:[S,m,x]}),e[25]=S,e[26]=m,e[27]=x,e[28]=w):w=e[28];let j;e[29]!==g||e[30]!==h||e[31]!==i?(j=h.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:i("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:h.map(g).join(", ")})]}):null,e[29]=g,e[30]=h,e[31]=i,e[32]=j):j=e[32];let N;e[33]!==i?(N=i("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=i,e[34]=N):N=e[34];let A;e[35]!==N?(A=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[35]=N,e[36]=A):A=e[36];let k;e[37]!==r||e[38]!==i?(k=h2.map(y=>s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 typography-micro text-foreground hover:bg-interactive-hover",onClick:()=>r(I=>({...I,schedule:{...I.schedule,cronExpression:y.expression}})),children:[s.jsx("span",{className:"font-mono",children:y.expression}),s.jsx("span",{className:"text-muted-foreground",children:i(y.labelKey)})]},y.expression)),e[37]=r,e[38]=i,e[39]=k):k=e[39];let C;e[40]!==k?(C=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:k}),e[40]=k,e[41]=C):C=e[41];let P;e[42]!==A||e[43]!==C?(P=s.jsxs("div",{className:"flex flex-col gap-1",children:[A,C]}),e[42]=A,e[43]=C,e[44]=P):P=e[44];let D;e[45]!==i?(D=i("sessions.scheduledTasks.editor.timezone.label"),e[45]=i,e[46]=D):D=e[46];let F;e[47]!==D?(F=s.jsx(Bs,{children:D}),e[47]=D,e[48]=F):F=e[48];let B;e[49]!==r?(B=y=>{r(I=>({...I,schedule:{...I.schedule,timezone:y}}))},e[49]=r,e[50]=B):B=e[50];let E;e[51]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ds,{})}),e[51]=E):E=e[51];let _;e[52]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx($s,{children:sl.map(R2)}),e[52]=_):_=e[52];let W;e[53]!==n.schedule.timezone||e[54]!==B?(W=s.jsxs(Ls,{value:n.schedule.timezone,onValueChange:B,children:[E,_]}),e[53]=n.schedule.timezone,e[54]=B,e[55]=W):W=e[55];let V;e[56]!==F||e[57]!==W?(V=s.jsxs("div",{className:"flex flex-col gap-1",children:[F,W]}),e[56]=F,e[57]=W,e[58]=V):V=e[58];let K;return e[59]!==w||e[60]!==j||e[61]!==P||e[62]!==V?(K=s.jsxs("div",{className:"flex flex-col gap-3",children:[w,j,P,V]}),e[59]=w,e[60]=j,e[61]=P,e[62]=V,e[63]=K):K=e[63],K};function P2(t){const{open:e,task:n,onOpenChange:r,onSave:o}=t,{t:i,locale:c}=mt(),a=Vt(T=>T.loadProviders),d=Vt(T=>T.loadAgents),u=Vt(T=>T.providers),h=Vt(T=>T.currentProviderId),f=Vt(T=>T.currentModelId),g=Vt(T=>T.currentVariant||""),b=Vt(T=>T.currentAgentName||""),S=xe(T=>T.timeFormatPreference),v=xe(T=>T.weekStartPreference),p=xe(T=>T.isMobile),[m,x]=Ge.useState(()=>Rd(n,{providerID:h,modelID:f,variant:g,agent:b})),[w,j]=Ge.useState(!1),[N,A]=Ge.useState(!1),[k,C]=Ge.useState(!1),[P,D]=Ge.useState(""),[F,B]=Ge.useState(!1),[E,_]=Ge.useState(""),[W,V]=Ge.useState(!1),[K,y]=Ge.useState(""),[I,$]=Ge.useState(()=>{const T=fi(n?.schedule?.date||"")||new Date;return new Date(T.getFullYear(),T.getMonth(),1)}),z=Ge.useRef(null),G=Ge.useRef(null),J=Ge.useRef(null),Z=Ge.useRef(null),re=Ge.useRef(null),ee=Ge.useMemo(()=>w2(c),[c]),he=Ge.useMemo(()=>v2(c),[c]),be=Ge.useMemo(()=>S==="24h"?!0:S==="12h"?!1:ee,[S,ee]),Y=Ge.useMemo(()=>v==="sunday"?0:v==="monday"?1:he,[v,he]),we=Ge.useMemo(()=>{const T=S2(c);return j2(Kf.map(ie=>({value:ie,label:T[ie]||""})),Y)},[c,Y]);Ge.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),d({source:"scheduledTaskEditor"}))},[e,a,d]),Ge.useEffect(()=>{if(!e)return;x(Rd(n,{providerID:h,modelID:f,variant:g,agent:b}));const T=fi(n?.schedule?.date||"")||new Date;$(new Date(T.getFullYear(),T.getMonth(),1)),A(!1),B(!1),C(!1),_(""),D("")},[e,n,h,f,g,b]),Ge.useEffect(()=>{if(!N)return;const T=ie=>{z.current&&!z.current.contains(ie.target)&&A(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},[N]);const me=Ge.useMemo(()=>{const ie=u.find(je=>je.id===m.execution.providerID)?.models?.find(je=>je.id===m.execution.modelID);return ie?.variants?Object.keys(ie.variants):[]},[u,m.execution.providerID,m.execution.modelID]),Q=me.length>0,pe=Ge.useMemo(()=>!Q||!m.execution.variant?"__default":me.includes(m.execution.variant)?m.execution.variant:"__default",[m.execution.variant,Q,me]);Ge.useEffect(()=>{Q||!m.execution.variant||x(T=>({...T,execution:{...T.execution,variant:""}}))},[Q,m.execution.variant]);const ve=Ge.useCallback((T,ie)=>{x(je=>{const Pe=new Set(je.schedule.weekdays);return ie?Pe.add(T):Pe.delete(T),{...je,schedule:{...je.schedule,weekdays:Array.from(Pe).sort((U,Be)=>U-Be)}}})},[]),Te=Ge.useCallback((T,ie)=>{x(je=>{const Pe=je.schedule.times.slice();return Pe[T]=ie,{...je,schedule:{...je.schedule,times:Pe}}})},[]),ke=Ge.useCallback(T=>{x(ie=>{const je=ie.schedule.times.filter((Pe,U)=>U!==T);return{...ie,schedule:{...ie.schedule,times:je.length>0?je:["09:00"]}}})},[]),Ie=Ge.useCallback(()=>{x(T=>({...T,schedule:{...T.schedule,times:[...T.schedule.times,"12:00"]}}))},[]),Ne=Ge.useMemo(()=>k2(),[]),Ae=Ge.useMemo(()=>Td(Ne),[Ne]),Se=Ge.useMemo(()=>{const T=fi(m.schedule.onceDate);return T?Id(T,Ne)?i("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(c,{weekday:"short"}).format(T):null},[m.schedule.onceDate,c,i,Ne]),Oe=Ge.useMemo(()=>Td(I).getTime()<=Ae.getTime(),[I,Ae]),ne=Ge.useMemo(()=>we.map(T=>T.label),[we]),ce=Ge.useCallback(T=>{x(ie=>({...ie,schedule:{...ie.schedule,onceDate:T}}))},[]),Re=Ge.useCallback((T,ie)=>{if(T.startsWith("/")){const Be=T.indexOf(" "),Fe=T.indexOf(`
|
|
909
|
-
`),Ye=Math.min(Be===-1?T.length:Be,Fe===-1?T.length:Fe);if(ie<=Ye&&Be===-1){_(T.substring(1,Ye)),B(!0),C(!1),V(!1);return}}B(!1);const je=T.substring(0,ie),Pe=je.lastIndexOf("#");if(Pe!==-1){const Be=Pe>0?je[Pe-1]:null,Fe=je.substring(Pe+1);if((!Be||/\s/.test(Be))&&!Fe.includes(" ")&&!Fe.includes(`
|
|
910
|
-
`)){y(Fe),V(!0),C(!1);return}}V(!1);const U=je.lastIndexOf("@");if(U!==-1){const Be=U>0?je[U-1]:null,Fe=je.substring(U+1);(!Be||/\s/.test(Be))&&!Fe.includes(" ")&&!Fe.includes(`
|
|
911
|
-
`)?(D(Fe),C(!0)):C(!1);return}C(!1)},[]),te=Ge.useCallback(T=>{x(ie=>({...ie,execution:{...ie.execution,prompt:T}}))},[]),ae=Ge.useCallback(T=>{const ie=m.execution.prompt,Pe=G.current?.selectionStart??ie.length,Be=ie.substring(0,Pe).lastIndexOf("@"),Fe=T.relativePath&&T.relativePath.trim().length>0?T.relativePath.trim():T.path||T.name,Ye=Be!==-1?Be:Pe,at=`${ie.substring(0,Ye)}@${Fe} ${ie.substring(Pe)}`,st=Ye+Fe.length+2;te(at),C(!1),D(""),requestAnimationFrame(()=>{const ct=G.current;ct&&(ct.selectionStart=st,ct.selectionEnd=st,ct.focus()),Re(at,st)})},[m.execution.prompt,te,Re]),de=Ge.useCallback(T=>{const ie=m.execution.prompt,Pe=G.current?.selectionStart??ie.length,Be=ie.substring(0,Pe).lastIndexOf("@"),Fe=Be!==-1?Be:Pe,Ye=`${ie.substring(0,Fe)}@${T} ${ie.substring(Pe)}`,at=Fe+T.length+2;te(Ye),C(!1),D(""),requestAnimationFrame(()=>{const st=G.current;st&&(st.selectionStart=at,st.selectionEnd=at,st.focus()),Re(Ye,at)})},[m.execution.prompt,te,Re]),H=Ge.useCallback(T=>{const ie=`/${T.name} `;te(ie),B(!1),_(""),V(!1),requestAnimationFrame(()=>{const je=G.current;je&&(je.focus(),je.selectionStart=je.value.length,je.selectionEnd=je.value.length),Re(ie,ie.length)})},[te,Re]),ge=Ge.useCallback((T,ie)=>{const je=m.execution.prompt,U=G.current?.selectionStart??je.length,Fe=je.substring(0,U).lastIndexOf("#"),Ye=Fe!==-1?Fe:U,at=`${je.substring(0,Ye)}#${ie} ${je.substring(U)}`,st=Ye+ie.length+2;te(at),V(!1),y(""),requestAnimationFrame(()=>{const ct=G.current;ct&&(ct.selectionStart=st,ct.selectionEnd=st,ct.focus()),Re(at,st)})},[m.execution.prompt,te,Re]),ue=Ge.useCallback(T=>{if(F&&Z.current&&(T.key==="Enter"||T.key==="ArrowUp"||T.key==="ArrowDown"||T.key==="Escape"||T.key==="Tab")){T.preventDefault(),Z.current.handleKeyDown(T.key);return}k&&J.current&&(T.key==="Enter"||T.key==="ArrowUp"||T.key==="ArrowDown"||T.key==="Escape"||T.key==="Tab")&&(T.preventDefault(),J.current.handleKeyDown(T.key)),W&&re.current&&(T.key==="Enter"||T.key==="ArrowUp"||T.key==="ArrowDown"||T.key==="Escape"||T.key==="Tab")&&(T.preventDefault(),re.current.handleKeyDown(T.key))},[F,k,W]),M=Ge.useCallback(async()=>{const T=N2(m,i);if(T){Ee.error(T);return}const ie={...m.id?{id:m.id}:{},name:m.name.trim(),enabled:m.enabled,schedule:{kind:m.schedule.kind,timezone:m.schedule.timezone.trim(),...m.schedule.kind==="cron"?{cron:m.schedule.cronExpression.trim()}:m.schedule.kind==="once"?{date:m.schedule.onceDate,time:m.schedule.onceTime}:{times:A2(m.schedule.times),...m.schedule.kind==="weekly"?{weekdays:m.schedule.weekdays}:{}}},execution:{prompt:m.execution.prompt,providerID:m.execution.providerID,modelID:m.execution.modelID,...m.execution.variant.trim()?{variant:m.execution.variant.trim()}:{},...m.execution.agent.trim()?{agent:m.execution.agent.trim()}:{},...m.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...m.execution.goalEnabled?{goalEnabled:!0}:{},...m.execution.goalEnabled&&m.execution.goalTokenBudget?{goalTokenBudget:m.execution.goalTokenBudget}:{}},...m.state?{state:m.state}:{}};j(!0);try{await o(ie),r(!1)}catch(je){Ee.error(je instanceof Error?je.message:i("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{j(!1)}},[m,r,o,i]),oe=Ge.useId(),De=Ge.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),fe=i(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),X=i("sessions.scheduledTasks.editor.description"),le=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Bs,{htmlFor:"sched-name",required:!0,children:i("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(Jn,{id:"sched-name",value:m.name,onChange:T=>x(ie=>({...ie,name:T.target.value})),placeholder:i("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Ls,{value:m.schedule.kind,onValueChange:T=>{x(ie=>({...ie,schedule:{...ie.schedule,kind:T,...T==="cron"&&!ie.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ds,{children:T=>i(T==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":T==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":T==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs($s,{children:[s.jsx(rs,{value:"daily",children:i("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(rs,{value:"weekly",children:i("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(rs,{value:"once",children:i("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(rs,{value:"cron",children:i("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx(D2,{draft:m,setDraft:x,locale:c,t:i}):m.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:z,children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:ye(Pu({size:"default"}),"w-fit max-w-full"),onClick:()=>A(T=>!T),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(R,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:g2(m.schedule.onceDate,i("sessions.scheduledTasks.editor.date.placeholder"),c)})]}),s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),N?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-background p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>$(T=>Ad(T,-1)),"aria-label":i("sessions.scheduledTasks.editor.date.previousMonth"),disabled:Oe,children:s.jsx(R,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(c,{month:"long",year:"numeric"}).format(I)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>$(T=>Ad(T,1)),"aria-label":i("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(R,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:ne.map((T,ie)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:T},`${T}-${ie}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:x2(I,Y).map(({date:T,inCurrentMonth:ie})=>{const je=Nd(T),Pe=je===m.schedule.onceDate,U=Id(T,Ne),Be=T.getTime()<Ne.getTime(),Fe=Pe?"bg-interactive-selection text-interactive-selection-foreground":Be?"text-muted-foreground/40":ie?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{Be||(ce(je),A(!1))},disabled:Be,className:["h-8 rounded-md typography-ui-label",Fe,U&&!Pe?"ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50":"",Be?"cursor-not-allowed opacity-45":""].join(" "),children:T.getDate()},je)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:Se||""}),s.jsx(nt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{ce(Nd(Ne)),$(new Date(Ne.getFullYear(),Ne.getMonth(),1))},children:i("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.time.label")}),s.jsx(Ed,{value:m.schedule.onceTime,use24Hour:be,hourAriaLabel:i("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:i("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:i("sessions.scheduledTasks.editor.time.periodAria"),amLabel:i("sessions.scheduledTasks.editor.time.period.am"),pmLabel:i("sessions.scheduledTasks.editor.time.period.pm"),onChange:T=>x(ie=>({...ie,schedule:{...ie.schedule,onceTime:T}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ls,{value:m.schedule.timezone,onValueChange:T=>{x(ie=>({...ie,schedule:{...ie.schedule,timezone:T}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ds,{})}),s.jsx($s,{children:sl.map(T=>s.jsx(rs,{value:T,children:T},T))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[m.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:we.map(T=>{const ie=m.schedule.weekdays.includes(T.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",ie?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(qr,{checked:ie,onChange:je=>ve(T.value,je),ariaLabel:T.label}),s.jsx("button",{type:"button",onClick:()=>ve(T.value,!ie),className:"group-hover:text-foreground",children:T.label})]},T.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((T,ie)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ed,{value:T,use24Hour:be,hourAriaLabel:i("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:i("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:i("sessions.scheduledTasks.editor.time.periodAria"),amLabel:i("sessions.scheduledTasks.editor.time.period.am"),pmLabel:i("sessions.scheduledTasks.editor.time.period.pm"),onChange:je=>Te(ie,je)}),m.schedule.times.length>1?s.jsx(nt,{type:"button",size:"icon",variant:"ghost",onClick:()=>ke(ie),"aria-label":i("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(R,{name:"close",className:"h-4 w-4"})}):null]},ie))}),s.jsx("div",{children:s.jsxs(nt,{type:"button",size:"sm",variant:"outline",onClick:Ie,children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"})," ",i("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ls,{value:m.schedule.timezone,onValueChange:T=>{x(ie=>({...ie,schedule:{...ie.schedule,timezone:T}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ds,{})}),s.jsx($s,{children:sl.map(T=>s.jsx(rs,{value:T,children:T},T))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Bs,{required:!0,children:i("sessions.scheduledTasks.editor.model.label")}),s.jsx(Ap,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(T,ie)=>{x(je=>({...je,execution:{...je.execution,providerID:T,modelID:ie,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Ls,{value:pe,disabled:!Q,onValueChange:T=>{x(ie=>({...ie,execution:{...ie.execution,variant:T==="__default"?"":T}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ds,{children:T=>T==="__default"?i("sessions.scheduledTasks.editor.thinkingLevel.default"):T})}),s.jsxs($s,{children:[s.jsx(rs,{value:"__default",children:i("sessions.scheduledTasks.editor.thinkingLevel.default")}),me.map(T=>s.jsx(rs,{value:T,children:T},T))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Dp,{agentName:m.execution.agent,filter:T=>Du(T.mode),onChange:T=>x(ie=>({...ie,execution:{...ie.execution,agent:T}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Bs,{htmlFor:"sched-prompt",required:!0,children:i("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(Kr,{id:"sched-prompt",ref:G,value:m.execution.prompt,onChange:T=>{const ie=T.target.value;te(ie);const je=T.target.selectionStart??ie.length;Re(ie,je)},onKeyDown:ue,rows:8,placeholder:i("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),F?s.jsx(Ru,{ref:Z,searchQuery:E,onCommandSelect:H,onClose:()=>B(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,k?s.jsx(Mu,{ref:J,searchQuery:P,onFileSelect:ae,onAgentSelect:de,onClose:()=>C(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,W?s.jsx(Ou,{ref:re,searchQuery:K,onSnippetSelect:ge,onClose:()=>V(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),m.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(qr,{checked:m.execution.goalTokenBudget!==null,onChange:T=>x(ie=>({...ie,execution:{...ie.execution,goalTokenBudget:T?2e5:null}})),ariaLabel:i("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:i("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),m.execution.goalTokenBudget!==null?s.jsx(Pp,{value:m.execution.goalTokenBudget,onValueChange:T=>{typeof T=="number"&&Number.isFinite(T)&&T>0&&x(ie=>({...ie,execution:{...ie.execution,goalTokenBudget:Math.floor(T)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),se=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(qr,{checked:m.enabled,onChange:T=>x(ie=>({...ie,enabled:T})),ariaLabel:i("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:i("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",className:ye(kd),onClick:()=>x(T=>({...T,execution:{...T.execution,permissionAutoAccept:!T.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":i("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(R,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(R,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(ft,{side:"top",sideOffset:6,children:i("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",className:ye(kd,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>x(T=>({...T,execution:{...T.execution,goalEnabled:!T.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":i("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(R,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(R,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(ft,{side:"top",sideOffset:6,children:i("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:w,children:i("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(nt,{type:"button",size:"sm",onClick:M,disabled:w,children:i(w?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return p?s.jsx(_i,{open:e,title:fe,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:T=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:fe}),T]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:X})]}),footer:se,children:le}):s.jsx(Ws,{open:e,onOpenChange:T=>{!T&&De()||r(T)},children:s.jsxs(Vs,{"aria-describedby":oe,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Sn,{id:oe,className:"sr-only",children:X}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(wn,{className:"typography-ui-label font-medium text-foreground",children:fe}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:X})]})}),s.jsx(ll,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:le})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:se})})]})})}function E2(t){return no(t,{min:0,max:23})}function T2(t,e){return no(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function I2(t,e){const n=Number(t),r=Number(e),o=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,i=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function R2(t){return s.jsx(rs,{value:t,children:t},t)}const M2=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,o)=>r.localeCompare(o))},O2=(t,e)=>{const n=M2(t).join(", ")||"--:--",r=o=>e(o===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":o===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":o===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":o===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":o===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":o===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":o===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:Fr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const o=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(i=>r(i)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:o,time:n,timezone:Fr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:o,time:n})}if(t.schedule.kind==="once"){const o=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),i=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:o,time:i,timezone:Fr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:o,time:i})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:Fr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},F2=(t,e)=>!t||!Number.isFinite(t)?"":pu(t,e),Md=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),o=6e4,i=60*o,c=24*i,a=n>=0;if(r<o)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<i){const f=Math.round(r/o);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<c){const f=Math.floor(r/i),g=Math.round(r%i/o),b=g>0?`${f}h ${g}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:b}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:b})}const d=Math.floor(r/c),u=Math.round(r%c/i),h=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:h}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:h})},B2={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},L2=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function Od(){const{t}=mt(),e=xe(y=>y.isScheduledTasksDialogOpen),n=xe(y=>y.setScheduledTasksDialogOpen),r=xe(y=>y.isMobile),o=xe(y=>y.timeFormatPreference),i=qt(y=>y.projects),c=qt(y=>y.getActiveProject()),a=ls(y=>y.homeDirectory),{currentTheme:d}=_r(),[u,h]=Ge.useState(""),[f,g]=Ge.useState([]),[b,S]=Ge.useState(!0),[v,p]=Ge.useState(!1),[m,x]=Ge.useState(null),[w,j]=Ge.useState(null),N=Ge.useMemo(()=>i.find(y=>y.id===u)||null,[i,u]),A=Ge.useCallback(y=>{const I=y.label?.trim()||hr(y.path,a||void 0),$=y.icon?fl[y.icon]:null,z=y.color?ml[y.color]:void 0,G=$?s.jsx(R,{name:$,className:"h-3.5 w-3.5 shrink-0",style:z?{color:z}:void 0}):s.jsx(R,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:z?{color:z}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[y.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:y.iconBackground?{backgroundColor:y.iconBackground}:void 0,children:s.jsx(hl,{project:{id:y.id,iconImage:y.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:G})}):G,s.jsx("span",{className:"truncate",children:I})]})},[a,d.metadata.variant,d.colors.surface.foreground]),k=Ge.useCallback(async(y,I)=>{if(!y){g([]);return}I?.silent||S(!0);try{const $=await Wg(y);$.sort((z,G)=>{if(z.enabled!==G.enabled)return z.enabled?-1:1;const J=z.name.localeCompare(G.name);return J!==0?J:(z.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(G.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),g($)}catch($){Ee.error($ instanceof Error?$.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),I?.silent||g([])}finally{I?.silent||S(!1)}},[t]);Ge.useEffect(()=>{if(!e)return;const y=c?.id||i[0]?.id||"";h(y),y?k(y):(g([]),S(!1))},[e,c,i,k]),Ge.useEffect(()=>{if(!e)return;let y=null;const I=Dl($=>{$.type==="scheduled-task-ran"&&$.projectId===u&&(y&&clearTimeout(y),y=setTimeout(()=>{k(u,{silent:!0})},400))});return()=>{y&&clearTimeout(y),I()}},[e,u,k]);const C=Ge.useCallback(async y=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await yc(u,y),await k(u),Ee.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,k,t]),P=Ge.useCallback(async(y,I)=>{if(u){j(y.id),g($=>$.map(z=>z.id===y.id?{...z,enabled:I}:z));try{y.loopFile?await Vg(u,y.id,I):await yc(u,{...y,enabled:I}),await k(u,{silent:!0})}catch($){Ee.error($ instanceof Error?$.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await k(u,{silent:!0})}finally{j(null)}}},[u,k,t]),D=Ge.useCallback(async y=>{if(!(!u||!window.confirm(y.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:y.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:y.name})))){j(y.id);try{y.loopFile?await Hg(u,y.id):await Kg(u,y.id),await k(u,{silent:!0}),Ee.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch($){Ee.error($ instanceof Error?$.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{j(null)}}},[u,k,t]),F=Ge.useCallback(y=>{if(!y.loopFile){x(y),p(!0);return}if(N?.path){if(n(!1),r){Bn.getState().setSelectedPath(N.path,y.loopFile,{allowOutsideRoot:!0}),xe.getState().setActiveMainTab("files");return}xe.getState().openContextFile(N.path,y.loopFile)}},[r,N?.path,n]),B=Ge.useCallback(async y=>{if(u){j(y.id);try{const{sessionId:I,persistError:$}=await Gg(u,y.id);if(await Promise.all([k(u,{silent:!0}),xi()]),$?Ee.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Ee.success(t("sessions.scheduledTasks.dialog.toast.started")),I){const z=i.find(G=>G.id===u);Je.getState().setCurrentSession(I,z?.path??null),xe.getState().setActiveMainTab("chat")}}catch(I){Ee.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{j(null)}}},[u,i,k,t]),E=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(Ls,{value:u||"__none",onValueChange:y=>{const I=y==="__none"?"":y;h(I),I?k(I):g([])},children:[s.jsx(_s,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(Ds,{children:A(N)}):s.jsx(Ds,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs($s,{children:[i.length===0?s.jsx(rs,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,i.map(y=>s.jsx(rs,{value:y.id,children:A(y)},y.id))]})]})]}),_=()=>{x(null),p(!0)},W=y=>{h(y),y?k(y):g([])},V=s.jsx("div",{className:"min-h-[280px]",children:b?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(u?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(y=>{const I=w===y.id,$=y.state?.lastStatus||"idle",z=B2[$],G=t($==="success"?"sessions.scheduledTasks.dialog.status.success":$==="error"?"sessions.scheduledTasks.dialog.status.error":$==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),J=y.state?.nextRunAt,Z=y.state?.lastRunAt;return s.jsxs("div",{className:ye("rounded-lg border border-border p-4 transition-opacity",!y.enabled&&"opacity-60"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:y.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:O2(y,t)}),y.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:y.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:y.loopFile})}):null]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(R,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),J?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:Md(J,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:F2(J,o)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(R,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),$==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(R,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):Z?s.jsxs(s.Fragment,{children:[z.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${z.tone})`},children:[s.jsx(R,{name:z.Icon,className:"h-3.5 w-3.5"}),G]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:Md(Z,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),y.state?.lastError?s.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",style:L2("error"),children:[s.jsx(R,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:y.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:ye("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",y.enabled?"text-foreground":"text-muted-foreground",I&&"cursor-not-allowed opacity-50"),children:[s.jsx(qr,{checked:y.enabled,onChange:re=>{P(y,re)},ariaLabel:y.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:y.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:y.name}),disabled:I}),y.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(nt,{variant:"outline",size:"sm",onClick:()=>{B(y)},disabled:I,children:[s.jsx(R,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(nt,{variant:"outline",size:"sm",onClick:()=>F(y),disabled:I,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:y.name}),children:[s.jsx(R,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(nt,{variant:"destructive",size:"sm",onClick:()=>{D(y)},disabled:I,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:y.name}),children:s.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},y.id)})})}),K=s.jsxs("div",{className:"space-y-4",children:[E,V]});return s.jsxs(s.Fragment,{children:[r?s.jsx(_i,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:y=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),y]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(nt,{className:"w-full",onClick:_,disabled:!u,children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:K}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:i.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):i.map(y=>s.jsx("button",{type:"button",onClick:()=>W(y.id),className:ye("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",u===y.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:A(y)},y.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(nt,{size:"sm",onClick:_,disabled:!u,children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:V})})]})]})}):null,s.jsx(P2,{open:v,task:m,onOpenChange:p,onSave:C})]})}const mi=100;function Fd(){const t=tt.c(105),{t:e}=mt(),n=xe(G2),r=xe(K2),o=xe(H2),i=Je(V2),c=Je(W2),a=ls(U2);let d;t[0]!==n?(d=Z=>n?Z.archivedSessions:[],t[0]=n,t[1]=d):d=t[1];const u=Rs(qn(d)),[h,f]=l.useState(""),[g,b]=l.useState(null),[S,v]=l.useState(mi);let p;t[2]!==h?(p=h.trim().toLowerCase(),t[2]=h,t[3]=p):p=t[3];const m=p;let x;e:{if(!n){let re;t[4]===Symbol.for("react.memo_cache_sentinel")?(re=[],t[4]=re):re=t[4],x=re;break e}let Z;t[5]!==u?(Z=[...u].sort(z2),t[5]=u,t[6]=Z):Z=t[6],x=Z}const w=x;let j;if(t[7]!==a||t[8]!==w||t[9]!==e){const Z=new Map;for(const re of w){const ee=wt(Us(re))??"",he=Z.get(ee);if(he){he.sessions.push(re);continue}Z.set(ee,{directory:ee,label:ee?hr(ee,a)||ee:e("sessions.archivePage.otherProjects"),sessions:[re]})}j=[...Z.values()].sort($2),t[7]=a,t[8]=w,t[9]=e,t[10]=j}else j=t[10];const N=j;let A;e:{if(m){let re;if(t[11]!==m||t[12]!==w){let ee;t[14]!==m?(ee=he=>(he.title??"").toLowerCase().includes(m),t[14]=m,t[15]=ee):ee=t[15],re=w.filter(ee),t[11]=m,t[12]=w,t[13]=re}else re=t[13];A=re;break e}if(g===null){A=w;break e}let Z;t[16]!==N||t[17]!==g?(Z=N.find(re=>re.directory===g)?.sessions??[],t[16]=N,t[17]=g,t[18]=Z):Z=t[18],A=Z}const k=A;let C,P,D,F,B,E,_,W,V,K;if(t[19]!==u.length||t[20]!==N||t[21]!==k||t[22]!==a||t[23]!==m||t[24]!==n||t[25]!==h||t[26]!==g||t[27]!==o||t[28]!==i||t[29]!==r||t[30]!==e||t[31]!==c||t[32]!==S){B=Symbol.for("react.early_return_sentinel");e:{const Z=k.slice(0,S);C=k.length-Z.length;const re=u.length;let ee;t[43]===Symbol.for("react.memo_cache_sentinel")?(ee=ne=>{b(ne),v(mi)},t[43]=ee):ee=t[43];const he=ee;let be;t[44]!==o||t[45]!==i||t[46]!==r?(be=ne=>{const ce=wt(Us(ne));i(ne.id,ce??void 0),o("chat"),r(!1)},t[44]=o,t[45]=i,t[46]=r,t[47]=be):be=t[47];const Y=be;let we;t[48]!==e||t[49]!==c?(we=ne=>{c(ne.id).then(ce=>{ce?Ee.success(e("sessions.sidebar.session.restore.success")):Ee.error(e("sessions.sidebar.session.restore.error"))})},t[48]=e,t[49]=c,t[50]=we):we=t[50];const me=we;if(!n){B=null;break e}let Q;t[51]!==e?(Q=(ne,ce,Re,te,ae,de,H)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:ae,title:de,className:ye("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",H?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",te?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ce}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:Re})]}),H?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>_n.requestDelete({sessions:H,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.archivePage.deleteProjectAria",{label:ce}),children:s.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},ne),t[51]=e,t[52]=Q):Q=t[52];const pe=Q;F="absolute inset-0 z-10 flex flex-col bg-background",P="flex min-h-0 flex-1";let ve;if(t[53]!==pe||t[54]!==g||t[55]!==e||t[56]!==re){let ne;t[58]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>he(null),t[58]=ne):ne=t[58],ve=pe("__all__",e("sessions.archivePage.allDirectories"),re,g===null,ne),t[53]=pe,t[54]=g,t[55]=e,t[56]=re,t[57]=ve}else ve=t[57];let Te;if(t[59]!==N||t[60]!==pe||t[61]!==g){let ne;t[63]!==pe||t[64]!==g?(ne=ce=>pe(ce.directory||"__none__",ce.label,ce.sessions.length,g===ce.directory,()=>he(ce.directory),ce.directory||void 0,ce.sessions),t[63]=pe,t[64]=g,t[65]=ne):ne=t[65],Te=N.map(ne),t[59]=N,t[60]=pe,t[61]=g,t[62]=Te}else Te=t[62];t[66]!==ve||t[67]!==Te?(D=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[ve,Te]})}),t[66]=ve,t[67]=Te,t[68]=D):D=t[68],V="flex min-w-0 flex-1 flex-col";let ke;t[69]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t[69]=ke):ke=t[69];let Ie;t[70]===Symbol.for("react.memo_cache_sentinel")?(Ie=ne=>{f(ne.target.value),v(mi)},t[70]=Ie):Ie=t[70];let Ne;t[71]!==e?(Ne=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=Ne):Ne=t[72];let Ae;t[73]!==h||t[74]!==Ne?(Ae=s.jsxs("div",{className:"relative min-w-0 flex-1",children:[ke,s.jsx("input",{value:h,onChange:Ie,placeholder:Ne,className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-3 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50"})]}),t[73]=h,t[74]=Ne,t[75]=Ae):Ae=t[75];let Se;t[76]!==k.length||t[77]!==e?(Se=k.length===1?e("sessions.archivePage.countSingle",{count:k.length}):e("sessions.archivePage.countPlural",{count:k.length}),t[76]=k.length,t[77]=e,t[78]=Se):Se=t[78];let Oe;t[79]!==Se?(Oe=s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:Se}),t[79]=Se,t[80]=Oe):Oe=t[80],t[81]!==Ae||t[82]!==Oe?(K=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Ae,Oe]}),t[81]=Ae,t[82]=Oe,t[83]=K):K=t[83],W="min-h-0 flex-1 overflow-y-auto px-6 py-3",E="mx-auto w-full max-w-3xl space-y-0.5",_=Z.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(m?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):Z.map(ne=>{const ce=wt(Us(ne))??"",Re=ce?hr(ce,a)||ce:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>Y(ne),role:"button",tabIndex:0,onKeyDown:te=>{(te.key==="Enter"||te.key===" ")&&(te.preventDefault(),Y(ne))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:ne.title||e("sessions.sidebar.session.untitled")}),m&&Re?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:ce,children:Re}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Tu(ne.time?.archived??ne.time?.updated??ne.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:te=>{te.stopPropagation(),me(ne)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.archivePage.restoreSessionAria",{title:ne.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(R,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:te=>{te.stopPropagation(),_n.requestDelete({sessions:[ne],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":e("sessions.archivePage.deleteSessionAria",{title:ne.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},ne.id)})}t[19]=u.length,t[20]=N,t[21]=k,t[22]=a,t[23]=m,t[24]=n,t[25]=h,t[26]=g,t[27]=o,t[28]=i,t[29]=r,t[30]=e,t[31]=c,t[32]=S,t[33]=C,t[34]=P,t[35]=D,t[36]=F,t[37]=B,t[38]=E,t[39]=_,t[40]=W,t[41]=V,t[42]=K}else C=t[33],P=t[34],D=t[35],F=t[36],B=t[37],E=t[38],_=t[39],W=t[40],V=t[41],K=t[42];if(B!==Symbol.for("react.early_return_sentinel"))return B;let y;t[84]!==C||t[85]!==e?(y=C>0?s.jsx("button",{type:"button",onClick:()=>v(_2),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[84]=C,t[85]=e,t[86]=y):y=t[86];let I;t[87]!==y||t[88]!==E||t[89]!==_?(I=s.jsxs("div",{className:E,children:[_,y]}),t[87]=y,t[88]=E,t[89]=_,t[90]=I):I=t[90];let $;t[91]!==I||t[92]!==W?($=s.jsx("div",{className:W,children:I}),t[91]=I,t[92]=W,t[93]=$):$=t[93];let z;t[94]!==$||t[95]!==V||t[96]!==K?(z=s.jsxs("div",{className:V,children:[K,$]}),t[94]=$,t[95]=V,t[96]=K,t[97]=z):z=t[97];let G;t[98]!==P||t[99]!==D||t[100]!==z?(G=s.jsxs("div",{className:P,children:[D,z]}),t[98]=P,t[99]=D,t[100]=z,t[101]=G):G=t[101];let J;return t[102]!==F||t[103]!==G?(J=s.jsx("div",{className:F,children:G}),t[102]=F,t[103]=G,t[104]=J):J=t[104],J}function _2(t){return t+mi}function $2(t,e){return e.sessions.length-t.sessions.length}function z2(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function U2(t){return t.homeDirectory}function W2(t){return t.unarchiveSession}function V2(t){return t.setCurrentSession}function H2(t){return t.setActiveMainTab}function K2(t){return t.setArchivePageOpen}function G2(t){return t.isArchivePageOpen}function Bd(){const t=tt.c(18),{t:e}=mt(),n=xe(Q2),r=xe(Y2),o=qt(q2);let i;t[0]!==n?(i=b=>b.projects.find(S=>S.id===n)??null,t[0]=n,t[1]=i):i=t[1];const c=qt(i);if(!n||!c)return null;let a;t[2]!==c.id||t[3]!==o||t[4]!==r?(a=()=>{o(c.id),r(!0)},t[2]=c.id,t[3]=o,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(R,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let h;t[9]!==a||t[10]!==u?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(nt,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=h):h=t[11];let f;t[12]!==c.id||t[13]!==c.path?(f=s.jsx(Ig,{projectRef:{id:c.id,path:c.path},sections:"list-only"}),t[12]=c.id,t[13]=c.path,t[14]=f):f=t[14];let g;return t[15]!==h||t[16]!==f?(g=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[h,f]})})}),t[15]=h,t[16]=f,t[17]=g):g=t[17],g}function q2(t){return t.setActiveProjectIdOnly}function Y2(t){return t.setNewWorktreeDialogOpen}function Q2(t){return t.worktreesPageProjectId}const nl=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),X2=(t,e)=>{const n=nl(t),r=nl(e);return`${n}-${r}`.substring(0,60)},Ld=(t,e)=>`${t}/${e}`,J2=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},_d=(t,e)=>{const n=J2(e),r=t.directory,o=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};Bp(t.id,n),Je.getState().markSessionAsOpenChamberCreated(t.id),Rs.getState().upsertSession(o);try{bi().ensureChild(n,{bootstrap:!1}).setState(c=>{const a=c.session.findIndex(u=>u.id===t.id);if(a>=0&&c.session[a]===o)return c;const d=a>=0?c.session.map((u,h)=>h===a?o:u):[...c.session,o].sort((u,h)=>u.id.localeCompare(h.id));return{session:d,sessionTotal:Math.max(c.sessionTotal,d.length),limit:Math.max(c.limit,d.length)}})}catch{}return o},Z2=()=>{const t=qt.getState(),e=t.activeProjectId;if(!e)return null;const n=t.projects.find(o=>o.id===e);if(n?.path)return{id:n.id,path:n.path};const r=ls.getState().currentDirectory??null;if(r&&r.trim().length>0){const o=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${o}`,path:o}}return null},ka=xr()(qu(t=>({isLoading:!1,error:null,createMultiRun:async e=>{const n=e.name.trim(),{groups:r,agent:o,files:i,setupCommands:c}=e;if(!n)return t({error:"Group name is required"}),null;if(!r||r.length===0)return t({error:"At least one run group is required"}),null;for(let a=0;a<r.length;a++){if(!r[a].prompt.trim())return t({error:`Group ${a+1}: prompt is required`}),null;if(r[a].models.length<1)return t({error:`Group ${a+1}: select at least 1 model`}),null;if(r[a].models.length>5)return t({error:`Group ${a+1}: maximum 5 models allowed`}),null}t({isLoading:!0,error:null});try{const a=Z2();if(!a)return t({error:"Select a project",isLoading:!1}),null;const d=a.path,h=await Iu(d)&&e.isolateRuns!==!1,f=nl(n),g=h?await $i(d):void 0,b=h?await Ep(d):null,S=[],v=c?.filter(j=>j.trim().length>0)??[];for(let j=0;j<r.length;j++){const N=r[j],A=N.prompt,k=new Map;for(const P of N.models){const D=`${P.providerID}:${P.modelID}`;k.set(D,(k.get(D)||0)+1)}const C=new Map;for(const P of N.models){const D=`${P.providerID}:${P.modelID}`,F=k.get(D)||1,B=(C.get(D)||0)+1;C.set(D,B);const E=X2(P.providerID,P.modelID),_=r.length>1?`g${j+1}`:void 0,W=F>1?Ld(f,`${E}/${B}`):Ld(f,E),V=_?`${_}/${W}`:W,K=bj({groupSlug:f,runGroup:_,providerID:P.providerID,modelID:P.modelID,index:F>1?B:void 0});try{if(!h){const z=await Xs.withDirectory(d,()=>Xs.createSession({title:K}));_d(z,d),S.push({sessionId:z.id,worktreePath:d,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:A});continue}const y=await Tp(a,{preferredName:V,mode:"new",branchName:V,worktreeName:V,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:v,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:b}),I={...y,createdFromBranch:g,kind:"standard"};await Ip(a)&&await Rp(y.path);const $=await Xs.withDirectory(y.path,()=>Xs.createSession({title:K}));_d($,y.path),Je.getState().setWorktreeMetadata($.id,I),S.push({sessionId:$.id,worktreePath:y.path,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:A})}catch(y){console.warn("[MultiRun] Failed to create session:",y)}}}const p=c?.filter(j=>j.trim().length>0)??[];p.length>0&&Mp(a,p).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const m=S.map(j=>j.sessionId),x=S[0]?.sessionId??null;if(m.length===0)return t({error:"Failed to create any sessions",isLoading:!1}),null;const w=i?.map(j=>({type:"file",mime:j.mime,filename:j.filename,url:j.url}));return(async()=>{try{const j=Op.getState().expandText;await Promise.allSettled(S.map(async N=>{try{const A=await j(N.prompt).catch(()=>N.prompt);await Fp({sessionId:N.sessionId,directory:N.worktreePath,content:A,providerID:N.providerID,modelID:N.modelID,variant:N.variant,agent:o,files:w})}catch(A){console.warn("[MultiRun] Failed to start run:",A)}}))}catch(j){console.warn("[MultiRun] Failed to start runs:",j)}})(),t({isLoading:!1}),{groupSlug:f,sessionIds:m,firstSessionId:x}}catch(a){return t({error:a instanceof Error?a.message:"Failed to create Multi-Run",isLoading:!1}),null}},clearError:()=>{t({error:null})}}),{name:"multirun-store"}));function Gf(t){const e=tt.c(30),{git:n}=tr(),r=xu(t),o=Lp(t),i=_p(t),c=$p(t),a=mr(rk),d=mr(nk);let u,h;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==o||e[4]!==i?(u=()=>{!t||!n||o!==null||i||d(t,n,{silent:!0})},h=[t,n,d,o,i],e[0]=t,e[1]=d,e[2]=n,e[3]=o,e[4]=i,e[5]=u,e[6]=h):(u=e[5],h=e[6]),l.useEffect(u,h);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==o?(f=()=>{!t||!n||o===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=o,e[12]=f):f=e[12];const g=r?.all;let b;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==o||e[17]!==g?(b=[t,n,o,g,a],e[13]=t,e[14]=a,e[15]=n,e[16]=o,e[17]=g,e[18]=b):b=e[18],l.useEffect(f,b);const S=i||o===!0&&c;let v;e:{if(!r?.all){let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[19]=k):k=e[19],v=k;break e}let A;e[20]!==r.all?(A=r.all.filter(sk).sort(),e[20]=r.all,e[21]=A):A=e[21],v=A}const p=v;let m;e:{if(!r?.all){let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[22]=k):k=e[22],m=k;break e}let A;e[23]!==r.all?(A=r.all.filter(tk).map(ek).sort(),e[23]=r.all,e[24]=A):A=e[24],m=A}const x=m;let w;e:{if(!t){w=null;break e}if(o!==null){w=o;break e}if(S){w=null;break e}w=r?.all?!0:null}const j=w;let N;return e[25]!==j||e[26]!==S||e[27]!==p||e[28]!==x?(N={localBranches:p,remoteBranches:x,isLoading:S,isGitRepository:j},e[25]=j,e[26]=S,e[27]=p,e[28]=x,e[29]=N):N=e[29],N}function ek(t){return t.replace(/^remotes\//,"")}function tk(t){return t.startsWith("remotes/")}function sk(t){return!t.startsWith("remotes/")}function nk(t){return t.fetchStatus}function rk(t){return t.fetchBranches}const ok=({directory:t,value:e,onChange:n,className:r,disabled:o,id:i})=>{const{t:c}=mt(),{localBranches:a,remoteBranches:d,isLoading:u,isGitRepository:h}=Gf(t),f=l.useMemo(()=>[...a,...d.map(b=>`remotes/${b}`)],[a,d]);l.useEffect(()=>{if(o||u||f.length===0||e&&f.includes(e))return;const b=e;let S=!1;return(async()=>{try{const p=t?await $i(t).catch(()=>null):null;if(S)return;const m=localStorage.getItem(bc),{sourceBranch:x,shouldClearSavedSourceBranch:w}=Rg({branches:f,savedSourceBranch:m,rootBranch:p});if(w&&localStorage.removeItem(bc),S||b&&f.includes(b))return;x&&n(x)}catch{}})(),()=>{S=!0}},[f,t,o,u,n,e]);const g=o||!h||u;return s.jsxs("div",{children:[s.jsxs(Ls,{value:e,onValueChange:n,disabled:g,children:[s.jsx(_s,{id:i,size:"lg",className:ye("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(Ds,{placeholder:c(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx($s,{className:"max-h-[280px] max-w-[320px]",children:u?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:c("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&d.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:c("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(Ma,{children:[s.jsx(cc,{className:"font-semibold text-foreground",children:c("multiRun.branchSelector.groups.localBranches")}),a.map(b=>s.jsx(rs,{value:b,className:"whitespace-normal break-all",children:b},b))]}),a.length>0&&d.length>0&&s.jsx(zp,{}),d.length>0&&s.jsxs(Ma,{children:[s.jsx(cc,{className:"font-semibold text-foreground",children:c("multiRun.branchSelector.groups.remoteBranches")}),d.map(b=>s.jsx(rs,{value:`remotes/${b}`,className:"whitespace-normal break-all",children:b},`remotes/${b}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:c("multiRun.branchSelector.status.notInGitRepository")})]})},ik=10*1024*1024,Ca=5,hi=t=>{const e=tt.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(R,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let o;return e[1]!==n?(o=s.jsxs(dt,{children:[r,s.jsx(ft,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=o):o=e[2],o},Mr=t=>{const e=tt.c(9),{htmlFor:n,required:r,children:o,info:i}=t;let c;e[0]!==r?(c=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=c):c=e[1];let a;e[2]!==o||e[3]!==n||e[4]!==c?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[o,c]}),e[2]=o,e[3]=n,e[4]=c,e[5]=a):a=e[5];const d=i&&i;let u;return e[6]!==a||e[7]!==d?(u=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,d]}),e[6]=a,e[7]=d,e[8]=u):u=e[8],u},$d=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:o}=mt(),[i,c]=l.useState(""),[a,d]=l.useState(()=>[{id:jo(),prompt:"",models:[]}]),[u,h]=l.useState(""),[f,g]=l.useState([]),[b,S]=l.useState(!1),[v,p]=l.useState([]),[m,x]=l.useState(!1),[w,j]=l.useState(!1),[N,A]=l.useState(!0),k=l.useRef(null),C=ls(H=>H.currentDirectory??null),P=ls(H=>H.homeDirectory??null),D=l.useMemo(()=>{if(typeof window>"u")return null;const H=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof H=="string"&&H.trim().length>0?H.trim():null},[]),F=qt(H=>H.activeProjectId),B=qt(H=>H.setActiveProjectIdOnly),E=qt(H=>H.projects),[_,W]=l.useState(()=>F??null);l.useEffect(()=>{if(F){W(F);return}!_&&E.length>0&&W(E[0].id)},[F,E,_]);const V=l.useMemo(()=>_?E.find(H=>H.id===_)??null:null,[E,_]),K=V?.path??C,y=l.useCallback(H=>{W(H),H!==F&&B(H)},[F,B]),{currentTheme:I}=_r(),$=l.useCallback(H=>{const ge=H.label?.trim()||hr(H.path,P),ue=H.icon?fl[H.icon]:null,M=H.color?ml[H.color]:void 0,oe=ue?s.jsx(R,{name:ue,className:"h-3.5 w-3.5 shrink-0",style:M?{color:M}:void 0}):s.jsx(R,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:M?{color:M}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[H.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:H.iconBackground?{backgroundColor:H.iconBackground}:void 0,children:s.jsx(hl,{project:{id:H.id,iconImage:H.iconImage??null},options:{themeVariant:I.metadata.variant,iconColor:I.colors.surface.foreground},className:"h-full w-full object-contain",fallback:oe})}):oe,s.jsx("span",{className:"truncate",children:ge})]})},[P,I.metadata.variant,I.colors.surface.foreground]),z=l.useMemo(()=>{if(V?.path)return{id:V.id,path:V.path};const H=C??D;return H?{id:`path:${H}`,path:H}:null},[V,C,D]),[G]=l.useState(()=>typeof window<"u"?$n():!1),J=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),Z=cu(),re=l.useMemo(()=>{if(typeof window>"u")return null;const H=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof H=="number"&&Number.isFinite(H)&&H>0)return H;if(typeof navigator>"u")return null;const ge=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ge)return null;const ue=Number.parseInt(ge[1],10),M=Number.parseInt(ge[2],10);return Number.isNaN(ue)?null:ue===10?M:ue},[]),ee=l.useMemo(()=>G&&J||Z?"pl-[5.5rem]":"pl-3",[G,J,Z]),he=l.useMemo(()=>!G||!J||re===null?"":re>=26?"h-12":re<=15?"h-14":"",[G,J,re]),be=l.useCallback(async H=>{H.target.closest("button, a, input, select, textarea")||H.button===0&&G&&await Up()},[G]);l.useEffect(()=>{if(!n)return;const H=ge=>{ge.key==="Escape"&&(ge.preventDefault(),ge.stopPropagation(),n())};return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[n]);const[Y,we]=l.useState(""),{isLoading:me,isGitRepository:Q}=Gf(K),pe=l.useRef(!1),ve=Q===!0,Te=ve&&N;l.useEffect(()=>{if(Q===!1){pe.current=!0,A(!1);return}Q===!0&&pe.current&&(pe.current=!1,A(!0))},[Q]);const ke=ka(H=>H.createMultiRun),Ie=ka(H=>H.error),Ne=ka(H=>H.clearError);l.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(H=>{const ge=[...H];return ge.length>0&&!ge[0].prompt.trim()&&(ge[0]={...ge[0],prompt:t}),ge})},[t]),l.useEffect(()=>{if(!z)return;let H=!1;return j(!0),(async()=>{try{const ge=await Wp(z);H||p(ge)}catch{}finally{H||j(!1)}})(),()=>{H=!0}},[z]);const Ae=l.useCallback((H,ge)=>{d(ue=>ue.map(M=>M.id===H?{...M,...ge}:M))},[]),Se=l.useCallback(H=>{d(ge=>ge.filter(ue=>ue.id!==H))},[]),Oe=l.useCallback(()=>{d(H=>[...H,{id:jo(),prompt:"",models:[]}])},[]),ne=async H=>{const ge=H.target.files;if(!ge)return;let ue=0;for(let M=0;M<ge.length;M++){const oe=ge[M];if(oe.size>ik){Ee.error(o("multirun.launcher.toast.fileTooLarge",{fileName:oe.name}));continue}try{const De=await new Promise((fe,X)=>{const le=new FileReader;le.onload=()=>fe(le.result),le.onerror=X,le.readAsDataURL(oe)});g(fe=>[...fe,{id:jo(),filename:oe.name,mimeType:oe.type||"application/octet-stream",size:oe.size,dataUrl:De}]),ue++}catch(De){console.error("File attach failed",De),Ee.error(o("multirun.launcher.toast.attachFailed",{fileName:oe.name}))}}ue>0&&Ee.success(ue===1?o("multirun.launcher.toast.attachedSingle",{count:ue}):o("multirun.launcher.toast.attachedPlural",{count:ue})),k.current&&(k.current.value="")},ce=H=>{g(ge=>ge.filter(ue=>ue.id!==H))},Re=l.useMemo(()=>a.reduce((H,ge)=>H+ge.models.length,0),[a]),te=async H=>{H.preventDefault();const ge=a.filter(ue=>ue.prompt.trim()&&ue.models.length>=1);if(ge.length!==0&&!(Re<1)){S(!0),Ne();try{_&&_!==F&&B(_);const ue=f.map(X=>({mime:X.mimeType,filename:X.filename,url:X.dataUrl})),M=v.filter(X=>X.trim().length>0),oe=ge.map(X=>({prompt:X.prompt.trim(),models:X.models.map(le=>({providerID:le.providerID,modelID:le.modelID,displayName:le.displayName,variant:le.variant}))})),De={name:i.trim(),groups:oe,agent:u||void 0,worktreeBaseBranch:Te?Y:void 0,isolateRuns:Te,files:ue.length>0?ue:void 0,setupCommands:M.length>0?M:void 0},fe=await ke(De);fe&&(fe.firstSessionId&&Je.getState().setCurrentSession(fe.firstSessionId),e?.())}finally{S(!1)}}},ae=!!(i.trim()&&a.some(H=>H.prompt.trim()&&H.models.length>=1)&&Re>=1&&K&&!me&&(Q===!1||!Te||Y)),de=v.filter(H=>H.trim()).length;return s.jsxs("form",{onSubmit:te,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:be,className:ye("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",ee,he),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:o("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":o("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary app-region-no-drag",children:s.jsx(R,{name:"close",className:"h-5 w-5"})})}),s.jsx(ft,{children:s.jsx("p",{children:o("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(ll,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Mr,{htmlFor:"multirun-project",required:!0,children:o("multirun.launcher.project.label")}),E.length>0?s.jsxs(Ls,{value:_??void 0,onValueChange:y,children:[s.jsx(_s,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:V?s.jsx(Ds,{children:$(V)}):s.jsx(Ds,{placeholder:o("multirun.launcher.project.placeholder")})}),s.jsx($s,{fitContent:!0,children:E.map(H=>s.jsx(rs,{value:H.id,className:"max-w-[24rem]",children:$(H)},H.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:o("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Mr,{htmlFor:"group-name",required:!0,info:s.jsx(hi,{children:o("multirun.launcher.groupName.info")}),children:o("multirun.launcher.groupName.label")}),s.jsx(Jn,{id:"group-name",value:i,onChange:H=>c(H.target.value),placeholder:o("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Mr,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(hi,{children:o("multirun.launcher.baseBranch.info")}),children:o("multirun.launcher.baseBranch.label")}),s.jsx(ok,{directory:K,value:Y,onChange:we,disabled:!Te,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(qr,{checked:N,onChange:A,disabled:!ve,ariaLabel:o("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:o("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Mr,{htmlFor:"multirun-agent",info:s.jsx(hi,{children:o("multirun.launcher.agent.info")}),children:o("multirun.launcher.agent.label")}),s.jsx(Wf,{value:u,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(yi,{open:m,onOpenChange:x,children:[s.jsxs(xl,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(R,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:o("multirun.launcher.setupCommands.label")}),de>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:de}),s.jsx(R,{name:"arrow-down-s",className:ye("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(vi,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:w?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:o("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[v.map((H,ge)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(Jn,{value:H,onChange:ue=>{const M=[...v];M[ge]=ue.target.value,p(M)},placeholder:o("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>p(v.filter((ue,M)=>M!==ge)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":o("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]},`${H}-${ge}`)),s.jsxs("button",{type:"button",onClick:()=>p([...v,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(R,{name:"add",className:"h-3 w-3"}),o("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Mr,{htmlFor:"prompt",required:!0,children:o("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:k,type:"file",multiple:!0,className:"hidden",onChange:ne,accept:"*/*"}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>k.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(R,{name:"attachment-2",className:"h-3 w-3"}),o("multirun.launcher.attachments.attach")]})}),s.jsx(ft,{children:o("multirun.launcher.attachments.tooltip")})]}),f.map(H=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[H.mimeType.startsWith("image/")?s.jsx(R,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(R,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:H.filename,children:H.filename}),s.jsx("button",{type:"button",onClick:()=>ce(H.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(R,{name:"close",className:"h-3 w-3"})})]},H.id))]})]}),a.map((H,ge)=>s.jsx(ak,{group:H,groupIndex:ge,canRemove:a.length>1,onUpdate:Ae,onRemove:Se},H.id)),s.jsxs("button",{type:"button",onClick:Oe,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(R,{name:"add",className:"h-3.5 w-3.5"}),o("multirun.launcher.groups.addGroup")]}),Ie&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:Ie})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!Te&&Q!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(R,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:o("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:n,children:o("multirun.launcher.actions.cancel")}):null,s.jsx(nt,{type:"submit",size:"sm",disabled:!ae||b,children:b?o("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:o("multirun.launcher.actions.startWithRunCount",{count:Re})})})]})})]})},ak=t=>{const e=tt.c(99),{group:n,groupIndex:r,canRemove:o,onUpdate:i,onRemove:c}=t,{t:a}=mt(),[d,u]=l.useState(!1),[h,f]=l.useState(""),[g,b]=l.useState(!1),[S,v]=l.useState(""),[p,m]=l.useState(!1),[x,w]=l.useState(""),j=l.useRef(null),N=l.useRef(null),A=l.useRef(null),k=l.useRef(null);let C;e[0]!==n.id||e[1]!==n.models||e[2]!==i?(C=M=>{n.models.length>=Ca||i(n.id,{models:[...n.models,M]})},e[0]=n.id,e[1]=n.models,e[2]=i,e[3]=C):C=e[3];const P=C;let D;e[4]!==n.id||e[5]!==n.models||e[6]!==i?(D=M=>{i(n.id,{models:n.models.filter((oe,De)=>De!==M)})},e[4]=n.id,e[5]=n.models,e[6]=i,e[7]=D):D=e[7];const F=D;let B;e[8]!==n.id||e[9]!==n.models||e[10]!==i?(B=(M,oe)=>{i(n.id,{models:n.models.map((De,fe)=>fe===M?oe:De)})},e[8]=n.id,e[9]=n.models,e[10]=i,e[11]=B):B=e[11];const E=B;let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=(M,oe)=>{if(M.startsWith("/")){const le=M.indexOf(" "),se=M.indexOf(`
|
|
912
|
-
`),T=Math.min(le===-1?M.length:le,se===-1?M.length:se);if(oe<=T&&le===-1){v(M.substring(1,T)),b(!0),u(!1),m(!1);return}}b(!1);const De=M.substring(0,oe),fe=De.lastIndexOf("#");if(fe!==-1){const le=fe>0?De[fe-1]:null,se=De.substring(fe+1);if((!le||/\s/.test(le))&&!se.includes(" ")&&!se.includes(`
|
|
913
|
-
`)){w(se),m(!0),u(!1);return}}m(!1);const X=De.lastIndexOf("@");if(X!==-1){const le=X>0?De[X-1]:null,se=De.substring(X+1);(!le||/\s/.test(le))&&!se.includes(" ")&&!se.includes(`
|
|
914
|
-
`)?(f(se),u(!0)):u(!1);return}u(!1)},e[12]=_):_=e[12];const W=_;let V;e[13]!==n.id||e[14]!==i?(V=M=>{i(n.id,{prompt:M})},e[13]=n.id,e[14]=i,e[15]=V):V=e[15];const K=V;let y;e[16]!==n.prompt||e[17]!==K?(y=M=>{const oe=n.prompt,fe=j.current?.selectionStart??oe.length,le=oe.substring(0,fe).lastIndexOf("@"),se=M.relativePath&&M.relativePath.trim().length>0?M.relativePath.trim():M.path||M.name,T=le!==-1?le:fe,ie=`${oe.substring(0,T)}@${se} ${oe.substring(fe)}`,je=T+se.length+2;K(ie),u(!1),f(""),requestAnimationFrame(()=>{const Pe=j.current;Pe&&(Pe.selectionStart=je,Pe.selectionEnd=je,Pe.focus()),W(ie,je)})},e[16]=n.prompt,e[17]=K,e[18]=y):y=e[18];const I=y;let $;e[19]!==n.prompt||e[20]!==K?($=M=>{const oe=n.prompt,fe=j.current?.selectionStart??oe.length,le=oe.substring(0,fe).lastIndexOf("@"),se=le!==-1?le:fe,T=`${oe.substring(0,se)}@${M} ${oe.substring(fe)}`,ie=se+M.length+2;K(T),u(!1),f(""),requestAnimationFrame(()=>{const je=j.current;je&&(je.selectionStart=ie,je.selectionEnd=ie,je.focus()),W(T,ie)})},e[19]=n.prompt,e[20]=K,e[21]=$):$=e[21];const z=$;let G;e[22]!==K?(G=M=>{const oe=`/${M.name} `;K(oe),b(!1),v(""),m(!1),requestAnimationFrame(()=>{const De=j.current;De&&(De.focus(),De.selectionStart=De.value.length,De.selectionEnd=De.value.length),W(oe,oe.length)})},e[22]=K,e[23]=G):G=e[23];const J=G;let Z;e[24]!==n.prompt||e[25]!==K?(Z=(M,oe)=>{const De=n.prompt,X=j.current?.selectionStart??De.length,se=De.substring(0,X).lastIndexOf("#"),T=se!==-1?se:X,ie=`${De.substring(0,T)}#${oe} ${De.substring(X)}`,je=T+oe.length+2;K(ie),m(!1),w(""),requestAnimationFrame(()=>{const Pe=j.current;Pe&&(Pe.selectionStart=je,Pe.selectionEnd=je,Pe.focus()),W(ie,je)})},e[24]=n.prompt,e[25]=K,e[26]=Z):Z=e[26];const re=Z;let ee;e[27]!==g||e[28]!==d||e[29]!==p?(ee=M=>{if(g&&A.current&&(M.key==="Enter"||M.key==="ArrowUp"||M.key==="ArrowDown"||M.key==="Escape"||M.key==="Tab")){M.preventDefault(),A.current.handleKeyDown(M.key);return}d&&N.current&&(M.key==="Enter"||M.key==="ArrowUp"||M.key==="ArrowDown"||M.key==="Escape"||M.key==="Tab")&&(M.preventDefault(),N.current.handleKeyDown(M.key)),p&&k.current&&(M.key==="Enter"||M.key==="ArrowUp"||M.key==="ArrowDown"||M.key==="Escape"||M.key==="Tab")&&(M.preventDefault(),k.current.handleKeyDown(M.key))},e[27]=g,e[28]=d,e[29]=p,e[30]=ee):ee=e[30];const he=ee,be=r+1;let Y;e[31]!==a||e[32]!==be?(Y=a("multirun.launcher.groups.groupLabel",{index:be}),e[31]=a,e[32]=be,e[33]=Y):Y=e[33];let we;e[34]!==Y?(we=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:Y}),e[34]=Y,e[35]=we):we=e[35];let me;e[36]!==o||e[37]!==n.id||e[38]!==c||e[39]!==a?(me=o&&s.jsx("button",{type:"button",onClick:()=>c(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=o,e[37]=n.id,e[38]=c,e[39]=a,e[40]=me):me=e[40];let Q;e[41]!==we||e[42]!==me?(Q=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[we,me]}),e[41]=we,e[42]=me,e[43]=Q):Q=e[43];let pe;e[44]!==a?(pe=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=pe):pe=e[45];let ve;e[46]!==pe?(ve=s.jsx(Mr,{required:!0,children:pe}),e[46]=pe,e[47]=ve):ve=e[47];const Te=n.prompt;let ke;e[48]!==K?(ke=M=>{const oe=M.target.value;K(oe);const De=M.target.selectionStart??oe.length;W(oe,De)},e[48]=K,e[49]=ke):ke=e[49];let Ie;e[50]!==a?(Ie=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=Ie):Ie=e[51];let Ne;e[52]!==n.prompt||e[53]!==he||e[54]!==ke||e[55]!==Ie?(Ne=s.jsx(Kr,{ref:j,value:Te,onChange:ke,onKeyDown:he,placeholder:Ie,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=he,e[54]=ke,e[55]=Ie,e[56]=Ne):Ne=e[56];let Ae;e[57]!==S||e[58]!==J||e[59]!==g?(Ae=g?s.jsx(Ru,{ref:A,searchQuery:S,onCommandSelect:J,onClose:()=>b(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=S,e[58]=J,e[59]=g,e[60]=Ae):Ae=e[60];let Se;e[61]!==z||e[62]!==I||e[63]!==h||e[64]!==d?(Se=d?s.jsx(Mu,{ref:N,searchQuery:h,onFileSelect:I,onAgentSelect:z,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=z,e[62]=I,e[63]=h,e[64]=d,e[65]=Se):Se=e[65];let Oe;e[66]!==re||e[67]!==p||e[68]!==x?(Oe=p?s.jsx(Ou,{ref:k,searchQuery:x,onSnippetSelect:re,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=re,e[67]=p,e[68]=x,e[69]=Oe):Oe=e[69];let ne;e[70]!==Ne||e[71]!==Ae||e[72]!==Se||e[73]!==Oe?(ne=s.jsxs("div",{className:"relative",children:[Ne,Ae,Se,Oe]}),e[70]=Ne,e[71]=Ae,e[72]=Se,e[73]=Oe,e[74]=ne):ne=e[74];let ce;e[75]!==ve||e[76]!==ne?(ce=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ve,ne]}),e[75]=ve,e[76]=ne,e[77]=ce):ce=e[77];let Re;e[78]!==a?(Re=a("multirun.launcher.models.info",{max:Ca}),e[78]=a,e[79]=Re):Re=e[79];let te;e[80]!==Re?(te=s.jsx(hi,{children:Re}),e[80]=Re,e[81]=te):te=e[81];let ae;e[82]!==a?(ae=a("multirun.launcher.models.label"),e[82]=a,e[83]=ae):ae=e[83];let de;e[84]!==te||e[85]!==ae?(de=s.jsx(Mr,{required:!0,info:te,children:ae}),e[84]=te,e[85]=ae,e[86]=de):de=e[86];let H;e[87]!==n.models||e[88]!==P||e[89]!==F||e[90]!==E?(H=s.jsx(Vf,{selectedModels:n.models,onAdd:P,onRemove:F,onUpdate:E,minModels:1,maxModels:Ca}),e[87]=n.models,e[88]=P,e[89]=F,e[90]=E,e[91]=H):H=e[91];let ge;e[92]!==de||e[93]!==H?(ge=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[de,H]}),e[92]=de,e[93]=H,e[94]=ge):ge=e[94];let ue;return e[95]!==Q||e[96]!==ce||e[97]!==ge?(ue=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[Q,ce,ge]}),e[95]=Q,e[96]=ce,e[97]=ge,e[98]=ue):ue=e[98],ue},lk=l.createContext(null),ck=t=>{const e=tt.c(3),{children:n,value:r}=t;let o;return e[0]!==n||e[1]!==r?(o=s.jsx(lk.Provider,{value:r,children:n}),e[0]=n,e[1]=r,e[2]=o):o=e[2],o},dk=Zs(()=>Js(()=>import("./PlanView-ZYEJn8A_.js"),__vite__mapDeps([134,1,2,4,5,6,7,8,123,50,51,52,53,54,55,72,48,49,56,124,125,3,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,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,73,74,75,76,77,78,79,80,112,113,131,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(t=>({default:t.PlanView}))),zd=Zs(()=>Js(()=>import("./GitView-DBFrDDBv.js"),__vite__mapDeps([132,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,113,133,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,114,115,117,118,119,120])).then(t=>({default:t.GitView}))),uk=Zs(()=>Js(()=>import("./DiffView-DZIoOnV7.js"),__vite__mapDeps([121,1,2,4,5,6,7,8,3,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])).then(t=>({default:t.DiffView}))),fk=Zs(()=>Js(()=>import("./FilesView-BKL6YlKG.js"),__vite__mapDeps([122,1,2,4,5,6,7,8,3,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,113,123,124,125,126,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,127,128,114,115,129,130,112,131,118])).then(t=>({default:t.FilesView}))),mk=Zs(()=>Js(()=>import("./DiagramView-CFXxgg_a.js"),__vite__mapDeps([135,1,2,4,5,6,7,8,3,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,129,130])).then(t=>({default:t.DiagramView}))),hk=Zs(()=>Js(()=>import("./SettingsView-5RmswFZe.js").then(t=>t.a),__vite__mapDeps([136,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,113,137,123,124,125,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98,138,139])).then(t=>({default:t.SettingsView}))),pk=Zs(()=>Js(()=>import("./SettingsWindow-BZhAYFdS.js"),__vite__mapDeps([140,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,136,113,137,123,124,125,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98,138,139])).then(t=>({default:t.SettingsWindow}))),gk=()=>{const t=xe(y=>y.isSidebarOpen),e=xe(y=>y.activeMainTab),n=xe(y=>y.setIsMobile),r=xe(y=>y.isSessionSwitcherOpen),o=xe(y=>y.isSettingsDialogOpen),i=xe(y=>y.setSettingsDialogOpen),[c,a]=l.useState(!1);l.useEffect(()=>{o&&a(!0)},[o]);const d=xe(y=>y.isMultiRunLauncherOpen),u=xe(y=>y.setMultiRunLauncherOpen),h=xe(y=>y.multiRunLauncherPrefillPrompt),f=xe(y=>y.isScheduledTasksDialogOpen),g=xe(y=>y.isArchivePageOpen),b=xe(y=>y.worktreesPageProjectId),S=f||g||!!b||d;l.useEffect(()=>{const y=()=>xe.getState().closeMainSurfaces(),I=Je.subscribe((z,G)=>{const J=!!z.currentSessionId&&z.currentSessionId!==G.currentSessionId,Z=!!z.newSessionDraft?.open&&z.newSessionDraft!==G.newSessionDraft;(J||Z)&&y()}),$=xe.subscribe((z,G)=>{z.activeMainTab!==G.activeMainTab&&y()});return()=>{I(),$()}},[]);const{isMobile:v}=pr(),p=l.useRef(!1),[m,x]=l.useState(!1),[w,j]=l.useState(!1),[N,A]=l.useState(!1),[k,C]=l.useState(!1),P=l.useCallback(y=>{x(y),xe.getState().setSessionSwitcherOpen(y)},[]),D=l.useRef(typeof window>"u"?0:window.innerWidth),F=jc(-D.current),B=Ge.useRef(0),E=jc(D.current),_=Ge.useRef(0);Ge.useEffect(()=>{v&&(B.current=window.innerWidth,_.current=window.innerWidth)},[v]),Ge.useEffect(()=>{if(!v){A(!1);return}m&&A(!0),kc(F,m?0:-B.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[m,v,F]),Ge.useEffect(()=>{if(!v){C(!1);return}w&&C(!0),kc(E,w?0:_.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[v,w,E]),Ge.useEffect(()=>{if(v)return F.on("change",y=>{const I=B.current||D.current,$=m||y>-I+.5;A(z=>z===$?z:$)})},[v,F,m]),Ge.useEffect(()=>{if(v)return E.on("change",y=>{const I=_.current||D.current,$=w||y<I-.5;C(z=>z===$?z:$)})},[v,w,E]),Ge.useEffect(()=>{v&&!r&&m&&P(!1)},[r,v,m,P]),Ge.useEffect(()=>{if(!v){p.current=!1;return}p.current||(p.current=!0,P(!1),j(!1))},[v,P]),Ge.useEffect(()=>{if(!v||e!=="chat"||m||w||o)return;let y=!1,I;const $=z=>{I=window.setTimeout(()=>{if(y)return;const G=Je.getState(),J=xe.getState();if(!(J.activeMainTab!=="chat"||J.isSettingsDialogOpen||G.currentSessionId||G.newSessionDraft?.open)){if(G.isLoading){$(250);return}G.openNewSessionDraft({automatic:!0})}},z)};return $(500),()=>{y=!0,I!==void 0&&window.clearTimeout(I)}},[e,v,o,m,w]),Ge.useEffect(()=>{!v||!o||(P(!1),j(!1))},[v,o,P]),Mg(),l.useEffect(()=>{xe.getState().isMobile!==v&&n(v)},[v,n]);const W=l.useCallback(()=>{m&&P(!1),j(!w)},[m,w,P]),V=l.useMemo(()=>{if(!v&&e!=="terminal"&&e!=="diagram")return null;switch(e){case"plan":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(dk,{})});case"git":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(zd,{isActive:!w})});case"diff":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(uk,{})});case"terminal":return s.jsx(Vu,{});case"files":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(fk,{})});case"context":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(Wu,{})});case"diagram":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(mk,{})});default:return null}},[e,v,w]),K=e==="chat";return s.jsx(Og,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:ye("main-content-safe-area",v?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[s.jsx(y1,{}),s.jsx(iS,{}),s.jsx(dS,{}),s.jsx(f2,{}),v?s.jsxs(ck,{value:{leftDrawerOpen:m,rightDrawerOpen:w,toggleLeftDrawer:()=>{const y=!m;w&&j(!1),P(y)},toggleRightDrawer:W,leftDrawerX:F,rightDrawerX:E,leftDrawerWidth:B,rightDrawerWidth:_,setMobileLeftDrawerOpen:P,setRightSidebarOpen:j},children:[!o&&s.jsx(Ec,{onToggleLeftDrawer:()=>{const y=!m;w&&j(!1),P(y)},onToggleRightDrawer:()=>{W()},leftDrawerOpen:m,rightDrawerOpen:w}),s.jsx("div",{"data-page-scroll-lock":"true",className:ye("flex flex-1 overflow-hidden relative",o&&"hidden"),children:s.jsxs("main",{className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:ye("absolute inset-0",(!K||S)&&"invisible"),children:s.jsx(cs,{children:s.jsx(Fa,{active:K&&!o&&!S})})}),V&&s.jsx("div",{className:ye("absolute inset-0",S&&"invisible"),children:s.jsx(cs,{children:V})}),d&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(cs,{children:s.jsx($d,{initialPrompt:h,onCreated:()=>u(!1),onCancel:()=>u(!1)})})}),s.jsx(cs,{children:s.jsx(Od,{})}),s.jsx(cs,{children:s.jsx(Fd,{})}),s.jsx(cs,{children:s.jsx(Bd,{})}),s.jsx(Cc.div,{className:ye("absolute inset-0 z-20 bg-sidebar",!N&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:F},"aria-hidden":!m,children:s.jsx(cs,{children:s.jsx(jd,{mobileVariant:!0,isVisible:N})})}),k&&s.jsx(Cc.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:E},"aria-hidden":!w,children:s.jsx(cs,{children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(zd,{isActive:w})})})})]})}),o&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:s.jsx(cs,{children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(hk,{onClose:()=>i(!1)})})})})]}):s.jsxs(s.Fragment,{children:[s.jsx(cb,{}),s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[s.jsx(ib,{isOpen:t,isMobile:v,className:"border-border",topBar:s.jsx(ab,{}),children:s.jsx(jd,{isVisible:t})}),s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsx(Ec,{}),s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:ye("absolute inset-0",(!K||S)&&"invisible"),children:s.jsx(cs,{children:s.jsx(Fa,{active:K&&!o&&!S})})}),V&&s.jsx("div",{className:ye("absolute inset-0",S&&"invisible"),children:s.jsx(cs,{children:V})}),d&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(cs,{children:s.jsx($d,{isWindowed:!0,initialPrompt:h,onCreated:()=>u(!1),onCancel:()=>u(!1)})})}),s.jsx(cs,{children:s.jsx(Od,{})}),s.jsx(cs,{children:s.jsx(Fd,{})}),s.jsx(cs,{children:s.jsx(Bd,{})})]}),s.jsx(Zw,{})]})})}),s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(cs,{children:s.jsx(o1,{})})})]})]})]}),c?s.jsx(l.Suspense,{fallback:null,children:s.jsx(pk,{open:o,onOpenChange:i})}):null]})]})})},qf=12,xk=[{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"}],bk=t=>{const e=tt.c(18),{isActive:n,burstKey:r,className:o,durationMs:i,bursts:c,onComplete:a}=t,d=r===void 0?0:r,u=i===void 0?900:i,h=c===void 0?xk:c,f=Ge.useRef(!1);let g,b;e[0]!==n||e[1]!==a?(g=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},b=[n,a],e[0]=n,e[1]=a,e[2]=g,e[3]=b):(g=e[2],b=e[3]),Ge.useEffect(g,b);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=Array.from({length:qf},yk),e[4]=S):S=e[4];const v=S;if(!n)return null;let p;e[5]!==o?(p=ye("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=p):p=e[6];let m;if(e[7]!==d||e[8]!==h||e[9]!==u){let w;e[11]!==d||e[12]!==u?(w=j=>{const N={"--burst-delay":`${j.delay}ms`,"--burst-x":`${j.x}%`,"--burst-y":`${j.y}%`,"--firework-color":`var(${j.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:v.map((A,k)=>{const C=A.x*j.radius,P=A.y*j.radius,D={"--translate-x":`${C}px`,"--translate-y":`${P}px`,"--particle-delay":`${A.delay}ms`,color:`var(${j.colorVar})`};return s.jsx("span",{className:"firework-particle",style:D},`${j.id}-${k}-${d}`)})},`${j.id}-${d}`)},e[11]=d,e[12]=u,e[13]=w):w=e[13],m=h.map(w),e[7]=d,e[8]=h,e[9]=u,e[10]=m}else m=e[10];let x;return e[14]!==d||e[15]!==p||e[16]!==m?(x=s.jsx("div",{className:p,"aria-hidden":"true","data-burst-key":d,children:m}),e[14]=d,e[15]=p,e[16]=m,e[17]=x):x=e[17],x};function yk(t,e){const n=Math.PI*2*e/qf;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const vk=t=>{const e=tt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,o=r===void 0?3400:r;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={isActive:!1,cycle:0},e[2]=i):i=e[2];const[c,a]=Ge.useState(i),d=Ge.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 h=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(wk)},e[4]=f):f=e[4];const g=f;let b;e[5]!==o?(b=()=>{h(),a(Sk),d.current=window.setTimeout(()=>{a(jk),d.current=null},o)},e[5]=o,e[6]=b):b=e[6];const S=b;let v,p;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>h(),p=[h],e[7]=v,e[8]=p):(v=e[7],p=e[8]),Ge.useEffect(v,p);let m;return e[9]!==c.cycle||e[10]!==c.isActive||e[11]!==S?(m={isActive:c.isActive,burstKey:c.cycle,triggerFireworks:S,dismissFireworks:g},e[9]=c.cycle,e[10]=c.isActive,e[11]=S,e[12]=m):m=e[12],m};function wk(t){return t.isActive?{...t,isActive:!1}:t}function Sk(t){return{isActive:!0,cycle:t.cycle+1}}function jk(t){return t.isActive?{...t,isActive:!1}:t}const Yf=l.createContext(void 0),kk=t=>{const e=tt.c(10),{children:n}=t,{isActive:r,burstKey:o,triggerFireworks:i,dismissFireworks:c}=vk();let a;e[0]!==c||e[1]!==i?(a={triggerFireworks:i,dismissFireworks:c},e[0]=c,e[1]=i,e[2]=a):a=e[2];const d=a;let u;e[3]!==o||e[4]!==r?(u=s.jsx(bk,{isActive:r,burstKey:o}),e[3]=o,e[4]=r,e[5]=u):u=e[5];let h;return e[6]!==n||e[7]!==u||e[8]!==d?(h=s.jsxs(Yf.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=h):h=e[9],h},WC=()=>{const t=l.useContext(Yf);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Ck=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},Is=t=>{const e=tt.c(8),{label:n,value:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=o):o=e[0];let i;e[1]!==n?(i=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=i):i=e[2];let c;e[3]!==r?(c=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=c):c=e[4];let a;return e[5]!==i||e[6]!==c?(a=s.jsxs("div",{className:"rounded-md p-2",style:o,children:[i,c]}),e[5]=i,e[6]=c,e[7]=a):a=e[7],a},Ud=t=>{const e=tt.c(43),{title:n,snapshot:r,emptyLabel:o}=t,{t:i}=mt();let c;if(e[0]!==o||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==i||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(Dk,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==i?(f=r.startedAt?Ck(r.durationMs):i("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=i,e[15]=f):f=e[15];let g;e[16]!==f?(g=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=g):g=e[17];let b;e[18]!==h||e[19]!==g?(b=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,g]}),e[18]=h,e[19]=g,e[20]=b):b=e[20];let S;e[21]!==i?(S=i("memoryDebugPanel.metric.metrics"),e[21]=i,e[22]=S):S=e[22];let v;e[23]!==r.entries.length||e[24]!==S?(v=s.jsx(Is,{label:S,value:r.entries.length}),e[23]=r.entries.length,e[24]=S,e[25]=v):v=e[25];let p;e[26]!==i?(p=i("memoryDebugPanel.metric.samples"),e[26]=i,e[27]=p):p=e[27];let m;e[28]!==p||e[29]!==u?(m=s.jsx(Is,{label:p,value:u}),e[28]=p,e[29]=u,e[30]=m):m=e[30];let x;e[31]!==i?(x=i("memoryDebugPanel.metric.lastUpdate"),e[31]=i,e[32]=x):x=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==i?(w=r.lastUpdatedAt?i("memoryDebugPanel.common.live"):i("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=i,e[35]=w):w=e[35];let j;e[36]!==x||e[37]!==w?(j=s.jsx(Is,{label:x,value:w}),e[36]=x,e[37]=w,e[38]=j):j=e[38];let N;e[39]!==m||e[40]!==j||e[41]!==v?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[v,m,j]}),e[39]=m,e[40]=j,e[41]=v,e[42]=N):N=e[42],c=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,N,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:o}):s.jsx(Yn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(A=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:A.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:i("memoryDebugPanel.metric.countValue",{value:A.count})}),s.jsx("span",{children:i("memoryDebugPanel.metric.avgValue",{value:A.avg})}),s.jsx("span",{children:i("memoryDebugPanel.metric.maxValue",{value:A.max})}),s.jsx("span",{children:i("memoryDebugPanel.metric.totalValue",{value:A.total})})]})]},A.metric))})})]}),e[0]=o,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=i,e[6]=n,e[7]=c}else c=e[7];return c},Nk=t=>{const e=tt.c(99),{onClose:n}=t,{t:r}=mt(),[o,i]=l.useState("memory"),[c,a]=l.useState("idle"),d=Je(Pk),u=Eu(Ek),h=bu(),f=Vp(Tk),g=hn(Ik),[b,S]=l.useState(Rk),[v,p]=l.useState(Mk);let m;e[0]!==b.entries?(m=new Map,b.entries.forEach(ae=>{m.set(ae.metric,ae.count)}),e[0]=b.entries,e[1]=m):m=e[1];let x;e[2]!==m?(x=m.get("ui.message_list.render")??0,e[2]=m,e[3]=x):x=e[3];let w;e[4]!==m?(w=m.get("ui.message_list.render.streaming")??0,e[4]=m,e[5]=w):w=e[5];let j;e[6]!==m?(j=m.get("ui.chat_message.render")??0,e[6]=m,e[7]=j):j=e[7];let N;e[8]!==m?(N=m.get("ui.chat_message.render.streaming")??0,e[8]=m,e[9]=N):N=e[9];let A;e[10]!==m?(A=m.get("ui.chat_message.render.static_during_stream")??0,e[10]=m,e[11]=A):A=e[11];let k;e[12]!==m?(k=m.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[12]=m,e[13]=k):k=e[13];let C;e[14]!==x||e[15]!==w||e[16]!==j||e[17]!==N||e[18]!==A||e[19]!==k?(C={messageListRender:x,messageListRenderStreaming:w,chatMessageRender:j,chatMessageRenderStreaming:N,chatMessageRenderStaticDuringStream:A,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},e[14]=x,e[15]=w,e[16]=j,e[17]=N,e[18]=A,e[19]=k,e[20]=C):C=e[20];const P=C;let D,F;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{const ae=()=>{S(si()),p(ni())};ae();const de=window.setInterval(ae,500);return()=>window.clearInterval(de)},F=[],e[21]=D,e[22]=F):(D=e[21],F=e[22]),l.useEffect(D,F);let B,E;e[23]!==c?(B=()=>{if(c==="idle")return;const ae=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(ae)},E=[c],e[23]=c,e[24]=B,e[25]=E):(B=e[24],E=e[25]),l.useEffect(B,E);let _=0,W=0,V=0;for(const ae of Object.keys(f)){const de=f[ae]??[];W=W+de.length;for(const H of de)H.role==="user"?V=V+1:H.role==="assistant"&&(_=_+1)}let K;e[26]!==_||e[27]!==W||e[28]!==V?(K={assistant:_,total:W,user:V},e[26]=_,e[27]=W,e[28]=V,e[29]=K):K=e[29];const y=K;let I;if(e[30]!==d||e[31]!==f||e[32]!==u||e[33]!==h||e[34]!==r){let ae;e[36]!==d||e[37]!==f||e[38]!==u||e[39]!==r?(ae=de=>{const H=f[de.id]??[];let ge=0,ue=0;for(const oe of H)oe.role==="user"?ue=ue+1:oe.role==="assistant"&&(ge=ge+1);const M=u.get(de.id);return{id:de.id,title:de.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ge,messageCount:H.length,userMessageCount:ue,isStreaming:M?.isStreaming||!1,isZombie:M?.isZombie||!1,backgroundCount:M?.backgroundMessageCount||0,lastAccessed:M?.lastAccessedAt||0,isCurrent:de.id===d}},e[36]=d,e[37]=f,e[38]=u,e[39]=r,e[40]=ae):ae=e[40],I=h.map(ae).sort(Ok),e[30]=d,e[31]=f,e[32]=u,e[33]=h,e[34]=r,e[35]=I}else I=e[35];const $=I;let z;e[41]!==f?(z=Object.keys(f),e[41]=f,e[42]=z):z=e[42];const G=z.length;let J;e[43]===Symbol.for("react.memo_cache_sentinel")?(J=async()=>{try{const ae={generatedAt:new Date().toISOString(),ui:si(),vscode:ni()};await navigator.clipboard.writeText(JSON.stringify(ae,null,2)),a("copied")}catch{a("error")}},e[43]=J):J=e[43];const Z=J;let re;e[44]===Symbol.for("react.memo_cache_sentinel")?(re={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[44]=re):re=e[44];let ee;e[45]!==o?(ee=o==="memory"?s.jsx(R,{name:"database-2",className:"h-4 w-4 text-[var(--surface-foreground)]"}):s.jsx(R,{name:"bar-chart-box",className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[45]=o,e[46]=ee):ee=e[46];let he;e[47]!==r?(he=r("memoryDebugPanel.title"),e[47]=r,e[48]=he):he=e[48];let be;e[49]!==he?(be=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:he}),e[49]=he,e[50]=be):be=e[50];let Y;e[51]!==ee||e[52]!==be?(Y=s.jsxs("div",{className:"flex items-center gap-2",children:[ee,be]}),e[51]=ee,e[52]=be,e[53]=Y):Y=e[53];let we;e[54]!==o?(we=o==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(nt,{size:"xs",variant:"ghost",onClick:Z,children:s.jsx(R,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(nt,{size:"xs",variant:"ghost",onClick:()=>{zm(),S(si()),p(ni())},children:s.jsx(R,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[54]=o,e[55]=we):we=e[55];let me;e[56]!==n?(me=n?s.jsx(nt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(R,{name:"close",className:"h-4 w-4"})}):null,e[56]=n,e[57]=me):me=e[57];let Q;e[58]!==we||e[59]!==me?(Q=s.jsxs("div",{className:"flex items-center gap-1",children:[we,me]}),e[58]=we,e[59]=me,e[60]=Q):Q=e[60];let pe;e[61]!==Y||e[62]!==Q?(pe=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Y,Q]}),e[61]=Y,e[62]=Q,e[63]=pe):pe=e[63];let ve;e[64]===Symbol.for("react.memo_cache_sentinel")?(ve={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[64]=ve):ve=e[64];const Te=o==="memory"?"secondary":"ghost";let ke;e[65]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>i("memory"),e[65]=ke):ke=e[65];let Ie;e[66]!==r?(Ie=r("memoryDebugPanel.tabs.memory"),e[66]=r,e[67]=Ie):Ie=e[67];let Ne;e[68]!==Te||e[69]!==Ie?(Ne=s.jsx(nt,{size:"sm",variant:Te,className:"flex-1",onClick:ke,children:Ie}),e[68]=Te,e[69]=Ie,e[70]=Ne):Ne=e[70];const Ae=o==="streaming"?"secondary":"ghost";let Se;e[71]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>i("streaming"),e[71]=Se):Se=e[71];let Oe;e[72]!==r?(Oe=r("memoryDebugPanel.tabs.streaming"),e[72]=r,e[73]=Oe):Oe=e[73];let ne;e[74]!==Ae||e[75]!==Oe?(ne=s.jsx(nt,{size:"sm",variant:Ae,className:"flex-1",onClick:Se,children:Oe}),e[74]=Ae,e[75]=Oe,e[76]=ne):ne=e[76];let ce;e[77]!==Ne||e[78]!==ne?(ce=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ve,children:[Ne,ne]}),e[77]=Ne,e[78]=ne,e[79]=ce):ce=e[79];let Re;e[80]!==o||e[81]!==G||e[82]!==c||e[83]!==d||e[84]!==f||e[85]!==y||e[86]!==u||e[87]!==$||e[88]!==h||e[89]!==P||e[90]!==b||e[91]!==r||e[92]!==g||e[93]!==v?(Re=o==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(Is,{label:r("memoryDebugPanel.metric.totalMessages"),value:y.total}),s.jsx(Is,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${G} / ${dc.MAX_SESSIONS}`}),s.jsx(Is,{label:r("memoryDebugPanel.metric.userMessages"),value:y.user}),s.jsx(Is,{label:r("memoryDebugPanel.metric.assistantMessages"),value:y.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:Hp()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:dc.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:g})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(Yn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:$.map(ae=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:ae.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:ae.title}),ae.isStreaming?s.jsx(R,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,ae.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:ae.assistantMessageCount,user:ae.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:ae.messageCount})}),ae.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",ae.backgroundCount]}):null]})]},ae.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(nt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(Fk),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:y,sessionMessageRoleCounts:$.map(Bk),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(ft,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(c==="copied"?"memoryDebugPanel.streaming.copy.copied":c==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(nt,{size:"xs",variant:"outline",onClick:Z,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Is,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),s.jsx(Is,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:v.entries.length}),s.jsx(Is,{label:r("memoryDebugPanel.metric.messageListRenders"),value:P.messageListRender}),s.jsx(Is,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:P.messageListRenderStreaming}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:P.chatMessageRender}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:P.chatMessageRenderStreaming}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:P.chatMessageRenderStaticDuringStream}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:P.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Ud,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),v.entries.length>0?s.jsx(Ud,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:v,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}),e[80]=o,e[81]=G,e[82]=c,e[83]=d,e[84]=f,e[85]=y,e[86]=u,e[87]=$,e[88]=h,e[89]=P,e[90]=b,e[91]=r,e[92]=g,e[93]=v,e[94]=Re):Re=e[94];let te;return e[95]!==pe||e[96]!==ce||e[97]!==Re?(te=s.jsxs(Kp,{className:"fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area",style:re,children:[pe,ce,Re]}),e[95]=pe,e[96]=ce,e[97]=Re,e[98]=te):te=e[98],te},Ak=Nk;function Dk(t,e){return t+e.count}function Pk(t){return t.currentSessionId}function Ek(t){return t.sessionMemoryState}function Tk(t){return t.message}function Ik(t){return t.totalRequestCount}function Rk(){return si()}function Mk(){return ni()}function Ok(t,e){return e.lastAccessed-t.lastAccessed}function Fk(t){return{id:t.id,title:t.title}}function Bk(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}const Lk=()=>{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()??"":""},_k=async()=>{const t=Lk()||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")},Wd="openchamber:menu-action",Na="openchamber:check-for-updates",$k=t=>{const e=Je(x=>x.openNewSessionDraft),n=xe(x=>x.toggleCommandPalette),r=xe(x=>x.setCommandPaletteOpen),o=xe(x=>x.toggleHelpDialog),i=xe(x=>x.toggleSidebar),c=xe(x=>x.setSessionSwitcherOpen),a=xe(x=>x.setActiveMainTab),d=xe(x=>x.setSettingsDialogOpen),u=xe(x=>x.setAboutDialogOpen),h=vo(x=>x.checkForUpdates),{setThemeMode:f}=_r(),g=l.useRef(!1),b=l.useCallback(()=>{g.current||(g.current=!0,h().then(()=>{const{available:x,error:w}=vo.getState();if(w){Ee.error("Failed to check for updates",{description:w});return}x||Ee.success("You are on the latest version")}).finally(()=>{g.current=!1}))},[h]),S=l.useCallback(()=>{_n.requestDirectoryDialog()},[]),v=l.useCallback(x=>{const w=Gp();if(w.length===0)return;const j=Je.getState().currentSessionId,N=w.findIndex(C=>C.id===j);let A=x>0?0:w.length-1;N>=0&&(A=(N+x+w.length)%w.length);const k=w[A];k&&(a("chat"),c(!1),Je.getState().setCurrentSession(k.id))},[a,c]),p=l.useCallback(x=>{const{activeProjectId:w,projects:j,setActiveProject:N}=qt.getState();if(j.length===0)return;const A=j.findIndex(P=>P.id===w);let k=x>0?0:j.length-1;A>=0&&(k=(A+x+j.length)%j.length);const C=j[k];C&&N(C.id)},[]),m=l.useCallback(x=>{switch(x){case"about":u(!0);break;case"settings":d(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":a("chat"),c(!1),e();break;case"new-worktree-session":a("chat"),c(!1),ju();break;case"change-workspace":S();break;case"toggle-right-sidebar":{const w=ls.getState().currentDirectory;if(!w)break;const j=xe.getState(),N=Vr(w),A=j.contextPanelByDirectory[N];A?.isOpen?j.closeContextPanel(N):A?.activeTabId?j.setActiveContextPanelTab(N,A.activeTabId):j.openContextSurface(N,"git");break}case"open-right-sidebar-git":{const w=ls.getState().currentDirectory;if(!w)break;xe.getState().openContextSurface(Vr(w),"git");break}case"open-right-sidebar-files":{const w=ls.getState().currentDirectory;if(!w)break;xe.getState().openContextSurface(Vr(w),"file");break}case"toggle-terminal":{const w=ls.getState().currentDirectory;if(!w)break;xe.getState().openContextSurface(Vr(w),"terminal");break}case"toggle-terminal-expanded":{const w=ls.getState().currentDirectory;if(!w)break;const j=Vr(w),N=xe.getState(),A=N.contextPanelByDirectory[j];(A?.isOpen?A.tabs.find(C=>C.id===A.activeTabId)?.mode:null)!=="terminal"&&N.openContextSurface(j,"terminal"),N.toggleContextPanelExpanded(j);break}case"copy":{const w=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(w)||_k();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":Yp();break;case"toggle-sidebar":i();break;case"toggle-memory-debug":t?.();break;case"go-back":ls.getState().goBack();break;case"go-forward":ls.getState().goForward();break;case"previous-session":v(-1);break;case"next-session":v(1);break;case"previous-project":p(-1);break;case"next-project":p(1);break;case"help-dialog":o();break;case"download-logs":{qp().catch(()=>{Ee.error("Failed to collect OpenCode status")});break}}},[S,p,v,t,e,u,a,c,r,d,f,n,o,i]);l.useEffect(()=>{const x=j=>{const N=j.detail;N&&m(N)},w=()=>{b()};return window.addEventListener(Wd,x),window.addEventListener(Na,w),()=>{window.removeEventListener(Wd,x),window.removeEventListener(Na,w)}},[m,b]),l.useEffect(()=>{if(typeof window>"u")return;const w=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof w!="function")return;let j=null,N=null;return w("openchamber:menu-action",A=>{const k=A?.payload;typeof k=="string"&&m(k)}).then(A=>{j=A}).catch(()=>{}),w("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Na))}).then(A=>{N=A}).catch(()=>{}),()=>{(async()=>{try{const k=j?.();k instanceof Promise&&await k}catch{}try{const k=N?.();k instanceof Promise&&await k}catch{}})()}},[m])},zk="openchamber:tray-action",Vd=5e3,Uk=500,Wk=45e3,Qf=20,Hd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Kd=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,Vk=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},Hk=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Xf=(t,e)=>to(t,e,No.getState().ids,zi.getState().rankById),Kk=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},Gk=(t,e,n,r,o)=>{if(!t)return"";const i=eg(n,r,t),c=e.project?.name,a=i?.label?.trim()||c?.trim()||Kk(t),d=ii(t);let u=d&&o.get(d)||"";if(!u){for(const[h,f]of mr.getState().directories)if(ii(h)===d){u=f.status?.current??"";break}}if(!u)for(const h of r.values()){const f=h.find(g=>ii(g.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},qk=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=Cs.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(c=>[c.providerId,c])),i=[];for(const c of du){if(!e.includes(c.id))continue;const a=o.get(c.id);if(!a||a.configured!==!0)continue;const d=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const g=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:hu(h),value:Ta(f.valueLabel,g)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;i.push({provider:c.name,rows:d,status:u})}return{mode:r,groups:i}},Yk=async()=>{try{if(Ti())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=fr();if(e&&Kl(e,t))return"Local OpenChamber";const r=(await Zd()).hosts.find(o=>e?Kl(e,Um(o)):!1);return r?.label?.trim()?eu(r.label.trim()):"Instance"}catch{return""}},Qk=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=bi()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[i,c]of o.children.entries()){const a=c.getState();a.vcs?.branch&&e.set(ii(i)??i,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 h=u?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",g=t.get(d);(!g||g==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:Vk(h),directory:i})}for(const[d,u]of Object.entries(a.question??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"question",id:h.id,sessionId:f,sessionTitle:"",label:Hk(h),directory:i})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},Xk=()=>{const t=Rs.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Xf).slice(0,Qf).forEach(r=>{const o=Us(r);o&&e.add(o)});const n=new Map;for(const r of t){if(!r?.id)continue;const o=Us(r);if(!o||!e.has(o))continue;const i=n.get(o)??[];i.push(r.id),n.set(o,i)}return n},Jk=t=>{const e=Qk(),n=Wi.getState().index.session,r=Rs.getState().activeSessions,o=new Map(e.titleById),i=new Map;for(const p of r)if(p?.id&&(p.title&&o.set(p.id,p.title),p.parentID)){const m=i.get(p.parentID)??[];m.push(p.id),i.set(p.parentID,m)}const c=p=>{const m=[],x=[...i.get(p)??[]],w=new Set;for(;x.length;){const j=x.pop();w.has(j)||(w.add(j),m.push(j),x.push(...i.get(j)??[]))}return m},a=Ui.getState().statusById,d=p=>{const m=e.statusById.get(p);return m&&m!=="idle"?m:a.get(p)?.status.type??m??"idle"},u=p=>{const m=p.map(x=>d(x));return m.includes("busy")?"busy":m.includes("retry")?"retry":"idle"},h=qt.getState().projects,f=Je.getState().availableWorktreesByProject,g=r.filter(p=>p?.id&&!p.parentID).slice().sort(Xf).slice(0,Qf).map(p=>{const m=[p.id,...c(p.id)],x=Us(p)??"";return{id:p.id,title:p.title||"Untitled session",status:u(m),branch:x?e.branchByDirectory.get(x)??"":"",unseen:m.reduce((w,j)=>w+(n.unseenCount[j]??0),0),hasError:m.some(w=>n.unseenHasError[w]??!1),directory:x,subtitle:Gk(x,p,h,f,e.branchByDirectory)}}),b=e.approvals.map(p=>({...p,sessionTitle:o.get(p.sessionId)||""})),S=xe.getState();let v=0;if(S.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let m=n.unseenCount[p.id]??0;m===0&&S.notifyOnSubtasks&&(m=c(p.id).reduce((x,w)=>x+(n.unseenCount[w]??0),0)),m>0&&(v+=1)}return{sessions:g,approvals:b,instanceName:t,usage:qk(),dockBadgeCount:v}},Zk=()=>{l.useEffect(()=>{if(!Hd()||!Kd()||!Ri())return;let t=!1,e="",n=null,r="";const o=()=>{if(t)return;const k=Jk(r),C=JSON.stringify(k);C!==e&&(e=C,ur("desktop_tray_update",k))};Yk().then(k=>{t||(r=k,o())});const i=async()=>{const k=Xk();await Promise.all([...k.entries()].map(async([C,P])=>{const D=await Xs.getSessionStatusForDirectory(C).catch(()=>null);t||D===null||Jp(C,D,P)}))},c=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,o()},Uk))},a=new Map,d=()=>{if(t)return;let k;try{k=bi()}catch{return}const C=new Set;for(const[P,D]of k.children.entries())C.add(P),a.has(P)||a.set(P,D.subscribe(()=>c()));for(const[P,D]of a)C.has(P)||(D(),a.delete(P))};let u=null;try{u=bi().subscribeRegistry(()=>{d(),c()})}catch{}d();const h=Wi.subscribe(()=>c()),f=Rs.subscribe(()=>c()),g=qt.subscribe(()=>c()),b=Je.subscribe(()=>c()),S=mr.subscribe(()=>c()),v=xe.subscribe(()=>c()),p=Ui.subscribe(()=>c()),m=zi.subscribe(()=>c()),x=No.subscribe(()=>c());Qp(Xp());const w=window.setInterval(()=>{xi()},Wk);i();const j=window.setInterval(()=>{i()},Vd),N=Cs.subscribe(()=>c());Cs.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:k,results:C}=Cs.getState();k.length>0&&k.some(D=>!C.some(F=>F.providerId===D))&&Cs.getState().fetchQuotas(k)});const A=window.setInterval(()=>{d(),o()},Vd);return o(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(A),window.clearInterval(w),window.clearInterval(j),h(),f(),g(),b(),S(),v(),p(),m(),x(),N(),u?.();for(const k of a.values())k();a.clear()}},[]),l.useEffect(()=>{if(!Hd()||!Kd()||typeof window>"u")return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=o=>{o.type==="respond-permission"&&Zp(o.sessionId,o.id,o.response).catch(()=>{Ee.error("Failed to respond to permission request")})};let r=null;return e(zk,o=>{const i=o?.payload;!i||typeof i!="object"||typeof i.type!="string"||n(i)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},eC="/api/notifications/stream",tC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),sC=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="openchamber:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},nC=t=>{const e=tt.c(3),n=t?.enabled??!0;let r,o;e[0]!==n?(r=()=>{if(!n||$n()||!rl()||typeof window>"u"||typeof EventSource>"u")return;const i=new EventSource(nu().sse(eC));return i.onmessage=rC,()=>{i.close()}},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),l.useEffect(r,o)};function rC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=xe.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&tC())return;const r=sC(e);if(!r)return;Ii()?.notifications?.notifyAgentCompletion(r)}const Gd="pwa-install-toast-shown",qd="pwa-install-toast-dismissed",oC=()=>{const t=tt.c(6),{browserTab:e}=Fg(),{t:n}=mt(),r=l.useRef(n);let o,i;t[0]!==n?(o=()=>{r.current=n},i=[n],t[0]=n,t[1]=o,t[2]=i):(o=t[1],i=t[2]),l.useEffect(o,i);let c,a;t[3]!==e?(c=()=>{if(typeof window>"u"||!rl()||!e)return;let d=null,u=null;const h=()=>{u!==null&&(Ee.dismiss(u),u=null)},f=async()=>{if(!d)return;const S=d;d=null,h(),await S.prompt();const{outcome:v}=await S.userChoice;v==="accepted"&&Ee.success(r.current("pwa.installPrompt.started"))},g=S=>{const v=S;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const p=Hr(),m=Wm();Bg({dismissed:p.getItem(qd),sessionShown:m.getItem(Gd),hasActiveToast:u!==null})&&(m.setItem(Gd,"true"),u=Ee.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Hr().setItem(qd,"true"),h()}}}))},b=()=>{d=null,h(),Ee.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",g),window.addEventListener("appinstalled",b),()=>{h(),window.removeEventListener("beforeinstallprompt",g),window.removeEventListener("appinstalled",b)}},a=[e],t[3]=e,t[4]=c,t[5]=a):(c=t[4],a=t[5]),l.useEffect(c,a)},iC=({open:t,onOpenChange:e})=>{const{t:n}=mt(),r=!1,[o,i]=l.useState(null),[c,a]=l.useState(null),[d,u]=l.useState(!1),[h,f]=l.useState(!1),[g,b]=l.useState(null),[S,v]=l.useState(!1);l.useCallback(async()=>{},[g,d,r,n]),l.useEffect(()=>{if(!t)return;(async()=>{try{const x=await ms("/api/system/info");if(x.ok){const w=await x.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){i(w.openchamberVersion);return}}}catch{}i(await tg())})()},[t]),l.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const w=await ms("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const j=await w.json().catch(()=>null),N=typeof j?.currentVersion=="string"?j.currentVersion.trim():"";!m&&N&&a(N)}catch{}})(),()=>{m=!0}},[t]),l.useEffect(()=>{{b(null),v(!1);return}},[t,r]);const p=o;return s.jsx(Ws,{open:t,onOpenChange:e,children:s.jsx(Vs,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(yu,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[p&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:p})}),c&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:c})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(R,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(R,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(R,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Yd=t=>{if(!(typeof window>"u")){if(t){window.location.href="openchamber://focus/mcp-auth";return}window.location.replace("/")}},Aa=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},aC=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to OpenChamber and click Authorize again.":n},lC=()=>{const t=sg(a=>a.completeAuth),[e,n]=l.useState("working"),[r,o]=l.useState(!1),[i,c]=l.useState("Completing MCP authorization...");return l.useEffect(()=>{if(typeof window>"u"){n("error"),c("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),d=Aa(a,"code"),u=ng(a),h=rg(a),f=Aa(a,"error"),g=Aa(a,"error_description");if(f){h&&ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),c(g??f);return}(async()=>{try{if(!d)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let b=u,S=!1;if(h){const v=await ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(v.ok){const p=await v.json().catch(()=>null);S=p?.origin===og,o(S),!b&&p?.name?.trim()&&(b={name:p.name.trim(),directory:typeof p.directory=="string"&&p.directory.trim()?p.directory.trim():null})}}if(!b?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");await t(b.name,d,b.directory),h&&await ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),S&&Yd(!0),c("Authorization completed. You can close this tab and return to OpenChamber.")}catch(b){h&&await ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),c(aC(b,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("h1",{className:ig,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:ye("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:i})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(nt,{type:"button",onClick:()=>Yd(r),children:"Return to OpenChamber"})})]})})},Qd=Zs(()=>Js(()=>import("./OnboardingScreen-D2Y6djMw.js"),__vite__mapDeps([141,1,2,4,5,6,7,8,3,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])).then(t=>({default:t.OnboardingScreen}))),cC=()=>{const t=tt.c(3),e=xe(pC),n=xe(gC);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(iC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},dC=t=>{const e=tt.c(21),{onRetry:n,isRetrying:r}=t,{t:o}=mt();let i;e[0]!==o?(i=o("startup.initRecovery.title"),e[0]=o,e[1]=i):i=e[1];let c;e[2]!==i?(c=s.jsx("h1",{className:"typography-title text-foreground",children:i}),e[2]=i,e[3]=c):c=e[3];let a;e[4]!==o?(a=o("startup.initRecovery.description"),e[4]=o,e[5]=a):a=e[5];let d;e[6]!==a?(d=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=d):d=e[7];let u;e[8]!==c||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let h;e[11]!==r||e[12]!==o?(h=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=o,e[13]=h):h=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==h?(f=s.jsx(nt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let g;return e[18]!==u||e[19]!==f?(g=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[u,f]})}),e[18]=u,e[19]=f,e[20]=g):g=e[20],g},Xd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",uC=()=>{if(typeof window>"u"||!Jg())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),o=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:o,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},fC=()=>typeof window>"u"?!1:window.location.pathname===ug,mC=t=>{const e=tt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:o}=t,i=ls(xC),c=Je(bC),a=Je(yC),d=Fi(),u=l.useRef(null);let h;e[0]!==n.directory?(h=Xd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let g;e[2]!==i?(g=Xd(i),e[2]=i,e[3]=g):g=e[3];const b=g;let S,v;if(e[4]!==b||e[5]!==c||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(S=()=>{if(r||f&&b!==f)return;const N=`${f}
|
|
915
|
-
${n.sessionId}`;u.current===N&&c||(u.current=N,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},v=[b,c,n.directory,n.sessionId,f,r,a,d],e[4]=b,e[5]=c,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=d,e[12]=S,e[13]=v):(S=e[12],v=e[13]),l.useEffect(S,v),f&&b!==f)return null;let p;e[14]!==o?(p=s.jsx(Fu,{embeddedBackgroundWorkEnabled:o}),e[14]=o,e[15]=p):p=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Hu,{}),e[16]=m):m=e[16];let x;e[17]!==o||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(x=s.jsx(Fa,{active:o,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=o,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=x):x=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Bu,{}),e[21]=w):w=e[21];let j;return e[22]!==p||e[23]!==x?(j=s.jsxs(s.Fragment,{children:[p,m,x,w]}),e[22]=p,e[23]=x,e[24]=j):j=e[24],j};function hC({apis:t}){l.useEffect(()=>{Vm("App:mounted"),Hm()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Vt(Q=>Q.initializeApp),n=Vt(Q=>Q.isInitialized),r=Vt(Q=>Q.isConnected),o=Vt(Q=>Q.providers.length),i=Vt(Q=>Q.agents.length),c=Vt(Q=>Q.loadProviders),a=Vt(Q=>Q.loadAgents),d=Je(Q=>Q.error),u=Je(Q=>Q.clearError),h=ls(Q=>Q.currentDirectory),f=ls(Q=>Q.setDirectory),g=ls(Q=>Q.isSwitchingDirectory),[b,S]=l.useState(!1),v=Lr(Q=>Q.refreshStatus),[p,m]=l.useState(()=>t.runtime.isVSCode),[x,w]=l.useState(!1),[j,N]=l.useState(!1),[A,k]=l.useState(0),[C,P]=l.useState(0),[D,F]=l.useState(!1),B=xe(Q=>Q.wideChatLayoutEnabled),E=xe(Q=>Q.mobileKeyboardMode),_=l.useMemo(()=>$n(),[]),W=il(Q=>Q.setPlanModeEnabled),[V,K]=l.useState(()=>Gl()),[y,I]=l.useState(()=>{const Q=ql();return Q!==null?Yl({isDesktopShell:!0,bootOutcome:Q}):null}),$=l.useRef(!1),z=l.useMemo(()=>uC(),[]),G=!z||x,J=l.useMemo(()=>fC(),[]);l.useEffect(()=>(Ql(b),()=>{Ql(!1)}),[b]),l.useEffect(()=>{Km(E)},[E]),l.useEffect(()=>{m(t.runtime.isVSCode)},[t.runtime.isVSCode]),l.useEffect(()=>Mi(Q=>{Lg(Q),P(pe=>pe+1),N(!1),k(pe=>pe+1)}),[]);const Z=uc(Q=>{const pe=xn();return Object.values(Q.runsByOriginalSessionID).filter(ve=>ve.status==="running"&&ve.runtimeKey===pe).map(ve=>`${ve.originalSessionID}:${ve.phase}:${ve.lastForwardedMessageID??""}:${ve.expectedAssistantParentID??""}`).sort().join("|")});l.useEffect(()=>{if(z)return;const Q=xn(),pe=Object.values(uc.getState().runsByOriginalSessionID).filter(ve=>ve.status==="running"&&ve.runtimeKey===Q);for(const ve of pe)ag(ve.originalSessionID)},[Z,z,C]),l.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",B),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[B]),l.useEffect(()=>(Xl(t),()=>Xl(null)),[t]),l.useEffect(()=>{z||v(t.github,{force:!0})},[t.github,z,v]),lg();const re=V==="valid",ee=y?.screen==="main";l.useEffect(()=>{if(!Gm({isDesktopShell:_,isInitialized:n,bootOutcomeKnown:re,bootViewIsMain:ee}))return;const Q=setTimeout(()=>{const pe=document.getElementById("initial-loading");pe&&(pe.classList.add("fade-out"),setTimeout(()=>{pe.remove()},300))},150);return()=>clearTimeout(Q)},[_,n,re,ee]),l.useEffect(()=>{if(!_||V!=="malformed")return;const Q=document.getElementById("initial-loading");Q&&(Q.textContent="Desktop startup failed — please restart the app.")},[_,V]),l.useEffect(()=>{if(_)return;const Q=setTimeout(()=>{const pe=document.getElementById("initial-loading");pe&&!n&&(pe.classList.add("fade-out"),setTimeout(()=>{pe.remove()},300))},5e3);return()=>clearTimeout(Q)},[_,n]),l.useEffect(()=>{let Q=!1;return(async()=>{const ve=await ms("/health",{method:"GET"}).catch(()=>null);if(!ve||!ve.ok||Q)return;const Te=await ve.json().catch(()=>null);if(!Te||Q)return;const ke=Te.planModeExperimentalEnabled;W(ke===!0||ke===1||ke==="1"||ke==="true")})(),()=>{Q=!0}},[W]),l.useEffect(()=>{p||e()},[e,p]),l.useEffect(()=>{if(p||n)return;let Q=!0,pe,ve=0;const Te=10,ke=1e3,Ie=async()=>{if(!Q)return;if(ve>=Te){N(!0);return}const Ne=Vt.getState();if(Ne.isInitialized){N(!1);return}ve+=1,await Ne.initializeApp();const Ae=Vt.getState();if(!Q)return;if(Ae.isInitialized){N(!1);return}if(ve>=Te){N(!0);return}const Se=Math.min(ke*Math.pow(2,ve-1),16e3);pe=setTimeout(Ie,Se)};return pe=setTimeout(Ie,ke),()=>{Q=!1,pe&&clearTimeout(pe)}},[A,n,p]),l.useEffect(()=>{n&&N(!1)},[n]),l.useEffect(()=>{if(!j)return;const Q=document.getElementById("initial-loading");Q&&(Q.classList.add("fade-out"),setTimeout(()=>{Q.remove()},300))},[j]),l.useEffect(()=>{if(p||!r||o>0&&i>0)return;let Q=!0,pe=0;const ve=15,Te=async()=>{const Ie=Vt.getState();if(!(Ie.providers.length>0&&Ie.agents.length>0))try{Ie.providers.length===0&&await c({source:"startupRecovery"}),Vt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};Te();const ke=setInterval(()=>{if(Q){if(++pe>=ve){clearInterval(ke);return}Te()}},2e3);return()=>{Q=!1,clearInterval(ke)}},[r,p,a,c,o,i]),l.useEffect(()=>{g||p||r&&Xs.setDirectory(h)},[h,g,r,p]),l.useEffect(()=>{if(!z||typeof window>"u")return;const Q=Te=>{const ke=Te?.visible===!0;w(ke)},pe=Te=>{if(Te.origin!==window.location.origin)return;const ke=Te.data;ke?.type==="openchamber:embedded-visibility"&&Q(ke.payload)},ve=window;return ve.__openchamberSetEmbeddedVisibility=Q,window.addEventListener("message",pe),()=>{window.removeEventListener("message",pe),ve.__openchamberSetEmbeddedVisibility===Q&&delete ve.__openchamberSetEmbeddedVisibility}},[z]),l.useEffect(()=>{!z?.directory||p||h!==z.directory&&f(z.directory,{showOverlay:!1})},[h,z,p,f]),l.useEffect(()=>{if(!z||typeof window>"u")return;const Q=pe=>{pe.storageArea===window.localStorage&&pe.key==="ui-store"&&xe.persist.rehydrate()};return window.addEventListener("storage",Q),()=>{window.removeEventListener("storage",Q)}},[z]),l.useEffect(()=>{if(typeof window>"u")return;const Q=pe=>{const ve=pe.detail,Te=typeof ve?.sessionId=="string"?ve.sessionId.trim():"";if(!Te)return;const ke=typeof ve?.directory=="string"&&ve.directory.trim().length>0?ve.directory.trim():null;xe.getState().setActiveMainTab("chat"),Je.getState().setCurrentSession(Te,ke)};return window.addEventListener("openchamber:open-session",Q),()=>window.removeEventListener("openchamber:open-session",Q)},[]),l.useEffect(()=>{if(typeof window>"u")return;const Q=()=>{const pe=ls.getState().currentDirectory,{activeProjectId:ve,projects:Te}=qt.getState(),ke=Te.find(Ie=>Ie.id===ve)??null;ur("desktop_open_draft_mini_chat_window",{directory:pe||ke?.path||"",projectId:ke?.id??null})};return window.addEventListener("openchamber:open-mini-chat",Q),()=>window.removeEventListener("openchamber:open-mini-chat",Q)},[]),l.useEffect(()=>{if(typeof window>"u")return;const Q=()=>{const pe=Je.getState().currentSessionId;pe&&vu(pe)};return window.addEventListener("focus",Q),()=>window.removeEventListener("focus",Q)},[]),l.useEffect(()=>{if(typeof window>"u")return;const Q=pe=>{const ve=pe.detail,Te=typeof ve?.directory=="string"&&ve.directory.trim().length>0?ve.directory.trim():null,ke=typeof ve?.projectId=="string"&&ve.projectId.trim().length>0?ve.projectId.trim():null;xe.getState().setActiveMainTab("chat"),xe.getState().setSessionSwitcherOpen(!1),Je.getState().openNewSessionDraft({selectedProjectId:ke,directoryOverride:Te,preserveDirectoryOverride:!!Te})};return window.addEventListener("openchamber:open-draft-session",Q),()=>window.removeEventListener("openchamber:open-draft-session",Q)},[]),l.useEffect(()=>{typeof window>"u"||!n||g||$.current||($.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,g]),cg({enabled:G}),nC({enabled:G}),oC(),dg(),_g();const he=l.useCallback(()=>{S(Q=>!Q)},[]);$k(he),Zk(),l.useEffect(()=>{if(z)return;const Q=pe=>{mu(pe)&&pe.shiftKey&&!pe.altKey&&(pe.code==="KeyD"||pe.key.toLowerCase()==="d")&&(pe.preventDefault(),S(Te=>!Te))};return window.addEventListener("keydown",Q,!0),()=>window.removeEventListener("keydown",Q,!0)},[z]),l.useEffect(()=>{z||d&&setTimeout(()=>u(),5e3)},[u,z,d]),l.useEffect(()=>{if(!_||V!=="not-injected")return;let Q=!1,pe=0;const ve=200,Te=2e3,ke=50,Ie=()=>{if(Q)return;pe++;const Ne=Gl();if(Ne!=="not-injected"){if(Q=!0,K(Ne),Ne==="valid"){const Se=ql();Se&&I(Yl({isDesktopShell:!0,bootOutcome:Se}))}return}const Ae=Math.min(ve*Math.pow(1.1,pe),Te);if(pe>=ke){const Se=document.getElementById("initial-loading");Se&&!Se.textContent?.includes("taking longer")&&(Se.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Ie,Ae)};return window.setTimeout(Ie,ve),()=>{Q=!0}},[_,V]);const be=l.useCallback(async()=>{if(qm({isDesktopShell:$n(),isDesktopLocalOriginActive:Ti()})){await Ym();return}window.location.reload()},[]),Y=l.useCallback(async()=>{if(!D){N(!1),F(!0);try{await Vt.getState().initializeApp()}finally{F(!1)}Vt.getState().isInitialized||k(Q=>Q+1)}},[D]),we=Q=>{if(Q.screen==="recovery")return Q.variant};if(_&&y&&y.screen!=="main"){if(y.screen==="chooser")return s.jsx(cs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Qd,{mode:"first-launch",localAvailable:y.localAvailable!==!1,onCliAvailable:be,onChooseRemote:()=>{}})})})});const Q=we(y),pe=y.screen==="recovery"&&"url"in y?y.url:void 0;return s.jsx(cs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Qd,{mode:"recovery",recoveryVariant:Q,recoveryHostUrl:pe,recoveryHostLabel:void 0,localAvailable:y.localAvailable!==!1,onCliAvailable:be})})})})}if(z)return s.jsx(cs,{children:s.jsx(fc,{sdk:Xs.getSdkClient(),directory:h||"",children:s.jsx(mc,{apis:t,children:s.jsx(Oa,{delayDuration:300,skipDelayDuration:150,children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(mC,{embeddedSessionChat:z,isVSCodeRuntime:p,embeddedBackgroundWorkEnabled:G})})})})},C)});if(J)return s.jsx(cs,{children:s.jsx(lC,{})});if(j&&!n&&!p&&!z)return s.jsx(cs,{children:s.jsx(dC,{onRetry:()=>{Y()},isRetrying:D})});const me=!n&&!_;return s.jsx(cs,{children:s.jsx(fc,{sdk:Xs.getSdkClient(),directory:h||"",children:s.jsx(mc,{apis:t,children:s.jsx(kk,{children:s.jsx(Oa,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:_?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Fu,{embeddedBackgroundWorkEnabled:G}),s.jsx(Hu,{}),s.jsx(gk,{}),s.jsx(Bu,{}),!me&&s.jsxs(s.Fragment,{children:[s.jsx($g,{}),s.jsx(cC,{}),b&&s.jsx(Ak,{onClose:()=>S(!1)})]})]})})})})},C)})}function pC(t){return t.isAboutDialogOpen}function gC(t){return t.setAboutDialogOpen}function xC(t){return t.currentDirectory}function bC(t){return t.currentSessionId}function yC(t){return t.setCurrentSession}const vC=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();fg();Qm().then(()=>{Promise.all([Xm(),mg()]).catch(t=>{console.error("[main] settings init failed:",t)}),hg(),pg(),gg()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Jf=document.getElementById("root");if(!Jf)throw new Error("Root element not found");Dm.createRoot(Jf).render(s.jsx(Ge.StrictMode,{children:s.jsx(xg,{children:s.jsx(bg,{children:s.jsx(yg,{children:s.jsx(vg,{children:s.jsx(hC,{apis:vC})})})})})}));const VC=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{kb as W,WC as a,jb as b,Lb as d,gf as g,UC as h,VC as m,hb as u,pf as v};
|