@openchamber/web 1.21.0 → 1.22.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/bin/cli.test.js +35 -0
- package/bin/lib/DOCUMENTATION.md +12 -0
- package/bin/lib/cli-settings-accessors.js +111 -0
- package/bin/lib/cli-settings-accessors.test.js +189 -0
- package/bin/lib/cli-startup.js +29 -9
- package/bin/lib/commands-connect-url.js +12 -14
- package/dist/assets/{CodeMirrorCommentWidgets-C2BopIs3.js → CodeMirrorCommentWidgets-CPvfxh0N.js} +1 -1
- package/dist/assets/CommitSection-CC5mFzO2.js +1 -0
- package/dist/assets/DiffView-6xGdyI0n.js +4 -0
- package/dist/assets/FilesView-Bm3vT63N.js +17 -0
- package/dist/assets/GitView-B6y1Y69c.js +6 -0
- package/dist/assets/{JsonTreeView-osju7J70.js → JsonTreeView-rwHz84MX.js} +1 -1
- package/dist/assets/LinearIssuesView-B0UM_Rkx.js +1 -0
- package/dist/assets/MarkdownImageGallery-sGilV9Hs.js +1 -0
- package/dist/assets/MarkdownRendererImpl--4sRsKBn.js +12 -0
- package/dist/assets/OnboardingScreen-CECL_Cms.js +1 -0
- package/dist/assets/{PatchDiff-Dan3mADn.js → PatchDiff-BGPl1s-U.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CGoI2v0q.js → PierreDiffViewer-Cvz9Z-io.js} +2 -2
- package/dist/assets/PlanView-BFMsnHk3.js +5 -0
- package/dist/assets/SettingsView-_Gtn5SdT.js +28 -0
- package/dist/assets/{SettingsWindow-DXF-MTHG.js → SettingsWindow-C1Qa09YO.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DrCa1JRk.js → ToolOutputDialog-DzQlzMF4.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-B_tfvlNF.js → ToolPartDiffPreview-DfVOfwHy.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-CN_BctrR.js → VirtualizedFileDiff-DT5MDv-u.js} +1 -1
- package/dist/assets/WalkthroughView-D8sLH_M8.js +4 -0
- package/dist/assets/{computeVirtualFileMetrics-Gi1d5eU1.js → computeVirtualFileMetrics-DmpLWhll.js} +1 -1
- package/dist/assets/{contextPanelEmbeddedChat-CpzVNWAv.js → contextPanelEmbeddedChat-BK78t3M_.js} +1 -1
- package/dist/assets/de-C3luvSd_.js +9 -0
- package/dist/assets/es-CmU4HLv9.js +15 -0
- package/dist/assets/fr-Bgyni40l.js +13 -0
- package/dist/assets/index-C57jT0Sa.css +1 -0
- package/dist/assets/{index-Brm3X9rs.js → index-CWYs7sMK.js} +1 -1
- package/dist/assets/index-b0zDkWyg.js +7 -0
- package/dist/assets/{isDiffPlainText-pH9kAJQH.js → isDiffPlainText-BO_q5ezD.js} +1 -1
- package/dist/assets/{isFilePlainText-CVKy_dgB.js → isFilePlainText-D8qPqUAf.js} +1 -1
- package/dist/assets/ja-C1ImKinT.js +15 -0
- package/dist/assets/ko-CP7OdxYH.js +15 -0
- package/dist/assets/main-D4rd8Hy5.js +928 -0
- package/dist/assets/{main-vUCh0VB0.js → main-D7fwjW2z.js} +2 -2
- package/dist/assets/{markdown-shiki.worker-CKGJ1J33.js → markdown-shiki.worker-D5fBU-lw.js} +5 -5
- package/dist/assets/markdownCore-BcmkWZPO.js +3 -0
- package/dist/assets/{miniChat-BlzGEYgE.js → miniChat-D5rraz-g.js} +2 -2
- package/dist/assets/{mobile-CkX6H-IT.js → mobile-Cg_DE3KL.js} +2 -2
- package/dist/assets/{patchFileDiff-BCTsE43U.js → patchFileDiff-Bpql0QGw.js} +3 -3
- package/dist/assets/pl-DQYSiGYX.js +15 -0
- package/dist/assets/pt-BR-DytpsW4M.js +15 -0
- package/dist/assets/{renderElectronMiniChatApp-CJYe_KOL.js → renderElectronMiniChatApp-B_Bn7BbN.js} +2 -2
- package/dist/assets/renderMobileApp-DLfxMzGJ.js +25 -0
- package/dist/assets/runtimeEndpointReset-HlRmXFGW.js +16 -0
- package/dist/assets/scheduledTasksApi-BPvxrynl.js +1 -0
- package/dist/assets/{shikiHighlight-BgTPSITe.js → shikiHighlight-CFAVs_lu.js} +1 -1
- package/dist/assets/tr-aizaUvft.js +6 -0
- package/dist/assets/uk-DwnRxJZd.js +15 -0
- package/dist/assets/useAppFontEffects-DWXGRUPZ.js +7310 -0
- package/dist/assets/{useInlineCommentController-DFFv0hae.js → useInlineCommentController-Cc0OCXr0.js} +2 -2
- package/dist/assets/useRootScrollLock-BFZtfciC.js +1 -0
- package/dist/assets/{vendor-base-ui-_6j2xOWl.js → vendor-base-ui-BeMD8X_w.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DkQX2EBa.js → vendor-codemirror-language-data-BGFszm8n.js} +2 -2
- package/dist/assets/{vendor-floating-ui-core-CXmKXOXc.js → vendor-floating-ui-core-PuGzNPnN.js} +1 -1
- package/dist/assets/{vendor-floating-ui-dom-WyXykhNi.js → vendor-floating-ui-dom-BTvzWks8.js} +1 -1
- package/dist/assets/{vendor-floating-ui-react-dom-DKpLs02S.js → vendor-floating-ui-react-dom-DxYCWdHj.js} +1 -1
- package/dist/assets/{vendor-floating-ui-utils-BzXdqYpP.js → vendor-floating-ui-utils-D6FqdtJt.js} +1 -1
- package/dist/assets/vendor-linkify-it-DZCzzDkK.js +1 -0
- package/dist/assets/vendor-marked-linkify-it-CXI_LHIE.js +1 -0
- package/dist/assets/vendor-uc.micro-BAd0H0z4.js +1 -0
- package/dist/assets/{web-components-DLnGY4fs.js → web-components-CD-GFayc.js} +4 -4
- package/dist/assets/zh-CN-UDNMxm7r.js +15 -0
- package/dist/assets/zh-TW-BsswdYL-.js +15 -0
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/dist/site.webmanifest +1 -1
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/public/site.webmanifest +1 -1
- package/server/index.js +6 -2
- package/server/lib/cloudflare-tunnel.js +1 -1
- package/server/lib/dictation/DOCUMENTATION.md +19 -6
- package/server/lib/dictation/local/model-catalog.js +220 -0
- package/server/lib/dictation/local/model-catalog.test.js +42 -0
- package/server/lib/dictation/local/sherpa-tts.js +41 -20
- package/server/lib/dictation/local/worker-process.js +2 -0
- package/server/lib/dictation/runtime.js +4 -0
- package/server/lib/dictation/service.js +27 -4
- package/server/lib/fs/DOCUMENTATION.md +5 -0
- package/server/lib/fs/routes.js +150 -0
- package/server/lib/fs/routes.test.js +308 -3
- package/server/lib/git/DOCUMENTATION.md +4 -3
- package/server/lib/git/service.js +128 -6
- package/server/lib/git/service.test.js +191 -1
- package/server/lib/linear/DOCUMENTATION.md +97 -0
- package/server/lib/linear/OAUTH-BROKER-HANDOFF.md +91 -0
- package/server/lib/linear/auth.js +436 -0
- package/server/lib/linear/auth.test.js +242 -0
- package/server/lib/linear/client.js +191 -0
- package/server/lib/linear/index.js +61 -0
- package/server/lib/linear/issues.js +499 -0
- package/server/lib/linear/issues.test.js +512 -0
- package/server/lib/linear/mapping.js +188 -0
- package/server/lib/linear/mapping.test.js +147 -0
- package/server/lib/linear/oauth.js +345 -0
- package/server/lib/linear/oauth.test.js +166 -0
- package/server/lib/linear/parse.js +23 -0
- package/server/lib/linear/routes.js +432 -0
- package/server/lib/linear/routes.test.js +661 -0
- package/server/lib/linear/status-runtime.js +64 -0
- package/server/lib/linear/status-runtime.test.js +167 -0
- package/server/lib/linear/status.js +280 -0
- package/server/lib/linear/status.test.js +271 -0
- package/server/lib/linear/teams.js +72 -0
- package/server/lib/linear/teams.test.js +94 -0
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
- package/server/lib/markdown-image-grants/routes.js +3 -1
- package/server/lib/markdown-image-grants/routes.test.js +14 -0
- package/server/lib/openchamber-sessions/routes.js +4 -1
- package/server/lib/openchamber-sessions/routes.test.js +23 -0
- package/server/lib/opencode/env-runtime.js +17 -1
- package/server/lib/opencode/env-runtime.test.js +56 -0
- package/server/lib/opencode/feature-routes-runtime.js +2 -0
- package/server/lib/opencode/lifecycle.js +48 -9
- package/server/lib/opencode/lifecycle.test.js +125 -1
- package/server/lib/opencode/managed-process-registry.d.ts +13 -0
- package/server/lib/opencode/managed-process-registry.js +213 -163
- package/server/lib/opencode/managed-process-registry.test.mjs +285 -0
- package/server/lib/opencode/project-directory-runtime.js +16 -11
- package/server/lib/opencode/project-directory-runtime.test.js +32 -12
- package/server/lib/opencode/pwa-manifest-routes.js +1 -1
- package/server/lib/opencode/routes-upgrade.test.js +96 -12
- package/server/lib/opencode/routes.js +53 -5
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +10 -0
- package/server/lib/opencode/static-routes-runtime.js +3 -3
- package/server/lib/opencode/theme-runtime.js +1 -1
- package/server/lib/opencode/theme-runtime.test.js +129 -0
- package/server/lib/projects/project-config.js +33 -5
- package/server/lib/projects/project-config.test.js +85 -0
- package/server/lib/quota/DOCUMENTATION.md +19 -0
- package/server/lib/quota/providers/copilot.js +26 -10
- package/server/lib/quota/providers/copilot.test.js +78 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +7 -0
- package/server/lib/small-model/DOCUMENTATION.md +11 -5
- package/server/lib/small-model/call.js +64 -20
- package/server/lib/small-model/call.test.js +184 -2
- package/server/lib/tts/DOCUMENTATION.md +1 -0
- package/server/lib/tts/language-detect.js +210 -0
- package/server/lib/tts/language-detect.test.js +76 -0
- package/server/lib/tts/routes.js +23 -1
- package/server/lib/tts/routes.test.js +26 -0
- package/server/lib/tunnels/install-help.js +2 -2
- package/server/lib/tunnels/install-help.test.js +9 -0
- package/server/lib/walkthrough/languages.js +1 -0
- package/dist/assets/CommitSection-HJeMUAWb.js +0 -1
- package/dist/assets/DiffView-D5cvbEPb.js +0 -4
- package/dist/assets/FilesView-DPU8aNPL.js +0 -17
- package/dist/assets/GitView-Ct6xWrVH.js +0 -6
- package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +0 -1
- package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +0 -12
- package/dist/assets/OnboardingScreen-w2VG4fWY.js +0 -1
- package/dist/assets/PlanView-Dgg-WTEc.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +0 -1
- package/dist/assets/SettingsView-D9yRuFZw.js +0 -28
- package/dist/assets/WalkthroughView-D9Q4lr5x.js +0 -4
- package/dist/assets/de-B_LdJwEM.js +0 -9
- package/dist/assets/es-CubfsAYV.js +0 -15
- package/dist/assets/fr-5qJM0nFS.js +0 -13
- package/dist/assets/index-BW82eK5v.css +0 -1
- package/dist/assets/index-rlLjZUM5.js +0 -7
- package/dist/assets/ja-DJYIBUlH.js +0 -15
- package/dist/assets/ko-DcUBkB7y.js +0 -15
- package/dist/assets/main-DLBxKIoX.js +0 -926
- package/dist/assets/markdownCore-DG6GHLF4.js +0 -3
- package/dist/assets/pl-rB6BLcio.js +0 -15
- package/dist/assets/pt-BR-DcwtlO-o.js +0 -15
- package/dist/assets/renderMobileApp-hQJTnr8B.js +0 -25
- package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +0 -15
- package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +0 -1
- package/dist/assets/uk-INZlFD9A.js +0 -15
- package/dist/assets/useAppFontEffects-Cll4gnsh.js +0 -7268
- package/dist/assets/zh-CN-Dzda8xa1.js +0 -15
- package/dist/assets/zh-TW-Cwn3rNYZ.js +0 -15
|
@@ -1,926 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-D9Q4lr5x.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-Cll4gnsh.js","assets/index-rlLjZUM5.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-BLfBSgBh.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-BW82eK5v.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-_6j2xOWl.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-DKpLs02S.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-CpzVNWAv.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-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.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-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-DkQX2EBa.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-gg7YLRW7.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/PierreDiffViewer-CGoI2v0q.js","assets/web-components-DLnGY4fs.js","assets/computeVirtualFileMetrics-Gi1d5eU1.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-CN_BctrR.js","assets/isDiffPlainText-pH9kAJQH.js","assets/vendor-diff-C3JhlQdm.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-DFFv0hae.js","assets/runtimeEndpointReset-BDh7r8BL.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/patchFileDiff-BCTsE43U.js","assets/SessionSwitcherDropdown-CJTrc8K7.js","assets/scheduledTasksApi-CAGPh_gZ.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-D5cvbEPb.js","assets/FilesView-DPU8aNPL.js","assets/shikiHighlight-BgTPSITe.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-osju7J70.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-CVKy_dgB.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-C2BopIs3.js","assets/GitView-Ct6xWrVH.js","assets/CommitSection-HJeMUAWb.js","assets/PlanView-Dgg-WTEc.js","assets/SettingsWindow-DXF-MTHG.js","assets/SettingsView-D9yRuFZw.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/OnboardingScreen-w2VG4fWY.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as Je,R as c,j as s,r as ot,h as Mu}from"./vendor-react-BUCujlKS.js";import{z as cn,A as Oo,O as ka,D as Ou,B as Bu,C as yc,E as _u,F as bn,o as Bo,G as Fu,H as yt,I as sn,u as Ce,J as _o,K as wc,L as Sc,v as Fo,r as ss,m as Zt,M as Nn,N as Ir,e as Dn,P as Lu,a as ks,Q as $u,R as zu,S as Wu,T as vc,n as nn,w as Es,U as Vu,V as qi,W as Uu,X as jc,Y as Hu,Z as Zn,_ as Qi,d as vo,$ as vr,a0 as us,a1 as pi,a2 as Ku,a3 as Gu,i as qu,a4 as io,a5 as ao,a6 as Qu,a7 as Ca,a8 as Yu,a9 as Xu,aa as Ju,ab as Zu,ac as Na,ad as Aa,ae as Da,af as Pa,ag as ef,t as Ia,ah as tf,ai as sf,aj as nf,x as rf,y as of}from"./index-rlLjZUM5.js";import{_ as Gn}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as ft,h as Pe,aY as Wt,I as O,g as an,t as Re,aZ as Us,a_ as Rs,a$ as Hs,b0 as Ks,b1 as Hr,y as Qe,u as xs,A as Yi,C as kc,b2 as gi,b3 as af,b4 as Cc,b5 as Nc,r as Is,b6 as Ac,b7 as Xi,b8 as lf,b9 as cf,ba as df,bb as Dc,bc as uf,bd as Ji,be as ff,bf as mf,K as Pc,bg as hf,a5 as ht,a6 as pt,a4 as gt,bh as lo,l as Ht,V as xn,bi as pf,b as Vt,n as er,bj as Tn,aq as Hn,bk as Ic,bl as gf,bm as bf,bn as xf,bo as yf,p as wf,bp as Tc,bq as Sf,br as vf,bs as jf,bt as Ec,bu as Rc,bv as kf,ar as Zi,bw as Vn,bx as $r,by as Cf,bz as Ns,bA as As,bB as Gs,bC as Fs,bD as Ls,bE as gn,B as lt,al as Vs,G as Nf,L as qn,o as Lo,bF as Ta,bG as Af,bH as Df,bI as Ws,bJ as $o,bK as Mc,bL as bi,bM as Pf,bN as Ms,bO as Os,bP as Cs,bQ as Bs,bR as es,S as hn,bS as tr,bT as Ea,bU as nr,M as zo,a9 as zr,aa as ea,bV as Oc,ad as Pn,bW as Wo,bX as pn,$ as ta,bY as If,bZ as Tf,ak as Ef,b_ as Rf,b$ as Mf,c0 as Of,am as sa,c1 as na,c2 as Cr,c3 as Bc,c4 as Bf,c5 as _f,c6 as Wr,c7 as Ff,O as _c,c8 as Lf,c9 as Qn,ca as $f,cb as zf,cc as Yo,cd as Fc,ce as Lc,cf as Wf,cg as xi,ch as Vf,ci as Ra,cj as $c,ck as jr,c as dr,d as Vo,Y as ra,cl as zc,cm as pr,cn as kr,co as Uf,cp as Hf,cq as Wc,W as oa,an as Kf,cr as Gf,cs as qf,ct as Qf,cu as Yf,cv as Vc,cw as ln,cx as Xf,cy as Jf,cz as yi,cA as Zf,cB as em,cC as Uc,cD as tm,H as Hc,cE as Uo,cF as Kc,cG as Gc,cH as qc,Z as jo,cI as Ma,Q as ia,N as aa,R as la,a as ca,cJ as Oa,cK as wi,cL as Qc,cM as sm,cN as Yc,cO as nm,P as Si,cP as Ba,cQ as rm,cR as _a,cS as om,cT as fs,cU as im,cV as In,cW as da,cX as Xc,cY as am,cZ as Jc,c_ as lm,D as cm,c$ as dm,d0 as um,d1 as fm,d2 as Fa,d3 as mm,d4 as hm,d5 as Zc,E as pm,d6 as co,d7 as ed,d8 as gm,d9 as bm,da as xm,db as ym,e as td,dc as ua,dd as wm,de as Tr,df as Sm,dg as La,dh as vm,di as jm,dj as km,dk as Cm,dl as Nm,aD as vi,dm as sd,a0 as Am,a1 as Dm,aH as Pm,dn as Im,J as Tm,dp as Em,dq as Rm,dr as Mm,ds as nd,dt as rd,du as od,dv as Om,F as fa,dw as Bm,_ as _m,dx as Fm,dy as Lm,dz as $m,dA as zm,dB as Wm,dC as Vm,dD as Um,dE as Hm,dF as ko,ab as Km,ac as Gm,dG as qm,dH as $a,dI as Qm,dJ as Ym,dK as Xm,dL as Jm,dM as Co,dN as Zm,dO as za,dP as eh,dQ as th,dR as sh,dS as nh,dT as rh,dU as uo,dV as id,dW as oh,i as ih,dX as ah,dY as lh,dZ as ch,d_ as dh,a2 as uh,d$ as fh,e0 as mh,e1 as hh,e2 as ph,e3 as Wa,e4 as gh,ax as bh,ay as xh,az as yh,aB as Va,aC as Ua,aF as Ha,aE as ad,aG as ld,e5 as wh,aT as Sh,aU as vh,aV as jh,aW as kh,aX as Ch,aP as Nh,aQ as Ah,aR as Dh,aS as Ph}from"./useAppFontEffects-Cll4gnsh.js";import{u as cd,S as Ka,C as Ih,W as dd,f as Th}from"./SessionSwitcherDropdown-CJTrc8K7.js";import{U as ud,h as Ga,i as Yt,n as Eh,j as qa,t as un,k as Rh,l as Xo,m as Mh,o as Oh,p as ji,q as ki,b as fd,s as md,v as hd,w as Bh,x as pd,y as gd,z as bd,P as _h,T as Fh,A as Lh,B as $h,E as zh,S as Qa,u as Nr,N as Wh,D as Vh,W as Uh,L as Ya,F as Hh,d as Kh,f as xd,g as Gh,G as qh,H as Qh,c as Yh,e as Xh,O as yd,C as Jh}from"./runtimeEndpointReset-BDh7r8BL.js";import{u as Bn,n as Zh,f as ep,a as Xa,s as tp,d as sp,b as np,r as rp}from"./scheduledTasksApi-CAGPh_gZ.js";import{f as Er,h as An,T as wd,M as Sd,D as Rr,j as Mr,d as op,P as Ci,b as ip,k as Ni,i as ap}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Ho,S as No,h as lp,a as vd,v as Ai,s as cp}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Ko}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as jd,M as kd,C as Cd,a as Di,b as Pi,c as Ii,d as Nd,e as dp,f as up}from"./vendor-base-ui-_6j2xOWl.js";import{c as Yn,u as Kn,d as Ad,p as fp}from"./vendor-zustand-BAGL70zf.js";import{g as mp,b as hp,E as Dd,c as pp,d as gp,e as bp,f as xp,i as yp}from"./contextPanelEmbeddedChat-CpzVNWAv.js";import{a as ma,s as ur,r as Pd}from"./vendor-zod-BLfBSgBh.js";import{u as wp}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{d as Id}from"./vendor-cron-parser-CUcP7OfX.js";const Sp="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",vp="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",Jo=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?Sp:t.id==="terminal"?vp:void 0}),Ja=t=>{const e=Je.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.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||i;if(u&&!o){let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=()=>l(!0),e[2]=x):x=e[2];let b;return e[3]!==u?(b=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:x}),e[3]=u,e[4]=b):b=e[4],b}let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=Pe("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=f):f=e[5];let h;return e[6]!==d?(h=s.jsx("span",{className:f,children:d}),e[6]=d,e[7]=h):h=e[7],h},jp=t=>{const e=Je.c(75),{directory:n,className:r}=t,{t:i}=ft(),o=Bn(kp),l=Bn(Cp),a=Bn(Np),d=Bn(Ap),u=Bn(Dp),f=Bn(Pp),h=Bn(Ip);let x,b;e[0]!==u?(x=()=>{u()},b=[u],e[0]=u,e[1]=x,e[2]=b):(x=e[1],b=e[2]),c.useEffect(x,b);const w=cn()&&Oo();let S;e:{let F;e[3]!==l||e[4]!==o?(F=l.find(V=>V.id===o)??l.find(Tp)??l[0]??ka[0],e[3]=l,e[4]=o,e[5]=F):F=e[5];const Z=F;if(Z){let V;e[6]!==Z?(V=Jo(Z),e[6]=Z,e[7]=V):V=e[7],S=V;break e}let G;e[8]===Symbol.for("react.memo_cache_sentinel")?(G=Jo(ka[0]),e[8]=G):G=e[8],S=G}const g=S;if(!w||!n||l.length===0)return null;let m;e[9]!==n?(m=async F=>{await Bu(n,F.id,F.appName)||await yc(n,F.appName)},e[9]=n,e[10]=m):m=e[10];const p=m;let y;e[11]!==p||e[12]!==h?(y=async F=>{await h(F.id),await p(F)},e[11]=p,e[12]=h,e[13]=y):y=e[13];const v=y;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await an(n)).ok&&Re.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=N):N=e[16];const C=N;let k;e[17]!==r?(k=Pe("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 A;e[19]!==p||e[20]!==g?(A=()=>{p(g)},e[19]=p,e[20]=g,e[21]=A):A=e[21];const D=d&&"animate-pulse";let P;e[22]!==D?(P=Pe("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",D),e[22]=D,e[23]=P):P=e[23];let T;e[24]!==g.label||e[25]!==i?(T=i("openInApp.actions.openInAria",{app:g.label}),e[24]=g.label,e[25]=i,e[26]=T):T=e[26];let $;e[27]!==g.fallbackIconDataUrl||e[28]!==g.iconDataUrl||e[29]!==g.label?($=s.jsx(Ja,{label:g.label,iconDataUrl:g.iconDataUrl,fallbackIconDataUrl:g.fallbackIconDataUrl}),e[27]=g.fallbackIconDataUrl,e[28]=g.iconDataUrl,e[29]=g.label,e[30]=$):$=e[30];let E;e[31]!==P||e[32]!==T||e[33]!==$||e[34]!==A?(E=s.jsx("button",{type:"button",onClick:A,className:P,"aria-label":T,children:$}),e[31]=P,e[32]=T,e[33]=$,e[34]=A,e[35]=E):E=e[35];let U;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=Pe("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]=U):U=e[36];let I;e[37]!==i?(I=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=I):I=e[38];let B;e[39]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(O,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=B):B=e[39];let R;e[40]!==I?(R=s.jsx(Us,{asChild:!0,children:s.jsx("button",{type:"button",className:U,"aria-label":I,children:B})}),e[40]=I,e[41]=R):R=e[41];let j;e[42]!==C?(j=()=>{C()},e[42]=C,e[43]=j):j=e[43];let M;e[44]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(O,{name:"file-copy",className:"h-4 w-4"}),e[44]=M):M=e[44];let L;e[45]!==i?(L=i("openInApp.actions.copyPath"),e[45]=i,e[46]=L):L=e[46];let W;e[47]!==L?(W=s.jsx("span",{className:"typography-ui-label text-foreground",children:L}),e[47]=L,e[48]=W):W=e[48];let te;e[49]!==j||e[50]!==W?(te=s.jsxs(Wt,{className:"flex items-center gap-2",onClick:j,children:[M,W]}),e[49]=j,e[50]=W,e[51]=te):te=e[51];let Q;e[52]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(Rs,{}),e[52]=Q):Q=e[52];let me;if(e[53]!==l||e[54]!==v||e[55]!==g.id){let F;e[57]!==v||e[58]!==g.id?(F=Z=>{const G=Jo(Z);return s.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{v(Z)},children:[s.jsx(Ja,{label:Z.label,iconDataUrl:Z.iconDataUrl,fallbackIconDataUrl:G.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:Z.label}),g.id===Z.id?s.jsx(O,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},Z.id)},e[57]=v,e[58]=g.id,e[59]=F):F=e[59],me=l.map(F),e[53]=l,e[54]=v,e[55]=g.id,e[56]=me}else me=e[56];let ce;e[60]!==a||e[61]!==f||e[62]!==i?(ce=a?s.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{f(!0)},children:[s.jsx(O,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=f,e[62]=i,e[63]=ce):ce=e[63];let H;e[64]!==te||e[65]!==me||e[66]!==ce?(H=s.jsxs(Hs,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[te,Q,me,ce]}),e[64]=te,e[65]=me,e[66]=ce,e[67]=H):H=e[67];let ne;e[68]!==R||e[69]!==H?(ne=s.jsxs(Ks,{children:[R,H]}),e[68]=R,e[69]=H,e[70]=ne):ne=e[70];let ie;return e[71]!==E||e[72]!==ne||e[73]!==k?(ie=s.jsxs("div",{className:k,children:[E,ne]}),e[71]=E,e[72]=ne,e[73]=k,e[74]=ie):ie=e[74],ie};function kp(t){return t.selectedAppId}function Cp(t){return t.availableApps}function Np(t){return t.isCacheStale}function Ap(t){return t.isScanning}function Dp(t){return t.initialize}function Pp(t){return t.loadInstalledApps}function Ip(t){return t.selectApp}function Tp(t){return t.id===Ou}const Ep=({transform:t})=>({...t,y:0}),Rp={Item:Wt,Separator:Rs},Mp={Item:({className:t,...e})=>s.jsx(kd,{className:Pe(Nc,t),...e}),Separator:({className:t,...e})=>s.jsx(jd,{className:Pe(Cc,t),...e})},Op=t=>{const e=Je.c(62),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:f}=t,{t:h}=ft(),[x,b]=c.useState(!1),[w,S]=c.useState(!1),[g,m]=c.useState(!1);let p;e[0]!==n.id?(p={id:n.id},e[0]=n.id,e[1]=p):p=e[1];const{attributes:y,listeners:v,setNodeRef:N,transform:C,transition:k,isDragging:A}=Ho(p);let D;e[2]!==h||e[3]!==n.session.title?(D=n.session.title?.trim()||h("sessions.sidebar.session.untitled"),e[2]=h,e[3]=n.session.title,e[4]=D):D=e[4];const P=D,T=!i&&(x||w),$=Yi(n.id),E=$?.type==="busy"||$?.type==="retry",I=kc(n.id)>0&&!r&&!E,B=E||I;let R;e[5]!==E||e[6]!==h?(R=h(E?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[5]=E,e[6]=h,e[7]=R):R=e[7];const j=R;let M;e[8]!==d||e[9]!==r||e[10]!==o||e[11]!==n?(M=pe=>({session:n.session,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:pe}),e[8]=d,e[9]=r,e[10]=o,e[11]=n,e[12]=M):M=e[12];const L=M;let W;e[13]!==C?(W=Ko.Translate.toString(C),e[13]=C,e[14]=W):W=e[14];let te;e[15]!==W||e[16]!==k?(te={transform:W,transition:k},e[15]=W,e[16]=k,e[17]=te):te=e[17];const Q=A&&"z-10 opacity-60";let me;e[18]!==Q?(me=Pe("session-tab-slot flex h-7 w-44 shrink-0 touch-none",Q),e[18]=Q,e[19]=me):me=e[19];const ce=r?"true":"false";let H;e[20]!==r?(H=r?{"data-active-session-tab":!0}:{},e[20]=r,e[21]=H):H=e[21];let ne;e[22]!==u?(ne=pe=>u?.(pe),e[22]=u,e[23]=ne):ne=e[23];let ie;e[24]!==f||e[25]!==j||e[26]!==r||e[27]!==E||e[28]!==L||e[29]!==x||e[30]!==l||e[31]!==u||e[32]!==o||e[33]!==T||e[34]!==a||e[35]!==B||e[36]!==i||e[37]!==h||e[38]!==n||e[39]!==P?(ie=s.jsx(Cd,{render:pe=>s.jsxs("div",{...pe,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),o(n))},onAuxClick:be=>{be.button===1&&(be.preventDefault(),l(n.id))},"data-controls-open":T?"true":"false",className:Pe("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2","transition-colors duration-75",r?"bg-interactive-selection":Pe("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",T&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Pe("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",T&&"pr-10"),children:[s.jsx("div",{className:Pe("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?f:s.jsx("span",{className:"text-[13px] font-medium leading-4",children:P})}),B?s.jsx("span",{className:Pe("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",E?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",T&&"opacity-0"),"aria-label":j}):null]}),i?null:s.jsxs("div",{onClick:_p,onPointerDown:Fp,className:Pe("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",T&&"flex opacity-100"),children:[s.jsxs(Ks,{open:x,onOpenChange:be=>{b(be),be&&S(!0)},onOpenChangeComplete:be=>{be||S(!1),u?.(be)},children:[s.jsx(Us,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":h("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"more",className:"size-4"})})}),s.jsx(Hs,{align:"start",className:"min-w-[190px]",children:a(L(Rp))})]}),s.jsx("button",{type:"button","aria-label":h("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]})]})}),e[24]=f,e[25]=j,e[26]=r,e[27]=E,e[28]=L,e[29]=x,e[30]=l,e[31]=u,e[32]=o,e[33]=T,e[34]=a,e[35]=B,e[36]=i,e[37]=h,e[38]=n,e[39]=P,e[40]=ie):ie=e[40];let F,Z;e[41]===Symbol.for("react.memo_cache_sentinel")?(F={color:"var(--surface-elevated-foreground)"},Z=Pe(gi,"min-w-[190px]"),e[41]=F,e[42]=Z):(F=e[41],Z=e[42]);let G;e[43]!==L||e[44]!==a?(G=a(L(Mp)),e[43]=L,e[44]=a,e[45]=G):G=e[45];let V;e[46]!==G?(V=s.jsx(Di,{children:s.jsx(Pi,{className:"app-region-no-drag z-50",children:s.jsx(Ii,{"data-slot":"dropdown-menu-content",style:F,className:Z,children:G})})}),e[46]=G,e[47]=V):V=e[47];let Y;e[48]!==g||e[49]!==ne||e[50]!==ie||e[51]!==V?(Y=s.jsxs(Nd,{open:g,onOpenChange:m,onOpenChangeComplete:ne,children:[ie,V]}),e[48]=g,e[49]=ne,e[50]=ie,e[51]=V,e[52]=Y):Y=e[52];let le;return e[53]!==y||e[54]!==v||e[55]!==N||e[56]!==H||e[57]!==Y||e[58]!==te||e[59]!==me||e[60]!==ce?(le=s.jsx("div",{ref:N,style:te,className:me,"data-active":ce,...H,...y,...v,children:Y}),e[53]=y,e[54]=v,e[55]=N,e[56]=H,e[57]=Y,e[58]=te,e[59]=me,e[60]=ce,e[61]=le):le=e[61],le},Bp=t=>{const e=Je.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=ft(),d=Hr(Lp),u=Hr($p),f=Hr(zp),h=Hr(Wp),x=Qe(Vp),b=Qe(Up),w=xs(Hp);let S,g;e[0]!==x||e[1]!==u?(S=()=>{x&&u(x)},g=[x,u],e[0]=x,e[1]=u,e[2]=S,e[3]=g):(S=e[2],g=e[3]),c.useEffect(S,g);let m;if(e[4]!==w){m=new Map;for(const fe of w)m.set(fe.id,fe);e[4]=w,e[5]=m}else m=e[5];const p=m;let y;if(e[6]!==p||e[7]!==d){y=[];for(const fe of d){const xe=p.get(fe);xe&&y.push({id:fe,session:xe})}e[6]=p,e[7]=d,e[8]=y}else y=e[8];const v=y;let N;e[9]!==b?(N=fe=>{b(fe.id,Is(fe.session))},e[9]=b,e[10]=N):N=e[10];const C=N,k=Kp;let A;e[11]!==f||e[12]!==x||e[13]!==C||e[14]!==v?(A=fe=>{if(f(fe),x&&x!==fe){const xe=v.find(ge=>ge.id===fe);xe&&C(xe)}},e[11]=f,e[12]=x,e[13]=C,e[14]=v,e[15]=A):A=e[15];const D=A;let P;e[16]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{distance:8}},e[16]=P):P=e[16];let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T={activationConstraint:{delay:200,tolerance:6}},e[17]=T):T=e[17];const $=Er(An(Sd,P),An(wd,T));let E;e[18]!==h?(E=fe=>{const{active:xe,over:ge}=fe;ge&&xe.id!==ge.id&&h(String(xe.id),String(ge.id))},e[18]=h,e[19]=E):E=e[19];const U=E,I=c.useRef(null);let B;e[20]===Symbol.for("react.memo_cache_sentinel")?(B={left:!1,right:!1},e[20]=B):B=e[20];const[R,j]=c.useState(B);let M;e[21]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{const fe=I.current;if(!fe)return;const xe=fe.scrollLeft>2,ge=fe.scrollLeft+fe.clientWidth<fe.scrollWidth-2;j(re=>re.left===xe&&re.right===ge?re:{left:xe,right:ge})},e[21]=M):M=e[21];const L=M;let W;e[22]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{L();const fe=I.current;if(!fe||!globalThis.ResizeObserver)return;const xe=new ResizeObserver(L);return xe.observe(fe),()=>xe.disconnect()},e[22]=W):W=e[22];let te;e[23]!==v.length?(te=[L,v.length],e[23]=v.length,e[24]=te):te=e[24],c.useEffect(W,te);let Q;e[25]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>{I.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=Q):Q=e[25];let me;e[26]!==x?(me=[x],e[26]=x,e[27]=me):me=e[27],c.useEffect(Q,me);const ce=R.left&&R.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":R.left?"linear-gradient(to right, transparent, black 24px)":R.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let H;e[28]!==v?(H=v.map(Gp),e[28]=v,e[29]=H):H=e[29];const ne=H;let ie;e[30]!==x||e[31]!==v?(ie=!x||!v.some(fe=>fe.id===x),e[30]=x,e[31]=v,e[32]=ie):ie=e[32];const F=ie;let Z;e[33]!==a?(Z=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=Z):Z=e[34];let G;e[35]!==ce?(G=ce?{maskImage:ce,WebkitMaskImage:ce}:void 0,e[35]=ce,e[36]=G):G=e[36];let V;e[37]===Symbol.for("react.memo_cache_sentinel")?(V=[Ep],e[37]=V):V=e[37];let Y;e[38]!==o||e[39]!==x||e[40]!==D||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==v?(Y=v.map(fe=>s.jsx(Op,{tab:fe,isActive:fe.id===x,suppressControls:fe.id===x&&l,onSelect:C,onClose:k,renderMenu:n,closeOtherTabs:D,onMenuOpenChangeComplete:r,children:fe.id===x?o:null},fe.id)),e[38]=o,e[39]=x,e[40]=D,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=v,e[46]=Y):Y=e[46];let le;e[47]!==Y||e[48]!==ne?(le=s.jsx(No,{items:ne,strategy:lp,children:Y}),e[47]=Y,e[48]=ne,e[49]=le):le=e[49];let pe;e[50]!==U||e[51]!==$||e[52]!==le?(pe=s.jsx(Rr,{sensors:$,collisionDetection:Mr,modifiers:V,onDragEnd:U,children:le}),e[50]=U,e[51]=$,e[52]=le,e[53]=pe):pe=e[53];let be;e[54]!==o||e[55]!==F?(be=F?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=F,e[56]=be):be=e[56];let Se;e[57]!==G||e[58]!==pe||e[59]!==be?(Se=s.jsxs("div",{ref:I,onScroll:L,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:G,children:[pe,be]}),e[57]=G,e[58]=pe,e[59]=be,e[60]=Se):Se=e[60];let De;return e[61]!==Z||e[62]!==Se?(De=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Z,children:Se}),e[61]=Z,e[62]=Se,e[63]=De):De=e[63],De};function _p(t){return t.stopPropagation()}function Fp(t){return t.stopPropagation()}function Lp(t){return t.tabIds}function $p(t){return t.ensureTab}function zp(t){return t.closeOtherTabs}function Wp(t){return t.reorderTabs}function Vp(t){return t.currentSessionId}function Up(t){return t.setCurrentSession}function Hp(t){return t.activeSessions}function Kp(t){af(t)}function Gp(t){return t.id}function qp(t){if(typeof t!="number"||!Number.isFinite(t))return"";const e=new Date(t);if(Number.isNaN(e.getTime()))return"";const n=e.toLocaleString(Xi(),{month:"short"}),r=e.getDate(),i=e.getFullYear(),o=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0");return`${n} ${r}, ${i}, ${o}:${l}`}function Qp(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 Yp(t){const e=t.info.role==="user"?"User":"Assistant",n=qp(t.info.time?.created),r=Qp(t),i=n&&r?`${n} (${r})`:n||r;return i?`**${e}**
|
|
3
|
-
|
|
4
|
-
*${i}*`:`**${e}**`}function Xp(t){return t.filter(e=>e.type==="text"&&typeof e.text=="string").map(e=>e.text).join("")}function Td(t){const e=Yp(t),n=Xp(t.parts).trim();return n?`${e}
|
|
5
|
-
|
|
6
|
-
${n}`:""}function Ed(t,e){const n="#".repeat(Math.min(e+1,6)),r=t.agent?` — ${t.agent}`:"",i=`${n} Sub-agent: ${t.title}${r}
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
`,o=t.records.map(Td).filter(Boolean).join(`
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
`),l=[i+o];for(const a of t.children)l.push(Ed(a,e+1));return l.join(`
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
`)}function Rd(t,e,n){const r=e?.trim()||"Session",i=new Date().toISOString().split("T")[0],o=`# ${r}
|
|
19
|
-
|
|
20
|
-
*Exported on ${i}*
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
`,l=t.map(Td).filter(Boolean).join(`
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
`);let a=o+l;if(n&&n.length>0){const d=n.map(u=>Ed(u,1)).join(`
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
`);a+=`
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
`+d}return a}function Md(t,e){const n=new Blob([t],{type:"text/markdown;charset=utf-8"}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function Od(t,e){const n=await _u(e,t);if(n)return n;if(!bn())return null;try{const r=await Bo()?.vscode?.saveMarkdown?.({fileName:e,content:t});if(!r||r.saved!==!0)return null;const i=typeof r.path=="string"?r.path.trim():"";return i.length>0?i:null}catch{return null}}async function Jp(t){const e=Bo()?.files;if(e?.revealPath)try{return!!(await e.revealPath(t))?.success}catch{return!1}return await Fu(t)?!0:yc(t)}function Zp(){return Ac()}function Bd(t){const r=(t?.trim()||"session").normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,60)||"session",i=new Date().toISOString().split("T")[0];return`${r}-${i}.md`}const ha=Yn(()=>({pendingSessionIds:new Set})),_d=t=>{const e=Je.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],ha(n)},Za=(t,e)=>{ha.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}})},eg=async(t,e)=>{try{const d=(await mf(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=yt(t),r=yt(e)??e,i=Qe.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>yt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},el=(t,e)=>{const n=ff(e);if(!n)throw new Error("Session status is unavailable");const r=n.session_status;if(t.some(o=>{const l=r[o.id]?.type;return l==="busy"||l==="retry"}))throw new Error("Session is not idle")},tg=async(t,e,n,r,i)=>{const o=[];for(const l of[...t].reverse())try{await Dc(l,r,n,l.id===e),Qe.getState().setWorktreeMetadata(l.id,i.get(l.id)??null)}catch(a){o.push(a)}return o},sg=async(t,e,n)=>{try{await Pc(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},ng=async t=>{if(ha.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Za(t.root.id,!0);try{const e=lf(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,Qe.getState().getWorktreeMetadata(a.id)]));el(n,t.sourceDirectory);const i=await eg(t.sourceDirectory,e.path),o=await cf(e,{startRef:i}),l=[];try{await df(o.path),el(n,t.sourceDirectory);for(const[a,d]of n.entries())await Dc(d,t.sourceDirectory,o.path,a===0),l.push(d),Qe.getState().setWorktreeMetadata(d.id,uf(o))}catch(a){if((await tg(l,t.root.id,t.sourceDirectory,o.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 sg(e,o,a)}try{await Ji([t.sourceDirectory,o.path])}catch(a){console.warn("[session-worktree-move] Failed to refresh moved sessions",a)}return o.path}finally{Za(t.root.id,!1)}},Fd=t=>{ng(t).then(()=>Re.success(t.successMessage)).catch(e=>Re.error(t.failureMessage,{description:e instanceof Error?e.message:String(e)}))},Or="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",rg=c.memo(function(e){const n=Je.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:f}=e,h=r===void 0?!0:r,x=f===void 0?!1:f;if(!h)return null;const b=a??Or,w=x&&"bg-interactive-selection text-interactive-selection-foreground";let S;n[0]!==b||n[1]!==w?(S=Pe(b,w),n[0]=b,n[1]=w,n[2]=S):S=n[2];const g=u??"h-[18px] w-[18px]";let m;n[3]!==d||n[4]!==g?(m=s.jsx(O,{name:d,className:g}),n[3]=d,n[4]=g,n[5]=m):m=n[5];let p;n[6]!==o||n[7]!==l||n[8]!==x||n[9]!==S||n[10]!==m?(p=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":x,className:S,children:m})}),n[6]=o,n[7]=l,n[8]=x,n[9]=S,n[10]=m,n[11]=p):p=n[11];let y;n[12]!==i?(y=s.jsx(pt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=y):y=n[13];let v;return n[14]!==p||n[15]!==y?(v=s.jsxs(gt,{children:[p,y]}),n[14]=p,n[15]=y,n[16]=v):v=n[16],v}),og=c.memo(function(e){const n=Je.c(42),{isMobile:r,githubAuthStatus:i,githubAccounts:o,githubAvatarUrl:l,githubLogin:a,isSwitchingGitHubAccount:d,handleGitHubAccountSwitch:u}=e,{t:f}=ft();if(!i?.connected||r)return null;if(o.length>1){let w;n[0]===Symbol.for("react.memo_cache_sentinel")?(w=Pe(Or,"h-7 w-7 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0"),n[0]=w):w=n[0];let S;n[1]!==a||n[2]!==f?(S=a?f("header.github.connectedWithLogin",{login:a}):f("header.github.connected"),n[1]=a,n[2]=f,n[3]=S):S=n[3];let g;n[4]!==l||n[5]!==a||n[6]!==f?(g=l?s.jsx("img",{src:l,alt:a?f("header.github.avatarWithLogin",{login:a}):f("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(O,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"}),n[4]=l,n[5]=a,n[6]=f,n[7]=g):g=n[7];let m;n[8]!==d||n[9]!==S||n[10]!==g?(m=s.jsx(Us,{asChild:!0,children:s.jsx("button",{type:"button",className:w,title:S,disabled:d,children:g})}),n[8]=d,n[9]=S,n[10]=g,n[11]=m):m=n[11];let p;n[12]!==f?(p=f("header.github.accountsTitle"),n[12]=f,n[13]=p):p=n[13];let y;n[14]!==p?(y=s.jsx(lo,{className:"typography-ui-header font-semibold text-foreground",children:p}),n[14]=p,n[15]=y):y=n[15];let v;n[16]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(Rs,{}),n[16]=v):v=n[16];let N;if(n[17]!==o||n[18]!==u||n[19]!==d||n[20]!==f){let A;n[22]!==u||n[23]!==d||n[24]!==f?(A=D=>{const P=D.user,T=!!D.current,$=D.source==="gh-cli"?f("header.github.accountSource.cli"):f("header.github.accountSource.oauth");return s.jsxs(Wt,{className:"gap-2",disabled:d,onSelect:()=>{T||u(D.id)},children:[P?.avatarUrl?s.jsx("img",{src:P.avatarUrl,alt:P.login?f("header.github.avatarWithLogin",{login:P.login}):f("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(O,{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:P?.name?.trim()||P?.login||"GitHub"}),P?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:P.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:$})]}):null]}),T?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},D.id)},n[22]=u,n[23]=d,n[24]=f,n[25]=A):A=n[25],N=o.map(A),n[17]=o,n[18]=u,n[19]=d,n[20]=f,n[21]=N}else N=n[21];let C;n[26]!==y||n[27]!==N?(C=s.jsxs(Hs,{align:"end",className:"w-64",children:[y,v,N]}),n[26]=y,n[27]=N,n[28]=C):C=n[28];let k;return n[29]!==m||n[30]!==C?(k=s.jsxs(Ks,{children:[m,C]}),n[29]=m,n[30]=C,n[31]=k):k=n[31],k}let h;n[32]!==a||n[33]!==f?(h=a?f("header.github.connectedWithLogin",{login:a}):f("header.github.connected"),n[32]=a,n[33]=f,n[34]=h):h=n[34];let x;n[35]!==l||n[36]!==a||n[37]!==f?(x=l?s.jsx("img",{src:l,alt:a?f("header.github.avatarWithLogin",{login:a}):f("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(O,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"}),n[35]=l,n[36]=a,n[37]=f,n[38]=x):x=n[38];let b;return n[39]!==h||n[40]!==x?(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:h,children:x}),n[39]=h,n[40]=x,n[41]=b):b=n[41],b}),ig=c.memo(function(e){const n=Je.c(43),{isDesktopApp:r,currentInstanceLabel:i,compactCurrentInstanceLabel:o,currentInstanceIsLocal:l,isDesktopServicesOpen:a,setIsDesktopServicesOpen:d,refreshCurrentInstanceLabel:u,shortcutLabel:f,remoteUpdateInfo:h,remoteUpdateChecking:x,remoteUpdateError:b,onOpenRemoteUpdate:w}=e,{t:S}=ft();let g;n[0]!==u||n[1]!==d?(g=E=>{d(E),E&&u()},n[0]=u,n[1]=d,n[2]=g):g=n[2];let m;n[3]!==i||n[4]!==r||n[5]!==S?(m=r?S("header.services.openWithCurrent",{current:i}):S("header.services.open"),n[3]=i,n[4]=r,n[5]=S,n[6]=m):m=n[6];const p=r?"w-auto max-w-[14rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let y;n[7]!==p?(y=Pe(Or,p),n[7]=p,n[8]=y):y=n[8];let v;n[9]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(O,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=v):v=n[9];let N;n[10]!==o||n[11]!==r?(N=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:o}):null,n[10]=o,n[11]=r,n[12]=N):N=n[12];let C;n[13]!==m||n[14]!==y||n[15]!==N?(C=s.jsx(ht,{asChild:!0,children:s.jsx(Us,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":m,className:y,children:[v,N]})})}),n[13]=m,n[14]=y,n[15]=N,n[16]=C):C=n[16];let k;n[17]!==i||n[18]!==f||n[19]!==S?(k=S("header.services.tooltip.currentInstance",{current:i,toggle:f("toggle_services_menu")}),n[17]=i,n[18]=f,n[19]=S,n[20]=k):k=n[20];let A;n[21]!==k?(A=s.jsx(pt,{children:s.jsx("p",{children:k})}),n[21]=k,n[22]=A):A=n[22];let D;n[23]!==C||n[24]!==A?(D=s.jsxs(gt,{children:[C,A]}),n[23]=C,n[24]=A,n[25]=D):D=n[25];let P;n[26]!==l||n[27]!==r||n[28]!==a||n[29]!==w||n[30]!==x||n[31]!==b||n[32]!==h||n[33]!==d||n[34]!==S?(P=r?s.jsxs("div",{children:[l?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:S("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?S("header.services.remoteUpdate.available",{version:h.version||""}):x?S("header.services.remoteUpdate.checking"):b||S("header.services.remoteUpdate.upToDate")})]}),h?.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:w,children:S("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(hf,{embedded:!0,open:a,onOpenChange:dg,onHostSwitched:()=>d(!1)})]}):null,n[26]=l,n[27]=r,n[28]=a,n[29]=w,n[30]=x,n[31]=b,n[32]=h,n[33]=d,n[34]=S,n[35]=P):P=n[35];let T;n[36]!==P?(T=s.jsx(Hs,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:P}),n[36]=P,n[37]=T):T=n[37];let $;return n[38]!==a||n[39]!==g||n[40]!==D||n[41]!==T?($=s.jsxs(Ks,{open:a,onOpenChange:g,children:[D,T]}),n[38]=a,n[39]=g,n[40]=D,n[41]=T,n[42]=$):$=n[42],$}),ag=(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??""),lg=t=>{const e=t.trim();if(!e)return"";const n=e.split(/\s+/).filter(Boolean);if(n.length>=2){const r=n[0],i=n[1].slice(0,3),o=`${r} ${i}`.trim();return n.length>2||o.length<e.length?`${o}...`:o}return e.length>12?`${e.slice(0,9).trimEnd()}...`:e},fn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},tl=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,cg=()=>{sn("ui.header.render");const{t}=ft(),e=Ce(q=>q.isSidebarOpen),n=Ce(q=>q.openContextOverview),r=Ce(q=>q.closeContextPanel),i=Ce(q=>q.shortcutOverrides),o=Ce(q=>q.sessionTabsEnabled),l=Ht(q=>q.getCurrentModel),a=xn(),d=Qe(q=>q.getContextUsage),u=Qe(q=>!!q.newSessionDraft?.open),f=Qe(q=>q.currentSessionId),h=pf(f??""),x=Yi(f??""),b=_d(f??""),w=xs(Kn(c.useCallback(q=>{if(!f)return null;const Ue=[...q.activeSessions,...q.archivedSessions].find(Pt=>Pt.id===f);if(!Ue)return null;const it=Ue;return{title:Ue.title??null,directory:it.directory??null,created:Ue.time?.created??null,slug:it.slug??null,shareUrl:Ue.share?.url??null,parentId:Ue.parentID??null}},[f]))),S=Vt(Kn(q=>{if(!q.activeProjectId)return null;const Ue=q.projects.find(it=>it.id===q.activeProjectId);return Ue?{id:Ue.id,path:Ue.path,label:Ue.label}:null})),g=c.useMemo(()=>{if(!S)return null;const q=S.label?.trim();if(q)return q;const Ue=S.path.split(/[\\/]/).filter(Boolean);return Ue[Ue.length-1]??null},[S]),m=er(q=>q.loadSettings),{isMobile:p}=Tn(),y=Hn(q=>q.status),v=Hn(q=>q.setStatus),N=c.useRef(null),[C,k]=c.useState(()=>typeof window>"u"?!1:cn()),A=c.useMemo(()=>_o(),[]),D=Ic(),[P,T]=c.useState(!1),$=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:E,side:U}=cd(),I=c.useMemo(()=>{if(typeof window>"u")return null;const q=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof q=="number"&&Number.isFinite(q)&&q>0)return q;if(typeof navigator>"u")return null;const Ue=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Ue)return null;const it=Number.parseInt(Ue[1],10),Pt=Number.parseInt(Ue[2],10);return Number.isNaN(it)?null:it===10?Pt:it},[]);ot.useEffect(()=>{typeof window>"u"||k(cn())},[]);const B=l(),R=B&&typeof B.limit=="object"&&B.limit!==null?B.limit:null,j=R&&typeof R.context=="number"?R.context:0,M=R&&typeof R.output=="number"?R.output:0,L=d(j,M),[W,te]=c.useState(null),Q=!f||h;ot.useEffect(()=>{if(!f){te(q=>q===null?q:null);return}if(L&&L.totalTokens>0){te(q=>ag(q,L)?q:L);return}Q&&te(q=>q===null?q:null)},[L,f,Q]);const me=y?.connected?y.user?.avatarUrl??null:null,ce=y?.connected?y.user?.login??null:null,H=y?.accounts??[],[ne,ie]=c.useState(!1),[F,Z]=c.useState(!1),[G,V]=c.useState("Local"),[Y,le]=c.useState(!0),[pe,be]=c.useState(!1),[Se,De]=c.useState(null),[fe,xe]=c.useState(!1),[ge,re]=c.useState(null),he=c.useMemo(()=>lg(G),[G]),Ne=c.useMemo(()=>bn(),[]),de=Ce(q=>q.workStatusPanelVisible),oe=Ce(q=>q.workStatusPanelEnabled),K=Ce(q=>q.setWorkStatusPanelEnabled),z=Ce(q=>q.workStatusPanelFits),ae=Ce(q=>q.workStatusOverlayOpen),ve=Ce(q=>q.setWorkStatusOverlayOpen),We=oe&&z||ae,Be=c.useCallback(()=>{if(oe&&!z){ve(!ae);return}K(!oe)},[ve,K,ae,oe,z]),Ae=!Ne&&!de&&!!W&&W.totalTokens>0,X=W&&W.contextLimit>0?Math.min(999,W.totalTokens/W.contextLimit*100):0,Oe=c.useCallback(async()=>{if(!(typeof window>"u"||!C))try{if(Oo()){V("Local"),le(!0);return}le(!1);const q=await wc(),Ue=gf(),it=bf([xf(Ue),...q.hosts]);if(it.id===yf){V("Local"),le(!0);return}V(Sc(it.label.trim()||"Instance"))}catch{V("Local"),le(!0)}},[C]);ot.useEffect(()=>(Oe(),Fo(()=>{Oe()})),[Oe]);const Fe=c.useCallback(async()=>{if(Y){De(null),re(null);return}xe(!0),re(null);try{const q=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Ue=await ss(`/api/openchamber/update-check?${q.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Ue.ok)throw new Error(`Server responded with ${Ue.status}`);const it=await Ue.json();De({available:it.available??!1,version:it.version,currentVersion:it.currentVersion??"unknown",body:it.body,nextSuggestedCheckInSec:typeof it.nextSuggestedCheckInSec=="number"?it.nextSuggestedCheckInSec:void 0,packageManager:it.packageManager,updateCommand:it.updateCommand})}catch(q){De(null),re(q instanceof Error?q.message:t("header.services.remoteUpdate.error"))}finally{xe(!1)}},[Y,t]);c.useEffect(()=>{De(null),re(null),be(!1)},[Y,G]),c.useEffect(()=>{if(!C||Y)return;const q=3e3,Ue=3600*1e3;let it=!1,Pt=null;const Kt=Gt=>{Pt=window.setTimeout(()=>{if(it||typeof document<"u"&&document.visibilityState!=="visible"){Kt(Ue);return}Fe().finally(()=>{it||Kt(Ue)})},Gt)};return Kt(q),()=>{it=!0,Pt!==null&&window.clearTimeout(Pt)}},[Fe,Y,G,C]);const _=c.useCallback(()=>{if(Se?.available){be(!0);return}Fe()},[Fe,Se?.available]);wf(),c.useEffect(()=>{m()},[m]);const ue=f?w??null:null,ke=c.useRef(null),[je,Ke]=c.useState(0);c.useEffect(()=>{if(!f){ke.current&&(ke.current=null,Ke(Pt=>Pt+1));return}if(ue){ke.current={sessionId:f,session:ue,expiresAt:Date.now()+2e3};return}const q=ke.current;if(!q||q.sessionId!==f)return;const Ue=q.expiresAt-Date.now();if(Ue<=0){ke.current=null,Ke(Pt=>Pt+1);return}const it=window.setTimeout(()=>{ke.current?.sessionId===f&&(ke.current=null),Ke(Pt=>Pt+1)},Ue);return()=>{window.clearTimeout(it)}},[f,ue]);const se=(()=>{if(ue)return ue;if(!f)return null;const q=ke.current;return q&&q.sessionId===f&&q.expiresAt>Date.now()?q.session:null})(),Ie=Qe(q=>f?q.worktreeMetadata.get(f)?.path??"":""),Ye=Qe(q=>f?q.worktreeMetadata.get(f)?.branch?.trim()??null:null),ee=Tc(q=>f?q.getAttachment(f):void 0),Ee=c.useMemo(()=>ee?Sf(ee,{pending:t("gitView.empty.worktreeSetupInProgress")}):null,[t,ee]),Ge=c.useMemo(()=>ee?ee.legacy?"legacy":ee.degraded?"degraded":ee.worktreeStatus==="pending"?"pending":ee.worktreeStatus==="missing"?"missing":ee.worktreeStatus==="invalid"?"invalid":ee.attentionReason?"attention":null:null,[ee]),ze=c.useMemo(()=>fn(Ie||""),[Ie]),$e=c.useMemo(()=>{const q=typeof se?.directory=="string"?se.directory:"";return fn(q||"")},[se?.directory]),_e=Qe(q=>q.newSessionDraft?.open?fn(q.newSessionDraft.bootstrapPendingDirectory??q.newSessionDraft.directoryOverride??""):""),Xe=Qe(q=>q.newSessionDraft.target),ct=Qe(q=>q.newSessionDraft.selectedProjectId),Nt=Qe(q=>q.currentSessionDirectory),At=Zt(q=>q.homeDirectory),Le=c.useMemo(()=>ze||$e||_e,[_e,$e,ze]),_t=Ce(c.useCallback(q=>{const Ue=fn(Le||"");return Ue?tl(q.contextPanelByDirectory[Ue]):null},[Le])),mt=Qe(q=>{const Ue=fn(ze||$e||"");if(!Ue)return null;for(const it of q.availableWorktreesByProject.values()){const Kt=it.find(Gt=>fn(Gt.path)===Ue)?.branch?.trim();if(Kt)return Kt}return null}),Dt=vf(Le||null)||Ye||mt,xt=u?Xe==="chat":jf($e||Nt,At),we=!xt&&!de&&!!(g||Dt||!u&&Ge),dt=c.useMemo(()=>{if(!f)return g??"OpenChamber";const q=se?.title?.trim();return q&&q.length>0?q:"Untitled Session"},[g,se?.title,f]),et=Ec(Le||void 0,{bootstrap:!1}),qe=Rc(),kt=Qe(q=>q.updateSessionTitle),wt=Qe(q=>q.shareSession),jt=Qe(q=>q.unshareSession),Ut=Qe(q=>q.archiveSessions),st=Qe(q=>q.deleteSessions),[rt,Ct]=c.useState(!1),[It,Bt]=c.useState(!1),Tt=c.useRef(null),[ns,Lt]=c.useState(""),[zt,qt]=c.useState(null),ms=c.useRef(null),Qt=c.useCallback(()=>{f&&(Lt(se?.title?.trim()||dt),Ct(!0))},[se?.title,f,dt]),Me=c.useRef(Qt);Me.current=Qt,c.useEffect(()=>{if(Bt(!1),qt(null),f&&Tt.current===f){Tt.current=null,Me.current();return}Ct(!1),Lt("")},[f]);const Ve=c.useCallback(async()=>{if(!f)return;const q=ns.trim();q&&q!==se?.title?.trim()&&await kt(f,q),Ct(!1)},[se?.title,f,ns,kt]);c.useEffect(()=>{if(!rt)return;const q=Ue=>{const it=Ue.target;(!it||!ms.current?.contains(it))&&Ve()};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[rt,Ve]);const Ze=c.useCallback(q=>{q&&an(q).then(Ue=>{Re[Ue.ok?"success":"error"](t(Ue.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Re.error(t("sessions.sidebar.session.copyId.error")))},[t]),at=c.useCallback(async q=>{if(!q)return;const Ue=await wt(q);if(Ue?.share?.url){const it=await an(Ue.share.url);Re[it.ok?"success":"warning"](t("sessions.sidebar.session.share.successTitle"),{description:t(it.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}Re.error(t("sessions.sidebar.session.share.error"))},[wt,t]),ut=c.useCallback(q=>{q&&an(q).then(Ue=>{Re[Ue.ok?"success":"error"](t(Ue.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>Re.error(t("sessions.sidebar.session.share.copyUrlError")))},[t]),St=c.useCallback(async q=>{if(!q)return;const Ue=await jt(q);Re[Ue?"success":"error"](t(Ue?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[t,jt]),nt=c.useCallback(async()=>{if(!f||!Le){Re.error(t("sessions.sidebar.session.export.nothingToExport"));return}try{await qe.loadCompleteHistory(f,Le)}catch{Re.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}const q=kf(et.getState(),f).list;if(q.length===0){Re.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Ue=Rd(q,se?.title??null),it=Bd(se?.title??null);await Od(Ue,it)||Md(Ue,it),Re.success(t("sessions.sidebar.session.export.success"))},[se?.title,f,et,Le,qe,t]),Ft=x?.type==="busy"||x?.type==="retry",Xt=c.useCallback(()=>{if(!f||!$e||Ft||b)return;const q=xs.getState().activeSessions,Ue=q.find(Kt=>Kt.id===f);if(!Ue)return;const it=[],Pt=[f];for(let Kt=0;Kt<Pt.length;Kt+=1){const Gt=Pt[Kt];for(const cs of q)cs.parentID===Gt&&(it.push(cs),Pt.push(cs.id))}Fd({root:Ue,descendants:it,sourceDirectory:$e,successMessage:t("sessions.sidebar.session.moveToWorktree.success"),failureMessage:t("sessions.sidebar.session.moveToWorktree.failed")})},[f,Ft,b,$e,t]),os=c.useCallback(async()=>{if(!zt)return;const q=xs.getState().activeSessions,Ue=[zt.sessionId];for(let Gt=0;Gt<Ue.length;Gt+=1){const cs=Ue[Gt];for(const vs of q)vs.parentID===cs&&!Ue.includes(vs.id)&&Ue.push(vs.id)}const it=zt.action;if(qt(null),(it==="archive"?await Ut(Ue):await st(Ue)).failedIds.length>0){Re.error(t(it==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Re.success(t(it==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[Ut,st,zt,t]),Ss=Ce(q=>q.isScheduledTasksDialogOpen),qs=Ce(q=>q.isArchivePageOpen),gs=Ce(q=>q.worktreesPageProjectId),is=Ce(q=>q.isMultiRunLauncherOpen),Mt=Vt(q=>{if(!gs)return null;const Ue=q.projects.find(it=>it.id===gs);return Ue?.label?.trim()||Ue?.path?.split("/").pop()||null}),Et=c.useMemo(()=>Ss?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:qs?{title:t("sessions.archivePage.title"),subtitle:null}:gs?{title:t("sessions.worktreesPage.title",{project:Mt??""}),subtitle:null}:is?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[qs,is,Ss,t,gs,Mt]),Jt=c.useMemo(()=>fn(Le||S?.path||""),[S?.path,Le]),hs=c.useMemo(()=>S?{id:S.id,path:S.path}:null,[S]),as=c.useRef(null);c.useEffect(()=>{!hs||!Jt||(as.current={projectRef:hs,directory:Jt})},[Jt,hs]);const ps=Zi(q=>q.planModeEnabled),ys=Qe(q=>q.isSessionPlanAvailable),rs=ps&&f?ys(f):!1,yn=c.useRef("");c.useEffect(()=>{if(!ps||!f)return;const q=`${f||"none"}:${$e||"none"}:${se?.created||0}:${se?.slug||"none"}`;yn.current!==q&&(yn.current=q)},[ps,rs,se?.slug,se?.created,f,$e]);const En=c.useCallback(async q=>{if(!(!q||ne)){ie(!0);try{const Ue=a.github?await a.github.authActivate(q):await(async()=>{const it=await ss("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:q})}),Pt=await it.json().catch(()=>null);if(!it.ok||!Pt)throw new Error(Pt?.error||it.statusText);return Pt})();v(Ue)}catch(Ue){console.error("Failed to switch GitHub account:",Ue)}finally{ie(!1)}}},[ne,a.github,v]),Rn=c.useCallback(()=>{Nn("desktop_open_draft_mini_chat_window",{directory:xt?"":_e,projectId:xt?null:ct,apiBaseUrl:Dn(),clientToken:Ir()}).catch(q=>{console.warn("[header] failed to open draft mini chat window",q)})},[_e,ct,xt]),Mn=c.useCallback(()=>{if(u){Rn();return}f&&Nn("desktop_open_session_mini_chat_window",{sessionId:f,directory:$e||fn(Nt||"")||ze,apiBaseUrl:Dn(),clientToken:Ir()}).catch(q=>{console.warn("[header] failed to open session mini chat window",q)})},[f,Rn,u,Nt,$e,ze]),J=c.useCallback(()=>{const q=fn(Le||"");if(!q)return;const Ue=Ce.getState().contextPanelByDirectory[q];if(tl(Ue)==="context"){r(q);return}n(q)},[r,n,Le]),He=_t==="context",tt=Or,bt=c.useMemo(()=>C&&$&&!P?"5.5rem":D?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!C||E)&&!Ne?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[C,P,$,D,Ne,E]);ot.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",bt)},[bt]);const $t=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Ot=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ot.useEffect(()=>{if(!C||!$){T(!1);return}let q=!1;const Ue=async()=>{try{const Pt=await Nn("desktop_is_window_fullscreen");q||T(Pt===!0)}catch{q||T(!1)}},it=()=>{Ue()};return Ue(),window.addEventListener("openchamber:window-resized",it),()=>{q=!0,window.removeEventListener("openchamber:window-resized",it)}},[C,$]);const vt=c.useMemo(()=>!C||!$||I===null?"":I>=26?"h-12":I<=15?"h-14":"",[C,$,I]),ls=c.useMemo(()=>{if(!(C&&!E||Ne))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))"}},[C,Ne,E]),bs=c.useCallback(()=>{if(typeof document>"u")return;const q=N.current?.getBoundingClientRect().height;q&&document.documentElement.style.setProperty("--oc-header-height",`${q}px`)},[]);ot.useEffect(()=>{if(typeof window>"u")return;bs();const q=N.current;if(!q||typeof ResizeObserver>"u")return()=>{};let Ue=0;const it=()=>{Ue||(Ue=requestAnimationFrame(()=>{Ue=0,bs()}))},Pt=new ResizeObserver(it);return Pt.observe(q),window.addEventListener("resize",it),window.addEventListener("orientationchange",it),()=>{Ue&&cancelAnimationFrame(Ue),Pt.disconnect(),window.removeEventListener("resize",it),window.removeEventListener("orientationchange",it)}},[bs]),ot.useEffect(()=>{bs()},[bs,p,vt]);const ts=c.useCallback(async q=>{const Ue=q.target;Ue.closest(".app-region-no-drag")||Ue.closest("button, a, input, select, textarea")||q.button===0&&C&&await Lu()},[C]),Qs=c.useCallback(q=>Vn($r(q,i)),[i]);Cf({rename_current_session:()=>{if(!f||p)return!1;Qt()},toggle_services_menu:()=>{if(F){Z(!1);return}Z(!0),Oe()}});const Ys=s.jsxs(s.Fragment,{children:[s.jsx(jp,{directory:Jt,className:"mr-1"}),C?s.jsx(ig,{isDesktopApp:C,currentInstanceLabel:G,compactCurrentInstanceLabel:he,currentInstanceIsLocal:Y,isDesktopServicesOpen:F,setIsDesktopServicesOpen:Z,refreshCurrentInstanceLabel:Oe,shortcutLabel:Qs,remoteUpdateInfo:Se,remoteUpdateChecking:fe,remoteUpdateError:ge,onOpenRemoteUpdate:_}):null,s.jsx(og,{isMobile:p,githubAuthStatus:y,githubAccounts:H,githubAvatarUrl:me,githubLogin:ce,isSwitchingGitHubAccount:ne,handleGitHubAccountSwitch:En})]}),On=A&&(u||!!f),wn=c.useCallback(({session:q,isActive:Ue,select:it,closeOtherTabs:Pt,components:Kt})=>{const{Item:Gt,Separator:cs}=Kt,vs=q.share?.url??null,hr=Ue&&!Ne&&!xt&&se&&!se.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Gt,{onClick:()=>{Ue||it(),Tt.current=q.id},children:[s.jsx(O,{name:"pencil-ai",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsxs(Gt,{onClick:()=>Ze(q.id),children:[s.jsx(O,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(cs,{}),vs?s.jsxs(s.Fragment,{children:[s.jsxs(Gt,{onClick:()=>ut(vs),children:[s.jsx(O,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Gt,{onClick:()=>{St(q.id)},children:[s.jsx(O,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Gt,{onClick:()=>{at(q.id)},children:[s.jsx(O,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),Ue?s.jsxs(Gt,{onClick:()=>{nt()},children:[s.jsx(O,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,hr?s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Gt,{disabled:!$e||Ft||b,onClick:Xt,className:"w-full",children:[s.jsx(O,{name:"folder-shared",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(pt,{side:"right",className:"max-w-72",children:t(b?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ft?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(cs,{}),s.jsxs(Gt,{onClick:Pt,children:[s.jsx(O,{name:"close-circle",className:"mr-2 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(cs,{}),s.jsxs(Gt,{onClick:()=>qt({action:"archive",sessionId:q.id}),children:[s.jsx(O,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Gt,{className:"text-destructive focus:text-destructive",onClick:()=>qt({action:"delete",sessionId:q.id}),children:[s.jsx(O,{name:"delete-bin",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Ze,ut,se,nt,xt,Ft,b,Ne,Xt,$e,at,t,St]),Qo=()=>s.jsxs("div",{onMouseDown:ts,className:Pe("app-region-drag relative flex h-12 select-none items-center",E&&U==="right"?"pr-0":"pr-3",vt),style:ls,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:$t}}),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:Ot}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Et?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:Et.title}),Et.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Et.subtitle}):null]}):Ne||!o?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:[e?null:s.jsx(Ka,{align:"start",children:s.jsx("button",{type:"button",className:tt,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(O,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[rt?s.jsxs("form",{ref:ms,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:q=>q.stopPropagation(),onSubmit:q=>{q.preventDefault(),Ve()},children:[s.jsx("input",{value:ns,onChange:q=>Lt(q.target.value),autoFocus:!0,onKeyDown:q=>{q.stopPropagation(),q.key==="Escape"&&Ct(!1)},placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ct(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{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:u?t("sessions.switcher.draftTitle"):dt}),we?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:[g?s.jsx("span",{className:"truncate",children:g}):null,Dt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:Dt})]}):null,!u&&Ge?s.jsxs("span",{className:Pe("inline-flex min-w-0 items-center gap-0.5",Ge==="attention"||Ge==="invalid"||Ge==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(O,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Ee})]}):null]}):null]}),s.jsx("div",{className:Pe("flex h-[18px] shrink-0 items-center justify-center",we?"self-start":"self-center"),children:f&&!u&&!rt?s.jsxs(Ks,{open:It,onOpenChange:Bt,onOpenChangeComplete:q=>{!q&&Tt.current&&Tt.current===f&&(Tt.current=null,Qt())},children:[s.jsx(Us,{asChild:!0,children:s.jsx(lt,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(O,{name:"more",className:"size-4"})})}),s.jsxs(Hs,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Wt,{onClick:()=>{Tt.current=f},children:[s.jsx(O,{name:"pencil-ai",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsxs(Wt,{onClick:()=>f&&Ze(f),children:[s.jsx(O,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Rs,{}),se?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Wt,{onClick:()=>ut(se?.shareUrl),children:[s.jsx(O,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Wt,{onClick:()=>{f&&St(f)},children:[s.jsx(O,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Wt,{onClick:()=>{f&&at(f)},children:[s.jsx(O,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),s.jsxs(Wt,{onClick:()=>{nt()},children:[s.jsx(O,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),!Ne&&!xt&&se&&!se.parentId?s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Wt,{disabled:!$e||Ft||b,onClick:Xt,className:"w-full",children:[s.jsx(O,{name:"folder-shared",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(pt,{side:"right",className:"max-w-72",children:t(b?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ft?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Rs,{}),s.jsxs(Wt,{onClick:()=>{f&&qt({action:"archive",sessionId:f})},children:[s.jsx(O,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Wt,{className:"text-destructive focus:text-destructive",onClick:()=>{f&&qt({action:"delete",sessionId:f})},children:[s.jsx(O,{name:"delete-bin",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(Ka,{align:"start",children:s.jsx("button",{type:"button",className:tt,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(O,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Bp,{renderMenu:wn,suppressActiveTabControls:rt,onMenuOpenChangeComplete:q=>{!q&&Tt.current&&Tt.current===f&&(Tt.current=null,Qt())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:rt?s.jsxs("form",{ref:ms,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:q=>q.stopPropagation(),onSubmit:q=>{q.preventDefault(),Ve()},children:[s.jsx("input",{value:ns,onChange:q=>Lt(q.target.value),autoFocus:!0,onKeyDown:q=>{q.stopPropagation(),q.key==="Escape"&&Ct(!1)},placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ct(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:u?t("sessions.switcher.draftTitle"):dt})})})]}),Et||Ne||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Ae&&W?s.jsx(Ih,{totalTokens:W.totalTokens,percentage:X,colorPercentage:W.percentage,contextLimit:W.contextLimit,outputLimit:W.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:J,pressed:He,className:On?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(rg,{visible:On,title:t(u?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(u?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Mn,className:Pe(tt,"mr-1"),Icon:"picture-in-picture-2"}),Ne?null:s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":We,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:Be,className:Pe(Or,"mr-1",We?"text-foreground":"text-muted-foreground/50"),children:s.jsx(O,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(pt,{side:"bottom",children:t(oe&&!z?ae?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":oe?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),Ys,s.jsx(dd,{visible:E&&U==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:N,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:Qo()}),s.jsx(Ns,{open:zt!==null,onOpenChange:q=>{q||qt(null)},children:s.jsxs(As,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Gs,{children:[s.jsx(Fs,{children:zt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Ls,{children:zt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:dt}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:dt})})]}),s.jsxs(gn,{children:[s.jsx(lt,{variant:"outline",size:"sm",onClick:()=>qt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(lt,{variant:"destructive",size:"sm",onClick:()=>{os()},children:zt?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(ud,{open:pe,onOpenChange:be,info:Se,downloading:!1,downloaded:!1,progress:null,error:ge,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function dg(){}const sl=280,nl=280,rl=500,ug=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=ft(),l=Ce(k=>k.sidebarWidth),a=Ce(k=>k.setSidebarWidth),[d,u]=c.useState(!1),f=c.useRef(0),h=c.useRef(l||sl),x=c.useRef(null),b=c.useRef(null),w=c.useRef(null),S=c.useCallback(k=>Math.min(rl,Math.max(nl,k)),[]),g=c.useCallback(k=>{const A=w.current;A&&(A.style.width=`${k}px`,A.style.minWidth=`${k}px`,A.style.maxWidth=`${k}px`,A.style.setProperty("--oc-left-sidebar-width",`${k}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(x.current=null,b.current=null)},[d]),e)return null;const m=Math.min(rl,Math.max(nl,l||sl)),p=t?m:0,y=k=>{if(t){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}b.current=k.pointerId,u(!0),f.current=k.clientX,h.current=p,x.current=p,g(p),k.preventDefault()}},v=k=>{if(e||!d||b.current!==k.pointerId)return;const A=k.clientX-f.current,D=S(h.current+A);x.current!==D&&(x.current=D,g(D))},N=k=>{if(b.current!==k.pointerId||e)return;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const A=S(x.current??p);b.current=null,x.current=null,u(!1),a(A)},C=d?x.current??p:p;return s.jsxs("aside",{ref:w,className:Pe("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:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${d?C: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||p===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:Pe("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:y,onPointerMove:v,onPointerUp:N,onPointerCancel:N,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Pe("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:s.jsx(Vs,{children:n})})]})]})},fg=()=>{const t=Je.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},Kr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function mg(){const t=Vt(h=>h.activeProjectId?h.projects.find(x=>x.id===h.activeProjectId)??null:null),e=Qe(h=>h.currentSessionId),n=Nf(e??null),r=Qe(h=>e?h.worktreeMetadata.get(e)?.path??"":""),i=Qe(h=>h.newSessionDraft?.open?Kr(h.newSessionDraft.bootstrapPendingDirectory??h.newSessionDraft.directoryOverride??""):""),o=c.useMemo(()=>Kr(r||""),[r]),l=c.useMemo(()=>{const h=typeof n?.directory=="string"?n.directory:"";return Kr(h||"")},[n?.directory]),a=o||l||i,d=c.useMemo(()=>Kr(a||t?.path||""),[t?.path,a]),u=c.useMemo(()=>t?{id:t.id,path:t.path}:null,[t]),f=c.useRef(null);return c.useEffect(()=>{u&&d&&(f.current={projectRef:u,directory:d})},[d,u]),c.useMemo(()=>u&&d?{projectRef:u,directory:d}:f.current,[u,d])}const Ao=new Map,Ti=new Set,Ld=()=>{for(const t of Ti)t()},Zo=(t,e)=>{const n=t.trim();n&&(e.length===0?Ao.delete(n):Ao.set(n,[...e]),Ld())},hg=t=>{Ao.delete(t.trim())&&Ld()},$d=[],pg=t=>Ao.get(t.trim())??$d,gg=t=>(Ti.add(t),()=>{Ti.delete(t)}),bg=t=>{const e=Je.c(2);let n;return e[0]!==t?(n=()=>pg(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(gg,n,xg)};function xg(){return $d}const yg=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],wg=["dev","start","preview","serve"];async function Sg(t,e,n){if(!t)return null;const r=kg(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Cg(n);if(i){const o=await Ng(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await vg(t)){const i=await jg(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function vg(t){const e=`${t}/index.html`,n=await Do(e,t);return typeof n=="string"&&n.trim().length>0}async function jg(){try{const t=await ss("/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 kg(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(wg.some(i=>n.includes(i)))return e}return null}function Cg(t){for(const{pattern:e}of yg)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ng(t){const e=await Do(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await Do(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Do(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ss(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Bo()?.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 ss(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Ag(t){try{const e=await Do(`${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 Dg=(t,e,n)=>new Promise(r=>{let i=!1,o=null,l=null;const a=d=>{i||(i=!0,l&&clearTimeout(l),o?.close(),r(d))};o=t.connect(e,{onEvent:d=>{(d.type==="exit"||d.type==="snapshot"&&d.status==="exited")&&a(!0)},onError:(d,u)=>{u&&a(!0)}}),i?o.close():l=setTimeout(()=>a(!1),n)}),$s="__openchamber_auto_discover_preview__",Pg=15e3,Ig=3e3,Tg=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},Eg=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}},Rg=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=ft(),{currentTheme:l}=qn(),{terminal:a,runtime:d}=xn(),{isMobile:u}=Tn(),f=c.useMemo(()=>cn(),[]),h=Ga(X=>X.instances),x=Ga(X=>X.load),b=Ce(X=>X.terminalShell),w=Ce(X=>X.terminalLoginShells.includes(X.terminalShell)),S=Ce(X=>X.setSettingsPage),g=Ce(X=>X.setSettingsDialogOpen),m=Ce(X=>X.setSettingsProjectsSelectedId),p=Ce(X=>X.openContextPreview),y=Yt(X=>X.ensureDirectory),v=Yt(X=>X.setTabLabel),N=Yt(X=>X.setTabIconKey),C=Yt(X=>X.setActiveTab),k=Yt(X=>X.setConnecting),A=Yt(X=>X.setTabSessionId),D=Yt(X=>X.setTabPreviewUrl),P=Yt(X=>X.projectActionRuns),T=Yt(X=>X.setProjectActionRun),$=Yt(X=>X.updateProjectActionRunStatus),E=Yt(X=>X.removeProjectActionRun),[U,I]=c.useState([]),[B,R]=c.useState(null),[j,M]=c.useState(!1),L=c.useRef({}),W=c.useRef({}),te=c.useRef({}),Q=c.useRef({}),me=c.useRef(new Set),ce=c.useRef(0),H=t?.id??null,ne=t?.path??"",ie=c.useMemo(()=>H?{id:H,path:ne}:null,[H,ne]);c.useEffect(()=>{f&&x().catch(()=>{})},[f,x]);const F=c.useCallback(async X=>{await Lo(X)},[]),Z=c.useCallback(async()=>{if(!ie)return;const X=ce.current+1;ce.current=X,M(!0);try{const Oe=await Ta(ie);if(ce.current!==X)return;const Fe=Oe.actions;I(Fe),R(_=>_===$s||_&&Fe.some(ue=>ue.id===_)?_:null)}catch{if(ce.current!==X)return}finally{ce.current===X&&M(!1)}},[ie]),G=c.useMemo(()=>Eh(e||ie?.path||""),[e,ie?.path]),V=c.useMemo(()=>B?U.find(X=>X.id===B)??null:null,[U,B]),Y=c.useMemo(()=>({id:$s,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),le=!u,pe=c.useMemo(()=>le?[Y,...U]:U,[U,Y,le]);c.useEffect(()=>{Z()},[Z]),c.useEffect(()=>{if(typeof window>"u")return;const X=Oe=>{const Fe=Oe.detail;H&&(Fe?.projectId&&Fe.projectId!==H||Z())};return window.addEventListener(qa,X),()=>{window.removeEventListener(qa,X)}},[Z,H]),c.useEffect(()=>{B&&(B===$s&&le||U.some(X=>X.id===B)||R(null))},[U,le,B]),c.useEffect(()=>{const X=Fe=>{delete Q.current[Fe];const _=W.current[Fe];if(!_||_.openedUrl)return;const ue=Yt.getState(),ke=ue.projectActionRuns[Fe];if(!ke)return;const je=_.announced;if(je.length!==0){if(_.openedUrl=!0,ue.updateProjectActionRunStatus(Fe,"running"),je.length===1){Zo(ke.directory,[]),D(ke.directory,ke.tabId,je[0],{locked:!1,autoOpened:!0}),p(ke.directory,je[0]);return}_.offering=!0,Zo(ke.directory,je),Ce.getState().openContextSurface(ke.directory,"browser"),Re.info(o("projectActions.toast.multipleServers"))}},Oe=()=>{const Fe=Yt.getState(),_=Fe.sessions,ue=Fe.projectActionRuns;for(const[ke,je]of Object.entries(ue)){const se=_.get(je.directory)?.tabs.find(Xe=>Xe.id===je.tabId);if(!se||se.terminalSessionId!==je.sessionId){E(ke);continue}const Ie=W.current[ke]??{lastSeenChunkId:null,openedUrl:!1,tail:"",openInPreview:!1,announced:[],offering:!1};W.current[ke]=Ie;const Ye=pe.find(Xe=>Xe.id===je.actionId),ee=Fe.getBuffer(je.directory,je.tabId).chunks;if(!Ye||ee.length===0)continue;const Ee=ee.filter(Xe=>Ie.lastSeenChunkId===null||Xe.id>Ie.lastSeenChunkId);if(Ee.length===0)continue;const Ge=Ee.map(Xe=>Xe.data).join(""),ze=`${Ie.tail}${Ge}`;if(Ie.openInPreview&&(!Ie.openedUrl||Ie.offering)){const Xe=Mh(ze),ct=Ie.announced.length;for(const At of Xe)Ie.announced.includes(At)||Ie.announced.push(At);const Nt=Ie.announced.length-ct;Ie.offering&&Nt>0?Zo(je.directory,Ie.announced):!Ie.openedUrl&&ct===0&&Ie.announced.length>0&&(window.clearTimeout(Q.current[ke]),Q.current[ke]=window.setTimeout(()=>X(ke),Ig))}const $e=!Ie.openedUrl&&Ye.autoOpenUrl===!0&&!Ie.openInPreview?Oh(ze):null,_e=Ee[Ee.length-1]?.id??Ie.lastSeenChunkId;if(Ie.lastSeenChunkId=_e,Ie.tail=ze.slice(-512),$e)if(Ie.openedUrl=!0,Ie.openInPreview){const Xe=ue[ke];Xe&&(D(Xe.directory,Xe.tabId,$e,{locked:!1,autoOpened:!1}),Xe.status==="waiting-for-preview"&&$(ke,"running"),window.clearTimeout(Q.current[ke]),delete Q.current[ke],p(Xe.directory,$e))}else F($e),Re.success(o("projectActions.toast.openedUrlFromOutput"));W.current[ke]=Ie}for(const ke of Object.keys(W.current))ue[ke]||(delete W.current[ke],window.clearTimeout(Q.current[ke]),delete Q.current[ke])};return Oe(),Yt.subscribe((Fe,_)=>{(Fe.sessions!==_.sessions||Fe.buffers!==_.buffers)&&Oe()})},[pe,p,F,P,E,D,o,$]);const be=c.useCallback(async(X,Oe={})=>{if(!G)throw new Error(o("projectActions.error.noActiveDirectory"));const Fe=un(G,X.id);y(G);const _=Yt.getState(),ue=_.getDirectoryState(G);let ke=L.current[Fe]||null;const je=ke?!!ue?.tabs.some(Ie=>Ie.id===ke):!1;(!ke||!je)&&(ke=_.createTab(G),L.current[Fe]=ke),v(G,ke,`Action: ${X.name}`),N(G,ke,X.icon||"play"),C(G,ke),Oe.revealTerminal!==!1&&Ce.getState().openContextPanelTab(G,{mode:"terminal"});const se=Yt.getState().getDirectoryState(G)?.tabs.find(Ie=>Ie.id===ke);return{key:Fe,tabId:ke,sessionId:se?.terminalSessionId??null}},[y,G,C,N,v,o]),Se=c.useCallback(async X=>{if(d.isVSCode||!i&&u)return;if(!G){Re.error(o("projectActions.error.noActiveDirectoryForAction"));return}const Oe=un(G,X.id),Fe=P[Oe];if(!(Fe&&Fe.status==="running")&&!me.current.has(Oe)){me.current.add(Oe);try{const _=X.id===$s?await(async()=>{const[$e,_e]=await Promise.all([Ta({id:ie?.id??"",path:G}),Ag(G)]),Xe=await Sg(G,$e.actions,_e);if(!Xe)throw new Error(o("contextPanel.preview.noDevServer"));return{id:$s,name:o("projectActions.actions.autoDiscover"),command:Xe.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Xe.previewUrlHint||""}})():X,ue=_.autoOpenUrl===!0&&(_.openUrl||"").trim().length>0,ke=!ue&&X.id!==$s,{key:je,tabId:Ke,sessionId:se}=await be(_,{revealTerminal:ke});let Ie=se;if(!Ie){k(G,Ke,!0);try{Ie=(await a.createSession({cwd:G,sessionId:Ke,shell:b,loginShell:w,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground})).sessionId,A(G,Ke,Ie)}finally{k(G,Ke,!1)}}if(!Ie)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));te.current[je]?.(),k(G,Ke,!0);const Ye=a.connect(Ie,{onEvent:$e=>{$e.type==="snapshot"&&(Yt.getState().replaceBuffer(G,Ke,$e.data??"",$e.sequence??0),Yt.getState().setConnecting(G,Ke,!1)),$e.type==="data"&&typeof $e.data=="string"&&$e.data.length>0&&Yt.getState().appendToBuffer(G,Ke,$e.data,$e.sequence,$e.replayData),$e.type==="exit"&&(Yt.getState().setTabLifecycle(G,Ke,"exited"),Yt.getState().setConnecting(G,Ke,!1),Yt.getState().removeProjectActionRun(je),delete W.current[je],te.current[je]?.(),delete te.current[je],window.clearTimeout(Q.current[je]),delete Q.current[je])},onError:($e,_e)=>{Yt.getState().setConnecting(G,Ke,!1),_e&&(Yt.getState().setTabLifecycle(G,Ke,"exited"),Yt.getState().setTabSessionId(G,Ke,null),Yt.getState().removeProjectActionRun(je))}});te.current[je]=Ye.close;const ee=_.autoOpenUrl===!0&&f&&(_.desktopOpenSshForward||"").trim().length>0,Ee=_.autoOpenUrl?Eg(_.openUrl):null,Ge=_.autoOpenUrl&&f?Rh(_.desktopOpenSshForward,h):null;T({key:je,directory:G,actionId:_.id,tabId:Ke,sessionId:Ie,status:_.id===$s&&!Ee?"waiting-for-preview":"running"}),window.clearTimeout(Q.current[je]),delete Q.current[je],_.id===$s&&!Ee&&(Q.current[je]=window.setTimeout(()=>{const $e=Yt.getState(),_e=$e.projectActionRuns[je];$e.updateProjectActionRunStatus(je,"running"),_e&&($e.setActiveTab(_e.directory,_e.tabId),Ce.getState().openContextPanelTab(_e.directory,{mode:"terminal"})),delete Q.current[je]},Pg)),W.current[je]={lastSeenChunkId:null,openedUrl:!!Ge||!!Ee||ue,tail:"",openInPreview:_.id===$s,announced:[],offering:!1};const ze=Tg(_.command.trim().replace(/\r\n|\r/g,`
|
|
37
|
-
`));await a.sendInput(Ie,`${ze}\r`),Ge?(D(G,Ke,null,{locked:!0}),F(Ge),Re.success(o("projectActions.toast.openedForwardedUrl"))):Ee?(D(G,Ke,Ee,{locked:!0,autoOpened:!0}),p(G,Ee),Re.success(o("projectActions.toast.openedActionUrl"))):ue?(D(G,Ke,null,{locked:!0}),Re.error(o("projectActions.error.invalidCustomUrlFormat"))):ee?(D(G,Ke,null,{locked:!0}),Re.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):D(G,Ke,null,{locked:!1,autoOpened:!1})}catch(_){E(Oe),delete W.current[Oe],te.current[Oe]?.(),delete te.current[Oe],window.clearTimeout(Q.current[Oe]),delete Q.current[Oe],Re.error(_ instanceof Error?_.message:o("projectActions.error.failedToRunAction"))}finally{me.current.delete(Oe)}}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,h,be,i,u,f,G,w,b,F,p,P,d.isVSCode,E,k,T,D,A,ie?.id,o,a]),De=c.useCallback(async X=>{const Oe=un(G,X.id),Fe=P[Oe];if(!Fe)return;$(Oe,"stopping");const _=Dg(a,Fe.sessionId,1e3);try{await a.sendInput(Fe.sessionId,"")}catch{}const ue=await _;if(Yt.getState().getDirectoryState(Fe.directory)?.tabs.find(Ke=>Ke.id===Fe.tabId)?.terminalSessionId===Fe.sessionId&&!ue){if(typeof a.forceKill=="function")try{await a.forceKill({sessionId:Fe.sessionId})}catch{}else try{await a.close(Fe.sessionId)}catch{}A(Fe.directory,Fe.tabId,null)}E(Oe),delete W.current[Oe],te.current[Oe]?.(),delete te.current[Oe],window.clearTimeout(Q.current[Oe]),delete Q.current[Oe]},[G,P,E,A,a,$]),fe=c.useCallback(()=>{const X=V??pe[0];if(!X)return;const Oe=un(G,X.id),Fe=P[Oe];if(Fe?.status!=="stopping"){if(Fe){De(X);return}Se(X)}},[pe,G,Se,P,V,De]),xe=c.useCallback((X,Oe=!1)=>{if(R(X.id),!Oe){Se(X);return}const Fe=un(G,X.id),_=P[Fe];if(_?.status!=="stopping"){if(_){De(X);return}Se(X)}},[G,Se,P,De]),ge=c.useCallback(()=>{ie?.id&&(m(ie.id),S("projects"),g(!0))},[g,S,m,ie?.id]),re=V??pe[0]??null,he=re?P[un(G,re.id)]:null,Ne=Yt(X=>he?X.sessions.get(he.directory)?.tabs.find(Oe=>Oe.id===he.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&u||!ie||!G)return null;const de=V??pe[0]??null;if(!de)return null;const oe=de.icon||"play",K=de.id===$s?"scan-2":Xo[oe]||"play",z=un(G,de.id),ae=P[z],ve=ae?.status==="stopping",ye=ae?.status==="waiting-for-preview",We=!!(ae&&Ne),Be=()=>{!ae||!Ne||p(ae.directory,Ne)},Ae=de.id===$s;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",disabled:j||ve,className:Pe("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:fe,"aria-label":ae?o("projectActions.actions.stopNamedAria",{name:de.name}):o("projectActions.actions.runNamedAria",{name:de.name}),children:ve||ye?s.jsx(O,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):ae?s.jsx(O,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(O,{name:K,className:"h-5 w-5"})})}),Ae?s.jsx(pt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),We?s.jsxs(gt,{children:[s.jsx(ht,{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":o("projectActions.actions.openPreview"),onClick:Be,children:s.jsx(O,{name:"global",className:"h-4 w-4"})})}),s.jsx(pt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ks,{children:[s.jsx(Us,{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":o("projectActions.actions.chooseActionAria"),children:s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Hs,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Wt,{className:"flex items-center gap-2",onClick:ge,children:[s.jsx(O,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Rs,{}),pe.map(X=>{const Oe=X.icon||"play",Fe=X.id===$s?"scan-2":Xo[Oe]||"play",_=un(G,X.id),ue=P[_],ke=!!ue,je=ue?.status==="stopping";return s.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{xe(X,!0)},children:[s.jsx(O,{name:Fe,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),je||ue?.status==="waiting-for-preview"?s.jsx(O,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):ke?s.jsx(O,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]}):s.jsxs("div",{className:Pe("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(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:fe,disabled:j||ve,className:Pe("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":ae?o("projectActions.actions.stopNamedAria",{name:de.name}):o("projectActions.actions.runNamedAria",{name:de.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:ve||ye?s.jsx(O,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):ae?s.jsx(O,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(O,{name:K,className:"h-4 w-4"})})})}),Ae?s.jsx(pt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),We?s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Be,className:Pe(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":o("projectActions.actions.openPreview"),children:s.jsx(O,{name:"global",className:"h-4 w-4"})})}),s.jsx(pt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ks,{children:[s.jsx(Us,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe(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":o("projectActions.actions.chooseActionAria"),children:s.jsx(O,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Hs,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Wt,{className:"flex items-center gap-2",onClick:ge,children:[s.jsx(O,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Rs,{}),pe.map(X=>{const Oe=X.icon||"play",Fe=X.id===$s?"scan-2":Xo[Oe]||"play",_=un(G,X.id),ue=P[_],ke=!!ue,je=ue?.status==="stopping";return s.jsxs(Wt,{className:"flex items-center gap-2",onClick:()=>{xe(X,!0)},children:[s.jsx(O,{name:Fe,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),je||ue?.status==="waiting-for-preview"?s.jsx(O,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):ke?s.jsx(O,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]})},ol="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",Mg=()=>{const t=Je.c(35),{t:e}=ft(),n=Ce(Og),r=Ce(Bg),i=mg(),o=c.useRef(null),l=Vn($r("toggle_sidebar",r)),{usesFramelessChrome:a,side:d}=cd(),u=Fg;let f,h;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const U=o.current;if(!U)return;const I=()=>{const R=Math.max(U.getBoundingClientRect().width,U.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(R)}px`)};if(I(),typeof ResizeObserver>"u")return;const B=new ResizeObserver(I);return B.observe(U),()=>{B.disconnect()}},h=[],t[0]=f,t[1]=h):(f=t[0],h=t[1]),c.useEffect(f,h);const x="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 w="flex items-center gap-2";let S;t[3]!==a||t[4]!==d?(S=a&&d==="left"?s.jsx(dd,{visible:!0,position:"left"}):null,t[3]=a,t[4]=d,t[5]=S):S=t[5];let g;t[6]!==e||t[7]!==a?(g=a?s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,"aria-label":e("header.actions.openAppMenuAria"),className:Pe(ol,"shrink-0"),children:s.jsx(O,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(pt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=a,t[8]=g):g=t[8];const m=gt;let p;t[9]!==e?(p=e("header.actions.openSessionsAria"),t[9]=e,t[10]=p):p=t[10];let y,v;t[11]===Symbol.for("react.memo_cache_sentinel")?(y=Pe(ol,"shrink-0"),v=s.jsx(O,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=y,t[12]=v):(y=t[11],v=t[12]);let N;t[13]!==p||t[14]!==n?(N=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":p,className:y,children:v})}),t[13]=p,t[14]=n,t[15]=N):N=t[15];const C=pt,k=e("header.actions.openSessionsWithShortcut",{shortcut:l});let A;t[16]!==k?(A=s.jsx("p",{children:k}),t[16]=k,t[17]=A):A=t[17];let D;t[18]!==C||t[19]!==A?(D=s.jsx(C,{children:A}),t[18]=C,t[19]=A,t[20]=D):D=t[20];let P;t[21]!==m||t[22]!==N||t[23]!==D?(P=s.jsxs(m,{children:[N,D]}),t[21]=m,t[22]=N,t[23]=D,t[24]=P):P=t[24];let T;t[25]!==i?(T=i?s.jsx(Rg,{projectRef:i.projectRef,directory:i.directory}):null,t[25]=i,t[26]=T):T=t[26];let $;t[27]!==P||t[28]!==T||t[29]!==S||t[30]!==g?($=s.jsxs("div",{ref:o,className:w,children:[S,g,P,T]}),t[27]=P,t[28]=T,t[29]=S,t[30]=g,t[31]=$):$=t[31];let E;return t[32]!==$||t[33]!==b?(E=s.jsx("div",{className:x,style:b,children:$}),t[32]=$,t[33]=b,t[34]=E):E=t[34],E};function Og(t){return t.toggleSidebar}function Bg(t){return t.shortcutOverrides}function _g(t){console.warn("[titlebar] failed to open app menu",t)}function Fg(t){const e=t.currentTarget.getBoundingClientRect();Nn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(_g)}function zd(t){const e=Je.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(O,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const il=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Lg(t,e,n){const r=Je.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,f]=await Promise.all([Af(t),Df(t)]).catch($g);if(d)return;const h=il(u),x=il(f);if(!h||!x||x===h)return;const b=n||"",w=x.split("/").filter(Boolean).pop()||x;o({source:"sdk",path:x,projectDirectory:h,branch:b,label:b||w,name:w,worktreeRoot:x,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]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function $g(){return["",""]}class Go 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 qo="/api/walkthrough",Wd=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),Vd=()=>new Go("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),zg=t=>!Wd(t)&&(t.ok||t.status===404),pa=async(t,e)=>{if(zg(t))throw Vd();const n=await t.json().catch(()=>null);throw new Go(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})},Ud=async t=>{if(!Wd(t))throw Vd();try{return await t.json()}catch{throw new Go("The server returned a malformed walkthrough response")}};async function Wg(t,e,n={}){const r=await ss(qo,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?Ud(r):pa(r,"Failed to load walkthrough")}async function Vg(t,e,n={}){const r=await ss(`${qo}/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?Ud(r):pa(r,"Failed to generate walkthrough")}async function Ug(t,e){const n=await ss(`${qo}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await pa(n,"Failed to cancel walkthrough generation")}async function Hg(t,e,n){const r=await ss(`${qo}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const gr={status:"idle",stage:null,result:null,readiness:null,error:null},Kg=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:`pr:${t.number}`,Sn=(t,e)=>`${ks()}\0${t}\0${Kg(e)}`,al=t=>t instanceof Go?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Xs=new Map,br=new Map,Gg=1e3,qg=Yn()(Ad((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Sn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Sn(n,r)],selectModel:(n,r,i)=>{const o=Sn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Sn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[Sn(n,r)]??gr,load:async(n,r,i={})=>{if(!n)return;const o=Sn(n,r);if(e().entries[o]?.status==="generating")return;Xs.get(o)?.abort();const a=new AbortController;Xs.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??gr,status:"loading",error:null}}}));try{const d=await Wg(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??gr,status:"error",stage:null,error:al(d)}}}))}finally{Xs.get(o)===a&&Xs.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Sn(n,r);Xs.get(o)?.abort();const l=new AbortController;Xs.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??gr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=br.get(o);d!==void 0&&(clearInterval(d),br.delete(o))};a(),br.set(o,setInterval(()=>{Hg(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const f=u.entries[o];return!f||f.status!=="generating"||f.stage===d?u:{entries:{...u.entries,[o]:{...f,stage:d}}}})}).catch(()=>{})},Gg));try{const d=await Vg(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??gr,status:"error",stage:null,error:al(d)}}}))}finally{a(),Xs.get(o)===l&&Xs.delete(o)}},cancel:(n,r)=>{const i=Sn(n,r);Ug(n,r).catch(()=>{}),Xs.get(i)?.abort(),Xs.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of Xs.values())n.abort();Xs.clear();for(const n of br.values())clearInterval(n);br.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),Qg="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)]",Yg=3e4,ll=20,Hd=(t,e)=>JSON.stringify([ks(),t,e]),Xg=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},cl=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),Gr=new Map,Jg=t=>{const e=Object.entries(t);return e.length<=ll?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,ll))},dl=Yn()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=Hd(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<Yg&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const f=`${l}::${a?"details":"plain"}`,x=Gr.get(`${l}::details`)??(a?null:Gr.get(f));if(x&&!o?.force)return x;const b=(async()=>{t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??cl(),isLoading:!0,error:null}}}));try{const w=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(S=>({entries:Jg({...S.entries,[l]:{result:w,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),w}catch(w){const S=w instanceof Error?w.message:"Failed to load pull request context";return t(g=>({entries:{...g.entries,[l]:{...g.entries[l]??cl(),isLoading:!1,error:S}}})),null}finally{Gr.delete(f)}})();return Gr.set(f,b),b},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=Xg(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),Zg=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},eb=35e3,ei=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},ti=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},ul=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"}},tb=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:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},sb=[2e3,5e3],fl=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),kn=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):""},nb=(t,e)=>{const n=kn(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},rb=(t,e)=>`${t}::${e}`,ga=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},si=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=ga(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},ob=t=>t.startsWith("pr-"),ib=(t,e)=>{const n=ga(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!ob(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},xr=new Map,qr=Lo;function ab(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const lb=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=ft(),d=Ce(J=>J.timeFormatPreference),{github:u}=xn(),f=Hn(J=>J.status),h=Hn(J=>J.hasChecked),x=Ce(J=>J.setSettingsDialogOpen),b=Ce(J=>J.setSettingsPage),w=Qe(J=>J.currentSessionId),S=Qe(J=>!!J.newSessionDraft?.open),{isMobile:g,hasTouchInput:m,screenWidth:p}=Tn(),y=Ce(J=>J.openContextSurface),v=qg(J=>J.requestSource),N=!g&&p>=768&&!bn(),C=c.useCallback(()=>{b("github"),x(!0)},[x,b]),k=c.useMemo(()=>rb(t,e),[t,e]),A=c.useMemo(()=>xr.get(k)??null,[k]),D=Ws(J=>J.ensureEntry),P=Ws(J=>J.setParams),T=Ws(J=>J.startWatching),$=Ws(J=>J.stopWatching),E=Ws(J=>J.refresh),U=Ws(J=>J.updateStatus),[I,B]=c.useState(()=>A?.title??fl(e)),[R,j]=c.useState(()=>A?.body??""),[M,L]=c.useState(()=>A?.draft??!1),[W,te]=c.useState(()=>A?.additionalContext??""),[Q,me]=c.useState(()=>{const J=typeof A?.targetBaseBranch=="string"?kn(A.targetBaseBranch):"";return J||kn(n)}),[ce,H]=c.useState("squash"),[ne,ie]=c.useState(!1),[F,Z]=c.useState(!1),[G,V]=c.useState(!1),[Y,le]=c.useState(!1),[pe,be]=c.useState(!1),[Se,De]=c.useState(!1),[fe,xe]=c.useState(null),[ge,re]=c.useState(""),[he,Ne]=c.useState(""),[de,oe]=c.useState(!1),[K,z]=c.useState(!1),[ae,ve]=c.useState(()=>si(i,{selectedRemoteName:A?.selectedRemoteName,trackingBranch:r})),[ye,We]=c.useState(!1),{detectedUpstream:Be,upstreamBranches:Ae}=ab(t,u);c.useEffect(()=>{We(!1)},[t]);const X=i.some(J=>J.name==="upstream"),Fe=!!(t&&e&&n&&(e!==n||(X||Be!==null))),_=c.useMemo(()=>$o(t,e,ae?.name??null),[t,e,ae?.name]),ue=Ws(J=>J.entries[_]),ke=ue?.isLoading??!1,je=ue?.status??null,Ke=ue?.error??null,se=ue?.isInitialStatusResolved??!1,Ie=c.useMemo(()=>{const J=ye?null:ae?.name?.trim()||null,He=new Set;for(const $t of o){const Ot=nb($t,J);!Ot||Ot==="HEAD"||He.add(Ot)}if(ye)for(const $t of Ae)$t&&$t!=="HEAD"&&He.add($t);const tt=kn(n);tt&&tt!=="HEAD"&&He.add(tt);const bt=kn(Q);return bt&&bt!=="HEAD"&&He.add(bt),Array.from(He).sort(($t,Ot)=>$t.localeCompare(Ot))},[n,o,ae?.name,Q,Ae,ye]);c.useEffect(()=>{if(i.length===0){ae&&ve(null);return}(!ae||!i.some(J=>J.name===ae.name))&&ve(si(i,{selectedRemoteName:A?.selectedRemoteName,trackingBranch:r}))},[A?.selectedRemoteName,i,ae,r]),c.useEffect(()=>{const J=kn(n);if(!Q&&J){me(J);return}if(Ie.length!==0&&!Ie.includes(Q)){const He=Ie.includes(J)?J:Ie[0];He&&me(He)}},[Ie,n,Q]);const[Ye,ee]=c.useState(()=>A?.activeSegment??"overview"),[Ee,Ge]=c.useState(new Set),[ze,$e]=c.useState(new Set),_e=c.useRef(new Set),Xe=c.useRef(null),ct=c.useRef(!1),Nt=c.useRef(new Set),At=c.useRef([]);c.useEffect(()=>{Be&&!X&&We(!0)},[Be,X]),c.useEffect(()=>{ye&&Be?.defaultBranch&&me(Be.defaultBranch)},[ye,Be?.defaultBranch]);const Le=je?.pr??null,_t=Le?.state==="merged"||Le?.state==="closed",mt=_t?null:Le,Rt=mt?Hd(t,mt.number):null,Dt=dl(J=>Rt?J.entries[Rt]:void 0),xt=dl(J=>J.ensure),we=Dt?.result??null,dt=Dt?.isLoading??!1,et=c.useCallback(J=>{ee(J);const He=xr.get(k);He&&xr.set(k,{...He,activeSegment:J})},[k]);c.useEffect(()=>{!mt||!u?.prContext||Ye==="overview"||xt(u,t,mt.number,{includeCheckDetails:Ye==="checks",sourceRepo:je?.repo??null})},[Ye,t,xt,u,mt,je?.repo]);const qe=je?.checks??null,kt=(qe?.pending??0)>0,wt=we?.checkRuns??null,jt=we?.fetchedAt;c.useEffect(()=>{if(!wt||wt.length===0)return;const J=Zg(wt);U(_,He=>{if(!He?.pr||typeof jt=="number"&&typeof He.fetchedAt=="number"&&jt<He.fetchedAt)return He;const tt=He.checks;return tt&&tt.state===J.state&&tt.total===J.total&&tt.success===J.success&&tt.failure===J.failure&&tt.pending===J.pending&&tt.inProgress===J.inProgress&&tt.queued===J.queued&&tt.startedAt===J.startedAt?He:{...He,checks:J,...typeof jt=="number"?{fetchedAt:jt}:{}}})},[wt,jt,_,U]),c.useEffect(()=>{if(Ye!=="checks"||!kt||!Le||!u?.prContext)return;const J=window.setInterval(()=>{xt(u,t,Le.number,{includeCheckDetails:!0,sourceRepo:je?.repo??null,force:!0})},eb);return()=>window.clearInterval(J)},[Ye,kt,t,xt,u,Le,je?.repo]);const[Ut,st]=c.useState(()=>Date.now());c.useEffect(()=>{if(!kt)return;st(Date.now());const J=window.setInterval(()=>st(Date.now()),3e4);return()=>window.clearInterval(J)},[kt]);const rt=Le?`${t}#${Le.number}`:null,Ct=!!(rt&&fe===rt);c.useEffect(()=>{if(!u?.prContext||!Le||typeof Le.body=="string"&&Le.body.length>0)return;const J=`${t}#${Le.number}`;if(_e.current.has(J))return;_e.current.add(J),xe(J);let He=!1;return xt(u,t,Le.number,{sourceRepo:je?.repo??null}).then(tt=>{if(He)return;const bt=tt?.pr;bt&&U(_,$t=>!$t?.pr||$t.pr.number!==Le.number?$t:{...$t,pr:{...$t.pr,body:bt.body||""}})}).catch(()=>{}).finally(()=>{He||xe(tt=>tt===J?null:tt)}),()=>{He=!0}},[t,xt,u,Le,_,je?.repo,U]),c.useEffect(()=>{if(!Le){De(!1),re(""),Ne(""),Xe.current=null;return}const J=Xe.current!==null&&Xe.current!==Le.number;J&&De(!1),(!Se||J)&&(re(Le.title||""),Ne(Le.body||"")),Xe.current=Le.number},[Se,Le]);const It=c.useCallback(J=>{if(!J)return"";const He=Date.parse(J);return Number.isFinite(He)?Mc(He,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):J},[d]),Bt=c.useMemo(()=>{const J=f?.user?.login;return typeof J=="string"?J.trim():""},[f]),Tt=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),ns=c.useCallback(J=>{const He=Bt.toLowerCase(),tt=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return J.replace(tt,(bt,$t,Ot)=>{const vt=`@${Ot}`,ls=Ot.toLowerCase();return`${$t}[${vt}](https://github.com/${ls}${He&&ls===He?"?oc-self-mention=1":""})`})},[Bt]),Lt=c.useMemo(()=>{const J=(we?.issueComments??[]).map(bt=>({id:`issue-${bt.id}`,body:bt.body||"",authorName:bt.author?.name||bt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:bt.author?.login||null,avatarUrl:bt.author?.avatarUrl||null,createdAt:bt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),He=(we?.reviewComments??[]).map(bt=>({id:`review-${bt.id}`,body:bt.body||"",authorName:bt.author?.name||bt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:bt.author?.login||null,avatarUrl:bt.author?.avatarUrl||null,createdAt:bt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:bt.path||null,line:bt.line??null})),tt=[...J,...He];return tt.sort((bt,$t)=>{const Ot=bt.createdAt?Date.parse(bt.createdAt):0,vt=$t.createdAt?Date.parse($t.createdAt):0,ls=Number.isFinite(Ot)?Ot:0,bs=Number.isFinite(vt)?vt:0;return ls-bs}),tt},[we,a]),zt=c.useCallback(()=>{const J=w??(S?"draft":null);return J?{directory:t,sessionKey:J}:(Re.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[w,t,S,a]),qt=c.useCallback((J,He)=>{const tt=He.authorLogin?`@${He.authorLogin}`:He.authorName,bt=He.path?` · ${He.path}${He.line?`:${He.line}`:""}`:"";bi.getState().addDraft(J,{source:"pr-comment",fileLabel:`PR #${Le?.number??""} ${tt}${bt}`,startLine:He.line??0,endLine:He.line??0,code:He.body,language:"markdown",text:""})},[Le?.number]),ms=c.useCallback((J,He)=>{const tt=J.status||"unknown",bt=J.conclusion??void 0,$t=bt?`${tt} / ${bt}`:tt,Ot=J.app?.name||J.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:He?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[He?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:J.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Ot?`${Ot} · ${$t}`:$t})]}),J.detailsUrl?s.jsx(lt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:J.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(O,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),J.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:J.output.title}):null,J.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:J.output.summary}):null,J.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:J.output.text}):null,Array.isArray(J.annotations)&&J.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",J.annotations.length>20?` (showing 20/${J.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:J.annotations.slice(0,20).map((vt,ls)=>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:[vt.title||vt.level||"Issue",vt.path?` · ${vt.path}`:"",typeof vt.startLine=="number"?`:${vt.startLine}`:"",typeof vt.endLine=="number"&&vt.endLine!==vt.startLine?`-${vt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:vt.message}),vt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:vt.rawDetails}):null]},`${vt.path||"file"}:${vt.startLine||ls}:${ls}`))})]}):null,J.job?.steps&&J.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:J.job.steps.map((vt,ls)=>{const bs=(vt.conclusion||"").toLowerCase(),ts=bs&&!["success","neutral","skipped"].includes(bs),Qs=`${J.id??"run"}:${J.job?.jobId??"job"}:${vt.number??ls}:${vt.name}`,Ys=Ee.has(Qs);return ts?s.jsxs(ji,{open:Ys,children:[s.jsxs("button",{type:"button",onClick:()=>{Ge(On=>{const wn=new Set(On);return wn.has(Qs)?wn.delete(Qs):wn.add(Qs),wn})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(ts?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Ys?s.jsx(O,{name:"arrow-down-s",className:"size-4"}):s.jsx(O,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:vt.name}),vt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:vt.conclusion}):null]}),s.jsx(ki,{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 vt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",vt.number]}):null,vt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",vt.status]}):null,vt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",vt.conclusion]}):null,vt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",It(vt.startedAt)]}):null,vt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",It(vt.completedAt)]}):null]})})]},Qs):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:vt.name}),vt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:vt.conclusion}):null]},Qs)})})]}):null]})},[Ee,It,a]),[Qt,Me]=c.useState(!1),[Ve,Ze]=c.useState(!1),at=c.useCallback(async()=>{if(!u?.prContext){Re.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!Le)return;const J=zt();if(J){Me(!0);try{const He=await xt(u,t,Le.number,{includeCheckDetails:!0,sourceRepo:je?.repo??null});if(!He){Re.error(a("gitView.pr.toast.loadChecksFailed"));return}const bt=(He.checkRuns??[]).filter(Ot=>ti(Ot.conclusion));if(bt.length===0){Re.message(a("gitView.pr.toast.noFailedChecks"));return}const $t=bi.getState();for(const Ot of bt){const vt=(Ot.annotations??[]).map(ts=>[[ts.level,ts.title].filter(Boolean).join(" "),ts.path?`${ts.path}${typeof ts.startLine=="number"?`:${ts.startLine}`:""}`:null,ts.message,ts.rawDetails].filter(Boolean).join(`
|
|
38
|
-
`)),ls=(Ot.job?.steps??[]).filter(ts=>ti(ts.conclusion)).map(ts=>`step ${ts.number??"?"}: ${ts.name} → ${ts.conclusion}`),bs=[`check: ${Ot.job?.workflowName?`${Ot.job.workflowName} / ${Ot.name}`:Ot.name}`,`status: ${Ot.status??"unknown"} / ${Ot.conclusion??"unknown"}`,Ot.detailsUrl?`url: ${Ot.detailsUrl}`:null,Ot.output?.title?`title: ${Ot.output.title}`:null,Ot.output?.summary?`summary:
|
|
39
|
-
${Ot.output.summary}`:null,ls.length>0?`failed steps:
|
|
40
|
-
${ls.join(`
|
|
41
|
-
`)}`:null,vt.length>0?`annotations:
|
|
42
|
-
${vt.join(`
|
|
43
|
-
---
|
|
44
|
-
`)}`:null].filter(Boolean).join(`
|
|
45
|
-
|
|
46
|
-
`);$t.addDraft(J,{source:"pr-check",fileLabel:`PR #${Le.number} · ${Ot.name}`,startLine:0,endLine:0,code:bs,language:"text",text:""})}}catch(He){const tt=He instanceof Error?He.message:String(He);Re.error(a("gitView.pr.toast.loadChecksFailed"),{description:tt})}finally{Me(!1)}}},[t,xt,u,Le,zt,je?.repo,a]),ut=c.useCallback(async()=>{if(!u?.prContext){Re.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!Le)return;const J=zt();if(J){Ze(!0);try{if(!await xt(u,t,Le.number,{sourceRepo:je?.repo??null})){Re.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(Lt.length===0){Re.message(a("gitView.pr.toast.noPrComments"));return}for(const tt of Lt)qt(J,tt)}catch(He){const tt=He instanceof Error?He.message:String(He);Re.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:tt})}finally{Ze(!1)}}},[qt,t,xt,u,Le,zt,je?.repo,a,Lt]),St=c.useCallback(async J=>{const He=zt();He&&qt(He,J)},[qt,zt]),nt=c.useCallback(async J=>{await E(_,J)},[_,E]),Ft=c.useCallback(()=>{At.current.forEach(J=>{window.clearTimeout(J)}),At.current=sb.map(J=>window.setTimeout(()=>{nt({force:!0,silent:!0,markInitialResolved:!0})},J))},[nt]);c.useEffect(()=>{if(!u?.prStatus||!Fe||i.length<=1||ct.current||je?.pr)return;const J=`${k}::${ae?.name??""}`;if(Nt.current.has(J))return;Nt.current.add(J);const He=ib(i,r).filter($t=>$t.name!==ae?.name);if(He.length===0)return;let tt=!1;return(async()=>{for(const $t of He){if(tt)return;try{if(!(await u.prStatus(t,e,$t.name))?.pr)continue;if(tt)return;ve(vt=>vt?.name===$t.name?vt:$t);return}catch{}}})(),()=>{tt=!0}},[e,Fe,t,u,i,ae?.name,k,je?.pr,r]),c.useEffect(()=>{D(_),P(_,{directory:t,branch:e,remoteName:ae?.name??null,canShow:Fe,github:u,githubAuthChecked:h,githubConnected:f?.connected??null})},[e,Fe,t,D,u,h,f?.connected,_,ae?.name,P]),c.useEffect(()=>(T(_),()=>{$(_)}),[_,T,$]),c.useEffect(()=>{const J=xr.get(k)??null;B(J?.title??fl(e)),j(J?.body??""),L(J?.draft??!1),me(J?.targetBaseBranch?kn(J.targetBaseBranch):kn(n));const He=si(i,{selectedRemoteName:J?.selectedRemoteName,trackingBranch:r});ve(tt=>tt?.name===He?.name?tt:He)},[n,e,i,k,r]),c.useEffect(()=>{nt({markInitialResolved:!0})},[_,nt]),c.useEffect(()=>{!Fe||!ae?.name||nt({force:!0,silent:!0,markInitialResolved:!0})},[Fe,nt,ae?.name]),c.useEffect(()=>{const J=je?.resolvedRemoteName?.trim();if(!J||ct.current)return;const He=i.find(tt=>tt.name===J);He&&ve(tt=>tt?.name===He.name?tt:He)},[i,je?.resolvedRemoteName]),c.useEffect(()=>{const J=()=>{const tt=Ws.getState().entries[_]?.lastRefreshAt??0;Date.now()-tt>6e4&&nt({force:!0,silent:!0})},He=()=>{document.visibilityState==="visible"&&J()};return window.addEventListener("focus",J),document.addEventListener("visibilitychange",He),()=>{window.removeEventListener("focus",J),document.removeEventListener("visibilitychange",He)}},[_,nt]),c.useEffect(()=>{h&&f?.connected===!1&&nt({force:!0,silent:!0,markInitialResolved:!0})},[h,f,nt]),c.useEffect(()=>{!t||!e||xr.set(k,{title:I,body:R,draft:M,additionalContext:W,targetBaseBranch:Q,selectedRemoteName:ae?.name,activeSegment:Ye})},[k,I,R,M,W,Q,ae?.name,t,e,Ye]),c.useEffect(()=>{const J=At.current;return()=>{J.forEach(He=>{window.clearTimeout(He)}),At.current=[]}},[]);const Xt=c.useCallback(async()=>{if(!ne&&t){ie(!0);try{const He={base:ye&&Be?.defaultBranchSha?Be.defaultBranchSha:Q,head:e};W&&(He.context=W);const tt=await Pf(t,He);tt.title?.trim()&&B(tt.title.trim()),tt.body?.trim()&&j(tt.body.trim()),l?.()}catch(J){const He=J instanceof Error?J.message:String(J);Re.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:He})}finally{ie(!1)}}},[W,e,Be?.defaultBranchSha,t,ne,l,Q,a,ye]),os=c.useCallback(async()=>{if(!u?.prCreate){Re.error(a("gitView.pr.toast.githubApiUnavailable"));return}const J=I.trim();if(!J){Re.error(a("gitView.pr.toast.titleRequired"));return}const He=Q.trim();if(!He){Re.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!ye&&He===e){Re.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}Z(!0);try{const tt=ga(r),bt=ye&&Be,$t=await u.prCreate({directory:t,title:J,head:e,base:He,...R.trim()?{body:R}:{},draft:M,...bt?{targetRepo:{owner:Be.owner,repo:Be.repo},headRemote:"origin"}:{...ae?{remote:ae.name}:{},...tt&&tt!==ae?.name?{headRemote:tt}:{}}});Re.success(a("gitView.pr.toast.prCreated")),U(_,Ot=>Ot&&{...Ot,pr:$t}),await nt({force:!0}),Ft()}catch(tt){const bt=tt instanceof Error?tt.message:String(tt);Re.error(a("gitView.pr.toast.createPrFailed"),{description:bt})}finally{Z(!1)}},[R,e,Be,t,M,u,_,nt,Ft,ae,Q,I,r,U,ye,a]),Ss=c.useCallback(async J=>{if(!u?.prMerge){Re.error(a("gitView.pr.toast.githubApiUnavailable"));return}le(!0);try{const He=await u.prMerge({directory:t,number:J.number,method:ce});He.merged?Re.success(a("gitView.pr.toast.prMerged")):Re.message(a("gitView.pr.toast.prNotMerged"),{description:He.message||a("gitView.pr.notMergeable")}),await nt({force:!0}),Ft()}catch(He){const tt=He instanceof Error?He.message:String(He);Re.error(a("gitView.pr.toast.mergeFailed"),{description:tt}),J.url&&qr(J.url)}finally{le(!1)}},[t,u,ce,nt,Ft,a]),qs=c.useCallback(async J=>{if(!u?.prReady){Re.error(a("gitView.pr.toast.githubApiUnavailable"));return}be(!0);try{await u.prReady({directory:t,number:J.number}),Re.success(a("gitView.pr.toast.markedReady")),await nt({force:!0}),Ft()}catch(He){const tt=He instanceof Error?He.message:String(He);Re.error(a("gitView.pr.toast.markReadyFailed"),{description:tt}),J.url&&qr(J.url)}finally{be(!1)}},[t,u,nt,Ft,a]),gs=c.useCallback(async J=>{if(!u?.prUpdate){Re.error(a("gitView.pr.toast.githubApiUnavailable"));return}const He=ge.trim();if(!He){Re.error(a("gitView.pr.toast.titleRequired"));return}V(!0);try{const tt=await u.prUpdate({directory:t,number:J.number,title:He,body:he});U(_,bt=>bt&&{...bt,pr:{...bt.pr??J,...tt}}),De(!1),Re.success(a("gitView.pr.toast.prUpdated")),await nt({force:!0}),Ft()}catch(tt){const bt=tt instanceof Error?tt.message:String(tt);Re.error(a("gitView.pr.toast.updatePrFailed"),{description:bt})}finally{V(!1)}},[t,he,ge,u,_,nt,Ft,U,a]);if(!Fe)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 is=je?.repo?.url||null,Mt=ye&&Be?.url?Be.url:is,Et=!!je?.canMerge,Jt=!!je?.connected,hs=h&&je?.connected===!1,as=tb(je),ps=as?`var(--pr-${as})`:"var(--status-info)",ys=as==="draft"?"git-pr-draft":as==="merged"?"git-merge":as==="closed"?"git-close-pull-request":"git-pull-request",rs=Le?[`${Le.state}${Le.draft?" (draft)":""}`,Le.mergeable===!1?a("gitView.pr.notMergeable"):null,Le.state==="open"&&typeof Le.mergeableState=="string"&&Le.mergeableState&&Le.mergeableState!=="unknown"?Le.mergeableState:null].filter(Boolean).join(" · "):"",yn=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:[Le?s.jsxs(lt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{qr(Le.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(O,{name:ys,className:"size-4 shrink-0",style:{color:ps}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(O,{name:ys,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")}),Le?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",Le.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[ke?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):null,s.jsxs(gt,{children:[s.jsx(ht,{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:ke,onClick:()=>{nt({force:!0})},"aria-label":a("gitView.pr.actions.refreshAria"),children:s.jsx(O,{name:"refresh",className:"size-3.5 text-muted-foreground"})})}),s.jsx(pt,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]})]})]}),Le?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:ps},children:rs}),qe?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${ul(qe.state)}`}),yn]}):null,r&&ae&&r.split("/")[0]!==ae.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",ae.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[N?s.jsxs(lt,{variant:"outline",size:"sm",className:Pe("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Qg),onClick:()=>{v(t,{kind:"pr",number:Le.number}),y(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(O,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,Et&&Le.draft&&Le.state==="open"?s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx(lt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>qs(Le),disabled:pe||Y||G||Se,"aria-label":a("gitView.pr.actions.markReadyAria"),children:pe?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(pt,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,Et?s.jsxs(s.Fragment,{children:[s.jsxs(Ms,{value:ce,onValueChange:J=>H(J),disabled:Y||Le.state!=="open",children:[s.jsx(Os,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(Cs,{})}),s.jsxs(Bs,{children:[s.jsx(es,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(es,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(es,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx(lt,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>Ss(Le),disabled:Y||pe||Le.state!=="open"||Le.draft||G||Se,"aria-label":a("gitView.pr.actions.mergePrAria"),children:Y?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"git-merge",className:"size-4"})})}),s.jsx(pt,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[hs?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(lt,{variant:"outline",size:"sm",onClick:C,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,Ke?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:Ke}),Mt?s.jsx(lt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:Mt,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(O,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!Le&&!se&&!Ke&&!hs?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):Le&&!_t?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(fd,{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 ${ul(qe.state)}`}):void 0},{id:"comments",label:we?`${a("gitView.pr.segment.comments")} ${(we.issueComments?.length??0)+(we.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:Ye,onSelect:J=>et(J),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),Ye==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Et&&Le.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,Et?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:Se?s.jsx(hn,{value:ge,onChange:J=>re(J.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:Le.title})}),Le.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:Se?s.jsxs(s.Fragment,{children:[s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx(lt,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{De(!1),re(Le.title||""),Ne(Le.body||"")},disabled:G,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(O,{name:"close",className:"size-4"})})}),s.jsx(pt,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx(lt,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>gs(Le),disabled:G||!ge.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:G?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"check",className:"size-4"})})}),s.jsx(pt,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx(lt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>De(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(O,{name:"edit",className:"size-4"})})}),s.jsx(pt,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),Se?s.jsx(tr,{value:he,onChange:J=>Ne(J.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m}):null,Se?null:Le.body?.trim()?s.jsx(Ea,{content:Le.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(Ct?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,Ye==="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(O,{name:"loader-4",className:"size-3.5 animate-spin"}),ei(qe.startedAt,void 0,Ut)]}):null]}):null,qe?.failure?s.jsxs(lt,{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:at,disabled:Qt,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[Qt?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(we?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(we?.checkRuns??[]).map((J,He)=>{const tt=`${J.id??"run"}:${J.name}:${He}`,bt=J.status==="in_progress",$t=J.status==="queued",Ot=ti(J.conclusion),vt=ze.has(tt),ls=!!(J.output?.title||J.output?.summary||J.output?.text||(J.annotations?.length??0)>0||(J.job?.steps?.length??0)>0||J.detailsUrl),bs=J.job?.workflowName,ts=bt?ei(J.startedAt,void 0,Ut):ei(J.startedAt,J.completedAt);return s.jsxs("div",{className:Pe("rounded-md border border-border/40",Ot&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!ls,onClick:()=>{$e(Qs=>{const Ys=new Set(Qs);return Ys.has(tt)?Ys.delete(tt):Ys.add(tt),Ys})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[bt?s.jsx(O,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):$t?s.jsx(O,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):Ot?s.jsx(O,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(O,{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:bs&&bs!==J.name?`${bs} / ${J.name}`:J.name}),ts?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:ts}):null,ls?s.jsx(O,{name:"arrow-down-s",className:Pe("size-4 shrink-0 text-muted-foreground transition-transform",vt&&"rotate-180")}):null]}),vt&&ls?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:ms(J,{hideHeader:!0})}):null]},tt)})}):dt?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(O,{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,Ye==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Lt.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(lt,{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:ut,disabled:Ve,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Ve?s.jsx(O,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(O,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,Lt.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:Lt.map((J,He)=>{const tt=(J.authorName||"?").charAt(0).toUpperCase(),bt=He===Lt.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[bt?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:J.avatarUrl?s.jsx("img",{src:J.avatarUrl,alt:J.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:tt})}),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:[J.authorName,J.authorLogin&&J.authorLogin!==J.authorName?` · @${J.authorLogin}`:""]}),J.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:It(J.createdAt)}):null,s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsxs(lt,{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:()=>{St(J)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(O,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(pt,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[J.context,J.path?` · ${J.path}`:"",J.line?`:${J.line}`:""]}),s.jsx(Ea,{content:ns(J.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",Tt].filter(Boolean).join(" "),enableFileReferences:!1})]})]},J.id)})})}):dt&&!we?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(O,{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:[Le&&_t?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border/60 bg-surface-muted/40 px-2.5 py-2",children:[s.jsx(O,{name:Le.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:ps}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Le.state==="merged"?a("gitView.pr.history.merged",{number:Le.number,base:Le.base||Q}):a("gitView.pr.history.closed",{number:Le.number})}),s.jsx(lt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{qr(Le.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(O,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",Q," ",s.jsxs("span",{className:"opacity-60",children:["(",ye&&Be?"upstream":"remote",")"]})]})]}),Mt?s.jsx(lt,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:Mt,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(O,{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(hn,{value:I,onChange:J=>B(J.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),Ie.length>0?s.jsxs(Ms,{value:Q,onValueChange:me,children:[s.jsx(Os,{size:"lg",children:s.jsx(Cs,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(Bs,{children:Ie.map(J=>s.jsx(es,{value:J,children:J},J))})]}):s.jsx(hn,{value:Q,onChange:J=>me(J.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(tr,{value:R,onChange:J=>j(J.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":M,onClick:()=>L(J=>!J),onKeyDown:J=>{(J.key===" "||J.key==="Enter")&&(J.preventDefault(),L(He=>!He))},children:[s.jsx(nr,{size:"sm",checked:M,onChange:J=>L(J),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),g?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(lt,{variant:"outline",size:"sm",onClick:()=>z(!0),children:W.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),W.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(ji,{open:de,onOpenChange:oe,children:[s.jsxs(md,{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:de?a("gitView.pr.actions.hide"):W.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(ki,{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(tr,{value:W,onChange:J=>te(J.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(zo,{open:K,onClose:()=>z(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(lt,{size:"sm",onClick:()=>z(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(tr,{value:W,onChange:J=>te(J.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(lt,{variant:"outline",size:"sm",onClick:Xt,disabled:ne||F,children:[ne?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(lt,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:os,disabled:F||!Jt||!Q.trim()||!ye&&Q.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:F?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},cb=t=>{const{remoteNames:e,localBranches:n,worktreeCreatedFromBranch:r,rootBranchHint:i,defaultBranch:o,headBranch:l}=t,a=typeof l=="string"?l.trim():"",d=b=>{if(!b)return"";let w=b.trim();if(!w||w==="HEAD")return"";if(n.includes(w))return w;w.startsWith("refs/heads/")&&(w=w.slice(11)),w.startsWith("heads/")&&(w=w.slice(6)),w.startsWith("remotes/")&&(w=w.slice(8));const S=w.indexOf("/");if(S>0){const g=w.slice(0,S);if(e.has(g)){const m=w.slice(S+1).trim();m&&(w=m)}}return w},u=b=>{const w=d(typeof b=="string"?b:"");return w&&w!==a?w:""},f=u(r);if(f)return f;const h=u(i);if(h)return h;const x=u(o);return x||(n.includes("main")?"main":n.includes("master")?"master":n.includes("develop")?"develop":"main")},v4=t=>{const{baseBranch:e,localBranches:n,remoteBranches:r}=t;return n.includes(e)?!0:r.some(i=>{const o=i.indexOf("/");return o>0&&i.slice(o+1)===e})},ni=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),Qr=new Map,Yr=new Map,vn=t=>`${ks()}::${t}`,db=()=>{const t=Je.c(86),{t:e}=ft(),{git:n}=xn(),r=zr(),i=ea(r??null),o=Oc(r??null),{ensureAll:l}=Pn(Kn(ub)),a=Qe(fb),d=Qe(mb),u=Qe(hb),f=Qe(pb);let h;t[0]!==r?(h=ni(r),t[0]=r,t[1]=h):h=t[1];const x=h;let b;if(t[2]!==f||t[3]!==x||t[4]!==u){e:{if(!x){b=void 0;break e}let fe;if(t[6]!==f||t[7]!==x){let ge;t[9]!==x?(ge=re=>ni(re.path)===x,t[9]=x,t[10]=ge):ge=t[10],fe=f.find(ge),t[6]=f,t[7]=x,t[8]=fe}else fe=t[8];const xe=fe;if(xe){b=xe;break e}for(const ge of u.values())if(ni(ge.path)===x){b=ge;break e}b=void 0}t[2]=f,t[3]=x,t[4]=u,t[5]=b}else b=t[5];const w=b;let S;t[11]!==a||t[12]!==w||t[13]!==d?.open||t[14]!==u?(S=()=>{if(a)return u.get(a)??w;if(d?.open)return w},t[11]=a,t[12]=w,t[13]=d?.open,t[14]=u,t[15]=S):S=t[15],d?.open;let g;t[16]!==S?(g=S(),t[16]=S,t[17]=g):g=t[17];const m=g;let p;t[18]!==a?(p=fe=>a?fe.getAttachment(a):void 0,t[18]=a,t[19]=p):p=t[19];const y=Tc(p),v=y&&!y.degraded&&!y.legacy?y.worktreeRoot??void 0:void 0,N=Lg(r,m,i?.current??void 0);let C,k;t[20]!==r||t[21]!==l||t[22]!==n?(C=()=>{!r||!n||l(r,n)},k=[r,l,n],t[20]=r,t[21]=l,t[22]=n,t[23]=C,t[24]=k):(C=t[23],k=t[24]),c.useEffect(C,k);const[A,D]=c.useState(null);let P;t[25]!==v||t[26]!==N?.projectDirectory?(P=()=>{const fe=v||N?.projectDirectory;if(!fe){D(null);return}let xe=!1;return Wo(fe).then(ge=>{if(xe)return;const re=ge.trim();D(re&&re!=="HEAD"?re:null)}).catch(()=>{xe||D(null)}),()=>{xe=!0}},t[25]=v,t[26]=N?.projectDirectory,t[27]=P):P=t[27];const T=N?.projectDirectory;let $;t[28]!==v||t[29]!==T?($=[v,T],t[28]=v,t[29]=T,t[30]=$):$=t[30],c.useEffect(P,$);let E;t[31]!==r?(E=()=>(r?Qr.get(vn(r)):void 0)??[],t[31]=r,t[32]=E):E=t[32];const[U,I]=c.useState(E);let B;t[33]!==r?(B=()=>(r?Yr.get(vn(r)):void 0)??null,t[33]=r,t[34]=B):B=t[34];const[R,j]=c.useState(B);let M,L;t[35]!==r||t[36]!==n?(M=()=>{if(!r||!n?.getRemotes){I([]);return}I(Qr.get(vn(r))??[]);let fe=!1;return n.getRemotes(r).then(xe=>{fe||(Qr.set(vn(r),xe??[]),I(xe??[]))}).catch(()=>{fe||I(Qr.get(vn(r))??[])}),()=>{fe=!0}},L=[r,n],t[35]=r,t[36]=n,t[37]=M,t[38]=L):(M=t[37],L=t[38]),c.useEffect(M,L);let W,te;t[39]!==r||t[40]!==n?(W=()=>{if(!r||!n?.getRemoteUrl){j(null);return}j(Yr.get(vn(r))??null);let fe=!1;return n.getRemoteUrl(r).then(xe=>{fe||(Yr.set(vn(r),xe),j(xe))}).catch(()=>{fe||j(Yr.get(vn(r))??null)}),()=>{fe=!0}},te=[r,n],t[39]=r,t[40]=n,t[41]=W,t[42]=te):(W=t[41],te=t[42]),c.useEffect(W,te);let Q;e:{if(!o?.all){let xe;t[43]===Symbol.for("react.memo_cache_sentinel")?(xe=[],t[43]=xe):xe=t[43],Q=xe;break e}let fe;t[44]!==o.all?(fe=o.all.filter(gb).sort(),t[44]=o.all,t[45]=fe):fe=t[45],Q=fe}const me=Q;let ce;e:{if(!o?.all){let xe;t[46]===Symbol.for("react.memo_cache_sentinel")?(xe=[],t[46]=xe):xe=t[46],ce=xe;break e}let fe;t[47]!==o.all?(fe=o.all.filter(bb).map(xb).sort(),t[47]=o.all,t[48]=fe):fe=t[48],ce=fe}const H=ce;let ne;t[49]!==H||t[50]!==R||t[51]!==U||t[52]!==i?.tracking?(ne=()=>{if(U.length>0)return U;const fe=new Set,xe=i?.tracking?.trim();xe&&xe.includes("/")&&fe.add(xe.split("/")[0]);for(const ge of H){const re=ge.indexOf("/");re>0&&fe.add(ge.slice(0,re))}return fe.size===0&&R&&fe.add("origin"),Array.from(fe).map(ge=>({name:ge,fetchUrl:R??"",pushUrl:R??""}))},t[49]=H,t[50]=R,t[51]=U,t[52]=i?.tracking,t[53]=ne):ne=t[53],i?.tracking;let ie;t[54]!==ne?(ie=ne(),t[54]=ne,t[55]=ie):ie=t[55];const F=ie,Z=i?.current??null;i?.tracking;let G;t[56]!==i?.tracking?(G=i?.tracking?.trim().split("/")[0],t[56]=i?.tracking,t[57]=G):G=t[57];const V=G,Y=(V&&o?.defaultBranches?.[V])??o?.defaultBranches?.origin;let le;t[58]!==Z||t[59]!==Y||t[60]!==F||t[61]!==me||t[62]!==A||t[63]!==N?.createdFromBranch?(le=()=>cb({remoteNames:new Set(F.map(yb)),localBranches:me,worktreeCreatedFromBranch:N?.createdFromBranch,rootBranchHint:A,defaultBranch:Y,headBranch:Z}),t[58]=Z,t[59]=Y,t[60]=F,t[61]=me,t[62]=A,t[63]=N?.createdFromBranch,t[64]=le):le=t[64],N?.createdFromBranch;let pe;t[65]!==le?(pe=le(),t[65]=le,t[66]=pe):pe=t[66];const be=pe;if(!r||!Z){let fe;t[67]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx(O,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=fe):fe=t[67];let xe;t[68]!==e?(xe=e("gitView.pullRequest.title"),t[68]=e,t[69]=xe):xe=t[69];let ge;t[70]!==xe?(ge=s.jsx("div",{className:"typography-ui-header text-foreground",children:xe}),t[70]=xe,t[71]=ge):ge=t[71];let re;t[72]!==e?(re=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=re):re=t[73];let he;t[74]!==re?(he=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:re}),t[74]=re,t[75]=he):he=t[75];let Ne;return t[76]!==ge||t[77]!==he?(Ne=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[fe,ge,he]}),t[76]=ge,t[77]=he,t[78]=Ne):Ne=t[78],Ne}const Se=i?.tracking??void 0;let De;return t[79]!==be||t[80]!==Z||t[81]!==r||t[82]!==H||t[83]!==U||t[84]!==Se?(De=s.jsx(pn,{as:ta,outerClassName:"h-full min-h-0",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(lb,{directory:r,branch:Z,baseBranch:be,trackingBranch:Se,remotes:U,remoteBranches:H})}),t[79]=be,t[80]=Z,t[81]=r,t[82]=H,t[83]=U,t[84]=Se,t[85]=De):De=t[85],De};function ub(t){return{ensureAll:t.ensureAll}}function fb(t){return t.currentSessionId}function mb(t){return t.newSessionDraft}function hb(t){return t.worktreeMetadata}function pb(t){return t.availableWorktrees}function gb(t){return!t.startsWith("remotes/")}function bb(t){return t.startsWith("remotes/")}function xb(t){return t.replace(/^remotes\//,"")}function yb(t){return t.name}const Ei=5e3,wb=(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},Xr=(t,e)=>Mf(Of.getState().dictionary,t,e),Sb=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"},vb=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 i=await ss(`/api/fs/read?${r.toString()}`,{cache:"no-store",headers:n?.directory?{"x-opencode-directory":n.directory}:void 0});if(!i.ok){const o=await i.json().catch(()=>({error:i.statusText}));throw new Error(o.error||"Failed to read file")}return i.text()},Kd=async(t,e,n)=>{if(If(e)||Tf(e)||Ef(e))return{ok:!0};try{const r=await vb(t,e,n);return Rf(r)?{ok:!1,reason:"binary"}:wb(r,Ei)>Ei?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:Sb(r)}}},Gd=t=>{if(t==="too-large"){const e=Ei.toLocaleString(Xi());return Xr("contextFileOpen.failure.tooLarge",{count:e})}return Xr(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},ml=3,rr=t=>Array.from(t.types).includes("Files"),jb=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},hl=t=>{const e=t.name;return!e||e==="."||e===".."||e.includes("/")||e.includes("\\")?null:e},kb=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),ds=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},ba=(t,e)=>{const n=ds(e),r=ds(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Cb=(t,e)=>{const n=ba(t,e);if(n!==".")return n;const r=ds(t);return r.split("/").filter(Boolean).pop()??r},Nb=t=>{const e=ds(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},Ab=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),Db=new Set(["node_modules"]),Pb=t=>Db.has(t),Ib=t=>{const e=ds(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Tb=8,rn=new Map,xa=t=>JSON.stringify([ks(),t]),Eb=t=>{const e=xa(t),n=rn.get(e);return n?(n.touchedAt=Date.now(),rn.delete(e),rn.set(e,n),n):null},ri=t=>{const e=xa(t),n=rn.get(e);if(n)return n.touchedAt=Date.now(),n;if(rn.size>=Tb){const i=rn.keys().next().value;i!==void 0&&rn.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return rn.set(e,r),r},Rb=t=>{rn.delete(xa(t))},qd=(t,e)=>s.jsx(sa,{filePath:t,extension:e}),Mb=t=>{const e=Je.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 i=r[n];let o;return e[1]!==i?(o=s.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i}}),e[1]=i,e[2]=o):o=e[2],o},Ob=t=>{const e=Je.c(84),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:d,isDropTarget:u,canUpload:f,permissions:h,downloadFile:x,onSelect:b,onToggle:w,onRevealPath:S,onOpenDialog:g,onSetDropTarget:m,onDropFiles:p}=t,{t:y}=ft(),v=n.type==="directory";let N;e[0]!==v||e[1]!==n.path?(N=v?n.path:Nb(n.path),e[0]=v,e[1]=n.path,e[2]=N):N=e[2];const C=N,{canRename:k,canCreateFile:A,canCreateFolder:D,canDelete:P,canReveal:T}=h,$=!v&&!!x,E=T&&!l,U=k||A||D||P||$||E,[I,B]=c.useState(!1),[R,j]=c.useState(!1);let M;e[3]!==U?(M=K=>{U&&(K?.preventDefault(),j(!0))},e[3]=U,e[4]=M):M=e[4];const L=M;let W;e[5]!==v||e[6]!==n||e[7]!==b||e[8]!==w?(W=()=>{v?w(n.path):b(n)},e[5]=v,e[6]=n,e[7]=b,e[8]=w,e[9]=W):W=e[9];const te=W;let Q;e[10]===Symbol.for("react.memo_cache_sentinel")?(Q=K=>{K.stopPropagation(),j(!1),B(!0)},e[10]=Q):Q=e[10];const me=Q;let ce;e[11]!==A||e[12]!==D||e[13]!==P||e[14]!==k||e[15]!==E||e[16]!==x||e[17]!==l||e[18]!==v||e[19]!==n||e[20]!==g||e[21]!==S||e[22]!==y?(ce=K=>{const{Item:z,Separator:ae}=K;return s.jsxs(s.Fragment,{children:[k&&s.jsxs(z,{onClick:ve=>{ve.stopPropagation(),g("rename",n)},children:[s.jsx(O,{name:"edit",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.rename")]}),s.jsxs(z,{onClick:ve=>{ve.stopPropagation(),an(n.path).then(ye=>{if(ye.ok){Re.success(y("sidebarFilesTree.toast.pathCopied"));return}Re.error(y("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(O,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.copyPath")]}),!v&&x&&s.jsxs(z,{onClick:ve=>{ve.stopPropagation(),x(n.path).catch(ye=>{console.error("Download failed:",ye),Re.error(y("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(O,{name:"download",className:"mr-2 h-4 w-4"})," ",y(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),E&&s.jsxs(z,{onClick:ve=>{ve.stopPropagation(),S(n.path)},children:[s.jsx(O,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",y(Ac())]}),v&&(A||D)&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{}),A&&s.jsxs(z,{onClick:ve=>{ve.stopPropagation(),g("createFile",n)},children:[s.jsx(O,{name:"file-add",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFile")]}),D&&s.jsxs(z,{onClick:ve=>{ve.stopPropagation(),g("createFolder",n)},children:[s.jsx(O,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFolder")]})]}),P&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{}),s.jsxs(z,{onClick:ve=>{ve.stopPropagation(),g("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(O,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.delete")]})]})]})},e[11]=A,e[12]=D,e[13]=P,e[14]=k,e[15]=E,e[16]=x,e[17]=l,e[18]=v,e[19]=n,e[20]=g,e[21]=S,e[22]=y,e[23]=ce):ce=e[23];const H=ce;let ne;e[24]!==n.path||e[25]!==r?(ne=K=>{const z=ba(r,n.path);!z||z==="."||(K.dataTransfer.setData("application/x-openchamber-file-path",z),K.dataTransfer.effectAllowed="copy")},e[24]=n.path,e[25]=r,e[26]=ne):ne=e[26];const ie=ne;let F;e[27]!==f||e[28]!==m||e[29]!==C?(F=K=>{!f||!C||!rr(K.dataTransfer)||(K.preventDefault(),K.stopPropagation(),K.dataTransfer.dropEffect="copy",m(C))},e[27]=f,e[28]=m,e[29]=C,e[30]=F):F=e[30];const Z=F;let G;e[31]!==f||e[32]!==m||e[33]!==C?(G=K=>{!f||!C||!rr(K.dataTransfer)||K.relatedTarget instanceof Node&&K.currentTarget.contains(K.relatedTarget)||(K.stopPropagation(),m(null))},e[31]=f,e[32]=m,e[33]=C,e[34]=G):G=e[34];const V=G;let Y;e[35]!==f||e[36]!==p||e[37]!==C?(Y=K=>{!f||!C||!rr(K.dataTransfer)||(K.preventDefault(),K.stopPropagation(),p(C,K.dataTransfer))},e[35]=f,e[36]=p,e[37]=C,e[38]=Y):Y=e[38];const le=Y;let pe;e[39]!==L||e[40]!==V||e[41]!==Z||e[42]!==le?(pe=s.jsx("div",{className:"group relative flex items-center",onContextMenu:L,onDragEnter:Z,onDragOver:Z,onDragLeave:V,onDrop:le}),e[39]=L,e[40]=V,e[41]=Z,e[42]=le,e[43]=pe):pe=e[43];const be=u?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let Se;e[44]!==be?(Se=Pe("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",be,"cursor-grab active:cursor-grabbing"),e[44]=be,e[45]=Se):Se=e[45];let De;e[46]!==v||e[47]!==i||e[48]!==n.extension||e[49]!==n.path?(De=v?i?s.jsx(O,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(O,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):qd(n.path,n.extension),e[46]=v,e[47]=i,e[48]=n.extension,e[49]=n.path,e[50]=De):De=e[50];let fe;e[51]!==n.name||e[52]!==n.path?(fe=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[51]=n.name,e[52]=n.path,e[53]=fe):fe=e[53];let xe;e[54]!==v||e[55]!==a?(xe=!v&&a&&s.jsx(Mb,{status:a}),e[54]=v,e[55]=a,e[56]=xe):xe=e[56];let ge;e[57]!==d||e[58]!==v?(ge=v&&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[57]=d,e[58]=v,e[59]=ge):ge=e[59];let re;e[60]!==L||e[61]!==ie||e[62]!==te||e[63]!==Se||e[64]!==De||e[65]!==fe||e[66]!==xe||e[67]!==ge?(re=s.jsxs("button",{type:"button",onClick:te,onContextMenu:L,draggable:!0,onDragStart:ie,className:Se,children:[De,fe,xe,ge]}),e[60]=L,e[61]=ie,e[62]=te,e[63]=Se,e[64]=De,e[65]=fe,e[66]=xe,e[67]=ge,e[68]=re):re=e[68];let he;e[69]!==I||e[70]!==U||e[71]!==H||e[72]!==y?(he=U&&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(Ks,{open:I,onOpenChange:B,children:[s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Us,{asChild:!0,children:s.jsx(lt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:me,title:y("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":y("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(O,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(pt,{side:"bottom",sideOffset:6,children:y("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(Hs,{align:"end",side:"bottom",onCloseAutoFocus:()=>B(!1),children:H({Item:Wt,Separator:Rs})})]})}),e[69]=I,e[70]=U,e[71]=H,e[72]=y,e[73]=he):he=e[73];let Ne;e[74]!==pe||e[75]!==re||e[76]!==he?(Ne=s.jsxs(gd,{render:pe,children:[re,he]}),e[74]=pe,e[75]=re,e[76]=he,e[77]=Ne):Ne=e[77];let de;e[78]!==H?(de=s.jsx(hd,{className:"min-w-[180px]",children:H({Item:pd,Separator:Bh})}),e[78]=H,e[79]=de):de=e[79];let oe;return e[80]!==R||e[81]!==Ne||e[82]!==de?(oe=s.jsxs(bd,{open:R,onOpenChange:j,children:[Ne,de]}),e[80]=R,e[81]=Ne,e[82]=de,e[83]=oe):oe=e[83],oe},Bb=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.canUpload===e.canUpload&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles,_b=c.memo(Ob,Bb),Fb=()=>{const{t}=ft(),{files:e,runtime:n}=xn(),r=$u(n.platform),i=zr()??"",o=ds(i.trim()),l=zu(),a=Wu(),d=vc(ee=>ee.searchFiles),u=Ce(ee=>ee.openContextFile),f=ea(i),[h,x]=c.useState(""),b=na(h,200),w=c.useRef(null),[S,g]=c.useState([]),[m,p]=c.useState(!1),[y,v]=c.useState(null),[N,C]=c.useState(!1),[k,A]=c.useState(null),D=c.useRef(!1),P=c.useRef(o);P.current=o;const[T,$]=c.useState({}),[E,U]=c.useState({}),I=c.useRef(new Set),B=c.useRef(new Set),R=c.useRef(null);c.useEffect(()=>{if(v(null),A(null),!o){$({}),U({}),I.current=new Set;return}const ee=Eb(o);ee?($({...ee.childrenByDir}),U({...ee.loadErrorsByDir}),I.current=new Set(ee.loadedDirs)):($({}),U({}),I.current=new Set)},[o]),c.useEffect(()=>{if(!o)return;const ee=ri(o);ee.childrenByDir=T},[o,T]),c.useEffect(()=>{if(!o)return;const ee=ri(o);ee.loadErrorsByDir=E},[o,E]),c.useEffect(()=>{if(!o)return;const ee=ri(o);ee.loadedDirs=new Set(I.current)},[o,T,E]),c.useEffect(()=>()=>{if(!o)return;const ee=rn.get(o);ee&&ee.loadedDirs.size===0&&Object.keys(ee.childrenByDir).length===0&&Rb(o)},[o]);const j=c.useMemo(()=>[],[]),M=c.useMemo(()=>[],[]),L=nn(ee=>o?ee.byRoot[o]?.expandedPaths??j:j),W=nn(ee=>o?ee.byRoot[o]?.selectedPath??null:null),te=nn(ee=>ee.setSelectedPath),Q=nn(ee=>ee.addOpenPath),me=nn(ee=>ee.removeOpenPathsByPrefix),ce=nn(ee=>ee.toggleExpandedPath),H=nn(ee=>ee.collapseAllExpandedPaths),ne=Ce(ee=>o?ee.contextPanelByDirectory[o]?.tabs??M:M),ie=c.useMemo(()=>new Set(ne.map(ee=>ee.mode==="file"?ee.targetPath:null).filter(ee=>typeof ee=="string"&&ee.length>0).map(ee=>ds(ee))),[ne]),[F,Z]=c.useState(null),[G,V]=c.useState(null),[Y,le]=c.useState(""),[pe,be]=c.useState(!1),Se=!!e.writeFile,De=!!e.createDirectory,fe=!!e.rename,xe=!!e.delete,ge=!!e.revealPath,re=!!e.uploadFile,he=c.useMemo(()=>({canRename:fe,canCreateFile:Se,canCreateFolder:De,canDelete:xe,canReveal:ge}),[fe,Se,De,xe,ge]),Ne=c.useCallback(ee=>{e.revealPath&&e.revealPath(ee).catch(()=>{Re.error(t("sidebarFilesTree.toast.revealFailed"))})},[e,t]),de=c.useCallback((ee,Ee)=>{Z(ee),V(Ee),le(ee==="rename"&&Ee.name||""),be(!1)},[]),oe=c.useCallback((ee,Ee)=>{const Ge=Ee.filter(ze=>ze&&typeof ze.name=="string"&&ze.name.length>0).filter(ze=>l||!ze.name.startsWith(".")).filter(ze=>a||!Pb(ze.name)).map(ze=>{const $e=ze.name,_e=ds(ze.path||""),Xe=_e?Ab(_e)?_e:ds(`${ee}/${_e}`):ds(`${ee}/${$e}`),ct=ze.isDirectory?"directory":"file",Nt=ct==="file"&&$e.includes(".")?$e.split(".").pop()?.toLowerCase():void 0;return{name:$e,path:Xe,type:ct,extension:Nt}});return kb(Ge)},[a,l]),K=c.useCallback(async(ee,Ee)=>{const Ge=ds(ee.trim());if(!Ge||I.current.has(Ge)||B.current.has(Ge))return;B.current=new Set(B.current),B.current.add(Ge);const ze=e.listDirectory?e.listDirectory(Ge).then($e=>$e.entries.map(_e=>({name:_e.name,path:_e.path,isDirectory:_e.isDirectory}))):Es.listLocalDirectory(Ge).then($e=>$e.map(_e=>({name:_e.name,path:_e.path,isDirectory:_e.isDirectory})));try{const $e=await ze;if(Ee?.())return;const _e=oe(Ge,$e);I.current=new Set(I.current),I.current.add(Ge),U(Xe=>{if(!Xe[Ge])return Xe;const ct={...Xe};return delete ct[Ge],ct}),$(Xe=>({...Xe,[Ge]:_e}))}catch($e){if(Ee?.())return;const _e=$e instanceof Error?$e.message:String($e??"");console.error("Failed to load sidebar directory:",$e),U(Xe=>({...Xe,[Ge]:_e}))}finally{B.current=new Set(B.current),B.current.delete(Ge)}},[e,oe]),z=c.useCallback(async()=>{if(!o)return;R.current?.abort();const ee=new AbortController;R.current=ee;try{const Ge=(nn.getState().byRoot[o]?.expandedPaths??[]).map(_e=>ds(_e)).filter(_e=>!!_e&&_e!==o&&_e.startsWith(`${o}/`)),ze=[o,...Ge];I.current=new Set(I.current);for(const _e of ze)I.current.delete(_e);U(_e=>{if(Object.keys(_e).length===0)return _e;const Xe={..._e};let ct=!1;for(const Nt of ze)Nt in Xe&&(delete Xe[Nt],ct=!0);return ct?Xe:_e});const $e=()=>ee.signal.aborted;await K(o,$e);for(let _e=0;_e<Ge.length&&!ee.signal.aborted;_e+=3){const Xe=Ge.slice(_e,_e+3);await Promise.all(Xe.map(ct=>K(ct,$e)))}}catch(Ee){if(ee.signal.aborted)return;console.error("Failed to refresh sidebar tree:",Ee)}finally{R.current===ee&&(R.current=null)}},[K,o]),ae=c.useCallback(async ee=>{if(!ee){await z();return}const Ee=ds(ee);I.current=new Set(I.current),I.current.delete(Ee),B.current=new Set(B.current),B.current.delete(Ee),await K(Ee)},[K,z]);c.useEffect(()=>{o&&(R.current?.abort(),I.current=new Set,B.current=new Set,U({}),$(ee=>Object.keys(ee).length===0?ee:{}),K(o))},[K,o,l,a]),c.useEffect(()=>{if(!o||L.length===0)return;const ee=L.map(ze=>ds(ze)).filter(ze=>!!ze&&ze!==o&&ze.startsWith(`${o}/`)&&!I.current.has(ze)&&!B.current.has(ze)).sort((ze,$e)=>ze.split("/").length-$e.split("/").length);if(ee.length===0)return;let Ee=!1;const Ge=()=>Ee;return(async()=>{for(let ze=0;ze<ee.length&&!Ee;ze+=3){const $e=ee.slice(ze,ze+3);await Promise.all($e.map(_e=>K(_e,Ge)))}})(),()=>{Ee=!0}},[L,K,o]),c.useEffect(()=>{if(!i){g([]),p(!1);return}const ee=b.trim();if(!ee){g([]),p(!1);return}let Ee=!1;return p(!0),d(i,ee,150,{includeHidden:l,respectGitignore:!a,type:"file"}).then(Ge=>{if(Ee)return;const $e=Ge.filter(_e=>a||!Ib(_e.path)).map(_e=>({name:_e.name,path:ds(_e.path),type:"file",extension:_e.extension,relativePath:_e.relativePath}));g($e)}).catch(()=>{Ee||g([])}).finally(()=>{Ee||p(!1)}),()=>{Ee=!0}},[i,b,d,l,a]);const ve=c.useMemo(()=>{const ee=new Map;if(!f?.files)return ee;for(const Ee of f.files)Ee.index==="A"||Ee.working_dir==="?"?ee.set(Ee.path,"git-added"):Ee.index==="D"?ee.set(Ee.path,"git-deleted"):(Ee.index==="M"||Ee.working_dir==="M")&&ee.set(Ee.path,"git-modified");return ee},[f]),ye=c.useMemo(()=>{const ee=new Map;if(!f?.files||!o)return ee;for(const Ee of f.files){const Ge=Ee.index==="M"||Ee.working_dir==="M",ze=Ee.index==="A"||Ee.working_dir==="?";if(!Ge&&!ze)continue;const $e=Ee.path.split("/");if($e.length<=1)continue;let _e=o;for(let Xe=0;Xe<$e.length-1;Xe++){_e=`${_e}/${$e[Xe]}`;let ct=ee.get(_e);ct||(ct={modified:0,added:0},ee.set(_e,ct)),Ge&&ct.modified++,ze&&ct.added++}}return ee},[f,o]),We=c.useCallback(ee=>{if(ie.has(ee))return"open";if(ve.size===0)return null;const Ee=ee.startsWith(o+"/")?ee.slice(o.length+1):ee;return ve.get(Ee)??null},[ie,ve,o]),Be=c.useCallback(ee=>{if(ye.size===0)return null;const Ee=ye.get(ee);return Ee&&Ee.modified+Ee.added>0?Ee:null},[ye]),Ae=c.useCallback(async ee=>{if(!o)return;const Ee=await Kd(e,ee.path,{directory:o});if(!Ee.ok){Re.error(Gd(Ee.reason));return}te(o,ee.path),Q(o,ee.path),u(o,ee.path)},[Q,e,u,o,te]),X=c.useCallback(async ee=>{const Ee=ds(ee);o&&(ce(o,Ee),I.current.has(Ee)||await K(Ee))},[K,o,ce]),Oe=c.useCallback(async(ee,Ee,Ge=!1)=>{const ze=e.uploadFile;if(!ze||Ee.length===0||D.current||!o)return;const $e=o,_e=ks();D.current=!0,C(!0),v(ee),Ge&&A(null);const Xe=[];for(let mt=0;mt<Ee.length;mt+=ml){const Rt=Ee.slice(mt,mt+ml),Dt=await Promise.all(Rt.map(async xt=>{const we=hl(xt);if(!we||ks()!==_e)return"failed";try{return(await ze(ds(`${ee}/${we}`),xt,{directory:$e,overwrite:Ge})).success?"uploaded":"failed"}catch(dt){return!Ge&&Vu(dt)&&dt.reason==="already-exists"?"conflict":"failed"}}));Xe.push(...Dt)}const ct=Xe.filter(mt=>mt==="uploaded").length,Nt=Xe.filter(mt=>mt==="failed").length,At=Ee.filter((mt,Rt)=>Xe[Rt]==="conflict"),Le=Ee.flatMap((mt,Rt)=>{const Dt=hl(mt);return Xe[Rt]==="uploaded"&&Dt?[ds(`${ee}/${Dt}`)]:[]}),_t=P.current===$e&&ks()===_e;try{Le.length>0&&Zh({runtimeKey:_e,paths:Le}),ct>0&&_t&&await ae(ee),ct>0&&Re.success(t(At.length>0?"sidebarFilesTree.toast.uploadedWithoutConflicts":"sidebarFilesTree.toast.uploaded")),Nt>0&&Re.error(t("sidebarFilesTree.toast.uploadFailed")),At.length>0&&_t&&A({directory:ee,files:At,runtimeKey:_e,workspaceRoot:$e})}finally{D.current=!1,C(!1),v(null)}},[e.uploadFile,ae,o,t]),Fe=c.useCallback((ee,Ee)=>{const Ge=jb(Ee);Ge.length!==0&&Oe(ee,Ge)},[Oe]),_=c.useCallback(ee=>{!re||D.current||!o||!rr(ee.dataTransfer)||(ee.preventDefault(),ee.dataTransfer.dropEffect="copy",v(o))},[re,o]),ue=c.useCallback(ee=>{rr(ee.dataTransfer)&&(ee.relatedTarget instanceof Node&&ee.currentTarget.contains(ee.relatedTarget)||v(null))},[]),ke=c.useCallback(ee=>{!re||D.current||!o||!rr(ee.dataTransfer)||(ee.preventDefault(),Fe(o,ee.dataTransfer))},[re,Fe,o]),je=c.useCallback(async ee=>{if(ee?.preventDefault(),!G||!F)return;be(!0);const Ee=()=>be(!1),Ge=()=>Z(null);if(F==="createFile"){if(!Y.trim()){Re.error(t("sidebarFilesTree.toast.filenameRequired")),Ee();return}if(!e.writeFile){Re.error(t("sidebarFilesTree.toast.writeNotSupported")),Ee();return}const ze=G.path,$e=ze?`${ze}/`:"",_e=ds(`${$e}${Y.trim()}`);await e.writeFile(_e,"").then(async Xe=>{Xe.success&&(Re.success(t("sidebarFilesTree.toast.fileCreated")),await ae(ze)),Ge()}).catch(()=>Re.error(t("sidebarFilesTree.toast.operationFailed"))).finally(Ee);return}if(F==="createFolder"){if(!Y.trim()){Re.error(t("sidebarFilesTree.toast.folderNameRequired")),Ee();return}const ze=G.path,$e=ze?`${ze}/`:"",_e=ds(`${$e}${Y.trim()}`);await e.createDirectory(_e).then(async Xe=>{Xe.success&&(Re.success(t("sidebarFilesTree.toast.folderCreated")),await ae(ze)),Ge()}).catch(()=>Re.error(t("sidebarFilesTree.toast.operationFailed"))).finally(Ee);return}if(F==="rename"){if(!Y.trim()){Re.error(t("sidebarFilesTree.toast.nameRequired")),Ee();return}if(!e.rename){Re.error(t("sidebarFilesTree.toast.renameNotSupported")),Ee();return}const ze=G.path,$e=ze.split("/").slice(0,-1).join("/"),_e=$e?`${$e}/`:"",Xe=ds(`${_e}${Y.trim()}`);await e.rename(ze,Xe).then(async ct=>{ct.success&&(Re.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await ae($e),o&&me(o,ze),(W===ze||W&&W.startsWith(`${ze}/`))&&te(o,null)),Ge()}).catch(()=>Re.error(t("sidebarFilesTree.toast.operationFailed"))).finally(Ee);return}if(F==="delete"){if(!e.delete){Re.error(t("sidebarFilesTree.toast.deleteNotSupported")),Ee();return}const ze=G.path,$e=ze.split("/").slice(0,-1).join("/");await e.delete(ze).then(async _e=>{_e.success&&(Re.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await ae($e),o&&me(o,ze),(W===ze||W&&W.startsWith(ze+"/"))&&te(o,null)),Ge()}).catch(()=>Re.error(t("sidebarFilesTree.toast.operationFailed"))).finally(Ee);return}Ee()},[F,G,Y,e,ae,me,o,W,te,t]);function Ke(ee,Ee){const Ge=T[ee]??[];return Ge.map((ze,$e)=>{const _e=ze.type==="directory",Xe=_e&&L.includes(ze.path),ct=W===ze.path,Nt=$e===Ge.length-1;return s.jsxs("li",{className:"relative",children:[Ee>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),Nt&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(_b,{node:ze,root:o,isExpanded:Xe,isActive:ct,isBrowserClient:r,status:_e?void 0:We(ze.path),badge:_e?Be(ze.path):void 0,isDropTarget:_e&&y===ze.path,canUpload:re&&!N,permissions:he,downloadFile:e.downloadFile,onSelect:Ae,onToggle:X,onRevealPath:Ne,onOpenDialog:de,onSetDropTarget:v,onDropFiles:Fe}),_e&&Xe&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[E[ze.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:E[ze.path],children:E[ze.path]}),s.jsxs(lt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{ae(ze.path)},children:[s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"}),t("sidebarFilesTree.actions.refreshTitle")]})]}):null,Ke(ze.path,Ee+1)]})]},ze.path)})}const se=!!(o&&T[o]),Ie=o?E[o]:null,Ye=y?Cb(o,y):"";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:[Se&&s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(lt,{variant:"ghost",size:"sm",onClick:()=>de("createFile",{path:i,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(O,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(pt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.newFileTitle")})]}),De&&s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(lt,{variant:"ghost",size:"sm",onClick:()=>de("createFolder",{path:i,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(O,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(pt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.newFolderTitle")})]}),s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(lt,{variant:"ghost",size:"sm",onClick:()=>{z()},className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.refreshTitle"),"aria-label":t("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(O,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(pt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(lt,{variant:"ghost",size:"sm",onClick:()=>{o&&H(o)},className:"h-8 w-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":t("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(O,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(pt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(O,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(hn,{ref:w,value:h,onChange:ee=>x(ee.target.value),placeholder:t("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),h.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:()=>{x(""),w.current?.focus()},children:s.jsx(O,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(pn,{outerClassName:"h-full min-h-0",className:Pe("p-2",y===o&&"bg-interactive-selection/10"),onDragEnter:_,onDragOver:_,onDragLeave:ue,onDrop:ke,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(O,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("sidebarFilesTree.state.searching")]}):S.length>0?S.map(ee=>{const Ee=W===ee.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>Ae(ee),draggable:!0,onDragStart:Ge=>{const ze=ee.relativePath||ba(o??"",ee.path);!ze||ze==="."||(Ge.dataTransfer.setData("application/x-openchamber-file-path",ze),Ge.dataTransfer.effectAllowed="copy")},className:Pe("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",Ee?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:ee.path,children:[qd(ee.path,ee.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:ee.relativePath??ee.path})]})},ee.path)}):Ie?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:Ie}),s.jsxs(lt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{z()},children:[s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"}),t("sidebarFilesTree.actions.refreshTitle")]})]}):se&&o?Ke(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("sidebarFilesTree.state.loading")})})}),y?s.jsxs("div",{className:"pointer-events-none absolute left-2 right-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(O,{name:N?"loader-4":"folder-received",className:Pe("size-4 flex-shrink-0",N&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Ye,children:t(N?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Ye})})]}):null]}),s.jsx(Ns,{open:!!k,onOpenChange:ee=>!ee&&A(null),children:s.jsxs(As,{children:[s.jsxs(Gs,{children:[s.jsx(Fs,{children:t("sidebarFilesTree.dialog.uploadConflicts.title")}),s.jsx(Ls,{children:t("sidebarFilesTree.dialog.uploadConflicts.description",{path:k?.directory??""})})]}),s.jsx(pn,{outerClassName:"max-h-52",className:"flex flex-col gap-1 pr-2",children:k?.files.map((ee,Ee)=>s.jsx("div",{className:"truncate rounded-md bg-muted px-2 py-1 typography-meta",title:ee.name,children:ee.name},`${ee.name}-${ee.size}-${Ee}`))}),s.jsxs(gn,{children:[s.jsx(lt,{variant:"outline",onClick:()=>A(null),disabled:N,children:t("sidebarFilesTree.dialog.cancel")}),s.jsx(lt,{onClick:()=>{if(k){if(k.runtimeKey!==ks()||k.workspaceRoot!==o){A(null);return}Oe(k.directory,k.files,!0)}},disabled:N,children:t("sidebarFilesTree.dialog.uploadConflicts.replace")})]})]})}),s.jsx(Ns,{open:!!F,onOpenChange:ee=>!ee&&Z(null),children:s.jsxs(As,{children:[s.jsxs(Gs,{children:[s.jsxs(Fs,{children:[F==="createFile"&&t("sidebarFilesTree.dialog.createFile.title"),F==="createFolder"&&t("sidebarFilesTree.dialog.createFolder.title"),F==="rename"&&t("sidebarFilesTree.dialog.rename.title"),F==="delete"&&t("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Ls,{children:[F==="createFile"&&t("sidebarFilesTree.dialog.createFile.description",{path:G?.path??t("sidebarFilesTree.dialog.rootFallback")}),F==="createFolder"&&t("sidebarFilesTree.dialog.createFolder.description",{path:G?.path??t("sidebarFilesTree.dialog.rootFallback")}),F==="rename"&&t("sidebarFilesTree.dialog.rename.description",{name:G?.name??""}),F==="delete"&&t("sidebarFilesTree.dialog.delete.description",{name:G?.name??""})]})]}),F!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(hn,{value:Y,onChange:ee=>le(ee.target.value),placeholder:t(F==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:ee=>{ee.key==="Enter"&&je()},autoFocus:!0})}),s.jsxs(gn,{children:[s.jsx(lt,{variant:"outline",onClick:()=>Z(null),disabled:pe,children:t("sidebarFilesTree.dialog.cancel")}),s.jsx(lt,{variant:F==="delete"?"destructive":"default",onClick:()=>{je()},disabled:pe||F!=="delete"&&!Y.trim(),children:pe?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):t(F==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})},pl=60,Lb=t=>{try{return new URL(t).origin}catch{return""}},oi=new Set,Qd=Yn()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=Lb(n);!i||!r||e().byOrigin[i]||oi.has(i)||(oi.add(i),Cr("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const d={...a.byOrigin,[i]:l},u=Object.keys(d);if(u.length<=pl)return{byOrigin:d};for(const f of u.slice(0,u.length-pl))delete d[f];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{oi.delete(i)}))}})),ya=t=>t,Ri=t=>{const e=ya(t).type;return typeof e=="string"?e:""},$b=t=>{const e=ya(t).tool;return typeof e=="string"?e:""},zb=t=>{const e=ya(t).text;return typeof e=="string"?e:""},Wb=t=>{const e=Ri(t);return e==="tool"?$b(t).trim().toLowerCase()||"tool":e||"unknown"},Vb=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=Wb(n);e.includes(r)||e.push(r)}return e.join(" + ")},Ub=t=>t.replace(/\s+/g," ").trim(),Hb=t=>{for(const n of t)if(Ri(n)==="text"){const r=Ub(zb(n));if(r.length===0)continue;return r}const e=t.filter(n=>Ri(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Kb=(t,e,n)=>`${n(t)} / ${n(e)}`,Gb=t=>{if(t==="12h")return!0;if(t==="24h")return!1},qb=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=Gb(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}})},Mi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},fo={user:0,assistant:0,tool:0,other:0},Cn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,ii=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof n=="number")return{...Mi,total:Cn(n)};if(!n||typeof n!="object")return Mi;const r=n,i=Cn(r.input),o=Cn(r.output),l=Cn(r.reasoning),a=Cn(r.cache?.read),d=Cn(r.cache?.write),u=Cn(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:d,total:u>0?u:i+o+l+a+d}},Qb=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},zs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+zs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+zs(n),0):0,Yb=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...fo,assistant:zs(n.text)+zs(n.content)};const i=Qb(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:zs(n.input)+zs(n.output)+zs(n.error)+zs(n.call?.input)+zs(n.call?.output)+zs(n.call?.error)+zs(n.raw)+Math.round(zs(n.metadata)*.25)+Math.round(zs(n.state)*.1),other:0}:e==="user"?{user:i.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},gl=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),Xb=t=>{const e=Wr(t.info);return e.isUser?"user":e.role==="assistant"?"assistant":e.role==="tool"?"tool":"other"},Jb=(t,e)=>{if(t.length===0)return{...fo};const n=t.reduce((r,i)=>{const o=Xb(i);let l={...fo};for(const a of i.parts)l=gl(l,Yb(a,o));return gl(r,l)},{...fo});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)}},Ln=t=>t.toLocaleString(Xi()),Zb=(t,e)=>!t||!Number.isFinite(t)?"-":Mc(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),ex=(t,e,n)=>{const r=t.find(o=>o.id===e),i=r?.models?.find(o=>o.id===n);return{providerName:r?.name||e||"-",modelName:i?.name||n||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},tx=()=>{const t=Je.c(203),{t:e}=ft(),n=Ce(sx);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[i,o]=c.useState(r),[l,a]=c.useState(null),d=c.useRef(null),u=Qe(nx),f=Qe(rx),h=Bc(f??void 0),x=Bf(u??"",f??void 0),b=Ht(ox);let w;t[1]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),o(ix),a(null)},t[1]=w):w=t[1];let S;t[2]!==f||t[3]!==u?(S=[f,u],t[2]=f,t[3]=u,t[4]=S):S=t[4],c.useEffect(w,S);let g,m;t[5]===Symbol.for("react.memo_cache_sentinel")?(g=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},m=[],t[5]=g,t[6]=m):(g=t[5],m=t[6]),c.useEffect(g,m);let p;t[7]===Symbol.for("react.memo_cache_sentinel")?(p=async(et,qe)=>{(await an(qe)).ok?(a(et),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{a(wt=>wt===et?null:wt),d.current=null},2e3)):a(null)},t[7]=p):p=t[7];const y=p;let v;t[8]!==u||t[9]!==h?(v=u?h.find(et=>et.id===u)??null:null,t[8]=u,t[9]=h,t[10]=v):v=t[10];const N=v;let C,k,A,D,P,T;if(t[11]!==b||t[12]!==x){C=x.filter(ax);let et;t[19]!==x?(et=x.filter(lx),t[19]=x,t[20]=et):et=t[20],T=et;let qe=null;for(let wt=C.length-1;wt>=0;wt=wt-1,wt){const jt=C[wt];if(ii(jt).total>0){qe=jt;break}}D=qe?ii(qe):Mi,k=_f({input:D.input,cache:{read:D.cacheRead,write:D.cacheWrite}}),P=C.reduce(cx,0);const kt=qe?.info??null;A=ex(b,kt?.providerID||"",kt?.modelID||""),t[11]=b,t[12]=x,t[13]=C,t[14]=k,t[15]=A,t[16]=D,t[17]=P,t[18]=T}else C=t[13],k=t[14],A=t[15],D=t[16],P=t[17],T=t[18];const $=A,E=$.contextLimit,U=E&&E>0?Math.min(999,D.total/E*100):0;let I;if(t[21]!==x){const et=[...x].reverse().find(dx)?.info?.system||"";I=Jb(x,et),t[21]=x,t[22]=I}else I=t[22];const B=I,R=B.user,j=B.assistant,M=B.tool,L=Math.max(0,D.input-R-j-M),W=R+j+M+L,te=x[0]?.info?.time?.created,Q=x.length>0?x[x.length-1]?.info?.time?.created:null;let me;t[23]!==N?.title||t[24]!==e?(me=N?.title||e("contextSidebar.session.untitled"),t[23]=N?.title,t[24]=e,t[25]=me):me=t[25];const ce=N?.time?.created??te??null,H=Q??N?.time?.created??null;let ne;t[26]!==j||t[27]!==L||t[28]!==M||t[29]!==R?(ne={user:R,assistant:j,tool:M,other:L},t[26]=j,t[27]=L,t[28]=M,t[29]=R,t[30]=ne):ne=t[30];let ie;t[31]!==C.length||t[32]!==W||t[33]!==k||t[34]!==E||t[35]!==$||t[36]!==x.length||t[37]!==ce||t[38]!==H||t[39]!==ne||t[40]!==me||t[41]!==D||t[42]!==P||t[43]!==U||t[44]!==T.length?(ie={sessionTitle:me,messagesCount:x.length,userMessagesCount:T.length,assistantMessagesCount:C.length,createdAt:ce,lastActivityAt:H,providerModel:$,tokenBreakdown:D,usagePercent:U,cacheHitRate:k,totalAssistantCost:P,contextLimit:E,breakdown:ne,breakdownTotal:W},t[31]=C.length,t[32]=W,t[33]=k,t[34]=E,t[35]=$,t[36]=x.length,t[37]=ce,t[38]=H,t[39]=ne,t[40]=me,t[41]=D,t[42]=P,t[43]=U,t[44]=T.length,t[45]=ie):ie=t[45];const F=ie;if(!u){let et;t[46]!==e?(et=e("contextSidebar.empty.openSession"),t[46]=e,t[47]=et):et=t[47];let qe;return t[48]!==et?(qe=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:et}),t[48]=et,t[49]=qe):qe=t[49],qe}let Z;t[50]!==e?(Z=e("contextSidebar.breakdown.user"),t[50]=e,t[51]=Z):Z=t[51];let G;t[52]!==Z||t[53]!==F.breakdown.user?(G={key:"user",label:Z,value:F.breakdown.user,color:"var(--status-success)"},t[52]=Z,t[53]=F.breakdown.user,t[54]=G):G=t[54];let V;t[55]!==e?(V=e("contextSidebar.breakdown.assistant"),t[55]=e,t[56]=V):V=t[56];let Y;t[57]!==V||t[58]!==F.breakdown.assistant?(Y={key:"assistant",label:V,value:F.breakdown.assistant,color:"var(--primary-base)"},t[57]=V,t[58]=F.breakdown.assistant,t[59]=Y):Y=t[59];let le;t[60]!==e?(le=e("contextSidebar.breakdown.toolCalls"),t[60]=e,t[61]=le):le=t[61];let pe;t[62]!==le||t[63]!==F.breakdown.tool?(pe={key:"tool",label:le,value:F.breakdown.tool,color:"var(--status-warning)"},t[62]=le,t[63]=F.breakdown.tool,t[64]=pe):pe=t[64];let be;t[65]!==e?(be=e("contextSidebar.breakdown.other"),t[65]=e,t[66]=be):be=t[66];let Se;t[67]!==be||t[68]!==F.breakdown.other?(Se={key:"other",label:be,value:F.breakdown.other,color:"var(--surface-muted-foreground)"},t[67]=be,t[68]=F.breakdown.other,t[69]=Se):Se=t[69];let De;t[70]!==G||t[71]!==Y||t[72]!==pe||t[73]!==Se?(De=[G,Y,pe,Se],t[70]=G,t[71]=Y,t[72]=pe,t[73]=Se,t[74]=De):De=t[74];const fe=De;let xe;t[75]!==F.sessionTitle?(xe=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:F.sessionTitle}),t[75]=F.sessionTitle,t[76]=xe):xe=t[76];let ge;t[77]!==F.providerModel.modelName||t[78]!==F.providerModel.providerName?(ge=s.jsxs("span",{children:[F.providerModel.providerName," / ",F.providerModel.modelName]}),t[77]=F.providerModel.modelName,t[78]=F.providerModel.providerName,t[79]=ge):ge=t[79];let re;t[80]!==n||t[81]!==F.createdAt?(re=F.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:Zb(F.createdAt,n)})]}),t[80]=n,t[81]=F.createdAt,t[82]=re):re=t[82];let he;t[83]!==ge||t[84]!==re?(he=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:[ge,re]}),t[83]=ge,t[84]=re,t[85]=he):he=t[85];let Ne;t[86]!==xe||t[87]!==he?(Ne=s.jsxs("div",{className:"mb-6",children:[xe,he]}),t[86]=xe,t[87]=he,t[88]=Ne):Ne=t[88];let de;t[89]!==e?(de=e("contextSidebar.section.context"),t[89]=e,t[90]=de):de=t[90];let oe;t[91]!==de?(oe=s.jsx("span",{className:"typography-micro text-muted-foreground",children:de}),t[91]=de,t[92]=oe):oe=t[92];let K;t[93]!==F.tokenBreakdown.total?(K=Ln(F.tokenBreakdown.total),t[93]=F.tokenBreakdown.total,t[94]=K):K=t[94];let z;t[95]!==F.contextLimit?(z=F.contextLimit?` / ${Ln(F.contextLimit)}`:"",t[95]=F.contextLimit,t[96]=z):z=t[96];let ae;t[97]!==K||t[98]!==z?(ae=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[K,z]}),t[97]=K,t[98]=z,t[99]=ae):ae=t[99];let ve;t[100]!==oe||t[101]!==ae?(ve=s.jsxs("div",{className:"flex items-baseline justify-between",children:[oe,ae]}),t[100]=oe,t[101]=ae,t[102]=ve):ve=t[102];let ye;t[103]!==F.usagePercent?(ye=F.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,F.usagePercent)}%`,backgroundColor:F.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[103]=F.usagePercent,t[104]=ye):ye=t[104];let We;t[105]!==ye?(We=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ye}),t[105]=ye,t[106]=We):We=t[106];let Be;t[107]!==e||t[108]!==F.usagePercent?(Be=e("contextSidebar.context.percentUsed",{percent:F.usagePercent.toFixed(1)}),t[107]=e,t[108]=F.usagePercent,t[109]=Be):Be=t[109];let Ae;t[110]!==Be?(Ae=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Be}),t[110]=Be,t[111]=Ae):Ae=t[111];let X;t[112]!==ve||t[113]!==We||t[114]!==Ae?(X=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ve,We,Ae]}),t[112]=ve,t[113]=We,t[114]=Ae,t[115]=X):X=t[115];let Oe;t[116]!==e?(Oe=e("contextSidebar.stats.messages"),t[116]=e,t[117]=Oe):Oe=t[117];let Fe;t[118]!==F.messagesCount?(Fe=Ln(F.messagesCount),t[118]=F.messagesCount,t[119]=Fe):Fe=t[119];let _;t[120]!==Oe||t[121]!==Fe?(_={label:Oe,value:Fe},t[120]=Oe,t[121]=Fe,t[122]=_):_=t[122];let ue;t[123]!==e?(ue=e("contextSidebar.stats.user"),t[123]=e,t[124]=ue):ue=t[124];let ke;t[125]!==F.userMessagesCount?(ke=Ln(F.userMessagesCount),t[125]=F.userMessagesCount,t[126]=ke):ke=t[126];let je;t[127]!==ue||t[128]!==ke?(je={label:ue,value:ke},t[127]=ue,t[128]=ke,t[129]=je):je=t[129];let Ke;t[130]!==e?(Ke=e("contextSidebar.stats.assistant"),t[130]=e,t[131]=Ke):Ke=t[131];let se;t[132]!==F.assistantMessagesCount?(se=Ln(F.assistantMessagesCount),t[132]=F.assistantMessagesCount,t[133]=se):se=t[133];let Ie;t[134]!==Ke||t[135]!==se?(Ie={label:Ke,value:se},t[134]=Ke,t[135]=se,t[136]=Ie):Ie=t[136];let Ye;t[137]!==e?(Ye=e("contextSidebar.stats.cost"),t[137]=e,t[138]=Ye):Ye=t[138];let ee;t[139]!==F.totalAssistantCost?(ee=Th(F.totalAssistantCost),t[139]=F.totalAssistantCost,t[140]=ee):ee=t[140];let Ee;t[141]!==Ye||t[142]!==ee?(Ee={label:Ye,value:ee},t[141]=Ye,t[142]=ee,t[143]=Ee):Ee=t[143];let Ge;t[144]!==_||t[145]!==je||t[146]!==Ie||t[147]!==Ee?(Ge=[_,je,Ie,Ee],t[144]=_,t[145]=je,t[146]=Ie,t[147]=Ee,t[148]=Ge):Ge=t[148];const ze=Ge;let $e;t[149]!==ze?($e=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:ze.map(ux)}),t[149]=ze,t[150]=$e):$e=t[150];let _e;t[151]!==e?(_e=e("contextSidebar.section.lastAssistantMessage"),t[151]=e,t[152]=_e):_e=t[152];let Xe;t[153]!==_e?(Xe=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:_e}),t[153]=_e,t[154]=Xe):Xe=t[154];let ct;t[155]!==e||t[156]!==F.cacheHitRate.hasInput||t[157]!==F.cacheHitRate.percent||t[158]!==F.tokenBreakdown.cacheRead||t[159]!==F.tokenBreakdown.cacheWrite||t[160]!==F.tokenBreakdown.input||t[161]!==F.tokenBreakdown.output||t[162]!==F.tokenBreakdown.reasoning?(ct=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:F.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:F.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:F.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:F.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:F.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:F.cacheHitRate.hasInput?F.cacheHitRate.percent:null,format:"percent"}].map(fx)}),t[155]=e,t[156]=F.cacheHitRate.hasInput,t[157]=F.cacheHitRate.percent,t[158]=F.tokenBreakdown.cacheRead,t[159]=F.tokenBreakdown.cacheWrite,t[160]=F.tokenBreakdown.input,t[161]=F.tokenBreakdown.output,t[162]=F.tokenBreakdown.reasoning,t[163]=ct):ct=t[163];let Nt;t[164]!==Xe||t[165]!==ct?(Nt=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Xe,ct]}),t[164]=Xe,t[165]=ct,t[166]=Nt):Nt=t[166];let At;t[167]!==fe||t[168]!==F.breakdownTotal?(At=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:fe.map(et=>et.value<=0||F.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${et.value/F.breakdownTotal*100}%`,backgroundColor:et.color}},et.key))}),t[167]=fe,t[168]=F.breakdownTotal,t[169]=At):At=t[169];let Le;t[170]!==fe||t[171]!==F.breakdownTotal?(Le=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:fe.map(et=>{const qe=F.breakdownTotal>0?et.value/F.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:et.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[et.label," ",s.jsxs("span",{className:"tabular-nums",children:[qe.toFixed(0),"%"]})]})]},et.key)})}),t[170]=fe,t[171]=F.breakdownTotal,t[172]=Le):Le=t[172];let _t;t[173]!==At||t[174]!==Le?(_t=s.jsxs("div",{className:"mb-6",children:[At,Le]}),t[173]=At,t[174]=Le,t[175]=_t):_t=t[175];let mt;t[176]!==e?(mt=e("contextSidebar.section.rawMessages"),t[176]=e,t[177]=mt):mt=t[177];let Rt;t[178]!==mt?(Rt=s.jsx("div",{className:"typography-micro text-muted-foreground",children:mt}),t[178]=mt,t[179]=Rt):Rt=t[179];let Dt;if(t[180]!==l||t[181]!==i||t[182]!==x||t[183]!==e||t[184]!==n){let et;t[186]!==l||t[187]!==i||t[188]!==e||t[189]!==n?(et=qe=>{const wt=Wr(qe.info).role,jt=wt==="assistant",Ut=wt==="user",st=i[qe.info.id]===!0,rt=l===qe.info.id,Ct=qe.info.time?.created??null,It=Vb(qe.parts),Bt=jt?ii({info:qe.info,parts:qe.parts}):null,Tt=Ut?Hb(qe.parts):"",ns=qb(Ct,n),Lt=It||"—",zt=Bt?Kb(Bt.input,Bt.output,Ln):"",qt=wt||"unknown",ms=It?`${qt}: ${It}`:qt,Qt=st?JSON.stringify({info:qe.info,parts:qe.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":st,onClick:()=>{o(Me=>({...Me,[qe.info.id]:Me[qe.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:jt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Ut?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",Tt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:jt?Lt:ms}),jt&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:zt})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:ns})]})}),st&&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:Me=>{Me.stopPropagation(),y(qe.info.id,Qt)},"aria-label":e(rt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(rt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:rt?s.jsx(O,{name:"check",className:"size-3.5"}):s.jsx(O,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Ff,{language:"json",code:Qt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},qe.info.id)},t[186]=l,t[187]=i,t[188]=e,t[189]=n,t[190]=et):et=t[190],Dt=[...x].reverse().map(et),t[180]=l,t[181]=i,t[182]=x,t[183]=e,t[184]=n,t[185]=Dt}else Dt=t[185];let xt;t[191]!==Dt?(xt=s.jsx("div",{className:"mt-2.5 space-y-1",children:Dt}),t[191]=Dt,t[192]=xt):xt=t[192];let we;t[193]!==Rt||t[194]!==xt?(we=s.jsxs("div",{children:[Rt,xt]}),t[193]=Rt,t[194]=xt,t[195]=we):we=t[195];let dt;return t[196]!==Ne||t[197]!==X||t[198]!==$e||t[199]!==Nt||t[200]!==_t||t[201]!==we?(dt=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:[Ne,X,$e,Nt,_t,we]})}),t[196]=Ne,t[197]=X,t[198]=$e,t[199]=Nt,t[200]=_t,t[201]=we,t[202]=dt):dt=t[202],dt};function sx(t){return t.timeFormatPreference}function nx(t){return t.currentSessionId}function rx(t){return t.currentSessionDirectory}function ox(t){return t.providers}function ix(t){return Object.keys(t).length>0?{}:t}function ax(t){return Wr(t.info).role==="assistant"}function lx(t){return Wr(t.info).isUser}function cx(t,e){const n=Cn(e.info.cost);return t+n}function dx(t){return Wr(t.info).isUser&&typeof t.info.system=="string"}function ux(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 fx(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)}%`:Ln(t.value):"—"})]},t.label)}const Yd=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),mx=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return Yd.has(n.toLowerCase())},en="about:blank",or=t=>{const e=t.trim();if(!e)return en;const n=e.includes("://")?e:`${mx(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?en:r.toString()}catch{return en}},fr=t=>{try{return Yd.has(new URL(t).hostname.toLowerCase())}catch{return!1}},wa=t=>{if(!t||t===en)return"";try{return new URL(t).host||t}catch{return t}},hx=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),px=(t,e)=>hx.has(t)&&fr(e),gx=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"},bx=async t=>{try{const e=await ss("/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(gx)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},xx=async t=>{try{const e=await ss("/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}},yx=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}},wx=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=yx(r);i!==null&&!n.has(i)&&n.set(i,r)}return e?e.map(r=>{const i=n.get(r.port);return{url:i??r.url,port:r.port,announced:i!==void 0}}).sort((r,i)=>r.announced!==i.announced?r.announced?-1:1:r.port-i.port):[...n.entries()].map(([r,i])=>({url:i,port:r,announced:!0})).sort((r,i)=>r.port-i.port)},Oi="__openchamberBrowserAnnotationActive",Sx=`(() => {
|
|
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['${Oi}']; } catch (error) { /* non-configurable */ }
|
|
56
|
-
})();`,vx=(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['${Oi}'] = 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;width:32px;height:32px;padding:0;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer}',
|
|
211
|
-
'.editor button svg{width:16px;height:16px;display:block}',
|
|
212
|
-
'.editor button[disabled]{opacity:.5;cursor:default}'
|
|
213
|
-
].join('');
|
|
214
|
-
shadow.appendChild(style);
|
|
215
|
-
|
|
216
|
-
var cursorStyle = document.createElement('style');
|
|
217
|
-
cursorStyle.id = 'openchamber-annotation-cursor';
|
|
218
|
-
document.head.appendChild(cursorStyle);
|
|
219
|
-
var setCursor = function (value) {
|
|
220
|
-
cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
var svgNS = 'http://www.w3.org/2000/svg';
|
|
224
|
-
var svg = document.createElementNS(svgNS, 'svg');
|
|
225
|
-
svg.setAttribute('class', 'layer');
|
|
226
|
-
svg.style.overflow = 'visible';
|
|
227
|
-
shadow.appendChild(svg);
|
|
228
|
-
|
|
229
|
-
var hoverBox = document.createElement('div');
|
|
230
|
-
hoverBox.className = 'box';
|
|
231
|
-
var hoverLabel = document.createElement('div');
|
|
232
|
-
hoverLabel.className = 'label';
|
|
233
|
-
var marqueeBox = document.createElement('div');
|
|
234
|
-
marqueeBox.className = 'box';
|
|
235
|
-
shadow.append(hoverBox, hoverLabel, marqueeBox);
|
|
236
|
-
|
|
237
|
-
var positionBox = function (node, rect) {
|
|
238
|
-
node.style.display = 'block';
|
|
239
|
-
node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
|
|
240
|
-
node.style.width = rect.width + 'px';
|
|
241
|
-
node.style.height = rect.height + 'px';
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
var tools = document.createElement('div');
|
|
245
|
-
tools.className = 'tools';
|
|
246
|
-
shadow.appendChild(tools);
|
|
247
|
-
|
|
248
|
-
var toolButtons = {};
|
|
249
|
-
[['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
|
|
250
|
-
var button = document.createElement('button');
|
|
251
|
-
button.type = 'button';
|
|
252
|
-
button.textContent = entry[1];
|
|
253
|
-
button.addEventListener('click', function () { setTool(entry[0]); });
|
|
254
|
-
toolButtons[entry[0]] = button;
|
|
255
|
-
tools.appendChild(button);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
var editor = document.createElement('div');
|
|
259
|
-
editor.className = 'editor';
|
|
260
|
-
shadow.appendChild(editor);
|
|
261
|
-
|
|
262
|
-
var comment = document.createElement('textarea');
|
|
263
|
-
comment.rows = 1;
|
|
264
|
-
comment.placeholder = LABELS.commentPlaceholder;
|
|
265
|
-
var submit = document.createElement('button');
|
|
266
|
-
submit.type = 'button';
|
|
267
|
-
// Icon-only attach button (Remix attachment-2), matching the chat comment
|
|
268
|
-
// input; the localized label stays available to assistive tech.
|
|
269
|
-
submit.setAttribute('aria-label', LABELS.submit);
|
|
270
|
-
submit.title = LABELS.submit;
|
|
271
|
-
submit.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.8287 7.75737L9.1718 13.4142C8.78127 13.8047 8.78127 14.4379 9.1718 14.8284C9.56232 15.219 10.1955 15.219 10.586 14.8284L16.2429 9.17158C17.4144 8.00001 17.4144 6.10052 16.2429 4.92894C15.0713 3.75737 13.1718 3.75737 12.0002 4.92894L6.34337 10.5858C4.39075 12.5384 4.39075 15.7042 6.34337 17.6569C8.29599 19.6095 11.4618 19.6095 13.4144 17.6569L19.0713 12L20.4855 13.4142L14.8287 19.0711C12.095 21.8047 7.66283 21.8047 4.92916 19.0711C2.19549 16.3374 2.19549 11.9053 4.92916 9.17158L10.586 3.51473C12.5386 1.56211 15.7045 1.56211 17.6571 3.51473C19.6097 5.46735 19.6097 8.63317 17.6571 10.5858L12.0002 16.2427C10.8287 17.4142 8.92916 17.4142 7.75759 16.2427C6.58601 15.0711 6.58601 13.1716 7.75759 12L13.4144 6.34316L14.8287 7.75737Z" fill="currentColor"/></svg>';
|
|
272
|
-
editor.append(comment, submit);
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Grows the box with its content.
|
|
276
|
-
*
|
|
277
|
-
* A hidden element reports scrollHeight 0, so measuring one collapses the
|
|
278
|
-
* field to nothing — which is what left a sliver of a click target and an
|
|
279
|
-
* invisible caret. Measuring only while visible, and never below the CSS
|
|
280
|
-
* min-height, keeps it usable.
|
|
281
|
-
*/
|
|
282
|
-
var resizeComment = function () {
|
|
283
|
-
if (editor.style.display === 'none') return;
|
|
284
|
-
comment.style.height = 'auto';
|
|
285
|
-
comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
|
|
286
|
-
};
|
|
287
|
-
comment.addEventListener('input', resizeComment);
|
|
288
|
-
|
|
289
|
-
// -------------------------------------------------------------- selection
|
|
290
|
-
|
|
291
|
-
var lastTargetRect = null;
|
|
292
|
-
|
|
293
|
-
/** Places the comment box under whatever was just marked, kept on screen. */
|
|
294
|
-
var positionEditor = function () {
|
|
295
|
-
if (!lastTargetRect) {
|
|
296
|
-
editor.style.display = 'none';
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
var wasHidden = editor.style.display === 'none';
|
|
300
|
-
editor.style.display = 'flex';
|
|
301
|
-
// Measured now that it is laid out, not while it was still hidden.
|
|
302
|
-
if (wasHidden) resizeComment();
|
|
303
|
-
var box = editor.getBoundingClientRect();
|
|
304
|
-
var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
|
|
305
|
-
var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
|
|
306
|
-
// Above the target when there is no room below, so the box is never left
|
|
307
|
-
// half off the bottom of the page.
|
|
308
|
-
if (top + box.height > window.innerHeight - 8) {
|
|
309
|
-
top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
|
|
310
|
-
}
|
|
311
|
-
left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
|
|
312
|
-
editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
/** Focus after layout: focusing a zero-height field puts the caret nowhere. */
|
|
316
|
-
var focusComment = function () {
|
|
317
|
-
requestAnimationFrame(function () {
|
|
318
|
-
try {
|
|
319
|
-
comment.focus({ preventScroll: true });
|
|
320
|
-
comment.setSelectionRange(comment.value.length, comment.value.length);
|
|
321
|
-
} catch (error) { /* field went away */ }
|
|
322
|
-
});
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
var hasTargets = function () {
|
|
326
|
-
return Boolean(selected) || regions.length > 0 || strokes.length > 0;
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
var syncChrome = function () {
|
|
330
|
-
submit.disabled = !hasTargets();
|
|
331
|
-
if (!hasTargets()) {
|
|
332
|
-
lastTargetRect = null;
|
|
333
|
-
editor.style.display = 'none';
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
positionEditor();
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
var syncSelectionVisuals = function () {
|
|
340
|
-
if (!selected) return;
|
|
341
|
-
var rect = rectFrom(selected.element.getBoundingClientRect());
|
|
342
|
-
if (!usableRect(rect)) {
|
|
343
|
-
selected.outline.style.display = 'none';
|
|
344
|
-
selected.badge.style.display = 'none';
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
positionBox(selected.outline, rect);
|
|
348
|
-
selected.badge.style.display = 'block';
|
|
349
|
-
selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
350
|
-
lastTargetRect = rect;
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
var dropSelection = function () {
|
|
354
|
-
if (!selected) return;
|
|
355
|
-
selected.outline.remove();
|
|
356
|
-
selected.badge.remove();
|
|
357
|
-
selected = null;
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
var selectElement = function (element) {
|
|
361
|
-
var wasSelected = selected && selected.element === element;
|
|
362
|
-
dropSelection();
|
|
363
|
-
if (wasSelected) {
|
|
364
|
-
// Clicking the chosen element again clears it, so a misclick costs one
|
|
365
|
-
// click rather than starting over.
|
|
366
|
-
lastTargetRect = null;
|
|
367
|
-
syncChrome();
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
var outline = document.createElement('div');
|
|
371
|
-
outline.className = 'box';
|
|
372
|
-
var badge = document.createElement('div');
|
|
373
|
-
badge.className = 'label';
|
|
374
|
-
badge.textContent = selectorPart(element);
|
|
375
|
-
shadow.append(outline, badge);
|
|
376
|
-
selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
|
|
377
|
-
syncSelectionVisuals();
|
|
378
|
-
syncChrome();
|
|
379
|
-
focusComment();
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
var setTool = function (next) {
|
|
383
|
-
tool = next;
|
|
384
|
-
hoverBox.style.display = 'none';
|
|
385
|
-
hoverLabel.style.display = 'none';
|
|
386
|
-
marqueeBox.style.display = 'none';
|
|
387
|
-
setCursor(next === 'select' ? '' : 'crosshair');
|
|
388
|
-
for (var key in toolButtons) {
|
|
389
|
-
if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
|
|
390
|
-
toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
// ------------------------------------------------------------- interaction
|
|
396
|
-
|
|
397
|
-
var drag = null;
|
|
398
|
-
|
|
399
|
-
var onPointerMove = function (event) {
|
|
400
|
-
if (drag) {
|
|
401
|
-
if (drag.kind === 'marquee') {
|
|
402
|
-
drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
|
|
403
|
-
positionBox(marqueeBox, drag.rect);
|
|
404
|
-
} else if (drag.kind === 'draw') {
|
|
405
|
-
drag.points.push({ x: event.clientX, y: event.clientY });
|
|
406
|
-
drag.path.setAttribute('d', drag.points.map(function (point, index) {
|
|
407
|
-
return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
|
|
408
|
-
}).join(' '));
|
|
409
|
-
}
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
if (tool !== 'select') return;
|
|
414
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
415
|
-
if (!element) {
|
|
416
|
-
hoverBox.style.display = 'none';
|
|
417
|
-
hoverLabel.style.display = 'none';
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
var rect = rectFrom(element.getBoundingClientRect());
|
|
421
|
-
positionBox(hoverBox, rect);
|
|
422
|
-
hoverLabel.textContent = selectorPart(element);
|
|
423
|
-
hoverLabel.style.display = 'block';
|
|
424
|
-
hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
var onPointerDown = function (event) {
|
|
428
|
-
if (event.button !== 0) return;
|
|
429
|
-
if (isOverlayNode(event.target)) return;
|
|
430
|
-
event.preventDefault();
|
|
431
|
-
event.stopPropagation();
|
|
432
|
-
|
|
433
|
-
if (tool === 'select') {
|
|
434
|
-
var element = elementFromPoint(event.clientX, event.clientY);
|
|
435
|
-
if (element) selectElement(element);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
if (tool === 'marquee') {
|
|
440
|
-
drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
var path = document.createElementNS(svgNS, 'path');
|
|
445
|
-
path.setAttribute('fill', 'none');
|
|
446
|
-
path.setAttribute('stroke', THEME.primary);
|
|
447
|
-
path.setAttribute('stroke-width', '2.5');
|
|
448
|
-
path.setAttribute('stroke-linecap', 'round');
|
|
449
|
-
path.setAttribute('stroke-linejoin', 'round');
|
|
450
|
-
svg.appendChild(path);
|
|
451
|
-
drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
var onPointerUp = function () {
|
|
455
|
-
if (!drag) return;
|
|
456
|
-
var finished = drag;
|
|
457
|
-
drag = null;
|
|
458
|
-
|
|
459
|
-
if (finished.kind === 'marquee') {
|
|
460
|
-
marqueeBox.style.display = 'none';
|
|
461
|
-
var rect = finished.rect;
|
|
462
|
-
if (!rect || !usableRect(rect)) return;
|
|
463
|
-
// A region marks an area, not the elements inside it: expanding it into a
|
|
464
|
-
// selection made the result depend on the page's markup rather than on
|
|
465
|
-
// what was drawn.
|
|
466
|
-
regions.push({ id: nextId('region'), rect: rect });
|
|
467
|
-
var outline = document.createElementNS(svgNS, 'rect');
|
|
468
|
-
outline.setAttribute('x', String(rect.x));
|
|
469
|
-
outline.setAttribute('y', String(rect.y));
|
|
470
|
-
outline.setAttribute('width', String(rect.width));
|
|
471
|
-
outline.setAttribute('height', String(rect.height));
|
|
472
|
-
outline.style.fill = THEME.primarySoft;
|
|
473
|
-
outline.setAttribute('stroke', THEME.primary);
|
|
474
|
-
outline.setAttribute('stroke-width', '1.5');
|
|
475
|
-
outline.setAttribute('rx', '2');
|
|
476
|
-
svg.appendChild(outline);
|
|
477
|
-
lastTargetRect = rect;
|
|
478
|
-
syncChrome();
|
|
479
|
-
focusComment();
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
var points = finished.points;
|
|
484
|
-
if (points.length < 2) {
|
|
485
|
-
if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
|
|
489
|
-
for (var p = 1; p < points.length; p += 1) {
|
|
490
|
-
minX = Math.min(minX, points[p].x);
|
|
491
|
-
minY = Math.min(minY, points[p].y);
|
|
492
|
-
maxX = Math.max(maxX, points[p].x);
|
|
493
|
-
maxY = Math.max(maxY, points[p].y);
|
|
494
|
-
}
|
|
495
|
-
var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
496
|
-
strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
|
|
497
|
-
lastTargetRect = bounds;
|
|
498
|
-
syncChrome();
|
|
499
|
-
focusComment();
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Swallows the page's own mouse handling while annotating.
|
|
504
|
-
*
|
|
505
|
-
* Blocking pointerdown is not enough: a click still follows it, so marking a
|
|
506
|
-
* button pressed that button and marking a link navigated away from the page
|
|
507
|
-
* being annotated. These are the events that reach page code, so these are
|
|
508
|
-
* the ones that have to stop.
|
|
509
|
-
*/
|
|
510
|
-
var blockPageInteraction = function (event) {
|
|
511
|
-
if (isOverlayNode(event.target)) return;
|
|
512
|
-
event.preventDefault();
|
|
513
|
-
event.stopPropagation();
|
|
514
|
-
};
|
|
515
|
-
var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
|
|
516
|
-
|
|
517
|
-
var onScrollOrResize = function () {
|
|
518
|
-
syncSelectionVisuals();
|
|
519
|
-
positionEditor();
|
|
520
|
-
};
|
|
521
|
-
|
|
522
|
-
var onKeyDown = function (event) {
|
|
523
|
-
if (event.key === 'Escape') {
|
|
524
|
-
event.preventDefault();
|
|
525
|
-
event.stopImmediatePropagation();
|
|
526
|
-
finish(null);
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
var onCommentKeyDown = function (event) {
|
|
531
|
-
// Do not let the annotated page treat typed letters as its own shortcuts.
|
|
532
|
-
event.stopPropagation();
|
|
533
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
|
534
|
-
event.preventDefault();
|
|
535
|
-
attach();
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
document.addEventListener('pointermove', onPointerMove, true);
|
|
540
|
-
document.addEventListener('pointerdown', onPointerDown, true);
|
|
541
|
-
document.addEventListener('pointerup', onPointerUp, true);
|
|
542
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
543
|
-
window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
|
|
544
|
-
});
|
|
545
|
-
window.addEventListener('scroll', onScrollOrResize, true);
|
|
546
|
-
window.addEventListener('resize', onScrollOrResize, true);
|
|
547
|
-
window.addEventListener('keydown', onKeyDown, true);
|
|
548
|
-
comment.addEventListener('keydown', onCommentKeyDown);
|
|
549
|
-
|
|
550
|
-
// ------------------------------------------------------------------ finish
|
|
551
|
-
|
|
552
|
-
var teardown = function () {
|
|
553
|
-
document.removeEventListener('pointermove', onPointerMove, true);
|
|
554
|
-
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
555
|
-
document.removeEventListener('pointerup', onPointerUp, true);
|
|
556
|
-
BLOCKED_EVENTS.forEach(function (name) {
|
|
557
|
-
window.removeEventListener(name, blockPageInteraction, true);
|
|
558
|
-
});
|
|
559
|
-
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
560
|
-
window.removeEventListener('resize', onScrollOrResize, true);
|
|
561
|
-
window.removeEventListener('keydown', onKeyDown, true);
|
|
562
|
-
comment.removeEventListener('keydown', onCommentKeyDown);
|
|
563
|
-
setCursor('');
|
|
564
|
-
if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
|
|
565
|
-
if (host.parentNode) host.parentNode.removeChild(host);
|
|
566
|
-
try { delete window['${Oi}']; } catch (error) { /* non-configurable */ }
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
var finish = function (payload) {
|
|
570
|
-
if (settled) return;
|
|
571
|
-
settled = true;
|
|
572
|
-
teardown();
|
|
573
|
-
// Removing the chrome is not enough: the host screenshots this page right
|
|
574
|
-
// after we resolve, and the compositor can still hold a frame containing
|
|
575
|
-
// our outlines. Yield two frames so the page has actually repainted.
|
|
576
|
-
requestAnimationFrame(function () {
|
|
577
|
-
requestAnimationFrame(function () { resolve(payload); });
|
|
578
|
-
});
|
|
579
|
-
};
|
|
580
|
-
|
|
581
|
-
var attach = function () {
|
|
582
|
-
if (!hasTargets()) return;
|
|
583
|
-
finish({
|
|
584
|
-
id: 'annotation-' + Date.now(),
|
|
585
|
-
pageUrl: String(location.href),
|
|
586
|
-
pageTitle: String(document.title || ''),
|
|
587
|
-
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
588
|
-
devicePixelRatio: window.devicePixelRatio || 1,
|
|
589
|
-
comment: comment.value,
|
|
590
|
-
// Zero or one element, never more. Kept as a list so elements, regions
|
|
591
|
-
// and strokes stay one uniform shape for everything downstream.
|
|
592
|
-
elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
|
|
593
|
-
regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
|
|
594
|
-
strokes: strokes.map(function (entry) {
|
|
595
|
-
return { id: entry.id, points: entry.points, bounds: entry.bounds };
|
|
596
|
-
})
|
|
597
|
-
});
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
submit.addEventListener('click', attach);
|
|
601
|
-
|
|
602
|
-
(document.body || document.documentElement).appendChild(host);
|
|
603
|
-
setTool('select');
|
|
604
|
-
syncChrome();
|
|
605
|
-
});`},jx={kind:"idle"},dn=t=>typeof t=="object"&&t!==null,mn=t=>typeof t=="number"&&Number.isFinite(t),bl=t=>dn(t)&&Object.values(t).every(e=>typeof e=="string"),Sa=t=>dn(t)&&mn(t.x)&&mn(t.y)&&mn(t.width)&&mn(t.height),Xd=t=>dn(t)&&mn(t.x)&&mn(t.y),kx=t=>dn(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"),Cx=t=>dn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&Sa(t.bounds)&&Xd(t.center)&&bl(t.attributes)&&bl(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(kx),Nx=t=>dn(t)&&typeof t.id=="string"&&Cx(t.element),Ax=t=>dn(t)&&typeof t.id=="string"&&Sa(t.rect),Dx=t=>dn(t)&&typeof t.id=="string"&&Sa(t.bounds)&&Array.isArray(t.points)&&t.points.every(Xd),Px=t=>dn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&dn(t.viewport)&&mn(t.viewport.width)&&mn(t.viewport.height)&&mn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(Nx)&&Array.isArray(t.regions)&&t.regions.every(Ax)&&Array.isArray(t.strokes)&&t.strokes.every(Dx),Ix=1600,Tx=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}),Ex=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:d})=>{if(!t)return null;try{const u=await Tx(`data:${e};base64,${t}`),f=Math.max(1,u.naturalWidth||n),h=Math.max(1,u.naturalHeight||r),x=f/Math.max(1,i||f),b=h/Math.max(1,o||h),w=Math.min(1,Ix/f),S=document.createElement("canvas");S.width=Math.max(1,Math.floor(f*w)),S.height=Math.max(1,Math.floor(h*w));const g=S.getContext("2d");if(!g)return null;g.scale(w,w),g.drawImage(u,0,0,f,h);const m=N=>({x:N.x*x,y:N.y*b,width:N.width*x,height:N.height*b}),p=Math.max(2,2.5*x/Math.max(w,.2));g.strokeStyle=a,g.fillStyle=d;const y=N=>{const C=m(N);g.lineWidth=p,g.fillRect(C.x,C.y,C.width,C.height),g.strokeRect(C.x,C.y,C.width,C.height)};for(const N of l.elements)y(N.element.bounds);for(const N of l.regions)y(N.rect);for(const N of l.strokes)N.points.length<2||(g.beginPath(),N.points.forEach((C,k)=>{const A=C.x*x,D=C.y*b;k===0?g.moveTo(A,D):g.lineTo(A,D)}),g.lineCap="round",g.lineJoin="round",g.lineWidth=p*1.4,g.stroke());const v=await new Promise(N=>S.toBlob(N,"image/jpeg",.85));return v?new File([v],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},Rx="({ width: window.innerWidth, height: window.innerHeight })",Mx=async t=>{try{const e=await t.executeJavaScript(Rx,!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}},mo=async t=>{try{await t.executeJavaScript(Sx,!1)}catch{}},Ox=async({host:t,theme:e,labels:n})=>{const r=vx(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!Px(i))return await mo(t),null;const o=i;try{const l=await Mx(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const d=await Ex({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:l.width,cssHeight:l.height,payload:o,accentColor:e.primary,accentFill:e.primarySoft});return{payload:o,screenshot:d}}catch{return{payload:o,screenshot:null}}},Js={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)"},Bx=()=>{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()}},_x=t=>{const e=Bx();if(!e)return{...Js,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,i=e.readVariable("--oc-glass-tooltip-opacity")||"62%",o=e.readVariable("--oc-glass-blur")||"26px",l=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${i}, transparent)`)||Js.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",Js.primary),primarySoft:r("--primary",16,Js.primarySoft),primaryFaint:r("--primary",10,Js.primaryFaint),primaryContrast:n("--primary-foreground",Js.primaryContrast),surface:n("--surface-background",Js.surface),surfaceElevated:n("--surface-elevated",Js.surfaceElevated),border:n("--border",Js.border),text:n("--foreground",Js.text),mutedText:n("--muted-foreground",Js.mutedText)}}catch{return{...Js,colorScheme:t}}finally{e.dispose()}};let ir=null,ar=null,ho=null,Br=0,Po=null;const on=new Set,Fx=3e4,Lx=45e3,Jd=()=>{ho&&(clearTimeout(ho),ho=null)},Zd=()=>{if(ar||on.size===0)return;const t=Math.min(1e3*Math.pow(2,Math.min(Br,5)),Fx);ar=setTimeout(()=>{ar=null,Br+=1,va()},t)},_r=()=>{Jd(),ir&&ir.close(),ir=null},xl=()=>{Jd(),on.size!==0&&(ho=setTimeout(()=>{_r(),Zd()},Lx))},$x=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}},Jr=t=>!t||typeof t!="object"?null:t,zx=t=>{if(t.type==="openchamber:event-stream-ready"){Br=0;return}if(t.type==="openchamber:heartbeat")return;if(t.type==="openchamber:agent-memory-changed"){const d=Jr(t.properties),f={type:"agent-memory-changed",scope:d?.scope==="project"?"project":"global",...typeof d?.projectId=="string"&&d.projectId.length>0?{projectId:d.projectId}:{}};for(const h of on)h(f);return}if(t.type==="openchamber:session-created"){const d=Jr(t.properties),u=typeof d?.sessionId=="string"?d.sessionId:"",f=typeof d?.directory=="string"?d.directory:"";if(!u||!f)return;const h={type:"session-created",sessionId:u,directory:f,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 x of on)x(h);return}if(t.type==="openchamber:browser-control-request"){const d=Jr(t.properties),u=typeof d?.requestId=="string"?d.requestId:"",f=typeof d?.action=="string"?d.action:"";if(!u||!f)return;const h=d?.parameters,x={type:"browser-control-request",requestId:u,action:f,parameters:h&&typeof h=="object"&&!Array.isArray(h)?h:{}};for(const b of on)b(x);return}if(t.type!=="openchamber:scheduled-task-ran")return;const e=Jr(t.properties),n=typeof e?.projectId=="string"?e.projectId:"",r=typeof e?.taskId=="string"?e.taskId:"",i=typeof e?.ranAt=="number"?e.ranAt:Date.now(),o=e?.status,l=o==="running"||o==="error"?o:"success";if(!n||!r)return;const a={type:"scheduled-task-ran",projectId:n,taskId:r,ranAt:i,status:l,...typeof e?.sessionId=="string"&&e.sessionId.length>0?{sessionId:e.sessionId}:{}};for(const d of on)d(a)},va=()=>{if(typeof window>"u"||on.size===0||typeof EventSource!="function"||ir&&ir.readyState!==EventSource.CLOSED)return;_r();const t=typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,e=new EventSource(qi().sse("/api/openchamber/events",t?{browser:"1"}:void 0));e.onopen=()=>{xl()},e.onmessage=n=>{xl();const r=$x(n.data);r&&zx(r)},e.onerror=()=>{_r(),Zd()},ir=e},Wx=()=>{Po||typeof window>"u"||(Po=Fo(()=>{_r(),Br=0,va()}))},Vx=()=>{Po?.(),Po=null},Vr=t=>(on.add(t),Wx(),va(),()=>{on.delete(t),on.size===0&&(ar&&(clearTimeout(ar),ar=null),Br=0,_r(),Vx())}),Ux=2e3,Hx=50;let Un=null,lr=null,Ar=null;const Kx=async t=>{try{const e=await ss("/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}},Jn=async(t,e)=>{try{const n=await ss("/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)}},Gx=async(t=Ux)=>{const e=Date.now()+t;for(;!Un&&Date.now()<e;)await new Promise(n=>setTimeout(n,Hx));return Un},qx=async t=>{const e=t.action==="browser.open",n=Un;if(!(!n&&!(e&&lr))&&await Kx(t.requestId))try{if(e&&!n){const i=typeof t.parameters.url=="string"?t.parameters.url:"";if(!i){await Jn(t.requestId,{ok:!1,error:"url is required"});return}lr?.(i);const o=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!o||o==="fill"){await Jn(t.requestId,{ok:!0,data:{url:i,opened:!0}});return}const l=await Gx();if(!l){await Jn(t.requestId,{ok:!0,data:{url:i,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 l.run("browser.resize",{viewport:o}),d=a&&typeof a=="object"?a.viewport??null:null;await Jn(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!0,viewport:d}});return}const r=await n.run(t.action,t.parameters);await Jn(t.requestId,{ok:!0,data:r})}catch(r){await Jn(t.requestId,{ok:!1,error:r instanceof Error?r.message:String(r)})}},eu=()=>{Ar||(Ar=Vr(t=>{t.type==="browser-control-request"&&qx({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},tu=()=>{Un||lr||!Ar||(Ar(),Ar=null)},Qx=t=>(Un=t,eu(),()=>{Un===t&&(Un=null),tu()}),Yx=t=>(lr=t,eu(),()=>{lr===t&&(lr=null),tu()}),Xx=50,Jx=6,Zx=2048,ey=200,su=t=>{const e=or(String(t??"").trim());if(!e||e.length>Zx)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},ty=(t,e)=>{const n=su(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,ey)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,Xx)},sy=(t,e)=>{const n=su(e);return t.filter(r=>r.url!==n)},ny=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),nu=(t,e,n=Jx)=>{const r=String(e??"").trim().toLowerCase(),i=[...t].sort((l,a)=>a.lastVisitedAt-l.lastVisitedAt);if(!r)return i.slice(0,n);const o=r.replace(/^https?:\/\//,"");return i.filter(l=>{const a=ny(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},yl=20,po=t=>{const e=yt((t||"").trim());return e?JSON.stringify([ks(),e]):""},ry=t=>{const e=Object.keys(t);if(e.length<=yl)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,yl);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},cr=Yn()(fp(t=>({byProject:{},recordVisit:(e,n)=>{const r=po(e);r&&t(i=>{const o=i.byProject[r]??[],l=ty(o,{...n,at:Date.now()});return l===o?i:{byProject:ry({...i.byProject,[r]:l})}})},forget:(e,n)=>{const r=po(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:sy(o,n)}}:i})},clear:e=>{const n=po(e);n&&t(r=>{if(!(n in r.byProject))return r;const i={...r.byProject};return delete i[n],{byProject:i}})}}),{name:"openchamber-browser-history",version:1,storage:Uu(),partialize:t=>({byProject:t.byProject})})),oy=[],ru=t=>e=>{const n=po(t);return(n?e.byProject[n]:void 0)??oy},Bi=new Map,Fr=new Map,ou=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,iu=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:!fr(e.toString())}catch{return!1}},au=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}},wl=(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 Dr extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const Sl=async t=>{if(!t||!ou()||!fr(t))return t;const e=Dn();if(!iu(e))return t;const n=au(t);if(!n)return t;const r=`${e}|${n}`,i=Bi.get(r);if(i){try{Fr.set(i,new URL(t).origin)}catch{}return wl(t,i)}try{const o=await Cr("desktop_dev_tunnel_open",{baseUrl:e,port:n,clientToken:Ir(),requestHeaders:jc()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new Dr(t);Bi.set(r,o.localPort);try{Fr.set(o.localPort,new URL(t).origin)}catch{}return wl(t,o.localPort)}catch(o){throw o instanceof Dr?o:new Dr(t)}},vl=t=>{if(!t||!ou()||!fr(t)||!iu(Dn()))return!1;const e=au(t);return e>0&&!Fr.has(e)},yr=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!=="127.0.0.1")return t;const n=Fr.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},iy=()=>{Bi.clear(),Fr.clear()};typeof window<"u"&&Fo(iy);const jl=6e3,ay=120,ly=80,cy=`
|
|
606
|
-
var MAX_ELEMENTS = ${ay};
|
|
607
|
-
var MAX_LABEL_CHARS = ${ly};
|
|
608
|
-
var visible = function (element) {
|
|
609
|
-
var rect = element.getBoundingClientRect();
|
|
610
|
-
if (rect.width < 1 || rect.height < 1) return false;
|
|
611
|
-
var style = window.getComputedStyle(element);
|
|
612
|
-
return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
|
|
613
|
-
};
|
|
614
|
-
var label = function (element) {
|
|
615
|
-
var aria = element.getAttribute('aria-label');
|
|
616
|
-
if (aria) return aria.trim();
|
|
617
|
-
var value = element.getAttribute('value');
|
|
618
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
619
|
-
if (text) return text.slice(0, MAX_LABEL_CHARS);
|
|
620
|
-
if (value) return String(value).slice(0, MAX_LABEL_CHARS);
|
|
621
|
-
var placeholder = element.getAttribute('placeholder');
|
|
622
|
-
return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
|
|
623
|
-
};
|
|
624
|
-
var isUnique = function (selector) {
|
|
625
|
-
try {
|
|
626
|
-
return document.querySelectorAll(selector).length === 1;
|
|
627
|
-
} catch (error) {
|
|
628
|
-
return false;
|
|
629
|
-
}
|
|
630
|
-
};
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* Names an element by what it is, falling back to where it sits.
|
|
634
|
-
*
|
|
635
|
-
* A positional chain like 'main > section:nth-of-type(3) > div > a' survives
|
|
636
|
-
* only until the markup shifts, and says nothing about what it points at.
|
|
637
|
-
* Anything the page states about identity — an id, a test id, an accessible
|
|
638
|
-
* name — outlives edits and reads as the thing it selects. The chain remains
|
|
639
|
-
* as the last resort, because something always has to work.
|
|
640
|
-
*/
|
|
641
|
-
var cssPath = function (element) {
|
|
642
|
-
var tag = element.tagName.toLowerCase();
|
|
643
|
-
|
|
644
|
-
if (element.id) {
|
|
645
|
-
var byId = '#' + CSS.escape(element.id);
|
|
646
|
-
if (isUnique(byId)) return byId;
|
|
647
|
-
}
|
|
648
|
-
var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
|
|
649
|
-
for (var a = 0; a < stableAttrs.length; a += 1) {
|
|
650
|
-
var value = element.getAttribute(stableAttrs[a]);
|
|
651
|
-
if (!value) continue;
|
|
652
|
-
var raw = String(value);
|
|
653
|
-
// A value containing a quote would need escaping for no real gain: such
|
|
654
|
-
// attributes are rare, and the positional chain still covers them.
|
|
655
|
-
if (raw.indexOf('"') !== -1) continue;
|
|
656
|
-
var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
|
|
657
|
-
if (isUnique(byAttr)) return byAttr;
|
|
658
|
-
}
|
|
659
|
-
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
660
|
-
if (className) {
|
|
661
|
-
var classes = className.split(/\\s+/).filter(Boolean);
|
|
662
|
-
for (var c = 0; c < classes.length; c += 1) {
|
|
663
|
-
var byClass = tag + '.' + CSS.escape(classes[c]);
|
|
664
|
-
if (isUnique(byClass)) return byClass;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
var parts = [];
|
|
669
|
-
var node = element;
|
|
670
|
-
var depth = 0;
|
|
671
|
-
while (node && node.nodeType === 1 && depth < 6) {
|
|
672
|
-
var part = node.tagName.toLowerCase();
|
|
673
|
-
var parent = node.parentElement;
|
|
674
|
-
if (!parent) { parts.unshift(part); break; }
|
|
675
|
-
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
676
|
-
return child.tagName === node.tagName;
|
|
677
|
-
});
|
|
678
|
-
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
679
|
-
parts.unshift(part);
|
|
680
|
-
if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
|
|
681
|
-
node = parent;
|
|
682
|
-
depth += 1;
|
|
683
|
-
}
|
|
684
|
-
return parts.join(' > ');
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
/** What a screen reader would announce, or '' when there is nothing to say. */
|
|
688
|
-
var accessibleName = function (element) {
|
|
689
|
-
var aria = element.getAttribute('aria-label');
|
|
690
|
-
if (aria && aria.trim()) return aria.trim();
|
|
691
|
-
var labelled = element.getAttribute('aria-labelledby');
|
|
692
|
-
if (labelled) {
|
|
693
|
-
var source = document.getElementById(labelled.split(/\\s+/)[0]);
|
|
694
|
-
if (source && (source.innerText || '').trim()) return source.innerText.trim();
|
|
695
|
-
}
|
|
696
|
-
var title = element.getAttribute('title');
|
|
697
|
-
if (title && title.trim()) return title.trim();
|
|
698
|
-
var alt = element.getAttribute('alt');
|
|
699
|
-
if (alt && alt.trim()) return alt.trim();
|
|
700
|
-
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
701
|
-
if (text) return text;
|
|
702
|
-
var value = element.getAttribute('value');
|
|
703
|
-
return value && String(value).trim() ? String(value).trim() : '';
|
|
704
|
-
};
|
|
705
|
-
var findByText = function (needle) {
|
|
706
|
-
var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
|
|
707
|
-
var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
|
|
708
|
-
var exact = null;
|
|
709
|
-
var partial = null;
|
|
710
|
-
for (var i = 0; i < candidates.length; i += 1) {
|
|
711
|
-
var element = candidates[i];
|
|
712
|
-
if (!visible(element)) continue;
|
|
713
|
-
var text = label(element).toLowerCase();
|
|
714
|
-
if (!text) continue;
|
|
715
|
-
if (text === wanted) { exact = element; break; }
|
|
716
|
-
if (!partial && text.indexOf(wanted) !== -1) partial = element;
|
|
717
|
-
}
|
|
718
|
-
return exact || partial;
|
|
719
|
-
};
|
|
720
|
-
`,Ur=t=>`(() => {
|
|
721
|
-
${cy}
|
|
722
|
-
${t}
|
|
723
|
-
})()`,dy=({selector:t}={})=>Ur(`
|
|
724
|
-
var scopeSelector = ${JSON.stringify(t??"")};
|
|
725
|
-
var root = document;
|
|
726
|
-
if (scopeSelector) {
|
|
727
|
-
try { root = document.querySelector(scopeSelector); }
|
|
728
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
|
|
729
|
-
if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
|
|
730
|
-
}
|
|
731
|
-
var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
|
|
732
|
-
var elements = [];
|
|
733
|
-
var visibleTotal = 0;
|
|
734
|
-
for (var i = 0; i < interactive.length; i += 1) {
|
|
735
|
-
var element = interactive[i];
|
|
736
|
-
if (!visible(element)) continue;
|
|
737
|
-
visibleTotal += 1;
|
|
738
|
-
if (elements.length >= MAX_ELEMENTS) continue;
|
|
739
|
-
|
|
740
|
-
var rect = element.getBoundingClientRect();
|
|
741
|
-
// Empty and default-valued fields are left out rather than serialized as
|
|
742
|
-
// "" and false. Repeated across a hundred entries that overhead dwarfed
|
|
743
|
-
// the information it carried.
|
|
744
|
-
var entry = {
|
|
745
|
-
selector: cssPath(element),
|
|
746
|
-
tag: element.tagName.toLowerCase(),
|
|
747
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
748
|
-
};
|
|
749
|
-
// The list covers the whole document so anything can be clicked without
|
|
750
|
-
// scrolling to it first, which means bounds alone do not say what is on
|
|
751
|
-
// screen — a negative y reads as a bug otherwise.
|
|
752
|
-
if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
|
|
753
|
-
var type = element.getAttribute('type');
|
|
754
|
-
if (type) entry.type = type;
|
|
755
|
-
var role = element.getAttribute('role');
|
|
756
|
-
if (role) entry.role = role;
|
|
757
|
-
var labelText = label(element);
|
|
758
|
-
if (labelText) entry.label = labelText;
|
|
759
|
-
if (element.disabled === true) entry.disabled = true;
|
|
760
|
-
// Flagged rather than described: reporting the accessible name of every
|
|
761
|
-
// element would cost more than it tells, while its absence on something
|
|
762
|
-
// clickable is a defect worth naming.
|
|
763
|
-
if (!accessibleName(element)) entry.missingAccessibleName = true;
|
|
764
|
-
elements.push(entry);
|
|
765
|
-
}
|
|
766
|
-
var body = document.body ? (document.body.innerText || '') : '';
|
|
767
|
-
var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
|
|
768
|
-
var docEl = document.documentElement;
|
|
769
|
-
var result = {
|
|
770
|
-
ok: true,
|
|
771
|
-
url: String(location.href),
|
|
772
|
-
title: String(document.title || ''),
|
|
773
|
-
scope: scopeSelector || 'document',
|
|
774
|
-
scrollY: Math.round(window.scrollY),
|
|
775
|
-
maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
|
|
776
|
-
text: text.slice(0, ${jl}),
|
|
777
|
-
elements: elements
|
|
778
|
-
};
|
|
779
|
-
// State what was dropped. A capped list that reports only its own length
|
|
780
|
-
// reads as the whole page, and the agent acts as if it had seen everything.
|
|
781
|
-
if (text.length > ${jl}) {
|
|
782
|
-
result.textTruncated = true;
|
|
783
|
-
result.textTotalChars = text.length;
|
|
784
|
-
}
|
|
785
|
-
if (visibleTotal > elements.length) {
|
|
786
|
-
result.elementsTruncated = true;
|
|
787
|
-
result.interactiveElementsOnPage = visibleTotal;
|
|
788
|
-
}
|
|
789
|
-
return result;
|
|
790
|
-
`),uy=({selector:t,text:e})=>Ur(`
|
|
791
|
-
var selector = ${JSON.stringify(t??"")};
|
|
792
|
-
var text = ${JSON.stringify(e??"")};
|
|
793
|
-
var target = null;
|
|
794
|
-
if (selector) {
|
|
795
|
-
try { target = document.querySelector(selector); }
|
|
796
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
797
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
798
|
-
} else {
|
|
799
|
-
target = findByText(text);
|
|
800
|
-
if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
|
|
801
|
-
}
|
|
802
|
-
if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
|
|
803
|
-
target.scrollIntoView({ block: 'center', inline: 'center' });
|
|
804
|
-
target.click();
|
|
805
|
-
return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
|
|
806
|
-
`),fy=({selector:t,value:e,submit:n})=>Ur(`
|
|
807
|
-
var selector = ${JSON.stringify(t)};
|
|
808
|
-
var value = ${JSON.stringify(e)};
|
|
809
|
-
var target = null;
|
|
810
|
-
try { target = document.querySelector(selector); }
|
|
811
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
812
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
813
|
-
|
|
814
|
-
var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
815
|
-
if (!editable) return { ok: false, error: selector + ' is not a text field' };
|
|
816
|
-
if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
|
|
817
|
-
|
|
818
|
-
target.scrollIntoView({ block: 'center' });
|
|
819
|
-
target.focus();
|
|
820
|
-
if (target.isContentEditable) {
|
|
821
|
-
target.textContent = value;
|
|
822
|
-
} else {
|
|
823
|
-
// Frameworks track the value through the native setter; assigning the
|
|
824
|
-
// property directly leaves React and friends unaware of the change.
|
|
825
|
-
var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
826
|
-
var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
|
|
827
|
-
if (setter && setter.set) setter.set.call(target, value);
|
|
828
|
-
else target.value = value;
|
|
829
|
-
}
|
|
830
|
-
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
831
|
-
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
832
|
-
|
|
833
|
-
if (${n?"true":"false"}) {
|
|
834
|
-
var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
|
|
835
|
-
target.dispatchEvent(new KeyboardEvent('keydown', enter));
|
|
836
|
-
target.dispatchEvent(new KeyboardEvent('keyup', enter));
|
|
837
|
-
var form = target.form;
|
|
838
|
-
if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
|
|
839
|
-
}
|
|
840
|
-
return { ok: true, selector: cssPath(target), url: String(location.href) };
|
|
841
|
-
`),my=({selector:t,direction:e})=>Ur(`
|
|
842
|
-
var selector = ${JSON.stringify(t??"")};
|
|
843
|
-
var direction = ${JSON.stringify(e??"")};
|
|
844
|
-
|
|
845
|
-
var settle = function (extra) {
|
|
846
|
-
return new Promise(function (resolve) {
|
|
847
|
-
requestAnimationFrame(function () {
|
|
848
|
-
requestAnimationFrame(function () {
|
|
849
|
-
var doc = document.documentElement;
|
|
850
|
-
var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
851
|
-
var scrollY = Math.round(window.scrollY);
|
|
852
|
-
var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
|
|
853
|
-
result.atTop = scrollY <= 1;
|
|
854
|
-
result.atBottom = scrollY >= maxScrollY - 1;
|
|
855
|
-
for (var key in extra) {
|
|
856
|
-
if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
|
|
857
|
-
}
|
|
858
|
-
resolve(result);
|
|
859
|
-
});
|
|
860
|
-
});
|
|
861
|
-
});
|
|
862
|
-
};
|
|
863
|
-
|
|
864
|
-
if (selector) {
|
|
865
|
-
var target = null;
|
|
866
|
-
try { target = document.querySelector(selector); }
|
|
867
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
868
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
869
|
-
// Instant on purpose: the page's own smooth scrolling would still be
|
|
870
|
-
// animating when the next action runs against it.
|
|
871
|
-
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
872
|
-
return settle({ scrolledTo: cssPath(target) });
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
var doc = document.documentElement;
|
|
876
|
-
var page = Math.round(window.innerHeight * 0.85);
|
|
877
|
-
var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
878
|
-
if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
|
|
879
|
-
else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
|
|
880
|
-
else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
|
|
881
|
-
else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
|
|
882
|
-
else return { ok: false, error: 'Unknown scroll direction: ' + direction };
|
|
883
|
-
return settle({ direction: direction });
|
|
884
|
-
`),hy=["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"],py=({selector:t})=>Ur(`
|
|
885
|
-
var selector = ${JSON.stringify(t)};
|
|
886
|
-
var target = null;
|
|
887
|
-
try { target = document.querySelector(selector); }
|
|
888
|
-
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
889
|
-
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
890
|
-
|
|
891
|
-
var computed = window.getComputedStyle(target);
|
|
892
|
-
var styles = {};
|
|
893
|
-
var props = ${JSON.stringify(hy)};
|
|
894
|
-
for (var i = 0; i < props.length; i += 1) {
|
|
895
|
-
var value = computed.getPropertyValue(props[i]);
|
|
896
|
-
if (value) styles[props[i]] = String(value).trim();
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
var rect = target.getBoundingClientRect();
|
|
900
|
-
return {
|
|
901
|
-
ok: true,
|
|
902
|
-
selector: cssPath(target),
|
|
903
|
-
tag: target.tagName.toLowerCase(),
|
|
904
|
-
label: label(target),
|
|
905
|
-
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
906
|
-
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
907
|
-
styles: styles
|
|
908
|
-
};
|
|
909
|
-
`),gy=t=>{const e=Je.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=ft();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]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let h;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(h=(x,b)=>s.jsxs("div",{role:"option","aria-selected":b===r,className:Pe("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",b===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:w=>{w.preventDefault(),i(x.url)},onPointerEnter:()=>l(b),children:[s.jsx(O,{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:x.title||wa(x.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:x.url})]}),s.jsx("button",{type:"button",className:Pe("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:w=>{w.preventDefault(),w.stopPropagation(),o(x.url)},children:s.jsx(O,{name:"close",className:"size-3","aria-hidden":"true"})})]},x.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=h):h=e[14],u=n.map(h),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let f;return e[15]!==d||e[16]!==u?(f=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]=f):f=e[17],f},Zs=t=>{const e=Je.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=Pe("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let f;e[2]!==n?(f=s.jsx(O,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=f):f=e[3];let h;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==f?(h=s.jsx(ht,{asChild:!0,children:s.jsx(lt,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:f})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=f,e[11]=h):h=e[11];let x;e[12]!==r?(x=s.jsx(pt,{sideOffset:6,children:r}),e[12]=r,e[13]=x):x=e[13];let b;return e[14]!==h||e[15]!==x?(b=s.jsxs(gt,{children:[h,x]}),e[14]=h,e[15]=x,e[16]=b):b=e[16],b},lu=t=>{const e=Je.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:f,canGoBack:h,canGoForward:x,isLoading:b,onAnnotate:w,onOpenDevTools:S,isAnnotating:g,onHardReload:m,onZoomIn:p,onZoomOut:y,onZoomReset:v,zoomPercent:N,onClearCookies:C,onClearCache:k,onToggleDeviceBar:A,isDeviceBarOpen:D}=t;let P;e[0]!==r?(P=r===void 0?[]:r,e[0]=r,e[1]=P):P=e[1];const T=P,$=N===void 0?100:N,{t:E}=ft(),[U,I]=c.useState(!1),[B,R]=c.useState(-1);let j;e[2]!==U||e[3]!==T?(j=U?T:[],e[2]=U,e[3]=T,e[4]=j):j=e[4];const M=j;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{R(-1)},e[5]=L):L=e[5];let W;e[6]!==n||e[7]!==U?(W=[n,U],e[6]=n,e[7]=U,e[8]=W):W=e[8],c.useEffect(L,W);let te;e[9]!==l?(te=X=>{I(!1),R(-1),l(X)},e[9]=l,e[10]=te):te=e[10];const Q=te;let me;e[11]!==B||e[12]!==Q||e[13]!==M?(me=X=>{if(M.length!==0){if(X.key==="ArrowDown"||X.key==="ArrowUp"){X.preventDefault();const Oe=X.key==="ArrowDown"?1:-1,Fe=M.length;R(_=>{const ue=_+Oe;return ue<-1?Fe-1:ue>=Fe?-1:ue});return}if(X.key==="Escape"&&B>=0){X.preventDefault(),R(-1);return}if(X.key==="Enter"&&B>=0){X.preventDefault();const Oe=M[B];Oe&&Q(Oe.url)}}},e[11]=B,e[12]=Q,e[13]=M,e[14]=me):me=e[14];const ce=me;let H;e[15]!==E?(H=E("contextPanel.browser.back"),e[15]=E,e[16]=H):H=e[16];const ne=!h;let ie;e[17]!==a||e[18]!==ne||e[19]!==H?(ie=s.jsx(Zs,{icon:"arrow-left",label:H,onClick:a,disabled:ne}),e[17]=a,e[18]=ne,e[19]=H,e[20]=ie):ie=e[20];let F;e[21]!==E?(F=E("contextPanel.browser.forward"),e[21]=E,e[22]=F):F=e[22];const Z=!x;let G;e[23]!==d||e[24]!==F||e[25]!==Z?(G=s.jsx(Zs,{icon:"arrow-right",label:F,onClick:d,disabled:Z}),e[23]=d,e[24]=F,e[25]=Z,e[26]=G):G=e[26];let V;e[27]!==b||e[28]!==E?(V=E(b?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=b,e[28]=E,e[29]=V):V=e[29];let Y;e[30]!==u||e[31]!==V?(Y=s.jsx(Zs,{icon:"refresh",label:V,onClick:u}),e[30]=u,e[31]=V,e[32]=Y):Y=e[32];let le;e[33]!==m||e[34]!==E?(le=m?s.jsx(Zs,{icon:"restart",label:E("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=E,e[35]=le):le=e[35];let pe;e[36]!==n||e[37]!==Q?(pe=X=>{X.preventDefault(),Q(n)},e[36]=n,e[37]=Q,e[38]=pe):pe=e[38];let be;e[39]!==o?(be=X=>o(X.target.value),e[39]=o,e[40]=be):be=e[40];let Se,De;e[41]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>I(!0),De=()=>I(!1),e[41]=Se,e[42]=De):(Se=e[41],De=e[42]);const fe=M.length>0;let xe;e[43]===Symbol.for("react.memo_cache_sentinel")?(xe=Pe("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]=xe):xe=e[43];let ge;e[44]!==E?(ge=E("contextPanel.browser.addressAria"),e[44]=E,e[45]=ge):ge=e[45];let re;e[46]!==n||e[47]!==ce||e[48]!==be||e[49]!==fe||e[50]!==ge?(re=s.jsx("input",{value:n,onChange:be,onFocus:Se,onBlur:De,onKeyDown:ce,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":fe,"aria-controls":"openchamber-browser-address-suggestions",className:xe,"aria-label":ge}),e[46]=n,e[47]=ce,e[48]=be,e[49]=fe,e[50]=ge,e[51]=re):re=e[51];let he;e[52]!==i?(he=X=>i?.(X),e[52]=i,e[53]=he):he=e[53];let Ne;e[54]!==B||e[55]!==Q||e[56]!==he||e[57]!==M?(Ne=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(gy,{entries:M,activeIndex:B,onSelect:Q,onForget:he,onHighlight:R})}),e[54]=B,e[55]=Q,e[56]=he,e[57]=M,e[58]=Ne):Ne=e[58];let de;e[59]!==pe||e[60]!==re||e[61]!==Ne?(de=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:pe,children:[re,Ne]}),e[59]=pe,e[60]=re,e[61]=Ne,e[62]=de):de=e[62];let oe;e[63]!==p||e[64]!==y||e[65]!==v||e[66]!==E||e[67]!==$?(oe=y&&p?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(Zs,{icon:"subtract",label:E("contextPanel.browser.zoomOut"),onClick:y}),$!==100&&v?s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsxs(lt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:v,"aria-label":E("contextPanel.browser.zoomReset"),children:[$,"%"]})}),s.jsx(pt,{sideOffset:6,children:E("contextPanel.browser.zoomReset")})]}):null,s.jsx(Zs,{icon:"add",label:E("contextPanel.browser.zoomIn"),onClick:p})]}):null,e[63]=p,e[64]=y,e[65]=v,e[66]=E,e[67]=$,e[68]=oe):oe=e[68];let K;e[69]!==C||e[70]!==E?(K=C?s.jsx(Zs,{icon:"delete-bin",label:E("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=E,e[71]=K):K=e[71];let z;e[72]!==k||e[73]!==E?(z=k?s.jsx(Zs,{icon:"database-2",label:E("contextPanel.browser.clearCache"),onClick:k}):null,e[72]=k,e[73]=E,e[74]=z):z=e[74];let ae;e[75]!==D||e[76]!==A||e[77]!==E?(ae=A?s.jsx(Zs,{icon:"smartphone",label:E("contextPanel.browser.deviceToolbar"),onClick:A,pressed:D}):null,e[75]=D,e[76]=A,e[77]=E,e[78]=ae):ae=e[78];let ve;e[79]!==g||e[80]!==w||e[81]!==E?(ve=w?s.jsx(Zs,{icon:"markup",label:E("contextPanel.browser.annotate.toggle"),onClick:w,pressed:g}):null,e[79]=g,e[80]=w,e[81]=E,e[82]=ve):ve=e[82];let ye;e[83]!==S||e[84]!==E?(ye=S?s.jsx(Zs,{icon:"terminal-box",label:E("contextPanel.browser.devTools"),onClick:S}):null,e[83]=S,e[84]=E,e[85]=ye):ye=e[85];let We;e[86]!==E?(We=E("contextPanel.browser.openExternal"),e[86]=E,e[87]=We):We=e[87];let Be;e[88]!==f||e[89]!==We?(Be=s.jsx(Zs,{icon:"external-link",label:We,onClick:f}),e[88]=f,e[89]=We,e[90]=Be):Be=e[90];let Ae;return e[91]!==ie||e[92]!==G||e[93]!==Y||e[94]!==le||e[95]!==de||e[96]!==oe||e[97]!==K||e[98]!==z||e[99]!==ae||e[100]!==ve||e[101]!==ye||e[102]!==Be?(Ae=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[ie,G,Y,le,de,oe,K,z,ae,ve,ye,Be]}),e[91]=ie,e[92]=G,e[93]=Y,e[94]=le,e[95]=de,e[96]=oe,e[97]=K,e[98]=z,e[99]=ae,e[100]=ve,e[101]=ye,e[102]=Be,e[103]=Ae):Ae=e[103],Ae},Io={kind:"fill"},kl=240,by=3840,cu=[{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}],Cl=t=>Number.isFinite(t)?Math.round(Math.min(by,Math.max(kl,t))):kl,To=t=>t.kind==="fill"?null:{width:t.width,height:t.height},du=t=>{const e=cu.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},xy=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},yy=(t,e)=>{const n=To(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},wy=["mobile","tablet","desktop","fill"],Sy={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Nl=t=>typeof t=="string"&&wy.includes(t),_i=t=>t==="fill"?Io:du(Sy[t])??Io,Zr=t=>{const e=To(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=_i(n),i=To(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},vy=t=>{const e=Je.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=ft();let d;e[0]!==n?(d=To(n),e[0]=n,e[1]=d):d=e[1];const u=d,f=n.kind==="preset"?n.id:"";let h;e[2]!==r||e[3]!==u?(h=(ne,ie)=>{const F=Number.parseInt(ie,10);if(!Number.isFinite(F))return;const Z=u??{width:1280,height:800};r({kind:"custom",width:Cl(ne==="width"?F:Z.width),height:Cl(ne==="height"?F:Z.height)})},e[2]=r,e[3]=u,e[4]=h):h=e[4];const x=h;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=Pe("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 w=b;let S;e[6]!==r?(S=ne=>{const ie=du(ne.target.value);r(ie??Io)},e[6]=r,e[7]=S):S=e[7];let g;e[8]!==a?(g=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=g):g=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=Pe("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 p;e[11]!==a?(p=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=p):p=e[12];let y;e[13]!==p?(y=s.jsx("option",{value:"",children:p}),e[13]=p,e[14]=y):y=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=cu.map(jy),e[15]=v):v=e[15];let N;e[16]!==f||e[17]!==S||e[18]!==g||e[19]!==y?(N=s.jsxs("select",{value:f,onChange:S,"aria-label":g,className:m,children:[y,v]}),e[16]=f,e[17]=S,e[18]=g,e[19]=y,e[20]=N):N=e[20];const C=u?String(u.width):"";let k;e[21]!==x?(k=ne=>x("width",ne.target.value),e[21]=x,e[22]=k):k=e[22];let A;e[23]!==a?(A=a("contextPanel.browser.device.width"),e[23]=a,e[24]=A):A=e[24];let D;e[25]!==C||e[26]!==k||e[27]!==A?(D=s.jsx("input",{value:C,onChange:k,placeholder:"—",inputMode:"numeric","aria-label":A,className:w}),e[25]=C,e[26]=k,e[27]=A,e[28]=D):D=e[28];let P;e[29]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=P):P=e[29];const T=u?String(u.height):"";let $;e[30]!==x?($=ne=>x("height",ne.target.value),e[30]=x,e[31]=$):$=e[31];let E;e[32]!==a?(E=a("contextPanel.browser.device.height"),e[32]=a,e[33]=E):E=e[33];let U;e[34]!==T||e[35]!==$||e[36]!==E?(U=s.jsx("input",{value:T,onChange:$,placeholder:"—",inputMode:"numeric","aria-label":E,className:w}),e[34]=T,e[35]=$,e[36]=E,e[37]=U):U=e[37];let I;e[38]!==r||e[39]!==n?(I=()=>r(xy(n)),e[38]=r,e[39]=n,e[40]=I):I=e[40];const B=!u;let R;e[41]!==a?(R=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=R):R=e[42];let j;e[43]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(O,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=j):j=e[43];let M;e[44]!==I||e[45]!==B||e[46]!==R?(M=s.jsx(ht,{asChild:!0,children:s.jsx(lt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:I,disabled:B,"aria-label":R,children:j})}),e[44]=I,e[45]=B,e[46]=R,e[47]=M):M=e[47];let L;e[48]!==a?(L=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=L):L=e[49];let W;e[50]!==L?(W=s.jsx(pt,{sideOffset:6,children:L}),e[50]=L,e[51]=W):W=e[51];let te;e[52]!==M||e[53]!==W?(te=s.jsxs(gt,{children:[M,W]}),e[52]=M,e[53]=W,e[54]=te):te=e[54];let Q;e[55]!==l||e[56]!==u?(Q=u&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=Q):Q=e[57];let me;e[58]===Symbol.for("react.memo_cache_sentinel")?(me=["system","light","dark"],e[58]=me):me=e[58];let ce;e[59]!==i||e[60]!==o||e[61]!==a?(ce=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:me.map(ne=>s.jsx(lt,{type:"button",variant:i===ne?"secondary":"ghost",size:"xs",className:Pe("shrink-0 rounded-full px-2.5 typography-micro",i===ne?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(ne),"aria-pressed":i===ne,children:a(ne==="system"?"contextPanel.browser.device.schemeSystem":ne==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},ne))}),e[59]=i,e[60]=o,e[61]=a,e[62]=ce):ce=e[62];let H;return e[63]!==N||e[64]!==D||e[65]!==U||e[66]!==te||e[67]!==Q||e[68]!==ce?(H=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,D,P,U,te,Q,ce]}),e[63]=N,e[64]=D,e[65]=U,e[66]=te,e[67]=Q,e[68]=ce,e[69]=H):H=e[69],H};function jy(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const ky=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},Cy=2e3,Ny=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=Dn();if(!t)return!1;try{return!fr(new URL(t,window.location.href).toString())}catch{return!1}},uu=t=>{const e=Je.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=ft();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,d]=c.useState(l),u=bg(i),[f]=c.useState(Ny);let h,x;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{let D=!0,P=null;const T=new AbortController,$=()=>{bx(T.signal).then(E=>{D&&(d(E),P=setTimeout($,Cy))})};return $(),()=>{D=!1,P&&clearTimeout(P),T.abort()}},x=[],e[1]=h,e[2]=x):(h=e[1],x=e[2]),c.useEffect(h,x);const b=a.kind==="ready"?a.servers:null;let w;e[3]!==u||e[4]!==b?(w=wx({announced:u,discovered:b}),e[3]=u,e[4]=b,e[5]=w):w=e[5];const S=w;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(_c,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=g):g=e[6];let m;e[7]!==o?(m=o("contextPanel.browser.empty"),e[7]=o,e[8]=m):m=e[8];let p;e[9]!==m?(p=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=p):p=e[10];let y;e[11]!==o?(y=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=y):y=e[12];let v;e[13]!==y?(v=s.jsx("span",{className:"typography-micro text-muted-foreground",children:y}),e[13]=y,e[14]=v):v=e[14];let N;e[15]!==v||e[16]!==p?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[p,v]}),e[15]=v,e[16]=p,e[17]=N):N=e[17];let C;e[18]!==u||e[19]!==S||e[20]!==i||e[21]!==n||e[22]!==f||e[23]!==o?(C=S.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?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),f?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:S.map(D=>s.jsxs(lt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{hg(i),n(D.url)},children:[s.jsx(O,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:wa(D.url)||D.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:ky(D.url)})]},D.port))})]}):null,e[18]=u,e[19]=S,e[20]=i,e[21]=n,e[22]=f,e[23]=o,e[24]=C):C=e[24];let k;e[25]!==S.length||e[26]!==a.kind||e[27]!==o?(k=S.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=S.length,e[26]=a.kind,e[27]=o,e[28]=k):k=e[28];let A;return e[29]!==N||e[30]!==C||e[31]!==k?(A=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:[g,N,C,k]}),e[29]=N,e[30]=C,e[31]=k,e[32]=A):A=e[32],A},_s=t=>Math.round(t),Ay=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${_s(l.x)}, y=${_s(l.y)}, width=${_s(l.width)}, height=${_s(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},Dy=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${_s(n.x)}, y=${_s(n.y)}, width=${_s(n.width)}, height=${_s(n.height)}`},Py=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${_s(n.x)}, y=${_s(n.y)}, width=${_s(n.width)}, height=${_s(n.height)}`},Iy=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${_s(t.viewport.width)}x${_s(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...Ay(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(Dy(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(Py(l,a)))),o.filter(l=>typeof l=="string").join(`
|
|
910
|
-
`)},Ty=t=>{const e=Je.c(7),{t:n}=ft(),r=Qe(Ry),i=Qe(My),o=bi(Oy),l=Lf(By);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){Re.error(n("contextPanel.browser.annotate.noSession"));return}let f=!1;if(d.screenshot)try{await l(d.screenshot),f=!0}catch{f=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:Iy({payload:d.payload,screenshotAttached:f,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Re.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},Ey=()=>{const t=Je.c(16),{t:e}=ft();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 i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function Ry(t){return t.currentSessionId}function My(t){return t.newSessionDraft?.open}function Oy(t){return t.addDraft}function By(t){return t.addAttachedFile}const _y=3e4,Fy=3,Ly=250,$y={attempts:0,windowStartedAt:null},zy=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=_y,r=n?0:t.attempts;return r>=Fy?null:{delayMs:Ly*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Wy=-3,eo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",sr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Vy=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:jx),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,f]=c.useState(!1),[h,x]=c.useState(!1),b=c.useRef(n);b.current=n;const w=c.useRef($y);return c.useEffect(()=>{if(!t)return;const S=()=>{try{const P=t.getURL();return eo(P)?P:""}catch{return""}},g=()=>{try{f(t.canGoBack()),x(t.canGoForward())}catch{}},m=P=>{eo(P)&&(l(P),b.current(P))},p=()=>{const P=S();i({kind:"loading",url:P})},y=()=>{const P=S();let T="";try{T=t.getTitle()||""}catch{T=""}d(T),m(P),g(),i($=>$.kind==="failed"&&$.url===P?$:{kind:"ready",url:P,title:T})},v=P=>{const T=sr(P);eo(T.url)&&(m(T.url),g())},N=P=>{const T=sr(P),$=Array.isArray(T.favicons)?T.favicons.find(Boolean):"",E=S();$&&E&&Qd.getState().resolve(E,$)},C=P=>{const T=sr(P);typeof T.title=="string"&&d(T.title)},k=P=>{const T=sr(P);if(T.isMainFrame===!1)return;const $=typeof T.errorCode=="number"?T.errorCode:0;$!==Wy&&i({kind:"failed",url:eo(T.validatedURL)?T.validatedURL:S(),code:$,description:typeof T.errorDescription=="string"?T.errorDescription:""})};let A=null;const D=()=>{const P=S(),T=zy(w.current,Date.now());if(!T){i({kind:"failed",url:P,code:0,description:"",crashed:!0});return}w.current=T.state,i({kind:"loading",url:P}),A=setTimeout(()=>{A=null;try{t.reload()}catch{i({kind:"failed",url:P,code:0,description:"",crashed:!0})}},T.delayMs)};t.addEventListener("did-start-loading",p),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",v),t.addEventListener("did-navigate-in-page",v),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",k),t.addEventListener("render-process-gone",D),t.addEventListener("crashed",D);try{!t.isLoading()&&S()&&y()}catch{}return()=>{A!==null&&clearTimeout(A),t.removeEventListener("render-process-gone",D),t.removeEventListener("crashed",D),t.removeEventListener("did-start-loading",p),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",v),t.removeEventListener("did-navigate-in-page",v),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",k)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:h}},Uy=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Hy=4e4,Al=.5,Ky=-3,Gy=4,qy="persist:openchamber-browser",Dl=20,Qy=600,Yy=2e4,Xy=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=ft(),{currentTheme:i}=qn(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(de=>{o.current=de,a(de)},[]),u=Ce(de=>de.setContextPanelTabTargetPath),f=c.useRef(or(t)),h=f.current!==en?f.current:"",[x,b]=c.useState(h?null:en),[w,S]=c.useState(h),[g,m]=c.useState(!1),[p,y]=c.useState(!1),[v,N]=c.useState(0),[C,k]=c.useState(!1),[A,D]=c.useState(Io),P=c.useRef(A);P.current=A;const T=c.useRef([]),[$,E]=c.useState("system"),[U,I]=c.useState({width:0,height:0}),B=c.useRef(null),R=c.useRef(null),j=c.useRef(!1),M=c.useRef(Date.now()),L=c.useCallback(de=>{!de||de===en||!e||!n||u(e,n,de)},[e,n,u]),W=Vy(l,{initialUrl:h,onUrlChange:c.useCallback(de=>{const oe=yr(de);S(oe),L(oe)},[L])}),[te,Q]=c.useState(null),me=Ty(e),ce=Ey(),H=W.status.kind==="loading",ne=cr(ru(e)),ie=cr(de=>de.recordVisit),F=cr(de=>de.forget);c.useEffect(()=>{W.status.kind==="ready"&&ie(e,{url:yr(W.status.url),title:W.status.title})},[e,W.status,ie]);const Z=c.useMemo(()=>nu(ne,w),[ne,w]),G=c.useCallback(de=>{const oe=or(de);oe!==en&&(S(oe),Q(null),Sl(oe).then(K=>{const z=o.current;if(!z){b(K);return}try{z.loadURL(K)}catch{b(K)}}).catch(K=>{K instanceof Dr&&Q(oe)}))},[]);c.useEffect(()=>{if(!h)return;let de=!0;return Sl(h).then(oe=>{de&&b(oe)}).catch(oe=>{if(de){if(oe instanceof Dr){Q(h),b(en);return}b(h)}}),()=>{de=!1}},[]);const V=c.useMemo(()=>({executeJavaScript:async(de,oe)=>{const K=o.current;if(!K)throw new Error("Browser view is not available");return K.executeJavaScript(de,oe)},capturePage:async()=>{const de=o.current;if(!de)return null;const oe=de.getWebContentsId();return Number.isFinite(oe)?await Cr("desktop_browser_capture_page",{webContentsId:oe}):null}}),[]),Y=c.useCallback(()=>{if(g){m(!1),mo(V);return}if(!W.url){Re.error(r("contextPanel.browser.annotate.noPage"));return}const de=_x(i.metadata.variant==="light"?"light":"dark");m(!0),Ox({host:V,theme:de,labels:ce}).then(async oe=>{m(!1),oe&&await me(oe)}).catch(()=>{m(!1),Re.error(r("contextPanel.browser.annotate.failed"))})},[V,me,i,g,W.url,ce,r]);c.useEffect(()=>{if(!g)return;const de=oe=>{oe.key==="Escape"&&(oe.preventDefault(),oe.stopImmediatePropagation(),m(!1),mo(V))};return window.addEventListener("keydown",de,!0),()=>window.removeEventListener("keydown",de,!0)},[V,g]);const le=c.useCallback(async(de=8e3)=>{const oe=Date.now();for(;;){const K=o.current;if(!K)return!1;let z=!1;try{z=K.isLoading()}catch{return!1}if(!z)return!0;if(Date.now()-oe>de)return!1;await new Promise(ae=>setTimeout(ae,120))}},[]),pe=c.useCallback(async(de,oe)=>{const K=o.current;if(!K)throw new Error("The browser panel is not ready");const z=()=>{Nl(oe.viewport)&&(D(_i(oe.viewport)),k(!0))};if(de==="browser.back"||de==="browser.forward"){const Ae=de==="browser.back";if(!(Ae?K.canGoBack():K.canGoForward()))throw new Error(Ae?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Ae?K.goBack():K.goForward(),await new Promise(Fe=>setTimeout(Fe,150)),await le();let Oe="";try{Oe=K.getTitle()||""}catch{Oe=""}return{url:yr(K.getURL()),title:Oe}}if(de==="browser.capture"){await le();const Ae=await V.capturePage();if(!Ae)throw new Error("The page could not be captured");let X="";try{X=K.getTitle()||""}catch{X=""}return{...Ae,url:yr(K.getURL()),title:X,viewport:Zr(P.current)}}if(de==="browser.resize"){if(!Nl(oe.viewport))throw new Error("viewport is required");return z(),await new Promise(Ae=>setTimeout(Ae,200)),await le(),{viewport:Zr(_i(oe.viewport))}}if(de==="browser.open"){const Ae=typeof oe.url=="string"?oe.url:"";if(!Ae)throw new Error("url is required");z(),G(Ae),await new Promise(Fe=>setTimeout(Fe,150));const X=await le(25e3);let Oe="";try{Oe=K.getTitle()||""}catch{Oe=""}return{url:or(Ae),title:Oe,opened:!0,settled:X,viewport:Zr(P.current)}}await le();const ae=Ae=>typeof Ae=="string"&&Ae?Ae:void 0,ye=(()=>{switch(de){case"browser.snapshot":return dy({selector:ae(oe.selector)});case"browser.click":return uy({selector:ae(oe.selector),text:ae(oe.text)});case"browser.type":return fy({selector:String(oe.selector??""),value:String(oe.value??""),submit:oe.submit===!0});case"browser.inspect":return py({selector:String(oe.selector??"")});case"browser.scroll":return my({selector:ae(oe.selector),direction:ae(oe.direction)});default:return null}})();if(!ye)throw new Error(`Unsupported browser action: ${de}`);const We=await K.executeJavaScript(ye,!0);if(!We||typeof We!="object")throw new Error("The page returned no result");const Be=We;if(Be.ok!==!0)throw new Error(typeof Be.error=="string"&&Be.error?Be.error:"Browser action failed");if(de==="browser.snapshot"){const Ae=T.current;return{...Be,viewport:Zr(P.current),...Ae.length>0?{consoleProblems:[...Ae]}:{}}}return(de==="browser.click"||de==="browser.type"&&oe.submit===!0)&&(await new Promise(Ae=>setTimeout(Ae,150)),await le()),We},[V,G,le]);c.useEffect(()=>Qx({run:pe}),[pe]),c.useEffect(()=>{const de=V;return()=>{mo(de)}},[V]),c.useEffect(()=>{if(!l)return;const de=K=>{const z=K;if(typeof z.level!="number"||z.level<2)return;const ae=z.sourceId?`${z.sourceId}${z.line?`:${z.line}`:""}`:"";T.current.push({level:z.level>=3?"error":"warning",message:String(z.message??"").slice(0,400),source:ae}),T.current.length>Dl&&T.current.splice(0,T.current.length-Dl)},oe=()=>{T.current=[]};return l.addEventListener("console-message",de),l.addEventListener("did-start-loading",oe),()=>{l.removeEventListener("console-message",de),l.removeEventListener("did-start-loading",oe)}},[l]);const be=c.useRef(new Set),Se=c.useCallback(de=>{be.current.clear(),G(de)},[G]);c.useEffect(()=>{if(!l)return;const de=K=>{const z=sr(K),ae=typeof z.url=="string"?z.url:"";!ae||!vl(ae)||(K.preventDefault(),G(ae))},oe=K=>{const z=sr(K);if(z.isMainFrame===!1||z.errorCode===-3)return;const ae=typeof z.validatedURL=="string"?z.validatedURL:"";!ae||!vl(ae)||be.current.has(ae)||(be.current.add(ae),G(ae))};return l.addEventListener("will-navigate",de),l.addEventListener("did-fail-load",oe),()=>{l.removeEventListener("will-navigate",de),l.removeEventListener("did-fail-load",oe)}},[G,l]),c.useEffect(()=>{if(!l)return;const de=oe=>{const K=oe.detail;oe.preventDefault(),K?.url&&G(K.url)};return l.addEventListener("new-window",de),()=>l.removeEventListener("new-window",de)},[G,l]);const De=c.useCallback(de=>{const oe=Math.min(Gy,Math.max(Ky,de));N(oe);try{o.current?.setZoomLevel(oe)}catch{}},[]),fe=c.useCallback(de=>{Cr("desktop_browser_clear_data",{partition:qy,cookies:de==="cookies",cache:de==="cache"}).then(()=>{Re.success(r(de==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Re.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const de=B.current;if(!de||typeof ResizeObserver>"u")return;const oe=new ResizeObserver(K=>{const z=K[0]?.contentRect;z&&I({width:z.width,height:z.height})});return oe.observe(de),()=>oe.disconnect()},[]);const xe=c.useCallback(de=>{E(de);const oe=o.current;if(!oe)return;let K=-1;try{K=oe.getWebContentsId()}catch{return}Cr("desktop_browser_set_color_scheme",{webContentsId:K,scheme:de}).catch(z=>{E("system"),Re.error(z instanceof Error?z.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),ge=c.useCallback(()=>{try{H?o.current?.stop():o.current?.reload()}catch{}},[H]),re=W.status;c.useEffect(()=>{const de=()=>{y(!0);const z=setTimeout(()=>{try{o.current?.reload()}catch{}},Qy);return()=>clearTimeout(z)};if(re.kind==="failed"){if(!px(re.code,re.url)){y(!1);return}const z=Date.now(),ae=R.current?.url===re.url?R.current:{url:re.url,startedAt:z};if(R.current=ae,z-ae.startedAt>Hy){y(!1);return}return de()}if(re.kind==="loading")return;if(R.current=null,re.kind!=="ready"||!re.url||!fr(re.url)){j.current=!0,y(!1);return}if(j.current||Date.now()-M.current>Yy){j.current=!0,y(!1);return}let oe=!1,K=null;return xx(yr(re.url)).then(z=>{if(!oe){if(z===null||z<500){j.current=!0,y(!1);return}K=de()}}),()=>{oe=!0,K?.()}},[re]);const he=W.status.kind==="failed"&&!p?W.status:null,Ne=yy(A,U);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(lu,{address:w,onAddressChange:S,onSubmit:Se,suggestions:Z,onForgetSuggestion:de=>F(e,de),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:ge,onOpenExternal:()=>{Lo(W.url||w)},canGoBack:W.canGoBack,canGoForward:W.canGoForward,isLoading:H,onAnnotate:Y,isAnnotating:g,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>De(v+Al),onZoomOut:()=>De(v-Al),onZoomReset:()=>De(0),zoomPercent:Math.round(Math.pow(1.2,v)*100),onClearCookies:()=>fe("cookies"),onClearCache:()=>fe("cache"),onToggleDeviceBar:()=>k(de=>!de),isDeviceBarOpen:C}),C?s.jsx(vy,{viewport:A,onViewportChange:D,colorScheme:$,onColorSchemeChange:xe,scale:Ne?.scale??1}):null,s.jsxs("div",{ref:B,className:Pe("relative min-h-0 flex-1 bg-background",Ne&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[x!==null?s.jsx("webview",{ref:d,src:x,partition:"persist:openchamber-browser",allowpopups:!0,style:Ne?{width:`${Ne.width}px`,height:`${Ne.height}px`,transform:`scale(${Ne.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,x!==null&&!h&&!W.url&&!H?s.jsx(uu,{onOpen:Se,directory:e}):null,p?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,te?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:te})})]}):null,he&&!te?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:he.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:he.crashed?r("contextPanel.browser.crashedHint"):he.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,H?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]})]})},Jy=t=>{const e=Je.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=ft(),l=Ce(e1);let a;e[0]!==n?(a=or(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==en?d:"",[f,h]=c.useState(u),[x,b]=c.useState(u);let w;e[2]!==u?(w=u?[u]:[],e[2]=u,e[3]=w):w=e[3];const[S,g]=c.useState(w),[m,p]=c.useState(u?0:-1),[y,v]=c.useReducer(t1,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=H=>{!H||H===en||!r||!i||l(r,i,H)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const C=N;let k;e[8]!==r?(k=ru(r),e[8]=r,e[9]=k):k=e[9];const A=cr(k),D=cr(s1),P=cr(n1);let T;e[10]!==f||e[11]!==A?(T=nu(A,f),e[10]=f,e[11]=A,e[12]=T):T=e[12];const $=T;let E;e[13]!==r||e[14]!==m||e[15]!==C||e[16]!==D?(E=H=>{const ne=or(H);ne!==en&&(h(ne),b(ne),C(ne),D(r,{url:ne}),g(ie=>{const F=m>=0?ie.slice(0,m+1):[];return F[F.length-1]===ne?(p(F.length-1),F):(p(F.length),[...F,ne])}))},e[13]=r,e[14]=m,e[15]=C,e[16]=D,e[17]=E):E=e[17];const U=E;let I;e[18]!==S||e[19]!==C?(I=H=>{const ne=S[H];ne&&(p(H),h(ne),b(ne),C(ne))},e[18]=S,e[19]=C,e[20]=I):I=e[20];const B=I;let R;e[21]!==r||e[22]!==P?(R=H=>P(r,H),e[21]=r,e[22]=P,e[23]=R):R=e[23];let j,M;e[24]!==B||e[25]!==m?(M=()=>B(m-1),j=()=>B(m+1),e[24]=B,e[25]=m,e[26]=j,e[27]=M):(j=e[26],M=e[27]);let L;e[28]!==f||e[29]!==x?(L=()=>{Lo(x||f)},e[28]=f,e[29]=x,e[30]=L):L=e[30];const W=m>0,te=m>=0&&m<S.length-1;let Q;e[31]!==f||e[32]!==U||e[33]!==$||e[34]!==j||e[35]!==L||e[36]!==W||e[37]!==te||e[38]!==R||e[39]!==M?(Q=s.jsx(lu,{address:f,onAddressChange:h,onSubmit:U,suggestions:$,onForgetSuggestion:R,onBack:M,onForward:j,onReload:v,onOpenExternal:L,canGoBack:W,canGoForward:te,isLoading:!1}),e[31]=f,e[32]=U,e[33]=$,e[34]=j,e[35]=L,e[36]=W,e[37]=te,e[38]=R,e[39]=M,e[40]=Q):Q=e[40];let me;e[41]!==x||e[42]!==U||e[43]!==y||e[44]!==o?(me=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:x?s.jsx("iframe",{src:x,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${x}|${y}`):s.jsx(uu,{onOpen:U})}),e[41]=x,e[42]=U,e[43]=y,e[44]=o,e[45]=me):me=e[45];let ce;return e[46]!==Q||e[47]!==me?(ce=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Q,me]}),e[46]=Q,e[47]=me,e[48]=ce):ce=e[48],ce},Zy=t=>{const e=Je.c(3),[n]=c.useState(Uy);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Xy,{...t}):s.jsx(Jy,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function e1(t){return t.setContextPanelTabTargetPath}function t1(t){return t+1}function s1(t){return t.recordVisit}function n1(t){return t.forget}const r1=Qn(()=>Gn(()=>import("./WalkthroughView-D9Q4lr5x.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.WalkthroughView}))),o1=Qn(()=>Gn(()=>import("./DiffView-D5cvbEPb.js"),__vite__mapDeps([124,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.DiffView}))),i1=Qn(()=>Gn(()=>import("./FilesView-DPU8aNPL.js"),__vite__mapDeps([125,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,116,126,127,128,129,130,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,131,132,117,118,114,121,133,115,134])).then(t=>({default:t.FilesView}))),a1=Qn(()=>Gn(()=>import("./GitView-Ct6xWrVH.js"),__vite__mapDeps([135,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,116,136,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,117,118,120,121,122,123])).then(t=>({default:t.GitView}))),l1=Qn(()=>Gn(()=>import("./PlanView-Dgg-WTEc.js"),__vite__mapDeps([137,1,2,4,5,6,7,8,9,126,57,58,59,60,61,62,79,55,56,63,127,128,129,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,115,116,134,117,118,102,103,87,88,89,90,91,92,93,94,95,96,97,98,99,100])).then(t=>({default:t.PlanView}))),c1=380,d1=1400,fu=600,u1=100,f1=24,Eo=new Map,m1=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},Pl=t=>Number.isFinite(t)?Math.min(d1,Math.max(c1,Math.round(t))):fu,h1=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},p1=(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},mu=(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"),g1=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},b1=(t,e,n)=>{if(t.mode==="chat"){const r=Fi(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?wa(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?g1(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):mu(t.mode,n)},Il=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(sa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(zd,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(O,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(O,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(O,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(O,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(O,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(O,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(O,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(O,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="browser"){const n=x1(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(O,{name:"global",className:"h-3.5 w-3.5"})}},x1=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},y1=200,w1=480,S1=({visible:t})=>{const{t:e}=ft(),n=Ce(m=>m.contextEditorTreeWidth),r=Ce(m=>m.setContextEditorTreeWidth),[i,o]=c.useState(!1),l=c.useRef(0),a=c.useRef(n),d=c.useRef(null),u=c.useRef(null),f=c.useRef(null),h=c.useCallback(m=>Math.min(w1,Math.max(y1,Math.round(m))),[]),x=c.useCallback(m=>{const p=f.current;p&&(p.style.width=`${m}px`,p.style.setProperty("--oc-editor-tree-width",`${m}px`))},[]),b=m=>{if(t){try{m.currentTarget.setPointerCapture(m.pointerId)}catch{}u.current=m.pointerId,o(!0),l.current=m.clientX,a.current=n,d.current=n,m.preventDefault()}},w=m=>{if(!i||u.current!==m.pointerId)return;const p=l.current-m.clientX,y=h(a.current+p);d.current!==y&&(d.current=y,x(y))},S=m=>{if(u.current!==m.pointerId)return;try{m.currentTarget.releasePointerCapture(m.pointerId)}catch{}const p=h(d.current??n);u.current=null,d.current=null,o(!1),r(p)},g=t?n:0;return s.jsxs("div",{ref:f,className:Pe("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:`${i?d.current??g:g}px`,"--oc-editor-tree-width":`${i?d.current??n:n}px`,overflowX:"clip",transitionProperty:i?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&s.jsx("div",{className:Pe("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",i&&"bg-[var(--interactive-border)]"),onPointerDown:b,onPointerMove:w,onPointerUp:S,onPointerCancel:S,role:"separator","aria-orientation":"vertical","aria-label":e("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Pe("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",i&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:s.jsx(Fb,{})})]})},Fi=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,v1=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},j1=(t,e)=>{if(e.length===0)return Eo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Eo:r},k1=(t,e)=>{const n=Ec(t),r=c.useRef(Eo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=j1(n.getState().session,i.current);return v1(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Eo)},C1=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,N1=()=>{const{t}=ft(),e=zr()??"",n=c.useMemo(()=>m1(e),[e]),r=Ce(se=>n?se.contextPanelByDirectory[n]:void 0),i=Ce(se=>se.closeContextPanel),o=Ce(se=>se.closeContextPanelTab),l=Ce(se=>se.openContextPanelTab),a=Ce(se=>se.toggleContextPanelExpanded),d=Ce(se=>se.setContextPanelWidth),u=Ce(se=>se.setActiveContextPanelTab),f=Ce(se=>se.openContextBrowser);c.useEffect(()=>{if(e)return Yx(se=>f(e,se,{reveal:!1}))},[e,f]);const h=Ce(se=>se.reorderContextPanelTabs),x=nn(se=>se.setSelectedPath),b=Ce(se=>se.contextEditorTreeVisible),w=Ce(se=>se.toggleContextEditorTree),S=Ce(se=>se.openNewContextBrowserTab),g=Qd(se=>se.byOrigin),m=Ce(se=>se.allowPromptingSubagentSessions),{themeMode:p,setThemeMode:y,lightThemeId:v,darkThemeId:N,currentTheme:C}=qn(),k=c.useMemo(()=>r?.tabs??[],[r?.tabs]),A=k.find(se=>se.id===r?.activeTabId)??k[k.length-1]??null,D=!!(r?.isOpen&&A),P=!!(D&&r?.expanded),[T,$]=c.useState(null),E=A?.mode??null,U=E?r?.widthByMode?.[E]:void 0,I=E?$f(E):.5,B=T??(typeof window<"u"?window.innerWidth:fu*2),R=Pl(U??Math.round(I*B)),j=c.useMemo(()=>{const se=[];for(const Ie of k){if(Ie.mode!=="chat")continue;const Ye=Fi(Ie.dedupeKey);Ye&&!se.includes(Ye)&&se.push(Ye)}return se},[k]),M=k1(n||void 0,j),[L,W]=c.useState(!1),te=c.useRef(0),Q=c.useRef(R),me=c.useRef(null),ce=c.useRef(null),H=c.useRef(null),ne=c.useRef(new Map),ie=c.useRef(new Map),F=c.useRef(!1);c.useLayoutEffect(()=>{const se=H.current?.parentElement;if(!se||typeof ResizeObserver>"u")return;const Ie=new ResizeObserver(()=>{$(se.clientWidth||null)});return Ie.observe(se),$(se.clientWidth||null),()=>Ie.disconnect()},[]),c.useEffect(()=>{if(!D||F.current){F.current=D;return}const se=window.requestAnimationFrame(()=>{H.current?.focus({preventScroll:!0})});return F.current=!0,()=>window.cancelAnimationFrame(se)},[D]);const Z=c.useRef(null),G=c.useRef(null),V=c.useCallback(()=>{G.current=null;const se=H.current,Ie=me.current;!se||Ie===null||se.style.setProperty("--oc-context-panel-width",`${Ie}px`)},[]);c.useEffect(()=>()=>{G.current!==null&&clearTimeout(G.current)},[]);const Y=c.useCallback(se=>{const Ie=Pl(se),Ye=Z.current;return Ye===null?Ie:Math.min(Ie,Math.max(1,Ye))},[]),le=c.useCallback(se=>{!D||P||!n||(ce.current=se.pointerId,W(!0),te.current=se.clientX,Q.current=R,me.current=R,Z.current=h1(H.current),document.documentElement.style.cursor="col-resize",se.preventDefault())},[n,P,D,R]),pe=c.useCallback(()=>{const se=Y(me.current??R);me.current=null,Z.current=null,G.current!==null&&(clearTimeout(G.current),G.current=null),document.documentElement.style.cursor="",n&&E&&d(n,E,se),W(!1),ce.current=null},[E,Y,n,d,R]);c.useEffect(()=>{if(!L)return;const se=ee=>{if(ce.current!==ee.pointerId)return;const Ee=te.current-ee.clientX,Ge=Y(Q.current+Ee);me.current!==Ge&&(me.current=Ge,G.current===null&&(G.current=setTimeout(V,u1)))},Ie=ee=>{ce.current===ee.pointerId&&pe()},Ye=()=>{pe()};return window.addEventListener("pointermove",se),window.addEventListener("pointerup",Ie),window.addEventListener("pointercancel",Ie),window.addEventListener("blur",Ye),()=>{window.removeEventListener("pointermove",se),window.removeEventListener("pointerup",Ie),window.removeEventListener("pointercancel",Ie),window.removeEventListener("blur",Ye)}},[V,Y,pe,L]),c.useEffect(()=>{L||(me.current=null,document.documentElement.style.cursor="")},[L]);const be=c.useCallback(()=>{n&&i(n)},[i,n]),Se=c.useCallback(()=>{n&&a(n)},[n,a]),De=c.useCallback(se=>{se.key==="Escape"&&(zf(se.target)||(se.preventDefault(),se.stopPropagation(),be()))},[be]);c.useEffect(()=>{if(!(!n||!A)&&A.mode==="file"&&A.targetPath){x(n,A.targetPath,{allowOutsideRoot:!0});return}},[A,n,x]);const fe=c.useMemo(()=>k.filter(se=>se.mode==="chat"),[k]),xe=D&&A?.mode==="chat"?A.id:null,ge=D&&A?.mode==="chat"?Fi(A.dedupeKey):null,re=mp(fe,xe);c.useEffect(()=>{if(!D||!n||!ge||typeof window>"u")return;const se=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Yo(n,ge,!1);return}Fc(ge),Yo(n,ge,!0)};se();const Ie=window.setInterval(se,1e4);return window.addEventListener("focus",se),window.addEventListener("blur",se),document.addEventListener("visibilitychange",se),()=>{window.clearInterval(Ie),window.removeEventListener("focus",se),window.removeEventListener("blur",se),document.removeEventListener("visibilitychange",se),Yo(n,ge,!1)}},[ge,n,D]);const he=c.useCallback((se,Ie,Ye)=>hp(ie.current,se,Ie,n||null,Ye,{mode:p,lightThemeId:v,darkThemeId:N,currentTheme:C},{allowPromptingSubagentSessions:m}),[m,C,N,n,v,p]),Ne=re&&ge?he(re.id,ge,re.readOnly):null;c.useEffect(()=>{const se=new Set(k.map(Ie=>Ie.id));for(const Ie of ie.current.keys())se.has(Ie)||ie.current.delete(Ie)},[k]);const de=c.useCallback(se=>{!n||A?.mode!=="diff"||l(n,{mode:"diff",targetPath:A.targetPath,stagedDiff:se==="staged",diffScope:se})},[A,n,l]),oe=c.useCallback(()=>{if(typeof window>"u")return;const se={themeMode:p,lightThemeId:v,darkThemeId:N,currentTheme:C};for(const Ie of ne.current.values()){const Ye=Ie.contentWindow;Ye&&Ye.postMessage({type:"openchamber:theme-sync",payload:se},window.location.origin)}},[C,N,v,p]),K=c.useCallback(()=>{if(typeof window>"u")return;const se={allowPromptingSubagentSessions:m};for(const Ie of ne.current.values()){const Ye=Ie.contentWindow;Ye&&Ye.postMessage({type:"openchamber:chat-settings-sync",payload:se},window.location.origin)}},[m]),z=c.useCallback((se,Ie,Ye)=>{const ee=Ie.contentWindow;ee&&ee.postMessage({type:Dd,payload:{visible:xe===se}},Ye)},[xe]),ae=c.useCallback(()=>{if(!(typeof window>"u"))for(const[se,Ie]of ne.current.entries())z(se,Ie,window.location.origin)},[z]);c.useEffect(()=>{if(typeof window>"u")return;const se=Ie=>{if(Ie.origin!==window.location.origin)return;const Ye=Array.from(ne.current.entries()).find(([,$e])=>$e.contentWindow===Ie.source);if(!Ye)return;const ee=Ie.data;if(ee?.type===pp){const[$e,_e]=Ye;z($e,_e,Ie.origin);return}if(ee?.type===gp){if(typeof ee.requestId!="string"||!ee.requestId)return;const $e=ks(),_e={apiBaseUrl:Dn(),clientToken:Ir(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:jc(),relayHostId:$e.startsWith("host:")?$e.slice(5):"",relay:Hu()??void 0};Ie.source?.postMessage({type:bp,requestId:ee.requestId,payload:_e},Ie.origin);return}if(ee?.type==="openchamber:theme-sync-request"){oe();return}if(ee?.type==="openchamber:chat-settings-request"){K();return}if(ee?.type!=="openchamber:cycle-theme-request")return;const Ee=["light","dark","system"],ze=(Ee.indexOf(p)+1)%Ee.length;y(Ee[ze])};return window.addEventListener("message",se),()=>window.removeEventListener("message",se)},[K,z,oe,y,p]),c.useLayoutEffect(()=>{k.some(Ie=>Ie.mode==="chat")&&(oe(),K(),ae())},[N,v,K,ae,oe,k,p]);const ve=A?.mode==="file"||A?.mode==="chat"||A?.mode==="browser",ye=c.useMemo(()=>A?k.filter(se=>se.mode===A.mode):[],[A,k]),We=c.useMemo(()=>ye.map(se=>{const Ie=b1(se,M,t),Ye=C1(Ie,f1),ee=p1(se.targetPath,e);return{id:se.id,label:Ye,icon:Il(se,g),title:ee?`${Ie}: ${ee}`:Ie,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ye})}}),[ye,e,g,M,t]),Be=A?.mode==="context"?s.jsx(tx,{}):A?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(a1,{isActive:D})}):A?.mode==="pr"?s.jsx(db,{}):A?.mode==="notes"?s.jsx(_h,{}):A?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(l1,{targetPath:A.targetPath,projectPlanId:A.projectPlanId})}):null,Ae=c.useMemo(()=>k.filter(se=>se.mode==="browser"),[k]),X=c.useMemo(()=>k.filter(se=>se.mode==="diff"),[k]),Oe=c.useMemo(()=>k.some(se=>se.mode==="terminal"),[k]),Fe=c.useMemo(()=>k.some(se=>se.mode==="walkthrough"),[k]),_=c.useMemo(()=>k.some(se=>se.mode==="file"),[k]),ue=c.useMemo(()=>k.some(se=>se.mode==="file"&&se.targetPath),[k]),ke=A?.mode==="file",je=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ve?s.jsx(fd,{items:We,activeId:A?.id??null,onSelect:se=>{n&&u(n,se)},onClose:se=>{n&&o(n,se)},onReorder:(se,Ie)=>{n&&h(n,se,Ie)},layoutMode:"scrollable",variant:"default"}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[A?Il(A,g):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:A?mu(A.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[A?.mode==="browser"?s.jsx(lt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&S(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(O,{name:"add",className:"h-3.5 w-3.5"})}):null,ke?s.jsx(lt,{type:"button",variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(O,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,s.jsx(lt,{type:"button",variant:"ghost",size:"sm",onClick:Se,className:"h-7 w-7 p-0",title:t(P?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(P?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:P?s.jsx(O,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(O,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(lt,{type:"button",variant:"ghost",size:"sm",onClick:be,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(O,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Ke=D?P?{"--oc-context-panel-width":T!==null?`${T}px`:"100%",width:T!==null?`${T}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${R}px`}:{"--oc-context-panel-width":`${R}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:H,"data-context-panel":"true",tabIndex:-1,inert:!D||void 0,className:Pe("flex min-h-0 flex-col overflow-hidden bg-background",P?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!D&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:De,style:Ke,children:[D&&!P&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),D&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!P&&s.jsx("div",{className:Pe("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",L&&"bg-[var(--interactive-border)]"),onPointerDown:le,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Pe("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]",!D&&"pointer-events-none select-none opacity-0"),style:{width:P?T!==null?`${T}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!D,children:[je,s.jsxs("div",{className:Pe("relative min-h-0 flex-1 overflow-hidden",L&&"pointer-events-none"),children:[_?s.jsxs("div",{className:Pe("absolute inset-0 flex",ke?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:ue?s.jsx(c.Suspense,{fallback:null,children:s.jsx(i1,{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(O,{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(S1,{visible:b})]}):null,re&&ge&&Ne?s.jsx("iframe",{ref:se=>{if(!se){ne.current.delete(re.id);return}ne.current.set(re.id,se)},src:Ne,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ge}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{oe(),K(),ae()}},re.id):null,Ae.map(se=>s.jsx("div",{className:Pe("absolute inset-0",A?.id!==se.id&&"hidden"),children:s.jsx(Zy,{initialUrl:se.targetPath??"",directory:n,tabID:se.id})},se.id)),X.map(se=>s.jsx("div",{className:Pe("absolute inset-0",A?.id!==se.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(o1,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:se.diffScope??(se.stagedDiff?"staged":"working"),onDiffScopeChange:de,targetFilePath:se.targetPath,flushContent:!0})})},se.id)),Oe?s.jsx("div",{className:Pe("absolute inset-0",A?.mode==="terminal"?"block":"hidden"),children:s.jsx(Fh,{visible:D&&A?.mode==="terminal"})}):null,Fe?s.jsx("div",{className:Pe("absolute inset-0",A?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(r1,{directory:e})})}):null,A?.mode!=="chat"&&!ke&&A?.mode!=="browser"&&A?.mode!=="diff"&&A?.mode!=="terminal"&&A?.mode!=="walkthrough"?Be:null]})]})]})},A1=t=>{const e=Je.c(42),{open:n,onOpenChange:r}=t,{t:i}=ft(),o=Ce(D1),l=Ce(P1),a=Ce(I1),d=Ce(T1);let u;e[0]!==o?(u=Lc(o),e[0]=o,e[1]=u):u=e[1];const f=u,h=l.length===0;let x;if(e[2]!==l||e[3]!==f){let A;e[5]!==l?(A=D=>l.includes(D.id),e[5]=l,e[6]=A):A=e[6],x=f.every(A),e[2]=l,e[3]=f,e[4]=x}else x=e[4];const b=x;let w;e[7]!==i?(w=i("contextRail.configure.dialogTitle"),e[7]=i,e[8]=w):w=e[8];let S;e[9]!==w?(S=s.jsx(Fs,{children:w}),e[9]=w,e[10]=S):S=e[10];let g;e[11]!==i?(g=i("contextRail.configure.dialogDescription"),e[11]=i,e[12]=g):g=e[12];let m;e[13]!==g?(m=s.jsx(Ls,{children:g}),e[13]=g,e[14]=m):m=e[14];let p;e[15]!==S||e[16]!==m?(p=s.jsxs(Gs,{children:[S,m]}),e[15]=S,e[16]=m,e[17]=p):p=e[17];let y;if(e[18]!==l||e[19]!==a||e[20]!==f||e[21]!==i){let A;e[23]!==l||e[24]!==a||e[25]!==i?(A=D=>s.jsx(Wf,{settingsItem:`layout.context-rail.surface.${D.id}`,checked:!l.includes(D.id),onChange:P=>a(D.id,P),label:i(D.labelKey),ariaLabel:i(D.labelKey)},D.id),e[23]=l,e[24]=a,e[25]=i,e[26]=A):A=e[26],y=f.map(A),e[18]=l,e[19]=a,e[20]=f,e[21]=i,e[22]=y}else y=e[22];let v;e[27]!==y?(v=s.jsx("div",{className:"flex flex-col",children:y}),e[27]=y,e[28]=v):v=e[28];let N;e[29]!==h||e[30]!==b||e[31]!==d||e[32]!==i?(N=h?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[b?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(lt,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[29]=h,e[30]=b,e[31]=d,e[32]=i,e[33]=N):N=e[33];let C;e[34]!==N||e[35]!==p||e[36]!==v?(C=s.jsxs(As,{className:"max-w-md",children:[p,v,N]}),e[34]=N,e[35]=p,e[36]=v,e[37]=C):C=e[37];let k;return e[38]!==r||e[39]!==n||e[40]!==C?(k=s.jsx(Ns,{open:n,onOpenChange:r,children:C}),e[38]=r,e[39]=n,e[40]=C,e[41]=k):k=e[41],k};function D1(t){return t.contextRailOrder}function P1(t){return t.contextRailHiddenSurfaces}function I1(t){return t.setContextRailSurfaceVisible}function T1(t){return t.setContextRailHiddenSurfaces}const hu=150,E1=500,R1=[],M1=t=>t>99?"99+":String(t),O1=t=>{const e=Je.c(51),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:f,showOrderNumber:h,onSelect:x}=t;let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:w,listeners:S,setNodeRef:g,transform:m,transition:p,isDragging:y}=Ho(b);let v;e[2]!==a?(v=a!=null&&a>0?M1(a):null,e[2]=a,e[3]=v):v=e[3];const N=v;let C;e[4]!==m?(C=Ko.Translate.toString(m),e[4]=m,e[5]=C):C=e[5];let k;e[6]!==C||e[7]!==p?(k={transform:C,transition:p},e[6]=C,e[7]=p,e[8]=k):k=e[8];const A=y&&"z-10 opacity-70";let D;e[9]!==A?(D=Pe("relative",A),e[9]=A,e[10]=D):D=e[10];let P;e[11]!==x||e[12]!==n?(P=()=>x(n),e[11]=x,e[12]=n,e[13]=P):P=e[13];const T=d??o,$=r?"text-primary":"text-muted-foreground hover:text-foreground";let E;e[14]!==$?(E=Pe("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",$),e[14]=$,e[15]=E):E=e[15];let U;e[16]!==n.icon||e[17]!==n.id?(U=n.id==="diff"?s.jsx(zd,{}):s.jsx(O,{name:n.icon,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.id,e[18]=U):U=e[18];let I;e[19]!==N||e[20]!==f||e[21]!==i||e[22]!==h?(I=h&&f!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:f===10?"0":f}):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}):i?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]=f,e[21]=i,e[22]=h,e[23]=I):I=e[23];let B;e[24]!==w||e[25]!==r||e[26]!==S||e[27]!==E||e[28]!==U||e[29]!==I||e[30]!==P||e[31]!==T?(B=s.jsx(ht,{asChild:!0,children:s.jsxs("button",{type:"button",...w,...S,onClick:P,"aria-label":T,"aria-pressed":r,className:E,children:[U,I]})}),e[24]=w,e[25]=r,e[26]=S,e[27]=E,e[28]=U,e[29]=I,e[30]=P,e[31]=T,e[32]=B):B=e[32];let R;e[33]!==o?(R=s.jsx("span",{children:o}),e[33]=o,e[34]=R):R=e[34];let j;e[35]!==l?(j=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[35]=l,e[36]=j):j=e[36];let M;e[37]!==u?(M=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[37]=u,e[38]=M):M=e[38];let L;e[39]!==R||e[40]!==j||e[41]!==M?(L=s.jsx(pt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[R,j,M]})}),e[39]=R,e[40]=j,e[41]=M,e[42]=L):L=e[42];let W;e[43]!==B||e[44]!==L?(W=s.jsxs(gt,{delayDuration:hu,children:[B,L]}),e[43]=B,e[44]=L,e[45]=W):W=e[45];let te;return e[46]!==g||e[47]!==W||e[48]!==k||e[49]!==D?(te=s.jsx("div",{ref:g,style:k,className:D,children:W}),e[46]=g,e[47]=W,e[48]=k,e[49]=D,e[50]=te):te=e[50],te},B1=()=>{const t=Je.c(70),{t:e}=ft(),n=zr();let r;t[0]!==n?(r=n?Zn(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=le=>i?le.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Ce(o),a=Ce(_1),d=Ce(F1),u=Ce(L1),f=Ce($1),h=Ce(z1),x=Ce(W1),b=Zi(V1),{screenWidth:w}=Tn(),S=ea(i||null);let g;t[4]!==x?(g=xi("switch_context_surface",x),t[4]=x,t[5]=g):g=t[5];const m=g,[p,y]=c.useState(!1);let v,N;t[6]!==m?(v=()=>{const le=new Set;let pe=null,be=!1;const Se=U1,De=()=>{Ra(m,le)?!be&&pe===null&&(pe=setTimeout(()=>y(!0),E1)):(be=!1,pe!==null&&(clearTimeout(pe),pe=null),y(!1))},fe=re=>{if(le.add(re.key.toLowerCase()),Se(re.key)&&Ra(m,le)){be=!0,pe!==null&&(clearTimeout(pe),pe=null),y(!1);return}De()},xe=re=>{le.delete(re.key.toLowerCase()),De()},ge=()=>{le.clear(),be=!1,pe!==null&&(clearTimeout(pe),pe=null),y(!1)};return window.addEventListener("keydown",fe,!0),window.addEventListener("keyup",xe,!0),window.addEventListener("blur",ge),()=>{window.removeEventListener("keydown",fe,!0),window.removeEventListener("keyup",xe,!0),window.removeEventListener("blur",ge),pe!==null&&clearTimeout(pe)}},N=[m],t[6]=m,t[7]=v,t[8]=N):(v=t[7],N=t[8]),c.useEffect(v,N);let C;t[9]===Symbol.for("react.memo_cache_sentinel")?(C={activationConstraint:{distance:8}},t[9]=C):C=t[9];let k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k={activationConstraint:{delay:200,tolerance:6}},t[10]=k):k=t[10];const A=Er(An(Sd,C),An(wd,k)),D=l?.tabs??R1;let P;t[11]!==l?.activeTabId||t[12]!==D?(P=D.find(le=>le.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=D,t[13]=P):P=t[13];const T=P,$=l?.isOpen?T?.mode??null:null,E=S?.files.length??0;let U;t[14]!==u||t[15]!==d||t[16]!==b||t[17]!==w||t[18]!==D?(U=Vf({railOrder:d,hiddenSurfaces:u,planModeEnabled:b,isVSCode:bn(),screenWidth:w,tabs:D}),t[14]=u,t[15]=d,t[16]=b,t[17]=w,t[18]=D,t[19]=U):U=t[19];const I=U,[B,R]=c.useState(!1);let j;t[20]!==f?(j=le=>{const{active:pe,over:be}=le;if(!be||pe.id===be.id)return;const Se=Lc(Ce.getState().contextRailOrder).map(H1),De=Se.indexOf(pe.id),fe=Se.indexOf(be.id);De===-1||fe===-1||f(vd(Se,De,fe))},t[20]=f,t[21]=j):j=t[21];const M=j;if(!i)return null;let L;t[22]!==e?(L=e("contextRail.aria.rail"),t[22]=e,t[23]=L):L=t[23];let W;t[24]!==I?(W=I.map(K1),t[24]=I,t[25]=W):W=t[25];let te;if(t[26]!==$||t[27]!==E||t[28]!==i||t[29]!==h||t[30]!==p||t[31]!==I||t[32]!==e||t[33]!==a){let le;t[35]!==$||t[36]!==E||t[37]!==i||t[38]!==h||t[39]!==p||t[40]!==e||t[41]!==a?(le=(pe,be)=>{const Se=e(pe.labelKey),De=pe.id==="git"&&!a?E:0,fe=De>0?De:null;return s.jsx(O1,{surface:pe,isActive:$===pe.mode,showActivityDot:!1,label:Se,description:e(pe.descriptionKey),badgeCount:fe,badgeAriaLabel:fe!==null?e(fe===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:Se,count:fe}):null,badgeDescription:fe!==null?e(fe===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:fe}):null,orderNumber:be+1,showOrderNumber:p,onSelect:xe=>h(i,xe.mode)},pe.id)},t[35]=$,t[36]=E,t[37]=i,t[38]=h,t[39]=p,t[40]=e,t[41]=a,t[42]=le):le=t[42],te=I.map(le),t[26]=$,t[27]=E,t[28]=i,t[29]=h,t[30]=p,t[31]=I,t[32]=e,t[33]=a,t[34]=te}else te=t[34];let Q;t[43]!==W||t[44]!==te?(Q=s.jsx(No,{items:W,strategy:Ai,children:te}),t[43]=W,t[44]=te,t[45]=Q):Q=t[45];let me;t[46]!==M||t[47]!==A||t[48]!==Q?(me=s.jsx(Rr,{sensors:A,collisionDetection:Mr,onDragEnd:M,children:Q}),t[46]=M,t[47]=A,t[48]=Q,t[49]=me):me=t[49];let ce;t[50]!==e?(ce=e("contextRail.configure.open"),t[50]=e,t[51]=ce):ce=t[51];let H;t[52]===Symbol.for("react.memo_cache_sentinel")?(H=()=>R(!0),t[52]=H):H=t[52];let ne;t[53]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(O,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[53]=ne):ne=t[53];let ie;t[54]!==ce?(ie=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":ce,onClick:H,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:ne})}),t[54]=ce,t[55]=ie):ie=t[55];let F;t[56]!==e?(F=e("contextRail.configure.open"),t[56]=e,t[57]=F):F=t[57];let Z;t[58]!==F?(Z=s.jsx(pt,{side:"left",sideOffset:8,children:F}),t[58]=F,t[59]=Z):Z=t[59];let G;t[60]!==ie||t[61]!==Z?(G=s.jsxs(gt,{delayDuration:hu,children:[ie,Z]}),t[60]=ie,t[61]=Z,t[62]=G):G=t[62];let V;t[63]!==B?(V=s.jsx(A1,{open:B,onOpenChange:R}),t[63]=B,t[64]=V):V=t[64];let Y;return t[65]!==L||t[66]!==me||t[67]!==G||t[68]!==V?(Y=s.jsxs("nav",{"aria-label":L,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[me,G,V]}),t[65]=L,t[66]=me,t[67]=G,t[68]=V,t[69]=Y):Y=t[69],Y};function _1(t){return t.workStatusPanelVisible}function F1(t){return t.contextRailOrder}function L1(t){return t.contextRailHiddenSurfaces}function $1(t){return t.setContextRailOrder}function z1(t){return t.openContextSurface}function W1(t){return t.shortcutOverrides}function V1(t){return t.planModeEnabled}function U1(t){return t.length===1&&t>="0"&&t<="9"}function H1(t){return t.id}function K1(t){return t.id}const G1=()=>{const e=Qe.getState().currentSessionId;if(!e)return"";const r=$c().find(i=>i.id===e);return typeof r?.directory=="string"?r.directory:""},q1=async(t,e=6e3)=>{const n=new AbortController,r=setTimeout(()=>n.abort(),e),i=Date.now();try{const o=await ss(t,{method:"GET",headers:{Accept:"application/json"},signal:n.signal}),l=Date.now()-i,a=o.headers.get("content-type")||"",d=a.toLowerCase(),u=d.includes("json")&&!d.includes("text/html");let f="";if(u){const h=await o.json().catch(()=>null);if(Array.isArray(h))f=`json[array] len=${h.length}`;else if(h&&typeof h=="object"){const x=Object.keys(h).slice(0,8);f=`json[object] keys=${x.join(",")}${Object.keys(h).length>x.length?",…":""}`}else f=`json[${typeof h}]`}else f=a?`content-type=${a}`:"no content-type";return{ok:o.ok&&u,status:o.status,elapsedMs:l,summary:f}}catch(o){const l=Date.now()-i,d=n.signal.aborted||o instanceof Error&&(o.name==="AbortError"||o.message.toLowerCase().includes("aborted"))?`timeout after ${e}ms`:o instanceof Error?o.message:String(o);return{ok:!1,status:0,elapsedMs:l,summary:`error=${d}`}}finally{clearTimeout(r)}},Q1=t=>{if(!t||!Number.isFinite(t))return"(n/a)";try{return new Date(t).toISOString()}catch{return"(invalid)"}},Y1=t=>{if(typeof t=="number"&&Number.isFinite(t)&&t>0)return Math.trunc(t);if(typeof t=="string"){const e=Number.parseInt(t,10);if(Number.isFinite(e)&&e>0)return e}return null},X1=t=>!!t&&typeof t=="object"&&!Array.isArray(t),jn=(t,e="(n/a)")=>typeof t=="string"?t.trim()||e:typeof t=="number"&&Number.isFinite(t)?String(t):typeof t=="boolean"?t?"true":"false":e,Tl=(t,e,n)=>t==="node-shebang"||t==="node-launcher"?e?`node (${e})`:"node":t==="bun-shebang"?n?`bun (${n})`:"bun":t||"direct executable",J1=async()=>{const t=new Date,e="1.21.0",n=typeof navigator<"u"?navigator.userAgent:"(no navigator)",r=G1(),i=Ce.getState().eventStreamStatus,o=typeof window<"u"?window.location.origin:"",l=qi(),a=l.health(),d=l.api("/api/"),u=await(async()=>{if(!a)return null;const m=new AbortController,p=setTimeout(()=>m.abort(),5e3);try{const y=await ss(a,{method:"GET",headers:{Accept:"application/json"},signal:m.signal});if(!y.ok)return null;const v=await y.json().catch(()=>null);return!v||typeof v!="object"||Array.isArray(v)?null:v}catch{return null}finally{clearTimeout(p)}})(),f=await(async()=>{if(!d)return null;const m=new AbortController,p=setTimeout(()=>m.abort(),7e3);try{const y=await ss(l.api("/api/config/opencode-resolution"),{method:"GET",headers:{Accept:"application/json"},signal:m.signal}),v=y.headers.get("content-type")||"(none)";if(!y.ok)return{data:null,status:y.status,error:`http ${y.status} content-type=${v}`};const N=await y.text();let C=null;try{C=JSON.parse(N)}catch{const k=N.replace(/\s+/g," ").slice(0,120);return{data:null,status:y.status,error:`invalid json content-type=${v} body=${k||"(empty)"}`}}return!C||typeof C!="object"||Array.isArray(C)?{data:null,status:y.status,error:`invalid json-shape content-type=${v}`}:{data:C,status:y.status,error:null}}catch(y){return{data:null,status:null,error:y instanceof Error?y.message:String(y)}}finally{clearTimeout(p)}})()||{data:null,error:null},h=(m,p=!0)=>{if(!d)return null;const y=new URL(m.replace(/^\/+/,""),d);return p&&r&&y.searchParams.set("directory",r),y.toString()},x=[{label:"health",path:"/health",includeDirectory:!1},{label:"config",path:"/config",includeDirectory:!0},{label:"providers",path:"/config/providers",includeDirectory:!0},{label:"agents",path:"/agent",includeDirectory:!0,timeoutMs:12e3},{label:"commands",path:"/command",includeDirectory:!0,timeoutMs:1e4},{label:"project",path:"/project/current",includeDirectory:!0},{label:"path",path:"/path",includeDirectory:!0},{label:"sessions",path:"/session",includeDirectory:!0,timeoutMs:12e3},{label:"sessionStatus",path:"/session/status",includeDirectory:!0}],b=d?await Promise.all(x.map(async m=>{const p=h(m.path,m.includeDirectory!==!1);if(!p)return{label:m.label,url:"(none)",result:null};const y=await q1(p,typeof m.timeoutMs=="number"?m.timeoutMs:void 0);return{label:m.label,url:p,result:y}})):[],w=[];w.push(`Time: ${t.toISOString()}`),w.push(`OpenChamber version: ${e}`),w.push(`Runtime: ${o||"(unknown)"} (api=${d||"(unknown)"})`),w.push(`OpenCode SDK base: ${Es.getBaseUrl()}`),w.push(`Event stream: ${i}`),w.push(`Directory: ${r||"(none)"}`),w.push(`Platform: ${n}`);const S=Y1(u?.openCodePort);if(w.push(`OpenCode runtime port: ${S??"(unknown)"}`),typeof u?.openCodeRunning=="boolean"&&w.push(`OpenCode runtime running: ${u.openCodeRunning?"yes":"no"}`),typeof u?.openCodeSecureConnection=="boolean"&&w.push(`Secure OpenCode connection: ${u.openCodeSecureConnection?"true":"false"}`),typeof u?.openCodeAuthSource=="string"&&u.openCodeAuthSource.trim()&&w.push(`OpenCode auth source: ${u.openCodeAuthSource}`),typeof window<"u"){const m=window.__OPENCHAMBER_MACOS_MAJOR__;typeof m=="number"&&Number.isFinite(m)&&m>0&&w.push(`macOS major: ${m}`)}if(/Mac OS X|Macintosh/.test(n)){w.push(""),w.push("OpenCode CLI resolution:");const m=X1(u?.lastOpenCodeLaunchDiagnostics)?u.lastOpenCodeLaunchDiagnostics:null,p=m&&Array.isArray(m.args)?m.args.filter(I=>typeof I=="string"):[],y=f.data,v=y&&typeof y.configured=="string"?y.configured:null,N=y&&typeof y.resolved=="string"?y.resolved:u&&typeof u.opencodeBinaryResolved=="string"?u.opencodeBinaryResolved:"",C=y&&typeof y.resolvedDir=="string"?y.resolvedDir:"",k=y&&typeof y.source=="string"?y.source:u&&typeof u.opencodeBinarySource=="string"?u.opencodeBinarySource:"",A=y&&typeof y.launchBinary=="string"?y.launchBinary:u&&typeof u.opencodeLaunchBinary=="string"?u.opencodeLaunchBinary:"",D=y&&typeof y.launchWrapperType=="string"?y.launchWrapperType:u&&typeof u.opencodeLaunchWrapperType=="string"?u.opencodeLaunchWrapperType:"",P=y&&Array.isArray(y.launchArgs)?y.launchArgs.filter(I=>typeof I=="string"):u&&Array.isArray(u.opencodeLaunchArgs)?u.opencodeLaunchArgs.filter(I=>typeof I=="string"):[],T=y&&typeof y.node=="string"?y.node:u&&typeof u.nodeBinaryResolved=="string"?u.nodeBinaryResolved:"",$=y&&typeof y.bun=="string"?y.bun:u&&typeof u.bunBinaryResolved=="string"?u.bunBinaryResolved:"",E=y&&typeof y.detectedNow=="string"?y.detectedNow:"",U=y&&typeof y.detectedSourceNow=="string"?y.detectedSourceNow:"";if(v!==null&&w.push(`- configured: ${v.trim().length===0?"(cleared)":v}`),N){const I=C||(N.includes("/")?N.split("/").slice(0,-1).join("/")||"/":"");w.push(`- opencode: ${N}${I?` (dir=${I})`:""}`)}else w.push("- opencode: (n/a)");w.push(`- source: ${k||"(n/a)"}`),E&&(w.push(`- detected-now: ${E}`),w.push(`- detected-source: ${U||"(n/a)"}`)),m?(w.push(`- launched-at: ${jn(m.launchedAt)}`),w.push(`- launch: ${jn(m.binary)} ${p.join(" ")}`.trim()),w.push(`- cwd: ${jn(m.cwd)}`),w.push(`- wrapper: ${jn(m.wrapperType)}`),w.push(`- runtime: ${Tl(jn(m.wrapperType,""),T,$)}`),w.push(`- PATH entries: ${jn(m.pathEntryCount,"(unknown)")}`),w.push(`- shell env: ${jn(m.hasShellEnv,"(unknown)")} (${jn(m.shellEnvKeysCount,"?")} keys)`)):(w.push(`- launch-binary: ${A||"(n/a)"}`),w.push(`- launch-wrapper: ${D||"(n/a)"}`),w.push(`- launch-args: ${P.length?P.join(" "):"(none)"}`),w.push(`- runtime: ${Tl(D||"",T,$)}`)),!y&&f.error&&w.push(`- resolution-endpoint: ${f.error}`)}if(w.push(""),b.length){w.push("OpenCode API probes:");for(const m of b){if(!m.result){w.push(`- ${m.label}: (no url)`);continue}const{ok:p,status:y,elapsedMs:v,summary:N}=m.result,C=p?"":` url=${m.url}`;w.push(`- ${m.label}: ${p?"ok":"fail"} status=${y} time=${v}ms ${N}${C}`)}}else w.push("OpenCode API probes: (skipped)");return w.push(""),w.push(`Generated: ${Q1(Date.now())}`),w.join(`
|
|
911
|
-
`)},pu=async()=>{const t=await J1(),e=Ce.getState();e.setOpenCodeStatusText(t),e.setOpenCodeStatusDialogOpen(!0)},Z1=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),ew=(t,e,n,r)=>!n||r!==n||t.length===0?[]:jr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),tw=new Set,sw=[],Li=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},nw=()=>{const t=Je.c(182),{t:e}=ft(),n=Ce(rw),r=Ce(ow),i=Ce(iw),o=Ce(aw),l=Ce(lw),a=Ce(cw),d=Ce(dw),u=Ce(uw),f=Ce(fw),h=Ce(mw),x=Ce(hw),b=Ce(pw),w=Ce(gw),S=Qe(bw),g=Qe(xw),m=Qe(yw),p=dr(ww);let y;t[0]!==n?(y=st=>n?st.activeSessions:sw,t[0]=n,t[1]=y):y=t[1];const v=xs(y);let N;t[2]!==n?(N=st=>n?st.ids:tw,t[2]=n,t[3]=N):N=t[3];const C=dr(N);let k;t[4]!==n?(k=st=>n?st.rankById:oa,t[4]=n,t[5]=k):k=t[5];const A=Vo(k),D=Zt(Sw),P=Vt(vw),T=Vt(jw),$=zr(),E=vc(kw),{files:U,git:I}=xn(),B=Pn(Cw),{isMobile:R}=Tn();let j;t[6]!==$?(j=$?Li($):null,t[6]=$,t[7]=j):j=t[7];const M=j,[L,W]=c.useState(""),Q=na(L,200).trim();let me;t[8]!==L?(me=L.trim(),t[8]=L,t[9]=me):me=t[9];const ce=me;let H,ne;t[10]!==n?(H=()=>{n&&W("")},ne=[n],t[10]=n,t[11]=H,t[12]=ne):(H=t[11],ne=t[12]),c.useEffect(H,ne);let ie,F;t[13]!==v||t[14]!==B||t[15]!==I||t[16]!==n?(ie=()=>{if(!n||!I)return;const st=setTimeout(()=>{const rt=new Set;for(const Ct of v){const It=Is(Ct);!It||rt.has(It)||(rt.add(It),B(It,I))}},0);return()=>clearTimeout(st)},F=[n,v,I,B],t[13]=v,t[14]=B,t[15]=I,t[16]=n,t[17]=ie,t[18]=F):(ie=t[17],F=t[18]),c.useEffect(ie,F);let Z;t[19]!==r?(Z=()=>r(!1),t[19]=r,t[20]=Z):Z=t[20];const G=Z;let V;t[21]!==G?(V=st=>()=>{G(),st()},t[21]=G,t[22]=V):V=t[22];const Y=V;let le;t[23]!==P?.id||t[24]!==P?.path||t[25]!==D||t[26]!==m||t[27]!==R||t[28]!==d||t[29]!==u||t[30]!==x||t[31]!==S||t[32]!==Y||t[33]!==b||t[34]!==w||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==p||t[39]!==a?(le=()=>{const st=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(O,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:Y(()=>{l(!1),S()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(O,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:Y(Nw)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(O,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:Y(Aw)},{id:"toggle-sidebar",title:e(R?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(O,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(R?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:Y(()=>{if(R){const{isSessionSwitcherOpen:rt}=Ce.getState();l(!rt)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(O,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:Y(()=>{D&&u(D,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(O,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:Y(()=>{D&&d(D)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(O,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:Y(Dw)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(O,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:Y(Pw)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(O,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:Y(()=>i(!0))}];return st.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(O,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:Y(()=>{m&&D&&p({directory:D,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(O,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:Y(()=>{m&&an(m).then(rt=>{if(rt.ok){Re.success(e("sessions.sidebar.session.copyId.success"));return}Re.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Re.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(O,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:Y(()=>{l(!1),x()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(O,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:Y(()=>{l(!1),b(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(O,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:Y(()=>{D&&(w("notes"),u(D,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(O,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:Y(()=>{D&&(w("todos"),u(D,"notes"))})}),st.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(O,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:Y(Iw)}),_o()&&st.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(O,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:Y(()=>{Nn("desktop_open_draft_mini_chat_window",{directory:Li(D||P?.path||""),projectId:P?.id??null}).catch(Tw)})}),st},t[23]=P?.id,t[24]=P?.path,t[25]=D,t[26]=m,t[27]=R,t[28]=d,t[29]=u,t[30]=x,t[31]=S,t[32]=Y,t[33]=b,t[34]=w,t[35]=l,t[36]=i,t[37]=e,t[38]=p,t[39]=a,t[40]=le):le=t[40],P?.id,P?.path;let pe;t[41]!==le?(pe=le(),t[41]=le,t[42]=pe):pe=t[42];const be=pe;let Se;t[43]===Symbol.for("react.memo_cache_sentinel")?(Se=cn(),t[43]=Se):Se=t[43];const De=Se;let fe,xe;t[44]===Symbol.for("react.memo_cache_sentinel")?(fe=bn(),xe=!De&&Qi(),t[44]=fe,t[45]=xe):(fe=t[44],xe=t[45]);let ge;t[46]!==R?(ge={isVSCode:fe,isWeb:xe,isDesktop:De,isMobile:R},t[46]=R,t[47]=ge):ge=t[47];const re=ge;let he;if(t[48]!==Y||t[49]!==i||t[50]!==o||t[51]!==re){let st;t[53]!==re?(st=Ct=>Ct.isAvailable?Ct.isAvailable(re):!0,t[53]=re,t[54]=st):st=t[54];let rt;t[55]!==Y||t[56]!==i||t[57]!==o?(rt=Ct=>{const It=$h(Ct.slug)??"settings-3",Bt=(Ct.keywords??[]).join(" ");return{id:`settings:${Ct.slug}`,title:Ct.title,icon:Ct.slug==="mcp"?s.jsx(Kf,{className:"mr-2 h-4 w-4"}):s.jsx(O,{name:It,className:"mr-2 h-4 w-4"}),searchText:`${Ct.title} ${Ct.group} ${Bt}`,onSelect:Y(()=>{o(Ct.slug),i(!0)})}},t[55]=Y,t[56]=i,t[57]=o,t[58]=rt):rt=t[58],he=Lh.filter(Ew).filter(st).map(rt),t[48]=Y,t[49]=i,t[50]=o,t[51]=re,t[52]=he}else he=t[52];const Ne=he;let de;if(t[59]!==v||t[60]!==C||t[61]!==A){const st=v.filter(Rw);de=ra(st,C,A),t[59]=v,t[60]=C,t[61]=A,t[62]=de}else de=t[62];const oe=de,K=zc(),z=Qe(Mw);let ae;t[63]!==K||t[64]!==z?(ae=(st,rt)=>{const Ct=z.get(st);return Ct?.branch?Ct.branch.trim()||null:rt&&K.get(rt)?.trim()||null},t[63]=K,t[64]=z,t[65]=ae):ae=t[65];const ve=ae;let ye;t[66]===Symbol.for("react.memo_cache_sentinel")?(ye=[],t[66]=ye):ye=t[66];const[We,Be]=c.useState(ye),[Ae,X]=c.useState(""),Oe=Z1(M,Q);let Fe;t[67]!==M||t[68]!==Oe||t[69]!==n||t[70]!==E||t[71]!==Be||t[72]!==X||t[73]!==Q?(Fe=()=>{if(!n){Be([]),X("");return}if(!Oe){Be([]),X("");return}if(!M){Be([]),X("");return}let st=!1;return E(M,Q,40,{type:"file"}).then(rt=>{st||(Be(rt.map(Ow)),X(Oe))}).catch(()=>{st||(Be([]),X(Oe))}),()=>{st=!0}},t[67]=M,t[68]=Oe,t[69]=n,t[70]=E,t[71]=Be,t[72]=X,t[73]=Q,t[74]=Fe):Fe=t[74];let _;t[75]!==M||t[76]!==Oe||t[77]!==n||t[78]!==E||t[79]!==Q?(_=[n,M,Q,Oe,E],t[75]=M,t[76]=Oe,t[77]=n,t[78]=E,t[79]=Q,t[80]=_):_=t[80],c.useEffect(Fe,_);const ue=ce.length>0;let ke;e:{if(!ue){let rt;t[81]!==be?(rt=be.filter(Bw).map(_w),t[81]=be,t[82]=rt):rt=t[82],ke=rt;break e}let st;t[83]!==be||t[84]!==ce?(st=jr(be,ce,Fw,{limit:7,noFuzzy:!0}),t[83]=be,t[84]=ce,t[85]=st):st=t[85],ke=st}const je=ke;let Ke;e:{if(!ue){let rt;t[86]===Symbol.for("react.memo_cache_sentinel")?(rt=[],t[86]=rt):rt=t[86],Ke=rt;break e}let st;t[87]!==ce||t[88]!==Ne?(st=jr(Ne,ce,Lw,{limit:7,noFuzzy:!0}),t[87]=ce,t[88]=Ne,t[89]=st):st=t[89],Ke=st}const se=Ke;let Ie;e:{if(!ue){let rt;t[90]!==oe?(rt=oe.slice(0,5).map($w),t[90]=oe,t[91]=rt):rt=t[91],Ie=rt;break e}let st;t[92]!==ce||t[93]!==oe?(st=jr(oe,ce,zw,{limit:7,threshold:.2}),t[92]=ce,t[93]=oe,t[94]=st):st=t[94],Ie=st}const Ye=Ie;let ee;e:{if(!n){let rt;t[95]===Symbol.for("react.memo_cache_sentinel")?(rt=[],t[95]=rt):rt=t[95],ee=rt;break e}let st;t[96]!==We||t[97]!==Ae||t[98]!==Oe||t[99]!==Q?(st=ew(We,Q,Oe,Ae),t[96]=We,t[97]=Ae,t[98]=Oe,t[99]=Q,t[100]=st):st=t[100],ee=st}const Ee=ee,Ge=n&&Oe.length>0&&Ae!==Oe;let ze;e:{if(!ue){let rt;t[101]===Symbol.for("react.memo_cache_sentinel")?(rt=[],t[101]=rt):rt=t[101],ze=rt;break e}let st;if(t[102]!==ce||t[103]!==T){const rt=T.map(Ww);st=jr(rt,ce,Vw,{limit:7,threshold:.4}),t[102]=ce,t[103]=T,t[104]=st}else st=t[104];ze=st}const $e=ze;let _e,Xe,ct,Nt,At,Le,_t,mt,Rt,Dt,xt,we,dt,et;if(t[105]!==ve||t[106]!==G||t[107]!==M||t[108]!==U||t[109]!==ue||t[110]!==n||t[111]!==f||t[112]!==S||t[113]!==L||t[114]!==je||t[115]!==Ee||t[116]!==$e||t[117]!==Ye||t[118]!==se||t[119]!==r||t[120]!==g||t[121]!==h||t[122]!==e){const st=je.map(Uw),rt=se.map(Hw),Ct=Ye.map(Kw),It=ue?Ee.map(Gw):[],Bt=ue?$e.map(qw):[];let Tt;e:{if(!ue){Tt=["commands","sessions"];break e}const St=Qw,nt=[{key:"commands",score:St(je)},{key:"settings",score:St(se)},{key:"sessions",score:St(Ye)},{key:"files",score:St(Ee)},{key:"projects",score:St($e)}];nt.sort(Yw),Tt=nt.map(Xw)}const ns=Tt,Lt=St=>{G(),g(St.id,Is(St))},zt=async St=>{if(!M)return;const nt=await Kd(U,St,{directory:M});if(!nt.ok){Re.error(Gd(nt.reason));return}f(M,St),G()},qt=(St,nt)=>{G(),S({selectedProjectId:St,directoryOverride:nt})},ms=St=>Vn($r(St,h));Nt=Ns,we=n,dt=r;let Qt;t[137]!==e?(Qt=e("commandPalette.title"),t[137]=e,t[138]=Qt):Qt=t[138];let Me;t[139]!==Qt?(Me=s.jsx(Fs,{children:Qt}),t[139]=Qt,t[140]=Me):Me=t[140];let Ve;t[141]!==e?(Ve=e("commandPalette.description"),t[141]=e,t[142]=Ve):Ve=t[142];let Ze;t[143]!==Ve?(Ze=s.jsx(Ls,{children:Ve}),t[143]=Ve,t[144]=Ze):Ze=t[144],t[145]!==Me||t[146]!==Ze?(et=s.jsxs(Gs,{className:"sr-only",children:[Me,Ze]}),t[145]=Me,t[146]=Ze,t[147]=et):et=t[147],ct=As,Dt="overflow-hidden p-0",xt=!0,Xe=Gf,_t=!1,mt="[&_[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 at;t[148]!==e?(at=e("commandPalette.input.placeholder"),t[148]=e,t[149]=at):at=t[149],t[150]!==L||t[151]!==at?(Rt=s.jsx(qf,{value:L,onValueChange:W,placeholder:at}),t[150]=L,t[151]=at,t[152]=Rt):Rt=t[152],_e=Qf;let ut;t[153]!==e?(ut=e("commandPalette.empty.noResults"),t[153]=e,t[154]=ut):ut=t[154],t[155]!==ut?(At=s.jsx(Yf,{children:ut}),t[155]=ut,t[156]=At):At=t[156],Le=ns.map(St=>St==="commands"&&st.length>0?s.jsx(pr,{children:st.map(nt=>s.jsxs(kr,{value:nt.id,onSelect:nt.onSelect,children:[nt.icon,s.jsx("span",{children:nt.title}),nt.shortcutId?s.jsx(Uf,{children:ms(nt.shortcutId)}):null]},nt.id))},"commands"):St==="settings"&&rt.length>0?s.jsx(pr,{children:rt.map(Jw)},"settings"):St==="sessions"&&Ct.length>0?s.jsx(pr,{children:Ct.map(nt=>{const Ft=nt.title||e("commandPalette.session.untitled"),Xt=Is(nt),os=ve(nt.id,Xt);return s.jsxs(kr,{value:`session:${nt.id}`,onSelect:()=>Lt(nt),children:[s.jsx(O,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:Ft}),os?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:os})]}):null]},nt.id)})},"sessions"):St==="files"&&It.length>0?s.jsx(pr,{children:It.map(nt=>{const Ft=Hf(nt.relativePath||nt.name,{maxLength:80});return s.jsxs(kr,{value:`file:${nt.path}`,onSelect:()=>{zt(nt.path)},children:[s.jsx(sa,{filePath:nt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":nt.relativePath,children:Ft})]},`file:${nt.path}`)})},"files"):St==="projects"&&Bt.length>0?s.jsx(pr,{children:Bt.map(nt=>{const Ft=nt.displayName;return s.jsxs(kr,{value:`project:${nt.id}`,onSelect:()=>qt(nt.id,nt.path),children:[s.jsx(O,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:Ft}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:nt.path})]},`project:${nt.id}`)})},"projects"):null),t[105]=ve,t[106]=G,t[107]=M,t[108]=U,t[109]=ue,t[110]=n,t[111]=f,t[112]=S,t[113]=L,t[114]=je,t[115]=Ee,t[116]=$e,t[117]=Ye,t[118]=se,t[119]=r,t[120]=g,t[121]=h,t[122]=e,t[123]=_e,t[124]=Xe,t[125]=ct,t[126]=Nt,t[127]=At,t[128]=Le,t[129]=_t,t[130]=mt,t[131]=Rt,t[132]=Dt,t[133]=xt,t[134]=we,t[135]=dt,t[136]=et}else _e=t[123],Xe=t[124],ct=t[125],Nt=t[126],At=t[127],Le=t[128],_t=t[129],mt=t[130],Rt=t[131],Dt=t[132],xt=t[133],we=t[134],dt=t[135],et=t[136];let qe;t[157]!==Ge||t[158]!==e?(qe=Ge?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[157]=Ge,t[158]=e,t[159]=qe):qe=t[159];let kt;t[160]!==_e||t[161]!==At||t[162]!==Le||t[163]!==qe?(kt=s.jsxs(_e,{children:[At,Le,qe]}),t[160]=_e,t[161]=At,t[162]=Le,t[163]=qe,t[164]=kt):kt=t[164];let wt;t[165]!==Xe||t[166]!==_t||t[167]!==mt||t[168]!==Rt||t[169]!==kt?(wt=s.jsxs(Xe,{shouldFilter:_t,className:mt,children:[Rt,kt]}),t[165]=Xe,t[166]=_t,t[167]=mt,t[168]=Rt,t[169]=kt,t[170]=wt):wt=t[170];let jt;t[171]!==ct||t[172]!==Dt||t[173]!==xt||t[174]!==wt?(jt=s.jsx(ct,{className:Dt,showCloseButton:xt,children:wt}),t[171]=ct,t[172]=Dt,t[173]=xt,t[174]=wt,t[175]=jt):jt=t[175];let Ut;return t[176]!==Nt||t[177]!==we||t[178]!==dt||t[179]!==et||t[180]!==jt?(Ut=s.jsxs(Nt,{open:we,onOpenChange:dt,children:[et,jt]}),t[176]=Nt,t[177]=we,t[178]=dt,t[179]=et,t[180]=jt,t[181]=Ut):Ut=t[181],Ut};function rw(t){return t.isCommandPaletteOpen}function ow(t){return t.setCommandPaletteOpen}function iw(t){return t.setSettingsDialogOpen}function aw(t){return t.setSettingsPage}function lw(t){return t.setSessionSwitcherOpen}function cw(t){return t.toggleSidebar}function dw(t){return t.openContextOverview}function uw(t){return t.openContextSurface}function fw(t){return t.openContextFile}function mw(t){return t.shortcutOverrides}function hw(t){return t.openMultiRunLauncher}function pw(t){return t.setArchivePageOpen}function gw(t){return t.setProjectContextTab}function bw(t){return t.openNewSessionDraft}function xw(t){return t.setCurrentSession}function yw(t){return t.currentSessionId}function ww(t){return t.toggle}function Sw(t){return t.currentDirectory}function vw(t){return t.getActiveProject()}function jw(t){return t.projects}function kw(t){return t.searchFiles}function Cw(t){return t.ensureStatus}function Nw(){Vc()}function Aw(){ln.requestDirectoryDialog()}function Dw(){Xf.invoke("cycle_theme")}function Pw(){pu()}function Iw(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function Tw(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function Ew(t){return t.slug!=="home"}function Rw(t){return!Wc(t)}function Mw(t){return t.worktreeMetadata}function Ow(t){return{path:Li(t.path),name:t.name,relativePath:t.relativePath}}function Bw(t){return!t.secondary}function _w(t){return{item:t,score:0}}function Fw(t){return t.searchText}function Lw(t){return t.searchText}function $w(t){return{item:t,score:0}}function zw(t){return t.title||""}function Ww(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Vw(t){return t.searchText}function Uw(t){return t.item}function Hw(t){return t.item}function Kw(t){return t.item}function Gw(t){return t.item}function qw(t){return t.item}function Qw(t){return t.length?t[0].score:1/0}function Yw(t,e){return t.score-e.score}function Xw(t){return t.key}function Jw(t){return s.jsxs(kr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const El=(t,e,n)=>Vn($r(t,e),n),Zw=()=>{const t=Je.c(68),{t:e}=ft(),n=Ce(eS),r=Ce(tS),i=Ce(sS);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=bn(),t[0]=o):o=t[0];const l=o;let a,d,u,f,h,x,b,w,S;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const I=[{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:[Vn("mod+shift+alt+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:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${Vn(xi("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${Vn(xi("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",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:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];d=Ns,w=n,S=r,a=As,x="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let B;t[14]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(O,{name:"command",className:"h-5 w-5"}),t[14]=B):B=t[14];let R;t[15]!==e?(R=e("helpDialog.title"),t[15]=e,t[16]=R):R=t[16];let j;t[17]!==R?(j=s.jsxs(Fs,{className:"flex items-center gap-2",children:[B,R]}),t[17]=R,t[18]=j):j=t[18];let M;t[19]!==e?(M=e("helpDialog.description"),t[19]=e,t[20]=M):M=t[20];let L;t[21]!==M?(L=s.jsx(Ls,{children:M}),t[21]=M,t[22]=L):L=t[22],t[23]!==j||t[24]!==L?(b=s.jsxs(Gs,{children:[j,L]}),t[23]=j,t[24]=L,t[25]=b):b=t[25],h="flex-1 overflow-y-auto mt-3 pr-1",u="space-y-4",f=I.map(W=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(W.categoryKey)}),s.jsx("div",{className:"space-y-1",children:W.items.filter(te=>!(l&&te.id==="toggle_prompt_navigator")).map(te=>{const Q=te.id?Jf(te.id):void 0,me=te.descriptionKey??(Q?.customizable?Q.settingsLabelKey:void 0);if(!me||te.id&&!$r(te.id,i))return null;const ce=te.id?El(te.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(te.keys)?te.keys:te.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:[te.icon&&s.jsx(O,{name:te.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(me)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(ce)?ce:[ce]).map((H,ne)=>s.jsxs(c.Fragment,{children:[ne>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:H})]},`${H}-${ne}`))})]},te.id||me)})})]},W.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=d,t[7]=u,t[8]=f,t[9]=h,t[10]=x,t[11]=b,t[12]=w,t[13]=S}else a=t[5],d=t[6],u=t[7],f=t[8],h=t[9],x=t[10],b=t[11],w=t[12],S=t[13];let g;t[26]!==u||t[27]!==f?(g=s.jsx("div",{className:u,children:f}),t[26]=u,t[27]=f,t[28]=g):g=t[28];let m;t[29]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(O,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[29]=m):m=t[29];let p;t[30]!==e?(p=e("helpDialog.proTips.title"),t[30]=e,t[31]=p):p=t[31];let y;t[32]!==p?(y=s.jsx("p",{className:"font-medium mb-1",children:p}),t[32]=p,t[33]=y):y=t[33];let v;t[34]!==i||t[35]!==e?(v=e("helpDialog.proTips.commandPalette",{shortcut:El("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[34]=i,t[35]=e,t[36]=v):v=t[36];let N;t[37]!==v?(N=s.jsxs("li",{children:["• ",v]}),t[37]=v,t[38]=N):N=t[38];let C;t[39]!==e?(C=e("helpDialog.proTips.recentSessions"),t[39]=e,t[40]=C):C=t[40];let k;t[41]!==C?(k=s.jsxs("li",{children:["• ",C]}),t[41]=C,t[42]=k):k=t[42];let A;t[43]!==e?(A=e("helpDialog.proTips.leaderSequences"),t[43]=e,t[44]=A):A=t[44];let D;t[45]!==A?(D=s.jsxs("li",{children:["• ",A]}),t[45]=A,t[46]=D):D=t[46];let P;t[47]!==N||t[48]!==k||t[49]!==D?(P=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[N,k,D]}),t[47]=N,t[48]=k,t[49]=D,t[50]=P):P=t[50];let T;t[51]!==y||t[52]!==P?(T=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[m,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[y,P]})]})}),t[51]=y,t[52]=P,t[53]=T):T=t[53];let $;t[54]!==T||t[55]!==h||t[56]!==g?($=s.jsxs("div",{className:h,children:[g,T]}),t[54]=T,t[55]=h,t[56]=g,t[57]=$):$=t[57];let E;t[58]!==a||t[59]!==$||t[60]!==x||t[61]!==b?(E=s.jsxs(a,{className:x,children:[b,$]}),t[58]=a,t[59]=$,t[60]=x,t[61]=b,t[62]=E):E=t[62];let U;return t[63]!==d||t[64]!==E||t[65]!==w||t[66]!==S?(U=s.jsx(d,{open:w,onOpenChange:S,children:E}),t[63]=d,t[64]=E,t[65]=w,t[66]=S,t[67]=U):U=t[67],U};function eS(t){return t.isHelpDialogOpen}function tS(t){return t.setHelpDialogOpen}function sS(t){return t.shortcutOverrides}const nS=()=>{const t=Je.c(32),{t:e}=ft(),n=Ce(rS),r=Ce(oS),i=Ce(iS);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await an(i)).ok){Re.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Re.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Fs,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let f;t[9]!==u?(f=s.jsx(Ls,{children:u}),t[9]=u,t[10]=f):f=t[10];let h;t[11]!==d||t[12]!==f?(h=s.jsxs(Gs,{children:[d,f]}),t[11]=d,t[12]=f,t[13]=h):h=t[13];let x;t[14]!==e?(x=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=x):x=t[15];let b;t[16]!==l||t[17]!==x?(b=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:x})}),t[16]=l,t[17]=x,t[18]=b):b=t[18];let w;t[19]!==i||t[20]!==e?(w=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=w):w=t[21];let S;t[22]!==w?(S=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:w}),t[22]=w,t[23]=S):S=t[23];let g;t[24]!==h||t[25]!==b||t[26]!==S?(g=s.jsxs(As,{className:"max-w-2xl",children:[h,b,S]}),t[24]=h,t[25]=b,t[26]=S,t[27]=g):g=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==g?(m=s.jsx(Ns,{open:n,onOpenChange:r,children:g}),t[28]=n,t[29]=r,t[30]=g,t[31]=m):m=t[31],m};function rS(t){return t.isOpenCodeStatusDialogOpen}function oS(t){return t.setOpenCodeStatusDialogOpen}function iS(t){return t.openCodeStatusText}const aS=t=>{const e=Je.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const w=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(w)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let f,h;e[5]!==a||e[6]!==o||e[7]!==i?(f=()=>{if(!a||typeof window>"u")return;const w=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",w),()=>window.removeEventListener("openchamber:sidebar-session-search",w)},h=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=f,e[9]=h):(f=e[8],h=e[9]),c.useEffect(f,h);let x,b;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(x=()=>{if(!a||!r||typeof document>"u")return;const w=S=>{l.current&&(l.current.contains(S.target)||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},b=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=x,e[15]=b):(x=e[14],b=e[15]),c.useEffect(x,b)},lS=t=>{const e=Je.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(cS)),u=[];a.forEach(x=>{const b=d.get(x);b&&(u.push(b),d.delete(x))});const f=[],h=[];return l.forEach(x=>{d.has(x.id)&&(x.isArchivedBucket?h.push(x):f.push(x))}),[...f,...u,...h]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function cS(t){return[t.id,t]}const to="oc.sessions.projectCollapse",Rl="oc.sessions.groupOrder",Ml="oc.sessions.groupCollapse",Ol=t=>{if(!t)return new Set;try{const e=ma(ur()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},dS=t=>{if(!t)return new Map;try{const e=Pd(ur(),ma(ur())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},uS=t=>{const e=Je.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=vo(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>Ol(o.getItem(to)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>Ol(o.getItem(Ml)),e[2]=u):u=e[2];const[f,h]=c.useState(u);let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=()=>dS(o.getItem(Rl)),e[3]=x):x=e[3];const[b,w]=c.useState(x),S=c.useRef(0),g=c.useRef(!1),m=c.useRef(!1),p=c.useRef(null),y=c.useRef(null);let v;e[4]!==n?(v=()=>{if(n)return;const Z=y.current;if(y.current=null,p.current=null,!Z)return;const{projects:G}=Vt.getState(),V=G.map(Y=>({...Y,sidebarCollapsed:Z.has(Y.id)}));vr({projects:V}).catch(fS)},e[4]=n,e[5]=v):v=e[5];const N=v;let C;e[6]!==N||e[7]!==n?(C=Z=>{!globalThis.window||n||(y.current=Z,p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=C):C=e[8];const k=C;let A,D;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=()=>()=>{globalThis.window&&p.current!==null&&window.clearTimeout(p.current),p.current=null,y.current=null},D=[],e[9]=A,e[10]=D):(A=e[9],D=e[10]),c.useEffect(A,D);let P,T;e[11]!==b?(T=()=>{if(m.current)try{o.setItem(Rl,JSON.stringify(Object.fromEntries(b.entries())))}catch{}},P=[b,o],e[11]=b,e[12]=P,e[13]=T):(P=e[12],T=e[13]),c.useEffect(T,P);let $,E;e[14]!==f?($=()=>{if(g.current)try{o.setItem(Ml,JSON.stringify(Array.from(f)))}catch{}},E=[f,o],e[14]=f,e[15]=$,e[16]=E):($=e[15],E=e[16]),c.useEffect($,E);let U;e[17]!==r||e[18]!==k?(U=()=>{S.current=Date.now()+150,g.current=!0,h(new Set),d(()=>{const Z=new Set(r.map(mS));try{o.setItem(to,JSON.stringify(Array.from(Z)))}catch{}return k(Z),Z})},e[17]=r,e[18]=k,e[19]=U):U=e[19];const I=U;let B;e[20]!==k?(B=()=>{S.current=Date.now()+150,g.current=!0,h(new Set),d(()=>{const Z=new Set;try{o.setItem(to,JSON.stringify([]))}catch{}return k(Z),Z})},e[20]=k,e[21]=B):B=e[21];const R=B;let j;e[22]!==k?(j=Z=>{S.current=Date.now()+150,d(G=>{const V=new Set(G);V.has(Z)?V.delete(Z):V.add(Z);try{o.setItem(to,JSON.stringify(Array.from(V)))}catch{}return k(V),V})},e[22]=k,e[23]=j):j=e[23];const M=j;let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=Z=>{g.current=!0,h(G=>{const V=new Set(G);return V.has(Z)?V.delete(Z):V.add(Z),V})},e[24]=L):L=e[24];const W=L;let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=Z=>{m.current=!0,w(Z)},e[25]=te):te=e[25];const Q=te,{getOrderedGroups:me}=lS(b);let ce;e[26]!==f||e[27]!==a||e[28]!==b?(ce={collapsedProjects:a,collapsedGroups:f,groupOrderByProject:b},e[26]=f,e[27]=a,e[28]=b,e[29]=ce):ce=e[29];const H=ce;let ne;e[30]!==I||e[31]!==R||e[32]!==me||e[33]!==k||e[34]!==M?(ne={setCollapsedProjects:d,toggleProject:M,collapseAllProjects:I,expandAllProjects:R,scheduleCollapsedProjectsPersist:k,setCollapsedGroups:h,toggleGroup:W,setGroupOrderByProject:Q,getOrderedGroups:me},e[30]=I,e[31]=R,e[32]=me,e[33]=k,e[34]=M,e[35]=ne):ne=e[35];const ie=ne;let F;return e[36]!==ie||e[37]!==H?(F={state:H,actions:ie},e[36]=ie,e[37]=H,e[38]=F):F=e[38],F};function fS(){}function mS(t){return t.id}const hS=5*6e4,pS=t=>{const e=Je.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=xn(),u=Pn(gS);let f,h;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(f=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(C=>{yi(()=>u(C.normalizedPath,d))})},h=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=f,e[6]=h):(f=e[5],h=e[6]),c.useEffect(f,h);let x,b;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(x=()=>{if(!a)return;const C=new Map;n.forEach(k=>{C.set(k.id,i.get(k.normalizedPath)?.isGitRepo??null)}),o(C)},b=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=x,e[12]=b):(x=e[11],b=e[12]),c.useEffect(x,b);let w;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=k=>{const A=i.get(k.normalizedPath)?.branch??"";return`${k.id}:${A}`},e[16]=i,e[17]=C):C=e[17],w=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=w}else w=e[15];const S=w;let g;e[18]===Symbol.for("react.memo_cache_sentinel")?(g=new Map,e[18]=g):g=e[18];const m=c.useRef(g);let p;e[19]===Symbol.for("react.memo_cache_sentinel")?(p=new Map,e[19]=p):p=e[19];const y=c.useRef(p);let v;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(v=()=>{if(!a)return;let C=!1;const k=setTimeout(()=>{(async()=>{const D=new Set(n.map(bS));for(const I of m.current.keys())D.has(I)||(m.current.delete(I),y.current.delete(I));const P=Date.now(),T=n.filter(I=>{const B=i.get(I.normalizedPath);if(B?.isGitRepo===!1)return m.current.delete(I.id),y.current.delete(I.id),!1;if(B?.isGitRepo!==!0||B.branch===null)return!1;const R=B.branch.trim(),j=`${I.normalizedPath}\0${R}`,M=m.current.get(I.id);if(M===j){const L=y.current.get(I.id);return L&&(L.at=P),!1}return!(M!==void 0&&P-(y.current.get(I.id)?.at??0)<hS)});if(T.length===0)return;const $=await Zf(T,2,async I=>{const B=i.get(I.normalizedPath)?.branch?.trim()??"",R=`${I.normalizedPath}\0${B}`,j=await yi(()=>Wo(I.normalizedPath,B?{knownBranch:B}:void 0)).catch(xS);return{id:I.id,inputKey:R,branch:j}});if(C)return;const E=$.filter(yS);if(E.length===0)return;const U=Date.now();l(I=>{const B=new Map(I);return E.forEach(R=>{const{id:j,branch:M}=R;M&&B.set(j,M)}),B}),E.forEach(I=>{const{id:B,inputKey:R,branch:j}=I;m.current.set(B,R),j&&y.current.set(B,{branch:j,at:U})})})()},150);return()=>{C=!0,clearTimeout(k)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=v):v=e[24];let N;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==S||e[29]!==l?(N=[a,n,S,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=S,e[29]=l,e[30]=N):N=e[30],c.useEffect(v,N)};function gS(t){return t.ensureStatus}function bS(t){return t.id}function xS(){return null}function yS(t){return t.branch}const wS=t=>{const e=Je.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(zh,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(As,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(pn,{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:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(Ns,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d},SS=(t,e)=>{if(!e)return Array.from(t);const n=[],r=new Set;for(const i of t){r.has(i)||(r.add(i),n.push(i));const o=e.get(i);if(o)for(const l of o)r.has(l)||(r.add(l),n.push(l))}return n},ws=Yn()((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,i)=>{const o=e(),l=new Set(o.selectedIds);let a=o.scopeKey,d=o.anchorId;r!==null&&o.scopeKey!==null&&r!==o.scopeKey?(l.clear(),a=r,d=null):a===null&&r!==null&&(a=r);const f=i&&i.length>0?[n,...i]:[n];if(l.has(n)){for(const x of f)l.delete(x);d===n&&(d=null)}else{for(const x of f)l.add(x);d=n}l.size===0?t({selectedIds:l,scopeKey:null,anchorId:null}):t({selectedIds:l,scopeKey:a,anchorId:d})},setRange:(n,r,i,o,l)=>{const a=e();if(i.length===0)return;const d=n&&i.includes(n)?n:i[0],u=i.indexOf(d),f=i.indexOf(r);if(u<0||f<0)return;const[h,x]=u<=f?[u,f]:[f,u],b=i.slice(h,x+1),w=SS(b,l),g=o!==null&&a.scopeKey!==null&&o!==a.scopeKey?new Set:new Set(a.selectedIds);for(const m of w)g.add(m);t({selectedIds:g,scopeKey:o??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 i=new Set(r.selectedIds);for(const o of n)i.delete(o);i.size!==r.selectedIds.size&&(i.size===0?t({selectedIds:i,scopeKey:null,anchorId:null}):t({selectedIds:i}))}}));function vS(t){const e=Je.c(213),{t:n}=ft(),{hideDirectoryControls:r,showProjectDisplayControls:i,showRecentControls:o,handleOpenDirectoryDialog:l,onOpenScheduled:a,onOpenMultiRun:d,canOpenMultiRun:u,onOpenArchive:f,headerActionIconClass:h,headerActionButtonClass:x,isSessionSearchOpen:b,setIsSessionSearchOpen:w,sessionSearchInputRef:S,sessionSearchQuery:g,setSessionSearchQuery:m,hasSessionSearchQuery:p,searchMatchCount:y,collapseAllProjects:v,expandAllProjects:N}=t,C=ws(OS),k=ws(MS),A=us(RS),D=us(ES),P=us(TS),T=us(IS),$=us(PS),E=us(DS),U=us(AS),I=us(NS),B=us(CS),R=us(kS),j=i&&B==="single";if(r)return null;let M;e[0]!==x?(M=Pe(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=x,e[1]=M):M=e[1];let L;e[2]!==n?(L=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=L):L=e[3];let W;e[4]!==h?(W=s.jsx(O,{name:"folder-add",className:h}),e[4]=h,e[5]=W):W=e[5];let te;e[6]!==l||e[7]!==M||e[8]!==L||e[9]!==W?(te=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,className:M,"aria-label":L,children:W})}),e[6]=l,e[7]=M,e[8]=L,e[9]=W,e[10]=te):te=e[10];let Q;e[11]!==n?(Q=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=Q):Q=e[12];let me;e[13]!==Q?(me=s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Q})}),e[13]=Q,e[14]=me):me=e[14];let ce;e[15]!==te||e[16]!==me?(ce=s.jsxs(gt,{delayDuration:500,children:[te,me]}),e[15]=te,e[16]=me,e[17]=ce):ce=e[17];let H;e[18]!==x?(H=Pe(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=x,e[19]=H):H=e[19];let ne;e[20]!==n?(ne=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=ne):ne=e[21];let ie;e[22]!==h?(ie=s.jsx(O,{name:"calendar-schedule",className:h}),e[22]=h,e[23]=ie):ie=e[23];let F;e[24]!==a||e[25]!==H||e[26]!==ne||e[27]!==ie?(F=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:H,"aria-label":ne,children:ie})}),e[24]=a,e[25]=H,e[26]=ne,e[27]=ie,e[28]=F):F=e[28];let Z;e[29]!==n?(Z=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=Z):Z=e[30];let G;e[31]!==Z?(G=s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Z})}),e[31]=Z,e[32]=G):G=e[32];let V;e[33]!==F||e[34]!==G?(V=s.jsxs(gt,{delayDuration:500,children:[F,G]}),e[33]=F,e[34]=G,e[35]=V):V=e[35];let Y;e[36]!==x?(Y=Pe(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=x,e[37]=Y):Y=e[37];let le;e[38]!==n?(le=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=le):le=e[39];const pe=!u;let be;e[40]!==h?(be=s.jsx(em,{className:h}),e[40]=h,e[41]=be):be=e[41];let Se;e[42]!==d||e[43]!==Y||e[44]!==le||e[45]!==pe||e[46]!==be?(Se=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:Y,"aria-label":le,disabled:pe,children:be})}),e[42]=d,e[43]=Y,e[44]=le,e[45]=pe,e[46]=be,e[47]=Se):Se=e[47];let De;e[48]!==n?(De=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=De):De=e[49];let fe;e[50]!==De?(fe=s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:De})}),e[50]=De,e[51]=fe):fe=e[51];let xe;e[52]!==Se||e[53]!==fe?(xe=s.jsxs(gt,{delayDuration:500,children:[Se,fe]}),e[52]=Se,e[53]=fe,e[54]=xe):xe=e[54];let ge;e[55]!==x?(ge=Pe(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=x,e[56]=ge):ge=e[56];let re;e[57]!==n?(re=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=re):re=e[58];let he;e[59]!==h?(he=s.jsx(O,{name:"archive",className:h}),e[59]=h,e[60]=he):he=e[60];let Ne;e[61]!==f||e[62]!==ge||e[63]!==re||e[64]!==he?(Ne=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:ge,"aria-label":re,children:he})}),e[61]=f,e[62]=ge,e[63]=re,e[64]=he,e[65]=Ne):Ne=e[65];let de;e[66]!==n?(de=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=de):de=e[67];let oe;e[68]!==de?(oe=s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:de})}),e[68]=de,e[69]=oe):oe=e[69];let K;e[70]!==Ne||e[71]!==oe?(K=s.jsxs(gt,{delayDuration:500,children:[Ne,oe]}),e[70]=Ne,e[71]=oe,e[72]=K):K=e[72];let z;e[73]!==V||e[74]!==xe||e[75]!==K||e[76]!==ce?(z=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[ce,V,xe,K]}),e[73]=V,e[74]=xe,e[75]=K,e[76]=ce,e[77]=z):z=e[77];let ae;e[78]!==w?(ae=()=>w(jS),e[78]=w,e[79]=ae):ae=e[79];let ve;e[80]!==x?(ve=Pe(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[80]=x,e[81]=ve):ve=e[81];let ye;e[82]!==n?(ye=n("sessions.sidebar.header.actions.searchSessions"),e[82]=n,e[83]=ye):ye=e[83];let We;e[84]!==h?(We=s.jsx(O,{name:"search",className:h}),e[84]=h,e[85]=We):We=e[85];let Be;e[86]!==b||e[87]!==ae||e[88]!==ve||e[89]!==ye||e[90]!==We?(Be=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ae,className:ve,"aria-label":ye,"aria-expanded":b,children:We})}),e[86]=b,e[87]=ae,e[88]=ve,e[89]=ye,e[90]=We,e[91]=Be):Be=e[91];let Ae;e[92]!==n?(Ae=n("sessions.sidebar.header.actions.searchSessions"),e[92]=n,e[93]=Ae):Ae=e[93];let X;e[94]!==Ae?(X=s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ae})}),e[94]=Ae,e[95]=X):X=e[95];let Oe;e[96]!==Be||e[97]!==X?(Oe=s.jsxs(gt,{delayDuration:500,children:[Be,X]}),e[96]=Be,e[97]=X,e[98]=Oe):Oe=e[98];const Fe=C&&"bg-interactive-hover text-primary";let _;e[99]!==x||e[100]!==Fe?(_=Pe(x,"text-muted-foreground hover:text-foreground hover:bg-transparent",Fe),e[99]=x,e[100]=Fe,e[101]=_):_=e[101];let ue;e[102]!==C||e[103]!==n?(ue=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[102]=C,e[103]=n,e[104]=ue):ue=e[104];let ke;e[105]!==h?(ke=s.jsx(O,{name:"checkbox-multiple",className:h}),e[105]=h,e[106]=ke):ke=e[106];let je;e[107]!==C||e[108]!==_||e[109]!==ue||e[110]!==ke||e[111]!==k?(je=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:k,className:_,"aria-label":ue,"aria-pressed":C,children:ke})}),e[107]=C,e[108]=_,e[109]=ue,e[110]=ke,e[111]=k,e[112]=je):je=e[112];let Ke;e[113]!==C||e[114]!==n?(Ke=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[113]=C,e[114]=n,e[115]=Ke):Ke=e[115];let se;e[116]!==Ke?(se=s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ke})}),e[116]=Ke,e[117]=se):se=e[117];let Ie;e[118]!==je||e[119]!==se?(Ie=s.jsxs(gt,{delayDuration:500,children:[je,se]}),e[118]=je,e[119]=se,e[120]=Ie):Ie=e[120];let Ye;e[121]!==x?(Ye=Pe(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[121]=x,e[122]=Ye):Ye=e[122];let ee;e[123]!==n?(ee=n("sessions.sidebar.header.displayMode.label"),e[123]=n,e[124]=ee):ee=e[124];let Ee;e[125]!==h?(Ee=s.jsx(O,{name:"equalizer-2",className:h}),e[125]=h,e[126]=Ee):Ee=e[126];let Ge;e[127]!==Ye||e[128]!==ee||e[129]!==Ee?(Ge=s.jsx(ht,{asChild:!0,children:s.jsx(Us,{asChild:!0,children:s.jsx("button",{type:"button",className:Ye,"aria-label":ee,children:Ee})})}),e[127]=Ye,e[128]=ee,e[129]=Ee,e[130]=Ge):Ge=e[130];let ze;e[131]!==n?(ze=n("sessions.sidebar.header.displayMode.label"),e[131]=n,e[132]=ze):ze=e[132];let $e;e[133]!==ze?($e=s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ze})}),e[133]=ze,e[134]=$e):$e=e[134];let _e;e[135]!==Ge||e[136]!==$e?(_e=s.jsxs(gt,{delayDuration:500,children:[Ge,$e]}),e[135]=Ge,e[136]=$e,e[137]=_e):_e=e[137];let Xe;e[138]!==n?(Xe=n("sessions.sidebar.header.actions.sortProjects"),e[138]=n,e[139]=Xe):Xe=e[139];let ct;e[140]!==Xe?(ct=s.jsx(lo,{children:Xe}),e[140]=Xe,e[141]=ct):ct=e[141];let Nt;e[142]!==P||e[143]!==T||e[144]!==n?(Nt=[["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(It=>{const[Bt,Tt]=It;return s.jsxs(Wt,{onClick:()=>{T(Bt),vr({sidebarProjectSortOrder:Bt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Tt)}),P===Bt?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},Bt)}),e[142]=P,e[143]=T,e[144]=n,e[145]=Nt):Nt=e[145];let At;e[146]===Symbol.for("react.memo_cache_sentinel")?(At=s.jsx(Rs,{}),e[146]=At):At=e[146];let Le;e[147]!==B||e[148]!==R||e[149]!==i||e[150]!==n?(Le=i?s.jsxs(s.Fragment,{children:[s.jsx(lo,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(It=>{const[Bt,Tt]=It;return s.jsxs(Wt,{onClick:()=>{R(Bt),vr({sidebarProjectDisplayMode:Bt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Tt)}),B===Bt?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},Bt)}),s.jsx(Rs,{})]}):null,e[147]=B,e[148]=R,e[149]=i,e[150]=n,e[151]=Le):Le=e[151];let _t;e[152]!==n?(_t=n("sessions.sidebar.header.grouping.label"),e[152]=n,e[153]=_t):_t=e[153];let mt;e[154]!==_t?(mt=s.jsx(lo,{children:_t}),e[154]=_t,e[155]=mt):mt=e[155];let Rt;e[156]!==$||e[157]!==E||e[158]!==n?(Rt=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(It=>{const[Bt,Tt]=It;return s.jsxs(Wt,{onClick:()=>{E(Bt),vr({sidebarSessionGroupingMode:Bt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Tt)}),$===Bt?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},Bt)}),e[156]=$,e[157]=E,e[158]=n,e[159]=Rt):Rt=e[159];let Dt;e[160]===Symbol.for("react.memo_cache_sentinel")?(Dt=s.jsx(Rs,{}),e[160]=Dt):Dt=e[160];let xt;e[161]!==j||e[162]!==o||e[163]!==A||e[164]!==n||e[165]!==D?(xt=o&&!j?s.jsxs(Wt,{onClick:()=>{D(),vr({sidebarShowRecentSection:!A})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),A?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[161]=j,e[162]=o,e[163]=A,e[164]=n,e[165]=D,e[166]=xt):xt=e[166];let we;e[167]!==n?(we=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[167]=n,e[168]=we):we=e[168];let dt;e[169]!==we?(dt=s.jsx("span",{children:we}),e[169]=we,e[170]=dt):dt=e[170];let et;e[171]!==U?(et=U?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null,e[171]=U,e[172]=et):et=e[172];let qe;e[173]!==dt||e[174]!==et||e[175]!==I?(qe=s.jsxs(Wt,{onClick:I,className:"flex items-center justify-between",children:[dt,et]}),e[173]=dt,e[174]=et,e[175]=I,e[176]=qe):qe=e[176];let kt;e[177]!==v||e[178]!==N||e[179]!==j||e[180]!==n?(kt=j?null:s.jsxs(s.Fragment,{children:[s.jsx(Rs,{}),s.jsxs(Wt,{onClick:v,className:"flex items-center gap-2",children:[s.jsx(O,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Wt,{onClick:N,className:"flex items-center gap-2",children:[s.jsx(O,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}),e[177]=v,e[178]=N,e[179]=j,e[180]=n,e[181]=kt):kt=e[181];let wt;e[182]!==ct||e[183]!==Nt||e[184]!==Le||e[185]!==mt||e[186]!==Rt||e[187]!==xt||e[188]!==qe||e[189]!==kt?(wt=s.jsxs(Hs,{align:"end",className:"min-w-[180px]",children:[ct,Nt,At,Le,mt,Rt,Dt,xt,qe,kt]}),e[182]=ct,e[183]=Nt,e[184]=Le,e[185]=mt,e[186]=Rt,e[187]=xt,e[188]=qe,e[189]=kt,e[190]=wt):wt=e[190];let jt;e[191]!==_e||e[192]!==wt?(jt=s.jsxs(Ks,{children:[_e,wt]}),e[191]=_e,e[192]=wt,e[193]=jt):jt=e[193];let Ut;e[194]!==Oe||e[195]!==Ie||e[196]!==jt?(Ut=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Oe,Ie,jt]}),e[194]=Oe,e[195]=Ie,e[196]=jt,e[197]=Ut):Ut=e[197];let st;e[198]!==z||e[199]!==Ut?(st=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[z,Ut]}),e[198]=z,e[199]=Ut,e[200]=st):st=e[200];let rt;e[201]!==p||e[202]!==b||e[203]!==y||e[204]!==S||e[205]!==g||e[206]!==w||e[207]!==m||e[208]!==n?(rt=b?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:[p?s.jsx("span",{children:y===1?n("sessions.sidebar.header.search.matchCountSingle",{count:y}):n("sessions.sidebar.header.search.matchCountPlural",{count:y})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsxs("div",{className:"relative",children:[s.jsx(O,{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:g,onChange:It=>m(It.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:It=>{It.key==="Escape"&&(It.stopPropagation(),p?m(""):w(!1))}}),g.length>0?s.jsx("button",{type:"button",onClick:()=>m(""),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(O,{name:"close",className:"h-3.5 w-3.5"})}):null]})]}):null,e[201]=p,e[202]=b,e[203]=y,e[204]=S,e[205]=g,e[206]=w,e[207]=m,e[208]=n,e[209]=rt):rt=e[209];let Ct;return e[210]!==st||e[211]!==rt?(Ct=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:[st,rt]})}),e[210]=st,e[211]=rt,e[212]=Ct):Ct=e[212],Ct}function jS(t){return!t}function kS(t){return t.setProjectDisplayMode}function CS(t){return t.projectDisplayMode}function NS(t){return t.toggleStickyZoneHeaders}function AS(t){return t.stickyZoneHeaders}function DS(t){return t.setSessionGroupingMode}function PS(t){return t.sessionGroupingMode}function IS(t){return t.setProjectSortOrder}function TS(t){return t.projectSortOrder}function ES(t){return t.toggleRecentSection}function RS(t){return t.showRecentSection}function MS(t){return t.toggleMode}function OS(t){return t.enabled}function BS(t){const e=Je.c(8),{t:n}=ft(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(O,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==o?(l=s.jsx("span",{className:"truncate",children:o}),e[3]=o,e[4]=l):l=e[4];let a;return e[5]!==t.onNewSession||e[6]!==l?(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:[i,l]})}),e[5]=t.onNewSession,e[6]=l,e[7]=a):a=e[7],a}const ai="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 _S(t){const e=Je.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,d=l===void 0?!0:l,u=a===void 0?!0:a,{t:f}=ft();if(!d&&!u)return null;let h;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==d||e[4]!==f?(h=d?s.jsxs(s.Fragment,{children:[s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:ai,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(O,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:ai,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(O,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:ai,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(O,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=f,e[5]=h):h=e[5];let x;e[6]!==o||e[7]!==u||e[8]!==f?(x=u?s.jsx(lt,{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:o,children:f("sessions.sidebar.footer.actions.update")}):null,e[6]=o,e[7]=u,e[8]=f,e[9]=x):x=e[9];let b;return e[10]!==h||e[11]!==x?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[h,x]}),e[10]=h,e[11]=x,e[12]=b):b=e[12],b}const FS=t=>{const e=Je.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:f,addSessionToFolder:h}=t,x=r===void 0?!0:r;let b,w;e[0]!==h||e[1]!==f||e[2]!==x||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(b=()=>{!x||o||!l||a||n.forEach(S=>{if(d.has(S.normalizedPath))return;const g=Uc(S.normalizedPath),m=i.archivedSessionsByProject.get(S.id)??[],p=u[g]??[],y=new Map(p.map(LS));m.forEach(v=>{const N=tm(v,S.normalizedPath),C=N.toLowerCase();let k=y.get(C);k||(k=f(g,N),y.set(C,k)),k.sessionIds.includes(v.id)||h(g,k.id,v.id)})})},w=[n,x,i,o,l,a,d,u,f,h],e[0]=h,e[1]=f,e[2]=x,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=b,e[11]=w):(b=e[10],w=e[11]),c.useEffect(b,w)};function LS(t){return[t.name.toLowerCase(),t]}function $S({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([f,h])=>f!==t&&h.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const zS=t=>{const e=Je.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:f,openNewSessionDraft:h,setSessionSwitcherOpen:x}=t;let b,w;if(e[0]!==n){w=new Map,b=new Map;const C=(k,A,D,P)=>{w.has(k)||w.set(k,new Map);const T=w.get(k);P.forEach($=>{const E=yt($.worktree?.path??$.session.directory??D??A);T.set($.session.id,{directory:E}),b.has(k)||b.set(k,{id:$.session.id,directory:E}),$.children.length>0&&C(k,A,E,$.children)})};n.forEach(k=>{k.groups.forEach(A=>{C(k.project.id,k.project.normalizedPath,A.directory,A.sessions)})}),e[0]=n,e[1]=b,e[2]=w}else b=e[1],w=e[2];let S;e[3]!==b||e[4]!==w?(S={metaByProject:w,firstSessionByProject:b},e[3]=b,e[4]=w,e[5]=S):S=e[5];const g=S,m=c.useRef(null);let p,y;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==f||e[12]!==u||e[13]!==h||e[14]!==n||e[15]!==g||e[16]!==o||e[17]!==x?(p=()=>{if(!r||u||Ce.getState().isNewWorktreeDialogOpen||m.current===r)return;const C=n.find(P=>P.project.id===r);if(!C)return;const k=g.metaByProject.get(r);if(l&&k&&k.has(l)){m.current=r,o(P=>{if(P.get(r)===l)return P;const T=new Map(P);return T.set(r,l),T});return}const A=$S({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:k,metaByProject:g.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:g.firstSessionByProject.get(r)?.id??null});if(A.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,A.kind==="open-draft"){f&&x(!1),h({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(A.kind!=="select-session")return;const D=k?.get(A.sessionId)?.directory??null;d(A.sessionId,D)},y=[r,i,l,a,d,u,f,h,n,g,x,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=f,e[12]=u,e[13]=h,e[14]=n,e[15]=g,e[16]=o,e[17]=x,e[18]=p,e[19]=y):(p=e[18],y=e[19]),c.useLayoutEffect(p,y);let v,N;e[20]!==r||e[21]!==l||e[22]!==g||e[23]!==o?(v=()=>{if(!r||!l)return;const C=g.metaByProject.get(r);!C||!C.has(l)||o(k=>{if(k.get(r)===l)return k;const A=new Map(k);return A.set(r,l),A})},N=[r,l,g,o],e[20]=r,e[21]=l,e[22]=g,e[23]=o,e[24]=v,e[25]=N):(v=e[24],N=e[25]),c.useEffect(v,N)},WS=t=>{const e=Je.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=Qe(VS),a=Qe(US);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let f;e[8]!==r?(f=()=>new Map(r),e[8]=r,e[9]=f):f=e[9];const[h,x]=c.useState(f);let b;e[10]!==h||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(b={...n,activeSessionByProject:h,setActiveSessionByProject:x,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=h,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=b):b=e[15],zS(b);let w,S;return e[16]!==h||e[17]!==i?(w=()=>{i(h)},S=[h,i],e[16]=h,e[17]=i,e[18]=w,e[19]=S):(w=e[18],S=e[19]),c.useEffect(w,S),null};function VS(t){return t.currentSessionId}function US(t){return!!t.newSessionDraft?.open}const HS=2880*60*1e3,KS=t=>!!t.parentID,GS=t=>!!t.time?.archived,qS=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},QS=(t,e,n=Date.now())=>{const r=n-HS;return t.filter(i=>GS(i)||KS(i)?!1:e.has(i.id)||qS(i)>=r)},YS=({sessions:t,getSessionLocation:e,getSessionNode:n,query:r})=>[{key:"active-now",items:t.flatMap(i=>{const o=typeof i.title=="string"?i.title.toLowerCase():"";if(r&&!o.includes(r))return[];const l=e(i.id);return[{node:n?.(i)??{session:i,children:[],worktree:null},projectId:l?.projectId??null,groupDirectory:l?.groupDirectory??i.directory??null,secondaryMeta:l?{projectLabel:l.projectLabel,branchLabel:l.branchLabel}:null}]})}],gu=t=>t.parentID??null,XS=(t,e)=>{const n=[],r=[];for(const i of t)if(!Wc(i)){if(Gc(i.directory)){if(e)continue;r.push(i);continue}n.push(i)}return{projectSessions:n,chatSessions:r}},JS=new Set,ZS=(t,e,n)=>{if(t.time?.archived)return!0;const r=yt(Is(t))?.toLowerCase();return!r||e.size===0?!n:e.has(r)},ev=(t,e)=>{const n=[...t],r=new Set(t.map(i=>i.id));for(const i of e)r.has(i.id)||(r.add(i.id),n.push(i));return n},tv=(t,e)=>{const n=[],r=new Set([e]),i=o=>{for(const l of t.get(o)??[])r.has(l.id)||(r.add(l.id),n.push(l.id),i(l.id))};return i(e),n},sv=({globalActiveSessions:t,liveSessions:e,knownDirectories:n,isVSCode:r,globalStructure:i})=>{Kc("sidebarStructureBuilds");const l=ev(t??[],e),a=XS(l,r),d=a.projectSessions.filter(S=>ZS(S,n,r)),u=[...d,...a.chatSessions],f=new Map(u.map(S=>[S.id,S])),h=new Set(d.map(S=>S.id)),x=i?.activeRootIds??[],b=new Set(x),w=[...x.flatMap(S=>{if(!h.has(S))return[];const g=f.get(S);return g?[g]:[]}),...d.filter(S=>!b.has(S.id)&&!gu(S))];return{chatSessionIds:new Set(a.chatSessions.map(S=>S.id)),projectSessions:d,rootSessions:w,sessionById:f,sessions:u,hierarchy:i?{rootIds:i.activeRootIds,childrenByParentId:i.activeChildrenByParentId}:void 0}},nv=(t,e,n)=>{const r=ra(t.sessions,e,n,t.hierarchy),i=new Map;for(const o of r){const l=gu(o);if(!l)continue;const a=i.get(l)??[];a.push(o),i.set(l,a)}return{chatSessions:r.filter(o=>t.chatSessionIds.has(o.id)),childrenMap:i,orderedSessions:r}},rv=t=>{const e=Je.c(33),{knownDirectories:n,isVSCode:r,isVisible:i}=t,o=xs(iv),l=xs(av),a=xs(lv),d=xs(cv),u=Hc(),f=dr(dv);let h;e[0]!==i?(h=T=>i?T.rankById:oa,e[0]=i,e[1]=h):h=e[1];const x=Vo(h);let b;e[2]!==o||e[3]!==l||e[4]!==r||e[5]!==n||e[6]!==u?(b=sv({globalActiveSessions:o,globalStructure:l,liveSessions:u,knownDirectories:n,isVSCode:r}),e[2]=o,e[3]=l,e[4]=r,e[5]=n,e[6]=u,e[7]=b):b=e[7];const w=b;let S;e[8]!==f||e[9]!==x||e[10]!==w?(S=nv(w,f,x),e[8]=f,e[9]=x,e[10]=w,e[11]=S):S=e[11];const g=S,{chatSessions:m,orderedSessions:p}=g,y=w.projectSessions;let v;e[12]!==a||e[13]!==w.sessions?(v=new Map([...w.sessions,...a].map(uv)),e[12]=a,e[13]=w.sessions,e[14]=v):v=e[14];const N=v;let C;if(e[15]!==a||e[16]!==g.childrenMap){C=new Map(g.childrenMap);for(const T of a){const $=T.parentID;if(!$)continue;const E=C.get($)??[];E.push(T),C.set($,E)}e[15]=a,e[16]=g.childrenMap,e[17]=C}else C=e[17];const k=C;let A;e[18]!==k||e[19]!==N?(A=(T,$)=>tv(k,T).filter(E=>$.includeArchived||!N.get(E)?.time?.archived),e[18]=k,e[19]=N,e[20]=A):A=e[20];const D=A;let P;return e[21]!==a||e[22]!==m||e[23]!==k||e[24]!==D||e[25]!==d||e[26]!==u||e[27]!==p||e[28]!==f||e[29]!==x||e[30]!==y||e[31]!==w.rootSessions?(P={archivedSessions:a,childrenMap:k,chatSessions:m,getDescendantIds:D,hasAuthoritativeGlobalSessions:d,liveSessions:u,orderedSessions:p,pinnedSessionIds:f,sessionOrderRanks:x,sessions:y,rootSessions:w.rootSessions},e[21]=a,e[22]=m,e[23]=k,e[24]=D,e[25]=d,e[26]=u,e[27]=p,e[28]=f,e[29]=x,e[30]=y,e[31]=w.rootSessions,e[32]=P):P=e[32],P},ov=t=>{const e=Je.c(9),{enabled:n,isVSCode:r,pinnedSessionIds:i,sessionOrderRanks:o,sessions:l}=t;let a;e[0]!==n||e[1]!==r?(a=f=>n&&!r?f.activeSessionIds:JS,e[0]=n,e[1]=r,e[2]=a):a=e[2];const d=Uo(a);let u;e:{if(!n||r){let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[3]=h):h=e[3],u=h;break e}Kc("recentCandidatesVisited",l.length);let f;e[4]!==d||e[5]!==i||e[6]!==o||e[7]!==l?(f=ra(QS(l,d),i,o),e[4]=d,e[5]=i,e[6]=o,e[7]=l,e[8]=f):f=e[8],u=f}return u};function iv(t){return t.activeSessions}function av(t){return t.structure}function lv(t){return t.archivedSessions}function cv(t){return t.status==="ready"}function dv(t){return t.ids}function uv(t){return[t.id,t]}const Bl={selected:0,"active-project":1,expanded:2,visible:3,background:4};function bu(t){const e=new Map,n=(r,i,o)=>{const l=yt(r??null);if(!l)return;const a=e.get(l);a&&Bl[a.priority]<=Bl[i]||e.set(l,{directory:l,priority:i,reason:o})};for(const r of t.knownDirectories??[])n(r,"background","known-project");n(t.activeProjectDirectory,"active-project","project-expanded");for(const r of t.projectSections??[]){const i=!t.collapsedProjects.has(r.project.id);let o="background";r.project.id===t.activeProjectId?o="active-project":i&&(o="expanded"),n(r.project.normalizedPath,o,i?"project-expanded":"known-project");for(const l of r.groups){if(!l.directory||l.isArchivedBucket||l.isMain)continue;const a=i&&!t.collapsedGroups.has(`${r.project.id}:${l.id}`);let d="background";a?d="expanded":i&&(d="visible"),n(l.directory,d,a?"worktree-expanded":"known-worktree")}}return n(t.currentDirectory,"selected","current-directory"),n(t.currentSessionDirectory,"selected","selected-session"),[...e.values()]}const fv=(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,_l=(t,e,n)=>{fv(t.get(e),n)&&t.set(e,n)},mv=t=>{const e=t;return yt(e.directory)??yt(e.project?.worktree)},hv=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)},pv=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const S=yt(w.normalizedPath);if(!S)continue;const g=l.get(S);(!g||w.id.localeCompare(g.id)<0)&&l.set(S,w),_l(o,S,{projectId:w.id,projectRoot:S,scopeDirectory:S,kind:"project"})}if(!r)for(const[w,S]of n){const g=yt(w),m=g?l.get(g):void 0;if(!(!m||!g))for(const p of S){const y=yt(p.path);y&&_l(o,y,{projectId:m.id,projectRoot:g,scopeDirectory:y,kind:"worktree"})}}const a=new Map,d=new Map,u=new Map,f=new Map,h=new Map,x=w=>{if(!w)return null;if(a.has(w))return a.get(w)??null;if(r){const p=o.get(w)??null;return a.set(w,p),p}const S=[];let g=w,m=null;for(;g;){if(a.has(g)){m=a.get(g)??null;break}if(S.push(g),m=o.get(g)??null,m)break;g=hv(g)}for(const p of S)a.set(p,m);return m},b=(w,S,g)=>{for(const m of w){const p=x(mv(m));if(!p)continue;d.set(m.id,p);const y=S.get(p.projectId);if(y?y.push(m):S.set(p.projectId,[m]),!g)continue;const v=g.get(p.scopeDirectory);v?v.add(m.id):g.set(p.scopeDirectory,new Set([m.id]))}};return b(t,u,h),b(i,f),{bySessionId:d,sessionsByProject:u,archivedSessionsByProject:f,sessionsByScope:h,directoryResolutions:a.size}},gv=t=>{const e=Je.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 i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},bv=[],xv=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,lastRepoStatus:a,buildGroupedSessions:d,hasSessionSearchQuery:u,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:h,buildGroupSearchText:x,foldersMap:b}=t,w=c.useRef(new Map),S=c.useMemo(()=>{const k=w.current,A=new Map;let D=0,P=0;const T=(E,U)=>E.length===U.length&&E.every((I,B)=>I===U[B]),$=e.map(E=>{const U=n(E.id),I=r(E.id),B=i.get(E.normalizedPath)??bv,R=o.has(E.id)?!!o.get(E.id):a,j=l.get(E.id)??null,M=k.get(E.id);if(M&&M.project===E&&T(M.activeSessions,U)&&T(M.archivedSessions,I)&&M.availableWorktrees===B&&M.rootBranch===j&&M.isRepo===R&&M.buildGroupedSessions===d)return D+=1,A.set(E.id,M),M.section;P+=1;const L=qc([...U,...I]),W=d(L,E.normalizedPath,B,j,R),te={project:E,groups:W};return A.set(E.id,{project:E,activeSessions:U,archivedSessions:I,availableWorktrees:B,rootBranch:j,isRepo:R,buildGroupedSessions:d,section:te}),te});return w.current=A,D>0&&sn("ui.sidebar.project_section.reused",D),P>0&&sn("ui.sidebar.project_section.rebuilt",P),$},[e,n,r,i,o,a,d,l]),g=c.useMemo(()=>S,[S]),m=c.useMemo(()=>{const k=new WeakMap;if(!u)return k;const A=D=>D.reduce((P,T)=>P+1+A(T.children),0);return g.forEach(D=>{D.groups.forEach(P=>{const T=h(P.sessions,f),$=A(T),E=jo([x(P)],f),U=yt(P.directory??null),B=(U?b[U]??[]:[]).filter(R=>jo([R.name],f)).length;k.set(P,{filteredNodes:T,matchedSessionCount:$,folderNameMatchCount:B,groupMatches:E,hasMatch:E||$>0||B>0})})}),k},[u,g,h,f,x,b]),p=c.useMemo(()=>u?g.map(k=>({...k,groups:k.groups.filter(A=>m.get(A)?.hasMatch===!0)})).filter(k=>k.groups.length>0):g,[u,g,m]),y=u?p:g,v=c.useRef(new WeakMap),N=c.useMemo(()=>{const k=v.current;return y.map(A=>{const D=k.get(A);if(D&&D.query===f)return D.section;const P=A.groups.filter(R=>!R.isArchivedBucket),T=A.groups.filter(R=>R.isArchivedBucket),$=P.flatMap(R=>u?m.get(R)?.filteredNodes??[]:R.sessions),E=P.map(R=>({scopeKey:R.folderScopeKey??yt(R.directory??null),directory:R.directory??null})).filter(R=>!!R.scopeKey),U=P.find(R=>R.isMain)??null,I={id:"flat",label:U?.label??"",branch:U?.branch??null,description:U?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:U?.directory??A.project.normalizedPath,folderScopeKey:U?.folderScopeKey??A.project.normalizedPath,folderScopes:E,sessions:$};if(u){const R=P.map(j=>m.get(j)).filter(j=>!!j);m.set(I,{filteredNodes:$,matchedSessionCount:R.reduce((j,M)=>j+M.matchedSessionCount,0),folderNameMatchCount:R.reduce((j,M)=>j+M.folderNameMatchCount,0),groupMatches:R.some(j=>j.groupMatches),hasMatch:R.some(j=>j.hasMatch)})}const B={project:A.project,groups:[I,...T]};return k.set(A,{query:f,section:B}),B})},[m,u,f,y]),C=c.useMemo(()=>u?y.reduce((k,A)=>k+A.groups.reduce((D,P)=>{const T=m.get(P);if(!T)return D;const $=T.folderNameMatchCount+(T.groupMatches?1:0);return D+T.matchedSessionCount+$},0),0):0,[u,y,m]);return{projectSections:S,visibleProjectSections:g,groupSearchDataByGroup:m,searchableProjectSections:p,sectionsForRender:y,flatSectionsForRender:N,searchMatchCount:C}},yv=180,Fl=600,wv=1,Sv=6,li=t=>`${t.directory}
|
|
912
|
-
${t.sessionId}`,vv=t=>t?.directory?.trim()||null,jv=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>bn(),[]),f=c.useCallback(()=>{d.current+=1,l.current=[],o.current.forEach(b=>window.clearTimeout(b)),o.current.clear()},[]),h=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<wv&&l.current.length>0;){const b=l.current.shift();if(!b)break;if(b.generation!==d.current||Qe.getState().currentSessionId===b.sessionId||Ma(b.sessionId,b.directory).renderable)continue;const S=li(b);a.current.add(S),i({directory:b.directory,sessionID:b.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(S),h()})}},[t,u,i]),x=c.useCallback(b=>{const w=b?.id,S=vv(b);if(!t||u||!w||!S||w===e)return;const g={sessionId:w,directory:S,generation:d.current},m=li(g);if(Ma(w,S).renderable||a.current.has(m)||l.current.some(v=>li(v)===m))return;const p=o.current.get(m);p!==void 0&&window.clearTimeout(p);const y=window.setTimeout(()=>{if(o.current.delete(m),g.generation!==d.current)return;const v=l.current;v.length>=Sv&&v.shift(),v.push(g),h()},yv);o.current.set(m,y)},[e,t,u,h]);c.useEffect(()=>{f()},[f,e,t,u]),c.useEffect(()=>{if(!t||u||!e||n.length===0)return;const b=window.setTimeout(()=>{const w=n.findIndex(S=>S.id===e);w<0||(x(n[w-1]),x(n[w+1]))},Fl);return()=>window.clearTimeout(b)},[e,t,u,x,n]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const b=window.setTimeout(()=>{const w=r.findIndex(S=>S.id===e);w<0||(x(r[w-1]),x(r[w+1]))},Fl);return()=>window.clearTimeout(b)},[e,t,u,r,x]),c.useEffect(()=>f,[f])},kv=t=>{const e=Je.c(3),n=Qe(Cv);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],jv(r),null};function Cv(t){return t.currentSessionId}const go=t=>{const e=Je.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u}=t,f=u===void 0?!1:u,{currentTheme:h}=qn(),x=i?ia[i]:null,b=o?aa[o]??null:null,w=d!==void 0,S=w?f?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let g;e[0]!==f||e[1]!==w||e[2]!==d?(g=w?s.jsx("span",{className:Pe("h-3.5 w-3.5 items-center justify-center text-muted-foreground",f?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(O,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=f,e[1]=w,e[2]=d,e[3]=g):g=e[3];let m;e[4]!==f||e[5]!==h||e[6]!==w||e[7]!==b||e[8]!==S||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==x?(m=l?s.jsx("span",{className:Pe("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",w&&f?"hidden":"inline-flex",S),style:a?{backgroundColor:a}:void 0,children:s.jsx(la,{project:{id:n,iconImage:l},options:{themeVariant:h.metadata.variant,iconColor:h.colors.surface.foreground},className:"h-full w-full object-contain",fallback:x?s.jsx(O,{name:x,className:"h-3.5 w-3.5",style:b?{color:b}:void 0}):s.jsx(O,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:b?{color:b}:void 0})})}):x?s.jsx(O,{name:x,className:Pe("h-3.5 w-3.5",S),style:b?{color:b}:void 0}):s.jsx(O,{name:"folder",className:Pe("h-3.5 w-3.5 text-muted-foreground/80",S),style:b?{color:b}:void 0}),e[4]=f,e[5]=h,e[6]=w,e[7]=b,e[8]=S,e[9]=n,e[10]=a,e[11]=l,e[12]=x,e[13]=m):m=e[13];let p;e[14]!==g||e[15]!==m?(p=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[g,m]}),e[14]=g,e[15]=m,e[16]=p):p=e[16];let y;e[17]!==r?(y=s.jsx("span",{className:"truncate text-[14px] font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=y):y=e[18];let v;return e[19]!==p||e[20]!==y?(v=s.jsxs(s.Fragment,{children:[p,y]}),e[19]=p,e[20]=y,e[21]=v):v=e[21],v},Nv=t=>{const e=Je.c(62),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectIcon:l,projectColor:a,projectIconImage:d,projectIconBackground:u,isCollapsed:f,isRepo:h,isDesktopShell:x,hideDirectoryControls:b,alwaysShowActions:w,onToggle:S,onNewSession:g,onNewWorktreeSession:m,onManageWorktrees:p,onRenameStart:y,onClose:v,sentinelRef:N,children:C,showCreateButtons:k,hideHeader:A,statusIndicator:D,openSidebarMenuKey:P,setOpenSidebarMenuKey:T,projectPickerOptions:$,onProjectSelect:E}=t,U=r===void 0?!1:r,I=k===void 0?!0:k,B=A===void 0?!1:A,R=D===void 0?null:D,{t:j}=ft(),M=us(Pv);let L;e[0]!==U||e[1]!==n?(L={id:n,disabled:U},e[0]=U,e[1]=n,e[2]=L):L=e[2];const{attributes:W,listeners:te,setNodeRef:Q,transform:me,transition:ce,isDragging:H}=Ho(L),ne=c.useRef(!1),ie=`project:${n}`,F=P===ie,[Z,G]=c.useState(!1),V=!!($&&E);let Y;e[3]!==ie||e[4]!==T?(Y=ve=>{ve&&G(!1),T(ve?ie:null)},e[3]=ie,e[4]=T,e[5]=Y):Y=e[5];const le=Y;let pe;e[6]!==b||e[7]!==h||e[8]!==v||e[9]!==p||e[10]!==g||e[11]!==y||e[12]!==I||e[13]!==j?(pe=ve=>s.jsxs(s.Fragment,{children:[I&&!h&&!b&&g&&s.jsxs(ve,{onClick:g,children:[s.jsx(O,{name:"add",className:"mr-1.5 h-4 w-4"}),j("sessions.sidebar.project.actions.newSession")]}),h&&!b&&p&&s.jsxs(ve,{onClick:p,children:[s.jsx(O,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),j("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(ve,{onClick:y,children:[s.jsx(O,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),j("sessions.sidebar.project.actions.edit")]}),s.jsxs(ve,{onClick:v,className:"text-destructive focus:text-destructive",children:[s.jsx(O,{name:"close",className:"mr-1.5 h-4 w-4"}),j("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=b,e[7]=h,e[8]=v,e[9]=p,e[10]=g,e[11]=y,e[12]=I,e[13]=j,e[14]=pe):pe=e[14];const be=pe,Se=Iv,De=Tv,fe=Ev;let xe;e[15]===Symbol.for("react.memo_cache_sentinel")?(xe=ve=>{(ve.button===2||ve.button===0&&ve.ctrlKey)&&(ne.current=!0)},e[15]=xe):xe=e[15];const ge=xe;let re;e[16]!==S?(re=ve=>{if(ve.currentTarget.blur(),ne.current){ne.current=!1;return}S()},e[16]=S,e[17]=re):re=e[17];const he=re;let Ne;e[18]!==me?(Ne=Ko.Transform.toString(me),e[18]=me,e[19]=Ne):Ne=e[19];let de;e[20]!==Ne||e[21]!==ce?(de={transform:Ne,transition:ce},e[20]=Ne,e[21]=ce,e[22]=de):de=e[22];const oe=H&&"opacity-30";let K;e[23]!==oe?(K=Pe("relative",oe),e[23]=oe,e[24]=K):K=e[24];let z;e[25]!==w||e[26]!==W||e[27]!==le||e[28]!==he||e[29]!==b||e[30]!==B||e[31]!==n||e[32]!==f||e[33]!==Z||e[34]!==x||e[35]!==F||e[36]!==V||e[37]!==h||e[38]!==te||e[39]!==g||e[40]!==m||e[41]!==E||e[42]!==a||e[43]!==o||e[44]!==l||e[45]!==u||e[46]!==d||e[47]!==i||e[48]!==$||e[49]!==be||e[50]!==N||e[51]!==I||e[52]!==R||e[53]!==M||e[54]!==j?(z=B?null:s.jsxs(s.Fragment,{children:[x&&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(bd,{open:Z,onOpenChange:G,children:[s.jsx(gd,{render:s.jsx("div",{className:Pe("-ml-2.5 -mr-2 text-left group/project select-none",M&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":M?"true":void 0,onContextMenu:ve=>{b||(ve.preventDefault(),G(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...W,children:[V?s.jsxs(Ks,{children:[s.jsx(Us,{asChild:!0,children:s.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":j("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(go,{id:n,projectLabel:i,projectIcon:l,projectColor:a,projectIconImage:d,projectIconBackground:u}),s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(Hs,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:$?.map(ve=>s.jsxs(Wt,{onClick:()=>E?.(ve.id),className:"flex items-center justify-between gap-3",title:ve.projectDescription,children:[s.jsx(go,{...ve}),ve.id===n?s.jsx(O,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},ve.id))})]}):s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:ge,onClick:he,...te,className:Pe("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]",h&&!b?w?"pr-20":"pr-7 group-hover/project:pr-20 group-focus-within/project:pr-20":w?"pr-14":"pr-7 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(go,{id:n,projectLabel:i,projectIcon:l,projectColor:a,projectIconImage:d,projectIconBackground:u,isCollapsed:f,alwaysShowActions:w}),R?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:R}):null]})}),s.jsx(pt,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Pe("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",I?"right-7":"right-0.5"),children:[I&&h&&!b&&m?s.jsxs(gt,{delayDuration:500,children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),m()},className:Pe("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",w?"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":j("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(O,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:j("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,b?null:s.jsxs(Ks,{open:F,onOpenChange:le,children:[s.jsx(Us,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe("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",F?"opacity-100 pointer-events-auto":w?"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":j("sessions.sidebar.project.actions.projectMenu"),onPointerDown:De,onMouseDown:fe,onClick:Se,children:s.jsx(O,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Hs,{align:"end",className:"min-w-[180px]",children:be(Wt)})]})]}),I&&g?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(gt,{delayDuration:500,children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),g()},className:Pe("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",w?"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":j(h?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(O,{name:"add",className:"h-4 w-4"})})}),s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:j(h?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(hd,{className:"min-w-[180px]",children:be(pd)})]})]}),e[25]=w,e[26]=W,e[27]=le,e[28]=he,e[29]=b,e[30]=B,e[31]=n,e[32]=f,e[33]=Z,e[34]=x,e[35]=F,e[36]=V,e[37]=h,e[38]=te,e[39]=g,e[40]=m,e[41]=E,e[42]=a,e[43]=o,e[44]=l,e[45]=u,e[46]=d,e[47]=i,e[48]=$,e[49]=be,e[50]=N,e[51]=I,e[52]=R,e[53]=M,e[54]=j,e[55]=z):z=e[55];let ae;return e[56]!==C||e[57]!==Q||e[58]!==de||e[59]!==K||e[60]!==z?(ae=s.jsxs("div",{ref:Q,style:de,className:K,children:[z,C]}),e[56]=C,e[57]=Q,e[58]=de,e[59]=K,e[60]=z,e[61]=ae):ae=e[61],ae},Av=t=>{const e=Je.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:f,transition:h,isDragging:x}=Ho(l);let b;e[3]!==a||e[4]!==u?(b={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=b):b=e[5];const w=b;let S;e[6]!==f?(S=Ko.Transform.toString(f),e[6]=f,e[7]=S):S=e[7];let g;e[8]!==S||e[9]!==h?(g={transform:S,transition:h},e[8]=S,e[9]=h,e[10]=g):g=e[10];const m=x&&"opacity-50";let p;e[11]!==m?(p=Pe("space-y-0.5 rounded-md",m),e[11]=m,e[12]=p):p=e[12];let y;e[13]!==i||e[14]!==w?(y=i(w),e[13]=i,e[14]=w,e[15]=y):y=e[15];let v;return e[16]!==d||e[17]!==g||e[18]!==p||e[19]!==y?(v=s.jsx("div",{ref:d,style:g,className:p,children:y}),e[16]=d,e[17]=g,e[18]=p,e[19]=y,e[20]=v):v=e[20],v},Dv=c.memo(Av);function Pv(t){return t.stickyZoneHeaders}function Iv(t){t.stopPropagation()}function Tv(t){t.stopPropagation()}function Ev(t){t.stopPropagation()}const Rv=(t,e)=>{const n=new Set,r=new Set,i=(o,l)=>{n.add(o.session.id),(!l||e)&&r.add(o.session.id),o.children.forEach(a=>i(a,!0))};return t.forEach(o=>i(o,!1)),{active:n,unread:r}},xu=t=>{const e=Je.c(9),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==r||e[1]!==n?(l=Rv(n,r),e[0]=r,e[1]=n,e[2]=l):l=e[2];const a=l;let d;e[3]!==o||e[4]!==a.active?(d=x=>{if(!o)return null;for(const b of a.active){const w=x.statusById.get(b)?.status.type;if(w==="busy"||w==="retry")return"active"}return null},e[3]=o,e[4]=a.active,e[5]=d):d=e[5];const u=Uo(d);let f;e[6]!==o||e[7]!==a.unread?(f=x=>{if(!o)return null;for(const b of a.unread)if((x.index.session.unseenCount[b]??0)>0)return"unread";return null},e[6]=o,e[7]=a.unread,e[8]=f):f=e[8];const h=ca(f);return u??h};function yu(t){const e=Je.c(6),{state:n,activeLabel:r,unreadLabel:i,className:o}=t,l=n==="active"?r:i,a=n==="active"?"bg-primary":"bg-[var(--status-info)]";let d;e[0]!==o||e[1]!==a?(d=Pe("h-1.5 w-1.5 shrink-0 rounded-full",a,o),e[0]=o,e[1]=a,e[2]=d):d=e[2];let u;return e[3]!==l||e[4]!==d?(u=s.jsx("span",{className:d,"aria-label":l,title:l}),e[3]=l,e[4]=d,e[5]=u):u=e[5],u}const Mv=t=>{const e=Je.c(11),{nodes:n,includeUnreadSubtasks:r}=t,{t:i}=ft();let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=xu(o);if(!l)return null;let a;e[3]!==i?(a=i("sessions.sidebar.session.status.active"),e[3]=i,e[4]=a):a=e[4];let d;e[5]!==i?(d=i("sessions.sidebar.session.status.unread"),e[5]=i,e[6]=d):d=e[6];let u;return e[7]!==l||e[8]!==a||e[9]!==d?(u=s.jsx(yu,{state:l,activeLabel:a,unreadLabel:d}),e[7]=l,e[8]=a,e[9]=d,e[10]=u):u=e[10],u},Ov=t=>{const e=Je.c(82),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:f,children:h,mobileVariant:x,alwaysShowActions:b,isRenaming:w,renameDraft:S,onRenameDraftChange:g,onRenameSave:m,onRenameCancel:p,droppableRef:y,isDropTarget:v,onNewSession:N,depth:C,hideActions:k,archivedBucket:A}=t,D=a===void 0?null:a,T=b===void 0?x===void 0?!1:x:b,$=w===void 0?!1:w,E=S===void 0?"":S,U=v===void 0?!1:v,I=k===void 0?!1:k,B=A===void 0?!1:A,{t:R}=ft(),[j,M]=c.useState(!1),[L,W]=c.useState(""),te=c.useRef(null),Q=$||j,me=$?E:L;let ce;e[0]!==n.name?(ce=()=>{W(n.name),M(!0)},e[0]=n.name,e[1]=ce):ce=e[1];const H=ce;let ne;e[2]!==me||e[3]!==n.name||e[4]!==$||e[5]!==u||e[6]!==m?(ne=()=>{const Ae=me.trim();Ae&&Ae!==n.name&&u(Ae),$&&m&&m(),M(!1),W("")},e[2]=me,e[3]=n.name,e[4]=$,e[5]=u,e[6]=m,e[7]=ne):ne=e[7];const ie=ne;let F;e[8]!==$||e[9]!==p?(F=()=>{$&&p&&p(),M(!1),W("")},e[8]=$,e[9]=p,e[10]=F):F=e[10];const Z=F;let G;e[11]!==$||e[12]!==g?(G=Ae=>{$&&g?g(Ae):W(Ae)},e[11]=$,e[12]=g,e[13]=G):G=e[13];const V=G;let Y,le;e[14]!==$?(Y=()=>{if(!$)return;const Ae=()=>{const Fe=te.current;Fe&&(Fe.focus(),Fe.select())},X=requestAnimationFrame(Ae),Oe=window.setTimeout(Ae,0);return()=>{cancelAnimationFrame(X),window.clearTimeout(Oe)}},le=[$],e[14]=$,e[15]=Y,e[16]=le):(Y=e[15],le=e[16]),c.useEffect(Y,le);const pe=l?"folder":"folder-open",be=U&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let Se;e[17]!==be?(Se=Pe("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",be),e[17]=be,e[18]=Se):Se=e[18];let De;e[19]!==d||e[20]!==Q?(De=Q?void 0:Ae=>{Ae.currentTarget.blur(),d()},e[19]=d,e[20]=Q,e[21]=De):De=e[21];const fe=Q?void 0:"button",xe=Q?void 0:0;let ge;e[22]!==d||e[23]!==Q?(ge=Q?void 0:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),d())},e[22]=d,e[23]=Q,e[24]=ge):ge=e[24];let re;e[25]!==n.name||e[26]!==l||e[27]!==R?(re=l?R("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):R("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=R,e[28]=re):re=e[28];const he=B?T?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":T?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let Ne;e[29]!==he?(Ne=Pe("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",he),e[29]=he,e[30]=Ne):Ne=e[30];const de=U?"text-primary":"text-muted-foreground";let oe;e[31]!==de?(oe=Pe("h-3.5 w-3.5 flex-shrink-0",de),e[31]=de,e[32]=oe):oe=e[32];let K;e[33]!==pe||e[34]!==oe?(K=s.jsx(O,{name:pe,className:oe}),e[33]=pe,e[34]=oe,e[35]=K):K=e[35];let z;e[36]!==D||e[37]!==r||e[38]!==me||e[39]!==n.name||e[40]!==Z||e[41]!==V||e[42]!==ie||e[43]!==l||e[44]!==U||e[45]!==Q||e[46]!==i||e[47]!==R?(z=Q?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:_v,onMouseDown:Fv,onSubmit:Ae=>{Ae.preventDefault(),ie()},children:[s.jsx("input",{ref:te,value:me,onChange:Ae=>V(Ae.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:R("sessions.sidebar.folderItem.namePlaceholder"),onClick:Lv,onPointerDown:$v,onMouseDown:zv,onKeyDown:Ae=>{if(Ae.key==="Escape"){Ae.stopPropagation(),Z();return}(Ae.key===" "||Ae.key==="Enter")&&Ae.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:Wv,onPointerDown:Vv,onMouseDown:Uv,children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),Z()},onPointerDown:Hv,onMouseDown:Kv,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:Pe("typography-ui-label font-semibold truncate",U?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(pt,{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:["• ",i.length]}),D?s.jsx(yu,{state:D,activeLabel:R("sessions.sidebar.session.status.active"),unreadLabel:R("sessions.sidebar.session.status.unread")}):null,l?s.jsx(O,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=D,e[37]=r,e[38]=me,e[39]=n.name,e[40]=Z,e[41]=V,e[42]=ie,e[43]=l,e[44]=U,e[45]=Q,e[46]=i,e[47]=R,e[48]=z):z=e[48];let ae;e[49]!==Ne||e[50]!==K||e[51]!==z?(ae=s.jsxs("div",{className:Ne,children:[K,z]}),e[49]=Ne,e[50]=K,e[51]=z,e[52]=ae):ae=e[52];let ve;e[53]!==T||e[54]!==B||e[55]!==n.name||e[56]!==H||e[57]!==I||e[58]!==f||e[59]!==N||e[60]!==Q||e[61]!==R?(ve=!Q&&(!I||B)?s.jsx("div",{className:Pe("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",T?"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:[!B&&N?s.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),N()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":R("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:R("sessions.sidebar.project.actions.newSession"),children:s.jsx(O,{name:"add",className:"h-3.5 w-3.5"})}):null,B?null:s.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),H()},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":R("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(O,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),f()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":B?R("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):R("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(O,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=T,e[54]=B,e[55]=n.name,e[56]=H,e[57]=I,e[58]=f,e[59]=N,e[60]=Q,e[61]=R,e[62]=ve):ve=e[62];let ye;e[63]!==y||e[64]!==Se||e[65]!==De||e[66]!==fe||e[67]!==xe||e[68]!==ge||e[69]!==re||e[70]!==ae||e[71]!==ve?(ye=s.jsxs("div",{ref:y,className:Se,onClick:De,role:fe,tabIndex:xe,onKeyDown:ge,"aria-label":re,children:[ae,ve]}),e[63]=y,e[64]=Se,e[65]=De,e[66]=fe,e[67]=xe,e[68]=ge,e[69]=re,e[70]=ae,e[71]=ve,e[72]=ye):ye=e[72];let We;e[73]!==h||e[74]!==l||e[75]!==i||e[76]!==o||e[77]!==R?(We=l?null:s.jsxs("div",{className:"pb-1",children:[o,i.length>0?h:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:R("sessions.sidebar.folderItem.emptyFolder")})]}),e[73]=h,e[74]=l,e[75]=i,e[76]=o,e[77]=R,e[78]=We):We=e[78];let Be;return e[79]!==ye||e[80]!==We?(Be=s.jsxs("div",{className:"oc-folder",children:[ye,We]}),e[79]=ye,e[80]=We,e[81]=Be):Be=e[81],Be},Bv=c.memo(Ov);function _v(t){return t.stopPropagation()}function Fv(t){return t.stopPropagation()}function Lv(t){return t.stopPropagation()}function $v(t){return t.stopPropagation()}function zv(t){return t.stopPropagation()}function Wv(t){return t.stopPropagation()}function Vv(t){return t.stopPropagation()}function Uv(t){return t.stopPropagation()}function Hv(t){return t.stopPropagation()}function Kv(t){return t.stopPropagation()}const Gv=t=>{const e=Je.c(15),{sessionId:n,sessionDirectory:r,sessionTitle:i,children:o}=t,l=`session-drag:${n}`;let a;e[0]!==r||e[1]!==n||e[2]!==i?(a={type:"session",sessionId:n,sessionDirectory:r,sessionTitle:i},e[0]=r,e[1]=n,e[2]=i,e[3]=a):a=e[3];let d;e[4]!==l||e[5]!==a?(d={id:l,data:a},e[4]=l,e[5]=a,e[6]=d):d=e[6];const{attributes:u,listeners:f,setNodeRef:h,isDragging:x}=op(d);let b;e[7]!==f?(b=m=>{m.stopPropagation(),f?.onPointerDown&&f.onPointerDown(m)},e[7]=f,e[8]=b):b=e[8];const w=b,S=x?"opacity-30":void 0;let g;return e[9]!==u||e[10]!==o||e[11]!==w||e[12]!==h||e[13]!==S?(g=s.jsx("div",{ref:h,...u,onPointerDown:w,className:S,children:o}),e[9]=u,e[10]=o,e[11]=w,e[12]=h,e[13]=S,e[14]=g):g=e[14],g},qv=t=>{const e=Je.c(11),{folderId:n,children:r}=t,i=`folder-drop:${n}`;let o;e[0]!==n?(o={type:"folder",folderId:n},e[0]=n,e[1]=o):o=e[1];let l;e[2]!==i||e[3]!==o?(l={id:i,data:o},e[2]=i,e[3]=o,e[4]=l):l=e[4];const{setNodeRef:a,isOver:d}=ip(l);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 f;return e[9]!==u?(f=s.jsx(s.Fragment,{children:u}),e[9]=u,e[10]=f):f=e[10],f},Qv=t=>{const e=Je.c(20),{scopeKey:n,hasFolders:r,onSessionDroppedOnFolder:i,children:o}=t;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={activationConstraint:{distance:8}},e[0]=l):l=e[0];const a=Er(An(Ci,l)),[d,u]=c.useState(null),[f,h]=c.useState("Session"),[x,b]=c.useState(null),[w,S]=c.useState(null);if(!n){let k;return e[1]!==o?(k=s.jsx(s.Fragment,{children:o}),e[1]=o,e[2]=k):k=e[2],k}let g;e[3]!==i?(g=k=>{u(null),b(null),S(null);const{active:A,over:D}=k;if(!D)return;const P=A.data.current,T=D.data.current;P?.type==="session"&&P.sessionId&&T?.type==="folder"&&T.folderId&&i(P.sessionId,T.folderId)},e[3]=i,e[4]=g):g=e[4];const m=g;let p,y;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=k=>{const A=k.active.data.current;if(A?.type==="session"&&A.sessionId){u(A.sessionId),h(A.sessionTitle??"Session");const D=k.active.rect.current.initial?.width,P=k.active.rect.current.initial?.height;b(typeof D=="number"?D:null),S(typeof P=="number"?P:null)}},y=()=>{u(null),b(null),S(null)},e[5]=p,e[6]=y):(p=e[5],y=e[6]);let v;e[7]!==w||e[8]!==d||e[9]!==f||e[10]!==x||e[11]!==r?(v=d&&r?s.jsxs("div",{style:{width:x?`${x}px`:"auto",height:w?`${w}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(O,{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:f})]}):null,e[7]=w,e[8]=d,e[9]=f,e[10]=x,e[11]=r,e[12]=v):v=e[12];let N;e[13]!==v?(N=s.jsx(Ni,{children:v}),e[13]=v,e[14]=N):N=e[14];let C;return e[15]!==o||e[16]!==m||e[17]!==a||e[18]!==N?(C=s.jsxs(Rr,{sensors:a,collisionDetection:Mr,onDragStart:p,onDragCancel:y,onDragEnd:m,children:[o,N]}),e[15]=o,e[16]=m,e[17]=a,e[18]=N,e[19]=C):C=e[19],C},$i=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},zn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(zn(n,e))return!0;return!1},Yv=(t,e,n)=>{const r=new Map,i=o=>{const l=Is(o.session)??yt(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},Xv=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},Jv=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of n.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},Zv=(t,e)=>{const n=new Map(t.map(d=>[d.id,d])),r=new Map,i=new Set;for(const d of t){if(d.parentId&&!n.has(d.parentId)){i.add(d.id);continue}if(d.parentId){const h=r.get(d.parentId)??[];h.push(d.id),r.set(d.parentId,h)}const u=new Set;let f=d.id;for(;f;){if(u.has(f)){i.add(d.id);break}u.add(f),f=n.get(f)?.parentId}}const o=new Set,l=new Set,a=d=>{if(o.has(d))return!0;if(l.has(d))return!1;const u=n.get(d);if(!u)return!1;l.add(d);let f=i.has(d);return!f&&e.archivedBucket&&u.nodeCount===0?f=(r.get(d)??[]).some(a):(!f&&!e.searchQuery&&(f=!0),!f&&(u.nodeCount>0||jo([u.name],e.searchQuery))&&(f=!0),f||(f=(r.get(d)??[]).some(a))),l.delete(d),f&&o.add(d),f};return t.forEach(d=>a(d.id)),new Set(t.filter(d=>o.has(d.id)).map(d=>d.id))},Ll=new WeakMap;let $l=1;const e0=t=>{const e=Ll.get(t);if(e!==void 0)return e;const n=$l;return $l+=1,Ll.set(t,n),n},Ro=t=>t.children.length===0?"":t.children.map(n=>{const r=e0(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Ro(n)}`}).join("|"),wu=(t,e,n,r,i,o)=>{const l=ks(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const f=d.session.directory??i,h=u.session.directory??o,x=Oa(l,f??"",d.session.id),b=Oa(l,h??"",u.session.id);return(x?n.has(x):!1)!==(b?r.has(b):!1)?!0:d.children.some((w,S)=>a(w,u.children[S]))};return a(t,e)},Lr=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o};let zi=!1;const Wi=new Set;let zl=!1;function t0(){for(const t of Wi)t()}function ja(t){zi!==t&&(zi=t,t0())}function s0(t){t.key==="Shift"&&ja(!0)}function n0(t){t.key==="Shift"&&ja(!1)}function r0(){ja(!1)}function o0(){zl||typeof window>"u"||(zl=!0,window.addEventListener("keydown",s0),window.addEventListener("keyup",n0),window.addEventListener("blur",r0))}function i0(t){return o0(),Wi.add(t),()=>{Wi.delete(t)}}function a0(){return zi}function l0(){return!1}function c0(){return ot.useSyncExternalStore(i0,a0,l0)}const d0=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,Su=/^g[1-9]\d*$/,wr=(t,e,n,r,i)=>{if(!d0.test(t)||e!==void 0&&!Su.test(e)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(i===void 0)return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!1};if(i==="fusion")return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(i))return null;const o=Number.parseInt(i,10);return!Number.isSafeInteger(o)||o<=0?null:{groupSlug:t,runGroup:e,providerID:n,modelID:r,index:o,fusion:!1}},bo=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 wr(n,void 0,e[1],e[2],void 0);if(e.length===4){const[,a,d,u]=e;return Su.test(a)?wr(n,a,d,u,void 0):wr(n,void 0,a,d,u)}const[,r,i,o,l]=e;return r===""?wr(n,void 0,i,o,l):wr(n,r,i,o,l)},u0=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("/")},f0=(t,e,n,r)=>{const i=[t];return r&&i.push(r),i.push(e,n,"fusion"),i.join("/")},vu=t=>{const e=Je.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:d}=ft(),u=Ht(m0),f=Ht(h0),h=Ht(p0);let x;e[0]!==u?(x=u(),e[0]=u,e[1]=x):x=e[1];const b=x;let w;e[2]!==b?(w=b.filter(g0),e[2]=b,e[3]=w):w=e[3];const S=w;let g,m;e[4]!==b.length||e[5]!==f?(g=()=>{b.length===0&&f()},m=[b.length,f],e[4]=b.length,e[5]=f,e[6]=g,e[7]=m):(g=e[6],m=e[7]),c.useEffect(g,m);let p,y;e[8]!==h||e[9]!==o||e[10]!==r||e[11]!==S||e[12]!==n?(p=()=>{if(o)return;const $=n.trim();if($.length>0&&S.some(I=>I.name===$))return;const E=typeof h=="string"&&h.trim().length>0?h.trim():null;if(E&&S.some(I=>I.name===E)){r(E);return}const U=S[0]?.name;U&&r(U)},y=[h,o,r,S,n],e[8]=h,e[9]=o,e[10]=r,e[11]=S,e[12]=n,e[13]=p,e[14]=y):(p=e[13],y=e[14]),c.useEffect(p,y);const v=n.trim().length>0?n:void 0;let N;e[15]!==i?(N=Pe("max-w-full",i),e[15]=i,e[16]=N):N=e[16];let C;e[17]!==d?(C=d("multirun.agentSelector.placeholder"),e[17]=d,e[18]=C):C=e[18];let k;e[19]!==C?(k=s.jsx(Cs,{placeholder:C}),e[19]=C,e[20]=k):k=e[20];let A;e[21]!==l||e[22]!==N||e[23]!==k?(A=s.jsx(Os,{id:l,size:"lg",className:N,children:k}),e[21]=l,e[22]=N,e[23]=k,e[24]=A):A=e[24];let D;e[25]!==S?(D=S.length>0&&s.jsx(wi,{children:S.map(b0)}),e[25]=S,e[26]=D):D=e[26];let P;e[27]!==a||e[28]!==D?(P=s.jsx(Bs,{fitContent:!0,portalToBody:a,children:D}),e[27]=a,e[28]=D,e[29]=P):P=e[29];let T;return e[30]!==o||e[31]!==r||e[32]!==v||e[33]!==A||e[34]!==P?(T=s.jsxs(Ms,{value:v,onValueChange:r,disabled:o,children:[A,P]}),e[30]=o,e[31]=r,e[32]=v,e[33]=A,e[34]=P,e[35]=T):T=e[35],T};function m0(t){return t.getVisibleAgents}function h0(t){return t.loadAgents}function p0(t){return t.currentAgentName}function g0(t){return Qc(t.mode)}function b0(t){return s.jsx(es,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const x0="h-7",Pr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,y0=t=>{const e=Je.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=Pe("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",x0),e[0]=d):d=e[0];let u;e[1]!==n.providerID?(u=s.jsx(Si,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=u):u=e[2];let f;e[3]!==a?(f=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=f):f=e[4];let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(O,{name:"close",className:"h-3.5 w-3.5"}),e[5]=h):h=e[5];let x;e[6]!==o?(x=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:h}),e[6]=o,e[7]=x):x=e[7];let b;return e[8]!==u||e[9]!==f||e[10]!==x?(b=s.jsxs("div",{className:d,children:[u,f,x]}),e[8]=u,e[9]=f,e[10]=x,e[11]=b):b=e[11],b},ju=t=>{const e=Je.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:d,maxModels:u,addButtonClassName:f,dropdownSide:h,dropdownClassName:x,containerClassName:b,triggerIcon:w}=t,S=d===void 0?!0:d,g=h===void 0?"top":h,{t:m}=ft(),p=Ht(w0),y=Ht(S0),v=Ce(v0),N=Ce(j0),{favoriteModelsList:C,recentModelsList:k}=sm(),A=Ce(k0),D=Ce(C0),[P,T]=c.useState(!1),[$,E]=c.useState(""),[U,I]=c.useState(null),B=c.useRef(null),R=c.useRef(null),j=u===1,M=u===void 0||n.length<u||j;let L;if(e[0]!==n){L=new Map;for(const je of n){const Ke=`${je.providerID}:${je.modelID}`;L.set(Ke,(L.get(Ke)||0)+1)}e[0]=n,e[1]=L}else L=e[1];const W=L;let te;e[2]!==n?(te=je=>n.filter(se=>se.providerID===je.providerID&&se.modelID===je.modelID).findIndex(se=>se.instanceId===je.instanceId)+1,e[2]=n,e[3]=te):te=e[3];const Q=te;let me,ce;e[4]!==g||e[5]!==P?(me=()=>{if(!P||!R.current)return;const je=R.current.getBoundingClientRect();if(g==="bottom"){const Ee=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-je.bottom-16-112;I(Math.max(160,Math.min(320,Ee)));return}let Ke=R.current.parentElement;for(;Ke&&!Ke.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const Ye=getComputedStyle(Ke);if(Ye.overflow==="auto"||Ye.overflow==="hidden"||Ye.overflowY==="auto"||Ye.overflowY==="hidden")break;Ke=Ke.parentElement}const se=Ke?Ke.getBoundingClientRect().top:0,Ie=je.top-se-16;I(Math.max(150,Math.min(300,Ie)))},ce=[g,P],e[4]=g,e[5]=P,e[6]=me,e[7]=ce):(me=e[6],ce=e[7]),c.useEffect(me,ce);let H,ne;e[8]!==M||e[9]!==P?(H=()=>{!M&&P&&(T(!1),E(""))},ne=[M,P],e[8]=M,e[9]=P,e[10]=H,e[11]=ne):(H=e[10],ne=e[11]),c.useEffect(H,ne);let ie,F;e[12]!==P?(ie=()=>{if(!P)return;const je=Ke=>{B.current&&!B.current.contains(Ke.target)&&(T(!1),E(""))};return document.addEventListener("mousedown",je),()=>document.removeEventListener("mousedown",je)},F=[P],e[12]=P,e[13]=ie,e[14]=F):(ie=e[13],F=e[14]),c.useEffect(ie,F);let Z;e[15]!==j||e[16]!==r||e[17]!==o||e[18]!==n.length?(Z=je=>{const Ke={providerID:je.providerID,modelID:je.modelID,displayName:je.model.name||je.modelID,instanceId:Pr()};j&&n.length>0&&o?o(0,Ke):r(Ke),j&&(T(!1),E(""))},e[15]=j,e[16]=r,e[17]=o,e[18]=n.length,e[19]=Z):Z=e[19];const G=Z;let V;e[20]!==m?(V=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=V):V=e[21];let Y;e[22]!==m?(Y=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=Y):Y=e[23];let le;e[24]!==m?(le=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=le):le=e[25];let pe;e[26]!==m?(pe=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=pe):pe=e[27];let be;e[28]!==m?(be=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=be):be=e[29];let Se;e[30]!==m?(Se=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=Se):Se=e[31];let De;e[32]!==m?(De=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=De):De=e[33];let fe;e[34]!==m?(fe=m("chat.modelControls.capabilities"),e[34]=m,e[35]=fe):fe=e[35];let xe;e[36]!==m?(xe=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=xe):xe=e[37];let ge;e[38]!==m?(ge=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=ge):ge=e[39];let re;e[40]!==m?(re=m("chat.modelControls.input"),e[40]=m,e[41]=re):re=e[41];let he;e[42]!==m?(he=m("chat.modelControls.output"),e[42]=m,e[43]=he):he=e[43];let Ne;e[44]!==m?(Ne=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=Ne):Ne=e[45];let de;e[46]!==V||e[47]!==Y||e[48]!==le||e[49]!==pe||e[50]!==be||e[51]!==Se||e[52]!==De||e[53]!==fe||e[54]!==xe||e[55]!==ge||e[56]!==re||e[57]!==he||e[58]!==Ne?(de={searchPlaceholder:V,noResults:Y,favorites:le,recent:pe,keyboardHint:be,favorite:Se,unfavorite:De,capabilities:fe,capabilityToolCalling:xe,capabilityReasoning:ge,input:re,output:he,costPerMillion:Ne},e[46]=V,e[47]=Y,e[48]=le,e[49]=pe,e[50]=be,e[51]=Se,e[52]=De,e[53]=fe,e[54]=xe,e[55]=ge,e[56]=re,e[57]=he,e[58]=Ne,e[59]=de):de=e[59];const oe=de;let K;e[60]!==b?(K=Pe("relative",b),e[60]=b,e[61]=K):K=e[61];const z=P?"":void 0;let ae;e[62]!==f?(ae=Pe(Yc({size:"default"}),"w-fit",f),e[62]=f,e[63]=ae):ae=e[63];const ve=!M;let ye;e[64]!==P?(ye=()=>{T(!P)},e[64]=P,e[65]=ye):ye=e[65];let We;e[66]!==w?(We=w??s.jsx(O,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=w,e[67]=We):We=e[67];let Be;e[68]!==a||e[69]!==m?(Be=a??m("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=m,e[70]=Be):Be=e[70];let Ae;e[71]!==z||e[72]!==ae||e[73]!==ve||e[74]!==ye||e[75]!==We||e[76]!==Be?(Ae=s.jsxs("button",{ref:R,type:"button","data-popup-open":z,className:ae,disabled:ve,onClick:ye,children:[We,Be]}),e[71]=z,e[72]=ae,e[73]=ve,e[74]=ye,e[75]=We,e[76]=Be,e[77]=Ae):Ae=e[77];let X;e[78]!==U||e[79]!==M||e[80]!==x||e[81]!==g||e[82]!==C||e[83]!==G||e[84]!==A||e[85]!==N||e[86]!==P||e[87]!==oe||e[88]!==W||e[89]!==y||e[90]!==D||e[91]!==p||e[92]!==k||e[93]!==$||e[94]!==v?(X=P?s.jsx("div",{className:Pe("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",g==="top"?"bottom-full mb-1":"top-full mt-1",x),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(nm,{providers:p,providerOrder:D,favoriteModels:C,recentModels:k,modelsMetadata:y,hiddenModels:A,searchQuery:$,onSearchQueryChange:E,onSelect:G,labels:oe,selectionCount:je=>W.get(`${je.providerID}:${je.modelID}`)||0,disabled:!M,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:U?`${U}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:P,isFavorite:je=>N(je.providerID,je.modelID),onToggleFavorite:je=>v(je.providerID,je.modelID),onEscape:()=>{T(!1),E("")}})}):null,e[78]=U,e[79]=M,e[80]=x,e[81]=g,e[82]=C,e[83]=G,e[84]=A,e[85]=N,e[86]=P,e[87]=oe,e[88]=W,e[89]=y,e[90]=D,e[91]=p,e[92]=k,e[93]=$,e[94]=v,e[95]=X):X=e[95];let Oe;e[96]!==K||e[97]!==Ae||e[98]!==X?(Oe=s.jsxs("div",{className:K,ref:B,children:[Ae,X]}),e[96]=K,e[97]=Ae,e[98]=X,e[99]=Oe):Oe=e[99];let Fe;e[100]!==Q||e[101]!==W||e[102]!==i||e[103]!==o||e[104]!==p||e[105]!==n||e[106]!==S||e[107]!==m?(Fe=S&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((je,Ke)=>{const se=`${je.providerID}:${je.modelID}`,Ie=W.get(se)||1,Ye=Q(je),Ee=p.find(_e=>_e.id===je.providerID)?.models?.find(_e=>_e.id===je.modelID),Ge=Ee?.variants?Object.keys(Ee.variants):[],ze=Ge.length>0,$e=je.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(y0,{model:je,instanceIndex:Ye,totalSameModel:Ie,onRemove:()=>i(Ke)}),ze&&s.jsxs(Ms,{value:$e,onValueChange:_e=>{if(!o)return;o(Ke,{...je,variant:_e==="__default__"?void 0:_e})},children:[s.jsxs(Os,{size:"sm",className:"gap-1.5",children:[s.jsx(O,{name:"brain-ai-3",className:Pe("h-3.5 w-3.5 flex-shrink-0",$e==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(Cs,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:_e=>_e==="__default__"?m("multirun.modelMultiSelect.variant.default"):_e})]}),s.jsxs(Bs,{fitContent:!0,children:[s.jsx(es,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),Ge.map(N0)]})]})]},je.instanceId)})}),e[100]=Q,e[101]=W,e[102]=i,e[103]=o,e[104]=p,e[105]=n,e[106]=S,e[107]=m,e[108]=Fe):Fe=e[108];let _;e[109]!==Oe||e[110]!==Fe?(_=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[Oe,Fe]}),e[109]=Oe,e[110]=Fe,e[111]=_):_=e[111];let ue;e[112]!==u||e[113]!==l||e[114]!==n.length||e[115]!==m?(ue=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:u!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:l,max:u}):m("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=u,e[113]=l,e[114]=n.length,e[115]=m,e[116]=ue):ue=e[116];let ke;return e[117]!==_||e[118]!==ue?(ke=s.jsxs("div",{className:"space-y-2",children:[_,ue]}),e[117]=_,e[118]=ue,e[119]=ke):ke=e[119],ke};function w0(t){return t.providers}function S0(t){return t.modelsMetadata}function v0(t){return t.toggleFavoriteModel}function j0(t){return t.isFavoriteModel}function k0(t){return t.hiddenModels}function C0(t){return t.providerOrder}function N0(t){return s.jsx(es,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const A0=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
|
|
913
|
-
|
|
914
|
-
--- RESULT ${n+1}: ${r} ---
|
|
915
|
-
${e.trim()}
|
|
916
|
-
--- END RESULT ${n+1} ---`},Wl=(t,e)=>Qe.getState().getWorktreeMetadata(t)?.projectDirectory??e,D0=async t=>{const e=t.directory??void 0,n=rm(t.session.id,e);if(n.length===0&&t.directory){const i=(await Es.withDirectory(t.directory,()=>Es.getSdkClient().session.messages({sessionID:t.session.id,directory:t.directory??void 0,limit:50}))).data??[];for(let o=i.length-1;o>=0;o-=1){const l=i[o];if(l.info?.role==="assistant")return _a(l.parts??[]).trim()}return""}for(let r=n.length-1;r>=0;r-=1){const i=n[r];if(i.role==="assistant")return _a(om(i.id,e)).trim()}return""};function P0({session:t,open:e,onOpenChange:n}){const{t:r}=ft(),i=Hc(),o=xs(j=>j.activeSessions),l=xs(j=>j.archivedSessions),a=Ht(j=>j.providers),d=Ht(j=>j.currentProviderId),u=Ht(j=>j.currentModelId),f=Ht(j=>j.currentAgentName),[h,x]=c.useState(d??""),[b,w]=c.useState(u??""),[S,g]=c.useState(()=>d&&u?[{providerID:d,modelID:u,instanceId:Pr()}]:[]),[m,p]=c.useState(""),[y,v]=c.useState(f??""),[N,C]=c.useState([]),[k,A]=c.useState(!1),D=c.useMemo(()=>bo(t.title),[t.title]),P=c.useMemo(()=>{const j=new Map;for(const M of i)j.set(M.id,M);for(const M of o)j.set(M.id,M);for(const M of l)j.set(M.id,M);return t.id&&j.set(t.id,t),Array.from(j.values())},[o,l,i,t]);c.useEffect(()=>{if(!e||!D)return;const j=Qe.getState().getDirectoryForSession(t.id),M=Wl(t.id,j),L=P.map(W=>{const te=bo(W.title);if(!te||te.groupSlug!==D.groupSlug||te.fusion||(te.runGroup??null)!==(D.runGroup??null))return null;const Q=Qe.getState().getDirectoryForSession(W.id)??Is(W),me=Wl(W.id,Q);return M&&me&&M!==me?null:{session:W,directory:Q,projectDirectory:me}}).filter(W=>W!==null).sort((W,te)=>(W.session.time?.created??0)-(te.session.time?.created??0));C(L)},[P,e,D,t.id]);const $=a.find(j=>j.id===h)?.models.find(j=>j.id===b),E=$?.variants?Object.keys($.variants):[],U=!!(D&&h&&b&&N.length>0&&!k),I=c.useCallback(j=>{g([j]),x(j.providerID),w(j.modelID),p("")},[]),B=S[0]?.displayName||S[0]?.modelID||r("multirun.fusion.model.placeholder"),R=async()=>{if(!(!D||!h||!b)){A(!0);try{const j=await Promise.all(N.map(ce=>D0(ce))),M=N.map((ce,H)=>({source:ce,text:j[H]??""})).filter(ce=>ce.text.trim().length>0);if(M.length===0){Re.error(r("multirun.fusion.toast.noOutputs"));return}const L=N[0]?.projectDirectory??N[0]?.directory??null,W=f0(D.groupSlug,h,b,D.runGroup),[te,Q]=await Promise.all([Ba("session.fusion.visible"),Ba("session.fusion.instructions")]),me=await Qe.getState().createSession(W,L,null);if(!me)throw new Error("Failed to create fusion session");Qe.getState().setCurrentSession(me.id,L),n(!1),await Es.sendMessage({id:me.id,providerID:h,modelID:b,variant:m||void 0,agent:y||void 0,text:te,additionalParts:[{text:Q,synthetic:!0},...M.map((ce,H)=>({text:A0(ce.source,ce.text,H),synthetic:!0})),{text:`
|
|
917
|
-
|
|
918
|
-
--- FUSION INPUTS END ---
|
|
919
|
-
Now write the final fused answer.`,synthetic:!0}],directory:L??Es.getDirectory()})}catch(j){console.error("[MultiRunFusion] Failed to start fusion",j),Re.error(r("multirun.fusion.toast.failed"))}finally{A(!1)}}};return s.jsx(Ns,{open:e,onOpenChange:n,children:s.jsxs(As,{className:"max-w-xl overflow-visible",children:[s.jsxs(Gs,{children:[s.jsx(Fs,{children:r("multirun.fusion.title")}),s.jsx(Ls,{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(ju,{selectedModels:S,onAdd:I,onUpdate:(j,M)=>I(M),onRemove:()=>{g([]),x(""),w(""),p("")},maxModels:1,addButtonLabel:B,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:h?s.jsx(Si,{providerId:h,className:"h-3.5 w-3.5 mr-1"}):void 0})}),E.length>0?s.jsxs(Ms,{value:m||"__default__",onValueChange:j=>p(j==="__default__"?"":j),children:[s.jsxs(Os,{size:"lg",className:"w-fit",children:[s.jsx(O,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Cs,{children:j=>j==="__default__"?r("multirun.modelMultiSelect.variant.default"):j})]}),s.jsxs(Bs,{fitContent:!0,portalToBody:!0,children:[s.jsx(es,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),E.map(j=>s.jsx(es,{value:j,children:j},j))]})]}):null,s.jsx(vu,{value:y,onChange:v,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(j=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(Si,{providerId:bo(j.session.title)?.providerID??"",className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:j.session.title||j.session.id}),s.jsx("button",{type:"button",onClick:()=>C(M=>M.filter(L=>L.session.id!==j.session.id)),className:"text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"h-4 w-4"})})]},j.session.id))})]}),s.jsxs(gn,{children:[s.jsx(lt,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(lt,{onClick:R,disabled:!U,children:r(k?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function I0(t){const e=Je.c(7);let n,r,i,o,l;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"}),i=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),o=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),l=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=i,e[3]=o,e[4]=l):(n=e[0],r=e[1],i=e[2],o=e[3],l=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,i,o,l]}),e[5]=t,e[6]=a):a=e[6],a}const T0=(t,e)=>yt(t.worktree?.path??null)===yt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,Vi=6,so=14,Vl=Vi+14+6,ci=new WeakMap,E0=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;ci.get(n)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,l=null;const a=()=>{o=!0,l!==null&&window.cancelAnimationFrame(l),l=null,ci.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},d=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(n.scrollTop+=u,sn("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(d)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),ci.set(n,a),l=window.requestAnimationFrame(d)},R0=c.memo(function(e){const n=Je.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:f}=e,h=c0(),x=h?i:r;let b;n[0]!==u||n[1]!==f||n[2]!==h?(b=C=>{if(h||C.shiftKey){f(C);return}u(C)},n[0]=u,n[1]=f,n[2]=h,n[3]=b):b=n[3];const w=b,S=h?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let g;n[4]!==o||n[5]!==S?(g=Pe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",S,o),n[4]=o,n[5]=S,n[6]=g):g=n[6];const m=h?"delete-bin":"archive";let p;n[7]!==l||n[8]!==m?(p=s.jsx(O,{name:m,className:l}),n[7]=l,n[8]=m,n[9]=p):p=n[9];let y;n[10]!==w||n[11]!==x||n[12]!==d||n[13]!==a||n[14]!==g||n[15]!==p?(y=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",className:g,"aria-label":x,onPointerDown:a,onMouseDown:d,onClick:w,onKeyDown:z0,children:p})}),n[10]=w,n[11]=x,n[12]=d,n[13]=a,n[14]=g,n[15]=p,n[16]=y):y=n[16];let v;n[17]!==x?(v=s.jsx(pt,{side:"left",sideOffset:8,children:x}),n[17]=x,n[18]=v):v=n[18];let N;return n[19]!==y||n[20]!==v?(N=s.jsxs(gt,{delayDuration:500,children:[y,v]}),n[19]=y,n[20]=v,n[21]=N):N=n[21],N});function M0(t){sn("ui.sidebar_session_node.render");const{t:e}=ft(),{node:n,depth:r=0,groupDirectory:i,projectId:o,archivedBucket:l=!1,pinnedSessionIds:a,expandedParents:d,hasSessionSearchQuery:u,normalizedSessionSearchQuery:f,notifyOnSubtasks:h,editingId:x,setEditingId:b,editTitle:w,setEditTitle:S,handleSaveEdit:g,handleCancelEdit:m,toggleParent:p,handleSessionSelect:y,handleSessionDoubleClick:v,handleShareSession:N,copiedSessionId:C,handleCopyShareUrl:k,handleCopySessionId:A,handleUnshareSession:D,openSidebarMenuKey:P,setOpenSidebarMenuKey:T,createFolderAndStartRename:$,handleDeleteSession:E,handleRestoreSession:U,mobileVariant:I,alwaysShowActions:B,secondaryMeta:R,renderContext:j="project",children:M}=t,L=dr(Te=>Te.toggle),W=fs(Te=>Te.getFoldersForScope),te=fs(Te=>Te.getSessionFolderId),Q=fs(Te=>Te.removeSessionFromFolder),me=fs(Te=>Te.addSessionToFolder),ce=Ce(Te=>Te.openContextPanelTab),H=c.useMemo(()=>bn(),[]),ne=c.useMemo(()=>_o(),[]),ie=c.useContext(im),F=H?"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",Z=H?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",G=H,V=!l&&!I,Y=H?V&&G?"group-hover:pr-18":V||G?"group-hover:pr-14":"group-hover:pr-8":V?"group-hover:pr-7 group-focus-within:pr-7":"group-hover:pr-3 group-focus-within:pr-3",le=V?"pr-13":"pr-7",pe=c.useRef(!1),[be,Se]=c.useState(!1),De=c.useRef(x);De.current=x;const fe=c.useRef(null),xe=c.useRef(!1),ge=c.useRef(g);ge.current=g;const[re,he]=c.useState(w),Ne=c.useRef(re);Ne.current=re;const de=c.useRef(null),oe=c.useRef(null),K=n.session,z=K,ae=Vt(c.useCallback(Te=>{if(R?.projectLabel||!o)return null;const q=Te.projects.find(Ue=>Ue.id===o);return q?q.label?.trim()||In(yt(q.path)??q.path,null)||q.path:null},[o,R?.projectLabel])),ve=R?.projectLabel??(ae?da(ae):null),ye=R?.branchLabel??n.worktree?.branch??null,We=c.useMemo(()=>{if(H)return null;const Te=n.worktree?.branch?.trim(),q=yt(n.worktree?.path??null);return Te&&q?$o(q,Te):null},[H,n.worktree]),Be=Xc(We),Ae=Be?`var(--pr-${Be.visualState})`:void 0,X=us(Te=>Te.sessionGroupingMode),Oe=!!ye&&(j==="recent"||X==="flat"),Fe=c.useMemo(()=>{if(!Be)return null;switch(Be.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return Be.canMerge===!0||Be.mergeableState==="clean"||Be.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return Be.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}},[Be,e]),_=Qe(Te=>Te.currentSessionId===K.id),ue=yt(K.directory??null)??yt(i??null),ke=o??ue??null,je=am(),Ke=ws(Te=>Te.enabled),se=ws(c.useCallback(Te=>Te.selectedIds.has(K.id),[K.id])),Ie=ws(Te=>Te.toggleSelected),Ye=ws(Te=>Te.setRange),ee=c.useCallback(Te=>{const q=[],Ue=it=>{it.children.forEach(Pt=>{q.push(Pt.session.id),Ue(Pt)})};return Ue(Te),q},[]),Ee=c.useCallback(Te=>{const q=[],Ue=it=>{it.children.forEach(Pt=>{q.push(Pt.session),Ue(Pt)})};return Ue(Te),q},[]),[Ge,ze]=c.useState(!1),[$e,_e]=c.useState(!0),Xe=`${j}:${l?"archived":"active"}:${K.id}`,ct=Jc(c.useCallback(Te=>!!Te.sessionMemoryState.get(lm(K.id))?.isZombie,[K.id])),At=Yi(K.id)?.type??"idle",Le=At==="busy"||At==="retry",_t=cm(K.id,Le),mt=_d(K.id),Rt=dm(K.id,ue??void 0,{bootstrap:!1}),Dt=um(z),xt=Dt?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(Fa[Dt.status]),"aria-label":e(Fa[Dt.status]),children:s.jsx(O,{name:"target",className:"h-3 w-3",style:{color:fm[Dt.status]}})}):null,we=z.title||e("sessions.sidebar.session.untitled"),dt=n.children.length>0,et=mm(a,ue,K.id),qe=Xe,kt=u?!0:d.has(qe),wt=c.useMemo(()=>Yv(n,kt,ue),[kt,n,ue]),jt=hm(wt),Ut=!!z.parentID,rt=kc(K.id)>0&&(!Ut||h),Ct=z.time?.updated||z.time?.created||Date.now(),It=Zc(Ct),Bt=pm(Ct),Tt=P===Xe,[ns,Lt]=c.useState(!1),zt=Tt||ns,qt=c.useMemo(()=>bo(z.title)!==null,[z.title]),[ms,Qt]=c.useState(!1),Me=c.useMemo(()=>ee(n).length,[ee,n]),Ve=c.useCallback(async Te=>{const q=[];let Ue=0;for(const it of Te)try{if(!ue)throw new Error("Session directory is required for export");const Pt=await je({directory:ue,sessionID:it.session.id});if(!Pt)throw new Error("Session runtime changed during export");const Kt=it.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Gt=it.session.agent,cs=await Ve(it.children);Ue+=cs.skipped,q.push({title:Kt,agent:Gt,records:Pt,children:cs.children})}catch{Ue+=ee(it).length+1}return{children:q,skipped:Ue}},[ee,je,ue,e]),Ze=c.useCallback(Te=>{Te<=0||Re.warning(Te===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Te}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Te}))},[e]),at=c.useCallback(async Te=>{if(!ue){Re.error(e("sessions.sidebar.session.export.nothingToExport"));return}const q=await je({directory:ue,sessionID:K.id}).catch(()=>null);if(!q){Re.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(q.length===0){Re.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Ue,it=0;if(Te&&n.children.length>0){const cs=await Ve(n.children);Ue=cs.children,it=cs.skipped}const Pt=Rd(q,z.title??null,Ue),Kt=Bd(z.title??null),Gt=await Od(Pt,Kt);if(Gt){Re.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Zp()),onClick:()=>{Jp(Gt).then(cs=>{cs||Re.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),Ze(it);return}Md(Pt,Kt),Re.success(e("sessions.sidebar.session.export.success")),Ze(it)},[Ve,je,n.children,z.title,K.id,ue,Ze,e]),ut=c.useCallback(async()=>{if(n.children.length>0){_e(!0),ze(!0);return}await at(!1)},[at,n.children.length]),St=c.useCallback(()=>{ue&&Nn("desktop_open_session_mini_chat_window",{sessionId:K.id,directory:ue,apiBaseUrl:Dn(),clientToken:Ir()}).catch(Te=>{console.warn("[session-sidebar] failed to open mini chat window",Te)})},[K.id,ue]);if(c.useEffect(()=>{if(x!==K.id)return;const Te=q=>{const it=(q.target instanceof HTMLElement?q.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(K.id)}"]`);oe.current&&!it&&ge.current(Ne.current)};return document.addEventListener("mousedown",Te),()=>document.removeEventListener("mousedown",Te)},[x,K.id]),c.useLayoutEffect(()=>{if(x!==K.id){de.current===K.id&&(de.current=null);return}de.current!==K.id&&(de.current=K.id,he(w))},[x,w,K.id]),x===K.id)return s.jsx("div",{style:{paddingLeft:Vl+r*so},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:oe,"data-session-rename-form":K.id,className:"flex w-full items-center gap-2",onSubmit:Te=>{Te.preventDefault(),g(re)},children:[s.jsx("input",{value:re,onChange:Te=>he(Te.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:Te=>{if(Te.stopPropagation(),Te.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(O,{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(O,{name:"close",className:"size-4"})})]})})},K.id);const nt=Rt.length,Ft=jt===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:jt}),Xt=!mt&&!Le&&rt&&!_,os=Le||Xt,Ss=e(Le?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),qs=s.jsx("span",{className:Pe("h-1.5 w-1.5 rounded-full",Le?"bg-primary":"bg-[var(--status-info)]"),"aria-label":Ss,title:Ss}),gs=(Le||Xt)&&_t,is=!B&&dt&&(mt||os||et),Mt=et&&!mt&&!os,Et=s.jsx(O,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),Jt=mt||os||Mt?s.jsx("span",{style:{left:Vi+r*so},className:Pe("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",is?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:mt?s.jsx(O,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e("sessions.sidebar.session.status.movingToWorktree")}):os?qs:Mt?Et:null}):null,hs=dt&&!B&&(mt||os||et),as=dt?s.jsx("span",{role:"button",tabIndex:0,onClick:Te=>{Te.stopPropagation(),Te.currentTarget.blur(),p(qe)},onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),Te.stopPropagation(),p(qe))},style:{minWidth:14,minHeight:14,left:Vi+r*so},className:Pe("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",hs?"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(kt?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:kt?s.jsx(O,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(O,{name:"arrow-right-s",className:"h-3 w-3"})}):null,ps=ct?s.jsx(O,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,ys=Te=>{Te&&Lt(!1),T(Te?Xe:null)},rs=Te=>{if(!Te&&fe.current){const{id:q,title:Ue}=fe.current;fe.current=null,b(q),S(Ue)}},yn=Te=>{Lt(Te)},En=Te=>{Te.preventDefault(),Te.stopPropagation(),T(Tt?null:Xe)},Rn=Te=>{Te.preventDefault(),Te.stopPropagation()},Mn=Te=>{Te.preventDefault(),Te.stopPropagation()},J=Te=>{Te.preventDefault(),Te.stopPropagation()},He=Te=>{Te.preventDefault(),Te.stopPropagation()},tt=Te=>{Te.preventDefault(),Te.stopPropagation(),T(null),E(K,{archivedBucket:l})},bt=Te=>{Te.preventDefault(),Te.stopPropagation(),T(null),E(K,{archivedBucket:l,hardDelete:!0,skipConfirm:!0})},$t=Te=>{Te.preventDefault(),Te.stopPropagation()},Ot=Te=>{Te.preventDefault(),Te.stopPropagation()},vt=Te=>{Te.preventDefault(),Te.stopPropagation(),ie?.vscode?.executeCommand("openchamber.openSessionInEditor",K.id,we)},ls=Te=>{if(pe.current){pe.current=!1;return}if(Ke){if(Te?.preventDefault(),Te?.stopPropagation(),Te?.shiftKey){const Ue=Array.from(document.querySelectorAll("[data-session-row]")).map(Kt=>Kt.getAttribute("data-session-row")).filter(Kt=>Kt!==null&&Kt.length>0),it=ws.getState().anchorId,Pt=new Map;Pt.set(K.id,ee(n)),Ye(it,K.id,Ue,ke,Pt);return}Ie(K.id,ke,ee(n));return}Te?.currentTarget&&E0(Te.currentTarget),y(K.id,ue)},bs=Te=>{Te.defaultPrevented||(Te.target instanceof HTMLElement?Te.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||ls(Te)},ts=Te=>{(Te.button===2||Te.button===0&&Te.ctrlKey&&!Ke)&&(pe.current=!0)},Qs=Te=>{I&&Te.pointerType==="touch"&&Se(!0)},Ys=Te=>{I&&Te.pointerType==="touch"&&Se(!1)},On=({Item:Te,Separator:q,Sub:Ue,SubTrigger:it,SubContent:Pt})=>s.jsxs(s.Fragment,{children:[s.jsxs(Te,{onClick:()=>{fe.current={id:K.id,title:we}},className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsxs(Te,{onClick:()=>A(K.id),className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Te,{onClick:()=>ue&&L({directory:ue,sessionId:K.id}),className:"[&>svg]:mr-1",children:[et?s.jsx(O,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(O,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(et?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),z.share?s.jsxs(s.Fragment,{children:[s.jsx(Te,{onClick:()=>{z.share?.url&&k(z.share.url,K.id)},className:"[&>svg]:mr-1",children:C===K.id?s.jsxs(s.Fragment,{children:[s.jsx(O,{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(O,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyLink")]})}),s.jsxs(Te,{onClick:()=>D(K.id),className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"link-unlink-m",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Te,{onClick:()=>N(z),className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"share-2",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.share")]}),s.jsxs(Te,{onClick:()=>{ut()},className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),!Ut&&!l&&!H&&!Gc(ue)?s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Te,{disabled:!ue||Le||mt,onClick:()=>{!ue||Le||mt||Fd({root:z,descendants:Ee(n),sourceDirectory:ue,successMessage:e("sessions.sidebar.session.moveToWorktree.success"),failureMessage:e("sessions.sidebar.session.moveToWorktree.failed")})},className:"w-full [&>svg]:mr-1",children:[s.jsx(O,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(pt,{side:"right",className:"max-w-72",children:e(mt?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Le?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,qt?s.jsxs(Te,{onClick:()=>Qt(!0),className:"[&>svg]:mr-1",children:[s.jsx(I0,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,ue&&!l?(()=>{const Kt=[],Gt=Ds=>{const js=yt(Ds??null);js&&!Kt.includes(js)&&Kt.push(js)};if(o&&!H){const Ds=Vt.getState().projects.find(Xn=>Xn.id===o),js=yt(Ds?.path??null);Gt(js),js&&(Qe.getState().availableWorktreesByProject.get(js)??[]).forEach(Xn=>Gt(Xn.path))}Gt(ed(ue)),Gt(ue);const cs=Kt.flatMap(Ds=>W(Ds).map(js=>({scope:Ds,folder:js}))),vs=cs.find(({scope:Ds,folder:js})=>te(Ds,K.id)===js.id)??null,hr=Kt[0]??ue;return s.jsxs(s.Fragment,{children:[s.jsx(q,{}),s.jsxs(Ue,{children:[s.jsxs(it,{className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(Pt,{className:"min-w-[180px]",children:[cs.length===0?s.jsx(Te,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):cs.map(({scope:Ds,folder:js})=>{const Xn=vs?.folder.id===js.id;return s.jsxs(Te,{onClick:()=>{if(Xn){Q(Ds,K.id);return}vs&&vs.scope!==Ds&&Q(vs.scope,K.id),me(Ds,js.id,K.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:js.name}),Xn?s.jsx(O,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},js.id)}),s.jsx(q,{}),s.jsxs(Te,{onClick:()=>{const Ds=$(hr);Ds&&(xe.current=!0,vs&&vs.scope!==hr&&Q(vs.scope,K.id),me(hr,Ds.id,K.id))},children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),vs?s.jsxs(Te,{onClick:()=>{Q(vs.scope,K.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(O,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,H?null:s.jsxs(Te,{disabled:!ue,onClick:()=>{ue&&ce(ue,{mode:"chat",dedupeKey:`session:${K.id}`,label:we,sessionTitleFallback:we})},className:"[&>svg]:mr-1",children:[s.jsx(O,{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")})]}),ne?s.jsxs(Te,{disabled:!ue,onClick:St,className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(q,{}),l?null:s.jsxs(Te,{className:"[&>svg]:mr-1",onClick:()=>E(K,{archivedBucket:l}),children:[s.jsx(O,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),l?s.jsxs(Te,{className:"[&>svg]:mr-1",onClick:()=>U(K),children:[s.jsx(O,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Te,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>E(K,{archivedBucket:l,hardDelete:!0}),children:[s.jsx(O,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),wn=s.jsx(Hs,{align:"end",className:"min-w-[180px]",finalFocus:()=>xe.current?(xe.current=!1,!1):!De.current,children:On({Item:Wt,Separator:Rs,Sub:bm,SubTrigger:xm,SubContent:ym})}),Qo=s.jsx(Di,{children:s.jsx(Pi,{className:"app-region-no-drag z-50",children:s.jsx(Ii,{"data-slot":"dropdown-menu-content",finalFocus:()=>xe.current?(xe.current=!1,!1):!De.current,style:{color:"var(--surface-elevated-foreground)"},className:Pe(gi,"min-w-[180px]"),children:On({Item:({className:Te,...q})=>s.jsx(kd,{className:Pe(Nc,Te),...q}),Separator:({className:Te,...q})=>s.jsx(jd,{className:Pe(Cc,Te),...q}),Sub:dp,SubTrigger:({className:Te,children:q,...Ue})=>s.jsxs(up,{className:Pe(gm,Te),...Ue,children:[q,s.jsx(O,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Te,children:q,...Ue})=>s.jsx(Di,{children:s.jsx(Pi,{className:"app-region-no-drag z-50",children:s.jsx(Ii,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Pe(gi,Te),...Ue,children:q})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(Gv,{sessionId:K.id,sessionDirectory:ue??null,sessionTitle:we,children:s.jsxs(Nd,{open:ns,onOpenChange:yn,onOpenChangeComplete:rs,children:[s.jsxs(Cd,{render:s.jsx("div",{"data-session-row":K.id,"data-session-scope":ke??"","data-session-archived":l?"1":"0",onClick:bs,style:{paddingLeft:Vl+r*so},className:Pe("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-1.5",_&&!se&&"bg-primary/10",se&&"bg-interactive-selection")}),children:[Jt,as,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onPointerDown:Qs,onPointerUp:Ys,onPointerCancel:Ys,onMouseDown:ts,onClick:Te=>ls(Te),onDoubleClick:Te=>{Te.stopPropagation(),v(K.id,we)},className:Pe("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]",be&&"bg-interactive-hover/70",B?H?Y:le:Y),children:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:Pe("block min-w-0 flex-1 truncate typography-ui-label font-normal",_?"text-primary":rt?"text-foreground":"text-foreground/80"),children:co(we,f)}),B?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 text-[0.72rem] text-muted-foreground/75",children:gs?s.jsx(Qa,{sessionId:K.id,running:Le}):s.jsxs(s.Fragment,{children:[xt,Oe?s.jsx(O,{name:"git-branch",className:Pe("h-3 w-3",!Ae&&"text-muted-foreground/60"),style:Ae?{color:Ae}:void 0}):null,Bt]})}):gs||xt||Oe?s.jsx("div",{className:"relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",children:s.jsx("span",{className:Pe("inline-flex items-center gap-1 whitespace-nowrap text-right transition-opacity duration-150",zt?"opacity-0":Z),children:gs?s.jsx(Qa,{sessionId:K.id,running:Le,className:"text-[0.72rem]"}):s.jsxs(s.Fragment,{children:[xt,Oe?s.jsx(O,{name:"git-branch",className:Pe("h-3 w-3",!Ae&&"text-muted-foreground/60"),style:Ae?{color:Ae}:void 0}):null]})})}):null,nt>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(O,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:nt})]}):null,jt>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:Ft,"aria-label":Ft,children:[s.jsx(O,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:jt})]}):null]})})}),H?null:s.jsx(pt,{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:we}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:It,children:Bt})]}),ve?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(O,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:ve})]}):null,ye?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:Ae?{color:Ae}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:ye})]}):null,Be&&Fe?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(O,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:Ae?{color:Ae}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:Ae?{color:Ae}:void 0,children:["#",Be.number," · ",Fe]})]}):null]})})]})}),ps&&!I?s.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 z-10",children:ps}):null,s.jsxs("div",{className:Pe("absolute right-0 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",zt||B&&!H?"opacity-100":Pe("opacity-0",F)),children:[V?s.jsx(R0,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:B?"h-6 w-6":"h-4 w-4",iconSizeClass:B?"h-3.5 w-3.5":"h-2.5 w-2.5",onPointerDown:J,onMouseDown:He,onArchive:tt,onDelete:bt}):null,G?s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe("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",B?"h-6 w-6":"h-4 w-4"),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:$t,onMouseDown:Ot,onClick:vt,onKeyDown:Te=>Te.stopPropagation(),children:s.jsx(O,{name:"external-link",className:Pe(B?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),s.jsx(pt,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(Ks,{open:Tt,onOpenChange:ys,onOpenChangeComplete:rs,children:[s.jsx(Us,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe("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",B?"h-6 w-6 opacity-100":zt?"h-4 w-4 opacity-100":Pe("h-4 w-4 opacity-0",F)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Rn,onMouseDown:Mn,onClick:En,onKeyDown:Te=>Te.stopPropagation(),children:s.jsx(O,{name:"more-2",className:Pe(B?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),wn]})]})]}),Qo]})}),dt&&kt?M:null,s.jsx(Ns,{open:Ge,onOpenChange:ze,children:s.jsxs(As,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Gs,{children:[s.jsx(Fs,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Ls,{children:Me===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:Me}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:Me})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:$e,onChange:Te=>_e(Te.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(gn,{children:[s.jsx(lt,{type:"button",onClick:()=>ze(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(lt,{type:"button",onClick:()=>{ze(!1),at($e)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),qt?s.jsx(P0,{session:z,open:ms,onOpenChange:Qt}):null]},K.id)}const Ul=t=>yt(t.session.directory??null),O0=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),B0=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},Hl=t=>t.menuOpenSessionId??B0(t),no=(t,e,n)=>e?n.has(t.node.session.id)?!0:zn(t.node,e):!1,Ui=(t,e,n,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(n.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let l=0;l<t.children.length;l+=1)if(Ui(t.children[l],e.children[l],n,r,i))return!0;return!1},_0=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return Ui(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||Ui(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},F0=(t,e)=>t.id===e.id&&t.title===e.title&&t.directory===e.directory&&t.parentID===e.parentID&&t.share?.url===e.share?.url&&t.time?.created===e.time?.created&&t.time?.updated===e.time?.updated&&t.time?.archived===e.time?.archived,L0=(t,e)=>{if(t.node.session.id!==e.node.session.id||!F0(t.node.session,e.node.session)||!T0(t.node,e.node)||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||Ul(t.node)!==Ul(e.node)||!O0(t.secondaryMeta,e.secondaryMeta)||t.pinnedSessionIds!==e.pinnedSessionIds&&wu(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory)||t.expandedParents!==e.expandedParents&&_0(t,e)||t.editingId!==e.editingId&&(no(t,t.editingId,t.subtreeContainsEditing)||no(e,e.editingId,e.subtreeContainsEditing))||t.editTitle!==e.editTitle&&(no(t,t.editingId,t.subtreeContainsEditing)||no(e,e.editingId,e.subtreeContainsEditing))||t.copiedSessionId!==e.copiedSessionId&&(zn(t.node,t.copiedSessionId)||zn(e.node,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=Hl(t),r=Hl(e);if(zn(t.node,n)||zn(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.handleShareSession===e.handleShareSession&&t.handleCopyShareUrl===e.handleCopyShareUrl&&t.handleCopySessionId===e.handleCopySessionId&&t.handleUnshareSession===e.handleUnshareSession&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.children===e.children},$0=c.memo(M0,L0);function z0(t){return t.stopPropagation()}const W0=t=>{const{t:e}=ft(),n=c.useRef(null),r=c.useRef(t.editingId),i=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);r.current=t.editingId,i.current=t.editTitle,o.current=t.deleteSessionConfirm;const l=Ce(H=>H.setSessionSwitcherOpen),a=Qe(H=>H.setCurrentSession),d=Qe(H=>H.updateSessionTitle),u=Qe(H=>H.shareSession),f=Qe(H=>H.unshareSession),h=Qe(H=>H.deleteSession),x=Qe(H=>H.deleteSessions),b=Qe(H=>H.archiveSession),w=Qe(H=>H.archiveSessions),S=Qe(H=>H.unarchiveSession),{mobileVariant:g,allowReselect:m,onSessionSelected:p,isSessionSearchOpen:y,sessionSearchQuery:v,setSessionSearchQuery:N,setIsSessionSearchOpen:C,descendantIds:k,showDeletionDialog:A,setDeleteSessionConfirm:D,setEditingId:P,setEditTitle:T,setCopiedSessionId:$}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const E=c.useCallback((H,ne)=>{pi("navigation.session_select"),Ce.getState().closeMainSurfaces();const ie=()=>{!y&&v.length===0||(N(""),C(!1))};if(g&&l(!1),H===Qe.getState().currentSessionId){m&&p?.(H),ie();return}pi("navigation.session_state_set"),a(H,ne??null),p?.(H),ie()},[m,y,g,p,v,a,C,N,l]),U=c.useCallback((H,ne)=>{P(H),T(ne)},[T,P]),I=c.useCallback(async H=>{const ne=r.current;if(!ne)return;const ie=(H??i.current).trim();ie&&await d(ne,ie),P(null),T("")},[T,P,d]),B=c.useCallback(()=>{P(null),T("")},[T,P]),R=c.useCallback(async(H,ne)=>{try{return(await an(H)).ok?($(ne),n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{$(null),n.current=null},2e3),!0):!1}catch{return!1}},[$]),j=c.useCallback(async H=>{const ne=await u(H.id);if(!ne?.share?.url){Re.error(e("sessions.sidebar.session.share.error"));return}const ie=await R(ne.share.url,H.id);Re[ie?"success":"warning"](e("sessions.sidebar.session.share.successTitle"),{description:e(ie?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")})},[R,u,e]),M=c.useCallback((H,ne)=>{R(H,ne).then(ie=>{ie||Re.error(e("sessions.sidebar.session.share.copyUrlError"))})},[R,e]),L=c.useCallback(H=>{an(H).then(ne=>{if(ne.ok){Re.success(e("sessions.sidebar.session.copyId.success"));return}Re.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Re.error(e("sessions.sidebar.session.copyId.error")))},[e]),W=c.useCallback(async H=>{await f(H)?Re.success(e("sessions.sidebar.session.unshare.success")):Re.error(e("sessions.sidebar.session.unshare.error"))},[e,f]),te=c.useCallback(async(H,ne,ie)=>{const F=ne?.archivedBucket===!0||ne?.hardDelete===!0,Z=ie?.descendantIds??k;if(Z.length===0){(F?await h(H.id):await b(H.id))?Re.success(e(F?"sessions.sidebar.session.delete.success":"sessions.sidebar.session.archive.success")):Re.error(e(F?"sessions.sidebar.session.delete.error":"sessions.sidebar.session.archive.error"));return}const G=[H.id,...Z];if(F){const{deletedIds:le,failedIds:pe}=await x(G);if(pe.length===0){const be=le.length;Re.success(be===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:be}):e("sessions.sidebar.bulkActions.deletedPlural",{count:be}))}else Re.error(e("sessions.sidebar.session.delete.error"));return}const{archivedIds:V,failedIds:Y}=await w(G);V.length>0&&Re.success(V.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:V.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:V.length})),Y.length>0&&Re.error(Y.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Y.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:Y.length}))},[b,w,h,x,k,e]),Q=c.useCallback((H,ne)=>{const ie=ne?.archivedBucket===!0||ne?.hardDelete===!0,F=[...k];if(!A||ne?.skipConfirm===!0){te(H,ne,{descendantIds:F});return}D({session:H,descendantCount:F.length,descendantIds:F,archivedBucket:ie})},[k,te,D,A]),me=c.useCallback(async()=>{const H=o.current;if(!H)return;const{session:ne,archivedBucket:ie,descendantIds:F}=H;D(null),await te(ne,{archivedBucket:ie},{descendantIds:F})},[te,D]),ce=c.useCallback(async H=>{await S(H.id)?Re.success(e("sessions.sidebar.session.restore.success")):Re.error(e("sessions.sidebar.session.restore.error"))},[e,S]);return c.useMemo(()=>({handleSessionSelect:E,handleSessionDoubleClick:U,handleSaveEdit:I,handleCancelEdit:B,handleShareSession:j,handleCopyShareUrl:M,handleCopySessionId:L,handleUnshareSession:W,handleDeleteSession:Q,handleRestoreSession:ce,confirmDeleteSession:me}),[B,L,M,Q,ce,I,U,E,j,W,me])};function V0(t){const e=Je.c(71),{t:n}=ft(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let d,u,f,h,x,b,w,S,g,m;if(e[0]!==i||e[1]!==n||e[2]!==r){const M=n("sessions.sidebar.session.untitled");h=Ns,g=!!r,e[13]!==i?(m=W=>{W||i(null)},e[13]=i,e[14]=m):m=e[14],f=As,w=!1,S="max-w-sm gap-5",u=Gs;let L;e[15]!==n||e[16]!==r?.archivedBucket?(L=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=L):L=e[17],e[18]!==L?(b=s.jsx(Fs,{children:L}),e[18]=L,e[19]=b):b=e[19],d=Ls,x=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||M,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||M,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||M,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||M,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||M}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||M}),e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=u,e[5]=f,e[6]=h,e[7]=x,e[8]=b,e[9]=w,e[10]=S,e[11]=g,e[12]=m}else d=e[3],u=e[4],f=e[5],h=e[6],x=e[7],b=e[8],w=e[9],S=e[10],g=e[11],m=e[12];let p;e[20]!==d||e[21]!==x?(p=s.jsx(d,{children:x}),e[20]=d,e[21]=x,e[22]=p):p=e[22];let y;e[23]!==u||e[24]!==b||e[25]!==p?(y=s.jsxs(u,{children:[b,p]}),e[23]=u,e[24]=b,e[25]=p,e[26]=y):y=e[26];let v;e[27]!==l||e[28]!==o?(v=()=>l(!o),e[27]=l,e[28]=o,e[29]=v):v=e[29];const N=!o;let C;e[30]!==o?(C=o?s.jsx(O,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(O,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=C):C=e[31];let k;e[32]!==n?(k=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=k):k=e[33];let A;e[34]!==C||e[35]!==k||e[36]!==v||e[37]!==N?(A=s.jsxs("button",{type:"button",onClick:v,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":N,children:[C,k]}),e[34]=C,e[35]=k,e[36]=v,e[37]=N,e[38]=A):A=e[38];let D;e[39]!==i?(D=()=>i(null),e[39]=i,e[40]=D):D=e[40];let P;e[41]!==n?(P=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=P):P=e[42];let T;e[43]!==D||e[44]!==P?(T=s.jsx("button",{type:"button",onClick:D,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[43]=D,e[44]=P,e[45]=T):T=e[45];let $;e[46]!==a?($=()=>{a()},e[46]=a,e[47]=$):$=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 U;e[51]!==$||e[52]!==E?(U=s.jsx("button",{type:"button",onClick:$,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:E}),e[51]=$,e[52]=E,e[53]=U):U=e[53];let I;e[54]!==T||e[55]!==U?(I=s.jsxs("div",{className:"flex items-center gap-2",children:[T,U]}),e[54]=T,e[55]=U,e[56]=I):I=e[56];let B;e[57]!==A||e[58]!==I?(B=s.jsxs(gn,{className:"w-full sm:items-center sm:justify-between",children:[A,I]}),e[57]=A,e[58]=I,e[59]=B):B=e[59];let R;e[60]!==f||e[61]!==w||e[62]!==B||e[63]!==S||e[64]!==y?(R=s.jsxs(f,{showCloseButton:w,className:S,children:[y,B]}),e[60]=f,e[61]=w,e[62]=B,e[63]=S,e[64]=y,e[65]=R):R=e[65];let j;return e[66]!==h||e[67]!==R||e[68]!==g||e[69]!==m?(j=s.jsx(h,{open:g,onOpenChange:m,children:R}),e[66]=h,e[67]=R,e[68]=g,e[69]=m,e[70]=j):j=e[70],j}function U0(t){const e=Je.c(57),{t:n}=ft(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let f;e[0]!==d||e[1]!==u||e[2]!==n?(f=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]=f):f=e[3];const h=f;let x;e[4]!==d||e[5]!==u||e[6]!==n?(x=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]=x):x=e[7];const b=x,w=!!r;let S;e[8]!==i?(S=j=>{j||i(null)},e[8]=i,e[9]=S):S=e[9];let g;e[10]!==h?(g=s.jsx(Fs,{children:h}),e[10]=h,e[11]=g):g=e[11];let m;e[12]!==b?(m=s.jsx(Ls,{children:b}),e[12]=b,e[13]=m):m=e[13];let p;e[14]!==g||e[15]!==m?(p=s.jsxs(Gs,{children:[g,m]}),e[14]=g,e[15]=m,e[16]=p):p=e[16];let y;e[17]!==l||e[18]!==o?(y=()=>l(!o),e[17]=l,e[18]=o,e[19]=y):y=e[19];const v=!o;let N;e[20]!==o?(N=o?s.jsx(O,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(O,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=N):N=e[21];let C;e[22]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=C):C=e[23];let k;e[24]!==C||e[25]!==y||e[26]!==v||e[27]!==N?(k=s.jsxs("button",{type:"button",onClick:y,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":v,children:[N,C]}),e[24]=C,e[25]=y,e[26]=v,e[27]=N,e[28]=k):k=e[28];let A;e[29]!==i?(A=()=>i(null),e[29]=i,e[30]=A):A=e[30];let D;e[31]!==n?(D=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=D):D=e[32];let P;e[33]!==A||e[34]!==D?(P=s.jsx("button",{type:"button",onClick:A,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:D}),e[33]=A,e[34]=D,e[35]=P):P=e[35];let T;e[36]!==a?(T=()=>{a()},e[36]=a,e[37]=T):T=e[37];let $;e[38]!==d||e[39]!==n?($=n(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=n,e[40]=$):$=e[40];let E;e[41]!==T||e[42]!==$?(E=s.jsx("button",{type:"button",onClick:T,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:$}),e[41]=T,e[42]=$,e[43]=E):E=e[43];let U;e[44]!==P||e[45]!==E?(U=s.jsxs("div",{className:"flex items-center gap-2",children:[P,E]}),e[44]=P,e[45]=E,e[46]=U):U=e[46];let I;e[47]!==k||e[48]!==U?(I=s.jsxs(gn,{className:"w-full sm:items-center sm:justify-between",children:[k,U]}),e[47]=k,e[48]=U,e[49]=I):I=e[49];let B;e[50]!==I||e[51]!==p?(B=s.jsxs(As,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,I]}),e[50]=I,e[51]=p,e[52]=B):B=e[52];let R;return e[53]!==w||e[54]!==B||e[55]!==S?(R=s.jsx(Ns,{open:w,onOpenChange:S,children:B}),e[53]=w,e[54]=B,e[55]=S,e[56]=R):R=e[56],R}function H0(t){const e=Je.c(36),{t:n}=ft(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=N=>{N||i(null)},e[0]=i,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(Fs,{children:d}),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==n||e[7]!==r?(f=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=f):f=e[8];let h;e[9]!==f?(h=s.jsx(Ls,{children:f}),e[9]=f,e[10]=h):h=e[10];let x;e[11]!==u||e[12]!==h?(x=s.jsxs(Gs,{children:[u,h]}),e[11]=u,e[12]=h,e[13]=x):x=e[13];let b;e[14]!==i?(b=()=>i(null),e[14]=i,e[15]=b):b=e[15];let w;e[16]!==n?(w=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=w):w=e[17];let S;e[18]!==b||e[19]!==w?(S=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:w}),e[18]=b,e[19]=w,e[20]=S):S=e[20];let g;e[21]!==n?(g=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=g):g=e[22];let m;e[23]!==o||e[24]!==g?(m=s.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:g}),e[23]=o,e[24]=g,e[25]=m):m=e[25];let p;e[26]!==m||e[27]!==S?(p=s.jsxs(gn,{children:[S,m]}),e[26]=m,e[27]=S,e[28]=p):p=e[28];let y;e[29]!==p||e[30]!==x?(y=s.jsxs(As,{showCloseButton:!1,className:"max-w-sm gap-5",children:[x,p]}),e[29]=p,e[30]=x,e[31]=y):y=e[31];let v;return e[32]!==l||e[33]!==a||e[34]!==y?(v=s.jsx(Ns,{open:l,onOpenChange:a,children:y}),e[32]=l,e[33]=a,e[34]=y,e[35]=v):v=e[35],v}const K0=new Set;function Mo(t){const e=Je.c(136),{node:n,depth:r,groupDirectory:i,projectId:o,archivedBucket:l,secondaryMeta:a,renderContext:d,renderExtras:u,pinnedSessionIds:f,expandedParents:h,hasSessionSearchQuery:x,normalizedSessionSearchQuery:b,notifyOnSubtasks:w,editingId:S,setEditingId:g,editTitle:m,setEditTitle:p,toggleParent:y,openSidebarMenuKey:v,setOpenSidebarMenuKey:N,allowReselect:C,onSessionSelected:k,isSessionSearchOpen:A,sessionSearchQuery:D,setSessionSearchQuery:P,setIsSessionSearchOpen:T,deleteSessionConfirm:$,setDeleteSessionConfirm:E,startFolderRename:U,copiedSessionId:I,setCopiedSessionId:B,mobileVariant:R,alwaysShowActions:j}=t,M=r===void 0?0:r,L=l===void 0?!1:l,W=d===void 0?"project":d,te=fs(Y0),Q=fs(Q0),me=Ce(q0),ce=Ce(G0);let H;if(e[0]!==n){H=[];const Be=Ae=>Ae.children.forEach(X=>{H.push(X.session.id),Be(X)});Be(n),e[0]=n,e[1]=H}else H=e[1];const ne=H;let ie;e[2]!==te||e[3]!==U||e[4]!==Q?(ie=(Be,Ae)=>{if(!Be)return null;Ae&&fs.getState().collapsedFolderIds.has(Ae)&&Q(Ae);const X=te(Be,"New folder",Ae);return U(Be,X),X},e[2]=te,e[3]=U,e[4]=Q,e[5]=ie):ie=e[5];const F=ie;let Z;e[6]!==C||e[7]!==I||e[8]!==$||e[9]!==ne||e[10]!==m||e[11]!==S||e[12]!==A||e[13]!==R||e[14]!==k||e[15]!==D||e[16]!==B||e[17]!==E||e[18]!==p||e[19]!==g||e[20]!==T||e[21]!==P||e[22]!==me?(Z={mobileVariant:R,allowReselect:C,onSessionSelected:k,isSessionSearchOpen:A,sessionSearchQuery:D,setSessionSearchQuery:P,setIsSessionSearchOpen:T,descendantIds:ne,showDeletionDialog:me,setDeleteSessionConfirm:E,deleteSessionConfirm:$,editingId:S,setEditingId:g,editTitle:m,setEditTitle:p,copiedSessionId:I,setCopiedSessionId:B},e[6]=C,e[7]=I,e[8]=$,e[9]=ne,e[10]=m,e[11]=S,e[12]=A,e[13]=R,e[14]=k,e[15]=D,e[16]=B,e[17]=E,e[18]=p,e[19]=g,e[20]=T,e[21]=P,e[22]=me,e[23]=Z):Z=e[23];const G=W0(Z),V=u?.childRenderExtrasFor,Y=n.session.directory??i;let le;e[24]!==L||e[25]!==o||e[26]!==W||e[27]!==Y?(le={groupDirectory:Y,projectId:o,archivedBucket:L,renderContext:W},e[24]=L,e[25]=o,e[26]=W,e[27]=Y,e[28]=le):le=e[28];const pe=le,be=G.handleSaveEdit,Se=G.handleCancelEdit,De=G.handleSessionSelect,fe=G.handleSessionDoubleClick,xe=G.handleShareSession,ge=G.handleCopyShareUrl,re=G.handleCopySessionId,he=G.handleUnshareSession,Ne=G.handleDeleteSession,de=G.handleRestoreSession,oe=u?.subtreeContainsEditing??K0,K=u?.menuOpenSessionId??null,z=u?.nodeStructureKey??"";let ae;if(e[29]!==C||e[30]!==j||e[31]!==pe||e[32]!==V||e[33]!==I||e[34]!==$||e[35]!==M||e[36]!==m||e[37]!==S||e[38]!==h||e[39]!==x||e[40]!==A||e[41]!==R||e[42]!==n.children||e[43]!==b||e[44]!==w||e[45]!==k||e[46]!==v||e[47]!==f||e[48]!==D||e[49]!==B||e[50]!==E||e[51]!==p||e[52]!==g||e[53]!==T||e[54]!==N||e[55]!==P||e[56]!==U||e[57]!==y){let Be;e[59]!==C||e[60]!==j||e[61]!==pe||e[62]!==V||e[63]!==I||e[64]!==$||e[65]!==M||e[66]!==m||e[67]!==S||e[68]!==h||e[69]!==x||e[70]!==A||e[71]!==R||e[72]!==b||e[73]!==w||e[74]!==k||e[75]!==v||e[76]!==f||e[77]!==D||e[78]!==B||e[79]!==E||e[80]!==p||e[81]!==g||e[82]!==T||e[83]!==N||e[84]!==P||e[85]!==U||e[86]!==y?(Be=Ae=>s.jsx(Mo,{node:Ae,pinnedSessionIds:f,expandedParents:h,hasSessionSearchQuery:x,normalizedSessionSearchQuery:b,notifyOnSubtasks:w,editingId:S,setEditingId:g,editTitle:m,copiedSessionId:I,setEditTitle:p,toggleParent:y,openSidebarMenuKey:v,setOpenSidebarMenuKey:N,allowReselect:C,onSessionSelected:k,isSessionSearchOpen:A,sessionSearchQuery:D,setSessionSearchQuery:P,setIsSessionSearchOpen:T,deleteSessionConfirm:$,setDeleteSessionConfirm:E,startFolderRename:U,setCopiedSessionId:B,mobileVariant:R,alwaysShowActions:j,depth:M+1,...pe,renderExtras:V?.(Ae)},Ae.session.id),e[59]=C,e[60]=j,e[61]=pe,e[62]=V,e[63]=I,e[64]=$,e[65]=M,e[66]=m,e[67]=S,e[68]=h,e[69]=x,e[70]=A,e[71]=R,e[72]=b,e[73]=w,e[74]=k,e[75]=v,e[76]=f,e[77]=D,e[78]=B,e[79]=E,e[80]=p,e[81]=g,e[82]=T,e[83]=N,e[84]=P,e[85]=U,e[86]=y,e[87]=Be):Be=e[87],ae=n.children.map(Be),e[29]=C,e[30]=j,e[31]=pe,e[32]=V,e[33]=I,e[34]=$,e[35]=M,e[36]=m,e[37]=S,e[38]=h,e[39]=x,e[40]=A,e[41]=R,e[42]=n.children,e[43]=b,e[44]=w,e[45]=k,e[46]=v,e[47]=f,e[48]=D,e[49]=B,e[50]=E,e[51]=p,e[52]=g,e[53]=T,e[54]=N,e[55]=P,e[56]=U,e[57]=y,e[58]=ae}else ae=e[58];let ve;e[88]!==j||e[89]!==L||e[90]!==I||e[91]!==F||e[92]!==M||e[93]!==m||e[94]!==S||e[95]!==h||e[96]!==i||e[97]!==x||e[98]!==R||e[99]!==n||e[100]!==b||e[101]!==w||e[102]!==v||e[103]!==f||e[104]!==o||e[105]!==W||e[106]!==a||e[107]!==G.handleCancelEdit||e[108]!==G.handleCopySessionId||e[109]!==G.handleCopyShareUrl||e[110]!==G.handleDeleteSession||e[111]!==G.handleRestoreSession||e[112]!==G.handleSaveEdit||e[113]!==G.handleSessionDoubleClick||e[114]!==G.handleSessionSelect||e[115]!==G.handleShareSession||e[116]!==G.handleUnshareSession||e[117]!==p||e[118]!==g||e[119]!==N||e[120]!==oe||e[121]!==K||e[122]!==z||e[123]!==ae||e[124]!==y?(ve=s.jsx($0,{expandedParents:h,hasSessionSearchQuery:x,normalizedSessionSearchQuery:b,notifyOnSubtasks:w,editingId:S,setEditingId:g,editTitle:m,setEditTitle:p,handleSaveEdit:be,handleCancelEdit:Se,toggleParent:y,handleSessionSelect:De,handleSessionDoubleClick:fe,handleShareSession:xe,copiedSessionId:I,handleCopyShareUrl:ge,handleCopySessionId:re,handleUnshareSession:he,openSidebarMenuKey:v,setOpenSidebarMenuKey:N,createFolderAndStartRename:F,handleDeleteSession:Ne,handleRestoreSession:de,mobileVariant:R,alwaysShowActions:j,pinnedSessionIds:f,node:n,depth:M,groupDirectory:i,projectId:o,archivedBucket:L,secondaryMeta:a,renderContext:W,subtreeContainsEditing:oe,menuOpenSessionId:K,nodeStructureKey:z,children:ae}),e[88]=j,e[89]=L,e[90]=I,e[91]=F,e[92]=M,e[93]=m,e[94]=S,e[95]=h,e[96]=i,e[97]=x,e[98]=R,e[99]=n,e[100]=b,e[101]=w,e[102]=v,e[103]=f,e[104]=o,e[105]=W,e[106]=a,e[107]=G.handleCancelEdit,e[108]=G.handleCopySessionId,e[109]=G.handleCopyShareUrl,e[110]=G.handleDeleteSession,e[111]=G.handleRestoreSession,e[112]=G.handleSaveEdit,e[113]=G.handleSessionDoubleClick,e[114]=G.handleSessionSelect,e[115]=G.handleShareSession,e[116]=G.handleUnshareSession,e[117]=p,e[118]=g,e[119]=N,e[120]=oe,e[121]=K,e[122]=z,e[123]=ae,e[124]=y,e[125]=ve):ve=e[125];let ye;e[126]!==$||e[127]!==n.session.id||e[128]!==G.confirmDeleteSession||e[129]!==E||e[130]!==ce||e[131]!==me?(ye=$?.session.id===n.session.id?s.jsx(V0,{value:$,setValue:E,showDeletionDialog:me,setShowDeletionDialog:ce,onConfirm:G.confirmDeleteSession}):null,e[126]=$,e[127]=n.session.id,e[128]=G.confirmDeleteSession,e[129]=E,e[130]=ce,e[131]=me,e[132]=ye):ye=e[132];let We;return e[133]!==ve||e[134]!==ye?(We=s.jsxs(s.Fragment,{children:[ve,ye]}),e[133]=ve,e[134]=ye,e[135]=We):We=e[135],We}function G0(t){return t.setShowDeletionDialog}function q0(t){return t.showDeletionDialog}function Q0(t){return t.toggleFolderCollapse}function Y0(t){return t.createFolder}const X0=50,J0=28,Kl=[],Z0=t=>{const e=Je.c(6),{nodes:n,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=xu(o);let a;return e[3]!==i||e[4]!==l?(a=i(l),e[3]=i,e[4]=l,e[5]=a):a=e[5],a},Sr=(t,e)=>e?t.sessions.some(n=>zn(n,e)):!1,e2=(t,e,n)=>t.sessions.some(r=>wu(r,r,e,n,t.directory,t.directory)),t2=(t,e,n)=>{const r=i=>{const o=i.session.id;return e.get(o)!==n.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},s2=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const l=`project:${r}:${o.session.id}`;return e.has(l)!==n.has(l)?!0:o.children.some(i)};return t.sessions.some(i)},n2=(t,e)=>{if(t.group!==e.group||t.groupKey!==e.groupKey||t.projectId!==e.projectId||t.hideGroupLabel!==e.hideGroupLabel||t.compactBodyPadding!==e.compactBodyPadding||t.groupSearchDataByGroup!==e.groupSearchDataByGroup||t.visibleSessionCount!==e.visibleSessionCount||t.sessionBatchSize!==e.sessionBatchSize||t.collapsedGroups!==e.collapsedGroups&&t.collapsedGroups.has(t.groupKey)!==e.collapsedGroups.has(e.groupKey)||t.pinnedSessionIds!==e.pinnedSessionIds&&e2(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&t2(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&s2(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Sr(e.group,t.editingId)||Sr(e.group,e.editingId))||t.editTitle!==e.editTitle&&Sr(e.group,e.editingId)||t.copiedSessionId!==e.copiedSessionId&&(Sr(e.group,t.copiedSessionId)||Sr(e.group,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=Lr(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Lr(e.group.sessions,e.openSidebarMenuKey,"project",n);if(r||i)return!1}if(t.folderRename!==e.folderRename){const n=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??yt(e.group.directory??null)];if(n.includes(t.folderRename?.scopeKey??null)||n.includes(e.folderRename?.scopeKey??null))return!1}return t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.scrollContainerRef===e.scrollContainerRef&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.isSessionSearchOpen===e.isSessionSearchOpen&&t.sessionSearchQuery===e.sessionSearchQuery&&t.setSessionSearchQuery===e.setSessionSearchQuery&&t.setIsSessionSearchOpen===e.setIsSessionSearchOpen&&t.deleteSessionConfirm===e.deleteSessionConfirm&&t.setDeleteSessionConfirm===e.setDeleteSessionConfirm&&t.startFolderRename===e.startFolderRename&&t.setCopiedSessionId===e.setCopiedSessionId&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename};function r2(t){const{t:e}=ft(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,groupSearchDataByGroup:d,visibleSessionCount:u,sessionBatchSize:f,collapsedGroups:h,hideDirectoryControls:x,showMoreGroupSessions:b,resetGroupSessionLimit:w,mobileVariant:S,alwaysShowActions:g,activeProjectId:m,setActiveProjectIdOnly:p,setSessionSwitcherOpen:y,openNewSessionDraft:v,pinnedSessionIds:N,sessionOrderIndex:C,notifyOnSubtasks:k,onToggleCollapsedGroup:A,dragHandleProps:D,compactBodyPadding:P=!1,scrollContainerRef:T,expandedParents:$,editingId:E,openSidebarMenuKey:U,editTitle:I,copiedSessionId:B,folderRename:R,setFolderRenameDraft:j,clearFolderRename:M}=t,L=fs(Me=>Me.toggleFolderCollapse),W=fs(Me=>Me.renameFolder),te=fs(Me=>Me.deleteFolder),Q=fs(Me=>Me.addSessionToFolder),me=Ce(Me=>Me.showDeletionDialog),[ce,H]=c.useState(null),ne=c.useCallback((Me,Ve)=>{const Ze=C.get(Me.session.id),at=C.get(Ve.session.id);if(Ze!==void 0||at!==void 0){if(Ze===void 0)return 1;if(at===void 0)return-1;if(Ze!==at)return Ze-at}return td(Me.session,Ve.session,N,oa)},[N,C]),ie=l?d.get(n):null,F=l?!1:h.has(r),Z=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const Me=yt(n.directory??null),Ve=n.branch?.trim();return Me&&Ve?$o(Me,Ve):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),G=Xc(Z),V=G?`var(--pr-${G.visualState})`:void 0,Y=ua(),le=c.useMemo(()=>{const Me=n.folderScopes?.map(Ve=>yt(Ve.directory))??[yt(n.directory??null)];return[...new Set(Me.filter(Ve=>!!Ve))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(Me=>le.length>0?Y.subscribeBootstrap(Me):()=>{},[le.length,Y]),c.useCallback(()=>le.map(Me=>`${Me}\0${Y.getBootstrapState(Me)??""}\0${Y.getBootstrapFailure(Me)??""}`).join(""),[le,Y]),c.useCallback(()=>"",[]));const pe=le.some(Me=>{const Ve=Y.getBootstrapState(Me);return Ve==="queued"||Ve==="running"}),be=le.find(Me=>Y.getBootstrapState(Me)==="failed")??null,Se=be?Y.getBootstrapFailure(be):void 0,De=Se==="os-permission"&&Ku(),[fe,xe]=c.useState(!1),ge=c.useCallback(()=>{be&&Y.requestBootstrap({directory:be,priority:F?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[Y,be,n.isMain,F]),re=c.useCallback(async()=>{if(!(!be||!De||fe)){xe(!0);try{(await Gu(be)).success&&ge()}finally{xe(!1)}}},[De,be,fe,ge]),he=f??(x?10:5),Ne=Math.max(he,u??he),de=l?ie?.groupMatches===!0:!1,oe=l,K=c.useMemo(()=>[...oe?ie?.filteredNodes??[]:n.sessions].sort(ne),[ne,n.sessions,ie?.filteredNodes,oe]),z=n.folderScopeKey??yt(n.directory??null),ae=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:z?[{scopeKey:z,directory:n.directory??null}]:[],[z,n.directory,n.folderScopes]),ve=fs(Kn(c.useCallback(Me=>ae.map(({scopeKey:Ve})=>Me.foldersMap[Ve]??Kl),[ae]))),ye=c.useMemo(()=>ae.flatMap(({scopeKey:Me,directory:Ve},Ze)=>(ve[Ze]??Kl).map(ut=>({folder:ut,scopeKey:Me,scopeDirectory:Ve}))),[ve,ae]),We=fs(Kn(c.useCallback(Me=>new Set(ve.flatMap(Ve=>Ve.filter(Ze=>Me.collapsedFolderIds.has(Ze.id)).map(Ze=>Ze.id))),[ve]))),Be=c.useMemo(()=>{const Me=new Map,Ve=Ze=>{Ze.forEach(at=>{Me.set(at.session.id,at),at.children.length>0&&Ve(at.children)})};return Ve(K),Me},[K]),Ae=c.useMemo(()=>ye.map(({folder:Me,scopeKey:Ve,scopeDirectory:Ze})=>{const at=Xv(Me.sessionIds,Be).sort(ne);return{folder:Me,scopeKey:Ve,scopeDirectory:Ze,nodes:at}}),[ye,Be,ne]),X=c.useMemo(()=>{const Me=Zv(Ae.map(({folder:Ve,nodes:Ze})=>({id:Ve.id,name:Ve.name,parentId:Ve.parentId,nodeCount:Ze.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:l?a:""});return Ae.filter(({folder:Ve})=>Me.has(Ve.id))},[Ae,n.isArchivedBucket,l,a]),Oe=E,Fe=U,_=$,ue=c.useMemo(()=>new Set(X.flatMap(Me=>Me.folder.sessionIds)),[X]),ke=c.useMemo(()=>K.filter(Me=>!ue.has(Me.session.id)),[K,ue]),je=c.useMemo(()=>{const Me=new Map(X.map(Ve=>[Ve.folder.id,Ve]));return Jv(X.map(Ve=>Ve.folder)).map(Ve=>Me.get(Ve.id)).filter(Ve=>!!Ve)},[X]),Ke=c.useMemo(()=>{const Me=new Map;return X.forEach(Ve=>{if(!Ve.folder.parentId)return;const Ze=Me.get(Ve.folder.parentId)??[];Ze.push(Ve),Me.set(Ve.folder.parentId,Ze)}),Me},[X]),se=c.useMemo(()=>{const Me=new Map(X.map(at=>[at.folder.id,at])),Ve=new Map,Ze=(at,ut)=>{const St=Ve.get(at);if(St!==void 0)return St;if(ut.has(at))return[];ut.add(at);const nt=Me.get(at),Ft=nt?[...nt.nodes]:[];for(const Xt of Ke.get(at)??[])Ft.push(...Ze(Xt.folder.id,ut));return Ve.set(at,Ft),Ft};return X.forEach(({folder:at})=>Ze(at.id,new Set)),Ve},[X,Ke]),Ie="project",Ye=c.useMemo(()=>{const Me=new Set;return $i(K,Oe,Me),X.forEach(({nodes:Ve})=>{$i(Ve,Oe,Me)}),Me},[K,X,Oe]),ee=c.useMemo(()=>{if(!Fe)return null;const Me=Lr(K,Fe,Ie,!!n.isArchivedBucket);if(Me)return Me;for(const{nodes:Ve}of X){const Ze=Lr(Ve,Fe,Ie,!!n.isArchivedBucket);if(Ze)return Ze}return null},[Fe,K,X,n.isArchivedBucket]),Ee=c.useCallback(Me=>{const Ve=new WeakMap,Ze=at=>{Ve.set(at,Ro(at));for(const ut of at.children)Ze(ut)};return Me.forEach(Ze),Ve},[]),Ge=c.useMemo(()=>Ee(K),[Ee,K]),ze=c.useMemo(()=>{const Me=new WeakMap;return X.forEach(({nodes:Ve})=>{Ve.forEach(Ze=>Me.set(Ze,Ro(Ze)))}),Me},[X]),$e=c.useCallback(Me=>Ge.get(Me)??ze.get(Me)??"",[Ge,ze]),_e=c.useCallback(Me=>({subtreeContainsEditing:Ye,menuOpenSessionId:ee,nodeStructureKey:$e(Me)}),[Ye,ee,$e]),Xe=ke.length,ct=n.isArchivedBucket||l?ke:ke.slice(0,Ne),Nt=Xe-ct.length,At=!n.isArchivedBucket&&!l&&Xe>he&&Nt===0,Le=n.isArchivedBucket===!0&&!l&&ct.length>=X0,_t=n.isArchivedBucket?"archived":"active",mt=Le&&ct.some(Me=>{if(Me.children.length===0)return!1;const Ve=`project:${_t}:${Me.session.id}`;return _.has(Ve)}),Rt=c.useRef(null),[Dt,xt]=c.useState(null),[we,dt]=c.useState(0),[,et]=c.useState(0);c.useEffect(()=>{if(!Le)return;const Me=Rt.current;if(!Me||!globalThis.ResizeObserver)return;const Ve=new ResizeObserver(()=>et(Ze=>Ze+1));return Ve.observe(Me),()=>Ve.disconnect()},[Le]),c.useLayoutEffect(()=>{if(!Le){Dt!==null&&xt(null),we!==0&&dt(0);return}const Me=Rt.current;if(!Me)return;let Ve=Dt;const Ze=T?.current??null;if(Ze&&Ze.contains(Me)){if(Ve=Ze,Ve!==Dt){xt(Ve);return}}else if(!Ve||!Ve.contains(Me)){let ut=Me.parentElement;for(;ut;){const St=window.getComputedStyle(ut);if(St.overflowY==="auto"||St.overflowY==="scroll"){Ve=ut;break}ut=ut.parentElement}if(Ve!==Dt){xt(Ve);return}}if(!Ve)return;const at=Me.getBoundingClientRect().top-Ve.getBoundingClientRect().top+Ve.scrollTop;dt(ut=>Math.abs(ut-at)<1?ut:at)});const qe=Le&&Dt!==null,kt=wp({count:ct.length,enabled:qe,getScrollElement:()=>Dt,initialOffset:()=>Dt?.scrollTop??0,estimateSize:()=>J0,overscan:mt?20:8,scrollMargin:we,getItemKey:Me=>ct[Me]?.session.id??Me}),wt=c.useCallback(Me=>{const Ve=[],Ze=at=>{at.forEach(ut=>{Ve.push(ut.session),ut.children.length>0&&Ze(ut.children)})};return Ze(Me),Ve},[]),jt=c.useMemo(()=>wt(K),[wt,K]),Ut=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const Me=new Map,Ve=new Map;for(const{folder:at}of X){if(!at.parentId)continue;const ut=Ve.get(at.parentId)??[];ut.push(at.id),Ve.set(at.parentId,ut)}const Ze=(at,ut)=>{if(ut.has(at))return[];ut.add(at);const St=X.find(({folder:Xt})=>Xt.id===at),nt=St?wt(St.nodes):[],Ft=Ve.get(at)??[];for(const Xt of Ft)nt.push(...Ze(Xt,ut));return nt};for(const{folder:at}of X)Me.set(at.id,Ze(at.id,new Set));return Me},[X,wt,n.isArchivedBucket]);if(l&&!de&&je.length===0&&ke.length===0)return null;const st=!n.isMain&&!!n.branch,rt=n.branch&&wm(n.branch,n.label)?{label:n.branch}:null,Ct=F?s.jsx(Mv,{nodes:K,includeUnreadSubtasks:k}):null,It=(Me,Ve)=>{const{folder:Ze,scopeKey:at,scopeDirectory:ut,nodes:St}=Me,nt=Ut.get(Ze.id)??[],Ft=R?.folderId===Ze.id&&R?.scopeKey===at,Xt=l?!1:We.has(Ze.id),os=Ss=>s.jsx(qv,{folderId:Ze.id,children:(qs,gs)=>s.jsx(Bv,{folder:Ze,displayName:Ve,sessions:St,isCollapsed:Xt,collapsedActivityState:Ss,onToggle:()=>L(Ze.id),onRename:is=>{W(at,Ze.id,is)},onDelete:()=>{if(n.isArchivedBucket){ln.requestDelete({sessions:nt,mode:"session"});return}if(!me){te(at,Ze.id);return}const is=X.filter(({folder:Et})=>Et.parentId===Ze.id).length,Mt=St.length;H({scopeKey:at,folderId:Ze.id,folderName:Ze.name,subFolderCount:is,sessionCount:Mt})},groupDirectory:ut??n.directory,projectId:i,mobileVariant:S,alwaysShowActions:g,isRenaming:Ft,renameDraft:Ft?R?.draft:void 0,onRenameDraftChange:j,onRenameSave:()=>{const is=R?.draft.trim()??"";is&&W(at,Ze.id,is),M()},onRenameCancel:M,droppableRef:qs,isDropTarget:gs,depth:0,onNewSession:()=>{i&&i!==m&&p(i),S&&y(!1),v({selectedProjectId:i,directoryOverride:ut??n.directory,targetFolderId:Ze.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:St.map(is=>s.jsx(Mo,{node:is,pinnedSessionIds:N,expandedParents:$,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:k,editingId:E,editTitle:I,copiedSessionId:B,openSidebarMenuKey:U,mobileVariant:S,alwaysShowActions:g,groupDirectory:ut??n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:Ye,menuOpenSessionId:ee,nodeStructureKey:$e(is),childRenderExtrasFor:_e},setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId},is.session.id))})},Ze.id);return Xt?s.jsx(Z0,{nodes:se.get(Ze.id)??St,includeUnreadSubtasks:k,children:os},Ze.id):os(null)},Bt=()=>{const Me=new Map;for(const ut of X){const St=ut.folder.parentId;if(!St)continue;const nt=Me.get(St);nt?nt.push(ut):Me.set(St,[ut])}const Ve=[],Ze=new Set,at=(ut,St)=>{if(Ze.has(ut.folder.id))return;Ze.add(ut.folder.id);const nt=St?`${St} / ${ut.folder.name}`:ut.folder.name;Ve.push(It(ut,nt)),!(!l&&We.has(ut.folder.id))&&(Me.get(ut.folder.id)??[]).forEach(Xt=>at(Xt,nt))};return je.forEach(ut=>at(ut,"")),Ve},Tt=!!(!n.isMain&&n.worktree),ns=g?Tt?"pr-14":"pr-7":Tt?"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",Lt=be?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Se==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":"sessions.sidebar.group.empty.loadFailed"),De?s.jsx(lt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:fe,onClick:()=>{re()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(lt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:ge,children:e("sessions.sidebar.group.empty.retry")})]}):null,zt=Me=>s.jsx(Mo,{node:Me,pinnedSessionIds:N,expandedParents:$,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:k,editingId:E,editTitle:I,copiedSessionId:B,openSidebarMenuKey:U,mobileVariant:S,alwaysShowActions:g,groupDirectory:n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:Ye,menuOpenSessionId:ee,nodeStructureKey:$e(Me),childRenderExtrasFor:_e},setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId},Me.session.id),qt=s.jsxs(Qv,{scopeKey:ae[0]?.scopeKey??z,hasFolders:X.length>0,onSessionDroppedOnFolder:(Me,Ve)=>{const Ze=X.find(({folder:ut})=>ut.id===Ve);if(!Ze)return;const at=fs.getState();for(const{scopeKey:ut}of ae)ut!==Ze.scopeKey&&at.getSessionFolderId(ut,Me)&&at.removeSessionFromFolder(ut,Me);Q(Ze.scopeKey,Ve,Me)},children:[Bt(),Le?s.jsx("div",{ref:Rt,children:qe?s.jsx("div",{style:{height:kt.getTotalSize(),position:"relative"},children:kt.getVirtualItems().map(Me=>{const Ve=ct[Me.index];return Ve?s.jsx("div",{"data-index":Me.index,ref:kt.measureElement,className:"[&_[data-session-row]]:my-px",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${Me.start-we}px)`},children:zt(Ve)},Ve.session.id):null})}):ct.map(zt)}):ct.map(zt),Xe===0&&X.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"):pe?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(O,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Lt||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,Xe>0&&Lt?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:Lt}):null,Nt>0?s.jsx("button",{type:"button",onClick:()=>b(r,ct.length,f??7),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,At?s.jsx("button",{type:"button",onClick:()=>w(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),ms="pb-2",Qt=s.jsx(H0,{value:ce,setValue:H,onConfirm:()=>{const Me=ce;Me&&(te(Me.scopeKey,Me.folderId),H(null))}});return o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Pe("oc-group-body",ms),children:qt})}),Qt]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:Pe("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>A(r),role:"button",tabIndex:0,onKeyDown:Me=>{(Me.key==="Enter"||Me.key===" ")&&(Me.preventDefault(),A(r))},"aria-label":F?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!F,children:[s.jsx("div",{ref:D?.setActivatorNodeRef,className:Pe("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",ns),...D?.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(O,{name:"archive",className:Pe("h-3.5 w-3.5 shrink-0 text-muted-foreground",g?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:Pe("text-muted-foreground h-3.5 w-3.5 items-center justify-center",g?"inline-flex":"hidden group-hover/gh:inline-flex"),children:F?s.jsx(O,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:co(n.label,a)}),Ct]}):!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(O,{name:"git-branch",className:Pe("h-3.5 w-3.5 shrink-0",!V&&"text-muted-foreground",g?"hidden":"group-hover/gh:hidden"),style:V?{color:V}:void 0}),s.jsx("span",{className:Pe("text-muted-foreground h-3.5 w-3.5 items-center justify-center",g?"inline-flex":"hidden group-hover/gh:inline-flex"),children:F?s.jsx(O,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(O,{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:co(n.label,a)}),Ct,G?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:V?{color:V}:void 0,children:["#",G.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:co(n.label,a)}),Ct]})}),st&&rt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(O,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(O,{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:rt.label})]}):null]})}),n.isArchivedBucket&&jt.length>0?s.jsx("div",{className:Pe("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",g?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(gt,{delayDuration:500,children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),ln.requestDelete({sessions:jt,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(O,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(pt,{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:Pe("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",g?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(gt,{delayDuration:500,children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),ln.requestDelete({sessions:jt,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(O,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:Pe("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",g?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(gt,{delayDuration:500,children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),i&&i!==m&&p(i),S&&y(!1),v({selectedProjectId:i,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(O,{name:"add",className:"h-4 w-4"})})}),s.jsx(pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),F?null:s.jsx("div",{className:Pe("oc-group-body",ms),children:qt})]}),Qt]})}const xo=c.memo(r2,n2),o2=(t,e,n)=>e?t.filter(r=>r.project.id===n):t,i2=(t,e)=>{const n=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==n.id);return[n,...r?[r]:[]].map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:o.id===n.id}))},a2=48,l2=32,c2=24,di=(t,e)=>da(t.label?.trim()||In(t.normalizedPath,e)||t.normalizedPath);function d2(t){const e=Je.c(42);sn("ui.sidebar_projects_list.render");const{t:n}=ft(),{model:r,view:i,actions:o}=t,l=r.state.editingId!==null,a=i.isDesktopShellRuntime&&i.stickyZoneHeaders&&!r.singleProjectMode;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={coordinateGetter:cp},e[1]=u):u=e[1];const f=Er(An(Ci,d),An(ap,u));let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h={activationConstraint:{distance:8}},e[2]=h):h=e[2];const x=Er(An(Ci,h)),b=c.useRef(null),w=c.useRef(0);let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=ie=>{const Z=ie.scrollTop>1?Math.min(l2+ie.scrollTop,a2):0;w.current=Z;const G=ie.closest(".oc-sticky-fade-root");G?.style.setProperty("--scroll-shadow-top-size",`${Z}px`),G?.style.setProperty("--scroll-shadow-top-clear-size",`${Math.min(Math.max(Z-8,0),c2)}px`)},e[3]=S):S=e[3];const g=S;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=ie=>{ie.target.closest("[data-overlay-scrollbar-thumb], [data-sidebar-sticky-header]")||ie.clientY-ie.currentTarget.getBoundingClientRect().top>=w.current||(ie.preventDefault(),ie.stopPropagation())},e[4]=m):m=e[4];const p=m,y=o2(r.sectionsForRender,r.singleProjectMode,r.singleProjectId),v=r.projectSections.length>0&&y.length>0;let N,C;e[5]!==a||e[6]!==v?(N=()=>{a&&v&&b.current&&g(b.current)},C=[a,v,g],e[5]=a,e[6]=v,e[7]=N,e[8]=C):(N=e[7],C=e[8]),c.useLayoutEffect(N,C);let k=null;for(const ie of r.projectSections)r.stuckProjectHeaders.has(ie.project.id)&&(k=ie.project);const A=k??(r.hasSharedSessions?null:y[0]?.project??null),D=A?di(A,i.homeDirectory):null;let P;if(e[9]!==r.projectSections||e[10]!==i.homeDirectory){let ie;e[12]!==i.homeDirectory?(ie=F=>({id:F.project.id,projectLabel:di(F.project,i.homeDirectory),projectDescription:Tr(F.project.normalizedPath,i.homeDirectory),projectIcon:F.project.icon,projectColor:F.project.color,projectIconImage:F.project.iconImage,projectIconBackground:F.project.iconBackground}),e[12]=i.homeDirectory,e[13]=ie):ie=e[13],P=r.projectSections.map(ie),e[9]=r.projectSections,e[10]=i.homeDirectory,e[11]=P}else P=e[11];const T=P;if(r.projectSections.length===0){let ie;return e[14]!==r.emptyState||e[15]!==r.topContent?(ie=s.jsxs(pn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"space-y-1 pb-1 pl-2.5 pr-2",children:[r.topContent,r.emptyState]}),e[14]=r.emptyState,e[15]=r.topContent,e[16]=ie):ie=e[16],ie}if(r.sectionsForRender.length===0){let ie;return e[17]!==r.searchEmptyState?(ie=s.jsx(pn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"space-y-1 pb-1 pl-2.5 pr-2",children:r.searchEmptyState}),e[17]=r.searchEmptyState,e[18]=ie):ie=e[18],ie}const $="oc-sticky-fade-root relative flex min-h-0 flex-1";let E;e[19]!==a?(E=a?{"--scroll-shadow-top-size":"0px"}:void 0,e[19]=a,e[20]=E):E=e[20];const U=a?p:void 0,I=a?p:void 0,B=a?p:void 0,R=pn,j=!0,M=!a,L=96,W="flex-1 min-h-0",te="oc-sidebar-scroller space-y-1.5 pb-1 pl-2.5 pr-2 [overflow-anchor:none]";let Q;e[21]!==a?(Q=a?ie=>g(ie.currentTarget):void 0,e[21]=a,e[22]=Q):Q=e[22];const me=i.showOnlyMainWorkspace?s.jsx("div",{className:"space-y-[0.6rem] py-1",children:(()=>{const ie=y.find(Z=>Z.project.id===r.activeProjectId)??y[0];if(!ie)return i.hasSessionSearchQuery?r.searchEmptyState:r.emptyState;const F=i2(ie);return F.length?F.map(Z=>{const{group:G,groupKey:V,projectId:Y,hideGroupLabel:le}=Z;return s.jsx(c.Fragment,{children:s.jsx(xo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:G,groupKey:V,projectId:Y,hideGroupLabel:le,visibleSessionCount:r.state.visibleSessionCountByGroup.get(V),compactBodyPadding:!0,scrollContainerRef:b})},V)}):s.jsx("div",{className:"py-1 text-left typography-micro text-muted-foreground",children:n("sessions.sidebar.empty.noSessions.title")})})()}):s.jsxs(Rr,{sensors:f,collisionDetection:Mr,onDragEnd:ie=>{if(l||i.projectSortOrder!=="manual")return;const{active:F,over:Z}=ie;if(!Z||F.id===Z.id)return;const G=r.sectionsForRender.findIndex(Y=>Y.project.id===F.id),V=r.sectionsForRender.findIndex(Y=>Y.project.id===Z.id);G===-1||V===-1||G===V||o.reorderProjects(G,V)},children:[s.jsx(No,{items:y.map(h2),strategy:Ai,children:y.map(ie=>{const F=ie.project,Z=F.id,G=di(F,i.homeDirectory),V=Tr(F.normalizedPath,i.homeDirectory),Y=r.singleProjectMode?!1:i.collapsedProjects.has(Z),le=r.projectRepoStatus.get(Z);return s.jsx(Nv,{id:Z,disabled:r.singleProjectMode||i.projectSortOrder!=="manual",projectLabel:G,projectDescription:V,projectIcon:F.icon,projectColor:F.color,projectIconImage:F.iconImage,projectIconBackground:F.iconBackground,isCollapsed:Y,isRepo:!!le,isDesktopShell:i.isDesktopShellRuntime,hideDirectoryControls:i.hideDirectoryControls,mobileVariant:i.mobileVariant,alwaysShowActions:i.alwaysShowActions,statusIndicator:Y?o.renderProjectStatusIndicator?.(Z,ie.groups):null,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,projectPickerOptions:r.singleProjectMode?T:void 0,onProjectSelect:r.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{r.singleProjectMode||o.toggleProject(Z)},onNewSession:()=>{Z!==r.activeProjectId&&o.setActiveProjectIdOnly(Z),i.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:Z,directoryOverride:F.normalizedPath})},onNewWorktreeSession:()=>{Z!==r.activeProjectId&&o.setActiveProjectIdOnly(Z),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(Z),onRenameStart:()=>o.openProjectEditDialog(Z),onClose:()=>o.removeProject(Z),sentinelRef:pe=>{r.projectHeaderSentinelRefs.current.set(Z,pe)},showCreateButtons:!0,children:Y?null:s.jsx("div",{className:"space-y-0 pt-0.5 pb-0.5",children:(()=>{const pe=ie.groups,be=pe.find(m2)??null,Se=be?pe.filter(De=>De.id!==be.id):pe;return s.jsxs(Rr,{sensors:x,collisionDetection:Mr,onDragEnd:De=>{if(l)return;const{active:fe,over:xe}=De;if(!xe||fe.id===xe.id)return;const ge=Se.findIndex(de=>de.id===fe.id),re=Se.findIndex(de=>de.id===xe.id);if(ge===-1||re===-1||ge===re)return;const he=vd(Se,ge,re).map(f2),Ne=be?[be.id,...he]:he;o.setGroupOrderByProject(de=>{const oe=new Map(de);return oe.set(Z,Ne),oe})},children:[be?s.jsx(xo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:be,groupKey:`${Z}:${be.id}`,projectId:Z,hideGroupLabel:!0,visibleSessionCount:r.state.visibleSessionCountByGroup.get(`${Z}:${be.id}`),scrollContainerRef:b}):null,s.jsx(No,{items:Se.map(u2),strategy:Ai,children:Se.map(De=>{const fe=`${Z}:${De.id}`;return s.jsx(Dv,{id:De.id,disabled:l,children:xe=>s.jsx(xo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:De,groupKey:fe,projectId:Z,visibleSessionCount:r.state.visibleSessionCountByGroup.get(fe),dragHandleProps:xe,scrollContainerRef:b})},De.id)})}),s.jsx(Ni,{dropAnimation:null})]})})()})},Z)})}),s.jsx(Ni,{dropAnimation:null})]});let ce;e[23]!==R||e[24]!==r.topContent||e[25]!==M||e[26]!==Q||e[27]!==me?(ce=s.jsxs(R,{ref:b,useScrollShadow:j,hideTopScrollShadow:M,scrollShadowSize:L,outerClassName:W,className:te,onScroll:Q,children:[r.topContent,me]}),e[23]=R,e[24]=r.topContent,e[25]=M,e[26]=Q,e[27]=me,e[28]=ce):ce=e[28];let H;e[29]!==a||e[30]!==A||e[31]!==D||e[32]!==r.hasSharedSessions||e[33]!==n?(H=a&&(A||r.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:A&&D?s.jsx(go,{id:A.id,projectLabel:D,projectIcon:A.icon,projectColor:A.color,projectIconImage:A.iconImage,projectIconBackground:A.iconBackground}):s.jsxs(s.Fragment,{children:[s.jsx(O,{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:n("sessions.sidebar.activity.recentTitle")})]})}):null,e[29]=a,e[30]=A,e[31]=D,e[32]=r.hasSharedSessions,e[33]=n,e[34]=H):H=e[34];let ne;return e[35]!==U||e[36]!==I||e[37]!==B||e[38]!==ce||e[39]!==H||e[40]!==E?(ne=s.jsxs("div",{className:$,style:E,onPointerDownCapture:U,onClickCapture:I,onContextMenuCapture:B,children:[ce,H]}),e[35]=U,e[36]=I,e[37]=B,e[38]=ce,e[39]=H,e[40]=E,e[41]=ne):ne=e[41],ne}function u2(t){return t.id}function f2(t){return t.id}function m2(t){return t.isMain}function h2(t){return t.project.id}const p2=c.memo(d2),Hi=new Map,g2=(t,e)=>{for(const n of t){const r=yt(n??null);r&&!Hi.has(r)&&Hi.set(r,e)}},Gl=t=>{const e=yt(t??null);return e?Hi.get(e)??0:0},ro=t=>!!t.time?.archived,b2=t=>{const{t:e}=ft(),n=c.useCallback(l=>[l.label,l.branch??"",l.description??"",l.directory??""].join(" ").toLowerCase(),[]),r=c.useCallback(l=>{const a=yt(l.directory??null)??"";return`${(l.title||e("sessions.sidebar.session.untitled")).trim()} ${a}`.toLowerCase()},[e]),i=c.useCallback((l,a)=>a?l.flatMap(d=>{if(jo([r(d.session)],a))return[d];const f=i(d.children,a);return f.length===0?[]:[{...d,children:f}]}):l,[r]),o=c.useCallback((l,a,d,u,f)=>{const h=yt(a??null),x=qc(l),b=new Map(x.map(I=>[I.id,I])),w=new Map;x.forEach(I=>{const B=I.parentID;if(!B)return;const R=b.get(B);if(!R||ro(R)!==ro(I))return;const j=w.get(B)??[];j.push(I),w.set(B,j)});const S=new Map;d.forEach(I=>{if(I.path){const B=yt(I.path)??I.path;S.set(B,I)}});const g=I=>{const B=yt(I.directory??null),R=t.worktreeMetadata.get(I.id)??null;if(R)return R;if(B){const j=S.get(B)??null;if(j&&B!==h)return j}return null},m=new Set,p=I=>{m.add(I.id);const B=w.get(I.id)??[],R=[];for(const j of B)m.has(j.id)||R.push(p(j));return{session:I,children:R,worktree:g(I)}},y=x.filter(I=>{const B=I.parentID;if(!B)return!0;const R=b.get(B);return R?ro(R)!==ro(I):!0}),v=[],N=I=>{m.has(I.id)||v.push(p(I))};y.forEach(N),x.forEach(N);const C=new Map,k="__archived__",A=I=>{if(I.time?.archived)return k;if(t.isVSCode)return h??"__project_root__";const R=yt(t.worktreeMetadata.get(I.id)?.path??null)??Is(I);return R?R!==h&&S.has(R)?R:R===h?h??"__project_root__":k:k};v.forEach(I=>{const B=A(I.session);C.has(B)||C.set(B,[]),C.get(B)?.push(I)});const D=h??"__project_root__",P=[{id:"root",label:f&&u&&u!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:u}):e("sessions.sidebar.grouping.projectRoot"),branch:u??null,description:h?Tr(h,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:h,folderScopeKey:h,sessions:C.get(D)??[]}],T=new Map;d.forEach(I=>{const B=yt(I.path)??I.path,R=C.get(B)??[],j=R.length>0,M=R.reduce((L,W)=>{const te=Sm(W.session,t.sessionOrderRanks);return Number.isFinite(te)?Math.max(L,te):L},0);T.set(B,{hasActiveSession:j,lastUpdatedAt:M})});const $=[...d].sort((I,B)=>{const R=yt(I.path)??I.path,j=yt(B.path)??B.path,M=T.get(R)??{hasActiveSession:!1,lastUpdatedAt:0},L=T.get(j)??{hasActiveSession:!1,lastUpdatedAt:0};if(M.hasActiveSession!==L.hasActiveSession)return M.hasActiveSession?-1:1;if(M.hasActiveSession&&L.hasActiveSession)return L.lastUpdatedAt-M.lastUpdatedAt;const W=Gl(I.path),te=Gl(B.path);if(W!==te)return te-W;const Q=(I.label||I.branch||I.name||I.path||"").toLowerCase(),me=(B.label||B.branch||B.name||B.path||"").toLowerCase();return Q.localeCompare(me)});(t.isVSCode?[]:$).forEach(I=>{const B=yt(I.path)??I.path,R=t.gitBranches.get(B)?.trim()||null,j=I.branch?.trim()||null,L=!!(R&&j&&I.label&&La(I.label)===La(j))?R:I.label||I.name||In(B,t.homeDirectory)||B;P.push({id:`worktree:${B}`,label:L,branch:R||j,description:Tr(B,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:I,directory:B,folderScopeKey:B,sessions:C.get(B)??[]})});const U=C.get(k)??[];return U.length>0&&P.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&&h?Uc(h):null,sessions:U}),P},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.gitBranches,t.isVSCode,e]);return{buildGroupSearchText:n,buildSessionSearchText:r,filterSessionNodesForSearch:i,buildGroupedSessions:o}},x2=t=>{const e=Je.c(10),{enabled:n,isDesktopShellRuntime:r,projectSections:i,projectHeaderSentinelRefs:o}=t,l=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]=c.useState(a);let f;e[1]!==l||e[2]!==r||e[3]!==o?(f=()=>{if(!l||!r){u(y2);return}const b=Array.from(o.current.values()).find(w2)?.closest(".oc-sidebar-scroller")??null;if(!b)return;const w=new IntersectionObserver(S=>{u(g=>{const m=new Set(g);let p=!1;for(const y of S){const v=y.target.dataset.projectId;if(!v)continue;const N=y.rootBounds?.top??b.getBoundingClientRect().top,C=!y.isIntersecting&&y.boundingClientRect.top<N;m.has(v)!==C&&(p=!0,C?m.add(v):m.delete(v))}return p?m:g})},{root:b,threshold:0});return o.current.forEach(S=>{S&&w.observe(S)}),()=>w.disconnect()},e[1]=l,e[2]=r,e[3]=o,e[4]=f):f=e[4];let h;return e[5]!==l||e[6]!==r||e[7]!==o||e[8]!==i?(h=[l,r,o,i],e[5]=l,e[6]=r,e[7]=o,e[8]=i,e[9]=h):h=e[9],c.useEffect(f,h),d};function y2(t){return t.size===0?t:new Set}function w2(t){return t!==null}const S2=t=>{const e=Je.c(51),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:f,onDelete:h,onDone:x}=t,{t:b}=ft(),w=!!r&&!o;let S;e[0]!==o||e[1]!==b?(S=b(o?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[0]=o,e[1]=b,e[2]=S):S=e[2];const g=S;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 p;e[6]!==m?(p=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:m}),e[6]=m,e[7]=p):p=e[7];let y;e[8]!==w||e[9]!==u||e[10]!==a||e[11]!==l||e[12]!==d||e[13]!==i||e[14]!==b?(y=w?s.jsxs(Ks,{children:[s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx(Us,{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(O,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(Hs,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(Wt,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):i.map(j=>s.jsx(Wt,{onClick:()=>l(j.id),children:s.jsx("span",{className:"flex-1 truncate",children:j.name})},j.id)),s.jsx(Rs,{}),s.jsxs(Wt,{onClick:a,children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(Wt,{onClick:d,className:"text-destructive focus:text-destructive",children:[s.jsx(O,{name:"close",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[8]=w,e[9]=u,e[10]=a,e[11]=l,e[12]=d,e[13]=i,e[14]=b,e[15]=y):y=e[15];let v;e[16]!==o||e[17]!==f||e[18]!==b?(v=o?s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,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(O,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[16]=o,e[17]=f,e[18]=b,e[19]=v):v=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=Pe("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 C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(O,{name:"delete-bin",className:"h-4 w-4"}),e[21]=C):C=e[21];let k;e[22]!==g||e[23]!==h?(k=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:N,"aria-label":g,children:C})}),e[22]=g,e[23]=h,e[24]=k):k=e[24];let A;e[25]!==g?(A=s.jsx(pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:g})}),e[25]=g,e[26]=A):A=e[26];let D;e[27]!==k||e[28]!==A?(D=s.jsxs(gt,{children:[k,A]}),e[27]=k,e[28]=A,e[29]=D):D=e[29];let P;e[30]!==b?(P=b("sessions.sidebar.header.actions.exitSelection"),e[30]=b,e[31]=P):P=e[31];let T;e[32]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(O,{name:"close",className:"h-4 w-4"}),e[32]=T):T=e[32];let $;e[33]!==x||e[34]!==P?($=s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:x,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":P,children:T})}),e[33]=x,e[34]=P,e[35]=$):$=e[35];let E;e[36]!==b?(E=b("sessions.sidebar.header.actions.exitSelection"),e[36]=b,e[37]=E):E=e[37];let U;e[38]!==E?(U=s.jsx(pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:E})}),e[38]=E,e[39]=U):U=e[39];let I;e[40]!==$||e[41]!==U?(I=s.jsxs(gt,{children:[$,U]}),e[40]=$,e[41]=U,e[42]=I):I=e[42];let B;e[43]!==D||e[44]!==I||e[45]!==y||e[46]!==v?(B=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[y,v,D,I]}),e[43]=D,e[44]=I,e[45]=y,e[46]=v,e[47]=B):B=e[47];let R;return e[48]!==B||e[49]!==p?(R=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5",children:[p,B]}),e[48]=B,e[49]=p,e[50]=R):R=e[50],R},v2=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},j2=t=>{const{t:e}=ft(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,getFolderScopesForProject:o,addSessionsToFolder:l,removeSessionsFromFolders:a,createFolderAndStartRename:d,archiveSessions:u,unarchiveSessions:f,deleteSessions:h,setBulkDeleteConfirm:x}=t,b=ws(j=>j.enabled),w=ws(j=>j.selectedIds.size),S=w>0,g=ws(j=>j.selectedIds),m=ws(j=>j.scopeKey),p=c.useCallback(()=>{ws.getState().toggleMode()},[]),y=c.useCallback(()=>{ws.getState().disable()},[]),v=c.useMemo(()=>{if(!S||typeof document>"u")return!1;let j=!1,M=!1;for(const L of g){const W=document.querySelectorAll(`[data-session-row="${CSS.escape(L)}"]`);for(const te of W)te.getAttribute("data-session-archived")==="1"?M=!0:j=!0}return M&&!j},[S,g]),N=c.useMemo(()=>{if(m)return m;if(!S||typeof document>"u")return null;for(const j of g){const L=document.querySelector(`[data-session-row="${CSS.escape(j)}"]`)?.getAttribute("data-session-scope");if(L&&L.length>0)return L}return null},[S,g,m]),C=c.useMemo(()=>v2(N,o),[N,o]),k=c.useMemo(()=>C.flatMap(j=>i[j]??[]),[i,C]),A=c.useCallback(j=>{for(const M of C)if((i[M]??[]).some(L=>L.id===j))return M;return null},[i,C]),D=c.useMemo(()=>{if(!S)return!1;for(const j of C)for(const M of i[j]??[])for(const L of M.sessionIds)if(g.has(L))return!0;return!1},[i,C,S,g]),P=c.useCallback((j,M)=>{const L=Array.from(g);for(const W of C)W!==j&&a(W,L);l(j,M,L)},[l,a,g,C]),T=c.useCallback(j=>{if(!S)return;const M=A(j);M&&P(M,j)},[S,P,A]),$=c.useCallback(()=>{const j=C[0];if(!j||!S)return;const M=d(j);M&&P(j,M.id)},[d,S,P,C]),E=c.useCallback(()=>{if(!S)return;const j=Array.from(g);for(const M of C)a(M,j)},[a,g,C,S]),U=c.useCallback(async()=>{const j=Array.from(g);if(j.length!==0){if(v){const{deletedIds:M,failedIds:L}=await h(j);M.length>0&&Re.success(M.length===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:M.length}):e("sessions.sidebar.bulkActions.deletedPlural",{count:M.length})),L.length>0&&Re.error(L.length===1?e("sessions.sidebar.bulkActions.failedDeleteSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedDeletePlural",{count:L.length}))}else{const{archivedIds:M,failedIds:L}=await u(j);M.length>0&&Re.success(M.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:M.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:M.length})),L.length>0&&Re.error(L.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:L.length}))}ws.getState().clear()}},[u,v,h,g,e]),I=c.useCallback(()=>{if(!S)return;const j=g.size;if(!r){U();return}x({sessionCount:j,archivedBucket:v})},[v,U,g,r,x,S]),B=c.useCallback(async()=>{if(!S||!v)return;const j=Array.from(g),{restoredIds:M,failedIds:L}=await f(j);M.length>0&&Re.success(M.length===1?e("sessions.sidebar.bulkActions.restoredSingle",{count:M.length}):e("sessions.sidebar.bulkActions.restoredPlural",{count:M.length})),L.length>0&&Re.error(L.length===1?e("sessions.sidebar.bulkActions.failedRestoreSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedRestorePlural",{count:L.length})),ws.getState().clear()},[v,S,g,e,f]),R=c.useCallback(async()=>{x(null),await U()},[U]);return c.useEffect(()=>{if(!b)return;const j=typeof navigator<"u"&&/Macintosh|Mac OS X/.test(navigator.userAgent||""),M=L=>{if(n)return;const W=L.target;if(W&&(W.tagName==="INPUT"||W.tagName==="TEXTAREA"||W.isContentEditable))return;const te=j?L.metaKey:L.ctrlKey;if(L.key==="Escape"){L.preventDefault(),ws.getState().disable();return}if(te&&L.key==="Backspace"){L.preventDefault(),I();return}if(te&&(L.key==="a"||L.key==="A")){const Q=typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[];if(Q.length===0)return;L.preventDefault();const ce=ws.getState().scopeKey??Q[0]?.getAttribute("data-session-scope")??null,H=ie=>ce?ie.getAttribute("data-session-scope")===ce:!0,ne=Q.filter(H).map(ie=>ie.getAttribute("data-session-row")).filter(ie=>typeof ie=="string"&&ie.length>0);if(ne.length===0)return;ws.getState().replaceAll(ne,ce||null)}};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[I,n,b]),{selectionModeEnabled:b,hasSelection:S,selectedIdsSize:w,bulkScopeIsArchived:v,derivedSelectionScope:N,bulkScopeFolders:k,bulkCanRemoveFromFolder:D,handleToggleSelectionMode:p,handleExitSelectionMode:y,handleBulkMoveToFolder:T,handleBulkCreateFolderAndMove:$,handleBulkRemoveFromFolder:E,handleBulkDelete:I,handleBulkRestore:B,confirmBulkDelete:R}};function k2(t){const e=Je.c(36),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=Ce(R2),d=Ce(E2),u=fs(T2),f=fs(I2),h=fs(P2),x=fs(D2),b=Qe(A2),w=Qe(N2),S=Qe(C2);let g;e[0]!==f||e[1]!==i?(g=C=>{const k=f(C,"New folder");return i(C,k),k},e[0]=f,e[1]=i,e[2]=g):g=e[2];let m;e[3]!==h||e[4]!==b||e[5]!==S||e[6]!==u||e[7]!==n||e[8]!==r||e[9]!==x||e[10]!==a||e[11]!==g||e[12]!==w?(m={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:n,addSessionsToFolder:h,removeSessionsFromFolders:x,createFolderAndStartRename:g,archiveSessions:b,unarchiveSessions:w,deleteSessions:S,setBulkDeleteConfirm:l},e[3]=h,e[4]=b,e[5]=S,e[6]=u,e[7]=n,e[8]=r,e[9]=x,e[10]=a,e[11]=g,e[12]=w,e[13]=m):m=e[13];const p=j2(m);let y;e[14]!==p.bulkCanRemoveFromFolder||e[15]!==p.bulkScopeFolders||e[16]!==p.bulkScopeIsArchived||e[17]!==p.derivedSelectionScope||e[18]!==p.handleBulkCreateFolderAndMove||e[19]!==p.handleBulkDelete||e[20]!==p.handleBulkMoveToFolder||e[21]!==p.handleBulkRemoveFromFolder||e[22]!==p.handleBulkRestore||e[23]!==p.handleExitSelectionMode||e[24]!==p.hasSelection||e[25]!==p.selectedIdsSize||e[26]!==p.selectionModeEnabled?(y=p.selectionModeEnabled&&p.hasSelection?s.jsx(S2,{selectedCount:p.selectedIdsSize,scopeKey:p.derivedSelectionScope,scopeFolders:p.bulkScopeFolders,archivedBucket:p.bulkScopeIsArchived,onMoveToFolder:p.handleBulkMoveToFolder,onCreateFolderAndMove:p.handleBulkCreateFolderAndMove,onRemoveFromFolder:p.handleBulkRemoveFromFolder,canRemoveFromFolder:p.bulkCanRemoveFromFolder,onRestore:p.handleBulkRestore,onDelete:p.handleBulkDelete,onDone:p.handleExitSelectionMode}):null,e[14]=p.bulkCanRemoveFromFolder,e[15]=p.bulkScopeFolders,e[16]=p.bulkScopeIsArchived,e[17]=p.derivedSelectionScope,e[18]=p.handleBulkCreateFolderAndMove,e[19]=p.handleBulkDelete,e[20]=p.handleBulkMoveToFolder,e[21]=p.handleBulkRemoveFromFolder,e[22]=p.handleBulkRestore,e[23]=p.handleExitSelectionMode,e[24]=p.hasSelection,e[25]=p.selectedIdsSize,e[26]=p.selectionModeEnabled,e[27]=y):y=e[27];let v;e[28]!==p.confirmBulkDelete||e[29]!==o||e[30]!==d||e[31]!==a?(v=s.jsx(U0,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:d,onConfirm:p.confirmBulkDelete}),e[28]=p.confirmBulkDelete,e[29]=o,e[30]=d,e[31]=a,e[32]=v):v=e[32];let N;return e[33]!==y||e[34]!==v?(N=s.jsxs(s.Fragment,{children:[y,v]}),e[33]=y,e[34]=v,e[35]=N):N=e[35],N}function C2(t){return t.deleteSessions}function N2(t){return t.unarchiveSessions}function A2(t){return t.archiveSessions}function D2(t){return t.removeSessionsFromFolders}function P2(t){return t.addSessionsToFolder}function I2(t){return t.createFolder}function T2(t){return t.foldersMap}function E2(t){return t.setShowDeletionDialog}function R2(t){return t.showDeletionDialog}const ql=7;function M2(t){const{sections:e,variant:n="section",initialVisibleCount:r=ql,batchSize:i=ql}=t,{t:o}=ft(),{pinnedSessionIds:l}=t,a=us(p=>p.stickyZoneHeaders),[d,u]=c.useState(new Set),[f,h]=c.useState(new Map),x=n==="flat",b=c.useCallback(p=>{h(y=>{if(!y.has(p))return y;const v=new Map(y);return v.delete(p),v})},[]),w=c.useCallback(p=>{b(p),u(y=>{const v=new Set(y);return v.has(p)?v.delete(p):v.add(p),v})},[b]),S=c.useCallback((p,y,v)=>{h(N=>{const C=Math.min(v,y+i),k=new Map(N);return k.set(p,C),k})},[i]),g=c.useCallback(p=>{const y=new Set;$i(p,t.editingId,y);const v=Lr(p,t.openSidebarMenuKey,"recent",!1),N=new WeakMap,C=A=>{N.set(A,Ro(A)),A.children.forEach(C)};p.forEach(C);const k=A=>({subtreeContainsEditing:y,menuOpenSessionId:v,nodeStructureKey:N.get(A)??"",childRenderExtrasFor:k});return A=>({subtreeContainsEditing:y,menuOpenSessionId:v,nodeStructureKey:N.get(A)??"",childRenderExtrasFor:k})},[t.editingId,t.openSidebarMenuKey]),m=e.filter(p=>p.items.length>0||p.key==="chats");return m.length===0?null:s.jsx("div",{className:Pe(x?"space-y-0.5 pb-2":"space-y-2 pb-2"),children:m.map(p=>{const y=d.has(p.key),v=Math.max(r,f.get(p.key)??r),N=p.items.slice(0,v),C=p.items.length-N.length,k=p.key==="chats"&&!!t.renderChatsSection,A=!k&&!x&&p.items.length>r&&C===0,D=g(N.map(T=>T.node)),P=T=>s.jsx(Mo,{node:T.node,pinnedSessionIds:l,expandedParents:t.expandedParents,hasSessionSearchQuery:t.hasSessionSearchQuery,normalizedSessionSearchQuery:t.normalizedSessionSearchQuery,notifyOnSubtasks:t.notifyOnSubtasks,editingId:t.editingId,editTitle:t.editTitle,copiedSessionId:t.copiedSessionId,openSidebarMenuKey:t.openSidebarMenuKey,mobileVariant:t.mobileVariant,alwaysShowActions:t.alwaysShowActions,groupDirectory:T.groupDirectory,projectId:T.projectId,secondaryMeta:T.secondaryMeta,renderContext:"recent",renderExtras:D(T.node),setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId},T.node.session.id);return x?s.jsxs("div",{className:"space-y-0.5",children:[N.map(P),C>0?s.jsx("button",{type:"button",onClick:()=>S(p.key,N.length,p.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:o("sessions.sidebar.group.showMore")}):null]},p.key):s.jsxs("div",{className:"relative space-y-1",children:[s.jsxs("div",{className:Pe("relative group/chats","-ml-2.5 -mr-2",a&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":a?"true":void 0,children:[s.jsxs("button",{type:"button",onClick:()=>w(p.key),className:Pe("group flex w-full items-center gap-1.5 py-1 pl-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",p.key==="chats"?"pr-10":"pr-3.5"),"aria-expanded":!y,children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[s.jsx(O,{name:p.key==="chats"?"chat-4":"history",className:Pe("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:y?s.jsx(O,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"text-[14px] font-semibold lowercase text-foreground",children:p.title})]}),p.key==="chats"&&t.onNewChat?s.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),t.onNewChat?.()},className:Pe("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",t.alwaysShowActions?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":o("sessions.sidebar.header.actions.newSession"),children:s.jsx(O,{name:"add",className:"h-4 w-4"})}):null]}),y?null:s.jsxs("div",{className:Pe("space-y-0.5"),children:[k?t.renderChatsSection?.(p.items):N.map(P),!k&&C>0?s.jsx("button",{type:"button",onClick:()=>S(p.key,N.length,p.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:o("sessions.sidebar.group.showMore")}):null,A?s.jsx("button",{type:"button",onClick:()=>b(p.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:o("sessions.sidebar.group.showFewer")}):null]})]},p.key)})})}const O2=t=>{const e=Je.c(60),{projects:n,availableWorktreesByProject:r,gitBranches:i,homeDirectory:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,isDesktopShellRuntime:d,sessions:u,childrenMap:f,pinnedSessionIds:h,recentSessions:x,chatSessions:b,showRecentSection:w}=t,{t:S}=ft();let g;if(e[0]!==r||e[1]!==i||e[2]!==o||e[3]!==n||e[4]!==u){g=new Map;for(const I of u){const B=yt(I.directory??null);if(!B)continue;let R=null,j=-1;for(const te of n){const Q=yt(te.normalizedPath);Q&&(B===Q||B.startsWith(`${Q}/`))&&Q.length>j&&(R=te,j=Q.length)}if(!R)continue;const M=r.get(R.normalizedPath)?.find(te=>yt(te.path)===B),L=da(R.label?.trim()||In(R.normalizedPath,o)||R.normalizedPath),W=M?.branch?.trim()||i.get(B)?.trim()||null;g.set(I.id,{projectId:R.id,groupDirectory:B,projectLabel:L,branchLabel:W&&W!=="HEAD"&&W!==L?W:null})}e[0]=r,e[1]=i,e[2]=o,e[3]=n,e[4]=u,e[5]=g}else g=e[5];const m=g;let p;e[6]!==m?(p=I=>m.get(I)??null,e[6]=m,e[7]=p):p=e[7];const y=p;let v;e[8]!==f?(v=I=>({session:I,children:(f.get(I.id)??[]).filter(B2).map(_2),worktree:null}),e[8]=f,e[9]=v):v=e[9];const N=v,C=l?a:"";let k;e[10]!==y||e[11]!==N||e[12]!==x||e[13]!==C?(k=YS({sessions:x,getSessionLocation:y,getSessionNode:N,query:C}),e[10]=y,e[11]=N,e[12]=x,e[13]=C,e[14]=k):k=e[14];const A=k;let D;e[15]!==S?(D=S("sessions.sidebar.activity.chatsTitle"),e[15]=S,e[16]=D):D=e[16];let P;if(e[17]!==b||e[18]!==N){let I;e[20]!==N?(I=B=>({node:N(B),projectId:null,groupDirectory:B.directory??null,secondaryMeta:null}),e[20]=N,e[21]=I):I=e[21],P=b.map(I),e[17]=b,e[18]=N,e[19]=P}else P=e[19];let T;e[22]!==D||e[23]!==P?(T={key:"chats",title:D,items:P},e[22]=D,e[23]=P,e[24]=T):T=e[24];let $;e[25]!==A||e[26]!==w||e[27]!==S||e[28]!==T?($=[T,...w?A.map(I=>({...I,title:S("sessions.sidebar.activity.recentTitle")})):[]],e[25]=A,e[26]=w,e[27]=S,e[28]=T,e[29]=$):$=e[29];const E=$;let U;return e[30]!==d||e[31]!==h||e[32]!==t.allowReselect||e[33]!==t.alwaysShowActions||e[34]!==t.copiedSessionId||e[35]!==t.deleteSessionConfirm||e[36]!==t.editTitle||e[37]!==t.editingId||e[38]!==t.expandedParents||e[39]!==t.hasSessionSearchQuery||e[40]!==t.isSessionSearchOpen||e[41]!==t.mobileVariant||e[42]!==t.normalizedSessionSearchQuery||e[43]!==t.notifyOnSubtasks||e[44]!==t.onNewChat||e[45]!==t.onSessionSelected||e[46]!==t.openSidebarMenuKey||e[47]!==t.renderChatsSection||e[48]!==t.sessionSearchQuery||e[49]!==t.setCopiedSessionId||e[50]!==t.setDeleteSessionConfirm||e[51]!==t.setEditTitle||e[52]!==t.setEditingId||e[53]!==t.setIsSessionSearchOpen||e[54]!==t.setOpenSidebarMenuKey||e[55]!==t.setSessionSearchQuery||e[56]!==t.startFolderRename||e[57]!==t.toggleParent||e[58]!==E?(U=s.jsx(M2,{sections:E,variant:"section",isDesktopShellRuntime:d,pinnedSessionIds:h,expandedParents:t.expandedParents,hasSessionSearchQuery:t.hasSessionSearchQuery,normalizedSessionSearchQuery:t.normalizedSessionSearchQuery,notifyOnSubtasks:t.notifyOnSubtasks,editingId:t.editingId,editTitle:t.editTitle,copiedSessionId:t.copiedSessionId,openSidebarMenuKey:t.openSidebarMenuKey,mobileVariant:t.mobileVariant,alwaysShowActions:t.alwaysShowActions,onNewChat:t.onNewChat,renderChatsSection:t.renderChatsSection,setEditingId:t.setEditingId,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,isSessionSearchOpen:t.isSessionSearchOpen,sessionSearchQuery:t.sessionSearchQuery,setSessionSearchQuery:t.setSessionSearchQuery,setIsSessionSearchOpen:t.setIsSessionSearchOpen,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,setCopiedSessionId:t.setCopiedSessionId}),e[30]=d,e[31]=h,e[32]=t.allowReselect,e[33]=t.alwaysShowActions,e[34]=t.copiedSessionId,e[35]=t.deleteSessionConfirm,e[36]=t.editTitle,e[37]=t.editingId,e[38]=t.expandedParents,e[39]=t.hasSessionSearchQuery,e[40]=t.isSessionSearchOpen,e[41]=t.mobileVariant,e[42]=t.normalizedSessionSearchQuery,e[43]=t.notifyOnSubtasks,e[44]=t.onNewChat,e[45]=t.onSessionSelected,e[46]=t.openSidebarMenuKey,e[47]=t.renderChatsSection,e[48]=t.sessionSearchQuery,e[49]=t.setCopiedSessionId,e[50]=t.setDeleteSessionConfirm,e[51]=t.setEditTitle,e[52]=t.setEditingId,e[53]=t.setIsSessionSearchOpen,e[54]=t.setOpenSidebarMenuKey,e[55]=t.setSessionSearchQuery,e[56]=t.startFolderRename,e[57]=t.toggleParent,e[58]=E,e[59]=U):U=e[59],U};function B2(t){return!t.time?.archived}function _2(t){return{session:t,children:[],worktree:null}}const ku="oc.sessions.expandedParents.v3",F2=ma(ur()),L2=()=>{try{const t=globalThis.localStorage.getItem(ku);if(t===null)return new Set;const e=F2.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},$2=()=>{const[t,e]=c.useState(L2),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=vm(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(ku,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},z2=5*6e4,W2=t=>!t.parentID,V2=t=>{const e=Je.c(274),{topology:n,view:r,actions:i}=t;let o,l,a,d,u;e[0]!==i?({alwaysShowActions:o,notifyOnSubtasks:l,projectViewActions:a,rowActions:d,...u}=i,e[0]=i,e[1]=o,e[2]=l,e[3]=a,e[4]=d,e[5]=u):(o=e[1],l=e[2],a=e[3],d=e[4],u=e[5]);const f=fs(H2),h=fs(K2),x=fs(G2),b=r.projectView,{getOrderedGroups:w,setGroupOrderByProject:S,toggleGroup:g,toggleProject:m}=a;let p;e[6]!==n.isVSCode||e[7]!==n.knownDirectories?(p={knownDirectories:n.knownDirectories,isVSCode:n.isVSCode,isVisible:!0},e[6]=n.isVSCode,e[7]=n.knownDirectories,e[8]=p):p=e[8];const y=rv(p);let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=new Map,e[9]=v):v=e[9];const[N,C]=c.useState(v);let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=(Mt,Et)=>{C(Jt=>new Map(Jt).set(Mt,Et+7))},e[10]=k):k=e[10];const A=k;let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D=Mt=>{C(Et=>{if(!Et.has(Mt))return Et;const Jt=new Map(Et);return Jt.delete(Mt),Jt})},e[11]=D):D=e[11];const P=D,T=us(q2),$=us(Q2),E=us(Y2),U=us(X2);let I;e[12]!==n.isVSCode?(I=!n.isVSCode&&!qu(),e[12]=n.isVSCode,e[13]=I):I=e[13];const R=I&&$==="single",j=T&&!R;let M;e[14]!==y.pinnedSessionIds||e[15]!==y.rootSessions||e[16]!==y.sessionOrderRanks||e[17]!==j||e[18]!==n.isVSCode?(M={enabled:j,isVSCode:n.isVSCode,pinnedSessionIds:y.pinnedSessionIds,sessionOrderRanks:y.sessionOrderRanks,sessions:y.rootSessions},e[14]=y.pinnedSessionIds,e[15]=y.rootSessions,e[16]=y.sessionOrderRanks,e[17]=j,e[18]=n.isVSCode,e[19]=M):M=e[19];const L=ov(M),[W,te]=c.useState(null),[Q,me]=c.useState(""),[ce,H]=c.useState(null),[ne,ie]=c.useState(null),[F,Z]=c.useState(null),[G,V]=c.useState(null);let Y;e[20]===Symbol.for("react.memo_cache_sentinel")?(Y=(Mt,Et)=>{V({scopeKey:Mt,folderId:Et.id,draft:Et.name})},e[20]=Y):Y=e[20];const le=Y;let pe;e[21]===Symbol.for("react.memo_cache_sentinel")?(pe=Mt=>{V(Et=>Et?{...Et,draft:Mt}:null)},e[21]=pe):pe=e[21];const be=pe;let Se;e[22]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>V(null),e[22]=Se):Se=e[22];const De=Se,{expandedParents:fe,toggleParent:xe}=$2(),ge=Qe(J2);let re;e[23]!==ge?(re=(Mt,Et)=>{Mt!==Qe.getState().currentSessionId&&ge(Mt,Et)},e[23]=ge,e[24]=re):re=e[24];const he=re,Ne=jm();let de;e[25]!==y.pinnedSessionIds||e[26]!==y.sessionOrderRanks||e[27]!==n.gitBranches||e[28]!==n.isVSCode||e[29]!==n.worktreeMetadata||e[30]!==r.homeDirectory?(de={homeDirectory:r.homeDirectory,worktreeMetadata:n.worktreeMetadata,pinnedSessionIds:y.pinnedSessionIds,sessionOrderRanks:y.sessionOrderRanks,gitBranches:n.gitBranches,isVSCode:n.isVSCode},e[25]=y.pinnedSessionIds,e[26]=y.sessionOrderRanks,e[27]=n.gitBranches,e[28]=n.isVSCode,e[29]=n.worktreeMetadata,e[30]=r.homeDirectory,e[31]=de):de=e[31];const{buildGroupedSessions:oe,filterSessionNodesForSearch:K,buildGroupSearchText:z}=b2(de);let ae;e[32]!==y.archivedSessions||e[33]!==y.sessions||e[34]!==n.availableWorktreesByProject||e[35]!==n.isVSCode||e[36]!==n.projects?(ae=pv(y.sessions,n.projects,n.availableWorktreesByProject,n.isVSCode,y.archivedSessions),e[32]=y.archivedSessions,e[33]=y.sessions,e[34]=n.availableWorktreesByProject,e[35]=n.isVSCode,e[36]=n.projects,e[37]=ae):ae=e[37];const ve=ae;let ye;e[38]!==ve?(ye={ownership:ve},e[38]=ve,e[39]=ye):ye=e[39];const{getSessionsForProject:We,getArchivedSessionsForProject:Be}=gv(ye);let Ae;e[40]!==z||e[41]!==oe||e[42]!==K||e[43]!==f||e[44]!==Be||e[45]!==We||e[46]!==n.availableWorktreesByProject||e[47]!==n.lastRepoStatus||e[48]!==n.projectRepoStatus||e[49]!==n.projectRootBranches||e[50]!==n.projects||e[51]!==r.hasSessionSearchQuery||e[52]!==r.normalizedSessionSearchQuery?(Ae={normalizedProjects:n.projects,getSessionsForProject:We,getArchivedSessionsForProject:Be,availableWorktreesByProject:n.availableWorktreesByProject,projectRepoStatus:n.projectRepoStatus,projectRootBranches:n.projectRootBranches,lastRepoStatus:n.lastRepoStatus,buildGroupedSessions:oe,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,filterSessionNodesForSearch:K,buildGroupSearchText:z,foldersMap:f},e[40]=z,e[41]=oe,e[42]=K,e[43]=f,e[44]=Be,e[45]=We,e[46]=n.availableWorktreesByProject,e[47]=n.lastRepoStatus,e[48]=n.projectRepoStatus,e[49]=n.projectRootBranches,e[50]=n.projects,e[51]=r.hasSessionSearchQuery,e[52]=r.normalizedSessionSearchQuery,e[53]=Ae):Ae=e[53];const{projectSections:X,groupSearchDataByGroup:Oe,sectionsForRender:Fe,flatSectionsForRender:_}=xv(Ae),ue=ua(),ke=`session-collection-expansion:${c.useId()}`;let je,Ke;e[54]!==ue||e[55]!==ke||e[56]!==X||e[57]!==b.collapsedGroups||e[58]!==b.collapsedProjects||e[59]!==r.activeProjectId?(je=()=>(ue.setBootstrapDemand(ke,bu({projectSections:X,activeProjectId:r.activeProjectId,collapsedProjects:b.collapsedProjects,collapsedGroups:b.collapsedGroups,currentDirectory:null,currentSessionDirectory:null})),()=>ue.clearBootstrapDemand(ke)),Ke=[ue,ke,X,b.collapsedProjects,b.collapsedGroups,r.activeProjectId],e[54]=ue,e[55]=ke,e[56]=X,e[57]=b.collapsedGroups,e[58]=b.collapsedProjects,e[59]=r.activeProjectId,e[60]=je,e[61]=Ke):(je=e[60],Ke=e[61]),c.useEffect(je,Ke);const se=r.useGroupedSections?Fe:_;let Ie;e[62]!==se||e[63]!==r.showInlineArchived?(Ie=r.showInlineArchived?se:se.map(tj),e[62]=se,e[63]=r.showInlineArchived,e[64]=Ie):Ie=e[64];const Ye=Ie;let ee;e[65]!==_?(ee=Mt=>_.find(Jt=>Jt.project.id===Mt)?.groups.find(sj)?.folderScopes??[],e[65]=_,e[66]=ee):ee=e[66];const Ee=ee;let Ge;e[67]===Symbol.for("react.memo_cache_sentinel")?(Ge=new Map,e[67]=Ge):Ge=e[67];const ze=c.useRef(Ge);let $e;e[68]!==X||e[69]!==r.isDesktopShellRuntime||e[70]!==r.stickyZoneHeaders?($e={enabled:r.stickyZoneHeaders,isDesktopShellRuntime:r.isDesktopShellRuntime,projectSections:X,projectHeaderSentinelRefs:ze},e[68]=X,e[69]=r.isDesktopShellRuntime,e[70]=r.stickyZoneHeaders,e[71]=$e):$e=e[71];const _e=x2($e);let Xe;e[72]!==x||e[73]!==y.hasAuthoritativeGlobalSessions||e[74]!==h||e[75]!==f||e[76]!==ve||e[77]!==n.projects||e[78]!==r.isSessionsLoading||e[79]!==r.isWorktreeTopologyLoading||e[80]!==r.unresolvedWorktreeProjectPaths?(Xe={enabled:!0,normalizedProjects:n.projects,ownership:ve,isSessionsLoading:r.isSessionsLoading,hasAuthoritativeGlobalSessions:y.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:r.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:r.unresolvedWorktreeProjectPaths,foldersMap:f,createFolder:h,addSessionToFolder:x},e[72]=x,e[73]=y.hasAuthoritativeGlobalSessions,e[74]=h,e[75]=f,e[76]=ve,e[77]=n.projects,e[78]=r.isSessionsLoading,e[79]=r.isWorktreeTopologyLoading,e[80]=r.unresolvedWorktreeProjectPaths,e[81]=Xe):Xe=e[81],FS(Xe);const{github:ct}=xn(),Nt=Hn(nj),At=Hn(rj),Le=Ws(oj),_t=Ws(ij),mt=Ws(aj);let Rt;e[82]===Symbol.for("react.memo_cache_sentinel")?(Rt=new Set,e[82]=Rt):Rt=e[82];const Dt=c.useRef(Rt);let xt;e[83]!==Le||e[84]!==ct||e[85]!==At||e[86]!==Nt||e[87]!==X||e[88]!==b.collapsedProjects||e[89]!==mt||e[90]!==_t||e[91]!==n.gitBranches?(xt=()=>{if(!ct||!At||!Nt?.connected)return;const Mt=new Map,Et=Date.now();X.forEach(Jt=>{b.collapsedProjects.has(Jt.project.id)||Jt.groups.forEach(hs=>{if(hs.isArchivedBucket||hs.isMain)return;const as=yt(hs.directory??null),ps=hs.branch?.trim()||n.gitBranches.get(as||"")?.trim();if(!as||!ps)return;const ys=$o(as,ps),rs=Ws.getState().entries[ys],yn=rs?.status?.pr?.state==="closed"||rs?.status?.pr?.state==="merged",En=`${as}::${ps}`,Rn=Math.max(rs?.lastRefreshAt??0,rs?.lastDiscoveryPollAt??0),Mn=!!(rs?.isInitialStatusResolved&&(!rs.status?.pr||yn)&&(!Dt.current.has(En)||Et-Rn>=z2));(!rs||!rs.isInitialStatusResolved||Mn)&&(Mn&&Dt.current.add(En),Mt.set(ys,{directory:as,branch:ps}))})}),Mt.forEach((Jt,hs)=>{Le(hs),_t(hs,{...Jt,remoteName:null,canShow:!0,github:ct,githubAuthChecked:At,githubConnected:Nt.connected})}),Mt.size&&mt([...Mt.values()],{silent:!0,markInitialResolved:!0})},e[83]=Le,e[84]=ct,e[85]=At,e[86]=Nt,e[87]=X,e[88]=b.collapsedProjects,e[89]=mt,e[90]=_t,e[91]=n.gitBranches,e[92]=xt):xt=e[92];const we=Nt?.connected;let dt;e[93]!==Le||e[94]!==ct||e[95]!==At||e[96]!==X||e[97]!==b.collapsedProjects||e[98]!==mt||e[99]!==_t||e[100]!==we||e[101]!==n.gitBranches?(dt=[Le,ct,At,we,X,b.collapsedProjects,mt,_t,n.gitBranches],e[93]=Le,e[94]=ct,e[95]=At,e[96]=X,e[97]=b.collapsedProjects,e[98]=mt,e[99]=_t,e[100]=we,e[101]=n.gitBranches,e[102]=dt):dt=e[102],c.useEffect(xt,dt);let et;e[103]!==y.orderedSessions?(et=new Map(y.orderedSessions.map(lj)),e[103]=y.orderedSessions,e[104]=et):et=e[104];const qe=et;let kt;if(e[105]!==w||e[106]!==Ye){let Mt;e[108]!==w?(Mt=Et=>{const Jt=w(Et.project.id,Et.groups);return Jt===Et.groups?Et:{...Et,groups:Jt}},e[108]=w,e[109]=Mt):Mt=e[109],kt=Ye.map(Mt),e[105]=w,e[106]=Ye,e[107]=kt}else kt=e[107];const wt=kt;let jt;e[110]!==X||e[111]!==E||e[112]!==R||e[113]!==r.activeProjectId?(jt=null,R&&(X.some(Mt=>Mt.project.id===E)?jt=E:X.some(Mt=>Mt.project.id===r.activeProjectId)?jt=r.activeProjectId:jt=X[0]?.project.id??null),e[110]=X,e[111]=E,e[112]=R,e[113]=r.activeProjectId,e[114]=jt):jt=e[114];const Ut=R&&!r.useGroupedSections?20:void 0;let st;e[115]!==o||e[116]!==y.pinnedSessionIds||e[117]!==F||e[118]!==ne||e[119]!==Q||e[120]!==W||e[121]!==fe||e[122]!==G||e[123]!==Oe||e[124]!==l||e[125]!==b.collapsedGroups||e[126]!==d.allowReselect||e[127]!==d.isSessionSearchOpen||e[128]!==d.onSessionSelected||e[129]!==d.sessionSearchQuery||e[130]!==d.setIsSessionSearchOpen||e[131]!==d.setSessionSearchQuery||e[132]!==qe||e[133]!==Ut||e[134]!==xe||e[135]!==r.activeProjectId||e[136]!==r.hasSessionSearchQuery||e[137]!==r.hideDirectoryControls||e[138]!==r.mobileVariant||e[139]!==r.normalizedSessionSearchQuery?(st={hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,groupSearchDataByGroup:Oe,collapsedGroups:b.collapsedGroups,hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:o,activeProjectId:r.activeProjectId,notifyOnSubtasks:l,pinnedSessionIds:y.pinnedSessionIds,sessionOrderIndex:qe,expandedParents:fe,editingId:W,editTitle:Q,copiedSessionId:F,sessionBatchSize:Ut,setEditingId:te,setEditTitle:me,toggleParent:xe,allowReselect:d.allowReselect,onSessionSelected:d.onSessionSelected,isSessionSearchOpen:d.isSessionSearchOpen,sessionSearchQuery:d.sessionSearchQuery,setSessionSearchQuery:d.setSessionSearchQuery,setIsSessionSearchOpen:d.setIsSessionSearchOpen,deleteSessionConfirm:ne,setDeleteSessionConfirm:ie,startFolderRename:le,setCopiedSessionId:Z,folderRename:G,setFolderRenameDraft:be,clearFolderRename:De},e[115]=o,e[116]=y.pinnedSessionIds,e[117]=F,e[118]=ne,e[119]=Q,e[120]=W,e[121]=fe,e[122]=G,e[123]=Oe,e[124]=l,e[125]=b.collapsedGroups,e[126]=d.allowReselect,e[127]=d.isSessionSearchOpen,e[128]=d.onSessionSelected,e[129]=d.sessionSearchQuery,e[130]=d.setIsSessionSearchOpen,e[131]=d.setSessionSearchQuery,e[132]=qe,e[133]=Ut,e[134]=xe,e[135]=r.activeProjectId,e[136]=r.hasSessionSearchQuery,e[137]=r.hideDirectoryControls,e[138]=r.mobileVariant,e[139]=r.normalizedSessionSearchQuery,e[140]=st):st=e[140];const rt=st;let Ct;e[141]!==u.openNewSessionDraft||e[142]!==u.setActiveProjectIdOnly||e[143]!==u.setSessionSwitcherOpen||e[144]!==g?(Ct={showMoreGroupSessions:A,resetGroupSessionLimit:P,setActiveProjectIdOnly:u.setActiveProjectIdOnly,setSessionSwitcherOpen:u.setSessionSwitcherOpen,openNewSessionDraft:u.openNewSessionDraft,onToggleCollapsedGroup:g},e[141]=u.openNewSessionDraft,e[142]=u.setActiveProjectIdOnly,e[143]=u.setSessionSwitcherOpen,e[144]=g,e[145]=Ct):Ct=e[145];const It=Ct;let Bt;e:{if(n.isVSCode){Bt=null;break e}let Mt;e[146]!==y.chatSessions||e[147]!==r.homeDirectory?(Mt=km(r.homeDirectory)??y.chatSessions.map(cj).find(Boolean)??null,e[146]=y.chatSessions,e[147]=r.homeDirectory,e[148]=Mt):Mt=e[148];const Et=Mt;if(!Et){Bt=null;break e}let Jt;if(e[149]!==Et||e[150]!==y.chatSessions){const ys=[Et,...y.chatSessions.map(dj).filter(Boolean)];let rs;e[152]!==ys?(rs=new Set(ys),e[152]=ys,e[153]=rs):rs=e[153],Jt=Array.from(rs).filter(uj).map(fj),e[149]=Et,e[150]=y.chatSessions,e[151]=Jt}else Jt=e[151];const hs=Jt;let as;if(e[154]!==y.chatSessions||e[155]!==y.childrenMap){let ys;e[157]!==y.childrenMap?(ys=rs=>({session:rs,children:(y.childrenMap.get(rs.id)??[]).filter(hj).map(pj),worktree:null}),e[157]=y.childrenMap,e[158]=ys):ys=e[158],as=y.chatSessions.filter(mj).map(ys),e[154]=y.chatSessions,e[155]=y.childrenMap,e[156]=as}else as=e[156];let ps;e[159]!==Et||e[160]!==hs||e[161]!==as?(ps={id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Et,folderScopeKey:Et,folderScopes:hs,draftTarget:"chat",sessions:as},e[159]=Et,e[160]=hs,e[161]=as,e[162]=ps):ps=e[162],Bt=ps}const Tt=Bt;let ns;e[163]!==Tt||e[164]!==It||e[165]!==rt||e[166]!==ce?(ns=()=>Tt?s.jsx(xo,{...rt,...It,group:Tt,groupKey:"managed-chats",projectId:null,hideGroupLabel:!0,sessionBatchSize:20,scrollContainerRef:void 0,openSidebarMenuKey:ce,setOpenSidebarMenuKey:H}):null,e[163]=Tt,e[164]=It,e[165]=rt,e[166]=ce,e[167]=ns):ns=e[167];const Lt=ns;let zt;e[168]!==u||e[169]!==r.mobileVariant?(zt=()=>{Ce.getState().closeMainSurfaces(),r.mobileVariant&&u.setSessionSwitcherOpen(!1),u.openNewSessionDraft({selectedProjectId:Cm,directoryOverride:null})},e[168]=u,e[169]=r.mobileVariant,e[170]=zt):zt=e[170];const qt=zt;let ms;e[171]!==o||e[172]!==y.chatSessions||e[173]!==y.childrenMap||e[174]!==y.pinnedSessionIds||e[175]!==F||e[176]!==ne||e[177]!==Q||e[178]!==W||e[179]!==fe||e[180]!==qt||e[181]!==l||e[182]!==ce||e[183]!==L||e[184]!==Lt||e[185]!==d.allowReselect||e[186]!==d.isSessionSearchOpen||e[187]!==d.onSessionSelected||e[188]!==d.sessionSearchQuery||e[189]!==d.setIsSessionSearchOpen||e[190]!==d.setSessionSearchQuery||e[191]!==T||e[192]!==R||e[193]!==xe||e[194]!==n.availableWorktreesByProject||e[195]!==n.gitBranches||e[196]!==n.isVSCode||e[197]!==n.projects||e[198]!==r.hasSessionSearchQuery||e[199]!==r.homeDirectory||e[200]!==r.isDesktopShellRuntime||e[201]!==r.mobileVariant||e[202]!==r.normalizedSessionSearchQuery?(ms=n.isVSCode?null:s.jsx(O2,{projects:n.projects,availableWorktreesByProject:n.availableWorktreesByProject,gitBranches:n.gitBranches,homeDirectory:r.homeDirectory,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,isDesktopShellRuntime:r.isDesktopShellRuntime,sessions:L,childrenMap:y.childrenMap,pinnedSessionIds:y.pinnedSessionIds,recentSessions:L,expandedParents:fe,notifyOnSubtasks:l,editingId:W,editTitle:Q,copiedSessionId:F,openSidebarMenuKey:ce,mobileVariant:r.mobileVariant,alwaysShowActions:o,setEditingId:te,setEditTitle:me,toggleParent:xe,setOpenSidebarMenuKey:H,allowReselect:d.allowReselect,onSessionSelected:d.onSessionSelected,isSessionSearchOpen:d.isSessionSearchOpen,sessionSearchQuery:d.sessionSearchQuery,setSessionSearchQuery:d.setSessionSearchQuery,setIsSessionSearchOpen:d.setIsSessionSearchOpen,deleteSessionConfirm:ne,setDeleteSessionConfirm:ie,startFolderRename:le,setCopiedSessionId:Z,chatSessions:y.chatSessions,renderChatsSection:Lt,onNewChat:qt,showRecentSection:T&&!R}),e[171]=o,e[172]=y.chatSessions,e[173]=y.childrenMap,e[174]=y.pinnedSessionIds,e[175]=F,e[176]=ne,e[177]=Q,e[178]=W,e[179]=fe,e[180]=qt,e[181]=l,e[182]=ce,e[183]=L,e[184]=Lt,e[185]=d.allowReselect,e[186]=d.isSessionSearchOpen,e[187]=d.onSessionSelected,e[188]=d.sessionSearchQuery,e[189]=d.setIsSessionSearchOpen,e[190]=d.setSessionSearchQuery,e[191]=T,e[192]=R,e[193]=xe,e[194]=n.availableWorktreesByProject,e[195]=n.gitBranches,e[196]=n.isVSCode,e[197]=n.projects,e[198]=r.hasSessionSearchQuery,e[199]=r.homeDirectory,e[200]=r.isDesktopShellRuntime,e[201]=r.mobileVariant,e[202]=r.normalizedSessionSearchQuery,e[203]=ms):ms=e[203];const Qt=ms,Me=!!Qt;let Ve;e[204]!==W||e[205]!==ce||e[206]!==N?(Ve={editingId:W,openSidebarMenuKey:ce,setOpenSidebarMenuKey:H,visibleSessionCountByGroup:N},e[204]=W,e[205]=ce,e[206]=N,e[207]=Ve):Ve=e[207];let Ze;e[208]!==rt||e[209]!==wt||e[210]!==X||e[211]!==Qt||e[212]!==jt||e[213]!==R||e[214]!==_e||e[215]!==Me||e[216]!==Ve||e[217]!==n.projectRepoStatus||e[218]!==r.activeProjectId||e[219]!==r.emptyState||e[220]!==r.searchEmptyState?(Ze={topContent:Qt,hasSharedSessions:Me,sectionsForRender:wt,projectSections:X,activeProjectId:r.activeProjectId,singleProjectMode:R,singleProjectId:jt,emptyState:r.emptyState,searchEmptyState:r.searchEmptyState,projectRepoStatus:n.projectRepoStatus,stuckProjectHeaders:_e,projectHeaderSentinelRefs:ze,state:Ve,groupProps:rt},e[208]=rt,e[209]=wt,e[210]=X,e[211]=Qt,e[212]=jt,e[213]=R,e[214]=_e,e[215]=Me,e[216]=Ve,e[217]=n.projectRepoStatus,e[218]=r.activeProjectId,e[219]=r.emptyState,e[220]=r.searchEmptyState,e[221]=Ze):Ze=e[221];const at=Ze;let ut;e[222]!==o||e[223]!==b.collapsedProjects||e[224]!==r.hasSessionSearchQuery||e[225]!==r.hideDirectoryControls||e[226]!==r.homeDirectory||e[227]!==r.isDesktopShellRuntime||e[228]!==r.mobileVariant||e[229]!==r.normalizedSessionSearchQuery||e[230]!==r.projectSortOrder||e[231]!==r.showOnlyMainWorkspace||e[232]!==r.stickyZoneHeaders?(ut={homeDirectory:r.homeDirectory,collapsedProjects:b.collapsedProjects,showOnlyMainWorkspace:r.showOnlyMainWorkspace,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,hideDirectoryControls:r.hideDirectoryControls,isDesktopShellRuntime:r.isDesktopShellRuntime,stickyZoneHeaders:r.stickyZoneHeaders,mobileVariant:r.mobileVariant,alwaysShowActions:o,projectSortOrder:r.projectSortOrder},e[222]=o,e[223]=b.collapsedProjects,e[224]=r.hasSessionSearchQuery,e[225]=r.hideDirectoryControls,e[226]=r.homeDirectory,e[227]=r.isDesktopShellRuntime,e[228]=r.mobileVariant,e[229]=r.normalizedSessionSearchQuery,e[230]=r.projectSortOrder,e[231]=r.showOnlyMainWorkspace,e[232]=r.stickyZoneHeaders,e[233]=ut):ut=e[233];const St=ut;let nt;e[234]!==It||e[235]!==u.openNewSessionDraft||e[236]!==u.openNewWorktreeDialog||e[237]!==u.openProjectEditDialog||e[238]!==u.openWorktreesPage||e[239]!==u.removeProject||e[240]!==u.renderProjectStatusIndicator||e[241]!==u.reorderProjects||e[242]!==u.setActiveProjectIdOnly||e[243]!==u.setSessionSwitcherOpen||e[244]!==S||e[245]!==U||e[246]!==m?(nt={group:It,toggleProject:m,setActiveProjectIdOnly:u.setActiveProjectIdOnly,setSessionSwitcherOpen:u.setSessionSwitcherOpen,openNewSessionDraft:u.openNewSessionDraft,openNewWorktreeDialog:u.openNewWorktreeDialog,openWorktreesPage:u.openWorktreesPage,openProjectEditDialog:u.openProjectEditDialog,removeProject:u.removeProject,reorderProjects:u.reorderProjects,setGroupOrderByProject:S,renderProjectStatusIndicator:u.renderProjectStatusIndicator,setSingleProjectId:U},e[234]=It,e[235]=u.openNewSessionDraft,e[236]=u.openNewWorktreeDialog,e[237]=u.openProjectEditDialog,e[238]=u.openWorktreesPage,e[239]=u.removeProject,e[240]=u.renderProjectStatusIndicator,e[241]=u.reorderProjects,e[242]=u.setActiveProjectIdOnly,e[243]=u.setSessionSwitcherOpen,e[244]=S,e[245]=U,e[246]=m,e[247]=nt):nt=e[247];const Ft=nt;let Xt;e[248]!==i.initialActiveSessionByProject||e[249]!==i.openNewSessionDraft||e[250]!==i.persistActiveSessionByProject||e[251]!==i.setSessionSwitcherOpen||e[252]!==ve.bySessionId||e[253]!==X||e[254]!==he||e[255]!==r.activeProjectId||e[256]!==r.mobileVariant?(Xt=s.jsx(WS,{projectSections:X,activeProjectId:r.activeProjectId,initialActiveSessionByProject:i.initialActiveSessionByProject,persistActiveSessionByProject:i.persistActiveSessionByProject,mobileVariant:r.mobileVariant,openNewSessionDraft:i.openNewSessionDraft,setSessionSwitcherOpen:i.setSessionSwitcherOpen,sessionOwnerBySessionId:ve.bySessionId,handleSessionSelect:he}),e[248]=i.initialActiveSessionByProject,e[249]=i.openNewSessionDraft,e[250]=i.persistActiveSessionByProject,e[251]=i.setSessionSwitcherOpen,e[252]=ve.bySessionId,e[253]=X,e[254]=he,e[255]=r.activeProjectId,e[256]=r.mobileVariant,e[257]=Xt):Xt=e[257];let os;e[258]!==y.orderedSessions||e[259]!==Ne||e[260]!==L?(os=s.jsx(kv,{sortedSessions:y.orderedSessions,recentSessions:L,prefetchSession:Ne}),e[258]=y.orderedSessions,e[259]=Ne,e[260]=L,e[261]=os):os=e[261];let Ss;e[262]!==Ft||e[263]!==at||e[264]!==St?(Ss=s.jsx(p2,{model:at,view:St,actions:Ft}),e[262]=Ft,e[263]=at,e[264]=St,e[265]=Ss):Ss=e[265];const qs=W!==null;let gs;e[266]!==Ee||e[267]!==qs?(gs=s.jsx(k2,{getFolderScopesForProject:Ee,isInlineEditing:qs,startFolderRename:le}),e[266]=Ee,e[267]=qs,e[268]=gs):gs=e[268];let is;return e[269]!==Xt||e[270]!==os||e[271]!==Ss||e[272]!==gs?(is=s.jsxs(s.Fragment,{children:[Xt,os,Ss,gs]}),e[269]=Xt,e[270]=os,e[271]=Ss,e[272]=gs,e[273]=is):is=e[273],is},U2=t=>{const e=Je.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(V2,{...t}):null,e[0]=t,e[1]=n):n=e[1],n};function H2(t){return t.foldersMap}function K2(t){return t.createFolder}function G2(t){return t.addSessionToFolder}function q2(t){return t.showRecentSection}function Q2(t){return t.projectDisplayMode}function Y2(t){return t.singleProjectId}function X2(t){return t.setSingleProjectId}function J2(t){return t.setCurrentSession}function Z2(t){return t.isArchivedBucket}function ej(t){return!t.isArchivedBucket}function tj(t){return t.groups.some(Z2)?{...t,groups:t.groups.filter(ej)}:t}function sj(t){return!t.isArchivedBucket}function nj(t){return t.status}function rj(t){return t.hasChecked}function oj(t){return t.ensureEntry}function ij(t){return t.setParams}function aj(t){return t.refreshTargets}function lj(t,e){return[t.id,e]}function cj(t){return ed(t.directory)}function dj(t){return yt(t.directory??null)}function uj(t){return!!t}function fj(t){return{scopeKey:t,directory:t}}function mj(t){return!t.time?.archived&&W2(t)}function hj(t){return!t.time?.archived}function pj(t){return{session:t,children:[],worktree:null}}const Cu=(t,e,n)=>{const r=new Set;for(const i of t){const o=yt(i.path)?.toLowerCase();o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=yt(o.path)?.toLowerCase();l&&r.add(l)}return r},Ql="oc.sessions.activeSessionByProject",gj=[],bj=Pd(ur(),ur().min(1).catch("")),xj=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{pi("react.session_sidebar_render"),sn("ui.session_sidebar.render"),sn(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),sn(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=ft(),[a,d]=c.useState(!1),[u,f]=c.useState(""),h=c.useRef(null),x=c.useRef(null),[b,w]=c.useState(null),S=c.useMemo(()=>vo(),[]),[g,m]=c.useState(new Map),p=Ce(we=>we.isNewWorktreeDialogOpen),y=Ce(we=>we.setNewWorktreeDialogOpen),[v,N]=c.useState(!1),C=c.useMemo(()=>{try{const we=S.getItem(Ql);if(!we)return new Map;const dt=bj.safeParse(JSON.parse(we));if(!dt.success)return new Map;const et=new Map;return Object.entries(dt.data).forEach(([qe,kt])=>{kt&&et.set(qe,kt)}),et}catch{return new Map}},[S]),k=c.useCallback(we=>{try{S.setItem(Ql,JSON.stringify(Object.fromEntries(we.entries())))}catch{}},[S]),[A,D]=c.useState(new Map),P=Zt(we=>we.homeDirectory),T=Vt(we=>we.projects),$=Vt(we=>we.activeProjectId),E=Vt(we=>we.removeProject),U=Vt(we=>we.setActiveProjectIdOnly),I=Vt(we=>we.updateProjectMeta),B=Vt(we=>we.reorderProjects),R=Ce(we=>we.setSettingsDialogOpen),j=Ce(we=>we.toggleHelpDialog),M=Ce(we=>we.setAboutDialogOpen),L=Ce(we=>we.setSessionSwitcherOpen),W=Ce(we=>we.setScheduledTasksDialogOpen),te=Ce(we=>we.setArchivePageOpen),Q=Ce(we=>we.setWorktreesPageProjectId),me=Ce(we=>we.openMultiRunLauncher),ce=Ce(we=>we.notifyOnSubtasks),H=na(u,120),ne=c.useMemo(()=>H.trim().toLowerCase(),[H]),ie=ne.length>0;aS({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:x,sessionSearchContainerRef:h});const F=zc(t),Z=c.useMemo(()=>bn(),[]),G=Qe(we=>we.setCurrentSession),V=Qe(we=>we.worktreeMetadata),Y=Qe(we=>we.availableWorktreesByProject),le=Qe(we=>we.openNewSessionDraft),pe=c.useMemo(()=>Cu(T,Y,{includeWorktrees:!Z}),[Y,Z,T]),be=c.useCallback(we=>{Ce.getState().closeMainSurfaces(),le(we),Z&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[Z,le]),Se=Nr(Kn(we=>({checkForUpdates:we.checkForUpdates,available:we.available,runtimeType:we.runtimeType,info:we.info,downloading:we.downloading,downloaded:we.downloaded,progress:we.progress,error:we.error,downloadUpdate:we.downloadUpdate,restartToUpdate:we.restartToUpdate}))),De=ks(),fe=c.useMemo(()=>`${De}|${T.map(we=>`${we.id}:${yt(we.path)??""}`).join("|")}`,[T,De]),[xe,ge]=c.useState(Z?fe:null),[re,he]=c.useReducer(we=>we+1,0),Ne=!Z&&xe!==fe,[de,oe]=c.useState(new Set);c.useEffect(()=>{let we=!1;return(async()=>{const et=De,qe=Vt.getState().projects;if(qe.length===0||Z){we||(oe(new Set),ge(fe));return}const kt=Qe.getState().availableWorktreesByProject,wt=new Map(kt),jt=new Set,Ut=3;let st=0;const rt=Array.from({length:Ut},async()=>{for(;;){const Tt=st;if(st+=1,Tt>=qe.length)return;const ns=qe[Tt],Lt=yt(ns.path);if(Lt)try{const zt=await yi(async()=>Pn.getState().directories.get(Lt)?.isGitRepo??await sd(Lt)?Am({id:ns.id,path:Lt}):null);if(zt===null){wt.delete(Lt);continue}if(we)return;zt.length===0?wt.delete(Lt):wt.set(Lt,zt)}catch{jt.add(Lt)}}});if(await Promise.all(rt),we||ks()!==et)return;const Ct=new Set(qe.map(Tt=>yt(Tt.path)).filter(Boolean));for(const Tt of wt.keys())Ct.has(Tt)||wt.delete(Tt);const It=Dm(qe,wt),Bt=[...It.values()].flat();g2(Bt.map(Tt=>Tt.path),Date.now()),Pm(It,kt)||Qe.setState({availableWorktrees:Bt,availableWorktreesByProject:It}),oe(jt),ge(fe)})(),()=>{we=!0}},[Z,fe,De,re]),c.useEffect(()=>{if(!Z)return Vr(we=>{we.type==="session-created"&&he()})},[Z]);const K=c.useMemo(()=>cn(),[]),{isTablet:z}=Tn(),ae=e||z,ve=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),ye=c.useMemo(()=>T.find(we=>we.id===b)??null,[T,b]),We=c.useCallback(we=>{b&&I(b,{label:we.label,icon:we.icon,color:we.color,iconBackground:we.iconBackground,defaultModel:we.defaultModel??null})},[b,I]),Be=c.useCallback(()=>{y(!0)},[y]),Ae=c.useCallback(()=>{const we=Nr.getState();if(we.available&&we.info){N(!0);return}Se.checkForUpdates().then(()=>{const{available:dt,error:et}=Nr.getState();if(et){Re.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:et});return}if(!dt){Re.success(l("sessions.sidebar.updateCheck.latestVersion"));return}N(!0)})},[l,Se]),X=c.useCallback(()=>{e&&L(!1),R(!0)},[e,L,R]),Oe=Se.available&&(Se.runtimeType==="desktop"||Se.runtimeType==="web"),Fe=c.useCallback(()=>{ln.requestDirectoryDialog()},[]),_=c.useMemo(()=>T.flatMap(we=>{const dt=yt(we.path);return dt?[{id:we.id,path:we.path,label:we.label,normalizedPath:dt,icon:we.icon??void 0,color:we.color??void 0,iconImage:we.iconImage??void 0,iconBackground:we.iconBackground??void 0,addedAt:we.addedAt,lastOpenedAt:we.lastOpenedAt,sidebarCollapsed:we.sidebarCollapsed}]:[]}),[T]),ue=c.useMemo(()=>_.map(we=>we.normalizedPath),[_]),ke=Nm(t?ue:gj);pS({enabled:t,normalizedProjects:_,gitRepoStatus:ke,setProjectRepoStatus:m,setProjectRootBranches:D});const je=Qe(we=>we.isLoading),Ke=c.useRef(!1);$&&g.has($)&&(Ke.current=!!g.get($));const se=us(we=>we.showArchivedSessions),Ie=us(we=>we.projectSortOrder),Ye=us(we=>we.stickyZoneHeaders),ee=Vt(we=>we.manualProjectOrder),Ee={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:z,projects:T,activeProjectId:$,manualProjectOrder:ee,worktreeMetadata:V,availableWorktreesByProject:Y,gitBranches:F,gitRepoStatus:ke,updateStore:Se,showArchivedSessions:se,projectSortOrder:Ie,projectRepoStatus:g,projectRootBranches:A,resolvedWorktreeTopologyKey:xe,unresolvedWorktreeProjectPaths:de,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:b,updateDialogOpen:v},Ge=c.useRef(null),ze=Ge.current;if(ze){let we=!1;for(const dt of Object.keys(Ee))Object.is(ze[dt],Ee[dt])||(sn(`ui.session_sidebar.source.${dt}`),we=!0);we||sn("ui.session_sidebar.source.parent_or_context")}Ge.current=Ee;const $e=c.useMemo(()=>{const we=[..._];switch(Ie){case"a-z":we.sort((dt,et)=>{const qe=(dt.label||dt.path).toLowerCase(),kt=(et.label||et.path).toLowerCase();return qe.localeCompare(kt)});break;case"z-a":we.sort((dt,et)=>{const qe=(dt.label||dt.path).toLowerCase();return(et.label||et.path).toLowerCase().localeCompare(qe)});break;case"date-added":we.sort((dt,et)=>(et.addedAt??0)-(dt.addedAt??0));break;case"recent":we.sort((dt,et)=>(et.lastOpenedAt??0)-(dt.lastOpenedAt??0));break;case"manual":{const dt=new Map(ee.map((et,qe)=>[et,qe]));we.sort((et,qe)=>{const kt=dt.get(et.id)??1/0,wt=dt.get(qe.id)??1/0;return kt-wt});break}}return we},[_,Ie,ee]),_e=uS({isVSCode:Z,projects:$e}),Xe=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noMatches.description")})]}),[l]),ct=Z&&se,At=us(we=>we.sessionGroupingMode)==="by-worktree"&&!Z,mt=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",Rt="h-4.5 w-4.5",Dt=c.useCallback(()=>{e&&L(!1),me()},[e,me,L]),xt=c.useCallback(()=>{Ce.getState().closeMainSurfaces(),e&&L(!1),le()},[e,le,L]);return s.jsx(vi,{delay:0,closeDelay:150,timeout:600,children:s.jsxs("div",{ref:h,className:Pe("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[!i&&!Z?s.jsx(BS,{onNewSession:xt}):null,s.jsx(vS,{hideDirectoryControls:i,showProjectDisplayControls:!Z,showRecentControls:!Z,handleOpenDirectoryDialog:Fe,onOpenScheduled:()=>{e&&L(!1),W(!0)},onOpenMultiRun:Dt,canOpenMultiRun:T.length>0,onOpenArchive:()=>{e&&L(!1),te(!0)},headerActionIconClass:Rt,headerActionButtonClass:mt,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:x,sessionSearchQuery:u,setSessionSearchQuery:f,hasSessionSearchQuery:ie,searchMatchCount:0,collapseAllProjects:_e.actions.collapseAllProjects,expandAllProjects:_e.actions.expandAllProjects}),s.jsx(U2,{topology:{projects:$e,availableWorktreesByProject:Y,knownDirectories:pe,isVSCode:Z,worktreeMetadata:V,gitBranches:F,projectRepoStatus:g,projectRootBranches:A,lastRepoStatus:Ke.current},view:{isVisible:t,hasSessionSearchQuery:ie,normalizedSessionSearchQuery:ne,activeProjectId:$,showInlineArchived:ct,useGroupedSections:At,homeDirectory:P,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:K,stickyZoneHeaders:Ye,projectSortOrder:Ie,emptyState:ve,searchEmptyState:Xe,isSessionsLoading:je,isWorktreeTopologyLoading:Ne,unresolvedWorktreeProjectPaths:de,projectView:_e.state},actions:{rowActions:{allowReselect:r,onSessionSelected:n,isSessionSearchOpen:a,sessionSearchQuery:u,setSessionSearchQuery:f,setIsSessionSearchOpen:d},alwaysShowActions:ae,notifyOnSubtasks:ce,setActiveProjectIdOnly:U,setSessionSwitcherOpen:L,openNewSessionDraft:be,openNewWorktreeDialog:Be,openWorktreesPage:we=>{e&&L(!1),Q(we)},openProjectEditDialog:w,removeProject:E,reorderProjects:B,initialActiveSessionByProject:C,persistActiveSessionByProject:k,projectViewActions:_e.actions}}),s.jsx(_S,{onOpenSettings:X,onOpenShortcuts:j,onOpenAbout:()=>M(!0),onOpenUpdate:Ae,showRuntimeButtons:!Z,showUpdateButton:Oe}),s.jsx(ud,{open:v,onOpenChange:N,info:Se.info,downloading:Se.downloading,downloaded:Se.downloaded,progress:Se.progress,error:Se.error,onDownload:Se.downloadUpdate,onRestart:Se.restartToUpdate,runtimeType:Se.runtimeType}),s.jsx(wS,{open:!!ye,onOpenChange:we=>{we||w(null)},project:ye,onSave:We}),s.jsx(Wh,{open:p,onOpenChange:y,onWorktreeCreated:(we,dt)=>{if(Ce.getState().closeMainSurfaces(),e&&L(!1),dt?.sessionId){G(dt.sessionId,we);return}le({directoryOverride:we,preserveDirectoryOverride:!0})}})]})})},yj=c.memo(xj),_n=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(/\/+$/,"")},wj=()=>{const{t}=ft(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,d]=c.useState([]),[u,f]=c.useState(!1),[h,x]=c.useState(!1),[b,w]=c.useState(!1),[S,g]=c.useState(!1),[m,p]=c.useState(new Set),y=Qe(he=>he.getWorktreeMetadata),v=Qe(he=>he.newSessionDraft),N=Qe(he=>he.setNewSessionDraftTarget),C=Qe(he=>he.setDraftBootstrapPendingDirectory),k=Im,A=Em,D=Qe(he=>he.deleteSessions),P=Qe(he=>he.archiveSessions),T=Ce(he=>he.showDeletionDialog),$=Ce(he=>he.setShowDeletionDialog),E=Zt(he=>he.currentDirectory),U=Zt(he=>he.homeDirectory),I=Zt(he=>he.isHomeReady),B=Vt(he=>he.projects),R=Vt(he=>he.activeProjectId),{isMobile:j,isTablet:M,hasTouchInput:L}=Tn(),W=j||M||L,te=c.useMemo(()=>{const Ne=(R?B.find(de=>de.id===R)??null:null)?.path??E;return tn(Ne)},[R,E,B]),Q=c.useCallback(he=>{const de=tn(he.projectDirectory)||te;return{id:(B.find(K=>tn(K.path)===de)??null)?.id??`path:${de}`,path:de}},[te,B]),me=S&&m.size>0,ce=c.useMemo(()=>{const he=o?.worktree;return he&&typeof he.branch=="string"&&he.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:Ne})=>typeof Ne.branch=="string"&&Ne.branch.trim().length>0)},[o?.worktree,a]),H=o?.mode==="worktree",ne=H,ie=b||!H||!ce,F=b||!H;c.useEffect(()=>{r||!I||B.length>0||(i(!0),n(!0))},[r,I,B.length]);const Z=c.useCallback(he=>{l({sessions:he.sessions,dateLabel:he.dateLabel,mode:he.mode??"session",worktree:he.worktree??null})},[]),G=c.useCallback(()=>{l(null),d([]),f(!1),x(!1),w(!1),g(!1),p(new Set)},[]),V=c.useCallback(async he=>{if(he.sessions.length===0)return;if(he.sessions.length===1){const K=he.sessions[0];await k(K.id)?Re.success(t("sessions.sidebar.session.delete.success")):Re.error(t("sessions.sidebar.session.delete.error"));return}const Ne=he.sessions.map(K=>K.id),{deletedIds:de,failedIds:oe}=await D(Ne);if(de.length>0){const K=oe.length>0?oe.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:oe.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:oe.length}):he.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:he.dateLabel}):void 0;Re.success(de.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:de.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:de.length}),{description:_n(K)})}oe.length>0&&Re.error(oe.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:oe.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:oe.length}),{description:_n(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[k,D,t]);c.useEffect(()=>ln.onDeleteRequest(he=>{if(!T&&(he.mode??"session")==="session"){V(he);return}Z(he)}),[Z,T,V]),c.useEffect(()=>ln.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){d([]),f(!1),x(!1),g(!1),p(new Set);return}const he=o.sessions.map(oe=>{const K=y(oe.id);return K?{session:oe,metadata:K}:null}).filter(oe=>!!oe);d(he),f(!1),g(!1),p(new Set);const Ne=new Map;if(o.worktree?.path&&Ne.set(tn(o.worktree.path),o.worktree),he.forEach(({metadata:oe})=>{oe.path&&Ne.set(tn(oe.path),oe)}),Ne.size===0){g(!0);return}let de=!1;return(async()=>{const oe=new Map,K=new Set;await Promise.all(Array.from(Ne.entries()).map(async([z,ae])=>{try{const ve=await Tm(ae.path);oe.set(z,ve),ve?.isDirty&&K.add(z)}catch{ae.status&&(oe.set(z,ae.status),ae.status.isDirty&&K.add(z))}})).catch(z=>{console.warn("Failed to inspect worktree status before deletion:",z)}),!de&&(p(K),g(!0),l(z=>{if(!z?.worktree?.path)return z;const ae=tn(z.worktree.path),ve=oe.get(ae);if(!ve)return z;const ye=z.worktree.status;return ye?.isDirty===ve.isDirty&&ye?.ahead===ve.ahead&&ye?.behind===ve.behind&&ye?.upstream===ve.upstream?z:{...z,worktree:{...z.worktree,status:ve}}}),d(z=>z.map(ae=>{const ve=tn(ae.metadata.path),ye=oe.get(ve);return ye?{session:ae.session,metadata:{...ae.metadata,status:ye}}:ae})))})(),()=>{de=!0}},[o,y]),c.useEffect(()=>{ce||f(!1)},[ce]);const Y=c.useCallback(async(he,Ne)=>{const de=u&&ce,oe=Q(he),K=tn(he.path),z=tn(oe.path);try{await Pc(oe,he,{deleteRemoteBranch:de,deleteLocalBranch:Ne});const ae=tn(v?.directoryOverride);return v?.open&&K&&ae===K&&z&&(C(null),N({projectId:oe.id,directoryOverride:z},{force:!0})),tn(E)===K&&z&&Zt.getState().setDirectory(z,{showOverlay:!1}),!0}catch(ae){return Re.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:_n(ae instanceof Error?ae.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ce,E,u,Q,v?.directoryOverride,v?.open,C,N,t]),le=c.useCallback((he,Ne)=>{const de=u&&ce;(async()=>{if(!await Y(he,Ne))return;const K=t(de?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Re.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle"),{description:_n(K)})})()},[ce,u,Y,t]),pe=c.useCallback(async()=>{if(o){w(!0);try{const he=ne,Ne=he&&u,de=he&&h;if(o.sessions.length===0&&H&&o.worktree){le(o.worktree,de),G();return}if(o.sessions.length===1){const oe=o.sessions[0];if(!(H?await A(oe.id):await k(oe.id))){Re.error(t(H?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error")),w(!1);return}const z=!H&&he?t(Ne?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;Re.success(t(H?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"),{description:_n(z),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const oe=o.sessions.map(ae=>ae.id);let K=[],z=[];if(H){const ae=await P(oe);K=ae.archivedIds,z=ae.failedIds}else{const ae=await D(oe);K=ae.deletedIds,z=ae.failedIds}if(H&&o.worktree&&z.length===0&&le(o.worktree,de),K.length>0){const ae=!H&&he?t(Ne?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,ye=[z.length>0?H?z.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToArchive",{count:z.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToArchive",{count:z.length}):z.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:z.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:z.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,ae].filter(Boolean).join(" ");Re.success(H?K.length===1?t("sessions.sidebar.bulkActions.archivedSingle",{count:K.length}):t("sessions.sidebar.bulkActions.archivedPlural",{count:K.length}):K.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:K.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:K.length}),{description:_n(ye||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(z.length>0&&(Re.error(H?z.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:z.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:z.length}):z.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:z.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:z.length}),{description:_n(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),K.length===0)){w(!1);return}}H&&o.sessions.length===1&&o.worktree&&le(o.worktree,de),G()}finally{w(!1)}}},[o,u,h,k,D,A,P,G,ne,H,le,t]),be=o?.worktree??a[0]?.metadata??null,Se=o?o.mode==="worktree"?o.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):o.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:o.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:o.sessions.length}):o.sessions.length===1?o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:o.sessions.length,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:o.sessions.length}):"",De=o?s.jsxs("div",{className:Pe(H?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:Pe(H?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[H&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),s.jsxs("ul",{className:Pe(H?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(he=>s.jsxs("li",{className:Pe(H?"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:Pe(!H&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:he.title||t("sessions.sidebar.session.untitled")})]},he.id)),o.sessions.length>5&&s.jsx("li",{className:Pe(H?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),H?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(O,{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")}),be?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:be.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:be?Tr(be.path,U):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),me&&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,fe=H?ce?s.jsxs("button",{type:"button",onClick:()=>{ie||f(he=>!he)},disabled:ie,className:Pe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ie?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[u?s.jsx(O,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(O,{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,xe=H?s.jsxs("button",{type:"button",onClick:()=>{F||x(he=>!he)},disabled:F,className:Pe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",F?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[h?s.jsx(O,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(O,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,ge=H?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:[xe,fe]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(lt,{variant:"ghost",onClick:G,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(lt,{variant:"destructive",onClick:pe,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:()=>$(!T),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":!T,children:[T?s.jsx(O,{name:"checkbox-blank",className:"size-4"}):s.jsx(O,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(lt,{variant:"ghost",onClick:G,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(lt,{variant:"destructive",onClick:pe,disabled:b,children:b?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),re=H?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[W?s.jsx(zo,{open:!!o,onClose:()=>{b||G()},title:re,footer:s.jsx("div",{className:"flex justify-end gap-2",children:ge}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[Se&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:Se}),De]})}):s.jsx(Ns,{open:!!o,onOpenChange:he=>{if(!he){if(b)return;G()}},children:s.jsxs(As,{className:Pe(H?"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(Gs,{children:[s.jsxs(Fs,{className:Pe(H&&"flex items-center gap-2"),children:[H&&s.jsx(O,{name:"delete-bin",className:"h-5 w-5"}),re]}),Se&&s.jsx(Ls,{children:Se})]}),s.jsx("div",{className:Pe(H&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:De}),s.jsx(gn,{className:"mt-2 gap-2 pt-1 pb-1",children:ge})]})}),s.jsx(Vh,{open:e,onOpenChange:n})]})};function Nu(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return Id.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function Sj(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=Id.CronExpressionParser.parse(t,r),o=[];for(let l=0;l<n;l+=1){const a=i.next();a&&o.push(a.toDate())}return o}catch{return[]}}const vj=[{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"}],jj={"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"},Wn=t=>jj[t]??t,Au=[0,1,2,3,4,5,6],Yl="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",Ki=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(Wn))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],Xl=()=>{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}`},yo=t=>{const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),i=Number(e[3]),o=new Date(n,r-1,i);return Number.isNaN(o.getTime())||o.getFullYear()!==n||o.getMonth()!==r-1||o.getDate()!==i?null:o},Jl=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},kj=(t,e,n)=>{const r=yo(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},Zl=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),Cj=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),l=(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 f=0;f<42;f+=1){const h=f-l+1;if(h<=0){const x=d+h;u.push({date:new Date(n,r-1,x),inCurrentMonth:!1});continue}if(h>a){u.push({date:new Date(n,r+1,h-a),inCurrentMonth:!1});continue}u.push({date:new Date(n,r,h),inCurrentMonth:!0})}return u},Nj=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],i=n>=12?"PM":"AM",o=n%12===0?12:n%12;return{hour24:String(n).padStart(2,"0"),hour12:String(o).padStart(2,"0"),minute:r,meridiem:i}},Fn=(t,e,n)=>{const r=Number(t),i=Number(e),o=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,l=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0;let a=o%12;return n==="PM"&&(a+=12),`${String(a).padStart(2,"0")}:${String(l).padStart(2,"0")}`},mr=(t,e)=>{const{max:n,min:r=0,loop:i=!1}=e;let o=Number.parseInt(t,10);return Number.isFinite(o)?(i?(o>n&&(o=r),o<r&&(o=n)):(o>n&&(o=n),o<r&&(o=r)),String(o).padStart(2,"0")):"00"},ec=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:mr(t,{min:1,max:12}),oo=t=>/^[0-5][0-9]$/.test(t)?t:mr(t,{max:59}),Aj=(t,e)=>mr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),tc=(t,e)=>mr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),Dj=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}},Pj=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}},Ij=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return Au.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},Tj=(t,e)=>[...t.slice(e),...t.slice(0,e)],Ts=t=>{const e=Je.c(6),{htmlFor:n,required:r,children:i}=t;let o;e[0]!==r?(o=r&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"}),e[0]=r,e[1]=o):o=e[1];let l;return e[2]!==i||e[3]!==n||e[4]!==o?(l=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,o]})}),e[2]=i,e[3]=n,e[4]=o,e[5]=l):l=e[5],l},sc=t=>{const e=Je.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:d,pmLabel:u}=t;let f;e[0]!==n?(f=Nj(n),e[0]=n,e[1]=f):f=e[1];const h=f,x=ot.useRef(null),b=ot.useRef(null),[w,S]=ot.useState(null),[g,m]=ot.useState(null),p=ot.useRef(null),y=ot.useRef(null);let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=re=>{p.current=re,S(re)},e[2]=v):v=e[2];const N=v;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=re=>{y.current=re,m(re)},e[3]=C):C=e[3];const k=C,A=Fj,D=Lj,P=$j;let T;e[4]!==r||e[5]!==h.meridiem||e[6]!==h.minute||e[7]!==i?(T=re=>{const he=re.replace(/\D/g,"").slice(0,2);N(he),he.length===2&&(r(i?P(A(he),h.minute):Fn(ec(he),h.minute,h.meridiem)),N(null),b.current?.focus())},e[4]=r,e[5]=h.meridiem,e[6]=h.minute,e[7]=i,e[8]=T):T=e[8];const $=T;let E;e[9]!==r||e[10]!==h.meridiem||e[11]!==h.minute||e[12]!==i?(E=()=>{const re=p.current;if(re!==null&&(N(null),re.length!==0)){if(i){r(P(A(re.padStart(2,"0")),h.minute));return}r(Fn(ec(re.padStart(2,"0")),h.minute,h.meridiem))}},e[9]=r,e[10]=h.meridiem,e[11]=h.minute,e[12]=i,e[13]=E):E=e[13];const U=E;let I;e[14]!==r||e[15]!==h.hour12||e[16]!==h.hour24||e[17]!==h.meridiem||e[18]!==i?(I=re=>{const he=re.replace(/\D/g,"").slice(0,2);k(he),he.length===2&&(r(i?P(h.hour24,oo(he)):Fn(h.hour12,oo(he),h.meridiem)),k(null))},e[14]=r,e[15]=h.hour12,e[16]=h.hour24,e[17]=h.meridiem,e[18]=i,e[19]=I):I=e[19];const B=I;let R;e[20]!==r||e[21]!==h.hour12||e[22]!==h.hour24||e[23]!==h.meridiem||e[24]!==i?(R=()=>{const re=y.current;re!==null&&(k(null),re.length!==0&&r(i?P(h.hour24,oo(re.padStart(2,"0"))):Fn(h.hour12,oo(re.padStart(2,"0")),h.meridiem)))},e[20]=r,e[21]=h.hour12,e[22]=h.hour24,e[23]=h.meridiem,e[24]=i,e[25]=R):R=e[25];const j=R;let M;e[26]!==r||e[27]!==h.hour12||e[28]!==h.hour24||e[29]!==h.meridiem||e[30]!==h.minute||e[31]!==i?(M=re=>r(i?P(D(h.hour24,re),h.minute):Fn(Aj(h.hour12,re),h.minute,h.meridiem)),e[26]=r,e[27]=h.hour12,e[28]=h.hour24,e[29]=h.meridiem,e[30]=h.minute,e[31]=i,e[32]=M):M=e[32];const L=M;let W;e[33]!==r||e[34]!==h.hour12||e[35]!==h.hour24||e[36]!==h.meridiem||e[37]!==h.minute||e[38]!==i?(W=re=>r(i?P(h.hour24,tc(h.minute,re)):Fn(h.hour12,tc(h.minute,re),h.meridiem)),e[33]=r,e[34]=h.hour12,e[35]=h.hour24,e[36]=h.meridiem,e[37]=h.minute,e[38]=i,e[39]=W):W=e[39];const te=W;let Q;e[40]!==r||e[41]!==h.hour12||e[42]!==h.meridiem||e[43]!==h.minute?(Q=re=>{re!==h.meridiem&&r(Fn(h.hour12,h.minute,re))},e[40]=r,e[41]=h.hour12,e[42]=h.meridiem,e[43]=h.minute,e[44]=Q):Q=e[44];const me=Q;let ce;e[45]!==U||e[46]!==L?(ce=re=>{if(re.key==="ArrowRight"){re.preventDefault(),U(),b.current?.focus();return}(re.key==="ArrowUp"||re.key==="ArrowDown")&&(re.preventDefault(),N(null),L(re.key==="ArrowUp"?1:-1))},e[45]=U,e[46]=L,e[47]=ce):ce=e[47];const H=ce;let ne;e[48]!==j||e[49]!==te?(ne=re=>{if(re.key==="ArrowLeft"&&(re.currentTarget.selectionStart??0)===0){re.preventDefault(),j(),x.current?.focus();return}(re.key==="ArrowUp"||re.key==="ArrowDown")&&(re.preventDefault(),k(null),te(re.key==="ArrowUp"?1:-1))},e[48]=j,e[49]=te,e[50]=ne):ne=e[50];const ie=ne,F=i?"px-2":"pl-2 pr-1";let Z;e[51]!==F?(Z=Pe("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",F),e[51]=F,e[52]=Z):Z=e[52];const G=w??(i?h.hour24:h.hour12);let V;e[53]!==$?(V=re=>$(re.target.value),e[53]=$,e[54]=V):V=e[54];let Y;e[55]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>N(""),e[55]=Y):Y=e[55];let le;e[56]!==U||e[57]!==o||e[58]!==H||e[59]!==G||e[60]!==V?(le=s.jsx("input",{ref:x,inputMode:"numeric",value:G,onChange:V,onKeyDown:H,onFocus:Y,onBlur:U,maxLength:2,"aria-label":o,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]=U,e[57]=o,e[58]=H,e[59]=G,e[60]=V,e[61]=le):le=e[61];let pe;e[62]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=pe):pe=e[62];const be=g??h.minute;let Se;e[63]!==B?(Se=re=>B(re.target.value),e[63]=B,e[64]=Se):Se=e[64];let De;e[65]===Symbol.for("react.memo_cache_sentinel")?(De=()=>k(""),e[65]=De):De=e[65];let fe;e[66]!==j||e[67]!==l||e[68]!==ie||e[69]!==be||e[70]!==Se?(fe=s.jsx("input",{ref:b,inputMode:"numeric",value:be,onChange:Se,onKeyDown:ie,onFocus:De,onBlur:j,maxLength:2,"aria-label":l,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]=j,e[67]=l,e[68]=ie,e[69]=be,e[70]=Se,e[71]=fe):fe=e[71];let xe;e[72]!==d||e[73]!==h.meridiem||e[74]!==a||e[75]!==u||e[76]!==me||e[77]!==i?(xe=i?null:s.jsxs(Ms,{value:h.meridiem,onValueChange:re=>me(re),children:[s.jsx(Os,{"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(Cs,{})}),s.jsxs(Bs,{children:[s.jsx(es,{value:"AM",children:d}),s.jsx(es,{value:"PM",children:u})]})]}),e[72]=d,e[73]=h.meridiem,e[74]=a,e[75]=u,e[76]=me,e[77]=i,e[78]=xe):xe=e[78];let ge;return e[79]!==Z||e[80]!==le||e[81]!==fe||e[82]!==xe?(ge=s.jsxs("div",{className:Z,children:[le,pe,fe,xe]}),e[79]=Z,e[80]=le,e[81]=fe,e[82]=xe,e[83]=ge):ge=e[83],ge},nc=t=>new Date(t.getFullYear(),t.getMonth(),1),Ej=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},rc=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),Rj=t=>{if(!t)return["09:00"];const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(i=>typeof i=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(i)).map(i=>i.trim()),r=Array.from(new Set(n)).sort((i,o)=>i.localeCompare(o));return r.length>0?r:["09:00"]},oc=(t,e)=>{const n=Wn(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:Rj(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:Xl(),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:Wn(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:Xl(),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}}},Mj=(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(!Nu(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")},Oj=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))},Bj=t=>{const e=Je.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?Nu(l):null,e[0]=l,e[1]=a):a=e[1];const d=a;let u;e:{if(!d?.valid||!l.trim()){let M;e[2]===Symbol.for("react.memo_cache_sentinel")?(M=[],e[2]=M):M=e[2],u=M;break e}let j;e[3]!==l||e[4]!==n.schedule.timezone?(j=Sj(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=j):j=e[5],u=j}const f=u;let h;e[6]!==n.schedule.timezone||e[7]!==i?(h=j=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(j),e[6]=n.schedule.timezone,e[7]=i,e[8]=h):h=e[8];const x=h;let b;e[9]!==o?(b=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=b):b=e[10];let w;e[11]!==b?(w=s.jsx(Ts,{htmlFor:"sched-cron",required:!0,children:b}),e[11]=b,e[12]=w):w=e[12];let S;e[13]!==r?(S=j=>r(M=>({...M,schedule:{...M.schedule,cronExpression:j.target.value}})),e[13]=r,e[14]=S):S=e[14];let g;e[15]!==o?(g=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=g):g=e[16];let m;e[17]!==l||e[18]!==S||e[19]!==g?(m=s.jsx(hn,{id:"sched-cron",value:l,onChange:S,placeholder:g,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=S,e[19]=g,e[20]=m):m=e[20];let p;e[21]!==l||e[22]!==d||e[23]!==o?(p=d&&!d.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=d,e[23]=o,e[24]=p):p=e[24];let y;e[25]!==w||e[26]!==m||e[27]!==p?(y=s.jsxs("div",{className:"flex flex-col gap-1",children:[w,m,p]}),e[25]=w,e[26]=m,e[27]=p,e[28]=y):y=e[28];let v;e[29]!==x||e[30]!==f||e[31]!==o?(v=f.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:f.map(x).join(", ")})]}):null,e[29]=x,e[30]=f,e[31]=o,e[32]=v):v=e[32];let N;e[33]!==o?(N=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=N):N=e[34];let C;e[35]!==N?(C=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[35]=N,e[36]=C):C=e[36];let k;e[37]!==r||e[38]!==o?(k=vj.map(j=>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(M=>({...M,schedule:{...M.schedule,cronExpression:j.expression}})),children:[s.jsx("span",{className:"font-mono",children:j.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(j.labelKey)})]},j.expression)),e[37]=r,e[38]=o,e[39]=k):k=e[39];let A;e[40]!==k?(A=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:k}),e[40]=k,e[41]=A):A=e[41];let D;e[42]!==C||e[43]!==A?(D=s.jsxs("div",{className:"flex flex-col gap-1",children:[C,A]}),e[42]=C,e[43]=A,e[44]=D):D=e[44];let P;e[45]!==o?(P=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=P):P=e[46];let T;e[47]!==P?(T=s.jsx(Ts,{children:P}),e[47]=P,e[48]=T):T=e[48];let $;e[49]!==r?($=j=>{r(M=>({...M,schedule:{...M.schedule,timezone:j}}))},e[49]=r,e[50]=$):$=e[50];let E;e[51]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),e[51]=E):E=e[51];let U;e[52]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(Bs,{children:Ki.map(zj)}),e[52]=U):U=e[52];let I;e[53]!==n.schedule.timezone||e[54]!==$?(I=s.jsxs(Ms,{value:n.schedule.timezone,onValueChange:$,children:[E,U]}),e[53]=n.schedule.timezone,e[54]=$,e[55]=I):I=e[55];let B;e[56]!==T||e[57]!==I?(B=s.jsxs("div",{className:"flex flex-col gap-1",children:[T,I]}),e[56]=T,e[57]=I,e[58]=B):B=e[58];let R;return e[59]!==y||e[60]!==v||e[61]!==D||e[62]!==B?(R=s.jsxs("div",{className:"flex flex-col gap-3",children:[y,v,D,B]}),e[59]=y,e[60]=v,e[61]=D,e[62]=B,e[63]=R):R=e[63],R};function _j(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=ft(),a=Ht(_=>_.loadProviders),d=Ht(_=>_.loadAgents),u=Ht(_=>_.providers),f=Ht(_=>_.currentProviderId),h=Ht(_=>_.currentModelId),x=Ht(_=>_.currentVariant||""),b=Ht(_=>_.currentAgentName||""),w=Ce(_=>_.timeFormatPreference),S=Ce(_=>_.weekStartPreference),g=Ce(_=>_.isMobile),[m,p]=ot.useState(()=>oc(n,{providerID:f,modelID:h,variant:x,agent:b})),[y,v]=ot.useState(!1),[N,C]=ot.useState(!1),[k,A]=ot.useState(!1),[D,P]=ot.useState(""),[T,$]=ot.useState(!1),[E,U]=ot.useState(""),[I,B]=ot.useState(!1),[R,j]=ot.useState(""),[M,L]=ot.useState(()=>{const _=yo(n?.schedule?.date||"")||new Date;return new Date(_.getFullYear(),_.getMonth(),1)}),W=ot.useRef(null),te=ot.useRef(null),Q=ot.useRef(null),me=ot.useRef(null),ce=ot.useRef(null),H=ot.useMemo(()=>Pj(l),[l]),ne=ot.useMemo(()=>Dj(l),[l]),ie=ot.useMemo(()=>w==="24h"?!0:w==="12h"?!1:H,[w,H]),F=ot.useMemo(()=>S==="sunday"?0:S==="monday"?1:ne,[S,ne]),Z=ot.useMemo(()=>{const _=Ij(l);return Tj(Au.map(ue=>({value:ue,label:_[ue]||""})),F)},[l,F]);ot.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),d({source:"scheduledTaskEditor"}))},[e,a,d]),ot.useEffect(()=>{if(!e)return;p(oc(n,{providerID:f,modelID:h,variant:x,agent:b}));const _=yo(n?.schedule?.date||"")||new Date;L(new Date(_.getFullYear(),_.getMonth(),1)),C(!1),$(!1),A(!1),U(""),P("")},[e,n,f,h,x,b]),ot.useEffect(()=>{if(!N)return;const _=ue=>{W.current&&!W.current.contains(ue.target)&&C(!1)};return document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[N]);const G=ot.useMemo(()=>{const ue=u.find(ke=>ke.id===m.execution.providerID)?.models?.find(ke=>ke.id===m.execution.modelID);return ue?.variants?Object.keys(ue.variants):[]},[u,m.execution.providerID,m.execution.modelID]),V=G.length>0,Y=ot.useMemo(()=>!V||!m.execution.variant?"__default":G.includes(m.execution.variant)?m.execution.variant:"__default",[m.execution.variant,V,G]);ot.useEffect(()=>{V||!m.execution.variant||p(_=>({..._,execution:{..._.execution,variant:""}}))},[V,m.execution.variant]);const le=ot.useCallback((_,ue)=>{p(ke=>{const je=new Set(ke.schedule.weekdays);return ue?je.add(_):je.delete(_),{...ke,schedule:{...ke.schedule,weekdays:Array.from(je).sort((Ke,se)=>Ke-se)}}})},[]),pe=ot.useCallback((_,ue)=>{p(ke=>{const je=ke.schedule.times.slice();return je[_]=ue,{...ke,schedule:{...ke.schedule,times:je}}})},[]),be=ot.useCallback(_=>{p(ue=>{const ke=ue.schedule.times.filter((je,Ke)=>Ke!==_);return{...ue,schedule:{...ue.schedule,times:ke.length>0?ke:["09:00"]}}})},[]),Se=ot.useCallback(()=>{p(_=>({..._,schedule:{..._.schedule,times:[..._.schedule.times,"12:00"]}}))},[]),De=ot.useMemo(()=>Ej(),[]),fe=ot.useMemo(()=>nc(De),[De]),xe=ot.useMemo(()=>{const _=yo(m.schedule.onceDate);return _?rc(_,De)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(_):null},[m.schedule.onceDate,l,o,De]),ge=ot.useMemo(()=>nc(M).getTime()<=fe.getTime(),[M,fe]),re=ot.useMemo(()=>Z.map(_=>_.label),[Z]),he=ot.useCallback(_=>{p(ue=>({...ue,schedule:{...ue.schedule,onceDate:_}}))},[]),Ne=ot.useCallback((_,ue)=>{if(_.startsWith("/")){const se=_.indexOf(" "),Ie=_.indexOf(`
|
|
920
|
-
`),Ye=Math.min(se===-1?_.length:se,Ie===-1?_.length:Ie);if(ue<=Ye&&se===-1){U(_.substring(1,Ye)),$(!0),A(!1),B(!1);return}}$(!1);const ke=_.substring(0,ue),je=ke.lastIndexOf("#");if(je!==-1){const se=je>0?ke[je-1]:null,Ie=ke.substring(je+1);if((!se||/\s/.test(se))&&!Ie.includes(" ")&&!Ie.includes(`
|
|
921
|
-
`)){j(Ie),B(!0),A(!1);return}}B(!1);const Ke=ke.lastIndexOf("@");if(Ke!==-1){const se=Ke>0?ke[Ke-1]:null,Ie=ke.substring(Ke+1);(!se||/\s/.test(se))&&!Ie.includes(" ")&&!Ie.includes(`
|
|
922
|
-
`)?(P(Ie),A(!0)):A(!1);return}A(!1)},[]),de=ot.useCallback(_=>{p(ue=>({...ue,execution:{...ue.execution,prompt:_}}))},[]),oe=ot.useCallback(_=>{const ue=m.execution.prompt,je=te.current?.selectionStart??ue.length,se=ue.substring(0,je).lastIndexOf("@"),Ie=_.relativePath&&_.relativePath.trim().length>0?_.relativePath.trim():_.path||_.name,Ye=se!==-1?se:je,ee=`${ue.substring(0,Ye)}@${Ie} ${ue.substring(je)}`,Ee=Ye+Ie.length+2;de(ee),A(!1),P(""),requestAnimationFrame(()=>{const Ge=te.current;Ge&&(Ge.selectionStart=Ee,Ge.selectionEnd=Ee,Ge.focus()),Ne(ee,Ee)})},[m.execution.prompt,de,Ne]),K=ot.useCallback(_=>{const ue=m.execution.prompt,je=te.current?.selectionStart??ue.length,se=ue.substring(0,je).lastIndexOf("@"),Ie=se!==-1?se:je,Ye=`${ue.substring(0,Ie)}@${_} ${ue.substring(je)}`,ee=Ie+_.length+2;de(Ye),A(!1),P(""),requestAnimationFrame(()=>{const Ee=te.current;Ee&&(Ee.selectionStart=ee,Ee.selectionEnd=ee,Ee.focus()),Ne(Ye,ee)})},[m.execution.prompt,de,Ne]),z=ot.useCallback(_=>{const ue=`/${_.name} `;de(ue),$(!1),U(""),B(!1),requestAnimationFrame(()=>{const ke=te.current;ke&&(ke.focus(),ke.selectionStart=ke.value.length,ke.selectionEnd=ke.value.length),Ne(ue,ue.length)})},[de,Ne]),ae=ot.useCallback((_,ue)=>{const ke=m.execution.prompt,Ke=te.current?.selectionStart??ke.length,Ie=ke.substring(0,Ke).lastIndexOf("#"),Ye=Ie!==-1?Ie:Ke,ee=`${ke.substring(0,Ye)}#${ue} ${ke.substring(Ke)}`,Ee=Ye+ue.length+2;de(ee),B(!1),j(""),requestAnimationFrame(()=>{const Ge=te.current;Ge&&(Ge.selectionStart=Ee,Ge.selectionEnd=Ee,Ge.focus()),Ne(ee,Ee)})},[m.execution.prompt,de,Ne]),ve=ot.useCallback(_=>{if(T&&me.current&&(_.key==="Enter"||_.key==="ArrowUp"||_.key==="ArrowDown"||_.key==="Escape"||_.key==="Tab")){_.preventDefault(),me.current.handleKeyDown(_.key);return}k&&Q.current&&(_.key==="Enter"||_.key==="ArrowUp"||_.key==="ArrowDown"||_.key==="Escape"||_.key==="Tab")&&(_.preventDefault(),Q.current.handleKeyDown(_.key)),I&&ce.current&&(_.key==="Enter"||_.key==="ArrowUp"||_.key==="ArrowDown"||_.key==="Escape"||_.key==="Tab")&&(_.preventDefault(),ce.current.handleKeyDown(_.key))},[T,k,I]),ye=ot.useCallback(async()=>{const _=Mj(m,o);if(_){Re.error(_);return}const ue={...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:Oj(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}:{}};v(!0);try{await i(ue),r(!1)}catch(ke){Re.error(ke instanceof Error?ke.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{v(!1)}},[m,r,i,o]),We=ot.useId(),Be=ot.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),Ae=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),X=o("sessions.scheduledTasks.editor.description"),Oe=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(Ts,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(hn,{id:"sched-name",value:m.name,onChange:_=>p(ue=>({...ue,name:_.target.value})),placeholder:o("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(Ts,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Ms,{value:m.schedule.kind,onValueChange:_=>{p(ue=>({...ue,schedule:{...ue.schedule,kind:_,..._==="cron"&&!ue.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{children:_=>o(_==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":_==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":_==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(Bs,{children:[s.jsx(es,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(es,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(es,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(es,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx(Bj,{draft:m,setDraft:p,locale:l,t:o}):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:W,children:[s.jsx(Ts,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Pe(Yc({size:"default"}),"w-fit max-w-full"),onClick:()=>C(_=>!_),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(O,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:kj(m.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(O,{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:()=>L(_=>Zl(_,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:ge,children:s.jsx(O,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(M)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>L(_=>Zl(_,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(O,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:re.map((_,ue)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:_},`${_}-${ue}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:Cj(M,F).map(({date:_,inCurrentMonth:ue})=>{const ke=Jl(_),je=ke===m.schedule.onceDate,Ke=rc(_,De),se=_.getTime()<De.getTime(),Ie=je?"bg-interactive-selection text-interactive-selection-foreground":se?"text-muted-foreground/40":ue?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{se||(he(ke),C(!1))},disabled:se,className:["h-8 rounded-md typography-ui-label",Ie,Ke&&!je?"ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50":"",se?"cursor-not-allowed opacity-45":""].join(" "),children:_.getDate()},ke)})}),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:xe||""}),s.jsx(lt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{he(Jl(De)),L(new Date(De.getFullYear(),De.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ts,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(sc,{value:m.schedule.onceTime,use24Hour:ie,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:_=>p(ue=>({...ue,schedule:{...ue.schedule,onceTime:_}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Ts,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ms,{value:m.schedule.timezone,onValueChange:_=>{p(ue=>({...ue,schedule:{...ue.schedule,timezone:_}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),s.jsx(Bs,{children:Ki.map(_=>s.jsx(es,{value:_,children:_},_))})]})]})]})]}):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(Ts,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:Z.map(_=>{const ue=m.schedule.weekdays.includes(_.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",ue?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(nr,{checked:ue,onChange:ke=>le(_.value,ke),ariaLabel:_.label}),s.jsx("button",{type:"button",onClick:()=>le(_.value,!ue),className:"group-hover:text-foreground",children:_.label})]},_.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ts,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((_,ue)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(sc,{value:_,use24Hour:ie,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:ke=>pe(ue,ke)}),m.schedule.times.length>1?s.jsx(lt,{type:"button",size:"icon",variant:"ghost",onClick:()=>be(ue),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(O,{name:"close",className:"h-4 w-4"})}):null]},ue))}),s.jsx("div",{children:s.jsxs(lt,{type:"button",size:"sm",variant:"outline",onClick:Se,children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ts,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ms,{value:m.schedule.timezone,onValueChange:_=>{p(ue=>({...ue,schedule:{...ue.schedule,timezone:_}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{})}),s.jsx(Bs,{children:Ki.map(_=>s.jsx(es,{value:_,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 min-w-0 flex-col gap-1",children:[s.jsx(Ts,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Rm,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(_,ue)=>{p(ke=>({...ke,execution:{...ke.execution,providerID:_,modelID:ue,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ts,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Ms,{value:Y,disabled:!V,onValueChange:_=>{p(ue=>({...ue,execution:{...ue.execution,variant:_==="__default"?"":_}}))},children:[s.jsx(Os,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Cs,{children:_=>_==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):_})}),s.jsxs(Bs,{children:[s.jsx(es,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),G.map(_=>s.jsx(es,{value:_,children:_},_))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ts,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Mm,{agentName:m.execution.agent,filter:_=>Qc(_.mode),onChange:_=>p(ue=>({...ue,execution:{...ue.execution,agent:_}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ts,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(tr,{id:"sched-prompt",ref:te,value:m.execution.prompt,onChange:_=>{const ue=_.target.value;de(ue);const ke=_.target.selectionStart??ue.length;Ne(ue,ke)},onKeyDown:ve,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),T?s.jsx(nd,{ref:me,searchQuery:E,onCommandSelect:z,onClose:()=>$(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,k?s.jsx(rd,{ref:Q,searchQuery:D,onFileSelect:oe,onAgentSelect:K,onClose:()=>A(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,I?s.jsx(od,{ref:ce,searchQuery:R,onSnippetSelect:ae,onClose:()=>B(!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(nr,{checked:m.execution.goalTokenBudget!==null,onChange:_=>p(ue=>({...ue,execution:{...ue.execution,goalTokenBudget:_?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),m.execution.goalTokenBudget!==null?s.jsx(Om,{value:m.execution.goalTokenBudget,onValueChange:_=>{typeof _=="number"&&Number.isFinite(_)&&_>0&&p(ue=>({...ue,execution:{...ue.execution,goalTokenBudget:Math.floor(_)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),Fe=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(nr,{checked:m.enabled,onChange:_=>p(ue=>({...ue,enabled:_})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe(Yl),onClick:()=>p(_=>({..._,execution:{..._.execution,permissionAutoAccept:!_.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(O,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(O,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(pt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe(Yl,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>p(_=>({..._,execution:{..._.execution,goalEnabled:!_.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(O,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(O,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(pt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(lt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(lt,{type:"button",size:"sm",onClick:ye,disabled:y,children:o(y?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return g?s.jsx(zo,{open:e,title:Ae,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:_=>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:Ae}),_]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:X})]}),footer:Fe,children:Oe}):s.jsx(Ns,{open:e,onOpenChange:_=>{!_&&Be()||r(_)},children:s.jsxs(As,{"aria-describedby":We,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Ls,{id:We,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(Fs,{className:"typography-ui-label font-medium text-foreground",children:Ae}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:X})]})}),s.jsx(ta,{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:Oe})}),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:Fe})})]})})}function Fj(t){return mr(t,{min:0,max:23})}function Lj(t,e){return mr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function $j(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function zj(t){return s.jsx(es,{value:t,children:t},t)}const Wj=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,i)=>r.localeCompare(i))},Vj=(t,e)=>{const n=Wj(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===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:Wn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:Wn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=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:i,time:o,timezone:Wn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:Wn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},Uj=(t,e)=>!t||!Number.isFinite(t)?"":Bm(t,e),ic=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const h=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:h}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:h})}if(r<l){const h=Math.floor(r/o),x=Math.round(r%o/i),b=x>0?`${h}h ${x}m`:`${h}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:b}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:b})}const d=Math.floor(r/l),u=Math.round(r%l/o),f=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:f}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:f})},Hj={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"}},Kj=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function Gj(){const{t}=ft(),e=Ce(j=>j.isScheduledTasksDialogOpen),n=Ce(j=>j.setScheduledTasksDialogOpen),r=Ce(j=>j.isMobile),i=Ce(j=>j.timeFormatPreference),o=Vt(j=>j.projects),l=Vt(j=>j.getActiveProject()),a=Zt(j=>j.homeDirectory),{currentTheme:d}=qn(),[u,f]=ot.useState(""),[h,x]=ot.useState([]),[b,w]=ot.useState(!0),[S,g]=ot.useState(!1),[m,p]=ot.useState(null),[y,v]=ot.useState(null),N=ot.useMemo(()=>o.find(j=>j.id===u)||null,[o,u]),C=ot.useCallback(j=>{const M=j.label?.trim()||In(j.path,a||void 0),L=j.icon?ia[j.icon]:null,W=j.color?aa[j.color]:void 0,te=L?s.jsx(O,{name:L,className:"h-3.5 w-3.5 shrink-0",style:W?{color:W}:void 0}):s.jsx(O,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:W?{color:W}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[j.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:j.iconBackground?{backgroundColor:j.iconBackground}:void 0,children:s.jsx(la,{project:{id:j.id,iconImage:j.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:te})}):te,s.jsx("span",{className:"truncate",children:M})]})},[a,d.metadata.variant,d.colors.surface.foreground]),k=ot.useCallback(async(j,M)=>{if(!j){x([]);return}M?.silent||w(!0);try{const L=await ep(j);L.sort((W,te)=>{if(W.enabled!==te.enabled)return W.enabled?-1:1;const Q=W.name.localeCompare(te.name);return Q!==0?Q:(W.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(te.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),x(L)}catch(L){Re.error(L instanceof Error?L.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),M?.silent||x([])}finally{M?.silent||w(!1)}},[t]);ot.useEffect(()=>{if(!e)return;const j=l?.id||o[0]?.id||"";f(j),j?k(j):(x([]),w(!1))},[e,l,o,k]),ot.useEffect(()=>{if(!e)return;let j=null;const M=Vr(L=>{L.type==="scheduled-task-ran"&&L.projectId===u&&(j&&clearTimeout(j),j=setTimeout(()=>{k(u,{silent:!0})},400))});return()=>{j&&clearTimeout(j),M()}},[e,u,k]);const A=ot.useCallback(async j=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Xa(u,j),await k(u),Re.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,k,t]),D=ot.useCallback(async(j,M)=>{if(u){v(j.id),x(L=>L.map(W=>W.id===j.id?{...W,enabled:M}:W));try{j.loopFile?await tp(u,j.id,M):await Xa(u,{...j,enabled:M}),await k(u,{silent:!0})}catch(L){Re.error(L instanceof Error?L.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await k(u,{silent:!0})}finally{v(null)}}},[u,k,t]),P=ot.useCallback(async j=>{if(!(!u||!window.confirm(j.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:j.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:j.name})))){v(j.id);try{j.loopFile?await sp(u,j.id):await np(u,j.id),await k(u,{silent:!0}),Re.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(L){Re.error(L instanceof Error?L.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{v(null)}}},[u,k,t]),T=ot.useCallback(j=>{if(!j.loopFile){p(j),g(!0);return}N?.path&&(n(!1),nn.getState().setSelectedPath(N.path,j.loopFile,{allowOutsideRoot:!0}),Ce.getState().openContextFile(N.path,j.loopFile))},[N?.path,n]),$=ot.useCallback(async j=>{if(u){v(j.id);try{const{sessionId:M,persistError:L}=await rp(u,j.id);if(await Promise.all([k(u,{silent:!0}),fa()]),L?Re.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Re.success(t("sessions.scheduledTasks.dialog.toast.started")),M){const W=o.find(te=>te.id===u);Qe.getState().setCurrentSession(M,W?.path??null)}}catch(M){Re.error(M instanceof Error?M.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{v(null)}}},[u,o,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(Ms,{value:u||"__none",onValueChange:j=>{const M=j==="__none"?"":j;f(M),M?k(M):x([])},children:[s.jsx(Os,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(Cs,{children:C(N)}):s.jsx(Cs,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(Bs,{children:[o.length===0?s.jsx(es,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(j=>s.jsx(es,{value:j.id,children:C(j)},j.id))]})]})]}),U=()=>{p(null),g(!0)},I=j=>{f(j),j?k(j):x([])},B=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(O,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):h.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:h.map(j=>{const M=y===j.id,L=j.state?.lastStatus||"idle",W=Hj[L],te=t(L==="success"?"sessions.scheduledTasks.dialog.status.success":L==="error"?"sessions.scheduledTasks.dialog.status.error":L==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),Q=j.state?.nextRunAt,me=j.state?.lastRunAt;return s.jsxs("div",{className:Pe("rounded-lg border border-border p-4 transition-opacity",!j.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:j.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:Vj(j,t)}),j.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:j.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:j.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(O,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),Q?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:ic(Q,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:Uj(Q,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(O,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),L==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(O,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):me?s.jsxs(s.Fragment,{children:[W.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${W.tone})`},children:[s.jsx(O,{name:W.Icon,className:"h-3.5 w-3.5"}),te]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:ic(me,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),j.state?.lastError?s.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",style:Kj("error"),children:[s.jsx(O,{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:j.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Pe("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",j.enabled?"text-foreground":"text-muted-foreground",M&&"cursor-not-allowed opacity-50"),children:[s.jsx(nr,{checked:j.enabled,onChange:ce=>{D(j,ce)},ariaLabel:j.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:j.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:j.name}),disabled:M}),j.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(lt,{variant:"outline",size:"sm",onClick:()=>{$(j)},disabled:M,children:[s.jsx(O,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(lt,{variant:"outline",size:"sm",onClick:()=>T(j),disabled:M,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:j.name}),children:[s.jsx(O,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(lt,{variant:"destructive",size:"sm",onClick:()=>{P(j)},disabled:M,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:j.name}),children:s.jsx(O,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},j.id)})})}),R=s.jsxs("div",{className:"space-y-4",children:[E,B]});return s.jsxs(s.Fragment,{children:[r?s.jsx(zo,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:j=>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")}),j]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(lt,{className:"w-full",onClick:U,disabled:!u,children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:R}):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:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(j=>s.jsx("button",{type:"button",onClick:()=>I(j.id),className:Pe("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===j.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(j)},j.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(lt,{size:"sm",onClick:U,disabled:!u,children:[s.jsx(O,{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:B})})]})]})}):null,s.jsx(_j,{open:S,task:m,onOpenChange:g,onSave:A})]})}const wo=100;function qj(){const t=Je.c(101),{t:e}=ft(),n=Ce(nk),r=Ce(sk),i=Qe(tk),o=Qe(ek),l=Zt(Zj);let a;t[0]!==n?(a=Q=>n?Q.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=xs(Kn(a)),[u,f]=c.useState(""),[h,x]=c.useState(null),[b,w]=c.useState(wo);let S;t[2]!==u?(S=u.trim().toLowerCase(),t[2]=u,t[3]=S):S=t[3];const g=S;let m;e:{if(!n){let me;t[4]===Symbol.for("react.memo_cache_sentinel")?(me=[],t[4]=me):me=t[4],m=me;break e}let Q;t[5]!==d?(Q=[...d].sort(Jj),t[5]=d,t[6]=Q):Q=t[6],m=Q}const p=m;let y;if(t[7]!==l||t[8]!==p||t[9]!==e){const Q=new Map;for(const me of p){const ce=yt(Is(me))??"",H=Q.get(ce);if(H){H.sessions.push(me);continue}Q.set(ce,{directory:ce,label:ce?In(ce,l)||ce:e("sessions.archivePage.otherProjects"),sessions:[me]})}y=[...Q.values()].sort(Xj),t[7]=l,t[8]=p,t[9]=e,t[10]=y}else y=t[10];const v=y;let N;e:{if(g){let me;t[11]!==g||t[12]!==p?(me=_m(p,g,Yj),t[11]=g,t[12]=p,t[13]=me):me=t[13],N=me;break e}if(h===null){N=p;break e}let Q;t[14]!==v||t[15]!==h?(Q=v.find(me=>me.directory===h)?.sessions??[],t[14]=v,t[15]=h,t[16]=Q):Q=t[16],N=Q}const C=N;let k,A,D,P,T,$,E,U,I,B;if(t[17]!==d.length||t[18]!==v||t[19]!==C||t[20]!==l||t[21]!==g||t[22]!==n||t[23]!==u||t[24]!==h||t[25]!==i||t[26]!==r||t[27]!==e||t[28]!==o||t[29]!==b){T=Symbol.for("react.early_return_sentinel");e:{const Q=C.slice(0,b);k=C.length-Q.length;const me=d.length;let ce;t[40]===Symbol.for("react.memo_cache_sentinel")?(ce=ge=>{x(ge),w(wo)},t[40]=ce):ce=t[40];const H=ce;let ne;t[41]!==i||t[42]!==r?(ne=ge=>{const re=yt(Is(ge));i(ge.id,re??void 0),r(!1)},t[41]=i,t[42]=r,t[43]=ne):ne=t[43];const ie=ne;let F;t[44]!==e||t[45]!==o?(F=ge=>{o(ge.id).then(re=>{re?Re.success(e("sessions.sidebar.session.restore.success")):Re.error(e("sessions.sidebar.session.restore.error"))})},t[44]=e,t[45]=o,t[46]=F):F=t[46];const Z=F;if(!n){T=null;break e}let G;t[47]!==e?(G=(ge,re,he,Ne,de,oe,K)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:de,title:oe,className:Pe("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",K?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",Ne?"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:re}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:he})]}),K?s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>ln.requestDelete({sessions:K,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:re}),children:s.jsx(O,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(pt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},ge),t[47]=e,t[48]=G):G=t[48];const V=G;P="absolute inset-0 z-10 flex flex-col bg-background",A="flex min-h-0 flex-1";let Y;if(t[49]!==V||t[50]!==h||t[51]!==e||t[52]!==me){let ge;t[54]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>H(null),t[54]=ge):ge=t[54],Y=V("__all__",e("sessions.archivePage.allDirectories"),me,h===null,ge),t[49]=V,t[50]=h,t[51]=e,t[52]=me,t[53]=Y}else Y=t[53];let le;if(t[55]!==v||t[56]!==V||t[57]!==h){let ge;t[59]!==V||t[60]!==h?(ge=re=>V(re.directory||"__none__",re.label,re.sessions.length,h===re.directory,()=>H(re.directory),re.directory||void 0,re.sessions),t[59]=V,t[60]=h,t[61]=ge):ge=t[61],le=v.map(ge),t[55]=v,t[56]=V,t[57]=h,t[58]=le}else le=t[58];t[62]!==Y||t[63]!==le?(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:[Y,le]})}),t[62]=Y,t[63]=le,t[64]=D):D=t[64],I="flex min-w-0 flex-1 flex-col";let pe;t[65]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(O,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t[65]=pe):pe=t[65];let be;t[66]===Symbol.for("react.memo_cache_sentinel")?(be=ge=>{f(ge.target.value),w(wo)},t[66]=be):be=t[66];let Se;t[67]!==e?(Se=e("sessions.archivePage.searchPlaceholder"),t[67]=e,t[68]=Se):Se=t[68];let De;t[69]!==u||t[70]!==Se?(De=s.jsxs("div",{className:"relative min-w-0 flex-1",children:[pe,s.jsx("input",{value:u,onChange:be,placeholder:Se,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[69]=u,t[70]=Se,t[71]=De):De=t[71];let fe;t[72]!==C.length||t[73]!==e?(fe=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[72]=C.length,t[73]=e,t[74]=fe):fe=t[74];let xe;t[75]!==fe?(xe=s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:fe}),t[75]=fe,t[76]=xe):xe=t[76],t[77]!==De||t[78]!==xe?(B=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[De,xe]}),t[77]=De,t[78]=xe,t[79]=B):B=t[79],U="min-h-0 flex-1 overflow-y-auto px-6 py-3",$="mx-auto w-full max-w-3xl space-y-0.5",E=Q.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(g?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):Q.map(ge=>{const re=yt(Is(ge))??"",he=re?In(re,l)||re: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:()=>ie(ge),role:"button",tabIndex:0,onKeyDown:Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),ie(ge))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:ge.title||e("sessions.sidebar.session.untitled")}),g&&he?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:re,children:he}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Zc(ge.time?.archived??ge.time?.updated??ge.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:Ne=>{Ne.stopPropagation(),Z(ge)},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:ge.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(O,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Ne=>{Ne.stopPropagation(),ln.requestDelete({sessions:[ge],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:ge.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(O,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},ge.id)})}t[17]=d.length,t[18]=v,t[19]=C,t[20]=l,t[21]=g,t[22]=n,t[23]=u,t[24]=h,t[25]=i,t[26]=r,t[27]=e,t[28]=o,t[29]=b,t[30]=k,t[31]=A,t[32]=D,t[33]=P,t[34]=T,t[35]=$,t[36]=E,t[37]=U,t[38]=I,t[39]=B}else k=t[30],A=t[31],D=t[32],P=t[33],T=t[34],$=t[35],E=t[36],U=t[37],I=t[38],B=t[39];if(T!==Symbol.for("react.early_return_sentinel"))return T;let R;t[80]!==k||t[81]!==e?(R=k>0?s.jsx("button",{type:"button",onClick:()=>w(Qj),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[80]=k,t[81]=e,t[82]=R):R=t[82];let j;t[83]!==R||t[84]!==$||t[85]!==E?(j=s.jsxs("div",{className:$,children:[E,R]}),t[83]=R,t[84]=$,t[85]=E,t[86]=j):j=t[86];let M;t[87]!==j||t[88]!==U?(M=s.jsx("div",{className:U,children:j}),t[87]=j,t[88]=U,t[89]=M):M=t[89];let L;t[90]!==M||t[91]!==I||t[92]!==B?(L=s.jsxs("div",{className:I,children:[B,M]}),t[90]=M,t[91]=I,t[92]=B,t[93]=L):L=t[93];let W;t[94]!==A||t[95]!==D||t[96]!==L?(W=s.jsxs("div",{className:A,children:[D,L]}),t[94]=A,t[95]=D,t[96]=L,t[97]=W):W=t[97];let te;return t[98]!==P||t[99]!==W?(te=s.jsx("div",{className:P,children:W}),t[98]=P,t[99]=W,t[100]=te):te=t[100],te}function Qj(t){return t+wo}function Yj(t){return[t.title]}function Xj(t,e){return e.sessions.length-t.sessions.length}function Jj(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function Zj(t){return t.homeDirectory}function ek(t){return t.unarchiveSession}function tk(t){return t.setCurrentSession}function sk(t){return t.setArchivePageOpen}function nk(t){return t.isArchivePageOpen}function rk(){const t=Je.c(18),{t:e}=ft(),n=Ce(ak),r=Ce(ik),i=Vt(ok);let o;t[0]!==n?(o=b=>b.projects.find(w=>w.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Vt(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(O,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let f;t[9]!==a||t[10]!==u?(f=s.jsx("div",{className:"flex items-center",children:s.jsxs(lt,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=f):f=t[11];let h;t[12]!==l.id||t[13]!==l.path?(h=s.jsx(Uh,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=h):h=t[14];let x;return t[15]!==f||t[16]!==h?(x=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[f,h]})})}),t[15]=f,t[16]=h,t[17]=x):x=t[17],x}function ok(t){return t.setActiveProjectIdOnly}function ik(t){return t.setNewWorktreeDialogOpen}function ak(t){return t.worktreesPageProjectId}const Gi=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),lk=(t,e)=>{const n=Gi(t),r=Gi(e);return`${n}-${r}`.substring(0,60)},ac=(t,e)=>`${t}/${e}`,ck=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},lc=(t,e)=>{const n=ck(e),r=t.directory,i=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};Hm(t.id,n),Qe.getState().markSessionAsOpenChamberCreated(t.id),xs.getState().upsertSession(i);try{ko().ensureChild(n,{bootstrap:!1}).setState(l=>{const a=l.session.findIndex(u=>u.id===t.id);if(a>=0&&l.session[a]===i)return l;const d=a>=0?l.session.map((u,f)=>f===a?i:u):[...l.session,i].sort((u,f)=>u.id.localeCompare(f.id));return{session:d,sessionTotal:Math.max(l.sessionTotal,d.length),limit:Math.max(l.limit,d.length)}})}catch{}return i},dk=()=>{const t=Vt.getState(),e=t.activeProjectId;if(!e)return null;const n=t.projects.find(i=>i.id===e);if(n?.path)return{id:n.id,path:n.path};const r=Zt.getState().currentDirectory??null;if(r&&r.trim().length>0){const i=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${i}`,path:i}}return null},ui=Yn()(Ad(t=>({isLoading:!1,error:null,createMultiRun:async e=>{const n=e.name.trim(),{groups:r,agent:i,files:o,setupCommands:l}=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=dk();if(!a)return t({error:"Select a project",isLoading:!1}),null;const d=a.path,f=await sd(d)&&e.isolateRuns!==!1,h=Gi(n),x=f?await Wo(d):void 0,b=f?await Fm(d):null,w=[],S=l?.filter(v=>v.trim().length>0)??[];for(let v=0;v<r.length;v++){const N=r[v],C=N.prompt,k=new Map;for(const D of N.models){const P=`${D.providerID}:${D.modelID}`;k.set(P,(k.get(P)||0)+1)}const A=new Map;for(const D of N.models){const P=`${D.providerID}:${D.modelID}`,T=k.get(P)||1,$=(A.get(P)||0)+1;A.set(P,$);const E=lk(D.providerID,D.modelID),U=r.length>1?`g${v+1}`:void 0,I=T>1?ac(h,`${E}/${$}`):ac(h,E),B=U?`${U}/${I}`:I,R=u0({groupSlug:h,runGroup:U,providerID:D.providerID,modelID:D.modelID,index:T>1?$:void 0});try{if(!f){const W=await Es.withDirectory(d,()=>Es.createSession({title:R}));lc(W,d),w.push({sessionId:W.id,worktreePath:d,providerID:D.providerID,modelID:D.modelID,variant:D.variant,prompt:C});continue}const j=await Lm(a,{preferredName:B,mode:"new",branchName:B,worktreeName:B,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:S,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:b}),M={...j,createdFromBranch:x,kind:"standard"};await $m(a)&&await zm(j.path);const L=await Es.withDirectory(j.path,()=>Es.createSession({title:R}));lc(L,j.path),Qe.getState().setWorktreeMetadata(L.id,M),w.push({sessionId:L.id,worktreePath:j.path,providerID:D.providerID,modelID:D.modelID,variant:D.variant,prompt:C})}catch(j){console.warn("[MultiRun] Failed to create session:",j)}}}const g=l?.filter(v=>v.trim().length>0)??[];g.length>0&&Wm(a,g).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const m=w.map(v=>v.sessionId),p=w[0]?.sessionId??null;if(m.length===0)return t({error:"Failed to create any sessions",isLoading:!1}),null;const y=o?.map(v=>({type:"file",mime:v.mime,filename:v.filename,url:v.url}));return(async()=>{try{const v=Vm.getState().expandText;await Promise.allSettled(w.map(async N=>{try{const C=await v(N.prompt).catch(()=>N.prompt);await Um({sessionId:N.sessionId,directory:N.worktreePath,content:C,providerID:N.providerID,modelID:N.modelID,variant:N.variant,agent:i,files:y})}catch(C){console.warn("[MultiRun] Failed to start run:",C)}}))}catch(v){console.warn("[MultiRun] Failed to start runs:",v)}})(),t({isLoading:!1}),{groupSlug:h,sessionIds:m,firstSessionId:p}}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 Du(t){const e=Je.c(30),{git:n}=xn(),r=Oc(t),i=Km(t),o=Gm(t),l=qm(t),a=Pn(pk),d=Pn(hk);let u,f;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==i||e[4]!==o?(u=()=>{!t||!n||i!==null||o||d(t,n,{silent:!0})},f=[t,n,d,i,o],e[0]=t,e[1]=d,e[2]=n,e[3]=i,e[4]=o,e[5]=u,e[6]=f):(u=e[5],f=e[6]),c.useEffect(u,f);let h;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(h=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=h):h=e[12];const x=r?.all;let b;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==x?(b=[t,n,i,x,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=x,e[18]=b):b=e[18],c.useEffect(h,b);const w=o||i===!0&&l;let S;e:{if(!r?.all){let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[19]=k):k=e[19],S=k;break e}let C;e[20]!==r.all?(C=r.all.filter(mk).sort(),e[20]=r.all,e[21]=C):C=e[21],S=C}const g=S;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 C;e[23]!==r.all?(C=r.all.filter(fk).map(uk).sort(),e[23]=r.all,e[24]=C):C=e[24],m=C}const p=m;let y;e:{if(!t){y=null;break e}if(i!==null){y=i;break e}if(w){y=null;break e}y=r?.all?!0:null}const v=y;let N;return e[25]!==v||e[26]!==w||e[27]!==g||e[28]!==p?(N={localBranches:g,remoteBranches:p,isLoading:w,isGitRepository:v},e[25]=v,e[26]=w,e[27]=g,e[28]=p,e[29]=N):N=e[29],N}function uk(t){return t.replace(/^remotes\//,"")}function fk(t){return t.startsWith("remotes/")}function mk(t){return!t.startsWith("remotes/")}function hk(t){return t.fetchStatus}function pk(t){return t.fetchBranches}const gk=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=ft(),{localBranches:a,remoteBranches:d,isLoading:u,isGitRepository:f}=Du(t),h=c.useMemo(()=>[...a,...d.map(b=>`remotes/${b}`)],[a,d]);c.useEffect(()=>{if(i||u||h.length===0||e&&h.includes(e))return;const b=e;let w=!1;return(async()=>{try{const g=t?await Wo(t).catch(()=>null):null;if(w)return;const m=localStorage.getItem(Ya),{sourceBranch:p,shouldClearSavedSourceBranch:y}=Hh({branches:h,savedSourceBranch:m,rootBranch:g});if(y&&localStorage.removeItem(Ya),w||b&&h.includes(b))return;p&&n(p)}catch{}})(),()=>{w=!0}},[h,t,i,u,n,e]);const x=i||!f||u;return s.jsxs("div",{children:[s.jsxs(Ms,{value:e,onValueChange:n,disabled:x,children:[s.jsx(Os,{id:o,size:"lg",className:Pe("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(Cs,{placeholder:l(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Bs,{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:l("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:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(wi,{children:[s.jsx($a,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(b=>s.jsx(es,{value:b,className:"whitespace-normal break-all",children:b},b))]}),a.length>0&&d.length>0&&s.jsx(Qm,{}),d.length>0&&s.jsxs(wi,{children:[s.jsx($a,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),d.map(b=>s.jsx(es,{value:`remotes/${b}`,className:"whitespace-normal break-all",children:b},`remotes/${b}`))]})]})})]}),f===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},bk=10*1024*1024,fi=5,So=t=>{const e=Je.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(ht,{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(O,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(gt,{children:[r,s.jsx(pt,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},$n=t=>{const e=Je.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const d=o&&o;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},xk=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=ft(),[o,l]=c.useState(""),[a,d]=c.useState(()=>[{id:Pr(),prompt:"",models:[]}]),[u,f]=c.useState(""),[h,x]=c.useState([]),[b,w]=c.useState(!1),[S,g]=c.useState([]),[m,p]=c.useState(!1),[y,v]=c.useState(!1),[N,C]=c.useState(!0),k=c.useRef(null),A=Zt(z=>z.currentDirectory??null),D=Zt(z=>z.homeDirectory??null),P=c.useMemo(()=>{if(typeof window>"u")return null;const z=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof z=="string"&&z.trim().length>0?z.trim():null},[]),T=Vt(z=>z.activeProjectId),$=Vt(z=>z.setActiveProjectIdOnly),E=Vt(z=>z.projects),[U,I]=c.useState(()=>T??null);c.useEffect(()=>{if(T){I(T);return}!U&&E.length>0&&I(E[0].id)},[T,E,U]);const B=c.useMemo(()=>U?E.find(z=>z.id===U)??null:null,[E,U]),R=B?.path??A,j=c.useCallback(z=>{I(z),z!==T&&$(z)},[T,$]),{currentTheme:M}=qn(),L=c.useCallback(z=>{const ae=z.label?.trim()||In(z.path,D),ve=z.icon?ia[z.icon]:null,ye=z.color?aa[z.color]:void 0,We=ve?s.jsx(O,{name:ve,className:"h-3.5 w-3.5 shrink-0",style:ye?{color:ye}:void 0}):s.jsx(O,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:ye?{color:ye}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[z.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:z.iconBackground?{backgroundColor:z.iconBackground}:void 0,children:s.jsx(la,{project:{id:z.id,iconImage:z.iconImage??null},options:{themeVariant:M.metadata.variant,iconColor:M.colors.surface.foreground},className:"h-full w-full object-contain",fallback:We})}):We,s.jsx("span",{className:"truncate",children:ae})]})},[D,M.metadata.variant,M.colors.surface.foreground]),W=c.useMemo(()=>{if(B?.path)return{id:B.id,path:B.path};const z=A??P;return z?{id:`path:${z}`,path:z}:null},[B,A,P]),[te]=c.useState(()=>typeof window<"u"?cn():!1),Q=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),me=Ic(),ce=c.useMemo(()=>{if(typeof window>"u")return null;const z=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof z=="number"&&Number.isFinite(z)&&z>0)return z;if(typeof navigator>"u")return null;const ae=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ae)return null;const ve=Number.parseInt(ae[1],10),ye=Number.parseInt(ae[2],10);return Number.isNaN(ve)?null:ve===10?ye:ve},[]),H=c.useMemo(()=>te&&Q||me?"pl-[5.5rem]":"pl-3",[te,Q,me]),ne=c.useMemo(()=>!te||!Q||ce===null?"":ce>=26?"h-12":ce<=15?"h-14":"",[te,Q,ce]),ie=c.useCallback(async z=>{z.target.closest("button, a, input, select, textarea")||z.button===0&&te&&await Ym()},[te]);c.useEffect(()=>{if(!n)return;const z=ae=>{ae.key==="Escape"&&(ae.preventDefault(),ae.stopPropagation(),n())};return window.addEventListener("keydown",z,!0),()=>window.removeEventListener("keydown",z,!0)},[n]);const[F,Z]=c.useState(""),{isLoading:G,isGitRepository:V}=Du(R),Y=c.useRef(!1),le=V===!0,pe=le&&N;c.useEffect(()=>{if(V===!1){Y.current=!0,C(!1);return}V===!0&&Y.current&&(Y.current=!1,C(!0))},[V]);const be=ui(z=>z.createMultiRun),Se=ui(z=>z.error),De=ui(z=>z.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(z=>{const ae=[...z];return ae.length>0&&!ae[0].prompt.trim()&&(ae[0]={...ae[0],prompt:t}),ae})},[t]),c.useEffect(()=>{if(!W)return;let z=!1;return v(!0),(async()=>{try{const ae=await Xm(W);z||g(ae)}catch{}finally{z||v(!1)}})(),()=>{z=!0}},[W]);const fe=c.useCallback((z,ae)=>{d(ve=>ve.map(ye=>ye.id===z?{...ye,...ae}:ye))},[]),xe=c.useCallback(z=>{d(ae=>ae.filter(ve=>ve.id!==z))},[]),ge=c.useCallback(()=>{d(z=>[...z,{id:Pr(),prompt:"",models:[]}])},[]),re=async z=>{const ae=z.target.files;if(!ae)return;let ve=0;for(let ye=0;ye<ae.length;ye++){const We=ae[ye];if(We.size>bk){Re.error(i("multirun.launcher.toast.fileTooLarge",{fileName:We.name}));continue}try{const Be=await new Promise((Ae,X)=>{const Oe=new FileReader;Oe.onload=()=>Ae(Oe.result),Oe.onerror=X,Oe.readAsDataURL(We)});x(Ae=>[...Ae,{id:Pr(),filename:We.name,mimeType:We.type||"application/octet-stream",size:We.size,dataUrl:Be}]),ve++}catch(Be){console.error("File attach failed",Be),Re.error(i("multirun.launcher.toast.attachFailed",{fileName:We.name}))}}ve>0&&Re.success(ve===1?i("multirun.launcher.toast.attachedSingle",{count:ve}):i("multirun.launcher.toast.attachedPlural",{count:ve})),k.current&&(k.current.value="")},he=z=>{x(ae=>ae.filter(ve=>ve.id!==z))},Ne=c.useMemo(()=>a.reduce((z,ae)=>z+ae.models.length,0),[a]),de=async z=>{z.preventDefault();const ae=a.filter(ve=>ve.prompt.trim()&&ve.models.length>=1);if(ae.length!==0&&!(Ne<1)){w(!0),De();try{U&&U!==T&&$(U);const ve=h.map(X=>({mime:X.mimeType,filename:X.filename,url:X.dataUrl})),ye=S.filter(X=>X.trim().length>0),We=ae.map(X=>({prompt:X.prompt.trim(),models:X.models.map(Oe=>({providerID:Oe.providerID,modelID:Oe.modelID,displayName:Oe.displayName,variant:Oe.variant}))})),Be={name:o.trim(),groups:We,agent:u||void 0,worktreeBaseBranch:pe?F:void 0,isolateRuns:pe,files:ve.length>0?ve:void 0,setupCommands:ye.length>0?ye:void 0},Ae=await be(Be);Ae&&(Ae.firstSessionId&&Qe.getState().setCurrentSession(Ae.firstSessionId),e?.())}finally{w(!1)}}},oe=!!(o.trim()&&a.some(z=>z.prompt.trim()&&z.models.length>=1)&&Ne>=1&&R&&!G&&(V===!1||!pe||F)),K=S.filter(z=>z.trim()).length;return s.jsxs("form",{onSubmit:de,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:ie,className:Pe("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",H,ne),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:i("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":i("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(O,{name:"close",className:"h-5 w-5"})})}),s.jsx(pt,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(ta,{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($n,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),E.length>0?s.jsxs(Ms,{value:U??void 0,onValueChange:j,children:[s.jsx(Os,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:B?s.jsx(Cs,{children:L(B)}):s.jsx(Cs,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(Bs,{fitContent:!0,children:E.map(z=>s.jsx(es,{value:z.id,className:"max-w-[24rem]",children:L(z)},z.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx($n,{htmlFor:"group-name",required:!0,info:s.jsx(So,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(hn,{id:"group-name",value:o,onChange:z=>l(z.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx($n,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(So,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(gk,{directory:R,value:F,onChange:Z,disabled:!pe,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(nr,{checked:N,onChange:C,disabled:!le,ariaLabel:i("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:i("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx($n,{htmlFor:"multirun-agent",info:s.jsx(So,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(vu,{value:u,onChange:f,id:"multirun-agent"})]})]}),s.jsxs(ji,{open:m,onOpenChange:p,children:[s.jsxs(md,{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(O,{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:i("multirun.launcher.setupCommands.label")}),K>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:K}),s.jsx(O,{name:"arrow-down-s",className:Pe("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(ki,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:y?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[S.map((z,ae)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(hn,{value:z,onChange:ve=>{const ye=[...S];ye[ae]=ve.target.value,g(ye)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>g(S.filter((ve,ye)=>ye!==ae)),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":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(O,{name:"close",className:"h-3.5 w-3.5"})})]},`${z}-${ae}`)),s.jsxs("button",{type:"button",onClick:()=>g([...S,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(O,{name:"add",className:"h-3 w-3"}),i("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx($n,{htmlFor:"prompt",required:!0,children:i("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:re,accept:"*/*"}),s.jsxs(gt,{children:[s.jsx(ht,{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(O,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(pt,{children:i("multirun.launcher.attachments.tooltip")})]}),h.map(z=>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:[z.mimeType.startsWith("image/")?s.jsx(O,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(O,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:z.filename,children:z.filename}),s.jsx("button",{type:"button",onClick:()=>he(z.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(O,{name:"close",className:"h-3 w-3"})})]},z.id))]})]}),a.map((z,ae)=>s.jsx(yk,{group:z,groupIndex:ae,canRemove:a.length>1,onUpdate:fe,onRemove:xe},z.id)),s.jsxs("button",{type:"button",onClick:ge,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(O,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),Se&&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:Se})]})})}),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:[!pe&&V!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(O,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:i("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(lt,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(lt,{type:"submit",size:"sm",disabled:!oe||b,children:b?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:Ne})})})]})})]})},yk=t=>{const e=Je.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=ft(),[d,u]=c.useState(!1),[f,h]=c.useState(""),[x,b]=c.useState(!1),[w,S]=c.useState(""),[g,m]=c.useState(!1),[p,y]=c.useState(""),v=c.useRef(null),N=c.useRef(null),C=c.useRef(null),k=c.useRef(null);let A;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(A=ye=>{n.models.length>=fi||o(n.id,{models:[...n.models,ye]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=A):A=e[3];const D=A;let P;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(P=ye=>{o(n.id,{models:n.models.filter((We,Be)=>Be!==ye)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=P):P=e[7];const T=P;let $;e[8]!==n.id||e[9]!==n.models||e[10]!==o?($=(ye,We)=>{o(n.id,{models:n.models.map((Be,Ae)=>Ae===ye?We:Be)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=$):$=e[11];const E=$;let U;e[12]===Symbol.for("react.memo_cache_sentinel")?(U=(ye,We)=>{if(ye.startsWith("/")){const Oe=ye.indexOf(" "),Fe=ye.indexOf(`
|
|
923
|
-
`),_=Math.min(Oe===-1?ye.length:Oe,Fe===-1?ye.length:Fe);if(We<=_&&Oe===-1){S(ye.substring(1,_)),b(!0),u(!1),m(!1);return}}b(!1);const Be=ye.substring(0,We),Ae=Be.lastIndexOf("#");if(Ae!==-1){const Oe=Ae>0?Be[Ae-1]:null,Fe=Be.substring(Ae+1);if((!Oe||/\s/.test(Oe))&&!Fe.includes(" ")&&!Fe.includes(`
|
|
924
|
-
`)){y(Fe),m(!0),u(!1);return}}m(!1);const X=Be.lastIndexOf("@");if(X!==-1){const Oe=X>0?Be[X-1]:null,Fe=Be.substring(X+1);(!Oe||/\s/.test(Oe))&&!Fe.includes(" ")&&!Fe.includes(`
|
|
925
|
-
`)?(h(Fe),u(!0)):u(!1);return}u(!1)},e[12]=U):U=e[12];const I=U;let B;e[13]!==n.id||e[14]!==o?(B=ye=>{o(n.id,{prompt:ye})},e[13]=n.id,e[14]=o,e[15]=B):B=e[15];const R=B;let j;e[16]!==n.prompt||e[17]!==R?(j=ye=>{const We=n.prompt,Ae=v.current?.selectionStart??We.length,Oe=We.substring(0,Ae).lastIndexOf("@"),Fe=ye.relativePath&&ye.relativePath.trim().length>0?ye.relativePath.trim():ye.path||ye.name,_=Oe!==-1?Oe:Ae,ue=`${We.substring(0,_)}@${Fe} ${We.substring(Ae)}`,ke=_+Fe.length+2;R(ue),u(!1),h(""),requestAnimationFrame(()=>{const je=v.current;je&&(je.selectionStart=ke,je.selectionEnd=ke,je.focus()),I(ue,ke)})},e[16]=n.prompt,e[17]=R,e[18]=j):j=e[18];const M=j;let L;e[19]!==n.prompt||e[20]!==R?(L=ye=>{const We=n.prompt,Ae=v.current?.selectionStart??We.length,Oe=We.substring(0,Ae).lastIndexOf("@"),Fe=Oe!==-1?Oe:Ae,_=`${We.substring(0,Fe)}@${ye} ${We.substring(Ae)}`,ue=Fe+ye.length+2;R(_),u(!1),h(""),requestAnimationFrame(()=>{const ke=v.current;ke&&(ke.selectionStart=ue,ke.selectionEnd=ue,ke.focus()),I(_,ue)})},e[19]=n.prompt,e[20]=R,e[21]=L):L=e[21];const W=L;let te;e[22]!==R?(te=ye=>{const We=`/${ye.name} `;R(We),b(!1),S(""),m(!1),requestAnimationFrame(()=>{const Be=v.current;Be&&(Be.focus(),Be.selectionStart=Be.value.length,Be.selectionEnd=Be.value.length),I(We,We.length)})},e[22]=R,e[23]=te):te=e[23];const Q=te;let me;e[24]!==n.prompt||e[25]!==R?(me=(ye,We)=>{const Be=n.prompt,X=v.current?.selectionStart??Be.length,Fe=Be.substring(0,X).lastIndexOf("#"),_=Fe!==-1?Fe:X,ue=`${Be.substring(0,_)}#${We} ${Be.substring(X)}`,ke=_+We.length+2;R(ue),m(!1),y(""),requestAnimationFrame(()=>{const je=v.current;je&&(je.selectionStart=ke,je.selectionEnd=ke,je.focus()),I(ue,ke)})},e[24]=n.prompt,e[25]=R,e[26]=me):me=e[26];const ce=me;let H;e[27]!==x||e[28]!==d||e[29]!==g?(H=ye=>{if(x&&C.current&&(ye.key==="Enter"||ye.key==="ArrowUp"||ye.key==="ArrowDown"||ye.key==="Escape"||ye.key==="Tab")){ye.preventDefault(),C.current.handleKeyDown(ye.key);return}d&&N.current&&(ye.key==="Enter"||ye.key==="ArrowUp"||ye.key==="ArrowDown"||ye.key==="Escape"||ye.key==="Tab")&&(ye.preventDefault(),N.current.handleKeyDown(ye.key)),g&&k.current&&(ye.key==="Enter"||ye.key==="ArrowUp"||ye.key==="ArrowDown"||ye.key==="Escape"||ye.key==="Tab")&&(ye.preventDefault(),k.current.handleKeyDown(ye.key))},e[27]=x,e[28]=d,e[29]=g,e[30]=H):H=e[30];const ne=H,ie=r+1;let F;e[31]!==a||e[32]!==ie?(F=a("multirun.launcher.groups.groupLabel",{index:ie}),e[31]=a,e[32]=ie,e[33]=F):F=e[33];let Z;e[34]!==F?(Z=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:F}),e[34]=F,e[35]=Z):Z=e[35];let G;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(G=i&&s.jsx("button",{type:"button",onClick:()=>l(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(O,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=G):G=e[40];let V;e[41]!==Z||e[42]!==G?(V=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Z,G]}),e[41]=Z,e[42]=G,e[43]=V):V=e[43];let Y;e[44]!==a?(Y=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=Y):Y=e[45];let le;e[46]!==Y?(le=s.jsx($n,{required:!0,children:Y}),e[46]=Y,e[47]=le):le=e[47];const pe=n.prompt;let be;e[48]!==R?(be=ye=>{const We=ye.target.value;R(We);const Be=ye.target.selectionStart??We.length;I(We,Be)},e[48]=R,e[49]=be):be=e[49];let Se;e[50]!==a?(Se=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=Se):Se=e[51];let De;e[52]!==n.prompt||e[53]!==ne||e[54]!==be||e[55]!==Se?(De=s.jsx(tr,{ref:v,value:pe,onChange:be,onKeyDown:ne,placeholder:Se,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]=ne,e[54]=be,e[55]=Se,e[56]=De):De=e[56];let fe;e[57]!==w||e[58]!==Q||e[59]!==x?(fe=x?s.jsx(nd,{ref:C,searchQuery:w,onCommandSelect:Q,onClose:()=>b(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=w,e[58]=Q,e[59]=x,e[60]=fe):fe=e[60];let xe;e[61]!==W||e[62]!==M||e[63]!==f||e[64]!==d?(xe=d?s.jsx(rd,{ref:N,searchQuery:f,onFileSelect:M,onAgentSelect:W,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=W,e[62]=M,e[63]=f,e[64]=d,e[65]=xe):xe=e[65];let ge;e[66]!==ce||e[67]!==g||e[68]!==p?(ge=g?s.jsx(od,{ref:k,searchQuery:p,onSnippetSelect:ce,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=ce,e[67]=g,e[68]=p,e[69]=ge):ge=e[69];let re;e[70]!==De||e[71]!==fe||e[72]!==xe||e[73]!==ge?(re=s.jsxs("div",{className:"relative",children:[De,fe,xe,ge]}),e[70]=De,e[71]=fe,e[72]=xe,e[73]=ge,e[74]=re):re=e[74];let he;e[75]!==le||e[76]!==re?(he=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[le,re]}),e[75]=le,e[76]=re,e[77]=he):he=e[77];let Ne;e[78]!==a?(Ne=a("multirun.launcher.models.info",{max:fi}),e[78]=a,e[79]=Ne):Ne=e[79];let de;e[80]!==Ne?(de=s.jsx(So,{children:Ne}),e[80]=Ne,e[81]=de):de=e[81];let oe;e[82]!==a?(oe=a("multirun.launcher.models.label"),e[82]=a,e[83]=oe):oe=e[83];let K;e[84]!==de||e[85]!==oe?(K=s.jsx($n,{required:!0,info:de,children:oe}),e[84]=de,e[85]=oe,e[86]=K):K=e[86];let z;e[87]!==n.models||e[88]!==D||e[89]!==T||e[90]!==E?(z=s.jsx(ju,{selectedModels:n.models,onAdd:D,onRemove:T,onUpdate:E,minModels:1,maxModels:fi}),e[87]=n.models,e[88]=D,e[89]=T,e[90]=E,e[91]=z):z=e[91];let ae;e[92]!==K||e[93]!==z?(ae=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[K,z]}),e[92]=K,e[93]=z,e[94]=ae):ae=e[94];let ve;return e[95]!==V||e[96]!==he||e[97]!==ae?(ve=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[V,he,ae]}),e[95]=V,e[96]=he,e[97]=ae,e[98]=ve):ve=e[98],ve},wk=t=>{const e=new Map;for(const n of t){const r=Is(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},Sk=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},vk=t=>{const e=Je.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=ks(),f=wk(i),h=l.current?.runtimeKey===u?l.current.identities:null;for(const x of Sk(h,f))Jm({runtimeKey:u,...x});l.current={runtimeKey:u,identities:f}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},jk=new Map,kk=t=>{const e=Je.c(26),{isVSCode:n}=t,r=ua(),i=Vt(Ck),o=Vt(Nk),l=Zt(Ak),a=Qe(Dk);let d;e[0]!==n?(d=P=>n?jk:P.availableWorktreesByProject,e[0]=n,e[1]=d):d=e[1];const u=Qe(d),f=!n;let h;e[2]!==u||e[3]!==i||e[4]!==f?(h=Cu(i,u,{includeWorktrees:f}),e[2]=u,e[3]=i,e[4]=f,e[5]=h):h=e[5];const x=h,b=xs(Pk),w=xs(Ik),S=xs(Tk),g=`session-list-sync:${c.useId()}`;let m,p;e[6]!==o||e[7]!==g||e[8]!==r||e[9]!==l||e[10]!==a||e[11]!==x||e[12]!==i?(m=()=>(r.setBootstrapDemand(g,bu({knownDirectories:x,activeProjectDirectory:yt(i.find(P=>P.id===o)?.path??null),activeProjectId:o,collapsedProjects:new Set,collapsedGroups:new Set,currentDirectory:l,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(g)),p=[o,g,r,l,a,x,i],e[6]=o,e[7]=g,e[8]=r,e[9]=l,e[10]=a,e[11]=x,e[12]=i,e[13]=m,e[14]=p):(m=e[13],p=e[14]),c.useEffect(m,p);const y=c.useRef(null);let v,N;e[15]!==n||e[16]!==x?(v=()=>{const P=new Set(x),T=y.current;y.current=P;const $=T?[...P].filter(E=>!T.has(E)):n?[...P]:[];$.length&&Ji($,Co())},N=[n,x],e[15]=n,e[16]=x,e[17]=v,e[18]=N):(v=e[17],N=e[18]),c.useEffect(v,N);let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[19]=C):C=e[19],c.useEffect(Ek,C);let k;e[20]!==w||e[21]!==b?(k=[...b,...w],e[20]=w,e[21]=b,e[22]=k):k=e[22];const A=k;let D;e[23]!==A||e[24]!==S?(D={enabled:!0,hasAuthoritativeGlobalSessions:S,sessions:A},e[23]=A,e[24]=S,e[25]=D):D=e[25],vk(D)};function Ck(t){return t.projects}function Nk(t){return t.activeProjectId}function Ak(t){return t.currentDirectory}function Dk(t){return t.currentSessionDirectory}function Pk(t){return t.activeSessions}function Ik(t){return t.archivedSessions}function Tk(t){return t.status==="ready"}function Ek(){let t=null,e=!1;const n=new Set,r=Vr(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),fa(Co());return}const o=[...n];n.clear(),o.length&&Ji(o,Co())},500)});return()=>{t&&clearTimeout(t),r()}}const Rk=Qn(()=>Gn(()=>import("./SettingsWindow-DXF-MTHG.js"),__vite__mapDeps([138,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,139,116,140,126,127,128,129,117,118,102,103,87,88,89,90,91,92,93,94,95,96,97,98,99,100,141,142])).then(t=>({default:t.SettingsWindow}))),Mk=()=>{const t=Je.c(55);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],kk(e);const n=Ce(Ok),r=Ce(Bk),i=Ce(_k),o=Ce(Fk),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const f=Ce(Lk),h=Ce($k),x=Ce(zk),b=Ce(Wk),w=Ce(Vk),S=Ce(Uk),g=b||w||!!S||f;let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[4]=m):m=t[4],c.useEffect(Kk,m);const{isMobile:p}=Tn();Kh();let y,v;t[5]!==p||t[6]!==r?(y=()=>{Ce.getState().isMobile!==p&&r(p)},v=[p,r],t[5]=p,t[6]=r,t[7]=y,t[8]=v):(y=t[7],v=t[8]),c.useEffect(y,v);let N,C,k,A,D;t[9]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(nw,{}),k=s.jsx(Zw,{}),A=s.jsx(nS,{}),D=s.jsx(wj,{}),N=s.jsx(Mg,{}),t[9]=N,t[10]=C,t[11]=k,t[12]=A,t[13]=D):(N=t[9],C=t[10],k=t[11],A=t[12],D=t[13]);let P;t[14]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(fg,{}),t[14]=P):P=t[14];let T;t[15]!==n?(T=s.jsx(yj,{isVisible:n}),t[15]=n,t[16]=T):T=t[16];let $;t[17]!==p||t[18]!==n||t[19]!==T?($=s.jsx(ug,{isOpen:n,isMobile:p,className:"border-border",topBar:P,children:T}),t[17]=p,t[18]=n,t[19]=T,t[20]=$):$=t[20];let E;t[21]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(cg,{}),t[21]=E):E=t[21];const U=g&&"invisible";let I;t[22]!==U?(I=Pe("absolute inset-0",U),t[22]=U,t[23]=I):I=t[23];const B=!i&&!g;let R;t[24]!==B?(R=s.jsx(Vs,{children:s.jsx(xd,{active:B})}),t[24]=B,t[25]=R):R=t[25];let j;t[26]!==I||t[27]!==R?(j=s.jsx("div",{className:I,children:R}),t[26]=I,t[27]=R,t[28]=j):j=t[28];let M;t[29]!==f||t[30]!==x||t[31]!==h?(M=f&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Vs,{children:s.jsx(xk,{isWindowed:!0,initialPrompt:x,onCreated:()=>h(!1),onCancel:()=>h(!1)})})}),t[29]=f,t[30]=x,t[31]=h,t[32]=M):M=t[32];let L;t[33]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(Vs,{children:s.jsx(Gj,{})}),t[33]=L):L=t[33];let W;t[34]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(Vs,{children:s.jsx(qj,{})}),t[34]=W):W=t[34];let te;t[35]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(Vs,{children:s.jsx(rk,{})}),t[35]=te):te=t[35];let Q;t[36]!==j||t[37]!==M?(Q=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[j,M,L,W,te]}),t[36]=j,t[37]=M,t[38]=Q):Q=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(N1,{}),t[39]=me):me=t[39];let ce;t[40]!==Q?(ce=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:[Q,me]})})}),t[40]=Q,t[41]=ce):ce=t[41];let H;t[42]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Vs,{children:s.jsx(B1,{})})}),t[42]=H):H=t[42];let ne;t[43]!==ce?(ne=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[E,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[ce,H]})]}),t[43]=ce,t[44]=ne):ne=t[44];let ie;t[45]!==$||t[46]!==ne?(ie=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[$,ne]}),t[45]=$,t[46]=ne,t[47]=ie):ie=t[47];let F;t[48]!==i||t[49]!==o||t[50]!==l?(F=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Rk,{open:i,onOpenChange:o})}):null,t[48]=i,t[49]=o,t[50]=l,t[51]=F):F=t[51];let Z;return t[52]!==ie||t[53]!==F?(Z=s.jsx(Gh,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[C,k,A,D,N,ie,F]})}),t[52]=ie,t[53]=F,t[54]=Z):Z=t[54],Z};function Ok(t){return t.isSidebarOpen}function Bk(t){return t.setIsMobile}function _k(t){return t.isSettingsDialogOpen}function Fk(t){return t.setSettingsDialogOpen}function Lk(t){return t.isMultiRunLauncherOpen}function $k(t){return t.setMultiRunLauncherOpen}function zk(t){return t.multiRunLauncherPrefillPrompt}function Wk(t){return t.isScheduledTasksDialogOpen}function Vk(t){return t.isArchivePageOpen}function Uk(t){return t.worktreesPageProjectId}function Hk(){return Ce.getState().closeMainSurfaces()}function Kk(){const t=Hk,e=Qe.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}const Pu=12,Gk=[{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"}],qk=t=>{const e=Je.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,f=l===void 0?Gk:l,h=ot.useRef(!1);let x,b;e[0]!==n||e[1]!==a?(x=()=>{!n&&h.current&&a?.(),n&&(h.current=!0)},b=[n,a],e[0]=n,e[1]=a,e[2]=x,e[3]=b):(x=e[2],b=e[3]),ot.useEffect(x,b);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w=Array.from({length:Pu},Qk),e[4]=w):w=e[4];const S=w;if(!n)return null;let g;e[5]!==i?(g=Pe("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=g):g=e[6];let m;if(e[7]!==d||e[8]!==f||e[9]!==u){let y;e[11]!==d||e[12]!==u?(y=v=>{const N={"--burst-delay":`${v.delay}ms`,"--burst-x":`${v.x}%`,"--burst-y":`${v.y}%`,"--firework-color":`var(${v.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:S.map((C,k)=>{const A=C.x*v.radius,D=C.y*v.radius,P={"--translate-x":`${A}px`,"--translate-y":`${D}px`,"--particle-delay":`${C.delay}ms`,color:`var(${v.colorVar})`};return s.jsx("span",{className:"firework-particle",style:P},`${v.id}-${k}-${d}`)})},`${v.id}-${d}`)},e[11]=d,e[12]=u,e[13]=y):y=e[13],m=f.map(y),e[7]=d,e[8]=f,e[9]=u,e[10]=m}else m=e[10];let p;return e[14]!==d||e[15]!==g||e[16]!==m?(p=s.jsx("div",{className:g,"aria-hidden":"true","data-burst-key":d,children:m}),e[14]=d,e[15]=g,e[16]=m,e[17]=p):p=e[17],p};function Qk(t,e){const n=Math.PI*2*e/Pu;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const Yk=t=>{const e=Je.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=ot.useState(o),d=ot.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const f=u;let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{f(),a(Xk)},e[4]=h):h=e[4];const x=h;let b;e[5]!==i?(b=()=>{f(),a(Jk),d.current=window.setTimeout(()=>{a(Zk),d.current=null},i)},e[5]=i,e[6]=b):b=e[6];const w=b;let S,g;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>f(),g=[f],e[7]=S,e[8]=g):(S=e[7],g=e[8]),ot.useEffect(S,g);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:x},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=m):m=e[12],m};function Xk(t){return t.isActive?{...t,isActive:!1}:t}function Jk(t){return{isActive:!0,cycle:t.cycle+1}}function Zk(t){return t.isActive?{...t,isActive:!1}:t}const Iu=c.createContext(void 0),e3=t=>{const e=Je.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=Yk();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(qk,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let f;return e[6]!==n||e[7]!==u||e[8]!==d?(f=s.jsxs(Iu.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=f):f=e[9],f},j4=()=>{const t=c.useContext(Iu);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},t3=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`},Ps=t=>{const e=Je.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},cc=t=>{const e=Je.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=ft();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(r3,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let f;e[10]!==n?(f=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=f):f=e[11];let h;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(h=r.startedAt?t3(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=h):h=e[15];let x;e[16]!==h?(x=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:h}),e[16]=h,e[17]=x):x=e[17];let b;e[18]!==f||e[19]!==x?(b=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f,x]}),e[18]=f,e[19]=x,e[20]=b):b=e[20];let w;e[21]!==o?(w=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=w):w=e[22];let S;e[23]!==r.entries.length||e[24]!==w?(S=s.jsx(Ps,{label:w,value:r.entries.length}),e[23]=r.entries.length,e[24]=w,e[25]=S):S=e[25];let g;e[26]!==o?(g=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=g):g=e[27];let m;e[28]!==g||e[29]!==u?(m=s.jsx(Ps,{label:g,value:u}),e[28]=g,e[29]=u,e[30]=m):m=e[30];let p;e[31]!==o?(p=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=p):p=e[32];let y;e[33]!==r.lastUpdatedAt||e[34]!==o?(y=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=y):y=e[35];let v;e[36]!==p||e[37]!==y?(v=s.jsx(Ps,{label:p,value:y}),e[36]=p,e[37]=y,e[38]=v):v=e[38];let N;e[39]!==m||e[40]!==v||e[41]!==S?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[S,m,v]}),e[39]=m,e[40]=v,e[41]=S,e[42]=N):N=e[42],l=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:i}):s.jsx(pn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(C=>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:C.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:o("memoryDebugPanel.metric.countValue",{value:C.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:C.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:C.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},s3=t=>{const e=Je.c(99),{onClose:n}=t,{t:r}=ft(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=Qe(o3),u=Jc(i3),f=Bc(),h=Zm(a3),x=Ws(l3),[b,w]=c.useState(c3),[S,g]=c.useState(d3);let m;e[0]!==b.entries?(m=new Map,b.entries.forEach(oe=>{m.set(oe.metric,oe.count)}),e[0]=b.entries,e[1]=m):m=e[1];let p;e[2]!==m?(p=m.get("ui.message_list.render")??0,e[2]=m,e[3]=p):p=e[3];let y;e[4]!==m?(y=m.get("ui.message_list.render.streaming")??0,e[4]=m,e[5]=y):y=e[5];let v;e[6]!==m?(v=m.get("ui.chat_message.render")??0,e[6]=m,e[7]=v):v=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 C;e[10]!==m?(C=m.get("ui.chat_message.render.static_during_stream")??0,e[10]=m,e[11]=C):C=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 A;e[14]!==p||e[15]!==y||e[16]!==v||e[17]!==N||e[18]!==C||e[19]!==k?(A={messageListRender:p,messageListRenderStreaming:y,chatMessageRender:v,chatMessageRenderStreaming:N,chatMessageRenderStaticDuringStream:C,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},e[14]=p,e[15]=y,e[16]=v,e[17]=N,e[18]=C,e[19]=k,e[20]=A):A=e[20];const D=A;let P,T;e[21]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const oe=()=>{w(io()),g(ao())};oe();const K=window.setInterval(oe,500);return()=>window.clearInterval(K)},T=[],e[21]=P,e[22]=T):(P=e[21],T=e[22]),c.useEffect(P,T);let $,E;e[23]!==l?($=()=>{if(l==="idle")return;const oe=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(oe)},E=[l],e[23]=l,e[24]=$,e[25]=E):($=e[24],E=e[25]),c.useEffect($,E);let U=0,I=0,B=0;for(const oe of Object.keys(h)){const K=h[oe]??[];I=I+K.length;for(const z of K)z.role==="user"?B=B+1:z.role==="assistant"&&(U=U+1)}let R;e[26]!==U||e[27]!==I||e[28]!==B?(R={assistant:U,total:I,user:B},e[26]=U,e[27]=I,e[28]=B,e[29]=R):R=e[29];const j=R;let M;if(e[30]!==d||e[31]!==h||e[32]!==u||e[33]!==f||e[34]!==r){let oe;e[36]!==d||e[37]!==h||e[38]!==u||e[39]!==r?(oe=K=>{const z=h[K.id]??[];let ae=0,ve=0;for(const We of z)We.role==="user"?ve=ve+1:We.role==="assistant"&&(ae=ae+1);const ye=u.get(K.id);return{id:K.id,title:K.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ae,messageCount:z.length,userMessageCount:ve,isStreaming:ye?.isStreaming||!1,isZombie:ye?.isZombie||!1,backgroundCount:ye?.backgroundMessageCount||0,lastAccessed:ye?.lastAccessedAt||0,isCurrent:K.id===d}},e[36]=d,e[37]=h,e[38]=u,e[39]=r,e[40]=oe):oe=e[40],M=f.map(oe).sort(u3),e[30]=d,e[31]=h,e[32]=u,e[33]=f,e[34]=r,e[35]=M}else M=e[35];const L=M;let W;e[41]!==h?(W=Object.keys(h),e[41]=h,e[42]=W):W=e[42];const te=W.length;let Q;e[43]===Symbol.for("react.memo_cache_sentinel")?(Q=async()=>{try{const oe={generatedAt:new Date().toISOString(),ui:io(),vscode:ao()};await navigator.clipboard.writeText(JSON.stringify(oe,null,2)),a("copied")}catch{a("error")}},e[43]=Q):Q=e[43];const me=Q;let ce;e[44]===Symbol.for("react.memo_cache_sentinel")?(ce={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[44]=ce):ce=e[44];let H;e[45]!==i?(H=i==="memory"?s.jsx(O,{name:"database-2",className:"h-4 w-4 text-[var(--surface-foreground)]"}):s.jsx(O,{name:"bar-chart-box",className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[45]=i,e[46]=H):H=e[46];let ne;e[47]!==r?(ne=r("memoryDebugPanel.title"),e[47]=r,e[48]=ne):ne=e[48];let ie;e[49]!==ne?(ie=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:ne}),e[49]=ne,e[50]=ie):ie=e[50];let F;e[51]!==H||e[52]!==ie?(F=s.jsxs("div",{className:"flex items-center gap-2",children:[H,ie]}),e[51]=H,e[52]=ie,e[53]=F):F=e[53];let Z;e[54]!==i?(Z=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(lt,{size:"xs",variant:"ghost",onClick:me,children:s.jsx(O,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(lt,{size:"xs",variant:"ghost",onClick:()=>{Qu(),w(io()),g(ao())},children:s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[54]=i,e[55]=Z):Z=e[55];let G;e[56]!==n?(G=n?s.jsx(lt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(O,{name:"close",className:"h-4 w-4"})}):null,e[56]=n,e[57]=G):G=e[57];let V;e[58]!==Z||e[59]!==G?(V=s.jsxs("div",{className:"flex items-center gap-1",children:[Z,G]}),e[58]=Z,e[59]=G,e[60]=V):V=e[60];let Y;e[61]!==F||e[62]!==V?(Y=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[F,V]}),e[61]=F,e[62]=V,e[63]=Y):Y=e[63];let le;e[64]===Symbol.for("react.memo_cache_sentinel")?(le={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[64]=le):le=e[64];const pe=i==="memory"?"secondary":"ghost";let be;e[65]===Symbol.for("react.memo_cache_sentinel")?(be=()=>o("memory"),e[65]=be):be=e[65];let Se;e[66]!==r?(Se=r("memoryDebugPanel.tabs.memory"),e[66]=r,e[67]=Se):Se=e[67];let De;e[68]!==pe||e[69]!==Se?(De=s.jsx(lt,{size:"sm",variant:pe,className:"flex-1",onClick:be,children:Se}),e[68]=pe,e[69]=Se,e[70]=De):De=e[70];const fe=i==="streaming"?"secondary":"ghost";let xe;e[71]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>o("streaming"),e[71]=xe):xe=e[71];let ge;e[72]!==r?(ge=r("memoryDebugPanel.tabs.streaming"),e[72]=r,e[73]=ge):ge=e[73];let re;e[74]!==fe||e[75]!==ge?(re=s.jsx(lt,{size:"sm",variant:fe,className:"flex-1",onClick:xe,children:ge}),e[74]=fe,e[75]=ge,e[76]=re):re=e[76];let he;e[77]!==De||e[78]!==re?(he=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:le,children:[De,re]}),e[77]=De,e[78]=re,e[79]=he):he=e[79];let Ne;e[80]!==i||e[81]!==te||e[82]!==l||e[83]!==d||e[84]!==h||e[85]!==j||e[86]!==u||e[87]!==L||e[88]!==f||e[89]!==D||e[90]!==b||e[91]!==r||e[92]!==x||e[93]!==S?(Ne=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(Ps,{label:r("memoryDebugPanel.metric.totalMessages"),value:j.total}),s.jsx(Ps,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${te} / ${za.MAX_SESSIONS}`}),s.jsx(Ps,{label:r("memoryDebugPanel.metric.userMessages"),value:j.user}),s.jsx(Ps,{label:r("memoryDebugPanel.metric.assistantMessages"),value:j.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:eh()})})]}),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:za.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:x})]})]}),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(pn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:L.map(oe=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:oe.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:oe.title}),oe.isStreaming?s.jsx(O,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,oe.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:oe.assistantMessageCount,user:oe.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:oe.messageCount})}),oe.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",oe.backgroundCount]}):null]})]},oe.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(gt,{children:[s.jsx(ht,{asChild:!0,children:s.jsx(lt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:f.map(f3),currentSessionId:d,cachedSessions:Object.keys(h),messageRoleCounts:j,sessionMessageRoleCounts:L.map(m3),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(pt,{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(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(lt,{size:"xs",variant:"outline",onClick:me,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Ps,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),s.jsx(Ps,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:S.entries.length}),s.jsx(Ps,{label:r("memoryDebugPanel.metric.messageListRenders"),value:D.messageListRender}),s.jsx(Ps,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:D.messageListRenderStreaming}),s.jsx(Ps,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:D.chatMessageRender}),s.jsx(Ps,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:D.chatMessageRenderStreaming}),s.jsx(Ps,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:D.chatMessageRenderStaticDuringStream}),s.jsx(Ps,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:D.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(cc,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),S.entries.length>0?s.jsx(cc,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:S,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}),e[80]=i,e[81]=te,e[82]=l,e[83]=d,e[84]=h,e[85]=j,e[86]=u,e[87]=L,e[88]=f,e[89]=D,e[90]=b,e[91]=r,e[92]=x,e[93]=S,e[94]=Ne):Ne=e[94];let de;return e[95]!==Y||e[96]!==he||e[97]!==Ne?(de=s.jsxs(th,{className:"fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area",style:ce,children:[Y,he,Ne]}),e[95]=Y,e[96]=he,e[97]=Ne,e[98]=de):de=e[98],de},n3=s3;function r3(t,e){return t+e.count}function o3(t){return t.currentSessionId}function i3(t){return t.sessionMemoryState}function a3(t){return t.message}function l3(t){return t.totalRequestCount}function c3(){return io()}function d3(){return ao()}function u3(t,e){return e.lastAccessed-t.lastAccessed}function f3(t){return{id:t.id,title:t.title}}function m3(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}const h3=()=>{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()??"":""},p3=async()=>{const t=h3()||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")},dc="openchamber:menu-action",mi="openchamber:check-for-updates",g3=t=>{const e=Qe(m=>m.openNewSessionDraft),n=Ce(m=>m.toggleCommandPalette),r=Ce(m=>m.setCommandPaletteOpen),i=Ce(m=>m.toggleHelpDialog),o=Ce(m=>m.toggleSidebar),l=Ce(m=>m.setSessionSwitcherOpen),a=Ce(m=>m.setSettingsDialogOpen),d=Ce(m=>m.setAboutDialogOpen),u=Nr(m=>m.checkForUpdates),{setThemeMode:f}=qn(),h=c.useRef(!1),x=c.useCallback(()=>{h.current||(h.current=!0,u().then(()=>{const{available:m,error:p}=Nr.getState();if(p){Re.error("Failed to check for updates",{description:p});return}m||Re.success("You are on the latest version")}).finally(()=>{h.current=!1}))},[u]),b=c.useCallback(()=>{ln.requestDirectoryDialog()},[]),w=c.useCallback(m=>{const p=$c();if(p.length===0)return;const y=Qe.getState().currentSessionId,v=p.findIndex(k=>k.id===y);let N=m>0?0:p.length-1;v>=0&&(N=(v+m+p.length)%p.length);const C=p[N];C&&(l(!1),Qe.getState().setCurrentSession(C.id))},[l]),S=c.useCallback(m=>{const{activeProjectId:p,projects:y,setActiveProject:v}=Vt.getState();if(y.length===0)return;const N=y.findIndex(A=>A.id===p);let C=m>0?0:y.length-1;N>=0&&(C=(N+m+y.length)%y.length);const k=y[C];k&&v(k.id)},[]),g=c.useCallback(m=>{switch(m){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const p=Qe.getState(),y=Zt.getState().currentDirectory;e(p.currentSessionId&&y?{directoryOverride:y}:void 0)}break;case"new-worktree-session":l(!1),Vc();break;case"change-workspace":b();break;case"toggle-right-sidebar":{const p=Zt.getState().currentDirectory;if(!p)break;const y=Ce.getState(),v=Zn(p),N=y.contextPanelByDirectory[v];N?.isOpen?y.closeContextPanel(v):N?.activeTabId?y.setActiveContextPanelTab(v,N.activeTabId):y.openContextSurface(v,"git");break}case"open-right-sidebar-git":{const p=Zt.getState().currentDirectory;if(!p)break;Ce.getState().openContextSurface(Zn(p),"git");break}case"open-right-sidebar-files":{const p=Zt.getState().currentDirectory;if(!p)break;Ce.getState().openContextSurface(Zn(p),"file");break}case"toggle-terminal":{const p=Zt.getState().currentDirectory;if(!p)break;Ce.getState().openContextSurface(Zn(p),"terminal");break}case"toggle-terminal-expanded":{const p=Zt.getState().currentDirectory;if(!p)break;const y=Zn(p),v=Ce.getState(),N=v.contextPanelByDirectory[y];(N?.isOpen?N.tabs.find(k=>k.id===N.activeTabId)?.mode:null)!=="terminal"&&v.openContextSurface(y,"terminal"),v.toggleContextPanelExpanded(y);break}case"copy":{const p=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(p)||p3();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":sh();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":Zt.getState().goBack();break;case"go-forward":Zt.getState().goForward();break;case"previous-session":w(-1);break;case"next-session":w(1);break;case"previous-project":S(-1);break;case"next-project":S(1);break;case"help-dialog":i();break;case"download-logs":{pu().catch(()=>{Re.error("Failed to collect OpenCode status")});break}}},[b,S,w,t,e,d,l,r,a,f,n,i,o]);c.useEffect(()=>{const m=y=>{const v=y.detail;v&&g(v)},p=()=>{x()};return window.addEventListener(dc,m),window.addEventListener(mi,p),()=>{window.removeEventListener(dc,m),window.removeEventListener(mi,p)}},[g,x]),c.useEffect(()=>{if(typeof window>"u")return;const p=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof p!="function")return;let y=null,v=null;return p("openchamber:menu-action",N=>{const C=N?.payload;typeof C=="string"&&g(C)}).then(N=>{y=N}).catch(()=>{}),p("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(mi))}).then(N=>{v=N}).catch(()=>{}),()=>{(async()=>{try{const C=y?.();C instanceof Promise&&await C}catch{}try{const C=v?.();C instanceof Promise&&await C}catch{}})()}},[g])},b3="openchamber:tray-action",uc=5e3,x3=500,Tu=20,fc=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},mc=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,y3=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},w3=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Eu=(t,e)=>td(t,e,dr.getState().ids,Vo.getState().rankById),S3=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},v3=(t,e,n,r,i)=>{if(!t)return"";const o=id(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||S3(t),d=uo(t);let u=d&&i.get(d)||"";if(!u){for(const[f,h]of Pn.getState().directories)if(uo(f)===d){u=h.status?.current??"";break}}if(!u)for(const f of r.values()){const h=f.find(x=>uo(x.path)===d);if(h?.branch){u=h.branch;break}}return u?`${a} · ${u}`:a},j3=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=er.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of oh){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[f,h]of Object.entries(a.usage?.windows??{})){const x=r==="remaining"?h.remainingPercent:h.usedPercent;d.push({label:ah(f),value:ih(h.valueLabel,x)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},k3=async()=>{try{if(Oo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Dn();if(e&&Ca(e,t))return"Local OpenChamber";const r=(await wc()).hosts.find(i=>e?Ca(e,Yu(i)):!1);return r?.label?.trim()?Sc(r.label.trim()):"Instance"}catch{return""}},C3=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=ko()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(uo(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const f=u?.type,h=f==="busy"?"busy":f==="retry"?"retry":"idle",x=t.get(d);(!x||x==="idle")&&t.set(d,h)}for(const[d,u]of Object.entries(a.permission??{}))for(const f of u??[]){if(!f?.id)continue;const h=f.sessionID||d;n.push({kind:"permission",id:f.id,sessionId:h,sessionTitle:"",label:y3(f),directory:o})}for(const[d,u]of Object.entries(a.question??{}))for(const f of u??[]){if(!f?.id)continue;const h=f.sessionID||d;n.push({kind:"question",id:f.id,sessionId:h,sessionTitle:"",label:w3(f),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},N3=()=>{const t=xs.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Eu).slice(0,Tu).forEach(r=>{const i=Is(r);i&&e.add(i)});const n=new Map;for(const r of t){if(!r?.id)continue;const i=Is(r);if(!i||!e.has(i))continue;const o=n.get(i)??[];o.push(r.id),n.set(i,o)}return n},A3=t=>{const e=C3(),n=ca.getState().index.session,r=xs.getState().activeSessions,i=new Map(e.titleById),o=new Map;for(const g of r)if(g?.id&&(g.title&&i.set(g.id,g.title),g.parentID)){const m=o.get(g.parentID)??[];m.push(g.id),o.set(g.parentID,m)}const l=g=>{const m=[],p=[...o.get(g)??[]],y=new Set;for(;p.length;){const v=p.pop();y.has(v)||(y.add(v),m.push(v),p.push(...o.get(v)??[]))}return m},a=Uo.getState().statusById,d=g=>{const m=e.statusById.get(g);return m&&m!=="idle"?m:a.get(g)?.status.type??m??"idle"},u=g=>{const m=g.map(p=>d(p));return m.includes("busy")?"busy":m.includes("retry")?"retry":"idle"},f=Vt.getState().projects,h=Qe.getState().availableWorktreesByProject,x=r.filter(g=>g?.id&&!g.parentID).slice().sort(Eu).slice(0,Tu).map(g=>{const m=[g.id,...l(g.id)],p=Is(g)??"";return{id:g.id,title:g.title||"Untitled session",status:u(m),branch:p?e.branchByDirectory.get(p)??"":"",unseen:m.reduce((y,v)=>y+(n.unseenCount[v]??0),0),hasError:m.some(y=>n.unseenHasError[y]??!1),directory:p,subtitle:v3(p,g,f,h,e.branchByDirectory)}}),b=e.approvals.map(g=>({...g,sessionTitle:i.get(g.sessionId)||""})),w=Ce.getState();let S=0;if(w.dockBadgeEnabled)for(const g of r){if(!g?.id||g.parentID)continue;let m=n.unseenCount[g.id]??0;m===0&&w.notifyOnSubtasks&&(m=l(g.id).reduce((p,y)=>p+(n.unseenCount[y]??0),0)),m>0&&(S+=1)}return{sessions:x,approvals:b,instanceName:t,usage:j3(),dockBadgeCount:S}},D3=()=>{c.useEffect(()=>{if(!fc()||!mc()||!_o())return;let t=!1,e="",n=null,r="";const i=()=>{if(t)return;const C=A3(r),k=JSON.stringify(C);k!==e&&(e=k,Nn("desktop_tray_update",C))};k3().then(C=>{t||(r=C,i())});const o=async()=>{const C=N3();await Promise.all([...C.entries()].map(async([k,A])=>{const D=await Es.getSessionStatusForDirectory(k).catch(()=>null);t||D===null||nh(k,D,A)}))},l=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,i()},x3))},a=new Map,d=()=>{if(t)return;let C;try{C=ko()}catch{return}const k=new Set;for(const[A,D]of C.children.entries())k.add(A),a.has(A)||a.set(A,D.subscribe(()=>l()));for(const[A,D]of a)k.has(A)||(D(),a.delete(A))};let u=null;try{u=ko().subscribeRegistry(()=>{d(),l()})}catch{}d();const f=ca.subscribe(()=>l()),h=xs.subscribe(()=>l()),x=Vt.subscribe(()=>l()),b=Qe.subscribe(()=>l()),w=Pn.subscribe(()=>l()),S=Ce.subscribe(()=>l()),g=Uo.subscribe(()=>l()),m=Vo.subscribe(()=>l()),p=dr.subscribe(()=>l());o();const y=window.setInterval(()=>{o()},uc),v=er.subscribe(()=>l());er.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:C,results:k}=er.getState();C.length>0&&C.some(D=>!k.some(P=>P.providerId===D))&&er.getState().fetchQuotas(C)});const N=window.setInterval(()=>{d(),i()},uc);return i(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(N),window.clearInterval(y),f(),h(),x(),b(),w(),S(),g(),m(),p(),v(),u?.();for(const C of a.values())C();a.clear()}},[]),c.useEffect(()=>{if(!fc()||!mc()||typeof window>"u")return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&rh(i.sessionId,i.id,i.response).catch(()=>{Re.error("Failed to respond to permission request")})};let r=null;return e(b3,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},P3=45e3,I3=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,P3);return()=>r(i)},T3=t=>{const e=Je.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return I3(E3,R3)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function E3(){lh(Co())}function R3(){fa()}const M3="/api/notifications/stream",O3=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),B3=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}},_3=t=>{const e=Je.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||cn()||!Qi()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(qi().sse(M3));return o.onmessage=F3,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function F3(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Ce.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&O3())return;const r=B3(e);if(!r)return;Bo()?.notifications?.notifyAgentCompletion(r)}const L3=t=>{const e=Je.c(14),n=Ce($3),r=Vt(z3),i=Qe(W3),o=t??"",l=ch(V3);let a;e:{if(!o){a=null;break e}let b;e[0]!==i||e[1]!==o||e[2]!==r?(b=id(r,i,o),e[0]=i,e[1]=o,e[2]=r,e[3]=b):b=e[3],a=b?.path??null}const d=a;let u,f;e[4]!==n||e[5]!==l||e[6]!==d?(u=()=>{n&&l(d)},f=[n,l,d],e[4]=n,e[5]=l,e[6]=d,e[7]=u,e[8]=f):(u=e[7],f=e[8]),c.useEffect(u,f);let h,x;e[9]!==n||e[10]!==l||e[11]!==d?(h=()=>{if(n)return Vr(b=>{b.type==="agent-memory-changed"&&l(d)})},x=[n,l,d],e[9]=n,e[10]=l,e[11]=d,e[12]=h,e[13]=x):(h=e[12],x=e[13]),c.useEffect(h,x)};function $3(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function z3(t){return t.projects}function W3(t){return t.availableWorktreesByProject}function V3(t){return t.load}const hc="pwa-install-toast-shown",pc="pwa-install-toast-dismissed",U3=()=>{const t=Je.c(6),{browserTab:e}=qh(),{t:n}=ft(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!Qi()||!e)return;let d=null,u=null;const f=()=>{u!==null&&(Re.dismiss(u),u=null)},h=async()=>{if(!d)return;const w=d;d=null,f(),await w.prompt();const{outcome:S}=await w.userChoice;S==="accepted"&&Re.success(r.current("pwa.installPrompt.started"))},x=w=>{const S=w;if(typeof S.prompt!="function")return;S.preventDefault(),d=S;const g=vo(),m=Xu();Qh({dismissed:g.getItem(pc),sessionShown:m.getItem(hc),hasActiveToast:u!==null})&&(m.setItem(hc,"true"),u=Re.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{h()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{vo().setItem(pc,"true"),f()}}}))},b=()=>{d=null,f(),Re.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",x),window.addEventListener("appinstalled",b),()=>{f(),window.removeEventListener("beforeinstallprompt",x),window.removeEventListener("appinstalled",b)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},H3=({open:t,onOpenChange:e})=>{const{t:n}=ft(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[f,h]=c.useState(!1),[x,b]=c.useState(null),[w,S]=c.useState(!1);c.useCallback(async()=>{},[x,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const p=await ss("/api/system/info");if(p.ok){const y=await p.json();if(typeof y.openchamberVersion=="string"&&y.openchamberVersion.trim()){o(y.openchamberVersion);return}}}catch{}o(await dh())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const y=await ss("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!y.ok)return;const v=await y.json().catch(()=>null),N=typeof v?.currentVersion=="string"?v.currentVersion.trim():"";!m&&N&&a(N)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{b(null),S(!1);return}},[t,r]);const g=i;return s.jsx(Ns,{open:t,onOpenChange:e,children:s.jsx(As,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(_c,{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:[g&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:g})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),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(O,{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(O,{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(O,{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")})]})})})},gc=t=>{if(!(typeof window>"u")){if(t){window.location.href="openchamber://focus/mcp-auth";return}window.location.replace("/")}},hi=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},K3=(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},G3=()=>{const t=uh(a=>a.completeAuth),[e,n]=c.useState("working"),[r,i]=c.useState(!1),[o,l]=c.useState("Completing MCP authorization...");return c.useEffect(()=>{if(typeof window>"u"){n("error"),l("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),d=hi(a,"code"),u=fh(a),f=mh(a),h=hi(a,"error"),x=hi(a,"error_description");if(h){f&&ss(`/api/mcp/auth/pending?state=${encodeURIComponent(f)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(x??h);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,w=!1;if(f){const S=await ss(`/api/mcp/auth/pending?state=${encodeURIComponent(f)}`);if(S.ok){const g=await S.json().catch(()=>null);w=g?.origin===hh,i(w),!b&&g?.name?.trim()&&(b={name:g.name.trim(),directory:typeof g.directory=="string"&&g.directory.trim()?g.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),f&&await ss(`/api/mcp/auth/pending?state=${encodeURIComponent(f)}`,{method:"DELETE"}).catch(()=>{}),n("success"),w&&gc(!0),l("Authorization completed. You can close this tab and return to OpenChamber.")}catch(b){f&&await ss(`/api/mcp/auth/pending?state=${encodeURIComponent(f)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(K3(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:ph,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:Pe("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:o})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(lt,{type:"button",onClick:()=>gc(r),children:"Return to OpenChamber"})})]})})},bc=Qn(()=>Gn(()=>import("./OnboardingScreen-w2VG4fWY.js"),__vite__mapDeps([143,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.OnboardingScreen}))),q3=()=>{const t=Je.c(3),e=Ce(e4),n=Ce(t4);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(H3,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},Q3=t=>{const e=Je.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=ft();let o;e[0]!==i?(o=i("startup.initRecovery.title"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=s.jsx("h1",{className:"typography-title text-foreground",children:o}),e[2]=o,e[3]=l):l=e[3];let a;e[4]!==i?(a=i("startup.initRecovery.description"),e[4]=i,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]!==l||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10];let f;e[11]!==r||e[12]!==i?(f=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=i,e[13]=f):f=e[13];let h;e[14]!==r||e[15]!==n||e[16]!==f?(h=s.jsx(lt,{type:"button",onClick:n,disabled:r,children:f}),e[14]=r,e[15]=n,e[16]=f,e[17]=h):h=e[17];let x;return e[18]!==u||e[19]!==h?(x=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,h]})}),e[18]=u,e[19]=h,e[20]=x):x=e[20],x},xc=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",Y3=()=>{if(typeof window>"u"||!yp())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"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},X3=()=>typeof window>"u"?!1:window.location.pathname===wh,J3=t=>{const e=Je.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=Zt(s4),l=Qe(n4),a=Qe(r4),d=Rc(),u=c.useRef(null);let f;e[0]!==n.directory?(f=xc(n.directory),e[0]=n.directory,e[1]=f):f=e[1];const h=f;let x;e[2]!==o?(x=xc(o),e[2]=o,e[3]=x):x=e[3];const b=x;let w,S;if(e[4]!==b||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==h||e[9]!==r||e[10]!==a||e[11]!==d?(w=()=>{if(r||h&&b!==h)return;const N=`${h}
|
|
926
|
-
${n.sessionId}`;u.current===N&&l||(u.current=N,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},S=[b,l,n.directory,n.sessionId,h,r,a,d],e[4]=b,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=h,e[9]=r,e[10]=a,e[11]=d,e[12]=w,e[13]=S):(w=e[12],S=e[13]),c.useEffect(w,S),h&&b!==h)return null;let g;e[14]!==i?(g=s.jsx(ad,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=g):g=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(yd,{}),e[16]=m):m=e[16];let p;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(p=s.jsx(xd,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=p):p=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(ld,{}),e[21]=y):y=e[21];let v;return e[22]!==g||e[23]!==p?(v=s.jsxs(s.Fragment,{children:[g,m,p,y]}),e[22]=g,e[23]=p,e[24]=v):v=e[24],v};function Z3({apis:t}){c.useEffect(()=>{Ju("App:mounted"),Zu()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Ht(V=>V.initializeApp),n=Ht(V=>V.isInitialized),r=Ht(V=>V.isConnected),i=Ht(V=>V.providers.length),o=Ht(V=>V.agents.length),l=Ht(V=>V.loadProviders),a=Ht(V=>V.loadAgents),d=Qe(V=>V.error),u=Qe(V=>V.clearError),f=Zt(V=>V.currentDirectory),h=Zt(V=>V.setDirectory),x=Zt(V=>V.isSwitchingDirectory),[b,w]=c.useState(!1),S=Hn(V=>V.refreshStatus),[g,m]=c.useState(()=>t.runtime.isVSCode),[p,y]=c.useState(!1),[v,N]=c.useState(!1),[C,k]=c.useState(0),[A,D]=c.useState(0),[P,T]=c.useState(!1),$=Ce(V=>V.wideChatLayoutEnabled),E=Ce(V=>V.mobileKeyboardMode),U=c.useMemo(()=>cn(),[]),I=Zi(V=>V.setPlanModeEnabled),[B,R]=c.useState(()=>Na()),[j,M]=c.useState(()=>{const V=Aa();return V!==null?Da({isDesktopShell:!0,bootOutcome:V}):null}),L=c.useRef(!1),W=c.useMemo(()=>Y3(),[]),te=!W||p,Q=c.useMemo(()=>X3(),[]);c.useEffect(()=>(Pa(b),()=>{Pa(!1)}),[b]),c.useEffect(()=>{ef(E)},[E]),c.useEffect(()=>{m(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Fo(V=>{Yh(V),D(Y=>Y+1),N(!1),k(Y=>Y+1)}),[]);const me=Wa(V=>{const Y=ks();return Object.values(V.runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===Y).map(le=>`${le.originalSessionID}:${le.phase}:${le.lastForwardedMessageID??""}:${le.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(W)return;const V=ks(),Y=Object.values(Wa.getState().runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===V);for(const le of Y)gh(le.originalSessionID)},[me,W,A]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",$),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[$]),c.useEffect(()=>(Ia(t),()=>Ia(null)),[t]),c.useEffect(()=>{W||S(t.github,{force:!0})},[t.github,W,S]),bh();const ce=B==="valid",H=j?.screen==="main";c.useEffect(()=>{if(!tf({isDesktopShell:U,isInitialized:n,bootOutcomeKnown:ce,bootViewIsMain:H}))return;const V=setTimeout(()=>{const Y=document.getElementById("initial-loading");Y&&(Y.classList.add("fade-out"),setTimeout(()=>{Y.remove()},300))},150);return()=>clearTimeout(V)},[U,n,ce,H]),c.useEffect(()=>{if(!U||B!=="malformed")return;const V=document.getElementById("initial-loading");V&&(V.textContent="Desktop startup failed — please restart the app.")},[U,B]),c.useEffect(()=>{if(U)return;const V=setTimeout(()=>{const Y=document.getElementById("initial-loading");Y&&!n&&(Y.classList.add("fade-out"),setTimeout(()=>{Y.remove()},300))},5e3);return()=>clearTimeout(V)},[U,n]),c.useEffect(()=>{let V=!1;return(async()=>{const le=await ss("/health",{method:"GET"}).catch(()=>null);if(!le||!le.ok||V)return;const pe=await le.json().catch(()=>null);if(!pe||V)return;const be=pe.planModeExperimentalEnabled;I(be===!0||be===1||be==="1"||be==="true")})(),()=>{V=!0}},[I]),c.useEffect(()=>{g||e()},[e,g]),c.useEffect(()=>{if(g||n)return;let V=!0,Y,le=0;const pe=10,be=1e3,Se=async()=>{if(!V)return;if(le>=pe){N(!0);return}const De=Ht.getState();if(De.isInitialized){N(!1);return}le+=1,await De.initializeApp();const fe=Ht.getState();if(!V)return;if(fe.isInitialized){N(!1);return}if(le>=pe){N(!0);return}const xe=Math.min(be*Math.pow(2,le-1),16e3);Y=setTimeout(Se,xe)};return Y=setTimeout(Se,be),()=>{V=!1,Y&&clearTimeout(Y)}},[C,n,g]),c.useEffect(()=>{n&&N(!1)},[n]),c.useEffect(()=>{if(!v)return;const V=document.getElementById("initial-loading");V&&(V.classList.add("fade-out"),setTimeout(()=>{V.remove()},300))},[v]),c.useEffect(()=>{if(g||!r||i>0&&o>0)return;let V=!0,Y=0;const le=15,pe=async()=>{const Se=Ht.getState();if(!(Se.providers.length>0&&Se.agents.length>0))try{Se.providers.length===0&&await l({source:"startupRecovery"}),Ht.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};pe();const be=setInterval(()=>{if(V){if(++Y>=le){clearInterval(be);return}pe()}},2e3);return()=>{V=!1,clearInterval(be)}},[r,g,a,l,i,o]),c.useEffect(()=>{x||g||r&&Es.setDirectory(f)},[f,x,r,g]),c.useEffect(()=>{if(!W||typeof window>"u")return;const V=pe=>{y(pe?.visible===!0)},Y=pe=>{if(pe.origin!==window.location.origin||pe.source!==window.parent)return;const be=pe.data;be?.type===Dd&&V(be.payload)},le=window;return le.__openchamberSetEmbeddedVisibility=V,window.addEventListener("message",Y),xp(),()=>{window.removeEventListener("message",Y),le.__openchamberSetEmbeddedVisibility===V&&delete le.__openchamberSetEmbeddedVisibility}},[W]),c.useEffect(()=>{!W?.directory||g||f!==W.directory&&h(W.directory,{showOverlay:!1})},[f,W,g,h]),c.useEffect(()=>{if(!W||typeof window>"u")return;const V=Y=>{Y.storageArea===window.localStorage&&Y.key==="ui-store"&&Ce.persist.rehydrate()};return window.addEventListener("storage",V),()=>{window.removeEventListener("storage",V)}},[W]),c.useEffect(()=>{if(typeof window>"u")return;const V=Y=>{const le=Y.detail,pe=typeof le?.sessionId=="string"?le.sessionId.trim():"";if(!pe)return;const be=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null;Qe.getState().setCurrentSession(pe,be)};return window.addEventListener("openchamber:open-session",V),()=>window.removeEventListener("openchamber:open-session",V)},[]),c.useEffect(()=>{if(typeof window>"u")return;const V=()=>{Nn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",V),()=>window.removeEventListener("openchamber:open-mini-chat",V)},[]),c.useEffect(()=>{if(typeof window>"u")return;const V=()=>{const Y=Qe.getState().currentSessionId;Y&&Fc(Y)};return window.addEventListener("focus",V),()=>window.removeEventListener("focus",V)},[]),c.useEffect(()=>{if(typeof window>"u")return;const V=Y=>{const le=Y.detail,pe=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null,be=typeof le?.projectId=="string"&&le.projectId.trim().length>0?le.projectId.trim():null,Se=!!(pe||be);Ce.getState().setSessionSwitcherOpen(!1),Qe.getState().openNewSessionDraft({target:Se?"project":"chat",selectedProjectId:Se?be:null,directoryOverride:Se?pe:null,preserveDirectoryOverride:!!pe})};return window.addEventListener("openchamber:open-draft-session",V),()=>window.removeEventListener("openchamber:open-draft-session",V)},[]),c.useEffect(()=>{typeof window>"u"||!n||x||L.current||(L.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,x]),xh({enabled:te}),_3({enabled:te}),L3(f||null),U3(),yh(),Xh();const ne=c.useCallback(()=>{w(V=>!V)},[]);g3(ne),D3(),T3(!W),c.useEffect(()=>{if(W)return;const V=()=>w(Y=>!Y);return window.addEventListener("openchamber:memory-debug-toggle",V),()=>window.removeEventListener("openchamber:memory-debug-toggle",V)},[W]),c.useEffect(()=>{W||d&&setTimeout(()=>u(),5e3)},[u,W,d]),c.useEffect(()=>{if(!U||B!=="not-injected")return;let V=!1,Y=0;const le=200,pe=2e3,be=50,Se=()=>{if(V)return;Y++;const De=Na();if(De!=="not-injected"){if(V=!0,R(De),De==="valid"){const xe=Aa();xe&&M(Da({isDesktopShell:!0,bootOutcome:xe}))}return}const fe=Math.min(le*Math.pow(1.1,Y),pe);if(Y>=be){const xe=document.getElementById("initial-loading");xe&&!xe.textContent?.includes("taking longer")&&(xe.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Se,fe)};return window.setTimeout(Se,le),()=>{V=!0}},[U,B]);const ie=c.useCallback(async()=>{if(sf({isDesktopShell:cn(),isDesktopLocalOriginActive:Oo()})){await nf();return}window.location.reload()},[]),F=c.useCallback(async()=>{if(!P){N(!1),T(!0);try{await Ht.getState().initializeApp()}finally{T(!1)}Ht.getState().isInitialized||k(V=>V+1)}},[P]),Z=V=>{if(V.screen==="recovery")return V.variant};if(U&&j&&j.screen!=="main"){if(j.screen==="chooser")return s.jsx(Vs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(bc,{mode:"first-launch",localAvailable:j.localAvailable!==!1,onCliAvailable:ie,onChooseRemote:()=>{}})})})});const V=Z(j),Y=j.screen==="recovery"&&"url"in j?j.url:void 0;return s.jsx(Vs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(bc,{mode:"recovery",recoveryVariant:V,recoveryHostUrl:Y,recoveryHostLabel:void 0,localAvailable:j.localAvailable!==!1,onCliAvailable:ie})})})})}if(W)return s.jsx(Vs,{children:s.jsx(Va,{sdk:Es.getSdkClient(),directory:f||"",children:s.jsx(Ua,{apis:t,children:s.jsx(vi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(J3,{embeddedSessionChat:W,isVSCodeRuntime:g,embeddedBackgroundWorkEnabled:te}),s.jsx(Ha,{})]})})})},A)});if(Q)return s.jsx(Vs,{children:s.jsx(G3,{})});if(v&&!n&&!g&&!W)return s.jsx(Vs,{children:s.jsx(Q3,{onRetry:()=>{F()},isRetrying:P})});const G=!n&&!U;return s.jsx(Vs,{children:s.jsx(Va,{sdk:Es.getSdkClient(),directory:f||"",children:s.jsx(Ua,{apis:t,children:s.jsx(e3,{children:s.jsx(vi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:U?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(ad,{embeddedBackgroundWorkEnabled:te}),s.jsx(yd,{}),s.jsx(Mk,{}),s.jsx(ld,{}),s.jsx(Ha,{}),!G&&s.jsxs(s.Fragment,{children:[s.jsx(Jh,{}),s.jsx(q3,{}),b&&s.jsx(n3,{onClose:()=>w(!1)})]})]})})})})},A)})}function e4(t){return t.isAboutDialogOpen}function t4(t){return t.setAboutDialogOpen}function s4(t){return t.currentDirectory}function n4(t){return t.currentSessionId}function r4(t){return t.setCurrentSession}const o4=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Sh();rf().then(()=>{Promise.all([of(),vh()]).catch(t=>{console.error("[main] settings init failed:",t)}),jh(),kh(),Ch()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Ru=document.getElementById("root");if(!Ru)throw new Error("Root element not found");Mu.createRoot(Ru).render(s.jsx(ot.StrictMode,{children:s.jsx(Nh,{children:s.jsx(Ah,{children:s.jsx(Dh,{children:s.jsx(Ph,{children:s.jsx(Z3,{apis:o4})})})})})}));const k4=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Qg as W,Lg as a,j4 as b,cb as d,Gd as g,v4 as h,k4 as m,qg as u,Kd as v};
|