@aiworker/web 1.23.0 → 1.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-B1Gizi3a.js → CodeMirrorCommentWidgets-COGJG0Iv.js} +1 -1
- package/dist/assets/DiffView-BviYY3zL.js +4 -0
- package/dist/assets/{DirtyBranchSwitchDialog-aig6zJjg.js → DirtyBranchSwitchDialog-C26DvfVJ.js} +1 -1
- package/dist/assets/FilesView-D0ZU_nCt.js +13 -0
- package/dist/assets/{GitView-BXsS3jG6.js → GitView-CYgiDRH-.js} +4 -4
- package/dist/assets/{JsonTreeView-D_hpXBnF.js → JsonTreeView-GsV9UScz.js} +1 -1
- package/dist/assets/{LinearIssuesView-BoUiLQG1.js → LinearIssuesView-shqUS8nl.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-B_B_a9KS.js → MarkdownImageGallery-CQSTFp6m.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-xgyyLiBM.js → MarkdownRendererImpl-DJWP3A8X.js} +2 -2
- package/dist/assets/{OnboardingScreen-DIp84OWt.js → OnboardingScreen-CTuu4lgo.js} +1 -1
- package/dist/assets/{PatchDiff-8p6nLJaU.js → PatchDiff-Dp53v2pl.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DjC8nTk9.js → PierreDiffViewer-B5l0djPS.js} +1 -1
- package/dist/assets/PlanView-CLUWkGiG.js +5 -0
- package/dist/assets/SettingsView-CojPQVHx.js +28 -0
- package/dist/assets/{SettingsWindow-Cpb4hM6q.js → SettingsWindow-DbgEnZ6T.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DfaKZXNU.js → ToolOutputDialog-Du-RZj-a.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-DtZLzrSK.js → ToolPartDiffPreview-HBLSokoe.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-C8i9HpTB.js → VirtualizedFileDiff-Bzp3hClU.js} +4 -4
- package/dist/assets/WalkthroughView-CpgA4s9w.js +4 -0
- package/dist/assets/{computeVirtualFileMetrics-BBI7ZwrC.js → computeVirtualFileMetrics-CI1PC_z2.js} +2 -2
- package/dist/assets/de-BX8b4hDD.js +10 -0
- package/dist/assets/es-e98cS-yM.js +16 -0
- package/dist/assets/fr-BOiqxJAs.js +14 -0
- package/dist/assets/index-BD8ILbxF.js +40 -0
- package/dist/assets/{index-jXSK5RrB.js → index-Cmn74sw-.js} +1 -1
- package/dist/assets/index-zhgg-SDz.css +1 -0
- package/dist/assets/{isDiffPlainText-B_x_rVon.js → isDiffPlainText-DVralkU-.js} +1 -1
- package/dist/assets/{isFilePlainText-DW_xMer1.js → isFilePlainText-CgTREsRX.js} +1 -1
- package/dist/assets/ja-aoO55hGu.js +16 -0
- package/dist/assets/{ko-idhXGF8j.js → ko-BGzFLogk.js} +3 -3
- package/dist/assets/{main-CzdPuL0s.js → main-BgfXQ-4g.js} +2 -2
- package/dist/assets/main-DGYUWmIt.js +930 -0
- package/dist/assets/{markdownCore-Cn4Tyejo.js → markdownCore-BesaNs_G.js} +3 -3
- package/dist/assets/{miniChat-CCkqKOLp.js → miniChat-DHKXp-_I.js} +2 -2
- package/dist/assets/{mobile-mvxTo055.js → mobile-lXQ08VnX.js} +2 -2
- package/dist/assets/patchFileDiff-i1lTtNbn.js +13 -0
- package/dist/assets/{pl-CGZWUqZJ.js → pl-B5x19laq.js} +3 -3
- package/dist/assets/pt-BR-C3oU51Il.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-CuO4ue6B.js +2 -0
- package/dist/assets/renderMobileApp-B3zFlHy4.js +25 -0
- package/dist/assets/runtimeEndpointReset-BLzrtrmj.js +41 -0
- package/dist/assets/scheduledTasksApi-BEuUF_cj.js +1 -0
- package/dist/assets/{shikiHighlight-CRl0SUC9.js → shikiHighlight-ctlcPvvx.js} +1 -1
- package/dist/assets/surface-COKb77Ua.js +1 -0
- package/dist/assets/tr-C0QQa7et.js +7 -0
- package/dist/assets/uk-CqLSe9wT.js +16 -0
- package/dist/assets/{useAppFontEffects-CPKeOpUo.js → useAppFontEffects-B6OfEypo.js} +153 -155
- package/dist/assets/useGitComparison-BXZXEAW6.js +1 -0
- package/dist/assets/{useInlineCommentController-BiWz4AVb.js → useInlineCommentController-CgbrpEWu.js} +2 -2
- package/dist/assets/{useRootScrollLock-BS4-kr7P.js → useRootScrollLock-Me41OjBT.js} +1 -1
- package/dist/assets/{vendor-base-ui-DdV8vhHn.js → vendor-base-ui-BY_5qla_.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-Bg4AEeCr.js → vendor-codemirror-language-data-SJuFp0a0.js} +2 -2
- package/dist/assets/vendor-legendapp-list-BuBPBC3R.js +1 -0
- package/dist/assets/{vendor-zod-BPAANqvH.js → vendor-zod-B6551dwG.js} +2 -2
- package/dist/assets/{web-components-z7hfnS8n.js → web-components-D8GS8Ork.js} +1 -1
- package/dist/assets/zh-CN-iJEie4d6.js +16 -0
- package/dist/assets/zh-TW-CyslEwlK.js +16 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +1 -1
- package/server/index.js +3 -13
- package/server/lib/agent-memory/runtime.js +7 -2
- package/server/lib/agent-memory/runtime.test.js +22 -0
- package/server/lib/event-stream/DOCUMENTATION.md +3 -0
- package/server/lib/event-stream/global-hub.js +29 -4
- package/server/lib/event-stream/global-hub.test.js +22 -0
- package/server/lib/event-stream/global-ws-bridge.js +15 -18
- package/server/lib/event-stream/protocol.js +21 -7
- package/server/lib/event-stream/runtime.js +9 -6
- package/server/lib/event-stream/runtime.test.js +60 -0
- package/server/lib/git/DOCUMENTATION.md +10 -1
- package/server/lib/git/routes.js +21 -8
- package/server/lib/git/routes.test.js +78 -0
- package/server/lib/git/service.js +159 -4
- package/server/lib/git/service.test.js +74 -0
- package/server/lib/github/DOCUMENTATION.md +5 -0
- package/server/lib/github/routes.js +2 -2
- package/server/lib/message-queue/DOCUMENTATION.md +7 -0
- package/server/lib/message-queue/runtime.js +13 -0
- package/server/lib/message-queue/runtime.test.js +31 -1
- package/server/lib/notifications/DOCUMENTATION.md +1 -1
- package/server/lib/notifications/emitter-runtime.js +4 -3
- package/server/lib/opencode/DOCUMENTATION.md +18 -4
- package/server/lib/opencode/env-runtime.js +5 -1
- package/server/lib/opencode/env-runtime.test.js +72 -0
- package/server/lib/opencode/feature-routes-runtime.js +15 -1
- package/server/lib/opencode/lifecycle.js +4 -3
- package/server/lib/opencode/lifecycle.test.js +29 -0
- package/server/lib/opencode/managed-plugin-config.js +1 -1
- package/server/lib/opencode/proxy.js +33 -0
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +11 -1
- package/server/lib/opencode/settings-registry.json +3 -0
- package/server/lib/opencode/settings-runtime.js +36 -9
- package/server/lib/opencode/settings-runtime.test.js +158 -2
- package/server/lib/project-context/DOCUMENTATION.md +13 -3
- package/server/lib/project-context/runtime.js +8 -2
- package/server/lib/project-context/runtime.test.js +54 -0
- package/server/lib/projects/DOCUMENTATION.md +2 -1
- package/server/lib/projects/project-config.js +38 -9
- package/server/lib/projects/project-config.test.js +97 -0
- package/server/lib/projects/project-id.js +26 -0
- package/server/lib/relay/DOCUMENTATION.md +20 -0
- package/server/lib/relay/host-client.js +7 -0
- package/server/lib/relay/host-client.test.js +14 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +9 -1
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +28 -0
- package/server/lib/scheduled-tasks/runtime.js +12 -2
- package/server/lib/scheduled-tasks/runtime.test.js +53 -0
- package/server/lib/session-assist/DOCUMENTATION.md +131 -66
- package/server/lib/session-assist/context.js +127 -0
- package/server/lib/session-assist/context.test.js +132 -0
- package/server/lib/session-assist/prompt.js +54 -0
- package/server/lib/session-assist/runtime.js +111 -257
- package/server/lib/session-assist/runtime.test.js +203 -0
- package/server/lib/walkthrough/DOCUMENTATION.md +15 -5
- package/server/lib/walkthrough/pr-source.test.js +21 -0
- package/server/lib/walkthrough/pull-request.js +7 -4
- package/server/lib/walkthrough/pull-request.test.js +16 -0
- package/server/lib/walkthrough/routes.js +19 -0
- package/server/lib/walkthrough/routes.test.js +26 -0
- package/server/lib/walkthrough/sources.js +13 -2
- package/server/opencode-worktree-readiness.test.js +130 -0
- package/dist/assets/DiffView-DXjVsEOw.js +0 -4
- package/dist/assets/FilesView-CJdG0-wk.js +0 -17
- package/dist/assets/PlanView-CJTmOF6I.js +0 -5
- package/dist/assets/SettingsView-DD-JqIJx.js +0 -28
- package/dist/assets/WalkthroughView-DeKMvZlL.js +0 -4
- package/dist/assets/de-DCrsQ5zS.js +0 -10
- package/dist/assets/es-Dwv4YfH6.js +0 -16
- package/dist/assets/fr-BCWg4Cnx.js +0 -14
- package/dist/assets/index-B68h5S5B.css +0 -1
- package/dist/assets/index-DVwMarHI.js +0 -39
- package/dist/assets/ja-Bruw3RYC.js +0 -16
- package/dist/assets/main-BkyaQhJX.js +0 -930
- package/dist/assets/patchFileDiff-Csk4iNUi.js +0 -13
- package/dist/assets/pt-BR-B8V7u7tA.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-BxoyujA5.js +0 -2
- package/dist/assets/renderMobileApp-B48CsP4r.js +0 -25
- package/dist/assets/runtimeEndpointReset-Bg5gx18H.js +0 -17
- package/dist/assets/scheduledTasksApi-BW0Etzwz.js +0 -1
- package/dist/assets/surface-oMvhsog3.js +0 -1
- package/dist/assets/tr-BK_KiO2V.js +0 -7
- package/dist/assets/uk-CG74xV8N.js +0 -16
- package/dist/assets/useGitComparison-DH220WmO.js +0 -1
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +0 -1
- package/dist/assets/zh-CN-T4AXofZI.js +0 -16
- package/dist/assets/zh-TW-Dte40sxp.js +0 -16
- package/server/lib/mcp-reconnect/DOCUMENTATION.md +0 -55
- package/server/lib/mcp-reconnect/runtime.js +0 -122
- package/server/lib/mcp-reconnect/runtime.test.js +0 -140
|
@@ -0,0 +1,930 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-CpgA4s9w.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-B6OfEypo.js","assets/index-BD8ILbxF.js","assets/vendor-zod-B6551dwG.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-zhgg-SDz.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BY_5qla_.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.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/contextPanelEmbeddedChat-BdA6bdky.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-SJuFp0a0.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-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-i1lTtNbn.js","assets/runtimeEndpointReset-BLzrtrmj.js","assets/VirtualizedFileDiff-Bzp3hClU.js","assets/web-components-D8GS8Ork.js","assets/computeVirtualFileMetrics-CI1PC_z2.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/isDiffPlainText-DVralkU-.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-B5l0djPS.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-CgbrpEWu.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/useRootScrollLock-Me41OjBT.js","assets/scheduledTasksApi-BEuUF_cj.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-BviYY3zL.js","assets/useGitComparison-BXZXEAW6.js","assets/FilesView-D0ZU_nCt.js","assets/shikiHighlight-ctlcPvvx.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-GsV9UScz.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-CgTREsRX.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-COGJG0Iv.js","assets/GitView-CYgiDRH-.js","assets/DirtyBranchSwitchDialog-C26DvfVJ.js","assets/LinearIssuesView-shqUS8nl.js","assets/PlanView-CLUWkGiG.js","assets/SettingsWindow-DbgEnZ6T.js","assets/SettingsView-CojPQVHx.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/OnboardingScreen-CTuu4lgo.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as st,R as c,j as s,r as gt,h as Uf}from"./vendor-react-BUCujlKS.js";import{D as bn,E as Wo,F as Kf,G as ad,h as ds,v as zo,u as Te,H as Mt,I as Ga,J as Hf,K as Pn,L as Gf,N as vt,O as qs,P as Vo,Q as ld,R as qf,S as Qf,T as Yf,U as Xf,V as cd,z as ma,n as ts,W as Mn,X as $r,e as Nn,Y as Jf,a as us,Z as Zf,_ as em,$ as tm,a0 as dd,t as hn,A as Qs,a1 as sm,a2 as nm,a3 as qa,a4 as rm,a5 as ud,a6 as om,a7 as fd,f as im,a8 as am,a9 as or,aa as ha,d as No,q as Rr,o as ls,ab as md,ac as lm,ad as wi,ae as cm,af as dm,i as um,ag as fo,ah as mo,ai as fm,aj as Qa,ak as mm,al as hm,am as pm,an as gm,ao as Ya,ap as Xa,aq as Ja,ar as Za,as as xm,y as el,at as bm,au as ym,av as wm,B as Sm,C as vm}from"./index-BD8ILbxF.js";import{_ as Bn}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as Nt,h as Ie,bb as Kt,I as E,g as gn,t as Le,ap as Ys,bc as Os,ar as Xs,ao as Js,R as Zn,Y as Sn,ae as er,bd as _n,o as Uo,be as tl,bf as jm,bg as km,a9 as At,aa as Dt,ab as Pt,b as Ht,y as Je,G as Cm,bh as hd,bi as Jr,u as Is,A as pa,r as Ts,C as pd,bj as Si,bk as Nm,bl as gd,bm as xd,bn as bd,bo as ga,bp as Ko,bq as yd,br as wd,bs as Am,bt as sl,bu as Dm,bv as Pm,bw as xa,bx as vi,by as Im,bz as Tm,N as Sd,bA as Rm,l as qt,bB as Em,n as ar,bC as vd,p as Mm,bD as jd,bE as Om,bF as Fm,bG as Bm,bH as kd,bI as Cd,bJ as _m,aD as ba,bK as qn,bL as qr,bM as Lm,bN as vs,bO as js,bP as $s,bQ as Rs,bR as Es,bS as yn,B as xt,bT as cn,ax as Gs,bU as $m,bV as Wm,aB as An,bW as ho,bX as Hs,bY as Ho,bZ as Nd,b_ as ji,b$ as ki,c0 as Ci,c1 as zm,c2 as Fs,c3 as Bs,c4 as As,c5 as _s,c6 as ss,V as Cn,c7 as lr,c8 as nl,c9 as ur,ca as Ad,Q as Go,af as Vm,ag as ya,ah as Dd,H as Pd,J as Dn,cb as qo,a4 as wa,cc as Um,cd as Km,av as Hm,ce as Gm,cf as qm,cg as Qm,aw as Sa,ch as va,ci as fr,cj as Id,ck as Ym,cl as Xm,cm as Qr,cn as Jm,aJ as Yr,co as Zm,cp as ir,O as Td,cq as eh,cr as th,cs as Ln,ct as sh,cu as nh,cv as ei,cw as Rd,cx as Ed,cy as rh,aC as Ni,cz as Ai,cA as oh,cB as rl,cC as Er,c as Wr,d as ja,a0 as ih,cD as Md,cE as jr,cF as Mr,cG as ah,cH as lh,cI as ch,Z as Od,ay as dh,cJ as uh,cK as fh,cL as mh,cM as hh,cN as Fd,cO as xn,cP as ph,cQ as Bd,cR as gh,cS as Di,cT as xh,cU as bh,cV as _d,cW as yh,cX as Ld,a2 as Ao,cY as Pi,T as ka,S as Ca,U as Na,cZ as Aa,a as Da,a1 as wh,c_ as ol,c$ as Ii,d0 as $d,d1 as Sh,aq as Wd,d2 as vh,P as Ti,K as jh,d3 as il,d4 as kh,d5 as al,d6 as Ch,d7 as Nh,d8 as Ah,d9 as cs,da as Dh,db as Fn,dc as Pa,dd as zd,de as Ph,df as Vd,dg as Ud,dh as Ih,D as Th,di as Rh,dj as Eh,dk as Mh,dl as ll,dm as Oh,dn as Fh,dp as Kd,E as Bh,dq as po,dr as Hd,ds as _h,dt as Lh,du as $h,dv as Wh,e as Gd,dw as Ia,dx as zh,dy as zr,dz as Vh,dA as cl,dB as Uh,dC as Kh,$ as Hh,dD as Gh,aV as dl,a6 as ul,a5 as fl,dE as qh,aQ as Ri,dF as Qh,L as Yh,M as ti,dG as Xh,dH as Jh,dI as qd,dJ as Qd,dK as Yd,dL as Zh,F as Ta,dM as ep,a3 as tp,dN as sp,dO as np,dP as rp,dQ as op,dR as ip,dS as ap,dT as lp,dU as cp,dV as Do,ai as dp,dW as up,dX as ml,dY as fp,dZ as mp,d_ as hp,d$ as pp,e0 as Po,e1 as gp,e2 as hl,e3 as xp,e4 as bp,e5 as yp,e6 as wp,e7 as Sp,e8 as vp,e9 as go,ea as jp,i as kp,eb as Cp,ec as Np,ed as Ap,ee as Dp,a7 as Pp,ef as Ip,eg as Tp,eh as Rp,ei as Ep,ej as pl,ek as Mp,aK as Op,aL as Fp,aM as Bp,aO as gl,aP as xl,aS as bl,aT as yl,aR as Xd,aU as Jd,el as _p,b6 as Lp,b7 as $p,b8 as Wp,b9 as zp,ba as Vp,b0 as Up,b2 as Kp,b3 as Hp,b4 as Gp,b5 as qp}from"./useAppFontEffects-B6OfEypo.js";import{u as Zd,S as wl,C as Qp,W as eu,f as Yp,a as Xp}from"./useRootScrollLock-Me41OjBT.js";import{n as Sl,o as si,t as un,q as Ei,v as vl,w as Jp,x as Zp,y as eg,z as tg,A as sg,E as ng,F as rg,G as og,H as Ra,I as ig,a as ag,U as tu,h as Mi,f as su,J as lg,e as cg,d as dg,K as nu,L as Oi,M as Un,Q as ru,R as ou,P as ug,T as fg,V as mg,W as hg,X as pg,Y as gg,S as jl,Z as xg,_ as bg,$ as yg,u as Fr,s as wg,N as Sg,D as vg,a0 as jg,a1 as kl,a2 as kg,k as Cg,i as Ng,l as iu,m as Ag,a3 as Dg,a4 as Pg,a5 as Ig,g as Tg,j as Rg,O as au,C as Eg}from"./runtimeEndpointReset-BLzrtrmj.js";import{u as Wn,O as Cl,D as Mg,a as Og,b as Fg,n as Bg,f as _g,c as Nl,s as Lg,d as $g,e as Wg,r as zg}from"./scheduledTasksApi-BEuUF_cj.js";import{f as Vr,h as On,T as lu,M as cu,D as Ur,j as Kr,d as Vg,P as Fi,b as Ug,k as Bi,i as Kg}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Qo,S as Io,h as Hg,a as du,v as _i,s as Gg}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Yo}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as uu,M as fu,C as mu,a as Li,b as $i,c as Wi,d as hu,e as qg,f as Qg}from"./vendor-base-ui-BY_5qla_.js";import{c as tr,u as Jn,d as pu,p as Yg}from"./vendor-zustand-BAGL70zf.js";import{g as Xg,a as Jg,E as gu,b as Zg,c as ex,d as tx,e as sx,i as nx}from"./contextPanelEmbeddedChat-BdA6bdky.js";import{c as Ea,s as br,r as xu}from"./vendor-zod-B6551dwG.js";import{u as rx}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{d as bu}from"./vendor-cron-parser-CUcP7OfX.js";const ox="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",ix="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",ni=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__AIWORKER_PLATFORM__==="darwin"?ox:t.id==="terminal"?ix:void 0}),Al=t=>{const e=st.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 u=a,d=r||i;if(d&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let g;return e[3]!==d?(g=s.jsx("img",{src:d,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=d,e[4]=g):g=e[4],g}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Ie("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let f;return e[6]!==u?(f=s.jsx("span",{className:h,children:u}),e[6]=u,e[7]=f):f=e[7],f},ax=t=>{const e=st.c(75),{directory:n,className:r}=t,{t:i}=Nt(),o=Wn(lx),l=Wn(cx),a=Wn(dx),u=Wn(ux),d=Wn(fx),h=Wn(mx),f=Wn(hx);let p,g;e[0]!==d?(p=()=>{d()},g=[d],e[0]=d,e[1]=p,e[2]=g):(p=e[1],g=e[2]),c.useEffect(p,g);const w=bn()&&Wo();let S;e:{let K;e[3]!==l||e[4]!==o?(K=l.find(ne=>ne.id===o)??l.find(px)??l[0]??Cl[0],e[3]=l,e[4]=o,e[5]=K):K=e[5];const pe=K;if(pe){let ne;e[6]!==pe?(ne=ni(pe),e[6]=pe,e[7]=ne):ne=e[7],S=ne;break e}let je;e[8]===Symbol.for("react.memo_cache_sentinel")?(je=ni(Cl[0]),e[8]=je):je=e[8],S=je}const x=S;if(!w||!n||l.length===0)return null;let m;e[9]!==n?(m=async K=>{await Kf(n,K.id,K.appName)||await ad(n,K.appName)},e[9]=n,e[10]=m):m=e[10];const b=m;let y;e[11]!==b||e[12]!==f?(y=async K=>{await f(K.id),await b(K)},e[11]=b,e[12]=f,e[13]=y):y=e[13];const v=y;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await gn(n)).ok&&Le.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=Ie("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 D;e[19]!==b||e[20]!==x?(D=()=>{b(x)},e[19]=b,e[20]=x,e[21]=D):D=e[21];const P=u&&"animate-pulse";let I;e[22]!==P?(I=Ie("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",P),e[22]=P,e[23]=I):I=e[23];let M;e[24]!==x.label||e[25]!==i?(M=i("openInApp.actions.openInAria",{app:x.label}),e[24]=x.label,e[25]=i,e[26]=M):M=e[26];let _;e[27]!==x.fallbackIconDataUrl||e[28]!==x.iconDataUrl||e[29]!==x.label?(_=s.jsx(Al,{label:x.label,iconDataUrl:x.iconDataUrl,fallbackIconDataUrl:x.fallbackIconDataUrl}),e[27]=x.fallbackIconDataUrl,e[28]=x.iconDataUrl,e[29]=x.label,e[30]=_):_=e[30];let O;e[31]!==I||e[32]!==M||e[33]!==_||e[34]!==D?(O=s.jsx("button",{type:"button",onClick:D,className:I,"aria-label":M,children:_}),e[31]=I,e[32]=M,e[33]=_,e[34]=D,e[35]=O):O=e[35];let U;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=Ie("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 L;e[37]!==i?(L=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=L):L=e[38];let F;e[39]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(E,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=F):F=e[39];let R;e[40]!==L?(R=s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:U,"aria-label":L,children:F})}),e[40]=L,e[41]=R):R=e[41];let j;e[42]!==C?(j=()=>{C()},e[42]=C,e[43]=j):j=e[43];let A;e[44]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(E,{name:"file-copy",className:"h-4 w-4"}),e[44]=A):A=e[44];let B;e[45]!==i?(B=i("openInApp.actions.copyPath"),e[45]=i,e[46]=B):B=e[46];let X;e[47]!==B?(X=s.jsx("span",{className:"typography-ui-label text-foreground",children:B}),e[47]=B,e[48]=X):X=e[48];let H;e[49]!==j||e[50]!==X?(H=s.jsxs(Kt,{className:"flex items-center gap-2",onClick:j,children:[A,X]}),e[49]=j,e[50]=X,e[51]=H):H=e[51];let Z;e[52]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Os,{}),e[52]=Z):Z=e[52];let ce;if(e[53]!==l||e[54]!==v||e[55]!==x.id){let K;e[57]!==v||e[58]!==x.id?(K=pe=>{const je=ni(pe);return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{v(pe)},children:[s.jsx(Al,{label:pe.label,iconDataUrl:pe.iconDataUrl,fallbackIconDataUrl:je.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:pe.label}),x.id===pe.id?s.jsx(E,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},pe.id)},e[57]=v,e[58]=x.id,e[59]=K):K=e[59],ce=l.map(K),e[53]=l,e[54]=v,e[55]=x.id,e[56]=ce}else ce=e[56];let Y;e[60]!==a||e[61]!==h||e[62]!==i?(Y=a?s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(E,{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]=h,e[62]=i,e[63]=Y):Y=e[63];let se;e[64]!==H||e[65]!==ce||e[66]!==Y?(se=s.jsxs(Xs,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[H,Z,ce,Y]}),e[64]=H,e[65]=ce,e[66]=Y,e[67]=se):se=e[67];let oe;e[68]!==R||e[69]!==se?(oe=s.jsxs(Js,{children:[R,se]}),e[68]=R,e[69]=se,e[70]=oe):oe=e[70];let Se;return e[71]!==O||e[72]!==oe||e[73]!==k?(Se=s.jsxs("div",{className:k,children:[O,oe]}),e[71]=O,e[72]=oe,e[73]=k,e[74]=Se):Se=e[74],Se};function lx(t){return t.selectedAppId}function cx(t){return t.availableApps}function dx(t){return t.isCacheStale}function ux(t){return t.isScanning}function fx(t){return t.initialize}function mx(t){return t.loadInstalledApps}function hx(t){return t.selectApp}function px(t){return t.id===Mg}const To=new Map,zi=new Set,yu=()=>{for(const t of zi)t()},ri=(t,e)=>{const n=t.trim();n&&(e.length===0?To.delete(n):To.set(n,[...e]),yu())},gx=t=>{To.delete(t.trim())&&yu()},wu=[],xx=t=>To.get(t.trim())??wu,bx=t=>(zi.add(t),()=>{zi.delete(t)}),yx=t=>{const e=st.c(2);let n;return e[0]!==t?(n=()=>xx(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(bx,n,wx)};function wx(){return wu}const Sx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],vx=["dev","start","preview","serve"];async function jx(t,e,n){if(!t)return null;const r=Nx(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Ax(n);if(i){const o=await Dx(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 kx(t)){const i=await Cx(),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 kx(t){const e=`${t}/index.html`,n=await Ro(e,t);return typeof n=="string"&&n.trim().length>0}async function Cx(){try{const t=await ds("/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 Nx(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(vx.some(i=>n.includes(i)))return e}return null}function Ax(t){for(const{pattern:e}of Sx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Dx(t){const e=await Ro(`${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 Ro(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ro(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ds(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=zo()?.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 ds(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Px(t){try{const e=await Ro(`${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 mn="__aiworker_auto_discover_preview__",Ix=15e3,Tx=3e3,oi=t=>t.id===mn?"scan-2":og.find(n=>n.key===t.icon)?.Icon??"play",Rx=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}},Ex=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=Nt(),{currentTheme:l}=Zn(),{terminal:a,runtime:u}=Sn(),d=er(),{isMobile:h}=_n(),f=c.useMemo(()=>bn(),[]),p=Sl(J=>J.instances),g=Sl(J=>J.load),w=Te(J=>J.terminalShell),S=Te(J=>J.terminalLoginShells.includes(J.terminalShell)),x=Te(J=>J.setSettingsPage),m=Te(J=>J.setSettingsDialogOpen),b=Te(J=>J.setSettingsProjectsSelectedId),y=Te(J=>J.openContextPreview),v=Mt(J=>J.ensureDirectory),N=Mt(J=>J.reconcileServerSessions),C=Mt(J=>J.setTabLabel),k=Mt(J=>J.setTabIconKey),D=Mt(J=>J.setActiveTab),P=Mt(J=>J.setConnecting),I=Mt(J=>J.setTabSessionId),M=Mt(J=>J.setTabPurpose),_=Mt(J=>J.allocateActionExecution),O=Mt(J=>J.setTabLifecycle),U=Mt(J=>J.setTabPreviewUrl),L=Mt(J=>J.matchesActionExecution),F=Mt(J=>J.captureStartedActionMutationRevisions),[R,j]=c.useState([]),A=c.useRef(null),[B,X]=c.useState(null),[H,Z]=c.useState(!1),ce=c.useRef({}),Y=c.useRef({}),se=c.useRef({}),oe=c.useRef(new Set),Se=c.useRef(0),[K,pe]=c.useState({}),je=t?.id??null,ne=t?.path??"",T=c.useMemo(()=>je?{id:je,path:ne}:null,[je,ne]);c.useEffect(()=>{f&&g().catch(()=>{})},[f,g]);const G=c.useCallback(async J=>{await Uo(J)},[]),le=c.useCallback(async()=>{if(!T)return;const J=Se.current+1;Se.current=J,Z(!0);try{const re=await tl(T);if(Se.current!==J)return;A.current=re;const Pe=re.projectActions;j(Pe),X(_e=>_e===mn||_e&&Pe.some(Ve=>Ve.id===_e)?_e:null)}catch{if(Se.current!==J)return}finally{Se.current===J&&Z(!1)}},[T]),de=c.useMemo(()=>si(e||T?.path||""),[e,T?.path]),ue=c.useMemo(()=>si(T?.path||""),[T?.path]),Oe=c.useMemo(()=>si(d||"")||de,[d,de]),me=c.useRef(Oe);c.useEffect(()=>{me.current=Oe},[Oe]);const Re=Mt(J=>de?J.getDirectoryState(de):void 0),ye=Mt(J=>ue&&ue!==de?J.getDirectoryState(ue):void 0),q=c.useMemo(()=>{const J=de?[{directory:de,state:Re}]:[];return ue&&ue!==de&&J.push({directory:ue,state:ye}),J},[Re,de,ue,ye]),we=c.useMemo(()=>{const J=de?[de]:[];return ue&&ue!==de&&J.push(ue),J},[de,ue]),be=c.useCallback(J=>J.id!==mn&&J.runIn==="parent"&&ue||de,[de,ue]),Ne=c.useCallback((J,re,Pe)=>`${J}::${re}::${Pe}`,[]),ie=c.useCallback((J,re,Pe=Mt.getState())=>J?Pe.getDirectoryState(J)?.tabs.find(_e=>_e.purpose.type==="project-action"&&_e.purpose.actionId===re)??null:null,[]),ee=c.useMemo(()=>{const J={};for(const{directory:re,state:Pe}of q)for(const _e of Pe?.tabs??[]){if(_e.purpose.type!=="project-action"||!_e.purpose.executionId||!_e.terminalSessionId||_e.lifecycle==="idle"||_e.lifecycle==="exited")continue;const Ve=un(re,_e.purpose.actionId),Ze=Ne(re,_e.purpose.actionId,_e.purpose.executionId);J[Ve]={directory:re,actionId:_e.purpose.actionId,tabId:_e.id,sessionId:_e.terminalSessionId,executionId:_e.purpose.executionId,status:_e.lifecycle==="stopping"?"stopping":K[Ze]?"waiting-for-preview":"running"}}return J},[Ne,K,q]),V=c.useCallback((J,re,Pe)=>{const _e=un(J,re),Ve=Ne(J,re,Pe),lt=ce.current[_e]?.executionId===Pe,rt=globalThis.window,Ge=ot=>{rt?.clearTimeout(se.current[ot]),delete se.current[ot]};lt&&(delete ce.current[_e],Ge(_e)),Y.current[Ve]?.(),delete Y.current[Ve],Ge(Ve),pe(ot=>{if(!ot[Ve])return ot;const Ee={...ot};return delete Ee[Ve],Ee})},[Ne]),$=c.useCallback(J=>{Y.current[J]?.(),delete Y.current[J]},[]),ae=c.useCallback(J=>{window.clearTimeout(se.current[J]),delete se.current[J]},[]);c.useEffect(()=>{const J=Y.current,re=se.current;return()=>{for(const Pe of Object.keys(J))$(Pe);for(const Pe of Object.keys(re))ae(Pe)}},[ae,$]),c.useEffect(()=>{const J=new Set(we);for(const re of Object.values(ce.current))J.has(re.directory)||V(re.directory,re.actionId,re.executionId);for(const re of Object.keys(Y.current)){const Pe=re.split("::",1)[0]??"";J.has(Pe)||$(re)}},[V,$,we]);const W=c.useCallback((J,re)=>{Te.getState().openContextPanelTab(J,{mode:"terminal",targetDirectory:re===J?null:re})},[]),ve=c.useMemo(()=>B?R.find(J=>J.id===B)??null:null,[R,B]),Fe=c.useMemo(()=>({id:mn,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),Ce=!h,ke=c.useMemo(()=>Ce?[Fe,...R]:R,[R,Fe,Ce]);c.useEffect(()=>{le()},[le]),c.useEffect(()=>{const J=we.map(re=>Ei(a,re,F,Pe=>N(re,Pe.sessions,{startedActionMutationRevisions:Pe.startedActionMutationRevisions})));return()=>{for(const re of J)re()}},[F,N,a,we]),c.useEffect(()=>{for(const{directory:J,state:re}of q)if(J)for(const Pe of re?.tabs??[]){if(Pe.purpose.type!=="project-action")continue;const _e=Pe.purpose.actionId,Ve=ke.find(rt=>rt.id===_e),Ze=Ve?.name??_e,lt=Ve?.icon||"play";Pe.label!==Ze&&C(J,Pe.id,Ze),Pe.iconKey!==lt&&k(J,Pe.id,lt)}},[ke,k,C,q]),c.useEffect(()=>{const J=globalThis.window;if(!J)return;const re=Pe=>{const _e=Pe.detail;je&&(_e?.projectId&&_e.projectId!==je||le())};return J.addEventListener(vl,re),()=>{J.removeEventListener(vl,re)}},[le,je]),c.useEffect(()=>{B&&(B===mn&&Ce||R.some(J=>J.id===B)||X(null))},[R,Ce,B]),c.useEffect(()=>{const J=Pe=>{delete se.current[Pe];const _e=ce.current[Pe];if(!_e||_e.openedUrl)return;const Ve=Ne(_e.directory,_e.actionId,_e.executionId),Ze=_e.announced;if(Ze.length!==0){if(window.clearTimeout(se.current[Ve]),delete se.current[Ve],_e.openedUrl=!0,pe(lt=>{if(!lt[Ve])return lt;const rt={...lt};return delete rt[Ve],rt}),Ze.length===1){ri(_e.directory,[]),U(_e.directory,_e.tabId,Ze[0],{locked:!1,autoOpened:!0}),y(_e.directory,Ze[0]);return}_e.offering=!0,ri(_e.directory,Ze),Te.getState().openContextSurface(_e.directory,"browser"),Le.info(o("projectActions.toast.multipleServers"))}},re=()=>{const Pe=Mt.getState(),_e=Pe.sessions,Ve=ee;for(const[Ze,lt]of Object.entries(Ve)){const Ge=_e.get(lt.directory)?.tabs.find(yt=>yt.id===lt.tabId);if(!Ge||Ge.terminalSessionId!==lt.sessionId){V(lt.directory,lt.actionId,lt.executionId);continue}const ot=ce.current[Ze],Ee=ot?.executionId===lt.executionId?ot:{hostDirectory:me.current||lt.directory,directory:lt.directory,tabId:lt.tabId,actionId:lt.actionId,executionId:lt.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ce.current[Ze]=Ee;const Rt=ke.find(yt=>yt.id===lt.actionId),xe=Pe.getBuffer(lt.directory,lt.tabId).chunks;if(!Rt||xe.length===0)continue;const mt=xe.filter(yt=>Ee.lastSeenChunkId===null||yt.id>Ee.lastSeenChunkId);if(mt.length===0)continue;const Tt=mt.map(yt=>yt.data).join(""),Xe=`${Ee.tail}${Tt}`;if(Ee.openInPreview&&(!Ee.openedUrl||Ee.offering)){const yt=ng(Xe),It=Ee.announced.length;for(const Et of yt)Ee.announced.includes(Et)||Ee.announced.push(Et);const kt=Ee.announced.length-It;Ee.offering&&kt>0?ri(lt.directory,Ee.announced):!Ee.openedUrl&&It===0&&Ee.announced.length>0&&(window.clearTimeout(se.current[Ze]),se.current[Ze]=window.setTimeout(()=>J(Ze),Tx))}const nt=!Ee.openedUrl&&Rt.autoOpenUrl===!0&&!Ee.openInPreview?rg(Xe):null,St=mt[mt.length-1]?.id??Ee.lastSeenChunkId;if(Ee.lastSeenChunkId=St,Ee.tail=Xe.slice(-512),nt)if(Ee.openedUrl=!0,Ee.openInPreview){const yt=Ve[Ze];yt&&(U(yt.directory,yt.tabId,nt,{locked:!1,autoOpened:!1,expectedExecutionId:yt.executionId}),yt.status==="waiting-for-preview"&&pe(It=>{const kt=Ne(yt.directory,yt.actionId,yt.executionId);if(!It[kt])return It;const Et={...It};return delete Et[kt],Et}),window.clearTimeout(se.current[Ze]),delete se.current[Ze],y(yt.directory,nt))}else G(nt),Le.success(o("projectActions.toast.openedUrlFromOutput"));ce.current[Ze]=Ee}for(const Ze of Object.keys(ce.current))if(!Ve[Ze]){const lt=ce.current[Ze],rt=lt?_e.get(lt.directory)?.tabs.find(ot=>ot.id===lt.tabId):void 0;if(rt?.purpose.type==="project-action"&&rt.purpose.executionId===lt?.executionId&&!!rt.terminalSessionId&&rt.lifecycle!=="idle"&&rt.lifecycle!=="exited")continue;delete ce.current[Ze],window.clearTimeout(se.current[Ze]),delete se.current[Ze]}};return re(),Mt.subscribe((Pe,_e)=>{(Pe.sessions!==_e.sessions||Pe.buffers!==_e.buffers)&&re()})},[V,me,ke,Ne,y,G,ee,U,o]),c.useEffect(()=>{for(const{directory:J,state:re}of q)for(const Pe of re?.tabs??[]){if(Pe.purpose.type!=="project-action"||!Pe.purpose.executionId||!Pe.terminalSessionId||Pe.lifecycle!=="running")continue;const _e=Pe.purpose.actionId,Ve=Pe.purpose.executionId,Ze=Ne(J,_e,Ve);if(Y.current[Ze])continue;const lt=a.connect(Pe.terminalSessionId,{onEvent:rt=>{if(!L(J,Pe.id,Ve))return;rt.type==="snapshot"&&(Mt.getState().replaceBuffer(J,Pe.id,rt.data??"",rt.sequence??0,Ga(rt)),rt.status==="running"&&Mt.getState().setTabLifecycle(J,Pe.id,"running",{expectedExecutionId:Ve}),rt.status==="exited"&&(Mt.getState().setTabLifecycle(J,Pe.id,"exited",{expectedExecutionId:Ve}),Mt.getState().setTabPurpose(J,Pe.id,{type:"project-action",actionId:_e,executionId:null}),V(J,_e,Ve)));const Ge=rt.type==="data"?rt.data??"":"";Ge&&Mt.getState().appendToBuffer(J,Pe.id,Ge,rt.sequence,rt.replayData),rt.type==="exit"&&(Mt.getState().setTabLifecycle(J,Pe.id,"exited",{expectedExecutionId:Ve}),Mt.getState().setTabPurpose(J,Pe.id,{type:"project-action",actionId:_e,executionId:null}),V(J,_e,Ve))},onError:(rt,Ge)=>{!Ge||!L(J,Pe.id,Ve)||(Mt.getState().setTabLifecycle(J,Pe.id,"exited",{expectedExecutionId:Ve}),Mt.getState().setTabSessionId(J,Pe.id,null,{expectedExecutionId:Ve}),Mt.getState().setTabPurpose(J,Pe.id,{type:"project-action",actionId:_e,executionId:null}),V(J,_e,Ve))}});Y.current[Ze]=lt.close}},[V,Ne,L,a,q]);const Qe=c.useCallback(async J=>{const re=be(J);if(!re)throw new Error(o("projectActions.error.noActiveDirectory"));const Pe=un(re,J.id);v(re);const _e=Mt.getState(),Ve=ie(re,J.id,_e),Ze=Ve?.id??_e.createTab(re);C(re,Ze,J.name),k(re,Ze,J.icon||"play"),Ve||M(re,Ze,{type:"project-action",actionId:J.id,executionId:null}),D(re,Ze);const rt=Mt.getState().getDirectoryState(re)?.tabs.find(Ge=>Ge.id===Ze);return{executionDirectory:re,key:Pe,tabId:Ze,sessionId:rt?.terminalSessionId??null,executionId:rt?.purpose.type==="project-action"?rt.purpose.executionId:null}},[v,be,ie,D,k,C,M,o]),We=c.useCallback(async J=>{if(u.isVSCode||!i&&h)return;if(!de){Le.error(o("projectActions.error.noActiveDirectoryForAction"));return}const re=un(be(J),J.id),Pe=ee[re];if(Pe&&Pe.status==="running"||oe.current.has(re))return;oe.current.add(re);let _e=null;try{const Ve=J.id===mn?await(async()=>{const[kt,Et]=await Promise.all([jm({id:T?.id??"",path:de}),Px(de)]),Bt=await jx(de,kt.actions,Et);if(!Bt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:mn,name:o("projectActions.actions.autoDiscover"),command:Bt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Bt.previewUrlHint||""}})():J,Ze=Ve.autoOpenUrl===!0&&(Ve.openUrl||"").trim().length>0,lt=!Ze&&J.id!==mn,rt=me.current||de,{executionDirectory:Ge,key:ot,tabId:Ee}=await Qe(Ve),Rt=Jp(Ve.command);if(!Rt)throw new Error(o("projectActions.error.failedToRunAction"));const xe=Ve.autoOpenUrl===!0&&f&&(Ve.desktopOpenSshForward||"").trim().length>0,mt=Ve.autoOpenUrl?Rx(Ve.openUrl):null,Tt=Ve.autoOpenUrl&&f?Zp(Ve.desktopOpenSshForward,p):null;if(a.listSessions){const kt=ie(Ge,Ve.id);if(kt?.purpose.type==="project-action"&&kt.purpose.executionId===null){const Et=await eg(a,Ge,{captureStartedActionMutationRevisions:F});Et&&N(Ge,Et.sessions,{startedActionMutationRevisions:Et.startedActionMutationRevisions})}}const Xe=ie(Ge,Ve.id);let nt,St;if(Xe?.lifecycle==="running"&&Xe.terminalSessionId&&Xe.purpose.type==="project-action"&&Xe.purpose.executionId)nt=Xe.terminalSessionId,St=Xe.purpose.executionId;else{const kt=Xe?.purpose.type==="project-action"?Xe.purpose.executionId:null;kt&&V(Ge,Ve.id,kt);const Et=_(Ge,Ee,Ve.id);if(!Et)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));_e={directory:Ge,tabId:Ee,id:Et},P(Ge,Ee,!0,{expectedExecutionId:Et});const Bt=await tg({terminal:a,createOptions:{cwd:Ge,shell:w,loginShell:S,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Rt,isRunStillExpected:()=>L(Ge,Ee,Et),purpose:{type:"project-action",actionId:Ve.id,executionId:Et}});if(!L(Ge,Ee,Et)){Bt.sessionId===Et&&await a.close(Bt.sessionId).catch(()=>{});return}St=Bt.purpose?.type==="project-action"?Bt.purpose.executionId:Et,nt=Bt.sessionId,M(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:St}),I(Ge,Ee,nt,{expectedExecutionId:St}),P(Ge,Ee,!1,{expectedExecutionId:St})}lt&&rt&&W(rt,Ge),ce.current[ot]={hostDirectory:rt,directory:Ge,tabId:Ee,actionId:Ve.id,executionId:St,lastSeenChunkId:null,openedUrl:!!Tt||!!mt||Ze,tail:"",openInPreview:Ve.id===mn,announced:[],offering:!1};const yt=Ne(Ge,Ve.id,St);P(Ge,Ee,!0,{expectedExecutionId:St});const It=a.connect(nt,{onEvent:kt=>{if(!L(Ge,Ee,St)||kt.purpose?.type==="project-action"&&kt.purpose.executionId!==St)return;kt.type==="snapshot"&&(Mt.getState().replaceBuffer(Ge,Ee,kt.data??"",kt.sequence??0,Ga(kt)),Mt.getState().setConnecting(Ge,Ee,!1,{expectedExecutionId:St}),kt.purpose?.type==="project-action"&&Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:kt.purpose.actionId,executionId:kt.purpose.executionId}),kt.status==="running"&&Mt.getState().setTabLifecycle(Ge,Ee,"running",{expectedExecutionId:St}),kt.status==="exited"&&(Mt.getState().setTabLifecycle(Ge,Ee,"exited",{expectedExecutionId:St}),Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:null}),V(Ge,Ve.id,St)));const Et=kt.type==="data"?kt.data??"":"";Et&&Mt.getState().appendToBuffer(Ge,Ee,Et,kt.sequence,kt.replayData),kt.type==="exit"&&(Mt.getState().setTabLifecycle(Ge,Ee,"exited",{expectedExecutionId:St}),Mt.getState().setConnecting(Ge,Ee,!1,{expectedExecutionId:St}),Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:null}),V(Ge,Ve.id,St))},onError:(kt,Et)=>{L(Ge,Ee,St)&&(Mt.getState().setConnecting(Ge,Ee,!1,{expectedExecutionId:St}),Et&&(Mt.getState().setTabLifecycle(Ge,Ee,"exited",{expectedExecutionId:St}),Mt.getState().setTabSessionId(Ge,Ee,null,{expectedExecutionId:St}),Mt.getState().setTabPurpose(Ge,Ee,{type:"project-action",actionId:Ve.id,executionId:null}),V(Ge,Ve.id,St)))}});if(!L(Ge,Ee,St)){It.close();return}Y.current[yt]?.(),Y.current[yt]=It.close,window.clearTimeout(se.current[yt]),delete se.current[yt],Ve.id===mn&&!mt&&(pe(kt=>({...kt,[yt]:!0})),se.current[yt]=window.setTimeout(()=>{delete se.current[yt];const kt=ce.current[ot];!kt||kt.executionId!==St||kt.openedUrl||kt.offering||L(Ge,Ee,St)&&(pe(Et=>{if(!Et[yt])return Et;const Bt={...Et};return delete Bt[yt],Bt}),Mt.getState().setActiveTab(Ge,Ee),W(kt.hostDirectory,Ge))},Ix)),Tt?(U(Ge,Ee,null,{locked:!0,expectedExecutionId:St}),G(Tt),Le.success(o("projectActions.toast.openedForwardedUrl"))):mt?(U(Ge,Ee,mt,{locked:!0,autoOpened:!0,expectedExecutionId:St}),y(rt,mt),Le.success(o("projectActions.toast.openedActionUrl"))):Ze?(U(Ge,Ee,null,{locked:!0,expectedExecutionId:St}),Le.error(o("projectActions.error.invalidCustomUrlFormat"))):xe?(U(Ge,Ee,null,{locked:!0,expectedExecutionId:St}),Le.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):U(Ge,Ee,null,{locked:!1,autoOpened:!1,expectedExecutionId:St})}catch(Ve){if(_e&&L(_e.directory,_e.tabId,_e.id)){const{directory:Ze,tabId:lt,id:rt}=_e;V(Ze,J.id,rt),O(Ze,lt,"exited",{expectedExecutionId:rt}),M(Ze,lt,{type:"project-action",actionId:J.id,executionId:null})}if(Ve instanceof Error&&Ve.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Ve instanceof Error&&(Ve.message==="COMMAND_MODE_UNSUPPORTED"||Ve.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Le.error(o("projectActions.error.failedToCreateTerminalSession"));return}Le.error(Ve instanceof Error?Ve.message:o("projectActions.error.failedToRunAction"))}finally{oe.current.delete(re)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,me,p,Qe,i,h,f,de,S,w,G,y,ee,W,u.isVSCode,be,L,V,Ne,ie,N,_,F,P,O,M,U,I,T?.id,o,a]),z=c.useCallback(async J=>{const re=un(be(J),J.id),Pe=ee[re];Pe&&await sg({terminal:a,sessionId:Pe.sessionId,isExecutionStillCurrent:()=>L(Pe.directory,Pe.tabId,Pe.executionId),markStopping:()=>{O(Pe.directory,Pe.tabId,"stopping",{expectedExecutionId:Pe.executionId})},restoreRunning:()=>{O(Pe.directory,Pe.tabId,"running",{expectedExecutionId:Pe.executionId})},clearSession:()=>{I(Pe.directory,Pe.tabId,null,{expectedExecutionId:Pe.executionId})},finalizeExit:()=>{O(Pe.directory,Pe.tabId,"exited",{expectedExecutionId:Pe.executionId}),M(Pe.directory,Pe.tabId,{type:"project-action",actionId:Pe.actionId,executionId:null}),V(Pe.directory,Pe.actionId,Pe.executionId)}})},[V,be,L,ee,O,M,I,a]),he=c.useCallback(()=>{const J=ve??ke[0];if(!J)return;const re=un(be(J),J.id),Pe=ee[re];if(Pe?.status!=="stopping"){if(Pe){z(J);return}We(J)}},[ke,be,We,ee,ve,z]),Be=c.useCallback(async J=>{if(J.source==="shared"&&T){const re=A.current?.trust.trusted?A.current:await tl(T);if(A.current=re,!await km(T,re))return;A.current={...re,trust:{...re.trust,trusted:!0}}}await We(J)},[We,T]),Ae=c.useCallback((J,re=!1)=>{if(X(J.id),!re){Be(J);return}const Pe=un(be(J),J.id),_e=ee[Pe];if(_e?.status!=="stopping"){if(_e){z(J);return}Be(J)}},[be,Be,ee,z]),at=c.useCallback(()=>{T?.id&&(b(T.id),x("projects"),m(!0))},[m,x,b,T?.id]),Ue=ve??ke[0]??null,ht=Ue?ee[un(be(Ue),Ue.id)]:null,ut=Mt(J=>ht?J.getDirectoryState(ht.directory)?.tabs.find(re=>re.id===ht.tabId)?.previewUrl??null:null);if(u.isVSCode||!i&&h||!T||!de)return null;const Ct=ve??ke[0]??null;if(!Ct)return null;const ge=oi(Ct),Ye=un(be(Ct),Ct.id),bt=ee[Ye],jt=bt?.status==="stopping",fe=bt?.status==="waiting-for-preview",ze=!!(bt&&ut),it=()=>{!bt||!ut||y(bt.directory,ut)},$e=Ct.id===mn;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:H||jt,className:Ie("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:he,"aria-label":bt?o("projectActions.actions.stopNamedAria",{name:Ct.name}):o("projectActions.actions.runNamedAria",{name:Ct.name}),children:jt||fe?s.jsx(E,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):bt?s.jsx(E,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(E,{name:ge,className:"h-5 w-5"})})}),$e?s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),ze?s.jsxs(At,{children:[s.jsx(Dt,{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:it,children:s.jsx(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Js,{children:[s.jsx(Ys,{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(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Xs,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:at,children:[s.jsx(E,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),ke.map(J=>{const re=oi(J),Pe=un(be(J),J.id),_e=ee[Pe],Ve=!!_e,Ze=_e?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{Ae(J,!0)},children:[s.jsx(E,{name:re,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:J.name}),J.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Ze||_e?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(E,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},J.id)})]})]})]}):s.jsxs("div",{className:Ie("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(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:he,disabled:H||jt,className:Ie("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":bt?o("projectActions.actions.stopNamedAria",{name:Ct.name}):o("projectActions.actions.runNamedAria",{name:Ct.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:jt||fe?s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):bt?s.jsx(E,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(E,{name:ge,className:"h-4 w-4"})})})}),$e?s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),ze?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:it,className:Ie(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(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Js,{children:[s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(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(E,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Xs,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:at,children:[s.jsx(E,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),ke.map(J=>{const re=oi(J),Pe=un(be(J),J.id),_e=ee[Pe],Ve=!!_e,Ze=_e?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{Ae(J,!0)},children:[s.jsx(E,{name:re,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:J.name}),J.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Ze||_e?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(E,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},J.id)})]})]})]})},Or=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Mx=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Or(n??"");if(i){const o=hd(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function Ox(){const t=Ht(w=>w.projects),e=Ht(w=>w.activeProjectId),n=Je(w=>w.availableWorktreesByProject),r=Je(w=>w.currentSessionId),i=Cm(r??null),o=Je(w=>r?w.worktreeMetadata.get(r)?.path??"":""),l=Je(w=>w.newSessionDraft?.open?Or(w.newSessionDraft.bootstrapPendingDirectory??w.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Or(o||""),[o]),u=c.useMemo(()=>{const w=typeof i?.directory=="string"?i.directory:"";return Or(w||"")},[i?.directory]),d=a||u||l,h=c.useMemo(()=>Mx({projects:t,worktreesByProject:n,directory:d,activeProjectId:e}),[e,d,t,n]),f=c.useMemo(()=>Or(d||h?.path||""),[d,h?.path]),p=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),g=c.useRef(null);return c.useEffect(()=>{p&&f&&(g.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:g.current,[p,f])}const Fx=({transform:t})=>({...t,y:0}),Bx={Item:Kt,Separator:Os},_x={Item:({className:t,...e})=>s.jsx(fu,{className:Ie(xd,t),...e}),Separator:({className:t,...e})=>s.jsx(uu,{className:Ie(gd,t),...e})},Lx=t=>{const e=st.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:u,onMenuOpenChangeComplete:d,children:h}=t,{t:f}=Nt(),[p,g]=c.useState(!1),[w,S]=c.useState(!1),[x,m]=c.useState(!1);let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:y,listeners:v,setNodeRef:N,transform:C,transition:k,isDragging:D}=Qo(b);let P;e[2]!==f||e[3]!==n.session.title?(P=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=P):P=e[4];const I=P,M=!i&&(p||w),_=pa(n.id),O=n.id;let U;e[5]!==n.session?(U=Ts(n.session),e[5]=n.session,e[6]=U):U=e[6];const L=Ra(O,U),F=_?.type==="busy"||_?.type==="retry",j=pd(n.id)>0&&!r&&!F,A=F||j;let B;e[7]!==F||e[8]!==f?(B=f(F?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=F,e[8]=f,e[9]=B):B=e[9];const X=B;let H;e[10]!==u||e[11]!==x||e[12]!==r||e[13]!==p||e[14]!==o||e[15]!==n?(H=Oe=>({session:n.session,open:p||x,isActive:r,select:()=>o(n),closeOtherTabs:()=>u(n.id),components:Oe}),e[10]=u,e[11]=x,e[12]=r,e[13]=p,e[14]=o,e[15]=n,e[16]=H):H=e[16];const Z=H;let ce;e[17]!==C?(ce=Yo.Translate.toString(C),e[17]=C,e[18]=ce):ce=e[18];let Y;e[19]!==ce||e[20]!==k?(Y={transform:ce,transition:k},e[19]=ce,e[20]=k,e[21]=Y):Y=e[21];const se=D&&"z-10 opacity-60";let oe;e[22]!==se?(oe=Ie("session-tab-slot flex h-7 w-44 shrink-0 touch-none",se),e[22]=se,e[23]=oe):oe=e[23];const Se=r?"true":"false";let K;e[24]!==r?(K=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=K):K=e[25];let pe;e[26]!==d?(pe=Oe=>d?.(Oe),e[26]=d,e[27]=pe):pe=e[27];let je;e[28]!==h||e[29]!==X||e[30]!==r||e[31]!==L||e[32]!==F||e[33]!==Z||e[34]!==p||e[35]!==l||e[36]!==d||e[37]!==o||e[38]!==M||e[39]!==a||e[40]!==A||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==I?(je=s.jsx(mu,{render:Oe=>s.jsxs("div",{...Oe,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:me=>{(me.key==="Enter"||me.key===" ")&&(me.preventDefault(),o(n))},onAuxClick:me=>{me.button===1&&(me.preventDefault(),l(n.id))},"data-controls-open":M?"true":"false",className:Ie("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection":Ie("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",M&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Ie("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",M&&"pr-10"),children:[s.jsx("div",{className:Ie("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:I})})}),L?s.jsx(E,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):A?s.jsx("span",{className:Ie("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",F?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",M&&"opacity-0"),"aria-label":X}):null]}),i?null:s.jsxs("div",{onClick:Wx,onPointerDown:zx,className:Ie("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",M&&"flex opacity-100"),children:[s.jsxs(Js,{open:p,onOpenChange:me=>{g(me),me&&S(!0)},onOpenChangeComplete:me=>{me||S(!1),d?.(me)},children:[s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"more",className:"size-4"})})}),s.jsx(Xs,{align:"start",className:"min-w-[190px]",children:a(Z(Bx))})]}),s.jsx("button",{type:"button","aria-label":f("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(E,{name:"close",className:"size-4"})})]})]})}),e[28]=h,e[29]=X,e[30]=r,e[31]=L,e[32]=F,e[33]=Z,e[34]=p,e[35]=l,e[36]=d,e[37]=o,e[38]=M,e[39]=a,e[40]=A,e[41]=i,e[42]=f,e[43]=n,e[44]=I,e[45]=je):je=e[45];let ne,T;e[46]===Symbol.for("react.memo_cache_sentinel")?(ne={color:"var(--surface-elevated-foreground)"},T=Ie(Si,"min-w-[190px]"),e[46]=ne,e[47]=T):(ne=e[46],T=e[47]);let G;e[48]!==Z||e[49]!==a?(G=a(Z(_x)),e[48]=Z,e[49]=a,e[50]=G):G=e[50];let le;e[51]!==G?(le=s.jsx(Li,{children:s.jsx($i,{className:"app-region-no-drag z-50",children:s.jsx(Wi,{"data-slot":"dropdown-menu-content",style:ne,className:T,children:G})})}),e[51]=G,e[52]=le):le=e[52];let de;e[53]!==x||e[54]!==pe||e[55]!==je||e[56]!==le?(de=s.jsxs(hu,{open:x,onOpenChange:m,onOpenChangeComplete:pe,children:[je,le]}),e[53]=x,e[54]=pe,e[55]=je,e[56]=le,e[57]=de):de=e[57];let ue;return e[58]!==y||e[59]!==v||e[60]!==N||e[61]!==oe||e[62]!==Se||e[63]!==K||e[64]!==de||e[65]!==Y?(ue=s.jsx("div",{ref:N,style:Y,className:oe,"data-active":Se,...K,...y,...v,children:de}),e[58]=y,e[59]=v,e[60]=N,e[61]=oe,e[62]=Se,e[63]=K,e[64]=de,e[65]=Y,e[66]=ue):ue=e[66],ue},$x=t=>{const e=st.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=Nt(),u=Jr(Vx),d=Jr(Ux),h=Jr(Kx),f=Jr(Hx),p=Je(Gx),g=Je(qx),w=Is(Qx);let S,x;e[0]!==p||e[1]!==d?(S=()=>{p&&d(p)},x=[p,d],e[0]=p,e[1]=d,e[2]=S,e[3]=x):(S=e[2],x=e[3]),c.useEffect(S,x);let m;if(e[4]!==w){m=new Map;for(const me of w)m.set(me.id,me);e[4]=w,e[5]=m}else m=e[5];const b=m;let y;if(e[6]!==b||e[7]!==u){y=[];for(const me of u){const Re=b.get(me);Re&&y.push({id:me,session:Re})}e[6]=b,e[7]=u,e[8]=y}else y=e[8];const v=y;let N;e[9]!==g?(N=me=>{g(me.id,Ts(me.session))},e[9]=g,e[10]=N):N=e[10];const C=N,k=Yx;let D;e[11]!==h||e[12]!==p||e[13]!==C||e[14]!==v?(D=me=>{if(h(me),p&&p!==me){const Re=v.find(ye=>ye.id===me);Re&&C(Re)}},e[11]=h,e[12]=p,e[13]=C,e[14]=v,e[15]=D):D=e[15];const P=D;let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I={activationConstraint:{distance:8}},e[16]=I):I=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{delay:200,tolerance:6}},e[17]=M):M=e[17];const _=Vr(On(cu,I),On(lu,M));let O;e[18]!==f?(O=me=>{const{active:Re,over:ye}=me;ye&&Re.id!==ye.id&&f(String(Re.id),String(ye.id))},e[18]=f,e[19]=O):O=e[19];const U=O,L=c.useRef(null);let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F={left:!1,right:!1},e[20]=F):F=e[20];const[R,j]=c.useState(F);let A;e[21]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const me=L.current;if(!me)return;const Re=me.scrollLeft>2,ye=me.scrollLeft+me.clientWidth<me.scrollWidth-2;j(q=>q.left===Re&&q.right===ye?q:{left:Re,right:ye})},e[21]=A):A=e[21];const B=A;let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{B();const me=L.current;if(!me||!globalThis.ResizeObserver)return;const Re=new ResizeObserver(B);return Re.observe(me),()=>Re.disconnect()},e[22]=X):X=e[22];let H;e[23]!==v.length?(H=[B,v.length],e[23]=v.length,e[24]=H):H=e[24],c.useEffect(X,H);let Z;e[25]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>{L.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=Z):Z=e[25];let ce;e[26]!==p?(ce=[p],e[26]=p,e[27]=ce):ce=e[27],c.useEffect(Z,ce);const Y=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 se;e[28]!==v?(se=v.map(Xx),e[28]=v,e[29]=se):se=e[29];const oe=se;let Se;e[30]!==p||e[31]!==v?(Se=!p||!v.some(me=>me.id===p),e[30]=p,e[31]=v,e[32]=Se):Se=e[32];const K=Se;let pe;e[33]!==a?(pe=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=pe):pe=e[34];let je;e[35]!==Y?(je=Y?{maskImage:Y,WebkitMaskImage:Y}:void 0,e[35]=Y,e[36]=je):je=e[36];let ne;e[37]===Symbol.for("react.memo_cache_sentinel")?(ne=[Fx],e[37]=ne):ne=e[37];let T;e[38]!==o||e[39]!==p||e[40]!==P||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==v?(T=v.map(me=>s.jsx(Lx,{tab:me,isActive:me.id===p,suppressControls:me.id===p&&l,onSelect:C,onClose:k,renderMenu:n,closeOtherTabs:P,onMenuOpenChangeComplete:r,children:me.id===p?o:null},me.id)),e[38]=o,e[39]=p,e[40]=P,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=v,e[46]=T):T=e[46];let G;e[47]!==T||e[48]!==oe?(G=s.jsx(Io,{items:oe,strategy:Hg,children:T}),e[47]=T,e[48]=oe,e[49]=G):G=e[49];let le;e[50]!==U||e[51]!==_||e[52]!==G?(le=s.jsx(Ur,{sensors:_,collisionDetection:Kr,modifiers:ne,onDragEnd:U,children:G}),e[50]=U,e[51]=_,e[52]=G,e[53]=le):le=e[53];let de;e[54]!==o||e[55]!==K?(de=K?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]=K,e[56]=de):de=e[56];let ue;e[57]!==je||e[58]!==le||e[59]!==de?(ue=s.jsxs("div",{ref:L,onScroll:B,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:je,children:[le,de]}),e[57]=je,e[58]=le,e[59]=de,e[60]=ue):ue=e[60];let Oe;return e[61]!==pe||e[62]!==ue?(Oe=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":pe,children:ue}),e[61]=pe,e[62]=ue,e[63]=Oe):Oe=e[63],Oe};function Wx(t){return t.stopPropagation()}function zx(t){return t.stopPropagation()}function Vx(t){return t.tabIds}function Ux(t){return t.ensureTab}function Kx(t){return t.closeOtherTabs}function Hx(t){return t.reorderTabs}function Gx(t){return t.currentSessionId}function qx(t){return t.setCurrentSession}function Qx(t){return t.activeSessions}function Yx(t){Nm(t)}function Xx(t){return t.id}function Jx(t){if(typeof t!="number"||!Number.isFinite(t))return"";const e=new Date(t);if(Number.isNaN(e.getTime()))return"";const n=e.toLocaleString(ga(),{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 Zx(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 eb(t){const e=t.info.role==="user"?"User":"Assistant",n=Jx(t.info.time?.created),r=Zx(t),i=n&&r?`${n} (${r})`:n||r;return i?`**${e}**
|
|
3
|
+
|
|
4
|
+
*${i}*`:`**${e}**`}function Su(t){const e=eb(t),n=ig(t.parts,{user:t.info.role==="user"});return n?`${e}
|
|
5
|
+
|
|
6
|
+
${n}`:""}function vu(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(Su).filter(Boolean).join(`
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
`),l=[i+o];for(const a of t.children)l.push(vu(a,e+1));return l.join(`
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
`)}function ju(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(Su).filter(Boolean).join(`
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
`);let a=o+l;if(n&&n.length>0){const u=n.map(d=>vu(d,1)).join(`
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
`);a+=`
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
`+u}return a}function ku(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 Cu(t,e){const n=await Hf(e,t);if(n)return n;if(!Pn())return null;try{const r=await zo()?.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 tb(t){const e=zo()?.files;if(e?.revealPath)try{return!!(await e.revealPath(t))?.success}catch{return!1}return await Gf(t)?!0:ad(t)}function sb(){return bd()}function Nu(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`}function Vi(t){const e=st.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=Nt(),{pending:a,disabled:u,hint:d,run:h}=ag(n,r,i),f=a?"loader-4":"ai-generate-2",p=a?"mr-2 size-4 animate-spin":"mr-2 size-4";let g;e[0]!==f||e[1]!==p?(g=s.jsx(E,{name:f,className:p}),e[0]=f,e[1]=p,e[2]=g):g=e[2];let w;e[3]!==l?(w=l("sessions.aiRename.action"),e[3]=l,e[4]=w):w=e[4];let S;e[5]!==o||e[6]!==u||e[7]!==h||e[8]!==g||e[9]!==w?(S=s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:u,onClick:h,className:"w-full",children:[g,w]})})}),e[5]=o,e[6]=u,e[7]=h,e[8]=g,e[9]=w,e[10]=S):S=e[10];let x;e[11]!==d?(x=s.jsx(Pt,{side:"right",children:d}),e[11]=d,e[12]=x):x=e[12];let m;return e[13]!==S||e[14]!==x?(m=s.jsxs(At,{children:[S,x]}),e[13]=S,e[14]=x,e[15]=m):m=e[15],m}const Ui=(t,e)=>({success:t(e.success),failure:t(e.failure),sourceVerificationFailed:t("sessions.sidebar.session.moveToWorktree.sourceVerificationFailed"),applyChangesFailed:t("sessions.sidebar.session.moveToWorktree.applyChangesFailed"),changesMayBeInDestination:t("sessions.sidebar.session.moveToWorktree.changesMayBeInDestination")}),$n=tr(()=>({pendingSessionIds:new Set,requestingSessionIds:new Set,confirmation:null})),Au=t=>{const e=st.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t)||r.requestingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],$n(n)},nb=()=>$n(mb),Du=()=>$n.getState().confirmation,Ma=t=>{$n.setState(e=>e.confirmation===t?e:{...e,confirmation:t})},Dl=(t,e)=>{$n.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},cr=(t,e)=>{$n.setState(n=>{if(n.requestingSessionIds.has(t)===e)return n;const r=new Set(n.requestingSessionIds);return e?r.add(t):r.delete(t),{...n,requestingSessionIds:r}})},rb="Unable to apply your changes in the destination directory",ob=t=>t.status===400&&t.message.includes(rb),ib=async(t,e)=>{try{const u=(await yd(t,{mode:"light"})).current?.trim();if(u)return u}catch{}const n=vt(t),r=vt(e)??e,i=Je.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>vt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},Pl=t=>{for(const e of t){const n=Dm(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class Pu extends Error{changesMayBeInDestination;constructor(e,n,r){super(e,{cause:n}),this.name="IncompleteRollbackError",this.changesMayBeInDestination=r}}const ab=(t,e,n)=>{const r=e.map(({sessionId:i,error:o})=>`${i}: ${o.message}`).join(", ");return new Pu(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${r}`,{moveError:t,rollbackFailures:e},n)},lb=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(Pm(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await wd(o,n,e,!1),Je.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i};class Iu extends Error{constructor(e){super(e.message,{cause:e}),this.name="ChangesMayBeInDestinationError"}}const Il=async(t,e,n)=>{try{await Sd(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},Tl=async(t,e)=>{const n=e?[t,e]:[t];try{await xa(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},Tu=async(t,e)=>{if($n.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Dl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,Je.getState().getWorktreeMetadata(a.id)]));Pl(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,u]of n.entries()){Pl(n.slice(a));const d=u.id===t.root.id&&t.moveChanges;try{await wd(u,t.sourceDirectory,i.directory,d)}catch(h){throw d&&Am(h)&&(l=!0),h}o.push(u),u.id!==t.root.id&&Je.getState().setWorktreeMetadata(u.id,sl(i.metadata))}}catch(a){const u=a instanceof Error?a:new Error(String(a)),d=await lb(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await Tl(t.sourceDirectory,i?.directory),d.length>0)throw ab(u,d,l);if(l)throw new Iu(u);if(i?.onMoveFailure)return i.onMoveFailure(u);throw u}return Je.getState().setWorktreeMetadata(t.root.id,sl(i.metadata)),await Tl(t.sourceDirectory,i.directory),i.directory}finally{Dl(t.root.id,!1)}},cb=async t=>{const e=vt(t.sourceDirectory)??t.sourceDirectory,n=vt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return Tu(t,async()=>({directory:t.destination.path,metadata:t.destination}))},db=async t=>Tu(t,async()=>{const e=vi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await Ko(t.sourceDirectory)?await ib(t.sourceDirectory,e.path):null,r=await Im(e,n?{startRef:n}:{});try{await Tm(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return Il(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>Il(e,r,i)}}),ub=(t,e,n)=>e instanceof Iu?t.changesMayBeInDestination:e instanceof Pu&&e.changesMayBeInDestination?`${e.message} ${t.changesMayBeInDestination}`:n&&ob(e)?t.applyChangesFailed:e.message,Ki=(t,e)=>{(t.kind==="existing"?cb({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination,moveChanges:e}):db({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,moveChanges:e})).then(()=>Le.success(t.messages.success)).catch(r=>{const i=r instanceof Error?r:new Error(String(r));Le.error(t.messages.failure,{description:ub(t.messages,i,e)})})},fb=()=>{const t=Du();t&&(cr(t.intent.root.id,!1),Ma(null))},Ru=t=>{const e=Du();if(!e)return;const{intent:n}=e;Ma(null),cr(n.root.id,!1),Ki(n,t)},Hi=t=>{const e=$n.getState();e.confirmation||e.pendingSessionIds.has(t.root.id)||e.requestingSessionIds.has(t.root.id)||(cr(t.root.id,!0),(async()=>{try{if(!await Ko(t.sourceDirectory)){cr(t.root.id,!1),Ki(t,!1);return}const r=await yd(t.sourceDirectory);if(r.isClean){cr(t.root.id,!1),Ki(t,!1);return}const i=r.files.filter(o=>{const l=o.index.trim();return l!==""&&l!=="?"}).length;Ma({intent:t,dirtyFileCount:r.files.length,stagedFileCount:i})}catch{Le.error(t.messages.failure,{description:t.messages.sourceVerificationFailed}),cr(t.root.id,!1)}})())};function mb(t){return t.confirmation}const Eo="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",hb=c.memo(function(e){const n=st.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:u,iconClassName:d,pressed:h}=e,f=r===void 0?!0:r,p=h===void 0?!1:h;if(!f)return null;const g=a??Eo,w=p&&"bg-interactive-selection text-interactive-selection-foreground";let S;n[0]!==g||n[1]!==w?(S=Ie(g,w),n[0]=g,n[1]=w,n[2]=S):S=n[2];const x=d??"h-[18px] w-[18px]";let m;n[3]!==u||n[4]!==x?(m=s.jsx(E,{name:u,className:x}),n[3]=u,n[4]=x,n[5]=m):m=n[5];let b;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==S||n[10]!==m?(b=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:S,children:m})}),n[6]=o,n[7]=l,n[8]=p,n[9]=S,n[10]=m,n[11]=b):b=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]!==b||n[15]!==y?(v=s.jsxs(At,{children:[b,y]}),n[14]=b,n[15]=y,n[16]=v):v=n[16],v}),pb=c.memo(function(e){const n=st.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:u,shortcutLabel:d,remoteUpdateInfo:h,remoteUpdateChecking:f,remoteUpdateError:p,onOpenRemoteUpdate:g}=e,{t:w}=Nt();let S;n[0]!==u||n[1]!==a?(S=_=>{a(_),_&&u()},n[0]=u,n[1]=a,n[2]=S):S=n[2];let x;n[3]!==i||n[4]!==r||n[5]!==w?(x=r?w("header.services.openWithCurrent",{current:i}):w("header.services.open"),n[3]=i,n[4]=r,n[5]=w,n[6]=x):x=n[6];const m=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let b;n[7]!==m?(b=Ie(Eo,m),n[7]=m,n[8]=b):b=n[8];let y;n[9]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(E,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=y):y=n[9];let v;n[10]!==i||n[11]!==r?(v=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=v):v=n[12];let N;n[13]!==x||n[14]!==b||n[15]!==v?(N=s.jsx(Dt,{asChild:!0,children:s.jsx(Ys,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":x,className:b,children:[y,v]})})}),n[13]=x,n[14]=b,n[15]=v,n[16]=N):N=n[16];let C;n[17]!==i||n[18]!==d||n[19]!==w?(C=w("header.services.tooltip.currentInstance",{current:i,toggle:d("toggle_services_menu")}),n[17]=i,n[18]=d,n[19]=w,n[20]=C):C=n[20];let k;n[21]!==C?(k=s.jsx(Pt,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=k):k=n[22];let D;n[23]!==N||n[24]!==k?(D=s.jsxs(At,{children:[N,k]}),n[23]=N,n[24]=k,n[25]=D):D=n[25];let P;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==g||n[30]!==f||n[31]!==p||n[32]!==h||n[33]!==a||n[34]!==w?(P=r?s.jsxs("div",{children:[o?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:w("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?w("header.services.remoteUpdate.available",{version:h.version||""}):f?w("header.services.remoteUpdate.checking"):p||w("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:g,children:w("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Rm,{embedded:!0,open:l,onOpenChange:bb,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=g,n[30]=f,n[31]=p,n[32]=h,n[33]=a,n[34]=w,n[35]=P):P=n[35];let I;n[36]!==P?(I=s.jsx(Xs,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:P}),n[36]=P,n[37]=I):I=n[37];let M;return n[38]!==l||n[39]!==S||n[40]!==D||n[41]!==I?(M=s.jsxs(Js,{open:l,onOpenChange:S,children:[D,I]}),n[38]=l,n[39]=S,n[40]=D,n[41]=I,n[42]=M):M=n[42],M}),gb=(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??""),vn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Rl=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,xb=()=>{qs("ui.header.render");const{t}=Nt(),e=Te(Q=>Q.isSidebarOpen),n=Te(Q=>Q.openContextOverview),r=Te(Q=>Q.closeContextPanel),i=Te(Q=>Q.shortcutOverrides),o=Te(Q=>Q.sessionTabsEnabled),l=qt(Q=>Q.getCurrentModel),a=Je(Q=>Q.getContextUsage),u=Je(Q=>!!Q.newSessionDraft?.open),d=Je(Q=>Q.currentSessionId),h=Em(d??""),f=pa(d??""),p=Au(d??""),g=Is(Jn(c.useCallback(Q=>{if(!d)return null;const He=[...Q.activeSessions,...Q.archivedSessions].find(pt=>pt.id===d);if(!He)return null;const et=He;return{title:He.title??null,directory:et.directory??null,created:He.time?.created??null,slug:et.slug??null,shareUrl:He.share?.url??null,parentId:He.parentID??null}},[d]))),w=Ht(Jn(Q=>{if(!Q.activeProjectId)return null;const He=Q.projects.find(et=>et.id===Q.activeProjectId);return He?{id:He.id,path:He.path,label:He.label}:null})),S=c.useMemo(()=>{if(!w)return null;const Q=w.label?.trim();if(Q)return Q;const He=w.path.split(/[\\/]/).filter(Boolean);return He[He.length-1]??null},[w]),x=ar(Q=>Q.loadSettings),{isMobile:m}=_n(),b=c.useRef(null),[y,v]=c.useState(()=>typeof window>"u"?!1:bn()),N=c.useMemo(()=>Vo(),[]),C=vd(),[k,D]=c.useState(!1),P=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:I,side:M}=Zd(),_=c.useMemo(()=>{if(typeof window>"u")return null;const Q=window.__AIWORKER_MACOS_MAJOR__;if(typeof Q=="number"&&Number.isFinite(Q)&&Q>0)return Q;if(typeof navigator>"u")return null;const He=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!He)return null;const et=Number.parseInt(He[1],10),pt=Number.parseInt(He[2],10);return Number.isNaN(et)?null:et===10?pt:et},[]);gt.useEffect(()=>{typeof window>"u"||v(bn())},[]);const O=l(),U=O&&typeof O.limit=="object"&&O.limit!==null?O.limit:null,L=U&&typeof U.context=="number"?U.context:0,F=U&&typeof U.output=="number"?U.output:0,R=a(L,F),[j,A]=c.useState(null),B=!d||h;gt.useEffect(()=>{if(!d){A(Q=>Q===null?Q:null);return}if(R&&R.totalTokens>0){A(Q=>gb(Q,R)?Q:R);return}B&&A(Q=>Q===null?Q:null)},[R,d,B]);const[X,H]=c.useState(!1),[Z,ce]=c.useState("Local"),[Y,se]=c.useState(!0),[oe,Se]=c.useState(!1),[K,pe]=c.useState(null),[je,ne]=c.useState(!1),[T,G]=c.useState(null),le=c.useMemo(()=>Pn(),[]),de=Te(Q=>Q.workStatusPanelVisible),ue=Te(Q=>Q.workStatusPanelEnabled),Oe=Te(Q=>Q.setWorkStatusPanelEnabled),me=Te(Q=>Q.workStatusPanelFits),Re=Te(Q=>Q.workStatusOverlayOpen),ye=Te(Q=>Q.setWorkStatusOverlayOpen),we=ue&&me||Re,be=c.useCallback(()=>{if(ue&&!me){ye(!Re);return}Oe(!ue)},[ye,Oe,Re,ue,me]),Ne=!le&&!de&&!!j&&j.totalTokens>0,ie=j&&j.contextLimit>0?Math.min(999,j.totalTokens/j.contextLimit*100):0,ee=c.useCallback(async()=>{if(!(typeof window>"u"||!y))try{if(Wo()){ce("Local"),se(!0);return}se(!1);const Q=await ld(),He=qf(),et=Qf([Yf(He),...Q.hosts]);if(et.id===Xf){ce("Local"),se(!0);return}ce(cd(et.label.trim()||"Instance"))}catch{ce("Local"),se(!0)}},[y]);gt.useEffect(()=>(ee(),ma(()=>{ee()})),[ee]);const V=c.useCallback(async()=>{if(Y){pe(null),G(null);return}ne(!0),G(null);try{const Q=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),He=await ds(`/api/openchamber/update-check?${Q.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!He.ok)throw new Error(`Server responded with ${He.status}`);const et=await He.json();pe({available:et.available??!1,version:et.version,currentVersion:et.currentVersion??"unknown",body:et.body,nextSuggestedCheckInSec:typeof et.nextSuggestedCheckInSec=="number"?et.nextSuggestedCheckInSec:void 0,packageManager:et.packageManager,updateCommand:et.updateCommand})}catch(Q){pe(null),G(Q instanceof Error?Q.message:t("header.services.remoteUpdate.error"))}finally{ne(!1)}},[Y,t]);c.useEffect(()=>{pe(null),G(null),Se(!1)},[Y,Z]),c.useEffect(()=>{if(!y||Y)return;const Q=3e3,He=3600*1e3;let et=!1,pt=null;const Ut=Zt=>{pt=window.setTimeout(()=>{if(et||typeof document<"u"&&document.visibilityState!=="visible"){Ut(He);return}V().finally(()=>{et||Ut(He)})},Zt)};return Ut(Q),()=>{et=!0,pt!==null&&window.clearTimeout(pt)}},[V,Y,Z,y]);const $=c.useCallback(()=>{if(K?.available){Se(!0);return}V()},[V,K?.available]);Mm(),c.useEffect(()=>{x()},[x]);const ae=d?g??null:null,W=c.useRef(null),[ve,Fe]=c.useState(0);c.useEffect(()=>{if(!d){W.current&&(W.current=null,Fe(pt=>pt+1));return}if(ae){W.current={sessionId:d,session:ae,expiresAt:Date.now()+2e3};return}const Q=W.current;if(!Q||Q.sessionId!==d)return;const He=Q.expiresAt-Date.now();if(He<=0){W.current=null,Fe(pt=>pt+1);return}const et=window.setTimeout(()=>{W.current?.sessionId===d&&(W.current=null),Fe(pt=>pt+1)},He);return()=>{window.clearTimeout(et)}},[d,ae]);const Ce=(()=>{if(ae)return ae;if(!d)return null;const Q=W.current;return Q&&Q.sessionId===d&&Q.expiresAt>Date.now()?Q.session:null})(),ke=Je(Q=>d?Q.worktreeMetadata.get(d)?.path??"":""),Qe=Je(Q=>d?Q.worktreeMetadata.get(d)?.branch?.trim()??null:null),We=jd(Q=>d?Q.getAttachment(d):void 0),z=c.useMemo(()=>We?Om(We,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,We]),he=c.useMemo(()=>We?We.legacy?"legacy":We.degraded?"degraded":We.worktreeStatus==="pending"?"pending":We.worktreeStatus==="missing"?"missing":We.worktreeStatus==="invalid"?"invalid":We.attentionReason?"attention":null:null,[We]),Be=c.useMemo(()=>vn(ke||""),[ke]),Ae=c.useMemo(()=>{const Q=typeof Ce?.directory=="string"?Ce.directory:"";return vn(Q||"")},[Ce?.directory]),at=Ra(d??"",Ae),Ue=Je(Q=>Q.newSessionDraft?.open?vn(Q.newSessionDraft.bootstrapPendingDirectory??Q.newSessionDraft.directoryOverride??""):""),ht=Je(Q=>Q.newSessionDraft.target),ut=Je(Q=>Q.newSessionDraft.selectedProjectId),Ct=Je(Q=>Q.currentSessionDirectory),ge=ts(Q=>Q.homeDirectory),Ye=c.useMemo(()=>Be||Ae||Ue,[Ue,Ae,Be]),bt=Te(c.useCallback(Q=>{const He=vn(Ye||"");return He?Rl(Q.contextPanelByDirectory[He]):null},[Ye])),jt=Je(Q=>{const He=vn(Be||Ae||"");if(!He)return null;for(const et of Q.availableWorktreesByProject.values()){const Ut=et.find(Zt=>vn(Zt.path)===He)?.branch?.trim();if(Ut)return Ut}return null}),ze=Fm(Ye||null)||Qe||jt,it=u?ht==="chat":Bm(Ae||Ct,ge),$e=!it&&!de&&!!(S||ze||!u&&he),J=c.useMemo(()=>{if(!d)return S??"AiWorker";const Q=Ce?.title?.trim();return Q&&Q.length>0?Q:"Untitled Session"},[S,Ce?.title,d]),re=kd(Ye||void 0,{bootstrap:!1}),Pe=Cd(),_e=Je(Q=>Q.updateSessionTitle),Ve=Je(Q=>Q.shareSession),Ze=Je(Q=>Q.unshareSession),lt=Je(Q=>Q.archiveSessions),rt=Je(Q=>Q.deleteSessions),[Ge,ot]=c.useState(!1),[Ee,Rt]=c.useState(!1),xe=c.useRef(null),[mt,Tt]=c.useState(""),[Xe,nt]=c.useState(null),St=c.useRef(null),yt=c.useCallback(()=>{d&&(Tt(Ce?.title?.trim()||J),ot(!0))},[Ce?.title,d,J]),It=c.useRef(yt);It.current=yt;const kt=c.useCallback(Q=>{Q&&(Q.focus(),Q.select())},[]);c.useEffect(()=>{if(Rt(!1),nt(null),d&&xe.current===d){xe.current=null,It.current();return}ot(!1),Tt("")},[d]);const Et=c.useCallback(async()=>{if(!d)return;const Q=mt.trim();Q&&Q!==Ce?.title?.trim()&&await _e(d,Q),ot(!1)},[Ce?.title,d,mt,_e]);c.useEffect(()=>{if(!Ge)return;const Q=He=>{const et=He.target;(!et||!St.current?.contains(et))&&Et()};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[Ge,Et]);const Bt=c.useCallback(Q=>{Q&&gn(Q).then(He=>{Le[He.ok?"success":"error"](t(He.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(t("sessions.sidebar.session.copyId.error")))},[t]),zt=c.useCallback(async Q=>{if(!Q)return;const He=await Ve(Q);if(He?.share?.url){const et=await gn(He.share.url);Le[et.ok?"success":"warning"](t("sessions.sidebar.session.share.successTitle"),{description:t(et.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}Le.error(t("sessions.sidebar.session.share.error"))},[Ve,t]),Gt=c.useCallback(Q=>{Q&&gn(Q).then(He=>{Le[He.ok?"success":"error"](t(He.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>Le.error(t("sessions.sidebar.session.share.copyUrlError")))},[t]),rs=c.useCallback(async Q=>{if(!Q)return;const He=await Ze(Q);Le[He?"success":"error"](t(He?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[t,Ze]),_t=c.useCallback(async()=>{if(!d||!Ye){Le.error(t("sessions.sidebar.session.export.nothingToExport"));return}try{await Pe.loadCompleteHistory(d,Ye)}catch{Le.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}const Q=_m(re.getState(),d).list;if(Q.length===0){Le.error(t("sessions.sidebar.session.export.nothingToExport"));return}const He=ju(Q,Ce?.title??null),et=Nu(Ce?.title??null);await Cu(He,et)||ku(He,et),Le.success(t("sessions.sidebar.session.export.success"))},[Ce?.title,d,re,Ye,Pe,t]),Wt=f?.type==="busy"||f?.type==="retry",Me=c.useCallback(()=>{if(!d||!Ae||Wt||p)return;const Q=Is.getState().activeSessions,He=Q.find(Ut=>Ut.id===d);if(!He)return;const et=[],pt=[d];for(let Ut=0;Ut<pt.length;Ut+=1){const Zt=pt[Ut];for(const Lt of Q)Lt.parentID===Zt&&(et.push(Lt),pt.push(Lt.id))}Hi({kind:"quick",root:He,descendants:et,sourceDirectory:Ae,messages:Ui(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Wt,p,Ae,t]),qe=c.useCallback(async()=>{if(!Xe)return;const Q=Is.getState().activeSessions,He=[Xe.sessionId];for(let Zt=0;Zt<He.length;Zt+=1){const Lt=He[Zt];for(const hs of Q)hs.parentID===Lt&&!He.includes(hs.id)&&He.push(hs.id)}const et=Xe.action;if(nt(null),(et==="archive"?await lt(He):await rt(He)).failedIds.length>0){Le.error(t(et==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Le.success(t(et==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[lt,rt,Xe,t]),dt=Te(Q=>Q.isScheduledTasksDialogOpen),wt=Te(Q=>Q.isArchivePageOpen),ft=Te(Q=>Q.worktreesPageProjectId),ct=Te(Q=>Q.isMultiRunLauncherOpen),Vt=Ht(Q=>{if(!ft)return null;const He=Q.projects.find(et=>et.id===ft);return He?.label?.trim()||He?.path?.split("/").pop()||null}),Xt=c.useMemo(()=>dt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:wt?{title:t("sessions.archivePage.title"),subtitle:null}:ft?{title:t("sessions.worktreesPage.title",{project:Vt??""}),subtitle:null}:ct?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[wt,ct,dt,t,ft,Vt]),Jt=c.useMemo(()=>vn(Ye||w?.path||""),[w?.path,Ye]),ks=Ox(),ns=ba(Q=>Q.planModeEnabled),Ws=Je(Q=>Q.isSessionPlanAvailable),bs=ns&&d?Ws(d):!1,os=c.useRef("");c.useEffect(()=>{if(!ns||!d)return;const Q=`${d||"none"}:${Ae||"none"}:${Ce?.created||0}:${Ce?.slug||"none"}`;os.current!==Q&&(os.current=Q)},[ns,bs,Ce?.slug,Ce?.created,d,Ae]);const Zs=c.useCallback(()=>{Mn("desktop_open_draft_mini_chat_window",{directory:it?"":Ue,projectId:it?null:ut,apiBaseUrl:Nn(),clientToken:$r()}).catch(Q=>{console.warn("[header] failed to open draft mini chat window",Q)})},[Ue,ut,it]),zs=c.useCallback(()=>{if(u){Zs();return}d&&Mn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Ae||vn(Ct||"")||Be,apiBaseUrl:Nn(),clientToken:$r()}).catch(Q=>{console.warn("[header] failed to open session mini chat window",Q)})},[d,Zs,u,Ct,Ae,Be]),dn=c.useCallback(()=>{const Q=vn(Ye||"");if(!Q)return;const He=Te.getState().contextPanelByDirectory[Q];if(Rl(He)==="context"){r(Q);return}n(Q)},[r,n,Ye]),Ds=bt==="context",fs=Eo,Ps=c.useMemo(()=>y&&P&&!k?"88px":C?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!y||I)&&!le?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[y,k,P,C,le,I]);gt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",Ps)},[Ps]);const Vs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Us=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";gt.useEffect(()=>{if(!y||!P){D(!1);return}let Q=!1;const He=async()=>{try{const pt=await Mn("desktop_is_window_fullscreen");Q||D(pt===!0)}catch{Q||D(!1)}},et=()=>{He()};return He(),window.addEventListener("aiworker:window-resized",et),()=>{Q=!0,window.removeEventListener("aiworker:window-resized",et)}},[y,P]);const Cs=c.useMemo(()=>!y||!P||_===null?"":_>=26?"h-12":_<=15?"h-14":"",[y,P,_]),en=c.useMemo(()=>{if(!(y&&!I||le)&&!(I&&M==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[y,le,I,M]),Ot=c.useCallback(()=>{if(typeof document>"u")return;const Q=b.current?.getBoundingClientRect().height;Q&&document.documentElement.style.setProperty("--oc-header-height",`${Q}px`)},[]);gt.useEffect(()=>{if(typeof window>"u")return;Ot();const Q=b.current;if(!Q||typeof ResizeObserver>"u")return()=>{};let He=0;const et=()=>{He||(He=requestAnimationFrame(()=>{He=0,Ot()}))},pt=new ResizeObserver(et);return pt.observe(Q),window.addEventListener("resize",et),window.addEventListener("orientationchange",et),()=>{He&&cancelAnimationFrame(He),pt.disconnect(),window.removeEventListener("resize",et),window.removeEventListener("orientationchange",et)}},[Ot]),gt.useEffect(()=>{Ot()},[Ot,m,Cs]);const $t=c.useCallback(async Q=>{const He=Q.target;He.closest(".app-region-no-drag")||He.closest("button, a, input, select, textarea")||Q.button===0&&y&&await Jf()},[y]),Yt=c.useCallback(Q=>qn(qr(Q,i)),[i]);Lm({rename_current_session:()=>{if(!d||m)return!1;yt()},toggle_services_menu:()=>{if(X){H(!1);return}H(!0),ee()}});const ys=s.jsxs(s.Fragment,{children:[ks?s.jsx(Ex,{projectRef:ks.projectRef,directory:ks.directory,className:"mr-2"}):null,s.jsx(ax,{directory:Jt,className:"mr-1"}),y?s.jsx(pb,{isDesktopApp:y,currentInstanceLabel:Z,currentInstanceIsLocal:Y,isDesktopServicesOpen:X,setIsDesktopServicesOpen:H,refreshCurrentInstanceLabel:ee,shortcutLabel:Yt,remoteUpdateInfo:K,remoteUpdateChecking:je,remoteUpdateError:T,onOpenRemoteUpdate:$}):null]}),ms=N&&(u||!!d),te=c.useCallback(({session:Q,open:He,isActive:et,select:pt,closeOtherTabs:Ut,components:Zt})=>{const{Item:Lt,Separator:hs}=Zt,tn=Q.share?.url??null,Sr=et&&!le&&!it&&Ce&&!Ce.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Lt,{onClick:()=>{et||pt(),xe.current=Q.id},children:[s.jsx(E,{name:"pencil-ai",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(Vi,{sessionID:Q.id,directory:Q.directory,open:He,Item:Lt}),s.jsxs(Lt,{onClick:()=>Bt(Q.id),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(hs,{}),tn?s.jsxs(s.Fragment,{children:[s.jsxs(Lt,{onClick:()=>Gt(tn),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Lt,{onClick:()=>{rs(Q.id)},children:[s.jsx(E,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Lt,{onClick:()=>{zt(Q.id)},children:[s.jsx(E,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),et?s.jsxs(Lt,{onClick:()=>{_t()},children:[s.jsx(E,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,Sr?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Lt,{disabled:!Ae||Wt||p,onClick:Me,className:"w-full",children:[s.jsx(E,{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(p?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Wt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(hs,{}),s.jsxs(Lt,{onClick:Ut,children:[s.jsx(E,{name:"close-circle",className:"mr-2 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(hs,{}),s.jsxs(Lt,{onClick:()=>nt({action:"archive",sessionId:Q.id}),children:[s.jsx(E,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Lt,{className:"text-destructive focus:text-destructive",onClick:()=>nt({action:"delete",sessionId:Q.id}),children:[s.jsx(E,{name:"delete-bin",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Bt,Gt,Ce,_t,it,Wt,p,le,Me,Ae,zt,t,rs]),Ke=()=>s.jsxs("div",{onMouseDown:$t,className:Ie("app-region-drag relative flex h-12 select-none items-center",I&&M==="right"?"pr-0":"pr-3",Cs),style:en,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:Vs}}),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:Us}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Xt?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:Xt.title}),Xt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Xt.subtitle}):null]}):le||!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:[at?s.jsx(E,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(wl,{align:"start",children:s.jsx("button",{type:"button",className:fs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(E,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[Ge?s.jsxs("form",{ref:St,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:Q=>Q.stopPropagation(),onSubmit:Q=>{Q.preventDefault(),Et()},children:[s.jsx("input",{ref:kt,value:mt,onChange:Q=>Tt(Q.target.value),onKeyDown:Q=>Mi(Q,()=>ot(!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(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>ot(!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(E,{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"):J}),$e?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:[S?s.jsx("span",{className:"truncate",children:S}):null,ze?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:ze})]}):null,!u&&he?s.jsxs("span",{className:Ie("inline-flex min-w-0 items-center gap-0.5",he==="attention"||he==="invalid"||he==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(E,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:z})]}):null]}):null]}),s.jsx("div",{className:Ie("flex h-[18px] shrink-0 items-center justify-center",$e?"self-start":"self-center"),children:d&&!u&&!Ge?s.jsxs(Js,{open:Ee,onOpenChange:Rt,onOpenChangeComplete:Q=>{!Q&&xe.current&&xe.current===d&&(xe.current=null,yt())},children:[s.jsx(Ys,{asChild:!0,children:s.jsx(xt,{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(E,{name:"more",className:"size-4"})})}),s.jsxs(Xs,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Kt,{onClick:()=>{xe.current=d},children:[s.jsx(E,{name:"pencil-ai",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(Vi,{sessionID:d,directory:Ae,open:Ee,Item:Kt}),s.jsxs(Kt,{onClick:()=>d&&Bt(d),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Os,{}),Ce?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Kt,{onClick:()=>Gt(Ce?.shareUrl),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Kt,{onClick:()=>{d&&rs(d)},children:[s.jsx(E,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Kt,{onClick:()=>{d&&zt(d)},children:[s.jsx(E,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),s.jsxs(Kt,{onClick:()=>{_t()},children:[s.jsx(E,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),!le&&!it&&Ce&&!Ce.parentId?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Kt,{disabled:!Ae||Wt||p,onClick:Me,className:"w-full",children:[s.jsx(E,{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(p?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Wt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Os,{}),s.jsxs(Kt,{onClick:()=>{d&&nt({action:"archive",sessionId:d})},children:[s.jsx(E,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Kt,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&nt({action:"delete",sessionId:d})},children:[s.jsx(E,{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(wl,{align:"start",children:s.jsx("button",{type:"button",className:fs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(E,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx($x,{renderMenu:te,suppressActiveTabControls:Ge,onMenuOpenChangeComplete:Q=>{!Q&&xe.current&&xe.current===d&&(xe.current=null,yt())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:Ge?s.jsxs("form",{ref:St,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:Q=>Q.stopPropagation(),onSubmit:Q=>{Q.preventDefault(),Et()},children:[s.jsx("input",{ref:kt,value:mt,onChange:Q=>Tt(Q.target.value),onKeyDown:Q=>Mi(Q,()=>ot(!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(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>ot(!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(E,{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"):J})})})]}),Xt||le||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Ne&&j?s.jsx(Qp,{totalTokens:j.totalTokens,percentage:ie,colorPercentage:j.percentage,contextLimit:j.contextLimit,outputLimit:j.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:dn,pressed:Ds,className:ms?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(hb,{visible:ms,title:t(u?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(u?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:zs,className:Ie(fs,"mr-1"),Icon:"picture-in-picture-2"}),le?null:s.jsxs(At,{children:[s.jsx(Dt,{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:Ie(Eo,"mr-1",we?"text-foreground":"text-muted-foreground/50"),children:s.jsx(E,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(Pt,{side:"bottom",children:t(ue&&!me?Re?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":ue?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ys,s.jsx(eu,{visible:I&&M==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:b,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:Ke()}),s.jsx(vs,{open:Xe!==null,onOpenChange:Q=>{Q||nt(null)},children:s.jsxs(js,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs($s,{children:[s.jsx(Rs,{children:Xe?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Es,{children:Xe?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:J}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:J})})]}),s.jsxs(yn,{children:[s.jsx(xt,{variant:"outline",size:"sm",onClick:()=>nt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(xt,{variant:"destructive",size:"sm",onClick:()=>{qe()},children:Xe?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(tu,{open:oe,onOpenChange:Se,info:K,downloading:!1,downloaded:!1,progress:null,error:T,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function bb(){}const El=280,Ml=168,Ol=500,yb=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=Nt(),l=Te(k=>k.sidebarWidth),a=Te(k=>k.setSidebarWidth),[u,d]=c.useState(!1),h=c.useRef(0),f=c.useRef(l||El),p=c.useRef(null),g=c.useRef(null),w=c.useRef(null),S=c.useCallback(k=>Math.min(Ol,Math.max(Ml,k)),[]),x=c.useCallback(k=>{const D=w.current;D&&(D.style.width=`${k}px`,D.style.minWidth=`${k}px`,D.style.maxWidth=`${k}px`,D.style.setProperty("--oc-left-sidebar-width",`${k}px`))},[]);if(c.useEffect(()=>{e&&u&&d(!1)},[e,u]),c.useEffect(()=>{u||(p.current=null,g.current=null)},[u]),e)return null;const m=Math.min(Ol,Math.max(Ml,l||El)),b=t?m:0,y=k=>{if(t){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}g.current=k.pointerId,d(!0),h.current=k.clientX,f.current=b,p.current=b,x(b),k.preventDefault()}},v=k=>{if(e||!u||g.current!==k.pointerId)return;const D=k.clientX-h.current,P=S(f.current+D);p.current!==P&&(p.current=P,x(P))},N=k=>{if(g.current!==k.pointerId||e)return;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const D=S(p.current??b);g.current=null,p.current=null,d(!1),a(D)},C=u?p.current??b:b;return s.jsxs("aside",{ref:w,className:Ie("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":`${u?C:m}px`,overflowX:"clip",transitionProperty:u?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||b===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:Ie("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",u&&"bg-[var(--interactive-border)]"),onPointerDown:y,onPointerMove:v,onPointerUp:N,onPointerCancel:N,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Ie("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",u&&"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(cn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Gs,{children:n})})]})]})},wb=()=>{const t=st.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},Fl="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",Sb=()=>{const t=st.c(32),{t:e}=Nt(),n=Te(vb),r=Te(jb),i=c.useRef(null),o=qn(qr("toggle_sidebar",r)),{usesFramelessChrome:l,side:a}=Zd(),u=Cb;let d,h;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{if(typeof document>"u")return;const _=i.current;if(!_)return;const O=()=>{const L=Math.max(_.getBoundingClientRect().width,_.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(L)}px`)};if(O(),typeof ResizeObserver>"u")return;const U=new ResizeObserver(O);return U.observe(_),()=>{U.disconnect()}},h=[],t[0]=d,t[1]=h):(d=t[0],h=t[1]),c.useEffect(d,h);const f="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let p;t[2]===Symbol.for("react.memo_cache_sentinel")?(p={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=p):p=t[2];const g="flex items-center gap-2";let w;t[3]!==l||t[4]!==a?(w=l&&a==="left"?s.jsx(eu,{visible:!0,position:"left"}):null,t[3]=l,t[4]=a,t[5]=w):w=t[5];let S;t[6]!==e||t[7]!==l?(S=l?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,"aria-label":e("header.actions.openAppMenuAria"),className:Ie(Fl,"shrink-0"),children:s.jsx(E,{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]=l,t[8]=S):S=t[8];const x=At;let m;t[9]!==e?(m=e("header.actions.openSessionsAria"),t[9]=e,t[10]=m):m=t[10];let b,y;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=Ie(Fl,"shrink-0"),y=s.jsx(E,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=b,t[12]=y):(b=t[11],y=t[12]);let v;t[13]!==m||t[14]!==n?(v=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":m,className:b,children:y})}),t[13]=m,t[14]=n,t[15]=v):v=t[15];const N=Pt,C=e("header.actions.openSessionsWithShortcut",{shortcut:o});let k;t[16]!==C?(k=s.jsx("p",{children:C}),t[16]=C,t[17]=k):k=t[17];let D;t[18]!==N||t[19]!==k?(D=s.jsx(N,{children:k}),t[18]=N,t[19]=k,t[20]=D):D=t[20];let P;t[21]!==x||t[22]!==v||t[23]!==D?(P=s.jsxs(x,{children:[v,D]}),t[21]=x,t[22]=v,t[23]=D,t[24]=P):P=t[24];let I;t[25]!==P||t[26]!==w||t[27]!==S?(I=s.jsxs("div",{ref:i,className:g,children:[w,S,P]}),t[25]=P,t[26]=w,t[27]=S,t[28]=I):I=t[28];let M;return t[29]!==I||t[30]!==p?(M=s.jsx("div",{className:f,style:p,children:I}),t[29]=I,t[30]=p,t[31]=M):M=t[31],M};function vb(t){return t.toggleSidebar}function jb(t){return t.shortcutOverrides}function kb(t){console.warn("[titlebar] failed to open app menu",t)}function Cb(t){const e=t.currentTarget.getBoundingClientRect();Mn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(kb)}function Eu(t){const e=st.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(E,{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 u;return e[3]!==i?(u=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=u):u=e[4],u}const Bl=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Nb(t,e,n){const r=st.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 u=!1;return(async()=>{const[d,h]=await Promise.all([$m(t),Wm(t)]).catch(Ab);if(u)return;const f=Bl(d),p=Bl(h);if(!f||!p||p===f)return;const g=n||"",w=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:f,branch:g,label:g||w,name:w,worktreeRoot:p,worktreeStatus:"ready",headState:g?"branch":"unborn",worktreeSource:"existing"})})(),()=>{u=!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 Ab(){return["",""]}const _l="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Db=async(t,e)=>{if(t)return t.authActivate(e);const n=await ds("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},Ll=({className:t})=>{const{t:e}=Nt(),{github:n}=Sn(),r=An(g=>g.status),i=An(g=>g.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async g=>{if(!(!g||o)){l(!0);try{i(await Db(n,g))}catch(w){console.error("Failed to switch GitHub account:",w)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const u=r.user?.login??null,d=r.user?.avatarUrl??null,h=r.accounts??[],f=u?e("header.github.connectedWithLogin",{login:u}):e("header.github.connected"),p=d?s.jsx("img",{src:d,alt:u?e("header.github.avatarWithLogin",{login:u}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(E,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:Ie(_l,t),title:f,children:p}):s.jsxs(Js,{children:[s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(_l,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:p})}),s.jsxs(Xs,{align:"end",className:"w-64",children:[s.jsx(ho,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Os,{}),h.map(g=>{const w=g.user,S=!!g.current,x=g.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Kt,{className:"gap-2",disabled:o,onSelect:()=>{S||a(g.id)},children:[w?.avatarUrl?s.jsx("img",{src:w.avatarUrl,alt:w.login?e("header.github.avatarWithLogin",{login:w.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(E,{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:w?.name?.trim()||w?.login||"GitHub"}),w?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:w.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:x})]}):null]}),S?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},g.id)})]})]})};class Xo 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 Jo="/api/walkthrough",Mu=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),Ou=()=>new Xo("This AiWorker server has no walkthrough API",{code:"server-unsupported"}),Pb=t=>!Mu(t)&&(t.ok||t.status===404),Oa=async(t,e)=>{if(Pb(t))throw Ou();const n=await t.json().catch(()=>null);throw new Xo(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})},Fu=async t=>{if(!Mu(t))throw Ou();try{return await t.json()}catch{throw new Xo("The server returned a malformed walkthrough response")}};async function Ib(t,e,n={}){const r=await ds(Jo,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?Fu(r):Oa(r,"Failed to load walkthrough")}async function Tb(t,e,n={}){const r=await ds(`${Jo}/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?Fu(r):Oa(r,"Failed to generate walkthrough")}async function Rb(t,e){const n=await ds(`${Jo}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Oa(n,"Failed to cancel walkthrough generation")}async function Eb(t,e,n){const r=await ds(`${Jo}/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 kr={status:"idle",stage:null,result:null,readiness:null,error:null},Mb=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,In=(t,e)=>`${us()}\0${t}\0${Mb(e)}`,$l=t=>t instanceof Xo?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},rn=new Map,Cr=new Map,Ob=1e3,Fb=tr()(pu((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=In(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[In(n,r)],selectModel:(n,r,i)=>{const o=In(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[In(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[In(n,r)]??kr,load:async(n,r,i={})=>{if(!n)return;const o=In(n,r);if(e().entries[o]?.status==="generating")return;rn.get(o)?.abort();const a=new AbortController;rn.set(o,a),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??kr,status:"loading",error:null}}}));try{const u=await Ib(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{status:"ready",stage:null,result:u,readiness:u.readiness??null,error:null}}})),u.generating&&e().generate(n,r,{language:i.language})}catch(u){if(a.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??kr,status:"error",stage:null,error:$l(u)}}}))}finally{rn.get(o)===a&&rn.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=In(n,r);rn.get(o)?.abort();const l=new AbortController;rn.set(o,l),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??kr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const u=Cr.get(o);u!==void 0&&(clearInterval(u),Cr.delete(o))};a(),Cr.set(o,setInterval(()=>{Eb(n,r).then(u=>{!u||l.signal.aborted||t(d=>{const h=d.entries[o];return!h||h.status!=="generating"||h.stage===u?d:{entries:{...d.entries,[o]:{...h,stage:u}}}})}).catch(()=>{})},Ob));try{const u=await Tb(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{status:"ready",stage:null,result:u,readiness:d.entries[o]?.readiness??null,error:null}}}))}catch(u){if(l.signal.aborted)return;t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??kr,status:"error",stage:null,error:$l(u)}}}))}finally{a(),rn.get(o)===l&&rn.delete(o)}},cancel:(n,r)=>{const i=In(n,r);Rb(n,r).catch(()=>{}),rn.get(i)?.abort(),rn.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 rn.values())n.abort();rn.clear();for(const n of Cr.values())clearInterval(n);Cr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),Bb="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)]",_b=3e4,Wl=20,Bu=(t,e)=>JSON.stringify([us(),t,e]),Lb=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}},zl=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),Zr=new Map,$b=t=>{const e=Object.entries(t);return e.length<=Wl?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,Wl))},Vl=tr()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=Bu(r,i),a=o?.includeCheckDetails??!1,u=e().entries[l],d=u&&u.result&&Date.now()-u.fetchedAt<_b&&(u.hasCheckDetails||!a);if(!o?.force&&d)return u.result;const h=`${l}::${a?"details":"plain"}`,p=Zr.get(`${l}::details`)??(a?null:Zr.get(h));if(p&&!o?.force)return p;const g=(async()=>{t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??zl(),isLoading:!0,error:null}}}));try{const w=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(S=>({entries:$b({...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(x=>({entries:{...x.entries,[l]:{...x.entries[l]??zl(),isLoading:!1,error:S}}})),null}finally{Zr.delete(h)}})();return Zr.set(h,g),g},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const u=Lb(l);u&&u.directory===n&&(r==null||u.number===r)||(o[l]=a)}return{entries:o}})}})),Wb=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}:{}}},zb=35e3,ii=(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`},ai=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"}},Vb=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"},Ub=[2e3,5e3],Kb=600,Kl=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Rn=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):""},Hb=(t,e)=>{const n=Rn(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},Gb=(t,e)=>`${t}::${e}`,Fa=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},li=(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=Fa(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)},qb=t=>t.startsWith("pr-"),Qb=(t,e)=>{const n=Fa(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=>!qb(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Nr=new Map,eo=Uo;function Yb(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 u=await e.repoUpstream(t);if(a||!u?.isFork||!u.upstream||(r(u.upstream),!e.repoBranches))return;try{const d=await e.repoBranches(u.upstream.owner,u.upstream.repo);a||o(d)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const Xb=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=Nt(),u=Te(te=>te.timeFormatPreference),{github:d}=Sn(),h=An(te=>te.status),f=An(te=>te.hasChecked),p=Te(te=>te.setSettingsDialogOpen),g=Te(te=>te.setSettingsPage),w=Je(te=>te.currentSessionId),S=Je(te=>!!te.newSessionDraft?.open),{isMobile:x,hasTouchInput:m,screenWidth:b}=_n(),y=Te(te=>te.openContextSurface),v=Fb(te=>te.requestSource),N=!x&&b>=768&&!Pn(),C=c.useCallback(()=>{g("integrations"),p(!0)},[p,g]),k=c.useMemo(()=>Gb(t,e),[t,e]),D=c.useMemo(()=>Nr.get(k)??null,[k]),P=Hs(te=>te.ensureEntry),I=Hs(te=>te.setParams),M=Hs(te=>te.startWatching),_=Hs(te=>te.stopWatching),O=Hs(te=>te.refresh),U=Hs(te=>te.updateStatus),[L,F]=c.useState(()=>D?.title??Kl(e)),[R,j]=c.useState(()=>D?.body??""),[A,B]=c.useState(()=>D?.draft??!1),[X,H]=c.useState(()=>D?.additionalContext??""),[Z,ce]=c.useState(()=>{const te=typeof D?.targetBaseBranch=="string"?Rn(D.targetBaseBranch):"";return te||Rn(n)}),[Y,se]=c.useState("squash"),[oe,Se]=c.useState(!1),[K,pe]=c.useState(!1),[je,ne]=c.useState(!1),[T,G]=c.useState(!1),[le,de]=c.useState(!1),[ue,Oe]=c.useState(!1),[me,Re]=c.useState(null),[ye,q]=c.useState(""),[we,be]=c.useState(""),[Ne,ie]=c.useState(!1),[ee,V]=c.useState(!1),[$,ae]=c.useState(()=>li(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r})),[W,ve]=c.useState(!1),{detectedUpstream:Fe,upstreamBranches:Ce}=Yb(t,d);c.useEffect(()=>{ve(!1)},[t]);const ke=i.some(te=>te.name==="upstream"),We=!!(t&&e&&n&&(e!==n||(ke||Fe!==null))),z=c.useMemo(()=>Ho(t,e,$?.name??null),[t,e,$?.name]),he=Hs(te=>te.entries[z]),Be=he?.isLoading??!1,Ae=he?.status??null,at=he?.error??null,Ue=he?.isInitialStatusResolved??!1,ht=c.useMemo(()=>{const te=W?null:$?.name?.trim()||null,Ke=new Set;for(const He of o){const et=Hb(He,te);!et||et==="HEAD"||Ke.add(et)}if(W)for(const He of Ce)He&&He!=="HEAD"&&Ke.add(He);const tt=Rn(n);tt&&tt!=="HEAD"&&Ke.add(tt);const Q=Rn(Z);return Q&&Q!=="HEAD"&&Ke.add(Q),Array.from(Ke).sort((He,et)=>He.localeCompare(et))},[n,o,$?.name,Z,Ce,W]);c.useEffect(()=>{if(i.length===0){$&&ae(null);return}(!$||!i.some(te=>te.name===$.name))&&ae(li(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r}))},[D?.selectedRemoteName,i,$,r]),c.useEffect(()=>{const te=Rn(n);if(!Z&&te){ce(te);return}if(ht.length!==0&&!ht.includes(Z)){const Ke=ht.includes(te)?te:ht[0];Ke&&ce(Ke)}},[ht,n,Z]);const[ut,Ct]=c.useState(()=>D?.activeSegment??"overview"),[ge,Ye]=c.useState(new Set),[bt,jt]=c.useState(new Set),fe=c.useRef(new Set),ze=c.useRef(null),it=c.useRef(!1),$e=c.useRef(new Set),J=c.useRef([]);c.useEffect(()=>{Fe&&!ke&&ve(!0)},[Fe,ke]),c.useEffect(()=>{W&&Fe?.defaultBranch&&ce(Fe.defaultBranch)},[W,Fe?.defaultBranch]);const re=Ae?.pr??null,Pe=re?.state==="merged"||re?.state==="closed",_e=Pe?null:re,Ve=_e?Bu(t,_e.number):null,Ze=Vl(te=>Ve?te.entries[Ve]:void 0),lt=Vl(te=>te.ensure),rt=Ze?.result??null,Ge=Ze?.isLoading??!1,ot=c.useCallback(te=>{Ct(te);const Ke=Nr.get(k);Ke&&Nr.set(k,{...Ke,activeSegment:te})},[k]);c.useEffect(()=>{!_e||!d?.prContext||ut==="overview"||lt(d,t,_e.number,{includeCheckDetails:ut==="checks",sourceRepo:Ae?.repo??null})},[ut,t,lt,d,_e,Ae?.repo]);const Ee=Ae?.checks??null,Rt=(Ee?.pending??0)>0,xe=rt?.checkRuns??null,mt=rt?.fetchedAt;c.useEffect(()=>{if(!xe||xe.length===0)return;const te=Wb(xe);U(z,Ke=>{if(!Ke?.pr||typeof mt=="number"&&typeof Ke.fetchedAt=="number"&&mt<Ke.fetchedAt)return Ke;const tt=Ke.checks;return tt&&tt.state===te.state&&tt.total===te.total&&tt.success===te.success&&tt.failure===te.failure&&tt.pending===te.pending&&tt.inProgress===te.inProgress&&tt.queued===te.queued&&tt.startedAt===te.startedAt?Ke:{...Ke,checks:te,...typeof mt=="number"?{fetchedAt:mt}:{}}})},[xe,mt,z,U]),c.useEffect(()=>{if(ut!=="checks"||!Rt||!re||!d?.prContext)return;const te=window.setInterval(()=>{lt(d,t,re.number,{includeCheckDetails:!0,sourceRepo:Ae?.repo??null,force:!0})},zb);return()=>window.clearInterval(te)},[ut,Rt,t,lt,d,re,Ae?.repo]);const[Tt,Xe]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Rt)return;Xe(Date.now());const te=window.setInterval(()=>Xe(Date.now()),3e4);return()=>window.clearInterval(te)},[Rt]);const nt=re?`${t}#${re.number}`:null,St=!!(nt&&me===nt);c.useEffect(()=>{if(!d?.prContext||!re||typeof re.body=="string"&&re.body.length>0)return;const te=`${t}#${re.number}`;if(fe.current.has(te))return;fe.current.add(te),Re(te);let Ke=!1;return lt(d,t,re.number,{sourceRepo:Ae?.repo??null}).then(tt=>{if(Ke)return;const Q=tt?.pr;Q&&U(z,He=>!He?.pr||He.pr.number!==re.number?He:{...He,pr:{...He.pr,body:Q.body||""}})}).catch(()=>{}).finally(()=>{Ke||Re(tt=>tt===te?null:tt)}),()=>{Ke=!0}},[t,lt,d,re,z,Ae?.repo,U]),c.useEffect(()=>{if(!re){Oe(!1),q(""),be(""),ze.current=null;return}const te=ze.current!==null&&ze.current!==re.number;te&&Oe(!1),(!ue||te)&&(q(re.title||""),be(re.body||"")),ze.current=re.number},[ue,re]);const yt=c.useCallback(te=>{if(!te)return"";const Ke=Date.parse(te);return Number.isFinite(Ke)?Nd(Ke,u,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):te},[u]),It=c.useMemo(()=>{const te=h?.user?.login;return typeof te=="string"?te.trim():""},[h]),kt=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),Et=c.useCallback(te=>{const Ke=It.toLowerCase(),tt=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return te.replace(tt,(Q,He,et)=>{const pt=`@${et}`,Ut=et.toLowerCase();return`${He}[${pt}](https://github.com/${Ut}${Ke&&Ut===Ke?"?oc-self-mention=1":""})`})},[It]),Bt=c.useMemo(()=>{const te=(rt?.issueComments??[]).map(Q=>({id:`issue-${Q.id}`,body:Q.body||"",authorName:Q.author?.name||Q.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:Q.author?.login||null,avatarUrl:Q.author?.avatarUrl||null,createdAt:Q.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),Ke=(rt?.reviewComments??[]).map(Q=>({id:`review-${Q.id}`,body:Q.body||"",authorName:Q.author?.name||Q.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:Q.author?.login||null,avatarUrl:Q.author?.avatarUrl||null,createdAt:Q.createdAt,context:a("gitView.pr.comments.reviewContext"),path:Q.path||null,line:Q.line??null})),tt=[...te,...Ke];return tt.sort((Q,He)=>{const et=Q.createdAt?Date.parse(Q.createdAt):0,pt=He.createdAt?Date.parse(He.createdAt):0,Ut=Number.isFinite(et)?et:0,Zt=Number.isFinite(pt)?pt:0;return Ut-Zt}),tt},[rt,a]),zt=c.useCallback(()=>{const te=w??(S?"draft":null);return te?{directory:t,sessionKey:te}:(Le.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[w,t,S,a]),Gt=c.useCallback((te,Ke)=>{const tt=Ke.authorLogin?`@${Ke.authorLogin}`:Ke.authorName,Q=Ke.path?` · ${Ke.path}${Ke.line?`:${Ke.line}`:""}`:"";ji.getState().addDraft(te,{source:"pr-comment",fileLabel:`PR #${re?.number??""} ${tt}${Q}`,startLine:Ke.line??0,endLine:Ke.line??0,code:Ke.body,language:"markdown",text:""})},[re?.number]),rs=c.useCallback((te,Ke)=>{const tt=te.status||"unknown",Q=te.conclusion??void 0,He=Q?`${tt} / ${Q}`:tt,et=te.app?.name||te.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:Ke?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[Ke?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:te.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:et?`${et} · ${He}`:He})]}),te.detailsUrl?s.jsx(xt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:te.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),te.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:te.output.title}):null,te.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:te.output.summary}):null,te.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:te.output.text}):null,Array.isArray(te.annotations)&&te.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",te.annotations.length>20?` (showing 20/${te.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:te.annotations.slice(0,20).map((pt,Ut)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[pt.title||pt.level||"Issue",pt.path?` · ${pt.path}`:"",typeof pt.startLine=="number"?`:${pt.startLine}`:"",typeof pt.endLine=="number"&&pt.endLine!==pt.startLine?`-${pt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:pt.message}),pt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:pt.rawDetails}):null]},`${pt.path||"file"}:${pt.startLine||Ut}:${Ut}`))})]}):null,te.job?.steps&&te.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:te.job.steps.map((pt,Ut)=>{const Zt=(pt.conclusion||"").toLowerCase(),Lt=Zt&&!["success","neutral","skipped"].includes(Zt),hs=`${te.id??"run"}:${te.job?.jobId??"job"}:${pt.number??Ut}:${pt.name}`,tn=ge.has(hs);return Lt?s.jsxs(ki,{open:tn,children:[s.jsxs("button",{type:"button",onClick:()=>{Ye(Sr=>{const sr=new Set(Sr);return sr.has(hs)?sr.delete(hs):sr.add(hs),sr})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Lt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[tn?s.jsx(E,{name:"arrow-down-s",className:"size-4"}):s.jsx(E,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:pt.name}),pt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:pt.conclusion}):null]}),s.jsx(Ci,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof pt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",pt.number]}):null,pt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",pt.status]}):null,pt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",pt.conclusion]}):null,pt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",yt(pt.startedAt)]}):null,pt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",yt(pt.completedAt)]}):null]})})]},hs):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:pt.name}),pt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:pt.conclusion}):null]},hs)})})]}):null]})},[ge,yt,a]),[_t,Wt]=c.useState(!1),[Me,qe]=c.useState(!1),dt=c.useCallback(async()=>{if(!d?.prContext){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!re)return;const te=zt();if(te){Wt(!0);try{const Ke=await lt(d,t,re.number,{includeCheckDetails:!0,sourceRepo:Ae?.repo??null});if(!Ke){Le.error(a("gitView.pr.toast.loadChecksFailed"));return}const Q=(Ke.checkRuns??[]).filter(et=>ai(et.conclusion));if(Q.length===0){Le.message(a("gitView.pr.toast.noFailedChecks"));return}const He=ji.getState();for(const et of Q){const pt=(et.annotations??[]).map(Lt=>[[Lt.level,Lt.title].filter(Boolean).join(" "),Lt.path?`${Lt.path}${typeof Lt.startLine=="number"?`:${Lt.startLine}`:""}`:null,Lt.message,Lt.rawDetails].filter(Boolean).join(`
|
|
37
|
+
`)),Ut=(et.job?.steps??[]).filter(Lt=>ai(Lt.conclusion)).map(Lt=>`step ${Lt.number??"?"}: ${Lt.name} → ${Lt.conclusion}`),Zt=[`check: ${et.job?.workflowName?`${et.job.workflowName} / ${et.name}`:et.name}`,`status: ${et.status??"unknown"} / ${et.conclusion??"unknown"}`,et.detailsUrl?`url: ${et.detailsUrl}`:null,et.output?.title?`title: ${et.output.title}`:null,et.output?.summary?`summary:
|
|
38
|
+
${et.output.summary}`:null,Ut.length>0?`failed steps:
|
|
39
|
+
${Ut.join(`
|
|
40
|
+
`)}`:null,pt.length>0?`annotations:
|
|
41
|
+
${pt.join(`
|
|
42
|
+
---
|
|
43
|
+
`)}`:null].filter(Boolean).join(`
|
|
44
|
+
|
|
45
|
+
`);He.addDraft(te,{source:"pr-check",fileLabel:`PR #${re.number} · ${et.name}`,startLine:0,endLine:0,code:Zt,language:"text",text:""})}}catch(Ke){const tt=Ke instanceof Error?Ke.message:String(Ke);Le.error(a("gitView.pr.toast.loadChecksFailed"),{description:tt})}finally{Wt(!1)}}},[t,lt,d,re,zt,Ae?.repo,a]),wt=c.useCallback(async()=>{if(!d?.prContext){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!re)return;const te=zt();if(te){qe(!0);try{if(!await lt(d,t,re.number,{sourceRepo:Ae?.repo??null})){Le.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(Bt.length===0){Le.message(a("gitView.pr.toast.noPrComments"));return}for(const tt of Bt)Gt(te,tt)}catch(Ke){const tt=Ke instanceof Error?Ke.message:String(Ke);Le.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:tt})}finally{qe(!1)}}},[Gt,t,lt,d,re,zt,Ae?.repo,a,Bt]),ft=c.useCallback(async te=>{const Ke=zt();Ke&&Gt(Ke,te)},[Gt,zt]),ct=c.useCallback(async te=>{await O(z,te)},[z,O]),[Vt,Xt]=c.useState(!1),Jt=c.useRef(!0);c.useEffect(()=>(Jt.current=!0,()=>{Jt.current=!1}),[]);const ks=c.useCallback(async()=>{if(Vt)return;Xt(!0);const te=Date.now();try{await ct({force:!0})}finally{const Ke=Kb-(Date.now()-te);Ke>0&&await new Promise(tt=>window.setTimeout(tt,Ke)),Jt.current&&Xt(!1)}},[Vt,ct]),ns=c.useCallback(()=>{J.current.forEach(te=>{window.clearTimeout(te)}),J.current=Ub.map(te=>window.setTimeout(()=>{ct({force:!0,silent:!0,markInitialResolved:!0})},te))},[ct]);c.useEffect(()=>{if(!d?.prStatus||!We||i.length<=1||it.current||Ae?.pr)return;const te=`${k}::${$?.name??""}`;if($e.current.has(te))return;$e.current.add(te);const Ke=Qb(i,r).filter(He=>He.name!==$?.name);if(Ke.length===0)return;let tt=!1;return(async()=>{for(const He of Ke){if(tt)return;try{if(!(await d.prStatus(t,e,He.name))?.pr)continue;if(tt)return;ae(pt=>pt?.name===He.name?pt:He);return}catch{}}})(),()=>{tt=!0}},[e,We,t,d,i,$?.name,k,Ae?.pr,r]),c.useEffect(()=>{P(z),I(z,{directory:t,branch:e,remoteName:$?.name??null,canShow:We,github:d,githubAuthChecked:f,githubConnected:h?.connected??null})},[e,We,t,P,d,f,h?.connected,z,$?.name,I]),c.useEffect(()=>(M(z),()=>{_(z)}),[z,M,_]),c.useEffect(()=>{const te=Nr.get(k)??null;F(te?.title??Kl(e)),j(te?.body??""),B(te?.draft??!1),ce(te?.targetBaseBranch?Rn(te.targetBaseBranch):Rn(n));const Ke=li(i,{selectedRemoteName:te?.selectedRemoteName,trackingBranch:r});ae(tt=>tt?.name===Ke?.name?tt:Ke)},[n,e,i,k,r]),c.useEffect(()=>{ct({markInitialResolved:!0})},[z,ct]),c.useEffect(()=>{!We||!$?.name||ct({force:!0,silent:!0,markInitialResolved:!0})},[We,ct,$?.name]),c.useEffect(()=>{const te=Ae?.resolvedRemoteName?.trim();if(!te||it.current)return;const Ke=i.find(tt=>tt.name===te);Ke&&ae(tt=>tt?.name===Ke.name?tt:Ke)},[i,Ae?.resolvedRemoteName]),c.useEffect(()=>{const te=()=>{const tt=Hs.getState().entries[z]?.lastRefreshAt??0;Date.now()-tt>6e4&&ct({force:!0,silent:!0})},Ke=()=>{document.visibilityState==="visible"&&te()};return window.addEventListener("focus",te),document.addEventListener("visibilitychange",Ke),()=>{window.removeEventListener("focus",te),document.removeEventListener("visibilitychange",Ke)}},[z,ct]),c.useEffect(()=>{f&&h?.connected===!1&&ct({force:!0,silent:!0,markInitialResolved:!0})},[f,h,ct]),c.useEffect(()=>{!t||!e||Nr.set(k,{title:L,body:R,draft:A,additionalContext:X,targetBaseBranch:Z,selectedRemoteName:$?.name,activeSegment:ut})},[k,L,R,A,X,Z,$?.name,t,e,ut]),c.useEffect(()=>{const te=J.current;return()=>{te.forEach(Ke=>{window.clearTimeout(Ke)}),J.current=[]}},[]);const Ws=c.useCallback(async()=>{if(!oe&&t){Se(!0);try{const Ke={base:W&&Fe?.defaultBranchSha?Fe.defaultBranchSha:Z,head:e};X&&(Ke.context=X);const tt=await zm(t,Ke);tt.title?.trim()&&F(tt.title.trim()),tt.body?.trim()&&j(tt.body.trim()),l?.()}catch(te){const Ke=te instanceof Error?te.message:String(te);Le.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:Ke})}finally{Se(!1)}}},[X,e,Fe?.defaultBranchSha,t,oe,l,Z,a,W]),bs=c.useCallback(async()=>{if(!d?.prCreate){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}const te=L.trim();if(!te){Le.error(a("gitView.pr.toast.titleRequired"));return}const Ke=Z.trim();if(!Ke){Le.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!W&&Ke===e){Le.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}pe(!0);try{const tt=Fa(r),Q=W&&Fe,He=await d.prCreate({directory:t,title:te,head:e,base:Ke,...R.trim()?{body:R}:{},draft:A,...Q?{targetRepo:{owner:Fe.owner,repo:Fe.repo},headRemote:"origin"}:{...$?{remote:$.name}:{},...tt&&tt!==$?.name?{headRemote:tt}:{}}});Le.success(a("gitView.pr.toast.prCreated")),U(z,et=>et&&{...et,pr:He}),await ct({force:!0}),ns()}catch(tt){const Q=tt instanceof Error?tt.message:String(tt);Le.error(a("gitView.pr.toast.createPrFailed"),{description:Q})}finally{pe(!1)}},[R,e,Fe,t,A,d,z,ct,ns,$,Z,L,r,U,W,a]),os=c.useCallback(async te=>{if(!d?.prMerge){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}G(!0);try{const Ke=await d.prMerge({directory:t,number:te.number,method:Y});Ke.merged?Le.success(a("gitView.pr.toast.prMerged")):Le.message(a("gitView.pr.toast.prNotMerged"),{description:Ke.message||a("gitView.pr.notMergeable")}),await ct({force:!0}),ns()}catch(Ke){const tt=Ke instanceof Error?Ke.message:String(Ke);Le.error(a("gitView.pr.toast.mergeFailed"),{description:tt}),te.url&&eo(te.url)}finally{G(!1)}},[t,d,Y,ct,ns,a]),Zs=c.useCallback(async te=>{if(!d?.prReady){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}de(!0);try{await d.prReady({directory:t,number:te.number}),Le.success(a("gitView.pr.toast.markedReady")),await ct({force:!0}),ns()}catch(Ke){const tt=Ke instanceof Error?Ke.message:String(Ke);Le.error(a("gitView.pr.toast.markReadyFailed"),{description:tt}),te.url&&eo(te.url)}finally{de(!1)}},[t,d,ct,ns,a]),zs=c.useCallback(async te=>{if(!d?.prUpdate){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}const Ke=ye.trim();if(!Ke){Le.error(a("gitView.pr.toast.titleRequired"));return}ne(!0);try{const tt=await d.prUpdate({directory:t,number:te.number,title:Ke,body:we});U(z,Q=>Q&&{...Q,pr:{...Q.pr??te,...tt}}),Oe(!1),Le.success(a("gitView.pr.toast.prUpdated")),await ct({force:!0}),ns()}catch(tt){const Q=tt instanceof Error?tt.message:String(tt);Le.error(a("gitView.pr.toast.updatePrFailed"),{description:Q})}finally{ne(!1)}},[t,we,ye,d,z,ct,ns,U,a]);if(!We)return s.jsx("section",{className:"border-0 bg-transparent rounded-none",children:s.jsxs("div",{className:"space-y-1 pt-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("gitView.pullRequest.title")}),s.jsx(Ll,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const dn=Ae?.repo?.url||null,Ds=W&&Fe?.url?Fe.url:dn,fs=!!Ae?.canMerge,Ps=!!Ae?.connected,Vs=f&&Ae?.connected===!1,Us=Vb(Ae),Cs=Us?`var(--pr-${Us})`:"var(--status-info)",en=Us==="draft"?"git-pr-draft":Us==="merged"?"git-merge":Us==="closed"?"git-close-pull-request":"git-pull-request",Ot=re?[`${re.state}${re.draft?" (draft)":""}`,re.mergeable===!1?a("gitView.pr.notMergeable"):null,re.state==="open"&&typeof re.mergeableState=="string"&&re.mergeableState&&re.mergeableState!=="unknown"?re.mergeableState:null].filter(Boolean).join(" · "):"",$t=Ee?Ee.total>0?`${Ee.success}/${Ee.total} ${a("gitView.pr.checks.label")}`:`${Ee.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:"@container/pr-actions flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[re?s.jsxs(xt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{eo(re.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(E,{name:en,className:"size-4 shrink-0",style:{color:Cs}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(E,{name:en,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")}),re?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",re.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[re&&N?s.jsxs(xt,{variant:"outline",size:"sm",className:Ie("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Bb),onClick:()=>{v(t,{kind:"pr",number:re.number,sourceRepo:Ae?.repo?{owner:Ae.repo.owner,repo:Ae.repo.repo}:void 0}),y(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(E,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Be||Vt,onClick:()=>{ks()},"aria-label":a("gitView.pr.actions.refreshAria"),children:Be||Vt?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):s.jsx(E,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(Pt,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),s.jsx(Ll,{className:"h-7 w-7"})]})]}),re?s.jsxs("div",{className:"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:Cs},children:Ot}),Ee?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${Ul(Ee.state)}`}),$t]}):null,r&&$&&r.split("/")[0]!==$.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",$.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[fs&&re.draft&&re.state==="open"?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Zs(re),disabled:le||T||je||ue,"aria-label":a("gitView.pr.actions.markReadyAria"),children:le?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(Pt,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,fs?s.jsxs(s.Fragment,{children:[s.jsxs(Fs,{value:Y,onValueChange:te=>se(te),disabled:T||re.state!=="open",children:[s.jsx(Bs,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(As,{})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(ss,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(ss,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>os(re),disabled:T||le||re.state!=="open"||re.draft||je||ue,"aria-label":a("gitView.pr.actions.mergePrAria"),children:T?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{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:[Vs?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(xt,{variant:"outline",size:"sm",onClick:C,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,at?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:at}),Ds?s.jsx(xt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:Ds,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!re&&!Ue&&!at&&!Vs?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):re&&!Pe?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(su,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Ee&&Ee.total>0?`${a("gitView.pr.segment.checks")} ${Ee.success}/${Ee.total}`:a("gitView.pr.segment.checks"),icon:Ee?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Ul(Ee.state)}`}):void 0},{id:"comments",label:rt?`${a("gitView.pr.segment.comments")} ${(rt.issueComments?.length??0)+(rt.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:ut,onSelect:te=>ot(te),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),ut==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[fs&&re.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,fs?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:ue?s.jsx(Cn,{value:ye,onChange:te=>q(te.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:re.title})}),re.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:ue?s.jsxs(s.Fragment,{children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Oe(!1),q(re.title||""),be(re.body||"")},disabled:je,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(E,{name:"close",className:"size-4"})})}),s.jsx(Pt,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>zs(re),disabled:je||!ye.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:je?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"check",className:"size-4"})})}),s.jsx(Pt,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Oe(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(E,{name:"edit",className:"size-4"})})}),s.jsx(Pt,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),ue?s.jsx(lr,{value:we,onChange:te=>be(te.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m}):null,ue?null:re.body?.trim()?s.jsx(nl,{content:re.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(St?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,ut==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Ee&&Ee.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:[Ee.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Ee.success/Ee.total*100}%`}}):null,Ee.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Ee.failure/Ee.total*100}%`}}):null,Ee.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Ee.pending/Ee.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Ee.success,"/",Ee.total," ",a("gitView.pr.checks.label")]}),(Ee.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}),ii(Ee.startedAt,void 0,Tt)]}):null]}):null,Ee?.failure?s.jsxs(xt,{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:dt,disabled:_t,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[_t?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(rt?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(rt?.checkRuns??[]).map((te,Ke)=>{const tt=`${te.id??"run"}:${te.name}:${Ke}`,Q=te.status==="in_progress",He=te.status==="queued",et=ai(te.conclusion),pt=bt.has(tt),Ut=!!(te.output?.title||te.output?.summary||te.output?.text||(te.annotations?.length??0)>0||(te.job?.steps?.length??0)>0||te.detailsUrl),Zt=te.job?.workflowName,Lt=Q?ii(te.startedAt,void 0,Tt):ii(te.startedAt,te.completedAt);return s.jsxs("div",{className:Ie("rounded-md border border-border/40",et&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!Ut,onClick:()=>{jt(hs=>{const tn=new Set(hs);return tn.has(tt)?tn.delete(tt):tn.add(tt),tn})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[Q?s.jsx(E,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):He?s.jsx(E,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):et?s.jsx(E,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(E,{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:Zt&&Zt!==te.name?`${Zt} / ${te.name}`:te.name}),Lt?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:Lt}):null,Ut?s.jsx(E,{name:"arrow-down-s",className:Ie("size-4 shrink-0 text-muted-foreground transition-transform",pt&&"rotate-180")}):null]}),pt&&Ut?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:rs(te,{hideHeader:!0})}):null]},tt)})}):Ge?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(E,{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,ut==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Bt.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(xt,{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:wt,disabled:Me,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Me?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,Bt.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:Bt.map((te,Ke)=>{const tt=(te.authorName||"?").charAt(0).toUpperCase(),Q=Ke===Bt.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[Q?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:te.avatarUrl?s.jsx("img",{src:te.avatarUrl,alt:te.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:[te.authorName,te.authorLogin&&te.authorLogin!==te.authorName?` · @${te.authorLogin}`:""]}),te.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:yt(te.createdAt)}):null,s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs(xt,{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:()=>{ft(te)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(E,{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:[te.context,te.path?` · ${te.path}`:"",te.line?`:${te.line}`:""]}),s.jsx(nl,{content:Et(te.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",kt].filter(Boolean).join(" "),enableFileReferences:!1})]})]},te.id)})})}):Ge&&!rt?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(E,{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:[re&&Pe?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(E,{name:re.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Cs}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:re.state==="merged"?a("gitView.pr.history.merged",{number:re.number,base:re.base||Z}):a("gitView.pr.history.closed",{number:re.number})}),s.jsx(xt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{eo(re.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(E,{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)"})," → ",Z," ",s.jsxs("span",{className:"opacity-60",children:["(",W&&Fe?"upstream":"remote",")"]})]})]}),Ds?s.jsx(xt,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:Ds,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{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(Cn,{value:L,onChange:te=>F(te.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")}),ht.length>0?s.jsxs(Fs,{value:Z,onValueChange:ce,children:[s.jsx(Bs,{size:"lg",children:s.jsx(As,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(_s,{children:ht.map(te=>s.jsx(ss,{value:te,children:te},te))})]}):s.jsx(Cn,{value:Z,onChange:te=>ce(te.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(lr,{value:R,onChange:te=>j(te.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":A,onClick:()=>B(te=>!te),onKeyDown:te=>{(te.key===" "||te.key==="Enter")&&(te.preventDefault(),B(Ke=>!Ke))},children:[s.jsx(ur,{size:"sm",checked:A,onChange:te=>B(te),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),x?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(xt,{variant:"outline",size:"sm",onClick:()=>V(!0),children:X.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),X.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(ki,{open:Ne,onOpenChange:ie,children:[s.jsxs(Ad,{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:Ne?a("gitView.pr.actions.hide"):X.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(Ci,{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(lr,{value:X,onChange:te=>H(te.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(Go,{open:ee,onClose:()=>V(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(xt,{size:"sm",onClick:()=>V(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(lr,{value:X,onChange:te=>H(te.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(xt,{variant:"outline",size:"sm",onClick:Ws,disabled:oe||K,children:[oe?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(xt,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:bs,disabled:K||!Ps||!Z.trim()||!W&&Z.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:K?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},ci=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),to=new Map,so=new Map,Tn=t=>`${us()}::${t}`,Jb=()=>{const t=st.c(115),{t:e}=Nt(),{git:n}=Sn(),r=er(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=Vm(r??null),a=ya(o??null),u=Dd(o??null),d=Pd(o??null),{ensureAll:h,ensureNestedRepos:f,selectNestedRepo:p}=Dn(Jn(Zb)),g=Je(ey),w=Je(ty),S=Je(sy),x=Je(ny);let m;t[0]!==r?(m=ci(r),t[0]=r,t[1]=m):m=t[1];const b=m;let y;if(t[2]!==x||t[3]!==b||t[4]!==S){e:{if(!b){y=void 0;break e}let $;if(t[6]!==x||t[7]!==b){let W;t[9]!==b?(W=ve=>ci(ve.path)===b,t[9]=b,t[10]=W):W=t[10],$=x.find(W),t[6]=x,t[7]=b,t[8]=$}else $=t[8];const ae=$;if(ae){y=ae;break e}for(const W of S.values())if(ci(W.path)===b){y=W;break e}y=void 0}t[2]=x,t[3]=b,t[4]=S,t[5]=y}else y=t[5];const v=y;let N;t[11]!==g||t[12]!==v||t[13]!==w?.open||t[14]!==S?(N=()=>{if(g)return S.get(g)??v;if(w?.open)return v},t[11]=g,t[12]=v,t[13]=w?.open,t[14]=S,t[15]=N):N=t[15],w?.open;let C;t[16]!==N?(C=N(),t[16]=N,t[17]=C):C=t[17];const k=C;let D;t[18]!==g?(D=$=>g?$.getAttachment(g):void 0,t[18]=g,t[19]=D):D=t[19];const P=jd(D),I=P&&!P.degraded&&!P.legacy?P.worktreeRoot??void 0:void 0,M=Nb(r,k,a?.current??void 0);let _,O;t[20]!==h||t[21]!==n||t[22]!==o?(_=()=>{!o||!n||h(o,n)},O=[o,h,n],t[20]=h,t[21]=n,t[22]=o,t[23]=_,t[24]=O):(_=t[23],O=t[24]),c.useEffect(_,O);const[U,L]=c.useState(null);let F;t[25]!==I||t[26]!==M?.projectDirectory?(F=()=>{const $=I||M?.projectDirectory;if(!$){L(null);return}let ae=!1;return qo($).then(W=>{if(ae)return;const ve=W.trim();L(ve&&ve!=="HEAD"?ve:null)}).catch(()=>{ae||L(null)}),()=>{ae=!0}},t[25]=I,t[26]=M?.projectDirectory,t[27]=F):F=t[27];const R=M?.projectDirectory;let j;t[28]!==I||t[29]!==R?(j=[I,R],t[28]=I,t[29]=R,t[30]=j):j=t[30],c.useEffect(F,j);let A;t[31]!==o?(A=()=>(o?to.get(Tn(o)):void 0)??[],t[31]=o,t[32]=A):A=t[32];const[B,X]=c.useState(A);let H;t[33]!==o?(H=()=>(o?so.get(Tn(o)):void 0)??null,t[33]=o,t[34]=H):H=t[34];const[Z,ce]=c.useState(H);let Y,se;t[35]!==n||t[36]!==o?(Y=()=>{if(!o||!n?.getRemotes){X([]);return}X(to.get(Tn(o))??[]);let $=!1;return n.getRemotes(o).then(ae=>{$||(to.set(Tn(o),ae??[]),X(ae??[]))}).catch(()=>{$||X(to.get(Tn(o))??[])}),()=>{$=!0}},se=[o,n],t[35]=n,t[36]=o,t[37]=Y,t[38]=se):(Y=t[37],se=t[38]),c.useEffect(Y,se);let oe,Se;t[39]!==n||t[40]!==o?(oe=()=>{if(!o||!n?.getRemoteUrl){ce(null);return}ce(so.get(Tn(o))??null);let $=!1;return n.getRemoteUrl(o).then(ae=>{$||(so.set(Tn(o),ae),ce(ae))}).catch(()=>{$||ce(so.get(Tn(o))??null)}),()=>{$=!0}},Se=[o,n],t[39]=n,t[40]=o,t[41]=oe,t[42]=Se):(oe=t[41],Se=t[42]),c.useEffect(oe,Se);let K;e:{if(!u?.all){let ae;t[43]===Symbol.for("react.memo_cache_sentinel")?(ae=[],t[43]=ae):ae=t[43],K=ae;break e}let $;t[44]!==u.all?($=u.all.filter(ry).sort(),t[44]=u.all,t[45]=$):$=t[45],K=$}const pe=K;let je;e:{if(!u?.all){let ae;t[46]===Symbol.for("react.memo_cache_sentinel")?(ae=[],t[46]=ae):ae=t[46],je=ae;break e}let $;t[47]!==u.all?($=u.all.filter(oy).map(iy).sort(),t[47]=u.all,t[48]=$):$=t[48],je=$}const ne=je;let T;t[49]!==ne||t[50]!==Z||t[51]!==B||t[52]!==a?.tracking?(T=()=>{if(B.length>0)return B;const $=new Set,ae=a?.tracking?.trim();ae&&ae.includes("/")&&$.add(ae.split("/")[0]);for(const W of ne){const ve=W.indexOf("/");ve>0&&$.add(W.slice(0,ve))}return $.size===0&&Z&&$.add("origin"),Array.from($).map(W=>({name:W,fetchUrl:Z??"",pushUrl:Z??""}))},t[49]=ne,t[50]=Z,t[51]=B,t[52]=a?.tracking,t[53]=T):T=t[53],a?.tracking;let G;t[54]!==T?(G=T(),t[54]=T,t[55]=G):G=t[55];const le=G,de=a?.current??null;a?.tracking;let ue;t[56]!==a?.tracking?(ue=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=ue):ue=t[57];const Oe=ue,me=(Oe&&u?.defaultBranches?.[Oe])??u?.defaultBranches?.origin;let Re;t[58]!==de||t[59]!==me||t[60]!==le||t[61]!==pe||t[62]!==U||t[63]!==M?.createdFromBranch?(Re=()=>lg({remoteNames:new Set(le.map(ay)),localBranches:pe,worktreeCreatedFromBranch:M?.createdFromBranch,rootBranchHint:U,defaultBranch:me,headBranch:de}),t[58]=de,t[59]=me,t[60]=le,t[61]=pe,t[62]=U,t[63]=M?.createdFromBranch,t[64]=Re):Re=t[64],M?.createdFromBranch;let ye;t[65]!==Re?(ye=Re(),t[65]=Re,t[66]=ye):ye=t[66];const q=ye;if(!r){let $;t[67]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(E,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=$):$=t[67];let ae;t[68]!==e?(ae=e("gitView.pullRequest.title"),t[68]=e,t[69]=ae):ae=t[69];let W;t[70]!==ae?(W=s.jsx("div",{className:"typography-ui-header text-foreground",children:ae}),t[70]=ae,t[71]=W):W=t[71];let ve;t[72]!==e?(ve=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=ve):ve=t[73];let Fe;t[74]!==ve?(Fe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ve}),t[74]=ve,t[75]=Fe):Fe=t[75];let Ce;return t[76]!==W||t[77]!==Fe?(Ce=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[$,W,Fe]}),t[76]=W,t[77]=Fe,t[78]=Ce):Ce=t[78],Ce}if(i===!1&&d!==!0){let $;t[79]!==r||t[80]!==f?($=()=>{f(r,{force:!0})},t[79]=r,t[80]=f,t[81]=$):$=t[81];let ae;return t[82]!==d||t[83]!==l||t[84]!==i||t[85]!==$?(ae=s.jsx(cg,{rootIsGitRepo:i,resolvedIsGitRepo:d,nestedRepos:l,onRetryDiscovery:$}),t[82]=d,t[83]=l,t[84]=i,t[85]=$,t[86]=ae):ae=t[86],ae}if(!de){let $;t[87]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(E,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=$):$=t[87];let ae;t[88]!==e?(ae=e("gitView.pullRequest.title"),t[88]=e,t[89]=ae):ae=t[89];let W;t[90]!==ae?(W=s.jsx("div",{className:"typography-ui-header text-foreground",children:ae}),t[90]=ae,t[91]=W):W=t[91];let ve;t[92]!==e?(ve=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=ve):ve=t[93];let Fe;t[94]!==ve?(Fe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ve}),t[94]=ve,t[95]=Fe):Fe=t[95];let Ce;return t[96]!==W||t[97]!==Fe?(Ce=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[$,W,Fe]}),t[96]=W,t[97]=Fe,t[98]=Ce):Ce=t[98],Ce}const we=i===!1&&Array.isArray(l)&&l.length>0;let be;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==p||t[103]!==we?(be=we?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(dg,{repositories:l,selectedRepository:o??null,onSelectRepository:$=>{r&&p(r,$)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=p,t[103]=we,t[104]=be):be=t[104];const Ne=o??r,ie=a?.tracking??void 0;let ee;t[105]!==q||t[106]!==de||t[107]!==ne||t[108]!==B||t[109]!==Ne||t[110]!==ie?(ee=s.jsx(cn,{as:wa,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(Xb,{directory:Ne,branch:de,baseBranch:q,trackingBranch:ie,remotes:B,remoteBranches:ne})}),t[105]=q,t[106]=de,t[107]=ne,t[108]=B,t[109]=Ne,t[110]=ie,t[111]=ee):ee=t[111];let V;return t[112]!==be||t[113]!==ee?(V=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[be,ee]}),t[112]=be,t[113]=ee,t[114]=V):V=t[114],V};function Zb(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function ey(t){return t.currentSessionId}function ty(t){return t.newSessionDraft}function sy(t){return t.worktreeMetadata}function ny(t){return t.availableWorktrees}function ry(t){return!t.startsWith("remotes/")}function oy(t){return t.startsWith("remotes/")}function iy(t){return t.replace(/^remotes\//,"")}function ay(t){return t.name}const Gi=2e4,ly=(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},no=(t,e)=>qm(Qm.getState().dictionary,t,e),cy=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"},dy=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 ds(`/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()},_u=async(t,e,n)=>{if(Um(e)||Km(e)||Hm(e))return{ok:!0};try{const r=await dy(t,e,n);return Gm(r)?{ok:!1,reason:"binary"}:ly(r,Gi)>Gi?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:cy(r)}}},Lu=t=>{if(t==="too-large"){const e=Gi.toLocaleString(ga());return no("contextFileOpen.failure.tooLarge",{count:e})}return no(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},Hl=8;let qi=null;const $u=t=>{qi={x:t.clientX,y:t.clientY}},Wu=t=>{const e=qi;return qi=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=Hl&&Math.abs(t.clientY-e.y)<=Hl},Gl=3,mr=t=>Array.from(t.types).includes("Files"),uy=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]:[]})},ql=t=>{const e=t.name;return!e||e==="."||e===".."||e.includes("/")||e.includes("\\")?null:e},fy=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),as=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=as(e),r=as(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},my=(t,e)=>{const n=Ba(t,e);if(n!==".")return n;const r=as(t);return r.split("/").filter(Boolean).pop()??r},hy=t=>{const e=as(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},py=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),gy=new Set(["node_modules"]),xy=t=>gy.has(t),by=t=>{const e=as(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},yy=8,pn=new Map,_a=t=>JSON.stringify([us(),t]),wy=t=>{const e=_a(t),n=pn.get(e);return n?(n.touchedAt=Date.now(),pn.delete(e),pn.set(e,n),n):null},di=t=>{const e=_a(t),n=pn.get(e);if(n)return n.touchedAt=Date.now(),n;if(pn.size>=yy){const i=pn.keys().next().value;i!==void 0&&pn.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return pn.set(e,r),r},zu=(t,e)=>s.jsx(Sa,{filePath:t,extension:e}),Sy=t=>{const e=st.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},vy=t=>{const e=st.c(87),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:u,isDropTarget:d,canUpload:h,permissions:f,downloadFile:p,onSelect:g,onToggle:w,onRevealPath:S,onOpenDialog:x,onSetDropTarget:m,onDropFiles:b}=t,{t:y}=Nt(),v=n.type==="directory";let N;e[0]!==v||e[1]!==n.path?(N=v?n.path:hy(n.path),e[0]=v,e[1]=n.path,e[2]=N):N=e[2];const C=N,{canRename:k,canCreateFile:D,canCreateFolder:P,canDelete:I,canReveal:M}=f,_=!v&&!!p,O=M&&!l,U=k||D||P||I||_||O,[L,F]=c.useState(!1),[R,j]=c.useState(!1);let A;e[3]!==U?(A=$=>{U&&($?.preventDefault(),j(!0))},e[3]=U,e[4]=A):A=e[4];const B=A;let X;e[5]!==v||e[6]!==n||e[7]!==g||e[8]!==w?(X=()=>{v?w(n.path):g(n)},e[5]=v,e[6]=n,e[7]=g,e[8]=w,e[9]=X):X=e[9];const H=X;let Z;e[10]===Symbol.for("react.memo_cache_sentinel")?(Z=$=>{$.stopPropagation(),j(!1),F(!0)},e[10]=Z):Z=e[10];const ce=Z;let Y;e[11]!==D||e[12]!==P||e[13]!==I||e[14]!==k||e[15]!==O||e[16]!==p||e[17]!==l||e[18]!==v||e[19]!==n||e[20]!==x||e[21]!==S||e[22]!==y?(Y=$=>{const{Item:ae,Separator:W}=$;return s.jsxs(s.Fragment,{children:[k&&s.jsxs(ae,{onClick:ve=>{ve.stopPropagation(),x("rename",n)},children:[s.jsx(E,{name:"edit",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.rename")]}),s.jsxs(ae,{onClick:ve=>{ve.stopPropagation(),gn(n.path).then(Fe=>{if(Fe.ok){Le.success(y("sidebarFilesTree.toast.pathCopied"));return}Le.error(y("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(E,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.copyPath")]}),!v&&p&&s.jsxs(ae,{onClick:ve=>{ve.stopPropagation(),p(n.path).catch(Fe=>{console.error("Download failed:",Fe),Le.error(y("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(E,{name:"download",className:"mr-2 h-4 w-4"})," ",y(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),O&&s.jsxs(ae,{onClick:ve=>{ve.stopPropagation(),S(n.path)},children:[s.jsx(E,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",y(bd())]}),v&&(D||P)&&s.jsxs(s.Fragment,{children:[s.jsx(W,{}),D&&s.jsxs(ae,{onClick:ve=>{ve.stopPropagation(),x("createFile",n)},children:[s.jsx(E,{name:"file-add",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFile")]}),P&&s.jsxs(ae,{onClick:ve=>{ve.stopPropagation(),x("createFolder",n)},children:[s.jsx(E,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFolder")]})]}),I&&s.jsxs(s.Fragment,{children:[s.jsx(W,{}),s.jsxs(ae,{onClick:ve=>{ve.stopPropagation(),x("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.delete")]})]})]})},e[11]=D,e[12]=P,e[13]=I,e[14]=k,e[15]=O,e[16]=p,e[17]=l,e[18]=v,e[19]=n,e[20]=x,e[21]=S,e[22]=y,e[23]=Y):Y=e[23];const se=Y;let oe;e[24]!==n.path||e[25]!==r?(oe=$=>{$u($);const ae=Ba(r,n.path);!ae||ae==="."||($.dataTransfer.setData("application/x-openchamber-file-path",ae),$.dataTransfer.effectAllowed="copy")},e[24]=n.path,e[25]=r,e[26]=oe):oe=e[26];const Se=oe;let K;e[27]!==H?(K=$=>{Wu($)&&H()},e[27]=H,e[28]=K):K=e[28];const pe=K;let je;e[29]!==h||e[30]!==m||e[31]!==C?(je=$=>{!h||!C||!mr($.dataTransfer)||($.preventDefault(),$.stopPropagation(),$.dataTransfer.dropEffect="copy",m(C))},e[29]=h,e[30]=m,e[31]=C,e[32]=je):je=e[32];const ne=je;let T;e[33]!==h||e[34]!==m||e[35]!==C?(T=$=>{!h||!C||!mr($.dataTransfer)||$.relatedTarget instanceof Node&&$.currentTarget.contains($.relatedTarget)||($.stopPropagation(),m(null))},e[33]=h,e[34]=m,e[35]=C,e[36]=T):T=e[36];const G=T;let le;e[37]!==h||e[38]!==b||e[39]!==C?(le=$=>{!h||!C||!mr($.dataTransfer)||($.preventDefault(),$.stopPropagation(),b(C,$.dataTransfer))},e[37]=h,e[38]=b,e[39]=C,e[40]=le):le=e[40];const de=le;let ue;e[41]!==B||e[42]!==G||e[43]!==ne||e[44]!==de?(ue=s.jsx("div",{className:"group relative flex items-center",onContextMenu:B,onDragEnter:ne,onDragOver:ne,onDragLeave:G,onDrop:de}),e[41]=B,e[42]=G,e[43]=ne,e[44]=de,e[45]=ue):ue=e[45];const Oe=d?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let me;e[46]!==Oe?(me=Ie("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",Oe),e[46]=Oe,e[47]=me):me=e[47];let Re;e[48]!==v||e[49]!==i||e[50]!==n.extension||e[51]!==n.path?(Re=v?i?s.jsx(E,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(E,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):zu(n.path,n.extension),e[48]=v,e[49]=i,e[50]=n.extension,e[51]=n.path,e[52]=Re):Re=e[52];let ye;e[53]!==n.name||e[54]!==n.path?(ye=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[53]=n.name,e[54]=n.path,e[55]=ye):ye=e[55];let q;e[56]!==v||e[57]!==a?(q=!v&&a&&s.jsx(Sy,{status:a}),e[56]=v,e[57]=a,e[58]=q):q=e[58];let we;e[59]!==u||e[60]!==v?(we=v&&u&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[u.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",u.modified]}),u.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",u.added]})]}),e[59]=u,e[60]=v,e[61]=we):we=e[61];let be;e[62]!==B||e[63]!==pe||e[64]!==Se||e[65]!==H||e[66]!==me||e[67]!==Re||e[68]!==ye||e[69]!==q||e[70]!==we?(be=s.jsxs("button",{type:"button",onClick:H,onContextMenu:B,draggable:!0,onDragStart:Se,onDragEnd:pe,className:me,children:[Re,ye,q,we]}),e[62]=B,e[63]=pe,e[64]=Se,e[65]=H,e[66]=me,e[67]=Re,e[68]=ye,e[69]=q,e[70]=we,e[71]=be):be=e[71];let Ne;e[72]!==L||e[73]!==U||e[74]!==se||e[75]!==y?(Ne=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(Js,{open:L,onOpenChange:F,children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Ys,{asChild:!0,children:s.jsx(xt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ce,title:y("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":y("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(E,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(Pt,{side:"bottom",sideOffset:6,children:y("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(Xs,{align:"end",side:"bottom",onCloseAutoFocus:()=>F(!1),children:se({Item:Kt,Separator:Os})})]})}),e[72]=L,e[73]=U,e[74]=se,e[75]=y,e[76]=Ne):Ne=e[76];let ie;e[77]!==ue||e[78]!==be||e[79]!==Ne?(ie=s.jsxs(ru,{render:ue,children:[be,Ne]}),e[77]=ue,e[78]=be,e[79]=Ne,e[80]=ie):ie=e[80];let ee;e[81]!==se?(ee=s.jsx(nu,{className:"min-w-[180px]",children:se({Item:Un,Separator:Oi})}),e[81]=se,e[82]=ee):ee=e[82];let V;return e[83]!==R||e[84]!==ie||e[85]!==ee?(V=s.jsxs(ou,{open:R,onOpenChange:j,children:[ie,ee]}),e[83]=R,e[84]=ie,e[85]=ee,e[86]=V):V=e[86],V},jy=(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,ky=c.memo(vy,jy),Cy=t=>{const e=st.c(6),{visible:n}=t,r=n===void 0?!0:n,i=Dn(Ay),o=er();let l;e[0]!==o||e[1]!==i?(l=JSON.stringify([i,o]),e[0]=o,e[1]=i,e[2]=l):l=e[2];let a;return e[3]!==l||e[4]!==r?(a=s.jsx(Ny,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},Ny=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:n}=Nt(),{files:r,runtime:i}=Sn(),o=Zf(i.platform),l=er()??"",a=as(l.trim()),u=_a(a),d=em(),h=tm(),f=dd(fe=>fe.searchFiles),p=Te(fe=>fe.openContextFile),g=ya(t?l:null),[w,S]=c.useState(""),x=va(w,200),m=c.useRef(null),[b,y]=c.useState([]),[v,N]=c.useState(!1),[C,k]=c.useState(null),[D,P]=c.useState(!1),[I,M]=c.useState(null),_=c.useRef(!1),O=c.useRef(a);O.current=a;const[U,L]=c.useState({}),[F,R]=c.useState({}),j=c.useRef(new Set),A=c.useMemo(()=>new Og,[]);c.useEffect(()=>()=>A.clear(),[A]);const B=c.useRef(null);c.useEffect(()=>{if(k(null),M(null),!a){L({}),R({}),j.current=new Set;return}const fe=wy(a);fe?(L({...fe.childrenByDir}),R({...fe.loadErrorsByDir}),j.current=new Set(fe.loadedDirs)):(L({}),R({}),j.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const fe=di(a);fe.childrenByDir=U},[a,U]),c.useEffect(()=>{if(!a)return;const fe=di(a);fe.loadErrorsByDir=F},[a,F]),c.useEffect(()=>{if(!a)return;const fe=di(a);fe.loadedDirs=new Set(j.current)},[a,U,F]),c.useEffect(()=>()=>{if(!a)return;const fe=pn.get(u);fe&&fe.loadedDirs.size===0&&Object.keys(fe.childrenByDir).length===0&&pn.delete(u)},[u,a]);const X=c.useMemo(()=>[],[]),H=c.useMemo(()=>[],[]),Z=hn(fe=>a?fe.byRoot[a]?.expandedPaths??X:X),ce=c.useMemo(()=>new Set(Z),[Z]),Y=hn(fe=>a?fe.byRoot[a]?.selectedPath??null:null),se=hn(fe=>fe.setSelectedPath),oe=hn(fe=>fe.addOpenPath),Se=hn(fe=>fe.removeOpenPathsByPrefix),K=hn(fe=>fe.toggleExpandedPath),pe=hn(fe=>fe.collapseAllExpandedPaths),je=Te(fe=>a?fe.contextPanelByDirectory[a]?.tabs??H:H),ne=c.useMemo(()=>new Set(je.map(fe=>fe.mode==="file"?fe.targetPath:null).filter(fe=>typeof fe=="string"&&fe.length>0).map(fe=>as(fe))),[je]),[T,G]=c.useState(null),[le,de]=c.useState(null),[ue,Oe]=c.useState(""),[me,Re]=c.useState(!1),ye=!!r.writeFile,q=!!r.createDirectory,we=!!r.rename,be=!!r.delete,Ne=!!r.revealPath,ie=!!r.uploadFile,ee=c.useMemo(()=>({canRename:we,canCreateFile:ye,canCreateFolder:q,canDelete:be,canReveal:Ne}),[we,ye,q,be,Ne]),V=c.useCallback(fe=>{r.revealPath&&r.revealPath(fe).catch(()=>{Le.error(n("sidebarFilesTree.toast.revealFailed"))})},[r,n]),$=c.useCallback((fe,ze)=>{G(fe),de(ze),Oe(fe==="rename"&&ze.name||""),Re(!1)},[]),ae=c.useCallback((fe,ze)=>{const it=ze.filter($e=>$e&&typeof $e.name=="string"&&$e.name.length>0).filter($e=>d||!$e.name.startsWith(".")).filter($e=>h||!xy($e.name)).map($e=>{const J=$e.name,re=as($e.path||""),Pe=re?py(re)?re:as(`${fe}/${re}`):as(`${fe}/${J}`),_e=$e.isDirectory?"directory":"file",Ve=_e==="file"&&J.includes(".")?J.split(".").pop()?.toLowerCase():void 0;return{name:J,path:Pe,type:_e,extension:Ve}});return fy(it)},[h,d]),W=c.useCallback(async(fe,ze,it=!1)=>{if(!e.current||ze?.())return;const $e=as(fe.trim());if(!$e||!it&&j.current.has($e))return;const J=us();return A.run($e,async re=>{const Pe=()=>!re()||us()!==J;try{const _e=r.listDirectory?(await r.listDirectory($e)).entries:await Qs.listLocalDirectory($e);if(Pe())return;const Ve=ae($e,_e);j.current=new Set(j.current),j.current.add($e),R(Ze=>{if(!Ze[$e])return Ze;const lt={...Ze};return delete lt[$e],lt}),L(Ze=>Ze[$e]&&Fg(Ze[$e],Ve)?Ze:{...Ze,[$e]:Ve})}catch(_e){if(Pe())return;const Ve=_e instanceof Error?_e.message:String(_e??"");console.error("Failed to load sidebar directory:",_e),R(Ze=>({...Ze,[$e]:Ve}))}},it)},[A,r,ae]),ve=c.useCallback(async()=>{if(!a)return;B.current?.abort();const fe=new AbortController;B.current=fe,A.clear();try{const it=(hn.getState().byRoot[a]?.expandedPaths??[]).map(re=>as(re)).filter(re=>!!re&&re!==a&&re.startsWith(`${a}/`)),$e=[a,...it];j.current=new Set(j.current);for(const re of $e)j.current.delete(re);R(re=>{if(Object.keys(re).length===0)return re;const Pe={...re};let _e=!1;for(const Ve of $e)Ve in Pe&&(delete Pe[Ve],_e=!0);return _e?Pe:re});const J=()=>fe.signal.aborted;await W(a,J);for(let re=0;re<it.length&&!fe.signal.aborted;re+=3){const Pe=it.slice(re,re+3);await Promise.all(Pe.map(_e=>W(_e,J)))}}catch(ze){if(fe.signal.aborted)return;console.error("Failed to refresh sidebar tree:",ze)}finally{B.current===fe&&(B.current=null)}},[A,W,a]),Fe=c.useCallback(async fe=>{if(!fe){await ve();return}const ze=as(fe);j.current=new Set(j.current),j.current.delete(ze),await W(ze,void 0,!0)},[W,ve]);c.useEffect(()=>{a&&(B.current?.abort(),j.current=new Set,A.clear(),R({}),L(fe=>Object.keys(fe).length===0?fe:{}),W(a))},[A,W,a,d,h]),c.useEffect(()=>{if(!t||!a||Z.length===0)return;const fe=Z.map($e=>as($e)).filter($e=>!!$e&&$e!==a&&$e.startsWith(`${a}/`)&&!j.current.has($e)&&!A.has($e)).sort(($e,J)=>$e.split("/").length-J.split("/").length);if(fe.length===0)return;let ze=!1;const it=()=>ze;return(async()=>{for(let $e=0;$e<fe.length&&!ze;$e+=3){const J=fe.slice($e,$e+3);await Promise.all(J.map(re=>W(re,it)))}})(),()=>{ze=!0}},[A,Z,W,a,t]);const Ce=c.useRef(t);c.useEffect(()=>{const fe=t&&!Ce.current;Ce.current=t,fe&&ve()},[ve,t]),c.useEffect(()=>{if(!t)return;if(!l){y([]),N(!1);return}const fe=x.trim();if(!fe){y([]),N(!1);return}let ze=!1;return N(!0),f(l,fe,150,{includeHidden:d,respectGitignore:!h,type:"file"}).then(it=>{if(ze)return;const J=it.filter(re=>h||!by(re.path)).map(re=>({name:re.name,path:as(re.path),type:"file",extension:re.extension,relativePath:re.relativePath}));y(J)}).catch(()=>{ze||y([])}).finally(()=>{ze||N(!1)}),()=>{ze=!0}},[l,x,f,d,h,t]);const ke=c.useMemo(()=>{const fe=new Map;if(!g?.files)return fe;for(const ze of g.files)ze.index==="A"||ze.working_dir==="?"?fe.set(ze.path,"git-added"):ze.index==="D"?fe.set(ze.path,"git-deleted"):(ze.index==="M"||ze.working_dir==="M")&&fe.set(ze.path,"git-modified");return fe},[g]),Qe=c.useMemo(()=>{const fe=new Map;if(!g?.files||!a)return fe;for(const ze of g.files){const it=ze.index==="M"||ze.working_dir==="M",$e=ze.index==="A"||ze.working_dir==="?";if(!it&&!$e)continue;const J=ze.path.split("/");if(J.length<=1)continue;let re=a;for(let Pe=0;Pe<J.length-1;Pe++){re=`${re}/${J[Pe]}`;let _e=fe.get(re);_e||(_e={modified:0,added:0},fe.set(re,_e)),it&&_e.modified++,$e&&_e.added++}}return fe},[g,a]),We=c.useCallback(fe=>{if(ne.has(fe))return"open";if(ke.size===0)return null;const ze=fe.startsWith(a+"/")?fe.slice(a.length+1):fe;return ke.get(ze)??null},[ne,ke,a]),z=c.useCallback(fe=>{if(Qe.size===0)return null;const ze=Qe.get(fe);return ze&&ze.modified+ze.added>0?ze:null},[Qe]),he=c.useCallback(async fe=>{if(!a)return;const ze=await _u(r,fe.path,{directory:a});if(!ze.ok){Le.error(Lu(ze.reason));return}se(a,fe.path),oe(a,fe.path),p(a,fe.path)},[oe,r,p,a,se]),Be=c.useCallback(async fe=>{const ze=as(fe);a&&(K(a,ze),j.current.has(ze)||await W(ze))},[W,a,K]),Ae=c.useCallback(async(fe,ze,it=!1)=>{const $e=r.uploadFile;if(!$e||ze.length===0||_.current||!a)return;const J=a,re=us();_.current=!0,P(!0),k(fe),it&&M(null);const Pe=[];for(let Ge=0;Ge<ze.length;Ge+=Gl){const ot=ze.slice(Ge,Ge+Gl),Ee=await Promise.all(ot.map(async Rt=>{const xe=ql(Rt);if(!xe||us()!==re)return"failed";try{return(await $e(as(`${fe}/${xe}`),Rt,{directory:J,overwrite:it})).success?"uploaded":"failed"}catch(mt){return!it&&sm(mt)&&mt.reason==="already-exists"?"conflict":"failed"}}));Pe.push(...Ee)}const _e=Pe.filter(Ge=>Ge==="uploaded").length,Ve=Pe.filter(Ge=>Ge==="failed").length,Ze=ze.filter((Ge,ot)=>Pe[ot]==="conflict"),lt=ze.flatMap((Ge,ot)=>{const Ee=ql(Ge);return Pe[ot]==="uploaded"&&Ee?[as(`${fe}/${Ee}`)]:[]}),rt=O.current===J&&us()===re;try{lt.length>0&&Bg({runtimeKey:re,paths:lt}),_e>0&&rt&&await Fe(fe),_e>0&&Le.success(n(Ze.length>0?"sidebarFilesTree.toast.uploadedWithoutConflicts":"sidebarFilesTree.toast.uploaded")),Ve>0&&Le.error(n("sidebarFilesTree.toast.uploadFailed")),Ze.length>0&&rt&&M({directory:fe,files:Ze,runtimeKey:re,workspaceRoot:J})}finally{_.current=!1,P(!1),k(null)}},[r.uploadFile,Fe,a,n]),at=c.useCallback((fe,ze)=>{const it=uy(ze);it.length!==0&&Ae(fe,it)},[Ae]),Ue=c.useCallback(fe=>{!ie||_.current||!a||!mr(fe.dataTransfer)||(fe.preventDefault(),fe.dataTransfer.dropEffect="copy",k(a))},[ie,a]),ht=c.useCallback(fe=>{mr(fe.dataTransfer)&&(fe.relatedTarget instanceof Node&&fe.currentTarget.contains(fe.relatedTarget)||k(null))},[]),ut=c.useCallback(fe=>{!ie||_.current||!a||!mr(fe.dataTransfer)||(fe.preventDefault(),at(a,fe.dataTransfer))},[ie,at,a]),Ct=c.useCallback(async fe=>{if(fe?.preventDefault(),!le||!T)return;Re(!0);const ze=()=>Re(!1),it=()=>G(null);if(T==="createFile"){if(!ue.trim()){Le.error(n("sidebarFilesTree.toast.filenameRequired")),ze();return}if(!r.writeFile){Le.error(n("sidebarFilesTree.toast.writeNotSupported")),ze();return}const $e=le.path,J=$e?`${$e}/`:"",re=as(`${J}${ue.trim()}`);await r.writeFile(re,"").then(async Pe=>{Pe.success&&(Le.success(n("sidebarFilesTree.toast.fileCreated")),await Fe($e)),it()}).catch(()=>Le.error(n("sidebarFilesTree.toast.operationFailed"))).finally(ze);return}if(T==="createFolder"){if(!ue.trim()){Le.error(n("sidebarFilesTree.toast.folderNameRequired")),ze();return}const $e=le.path,J=$e?`${$e}/`:"",re=as(`${J}${ue.trim()}`);await r.createDirectory(re).then(async Pe=>{Pe.success&&(Le.success(n("sidebarFilesTree.toast.folderCreated")),await Fe($e)),it()}).catch(()=>Le.error(n("sidebarFilesTree.toast.operationFailed"))).finally(ze);return}if(T==="rename"){if(!ue.trim()){Le.error(n("sidebarFilesTree.toast.nameRequired")),ze();return}if(!r.rename){Le.error(n("sidebarFilesTree.toast.renameNotSupported")),ze();return}const $e=le.path,J=$e.split("/").slice(0,-1).join("/"),re=J?`${J}/`:"",Pe=as(`${re}${ue.trim()}`);await r.rename($e,Pe).then(async _e=>{_e.success&&(Le.success(n("sidebarFilesTree.toast.renamedSuccessfully")),await Fe(J),a&&Se(a,$e),(Y===$e||Y&&Y.startsWith(`${$e}/`))&&se(a,null)),it()}).catch(()=>Le.error(n("sidebarFilesTree.toast.operationFailed"))).finally(ze);return}if(T==="delete"){if(!r.delete){Le.error(n("sidebarFilesTree.toast.deleteNotSupported")),ze();return}const $e=le.path,J=$e.split("/").slice(0,-1).join("/");await r.delete($e).then(async re=>{re.success&&(Le.success(n("sidebarFilesTree.toast.deletedSuccessfully")),await Fe(J),a&&Se(a,$e),(Y===$e||Y&&Y.startsWith($e+"/"))&&se(a,null)),it()}).catch(()=>Le.error(n("sidebarFilesTree.toast.operationFailed"))).finally(ze);return}ze()},[T,le,ue,r,Fe,Se,a,Y,se,n]);function ge(fe,ze){const it=U[fe]??[];return it.map(($e,J)=>{const re=$e.type==="directory",Pe=re&&ce.has($e.path),_e=Y===$e.path,Ve=J===it.length-1;return s.jsxs("li",{className:"relative",children:[ze>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),Ve&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(ky,{node:$e,root:a,isExpanded:Pe,isActive:_e,isBrowserClient:o,status:re?void 0:We($e.path),badge:re?z($e.path):void 0,isDropTarget:re&&C===$e.path,canUpload:ie&&!D,permissions:ee,downloadFile:r.downloadFile,onSelect:he,onToggle:Be,onRevealPath:V,onOpenDialog:$,onSetDropTarget:k,onDropFiles:at}),re&&Pe&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[F[$e.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:F[$e.path],children:F[$e.path]}),s.jsxs(xt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Fe($e.path)},children:[s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):null,ge($e.path,ze+1)]})]},$e.path)})}const Ye=!!(a&&U[a]),bt=a?F[a]:null,jt=C?my(a,C):"";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:[ye&&s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(xt,{variant:"ghost",size:"sm",onClick:()=>$("createFile",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFileTitle"),"aria-label":n("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(E,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(Pt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFileTitle")})]}),q&&s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(xt,{variant:"ghost",size:"sm",onClick:()=>$("createFolder",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFolderTitle"),"aria-label":n("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(E,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(Pt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFolderTitle")})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(xt,{variant:"ghost",size:"sm",onClick:()=>{ve()},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.refreshTitle"),"aria-label":n("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(E,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(Pt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(xt,{variant:"ghost",size:"sm",onClick:()=>{a&&pe(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":n("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(E,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(Pt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(Cn,{ref:m,value:w,onChange:fe=>S(fe.target.value),placeholder:n("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),w.trim().length>0?s.jsx("button",{type:"button","aria-label":n("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:()=>{S(""),m.current?.focus()},children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(cn,{outerClassName:"h-full min-h-0",className:Ie("p-2",C===a&&"bg-interactive-selection/10"),onDragEnter:Ue,onDragOver:Ue,onDragLeave:ht,onDrop:ut,children:s.jsx("ul",{className:"flex flex-col",children:v?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin"}),n("sidebarFilesTree.state.searching")]}):b.length>0?b.map(fe=>{const ze=Y===fe.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>he(fe),draggable:!0,onDragStart:it=>{$u(it);const $e=fe.relativePath||Ba(a??"",fe.path);!$e||$e==="."||(it.dataTransfer.setData("application/x-openchamber-file-path",$e),it.dataTransfer.effectAllowed="copy")},onDragEnd:it=>{Wu(it)&&he(fe)},className:Ie("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",ze?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:fe.path,children:[zu(fe.path,fe.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:fe.relativePath??fe.path})]})},fe.path)}):bt?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:bt}),s.jsxs(xt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ve()},children:[s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):Ye&&a?ge(a,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:n("sidebarFilesTree.state.loading")})})}),C?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(E,{name:D?"loader-4":"folder-received",className:Ie("size-4 flex-shrink-0",D&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:jt,children:n(D?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:jt})})]}):null]}),s.jsx(vs,{open:!!I,onOpenChange:fe=>!fe&&M(null),children:s.jsxs(js,{children:[s.jsxs($s,{children:[s.jsx(Rs,{children:n("sidebarFilesTree.dialog.uploadConflicts.title")}),s.jsx(Es,{children:n("sidebarFilesTree.dialog.uploadConflicts.description",{path:I?.directory??""})})]}),s.jsx(cn,{outerClassName:"max-h-52",className:"flex flex-col gap-1 pr-2",children:I?.files.map((fe,ze)=>s.jsx("div",{className:"truncate rounded-md bg-muted px-2 py-1 typography-meta",title:fe.name,children:fe.name},`${fe.name}-${fe.size}-${ze}`))}),s.jsxs(yn,{children:[s.jsx(xt,{variant:"outline",onClick:()=>M(null),disabled:D,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(xt,{onClick:()=>{if(I){if(I.runtimeKey!==us()||I.workspaceRoot!==a){M(null);return}Ae(I.directory,I.files,!0)}},disabled:D,children:n("sidebarFilesTree.dialog.uploadConflicts.replace")})]})]})}),s.jsx(vs,{open:!!T,onOpenChange:fe=>!fe&&G(null),children:s.jsxs(js,{children:[s.jsxs($s,{children:[s.jsxs(Rs,{children:[T==="createFile"&&n("sidebarFilesTree.dialog.createFile.title"),T==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.title"),T==="rename"&&n("sidebarFilesTree.dialog.rename.title"),T==="delete"&&n("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Es,{children:[T==="createFile"&&n("sidebarFilesTree.dialog.createFile.description",{path:le?.path??n("sidebarFilesTree.dialog.rootFallback")}),T==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.description",{path:le?.path??n("sidebarFilesTree.dialog.rootFallback")}),T==="rename"&&n("sidebarFilesTree.dialog.rename.description",{name:le?.name??""}),T==="delete"&&n("sidebarFilesTree.dialog.delete.description",{name:le?.name??""})]})]}),T!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Cn,{value:ue,onChange:fe=>Oe(fe.target.value),placeholder:n(T==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:fe=>{fe.key==="Enter"&&Ct()},autoFocus:!0})}),s.jsxs(yn,{children:[s.jsx(xt,{variant:"outline",onClick:()=>G(null),disabled:me,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(xt,{variant:T==="delete"?"destructive":"default",onClick:()=>{Ct()},disabled:me||T!=="delete"&&!ue.trim(),children:me?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):n(T==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function Ay(t){return t.runtimeKey}const Ql=60,Dy=t=>{try{return new URL(t).origin}catch{return""}},ui=new Set,Vu=tr()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=Dy(n);!i||!r||e().byOrigin[i]||ui.has(i)||(ui.add(i),fr("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const u={...a.byOrigin,[i]:l},d=Object.keys(u);if(d.length<=Ql)return{byOrigin:u};for(const h of d.slice(0,d.length-Ql))delete u[h];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{ui.delete(i)}))}})),La=t=>t,Qi=t=>{const e=La(t).type;return typeof e=="string"?e:""},Py=t=>{const e=La(t).tool;return typeof e=="string"?e:""},Iy=t=>{const e=La(t).text;return typeof e=="string"?e:""},Ty=t=>{const e=Qi(t);return e==="tool"?Py(t).trim().toLowerCase()||"tool":e||"unknown"},Ry=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=Ty(n);e.includes(r)||e.push(r)}return e.join(" + ")},Ey=t=>t.replace(/\s+/g," ").trim(),My=t=>{for(const n of t)if(Qi(n)==="text"){const r=Ey(Iy(n));if(r.length===0)continue;return r}const e=t.filter(n=>Qi(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Oy=(t,e,n)=>`${n(t)} / ${n(e)}`,Fy=t=>{if(t==="12h")return!0;if(t==="24h")return!1},By=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=Fy(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}})},Yi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},xo={user:0,assistant:0,tool:0,other:0},En=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,fi=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(h=>h.tokens!==void 0)?.tokens;if(typeof n=="number")return{...Yi,total:En(n)};if(!n||typeof n!="object")return Yi;const r=n,i=En(r.input),o=En(r.output),l=En(r.reasoning),a=En(r.cache?.read),u=En(r.cache?.write),d=En(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:u,total:d>0?d:i+o+l+a+u}},_y=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Ks=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+Ks(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+Ks(n),0):0,Ly=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...xo,assistant:Ks(n.text)+Ks(n.content)};const i=_y(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Ks(n.input)+Ks(n.output)+Ks(n.error)+Ks(n.call?.input)+Ks(n.call?.output)+Ks(n.call?.error)+Ks(n.raw)+Math.round(Ks(n.metadata)*.25)+Math.round(Ks(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}},Yl=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),$y=t=>{const e=Qr(t.info);return e.isUser?"user":e.role==="assistant"?"assistant":e.role==="tool"?"tool":"other"},Wy=(t,e)=>{if(t.length===0)return{...xo};const n=t.reduce((r,i)=>{const o=$y(i);let l={...xo};for(const a of i.parts)l=Yl(l,Ly(a,o));return Yl(r,l)},{...xo});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)}},Vn=t=>t.toLocaleString(ga()),zy=(t,e)=>!t||!Number.isFinite(t)?"-":Nd(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Vy=(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}},Uy=()=>{const t=st.c(203),{t:e}=Nt(),n=Te(Ky);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),u=c.useRef(null),d=Je(Hy),h=Je(Gy),f=Id(h??void 0),p=Ym(d??"",h??void 0),g=qt(qy);let w;t[1]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),o(Qy),a(null)},t[1]=w):w=t[1];let S;t[2]!==h||t[3]!==d?(S=[h,d],t[2]=h,t[3]=d,t[4]=S):S=t[4],c.useEffect(w,S);let x,m;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},m=[],t[5]=x,t[6]=m):(x=t[5],m=t[6]),c.useEffect(x,m);let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=async(ot,Ee)=>{(await gn(Ee)).ok?(a(ot),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{a(xe=>xe===ot?null:xe),u.current=null},2e3)):a(null)},t[7]=b):b=t[7];const y=b;let v;t[8]!==d||t[9]!==f?(v=d?f.find(ot=>ot.id===d)??null:null,t[8]=d,t[9]=f,t[10]=v):v=t[10];const N=v;let C,k,D,P,I,M;if(t[11]!==g||t[12]!==p){C=p.filter(Yy);let ot;t[19]!==p?(ot=p.filter(Xy),t[19]=p,t[20]=ot):ot=t[20],M=ot;let Ee=null;for(let xe=C.length-1;xe>=0;xe=xe-1,xe){const mt=C[xe];if(fi(mt).total>0){Ee=mt;break}}P=Ee?fi(Ee):Yi,k=Xm({input:P.input,cache:{read:P.cacheRead,write:P.cacheWrite}}),I=C.reduce(Jy,0);const Rt=Ee?.info??null;D=Vy(g,Rt?.providerID||"",Rt?.modelID||""),t[11]=g,t[12]=p,t[13]=C,t[14]=k,t[15]=D,t[16]=P,t[17]=I,t[18]=M}else C=t[13],k=t[14],D=t[15],P=t[16],I=t[17],M=t[18];const _=D,O=_.contextLimit,U=O&&O>0?Math.min(999,P.total/O*100):0;let L;if(t[21]!==p){const ot=[...p].reverse().find(Zy)?.info?.system||"";L=Wy(p,ot),t[21]=p,t[22]=L}else L=t[22];const F=L,R=F.user,j=F.assistant,A=F.tool,B=Math.max(0,P.input-R-j-A),X=R+j+A+B,H=p[0]?.info?.time?.created,Z=p.length>0?p[p.length-1]?.info?.time?.created:null;let ce;t[23]!==N?.title||t[24]!==e?(ce=N?.title||e("contextSidebar.session.untitled"),t[23]=N?.title,t[24]=e,t[25]=ce):ce=t[25];const Y=N?.time?.created??H??null,se=Z??N?.time?.created??null;let oe;t[26]!==j||t[27]!==B||t[28]!==A||t[29]!==R?(oe={user:R,assistant:j,tool:A,other:B},t[26]=j,t[27]=B,t[28]=A,t[29]=R,t[30]=oe):oe=t[30];let Se;t[31]!==C.length||t[32]!==X||t[33]!==k||t[34]!==O||t[35]!==_||t[36]!==p.length||t[37]!==Y||t[38]!==se||t[39]!==oe||t[40]!==ce||t[41]!==P||t[42]!==I||t[43]!==U||t[44]!==M.length?(Se={sessionTitle:ce,messagesCount:p.length,userMessagesCount:M.length,assistantMessagesCount:C.length,createdAt:Y,lastActivityAt:se,providerModel:_,tokenBreakdown:P,usagePercent:U,cacheHitRate:k,totalAssistantCost:I,contextLimit:O,breakdown:oe,breakdownTotal:X},t[31]=C.length,t[32]=X,t[33]=k,t[34]=O,t[35]=_,t[36]=p.length,t[37]=Y,t[38]=se,t[39]=oe,t[40]=ce,t[41]=P,t[42]=I,t[43]=U,t[44]=M.length,t[45]=Se):Se=t[45];const K=Se;if(!d){let ot;t[46]!==e?(ot=e("contextSidebar.empty.openSession"),t[46]=e,t[47]=ot):ot=t[47];let Ee;return t[48]!==ot?(Ee=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:ot}),t[48]=ot,t[49]=Ee):Ee=t[49],Ee}let pe;t[50]!==e?(pe=e("contextSidebar.breakdown.user"),t[50]=e,t[51]=pe):pe=t[51];let je;t[52]!==pe||t[53]!==K.breakdown.user?(je={key:"user",label:pe,value:K.breakdown.user,color:"var(--status-success)"},t[52]=pe,t[53]=K.breakdown.user,t[54]=je):je=t[54];let ne;t[55]!==e?(ne=e("contextSidebar.breakdown.assistant"),t[55]=e,t[56]=ne):ne=t[56];let T;t[57]!==ne||t[58]!==K.breakdown.assistant?(T={key:"assistant",label:ne,value:K.breakdown.assistant,color:"var(--primary-base)"},t[57]=ne,t[58]=K.breakdown.assistant,t[59]=T):T=t[59];let G;t[60]!==e?(G=e("contextSidebar.breakdown.toolCalls"),t[60]=e,t[61]=G):G=t[61];let le;t[62]!==G||t[63]!==K.breakdown.tool?(le={key:"tool",label:G,value:K.breakdown.tool,color:"var(--status-warning)"},t[62]=G,t[63]=K.breakdown.tool,t[64]=le):le=t[64];let de;t[65]!==e?(de=e("contextSidebar.breakdown.other"),t[65]=e,t[66]=de):de=t[66];let ue;t[67]!==de||t[68]!==K.breakdown.other?(ue={key:"other",label:de,value:K.breakdown.other,color:"var(--surface-muted-foreground)"},t[67]=de,t[68]=K.breakdown.other,t[69]=ue):ue=t[69];let Oe;t[70]!==je||t[71]!==T||t[72]!==le||t[73]!==ue?(Oe=[je,T,le,ue],t[70]=je,t[71]=T,t[72]=le,t[73]=ue,t[74]=Oe):Oe=t[74];const me=Oe;let Re;t[75]!==K.sessionTitle?(Re=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:K.sessionTitle}),t[75]=K.sessionTitle,t[76]=Re):Re=t[76];let ye;t[77]!==K.providerModel.modelName||t[78]!==K.providerModel.providerName?(ye=s.jsxs("span",{children:[K.providerModel.providerName," / ",K.providerModel.modelName]}),t[77]=K.providerModel.modelName,t[78]=K.providerModel.providerName,t[79]=ye):ye=t[79];let q;t[80]!==n||t[81]!==K.createdAt?(q=K.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:zy(K.createdAt,n)})]}),t[80]=n,t[81]=K.createdAt,t[82]=q):q=t[82];let we;t[83]!==ye||t[84]!==q?(we=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:[ye,q]}),t[83]=ye,t[84]=q,t[85]=we):we=t[85];let be;t[86]!==Re||t[87]!==we?(be=s.jsxs("div",{className:"mb-6",children:[Re,we]}),t[86]=Re,t[87]=we,t[88]=be):be=t[88];let Ne;t[89]!==e?(Ne=e("contextSidebar.section.context"),t[89]=e,t[90]=Ne):Ne=t[90];let ie;t[91]!==Ne?(ie=s.jsx("span",{className:"typography-micro text-muted-foreground",children:Ne}),t[91]=Ne,t[92]=ie):ie=t[92];let ee;t[93]!==K.tokenBreakdown.total?(ee=Vn(K.tokenBreakdown.total),t[93]=K.tokenBreakdown.total,t[94]=ee):ee=t[94];let V;t[95]!==K.contextLimit?(V=K.contextLimit?` / ${Vn(K.contextLimit)}`:"",t[95]=K.contextLimit,t[96]=V):V=t[96];let $;t[97]!==ee||t[98]!==V?($=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[ee,V]}),t[97]=ee,t[98]=V,t[99]=$):$=t[99];let ae;t[100]!==ie||t[101]!==$?(ae=s.jsxs("div",{className:"flex items-baseline justify-between",children:[ie,$]}),t[100]=ie,t[101]=$,t[102]=ae):ae=t[102];let W;t[103]!==K.usagePercent?(W=K.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,K.usagePercent)}%`,backgroundColor:K.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[103]=K.usagePercent,t[104]=W):W=t[104];let ve;t[105]!==W?(ve=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:W}),t[105]=W,t[106]=ve):ve=t[106];let Fe;t[107]!==e||t[108]!==K.usagePercent?(Fe=e("contextSidebar.context.percentUsed",{percent:K.usagePercent.toFixed(1)}),t[107]=e,t[108]=K.usagePercent,t[109]=Fe):Fe=t[109];let Ce;t[110]!==Fe?(Ce=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Fe}),t[110]=Fe,t[111]=Ce):Ce=t[111];let ke;t[112]!==ae||t[113]!==ve||t[114]!==Ce?(ke=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ae,ve,Ce]}),t[112]=ae,t[113]=ve,t[114]=Ce,t[115]=ke):ke=t[115];let Qe;t[116]!==e?(Qe=e("contextSidebar.stats.messages"),t[116]=e,t[117]=Qe):Qe=t[117];let We;t[118]!==K.messagesCount?(We=Vn(K.messagesCount),t[118]=K.messagesCount,t[119]=We):We=t[119];let z;t[120]!==Qe||t[121]!==We?(z={label:Qe,value:We},t[120]=Qe,t[121]=We,t[122]=z):z=t[122];let he;t[123]!==e?(he=e("contextSidebar.stats.user"),t[123]=e,t[124]=he):he=t[124];let Be;t[125]!==K.userMessagesCount?(Be=Vn(K.userMessagesCount),t[125]=K.userMessagesCount,t[126]=Be):Be=t[126];let Ae;t[127]!==he||t[128]!==Be?(Ae={label:he,value:Be},t[127]=he,t[128]=Be,t[129]=Ae):Ae=t[129];let at;t[130]!==e?(at=e("contextSidebar.stats.assistant"),t[130]=e,t[131]=at):at=t[131];let Ue;t[132]!==K.assistantMessagesCount?(Ue=Vn(K.assistantMessagesCount),t[132]=K.assistantMessagesCount,t[133]=Ue):Ue=t[133];let ht;t[134]!==at||t[135]!==Ue?(ht={label:at,value:Ue},t[134]=at,t[135]=Ue,t[136]=ht):ht=t[136];let ut;t[137]!==e?(ut=e("contextSidebar.stats.cost"),t[137]=e,t[138]=ut):ut=t[138];let Ct;t[139]!==K.totalAssistantCost?(Ct=Yp(K.totalAssistantCost),t[139]=K.totalAssistantCost,t[140]=Ct):Ct=t[140];let ge;t[141]!==ut||t[142]!==Ct?(ge={label:ut,value:Ct},t[141]=ut,t[142]=Ct,t[143]=ge):ge=t[143];let Ye;t[144]!==z||t[145]!==Ae||t[146]!==ht||t[147]!==ge?(Ye=[z,Ae,ht,ge],t[144]=z,t[145]=Ae,t[146]=ht,t[147]=ge,t[148]=Ye):Ye=t[148];const bt=Ye;let jt;t[149]!==bt?(jt=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:bt.map(e1)}),t[149]=bt,t[150]=jt):jt=t[150];let fe;t[151]!==e?(fe=e("contextSidebar.section.lastAssistantMessage"),t[151]=e,t[152]=fe):fe=t[152];let ze;t[153]!==fe?(ze=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:fe}),t[153]=fe,t[154]=ze):ze=t[154];let it;t[155]!==e||t[156]!==K.cacheHitRate.hasInput||t[157]!==K.cacheHitRate.percent||t[158]!==K.tokenBreakdown.cacheRead||t[159]!==K.tokenBreakdown.cacheWrite||t[160]!==K.tokenBreakdown.input||t[161]!==K.tokenBreakdown.output||t[162]!==K.tokenBreakdown.reasoning?(it=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:K.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:K.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:K.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:K.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:K.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:K.cacheHitRate.hasInput?K.cacheHitRate.percent:null,format:"percent"}].map(t1)}),t[155]=e,t[156]=K.cacheHitRate.hasInput,t[157]=K.cacheHitRate.percent,t[158]=K.tokenBreakdown.cacheRead,t[159]=K.tokenBreakdown.cacheWrite,t[160]=K.tokenBreakdown.input,t[161]=K.tokenBreakdown.output,t[162]=K.tokenBreakdown.reasoning,t[163]=it):it=t[163];let $e;t[164]!==ze||t[165]!==it?($e=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ze,it]}),t[164]=ze,t[165]=it,t[166]=$e):$e=t[166];let J;t[167]!==me||t[168]!==K.breakdownTotal?(J=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:me.map(ot=>ot.value<=0||K.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${ot.value/K.breakdownTotal*100}%`,backgroundColor:ot.color}},ot.key))}),t[167]=me,t[168]=K.breakdownTotal,t[169]=J):J=t[169];let re;t[170]!==me||t[171]!==K.breakdownTotal?(re=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:me.map(ot=>{const Ee=K.breakdownTotal>0?ot.value/K.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:ot.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[ot.label," ",s.jsxs("span",{className:"tabular-nums",children:[Ee.toFixed(0),"%"]})]})]},ot.key)})}),t[170]=me,t[171]=K.breakdownTotal,t[172]=re):re=t[172];let Pe;t[173]!==J||t[174]!==re?(Pe=s.jsxs("div",{className:"mb-6",children:[J,re]}),t[173]=J,t[174]=re,t[175]=Pe):Pe=t[175];let _e;t[176]!==e?(_e=e("contextSidebar.section.rawMessages"),t[176]=e,t[177]=_e):_e=t[177];let Ve;t[178]!==_e?(Ve=s.jsx("div",{className:"typography-micro text-muted-foreground",children:_e}),t[178]=_e,t[179]=Ve):Ve=t[179];let Ze;if(t[180]!==l||t[181]!==i||t[182]!==p||t[183]!==e||t[184]!==n){let ot;t[186]!==l||t[187]!==i||t[188]!==e||t[189]!==n?(ot=Ee=>{const xe=Qr(Ee.info).role,mt=xe==="assistant",Tt=xe==="user",Xe=i[Ee.info.id]===!0,nt=l===Ee.info.id,St=Ee.info.time?.created??null,yt=Ry(Ee.parts),It=mt?fi({info:Ee.info,parts:Ee.parts}):null,kt=Tt?My(Ee.parts):"",Et=By(St,n),Bt=yt||"—",zt=It?Oy(It.input,It.output,Vn):"",Gt=xe||"unknown",rs=yt?`${Gt}: ${yt}`:Gt,_t=Xe?JSON.stringify({info:Ee.info,parts:Ee.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":Xe,onClick:()=>{o(Wt=>({...Wt,[Ee.info.id]:Wt[Ee.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:mt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Tt?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",kt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:mt?Bt:rs}),mt&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:zt})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Et})]})}),Xe&&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:Wt=>{Wt.stopPropagation(),y(Ee.info.id,_t)},"aria-label":e(nt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(nt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:nt?s.jsx(E,{name:"check",className:"size-3.5"}):s.jsx(E,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Jm,{language:"json",code:_t,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Ee.info.id)},t[186]=l,t[187]=i,t[188]=e,t[189]=n,t[190]=ot):ot=t[190],Ze=[...p].reverse().map(ot),t[180]=l,t[181]=i,t[182]=p,t[183]=e,t[184]=n,t[185]=Ze}else Ze=t[185];let lt;t[191]!==Ze?(lt=s.jsx("div",{className:"mt-2.5 space-y-1",children:Ze}),t[191]=Ze,t[192]=lt):lt=t[192];let rt;t[193]!==Ve||t[194]!==lt?(rt=s.jsxs("div",{children:[Ve,lt]}),t[193]=Ve,t[194]=lt,t[195]=rt):rt=t[195];let Ge;return t[196]!==be||t[197]!==ke||t[198]!==jt||t[199]!==$e||t[200]!==Pe||t[201]!==rt?(Ge=s.jsx(cn,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[be,ke,jt,$e,Pe,rt]})}),t[196]=be,t[197]=ke,t[198]=jt,t[199]=$e,t[200]=Pe,t[201]=rt,t[202]=Ge):Ge=t[202],Ge};function Ky(t){return t.timeFormatPreference}function Hy(t){return t.currentSessionId}function Gy(t){return t.currentSessionDirectory}function qy(t){return t.providers}function Qy(t){return Object.keys(t).length>0?{}:t}function Yy(t){return Qr(t.info).role==="assistant"}function Xy(t){return Qr(t.info).isUser}function Jy(t,e){const n=En(e.info.cost);return t+n}function Zy(t){return Qr(t.info).isUser&&typeof t.info.system=="string"}function e1(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 t1(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)}%`:Vn(t.value):"—"})]},t.label)}const Uu=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),s1=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return Uu.has(n.toLowerCase())},ln="about:blank",hr=t=>{const e=t.trim();if(!e)return ln;const n=e.includes("://")?e:`${s1(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?ln:r.toString()}catch{return ln}},yr=t=>{try{return Uu.has(new URL(t).hostname.toLowerCase())}catch{return!1}},$a=t=>{if(!t||t===ln)return"";try{return new URL(t).host||t}catch{return t}},n1=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),r1=(t,e)=>n1.has(t)&&yr(e),o1=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"},i1=async t=>{try{const e=await ds("/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(o1)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},a1=async t=>{try{const e=await ds("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const 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}},l1=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}},c1=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=l1(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)},Xi="__aiworkerBrowserAnnotationActive",d1=`(() => {
|
|
46
|
+
try {
|
|
47
|
+
var host = document.querySelector('[data-openchamber-annotation]');
|
|
48
|
+
if (host && host.parentNode) host.parentNode.removeChild(host);
|
|
49
|
+
} catch (error) { /* page navigated away */ }
|
|
50
|
+
try {
|
|
51
|
+
var cursor = document.getElementById('openchamber-annotation-cursor');
|
|
52
|
+
if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
|
|
53
|
+
} catch (error) { /* page navigated away */ }
|
|
54
|
+
try { delete window['${Xi}']; } catch (error) { /* non-configurable */ }
|
|
55
|
+
})();`,u1=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
|
|
56
|
+
var CONFIG = ${n};
|
|
57
|
+
var THEME = CONFIG.theme;
|
|
58
|
+
var LABELS = CONFIG.labels;
|
|
59
|
+
var OVERLAY_ATTR = 'data-openchamber-annotation';
|
|
60
|
+
var Z_OVERLAY = 2147483646;
|
|
61
|
+
var MAX_TEXT = 400;
|
|
62
|
+
var MIN_RECT = 3;
|
|
63
|
+
var EDITOR_GAP = 10;
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
|
|
67
|
+
if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
|
|
68
|
+
} catch (error) { /* nothing to clean */ }
|
|
69
|
+
|
|
70
|
+
window['${Xi}'] = true;
|
|
71
|
+
|
|
72
|
+
var counter = 0;
|
|
73
|
+
var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
|
|
74
|
+
|
|
75
|
+
var selected = null;
|
|
76
|
+
var regions = [];
|
|
77
|
+
var strokes = [];
|
|
78
|
+
var tool = 'select';
|
|
79
|
+
var settled = false;
|
|
80
|
+
|
|
81
|
+
// ---------------------------------------------------------------- geometry
|
|
82
|
+
|
|
83
|
+
var rectFrom = function (domRect) {
|
|
84
|
+
return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
|
|
85
|
+
};
|
|
86
|
+
var normalizeRect = function (ax, ay, bx, by) {
|
|
87
|
+
return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
|
|
88
|
+
};
|
|
89
|
+
var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
|
|
90
|
+
|
|
91
|
+
// ------------------------------------------------------------- description
|
|
92
|
+
|
|
93
|
+
var isOverlayNode = function (element) {
|
|
94
|
+
var node = element;
|
|
95
|
+
while (node) {
|
|
96
|
+
if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
|
|
97
|
+
node = node.parentNode || (node.host || null);
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
var elementFromPoint = function (x, y) {
|
|
103
|
+
var found = document.elementFromPoint(x, y);
|
|
104
|
+
if (!found || isOverlayNode(found)) return null;
|
|
105
|
+
return found;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
var selectorPart = function (element) {
|
|
109
|
+
var part = element.tagName.toLowerCase();
|
|
110
|
+
if (element.id) return part + '#' + element.id;
|
|
111
|
+
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
112
|
+
if (className) {
|
|
113
|
+
var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
|
|
114
|
+
if (first) part += '.' + first;
|
|
115
|
+
}
|
|
116
|
+
return part;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
var buildSelector = function (element) {
|
|
120
|
+
if (element.id) return '#' + element.id;
|
|
121
|
+
var parts = [];
|
|
122
|
+
var node = element;
|
|
123
|
+
var depth = 0;
|
|
124
|
+
while (node && node.nodeType === 1 && depth < 5) {
|
|
125
|
+
var part = selectorPart(node);
|
|
126
|
+
var parent = node.parentElement;
|
|
127
|
+
if (parent) {
|
|
128
|
+
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
129
|
+
return child.tagName === node.tagName;
|
|
130
|
+
});
|
|
131
|
+
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
132
|
+
}
|
|
133
|
+
parts.unshift(part);
|
|
134
|
+
if (node.id) break;
|
|
135
|
+
node = parent;
|
|
136
|
+
depth += 1;
|
|
137
|
+
}
|
|
138
|
+
return parts.join(' > ');
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
|
|
142
|
+
var STYLE_PROPS = [
|
|
143
|
+
'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
|
|
144
|
+
'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
|
|
145
|
+
'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
var describe = function (element) {
|
|
149
|
+
var computed = window.getComputedStyle(element);
|
|
150
|
+
var attributes = {};
|
|
151
|
+
for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
|
|
152
|
+
var name = INTERESTING_ATTRS[i];
|
|
153
|
+
var value = element.getAttribute(name);
|
|
154
|
+
if (value) attributes[name] = String(value).slice(0, 200);
|
|
155
|
+
}
|
|
156
|
+
var computedStyle = {};
|
|
157
|
+
for (var j = 0; j < STYLE_PROPS.length; j += 1) {
|
|
158
|
+
var prop = STYLE_PROPS[j];
|
|
159
|
+
computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
|
|
160
|
+
}
|
|
161
|
+
var ancestry = [];
|
|
162
|
+
var node = element.parentElement;
|
|
163
|
+
var depth = 0;
|
|
164
|
+
while (node && node.nodeType === 1 && depth < 4) {
|
|
165
|
+
var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
|
|
166
|
+
if (node.id) entry.id = node.id;
|
|
167
|
+
var cls = typeof node.className === 'string' ? node.className.trim() : '';
|
|
168
|
+
if (cls) entry.className = cls.slice(0, 200);
|
|
169
|
+
ancestry.unshift(entry);
|
|
170
|
+
node = node.parentElement;
|
|
171
|
+
depth += 1;
|
|
172
|
+
}
|
|
173
|
+
var box = element.getBoundingClientRect();
|
|
174
|
+
var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
|
|
175
|
+
return {
|
|
176
|
+
tag: element.tagName.toLowerCase(),
|
|
177
|
+
text: text.slice(0, MAX_TEXT),
|
|
178
|
+
selector: buildSelector(element),
|
|
179
|
+
path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
|
|
180
|
+
bounds: rectFrom(box),
|
|
181
|
+
center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
|
|
182
|
+
attributes: attributes,
|
|
183
|
+
computedStyle: computedStyle,
|
|
184
|
+
ancestry: ancestry
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// ------------------------------------------------------------------ chrome
|
|
189
|
+
|
|
190
|
+
var host = document.createElement('div');
|
|
191
|
+
host.setAttribute(OVERLAY_ATTR, '');
|
|
192
|
+
host.style.cssText = 'position:fixed;inset:0;z-index:' + Z_OVERLAY + ';pointer-events:none';
|
|
193
|
+
var shadow = host.attachShadow({ mode: 'closed' });
|
|
194
|
+
|
|
195
|
+
var style = document.createElement('style');
|
|
196
|
+
style.textContent = [
|
|
197
|
+
':host{all:initial}',
|
|
198
|
+
'*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
|
|
199
|
+
'.layer{position:fixed;inset:0;pointer-events:none}',
|
|
200
|
+
'.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
|
|
201
|
+
'.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}',
|
|
202
|
+
'.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}',
|
|
203
|
+
'.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}',
|
|
204
|
+
'.tools button:hover{background:' + THEME.primaryFaint + '}',
|
|
205
|
+
'.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
|
|
206
|
+
'.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}',
|
|
207
|
+
'.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}',
|
|
208
|
+
'.editor textarea::placeholder{color:' + THEME.mutedText + '}',
|
|
209
|
+
'.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}',
|
|
210
|
+
'.editor button svg{width:16px;height:16px;display:block}',
|
|
211
|
+
'.editor button[disabled]{opacity:.5;cursor:default}'
|
|
212
|
+
].join('');
|
|
213
|
+
shadow.appendChild(style);
|
|
214
|
+
|
|
215
|
+
var cursorStyle = document.createElement('style');
|
|
216
|
+
cursorStyle.id = 'openchamber-annotation-cursor';
|
|
217
|
+
document.head.appendChild(cursorStyle);
|
|
218
|
+
var setCursor = function (value) {
|
|
219
|
+
cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
var svgNS = 'http://www.w3.org/2000/svg';
|
|
223
|
+
var svg = document.createElementNS(svgNS, 'svg');
|
|
224
|
+
svg.setAttribute('class', 'layer');
|
|
225
|
+
svg.style.overflow = 'visible';
|
|
226
|
+
shadow.appendChild(svg);
|
|
227
|
+
|
|
228
|
+
var hoverBox = document.createElement('div');
|
|
229
|
+
hoverBox.className = 'box';
|
|
230
|
+
var hoverLabel = document.createElement('div');
|
|
231
|
+
hoverLabel.className = 'label';
|
|
232
|
+
var marqueeBox = document.createElement('div');
|
|
233
|
+
marqueeBox.className = 'box';
|
|
234
|
+
shadow.append(hoverBox, hoverLabel, marqueeBox);
|
|
235
|
+
|
|
236
|
+
var positionBox = function (node, rect) {
|
|
237
|
+
node.style.display = 'block';
|
|
238
|
+
node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
|
|
239
|
+
node.style.width = rect.width + 'px';
|
|
240
|
+
node.style.height = rect.height + 'px';
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
var tools = document.createElement('div');
|
|
244
|
+
tools.className = 'tools';
|
|
245
|
+
shadow.appendChild(tools);
|
|
246
|
+
|
|
247
|
+
var toolButtons = {};
|
|
248
|
+
[['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
|
|
249
|
+
var button = document.createElement('button');
|
|
250
|
+
button.type = 'button';
|
|
251
|
+
button.textContent = entry[1];
|
|
252
|
+
button.addEventListener('click', function () { setTool(entry[0]); });
|
|
253
|
+
toolButtons[entry[0]] = button;
|
|
254
|
+
tools.appendChild(button);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
var editor = document.createElement('div');
|
|
258
|
+
editor.className = 'editor';
|
|
259
|
+
shadow.appendChild(editor);
|
|
260
|
+
|
|
261
|
+
var comment = document.createElement('textarea');
|
|
262
|
+
comment.rows = 1;
|
|
263
|
+
comment.placeholder = LABELS.commentPlaceholder;
|
|
264
|
+
var submit = document.createElement('button');
|
|
265
|
+
submit.type = 'button';
|
|
266
|
+
// Icon-only attach button (Remix attachment-2), matching the chat comment
|
|
267
|
+
// input; the localized label stays available to assistive tech.
|
|
268
|
+
submit.setAttribute('aria-label', LABELS.submit);
|
|
269
|
+
submit.title = LABELS.submit;
|
|
270
|
+
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>';
|
|
271
|
+
editor.append(comment, submit);
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Grows the box with its content.
|
|
275
|
+
*
|
|
276
|
+
* A hidden element reports scrollHeight 0, so measuring one collapses the
|
|
277
|
+
* field to nothing — which is what left a sliver of a click target and an
|
|
278
|
+
* invisible caret. Measuring only while visible, and never below the CSS
|
|
279
|
+
* min-height, keeps it usable.
|
|
280
|
+
*/
|
|
281
|
+
var resizeComment = function () {
|
|
282
|
+
if (editor.style.display === 'none') return;
|
|
283
|
+
comment.style.height = 'auto';
|
|
284
|
+
comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
|
|
285
|
+
};
|
|
286
|
+
comment.addEventListener('input', resizeComment);
|
|
287
|
+
|
|
288
|
+
// -------------------------------------------------------------- selection
|
|
289
|
+
|
|
290
|
+
var lastTargetRect = null;
|
|
291
|
+
|
|
292
|
+
/** Places the comment box under whatever was just marked, kept on screen. */
|
|
293
|
+
var positionEditor = function () {
|
|
294
|
+
if (!lastTargetRect) {
|
|
295
|
+
editor.style.display = 'none';
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
var wasHidden = editor.style.display === 'none';
|
|
299
|
+
editor.style.display = 'flex';
|
|
300
|
+
// Measured now that it is laid out, not while it was still hidden.
|
|
301
|
+
if (wasHidden) resizeComment();
|
|
302
|
+
var box = editor.getBoundingClientRect();
|
|
303
|
+
var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
|
|
304
|
+
var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
|
|
305
|
+
// Above the target when there is no room below, so the box is never left
|
|
306
|
+
// half off the bottom of the page.
|
|
307
|
+
if (top + box.height > window.innerHeight - 8) {
|
|
308
|
+
top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
|
|
309
|
+
}
|
|
310
|
+
left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
|
|
311
|
+
editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
/** Focus after layout: focusing a zero-height field puts the caret nowhere. */
|
|
315
|
+
var focusComment = function () {
|
|
316
|
+
requestAnimationFrame(function () {
|
|
317
|
+
try {
|
|
318
|
+
comment.focus({ preventScroll: true });
|
|
319
|
+
comment.setSelectionRange(comment.value.length, comment.value.length);
|
|
320
|
+
} catch (error) { /* field went away */ }
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
var hasTargets = function () {
|
|
325
|
+
return Boolean(selected) || regions.length > 0 || strokes.length > 0;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
var syncChrome = function () {
|
|
329
|
+
submit.disabled = !hasTargets();
|
|
330
|
+
if (!hasTargets()) {
|
|
331
|
+
lastTargetRect = null;
|
|
332
|
+
editor.style.display = 'none';
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
positionEditor();
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
var syncSelectionVisuals = function () {
|
|
339
|
+
if (!selected) return;
|
|
340
|
+
var rect = rectFrom(selected.element.getBoundingClientRect());
|
|
341
|
+
if (!usableRect(rect)) {
|
|
342
|
+
selected.outline.style.display = 'none';
|
|
343
|
+
selected.badge.style.display = 'none';
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
positionBox(selected.outline, rect);
|
|
347
|
+
selected.badge.style.display = 'block';
|
|
348
|
+
selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
349
|
+
lastTargetRect = rect;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
var dropSelection = function () {
|
|
353
|
+
if (!selected) return;
|
|
354
|
+
selected.outline.remove();
|
|
355
|
+
selected.badge.remove();
|
|
356
|
+
selected = null;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
var selectElement = function (element) {
|
|
360
|
+
var wasSelected = selected && selected.element === element;
|
|
361
|
+
dropSelection();
|
|
362
|
+
if (wasSelected) {
|
|
363
|
+
// Clicking the chosen element again clears it, so a misclick costs one
|
|
364
|
+
// click rather than starting over.
|
|
365
|
+
lastTargetRect = null;
|
|
366
|
+
syncChrome();
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
var outline = document.createElement('div');
|
|
370
|
+
outline.className = 'box';
|
|
371
|
+
var badge = document.createElement('div');
|
|
372
|
+
badge.className = 'label';
|
|
373
|
+
badge.textContent = selectorPart(element);
|
|
374
|
+
shadow.append(outline, badge);
|
|
375
|
+
selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
|
|
376
|
+
syncSelectionVisuals();
|
|
377
|
+
syncChrome();
|
|
378
|
+
focusComment();
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
var setTool = function (next) {
|
|
382
|
+
tool = next;
|
|
383
|
+
hoverBox.style.display = 'none';
|
|
384
|
+
hoverLabel.style.display = 'none';
|
|
385
|
+
marqueeBox.style.display = 'none';
|
|
386
|
+
setCursor(next === 'select' ? '' : 'crosshair');
|
|
387
|
+
for (var key in toolButtons) {
|
|
388
|
+
if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
|
|
389
|
+
toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
// ------------------------------------------------------------- interaction
|
|
395
|
+
|
|
396
|
+
var drag = null;
|
|
397
|
+
|
|
398
|
+
var onPointerMove = function (event) {
|
|
399
|
+
if (drag) {
|
|
400
|
+
if (drag.kind === 'marquee') {
|
|
401
|
+
drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
|
|
402
|
+
positionBox(marqueeBox, drag.rect);
|
|
403
|
+
} else if (drag.kind === 'draw') {
|
|
404
|
+
drag.points.push({ x: event.clientX, y: event.clientY });
|
|
405
|
+
drag.path.setAttribute('d', drag.points.map(function (point, index) {
|
|
406
|
+
return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
|
|
407
|
+
}).join(' '));
|
|
408
|
+
}
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (tool !== 'select') return;
|
|
413
|
+
var element = elementFromPoint(event.clientX, event.clientY);
|
|
414
|
+
if (!element) {
|
|
415
|
+
hoverBox.style.display = 'none';
|
|
416
|
+
hoverLabel.style.display = 'none';
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
var rect = rectFrom(element.getBoundingClientRect());
|
|
420
|
+
positionBox(hoverBox, rect);
|
|
421
|
+
hoverLabel.textContent = selectorPart(element);
|
|
422
|
+
hoverLabel.style.display = 'block';
|
|
423
|
+
hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
var onPointerDown = function (event) {
|
|
427
|
+
if (event.button !== 0) return;
|
|
428
|
+
if (isOverlayNode(event.target)) return;
|
|
429
|
+
event.preventDefault();
|
|
430
|
+
event.stopPropagation();
|
|
431
|
+
|
|
432
|
+
if (tool === 'select') {
|
|
433
|
+
var element = elementFromPoint(event.clientX, event.clientY);
|
|
434
|
+
if (element) selectElement(element);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (tool === 'marquee') {
|
|
439
|
+
drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
var path = document.createElementNS(svgNS, 'path');
|
|
444
|
+
path.setAttribute('fill', 'none');
|
|
445
|
+
path.setAttribute('stroke', THEME.primary);
|
|
446
|
+
path.setAttribute('stroke-width', '2.5');
|
|
447
|
+
path.setAttribute('stroke-linecap', 'round');
|
|
448
|
+
path.setAttribute('stroke-linejoin', 'round');
|
|
449
|
+
svg.appendChild(path);
|
|
450
|
+
drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
var onPointerUp = function () {
|
|
454
|
+
if (!drag) return;
|
|
455
|
+
var finished = drag;
|
|
456
|
+
drag = null;
|
|
457
|
+
|
|
458
|
+
if (finished.kind === 'marquee') {
|
|
459
|
+
marqueeBox.style.display = 'none';
|
|
460
|
+
var rect = finished.rect;
|
|
461
|
+
if (!rect || !usableRect(rect)) return;
|
|
462
|
+
// A region marks an area, not the elements inside it: expanding it into a
|
|
463
|
+
// selection made the result depend on the page's markup rather than on
|
|
464
|
+
// what was drawn.
|
|
465
|
+
regions.push({ id: nextId('region'), rect: rect });
|
|
466
|
+
var outline = document.createElementNS(svgNS, 'rect');
|
|
467
|
+
outline.setAttribute('x', String(rect.x));
|
|
468
|
+
outline.setAttribute('y', String(rect.y));
|
|
469
|
+
outline.setAttribute('width', String(rect.width));
|
|
470
|
+
outline.setAttribute('height', String(rect.height));
|
|
471
|
+
outline.style.fill = THEME.primarySoft;
|
|
472
|
+
outline.setAttribute('stroke', THEME.primary);
|
|
473
|
+
outline.setAttribute('stroke-width', '1.5');
|
|
474
|
+
outline.setAttribute('rx', '2');
|
|
475
|
+
svg.appendChild(outline);
|
|
476
|
+
lastTargetRect = rect;
|
|
477
|
+
syncChrome();
|
|
478
|
+
focusComment();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
var points = finished.points;
|
|
483
|
+
if (points.length < 2) {
|
|
484
|
+
if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
|
|
488
|
+
for (var p = 1; p < points.length; p += 1) {
|
|
489
|
+
minX = Math.min(minX, points[p].x);
|
|
490
|
+
minY = Math.min(minY, points[p].y);
|
|
491
|
+
maxX = Math.max(maxX, points[p].x);
|
|
492
|
+
maxY = Math.max(maxY, points[p].y);
|
|
493
|
+
}
|
|
494
|
+
var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
495
|
+
strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
|
|
496
|
+
lastTargetRect = bounds;
|
|
497
|
+
syncChrome();
|
|
498
|
+
focusComment();
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Swallows the page's own mouse handling while annotating.
|
|
503
|
+
*
|
|
504
|
+
* Blocking pointerdown is not enough: a click still follows it, so marking a
|
|
505
|
+
* button pressed that button and marking a link navigated away from the page
|
|
506
|
+
* being annotated. These are the events that reach page code, so these are
|
|
507
|
+
* the ones that have to stop.
|
|
508
|
+
*/
|
|
509
|
+
var blockPageInteraction = function (event) {
|
|
510
|
+
if (isOverlayNode(event.target)) return;
|
|
511
|
+
event.preventDefault();
|
|
512
|
+
event.stopPropagation();
|
|
513
|
+
};
|
|
514
|
+
var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
|
|
515
|
+
|
|
516
|
+
var onScrollOrResize = function () {
|
|
517
|
+
syncSelectionVisuals();
|
|
518
|
+
positionEditor();
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
var onKeyDown = function (event) {
|
|
522
|
+
if (event.isComposing || event.keyCode === 229) return;
|
|
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
|
+
// WebKit can report the composition-confirming Enter as keyCode 229.
|
|
534
|
+
if (event.isComposing || event.keyCode === 229) return;
|
|
535
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
536
|
+
event.preventDefault();
|
|
537
|
+
attach();
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
document.addEventListener('pointermove', onPointerMove, true);
|
|
542
|
+
document.addEventListener('pointerdown', onPointerDown, true);
|
|
543
|
+
document.addEventListener('pointerup', onPointerUp, true);
|
|
544
|
+
BLOCKED_EVENTS.forEach(function (name) {
|
|
545
|
+
window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
|
|
546
|
+
});
|
|
547
|
+
window.addEventListener('scroll', onScrollOrResize, true);
|
|
548
|
+
window.addEventListener('resize', onScrollOrResize, true);
|
|
549
|
+
window.addEventListener('keydown', onKeyDown, true);
|
|
550
|
+
comment.addEventListener('keydown', onCommentKeyDown);
|
|
551
|
+
|
|
552
|
+
// ------------------------------------------------------------------ finish
|
|
553
|
+
|
|
554
|
+
var teardown = function () {
|
|
555
|
+
document.removeEventListener('pointermove', onPointerMove, true);
|
|
556
|
+
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
557
|
+
document.removeEventListener('pointerup', onPointerUp, true);
|
|
558
|
+
BLOCKED_EVENTS.forEach(function (name) {
|
|
559
|
+
window.removeEventListener(name, blockPageInteraction, true);
|
|
560
|
+
});
|
|
561
|
+
window.removeEventListener('scroll', onScrollOrResize, true);
|
|
562
|
+
window.removeEventListener('resize', onScrollOrResize, true);
|
|
563
|
+
window.removeEventListener('keydown', onKeyDown, true);
|
|
564
|
+
comment.removeEventListener('keydown', onCommentKeyDown);
|
|
565
|
+
setCursor('');
|
|
566
|
+
if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
|
|
567
|
+
if (host.parentNode) host.parentNode.removeChild(host);
|
|
568
|
+
try { delete window['${Xi}']; } catch (error) { /* non-configurable */ }
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
var finish = function (payload) {
|
|
572
|
+
if (settled) return;
|
|
573
|
+
settled = true;
|
|
574
|
+
teardown();
|
|
575
|
+
// Removing the chrome is not enough: the host screenshots this page right
|
|
576
|
+
// after we resolve, and the compositor can still hold a frame containing
|
|
577
|
+
// our outlines. Yield two frames so the page has actually repainted.
|
|
578
|
+
requestAnimationFrame(function () {
|
|
579
|
+
requestAnimationFrame(function () { resolve(payload); });
|
|
580
|
+
});
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
var attach = function () {
|
|
584
|
+
if (!hasTargets()) return;
|
|
585
|
+
finish({
|
|
586
|
+
id: 'annotation-' + Date.now(),
|
|
587
|
+
pageUrl: String(location.href),
|
|
588
|
+
pageTitle: String(document.title || ''),
|
|
589
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
590
|
+
devicePixelRatio: window.devicePixelRatio || 1,
|
|
591
|
+
comment: comment.value,
|
|
592
|
+
// Zero or one element, never more. Kept as a list so elements, regions
|
|
593
|
+
// and strokes stay one uniform shape for everything downstream.
|
|
594
|
+
elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
|
|
595
|
+
regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
|
|
596
|
+
strokes: strokes.map(function (entry) {
|
|
597
|
+
return { id: entry.id, points: entry.points, bounds: entry.bounds };
|
|
598
|
+
})
|
|
599
|
+
});
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
submit.addEventListener('click', attach);
|
|
603
|
+
|
|
604
|
+
(document.body || document.documentElement).appendChild(host);
|
|
605
|
+
setTool('select');
|
|
606
|
+
syncChrome();
|
|
607
|
+
});`},f1={kind:"idle"},wn=t=>typeof t=="object"&&t!==null,kn=t=>typeof t=="number"&&Number.isFinite(t),Xl=t=>wn(t)&&Object.values(t).every(e=>typeof e=="string"),Wa=t=>wn(t)&&kn(t.x)&&kn(t.y)&&kn(t.width)&&kn(t.height),Ku=t=>wn(t)&&kn(t.x)&&kn(t.y),m1=t=>wn(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"),h1=t=>wn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&Wa(t.bounds)&&Ku(t.center)&&Xl(t.attributes)&&Xl(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(m1),p1=t=>wn(t)&&typeof t.id=="string"&&h1(t.element),g1=t=>wn(t)&&typeof t.id=="string"&&Wa(t.rect),x1=t=>wn(t)&&typeof t.id=="string"&&Wa(t.bounds)&&Array.isArray(t.points)&&t.points.every(Ku),b1=t=>wn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&wn(t.viewport)&&kn(t.viewport.width)&&kn(t.viewport.height)&&kn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(p1)&&Array.isArray(t.regions)&&t.regions.every(g1)&&Array.isArray(t.strokes)&&t.strokes.every(x1),y1=1600,w1=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}),S1=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:u})=>{if(!t)return null;try{const d=await w1(`data:${e};base64,${t}`),h=Math.max(1,d.naturalWidth||n),f=Math.max(1,d.naturalHeight||r),p=h/Math.max(1,i||h),g=f/Math.max(1,o||f),w=Math.min(1,y1/h),S=document.createElement("canvas");S.width=Math.max(1,Math.floor(h*w)),S.height=Math.max(1,Math.floor(f*w));const x=S.getContext("2d");if(!x)return null;x.scale(w,w),x.drawImage(d,0,0,h,f);const m=N=>({x:N.x*p,y:N.y*g,width:N.width*p,height:N.height*g}),b=Math.max(2,2.5*p/Math.max(w,.2));x.strokeStyle=a,x.fillStyle=u;const y=N=>{const C=m(N);x.lineWidth=b,x.fillRect(C.x,C.y,C.width,C.height),x.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||(x.beginPath(),N.points.forEach((C,k)=>{const D=C.x*p,P=C.y*g;k===0?x.moveTo(D,P):x.lineTo(D,P)}),x.lineCap="round",x.lineJoin="round",x.lineWidth=b*1.4,x.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}},v1="({ width: window.innerWidth, height: window.innerHeight })",j1=async t=>{try{const e=await t.executeJavaScript(v1,!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}},bo=async t=>{try{await t.executeJavaScript(d1,!1)}catch{}},k1=async({host:t,theme:e,labels:n})=>{const r=u1(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!b1(i))return await bo(t),null;const o=i;try{const l=await j1(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const u=await S1({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:u}}catch{return{payload:o,screenshot:null}}},on={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)"},C1=()=>{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()}},N1=t=>{const e=C1();if(!e)return{...on,colorScheme:t};try{const n=(a,u)=>e.read(`var(${a})`)||u,r=(a,u,d)=>e.read(`color-mix(in srgb, var(${a}) ${u}%, transparent)`)||d,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)`)||on.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",on.primary),primarySoft:r("--primary",16,on.primarySoft),primaryFaint:r("--primary",10,on.primaryFaint),primaryContrast:n("--primary-foreground",on.primaryContrast),surface:n("--surface-background",on.surface),surfaceElevated:n("--surface-elevated",on.surfaceElevated),border:n("--border",on.border),text:n("--foreground",on.text),mutedText:n("--muted-foreground",on.mutedText)}}catch{return{...on,colorScheme:t}}finally{e.dispose()}},A1=2e3,D1=50;let Qn=null,pr=null,Br=null;const P1=async t=>{try{const e=await ds("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===!0:!1}catch{return!1}},rr=async(t,e)=>{try{const n=await ds("/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)}},I1=async(t=A1)=>{const e=Date.now()+t;for(;!Qn&&Date.now()<e;)await new Promise(n=>setTimeout(n,D1));return Qn},T1=async t=>{const e=t.action==="browser.open",n=Qn;if(!(!n&&!(e&&pr))&&await P1(t.requestId))try{if(e&&!n){const i=typeof t.parameters.url=="string"?t.parameters.url:"";if(!i){await rr(t.requestId,{ok:!1,error:"url is required"});return}pr?.(i);const o=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!o||o==="fill"){await rr(t.requestId,{ok:!0,data:{url:i,opened:!0}});return}const l=await I1();if(!l){await rr(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}),u=a&&typeof a=="object"?a.viewport??null:null;await rr(t.requestId,{ok:!0,data:{url:i,opened:!0,viewportApplied:!0,viewport:u}});return}const r=await n.run(t.action,t.parameters);await rr(t.requestId,{ok:!0,data:r})}catch(r){await rr(t.requestId,{ok:!1,error:r instanceof Error?r.message:String(r)})}},Hu=()=>{Br||(Br=Yr(t=>{t.type==="browser-control-request"&&T1({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Gu=()=>{Qn||pr||!Br||(Br(),Br=null)},R1=t=>(Qn=t,Hu(),()=>{Qn===t&&(Qn=null),Gu()}),E1=t=>(pr=t,Hu(),()=>{pr===t&&(pr=null),Gu()}),M1=50,O1=6,F1=2048,B1=200,qu=t=>{const e=hr(String(t??"").trim());if(!e||e.length>F1)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},_1=(t,e)=>{const n=qu(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,B1)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,M1)},L1=(t,e)=>{const n=qu(e);return t.filter(r=>r.url!==n)},$1=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Qu=(t,e,n=O1)=>{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=$1(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},Jl=20,yo=t=>{const e=vt((t||"").trim());return e?JSON.stringify([us(),e]):""},W1=t=>{const e=Object.keys(t);if(e.length<=Jl)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,Jl);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},gr=tr()(Yg(t=>({byProject:{},recordVisit:(e,n)=>{const r=yo(e);r&&t(i=>{const o=i.byProject[r]??[],l=_1(o,{...n,at:Date.now()});return l===o?i:{byProject:W1({...i.byProject,[r]:l})}})},forget:(e,n)=>{const r=yo(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:L1(o,n)}}:i})},clear:e=>{const n=yo(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:nm(),partialize:t=>({byProject:t.byProject})})),z1=[],Yu=t=>e=>{const n=yo(t);return(n?e.byProject[n]:void 0)??z1},Ji=new Map,Zo=new Map,Yn=new Map,Xn=new Set,V1=async(t,e)=>{if(!qa()){Xn.delete(t),ir(t,{type:"close"});return}if(await rm(Nn()),!Xn.has(t)||!qa())return;const n=ud().websocket(`/api/dev-tunnel?port=${e}`),r=om(n);Yn.set(t,r),r.binaryType="arraybuffer",r.onopen=()=>ir(t,{type:"ready"}),r.onmessage=i=>ir(t,{type:"data",data:i.data instanceof ArrayBuffer?i.data:new TextEncoder().encode(i.data)}),r.onerror=()=>ir(t,{type:"close"}),r.onclose=()=>{Xn.delete(t),Yn.delete(t),ir(t,{type:"close"})}};Zm(({connectionId:t,remotePort:e,message:n})=>{switch(n.type){case"data":{const r=Yn.get(t);r&&n.data&&r.send(n.data);return}case"close":Xn.delete(t),Yn.get(t)?.close(),Yn.delete(t);return;case"connect":Xn.add(t),V1(t,e).catch(()=>{Xn.delete(t),ir(t,{type:"close"})})}});const Xu=()=>typeof window<"u"&&!!window.__AIWORKER_ELECTRON__,Ju=t=>{if(!t)return!1;try{const e=new URL(t,typeof window<"u"?window.location.href:void 0),n=typeof window<"u"?window.__AIWORKER_LOCAL_ORIGIN__:"";return n&&e.origin===n?!1:!yr(e.toString())}catch{return!1}},Zu=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}},Zl=(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}},ec=(t,e)=>{try{Zo.set(e,new URL(t).origin)}catch{}};class _r extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const tc=async t=>{if(!t||!Xu()||!yr(t))return t;const e=Nn();if(!Ju(e))return t;const n=Zu(t);if(!n)return t;const r=`${e}|${n}`,i=Ji.get(r);if(i)return ec(t,i),Zl(t,i);try{const o=await fr("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:im(),targetKey:us(),clientToken:$r(),requestHeaders:fd()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new _r(t);return Ji.set(r,o.localPort),ec(t,o.localPort),Zl(t,o.localPort)}catch(o){throw o instanceof _r?o:new _r(t)}},sc=t=>{if(!t||!Xu()||!yr(t)||!Ju(Nn()))return!1;const e=Zu(t);return e>0&&!Zo.has(e)},Ar=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!=="127.0.0.1")return t;const n=Zo.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},U1=()=>{Ji.clear(),Zo.clear(),Xn.clear();for(const t of Yn.values())t.close();Yn.clear(),fr("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&ma(U1);const nc=6e3,K1=120,H1=80,G1=`
|
|
608
|
+
var MAX_ELEMENTS = ${K1};
|
|
609
|
+
var MAX_LABEL_CHARS = ${H1};
|
|
610
|
+
var visible = function (element) {
|
|
611
|
+
var rect = element.getBoundingClientRect();
|
|
612
|
+
if (rect.width < 1 || rect.height < 1) return false;
|
|
613
|
+
var style = window.getComputedStyle(element);
|
|
614
|
+
return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
|
|
615
|
+
};
|
|
616
|
+
var label = function (element) {
|
|
617
|
+
var aria = element.getAttribute('aria-label');
|
|
618
|
+
if (aria) return aria.trim();
|
|
619
|
+
var value = element.getAttribute('value');
|
|
620
|
+
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
621
|
+
if (text) return text.slice(0, MAX_LABEL_CHARS);
|
|
622
|
+
if (value) return String(value).slice(0, MAX_LABEL_CHARS);
|
|
623
|
+
var placeholder = element.getAttribute('placeholder');
|
|
624
|
+
return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
|
|
625
|
+
};
|
|
626
|
+
var isUnique = function (selector) {
|
|
627
|
+
try {
|
|
628
|
+
return document.querySelectorAll(selector).length === 1;
|
|
629
|
+
} catch (error) {
|
|
630
|
+
return false;
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Names an element by what it is, falling back to where it sits.
|
|
636
|
+
*
|
|
637
|
+
* A positional chain like 'main > section:nth-of-type(3) > div > a' survives
|
|
638
|
+
* only until the markup shifts, and says nothing about what it points at.
|
|
639
|
+
* Anything the page states about identity — an id, a test id, an accessible
|
|
640
|
+
* name — outlives edits and reads as the thing it selects. The chain remains
|
|
641
|
+
* as the last resort, because something always has to work.
|
|
642
|
+
*/
|
|
643
|
+
var cssPath = function (element) {
|
|
644
|
+
var tag = element.tagName.toLowerCase();
|
|
645
|
+
|
|
646
|
+
if (element.id) {
|
|
647
|
+
var byId = '#' + CSS.escape(element.id);
|
|
648
|
+
if (isUnique(byId)) return byId;
|
|
649
|
+
}
|
|
650
|
+
var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
|
|
651
|
+
for (var a = 0; a < stableAttrs.length; a += 1) {
|
|
652
|
+
var value = element.getAttribute(stableAttrs[a]);
|
|
653
|
+
if (!value) continue;
|
|
654
|
+
var raw = String(value);
|
|
655
|
+
// A value containing a quote would need escaping for no real gain: such
|
|
656
|
+
// attributes are rare, and the positional chain still covers them.
|
|
657
|
+
if (raw.indexOf('"') !== -1) continue;
|
|
658
|
+
var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
|
|
659
|
+
if (isUnique(byAttr)) return byAttr;
|
|
660
|
+
}
|
|
661
|
+
var className = typeof element.className === 'string' ? element.className.trim() : '';
|
|
662
|
+
if (className) {
|
|
663
|
+
var classes = className.split(/\\s+/).filter(Boolean);
|
|
664
|
+
for (var c = 0; c < classes.length; c += 1) {
|
|
665
|
+
var byClass = tag + '.' + CSS.escape(classes[c]);
|
|
666
|
+
if (isUnique(byClass)) return byClass;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
var parts = [];
|
|
671
|
+
var node = element;
|
|
672
|
+
var depth = 0;
|
|
673
|
+
while (node && node.nodeType === 1 && depth < 6) {
|
|
674
|
+
var part = node.tagName.toLowerCase();
|
|
675
|
+
var parent = node.parentElement;
|
|
676
|
+
if (!parent) { parts.unshift(part); break; }
|
|
677
|
+
var siblings = Array.prototype.filter.call(parent.children, function (child) {
|
|
678
|
+
return child.tagName === node.tagName;
|
|
679
|
+
});
|
|
680
|
+
if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
|
|
681
|
+
parts.unshift(part);
|
|
682
|
+
if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
|
|
683
|
+
node = parent;
|
|
684
|
+
depth += 1;
|
|
685
|
+
}
|
|
686
|
+
return parts.join(' > ');
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
/** What a screen reader would announce, or '' when there is nothing to say. */
|
|
690
|
+
var accessibleName = function (element) {
|
|
691
|
+
var aria = element.getAttribute('aria-label');
|
|
692
|
+
if (aria && aria.trim()) return aria.trim();
|
|
693
|
+
var labelled = element.getAttribute('aria-labelledby');
|
|
694
|
+
if (labelled) {
|
|
695
|
+
var source = document.getElementById(labelled.split(/\\s+/)[0]);
|
|
696
|
+
if (source && (source.innerText || '').trim()) return source.innerText.trim();
|
|
697
|
+
}
|
|
698
|
+
var title = element.getAttribute('title');
|
|
699
|
+
if (title && title.trim()) return title.trim();
|
|
700
|
+
var alt = element.getAttribute('alt');
|
|
701
|
+
if (alt && alt.trim()) return alt.trim();
|
|
702
|
+
var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
703
|
+
if (text) return text;
|
|
704
|
+
var value = element.getAttribute('value');
|
|
705
|
+
return value && String(value).trim() ? String(value).trim() : '';
|
|
706
|
+
};
|
|
707
|
+
var findByText = function (needle) {
|
|
708
|
+
var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
|
|
709
|
+
var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
|
|
710
|
+
var exact = null;
|
|
711
|
+
var partial = null;
|
|
712
|
+
for (var i = 0; i < candidates.length; i += 1) {
|
|
713
|
+
var element = candidates[i];
|
|
714
|
+
if (!visible(element)) continue;
|
|
715
|
+
var text = label(element).toLowerCase();
|
|
716
|
+
if (!text) continue;
|
|
717
|
+
if (text === wanted) { exact = element; break; }
|
|
718
|
+
if (!partial && text.indexOf(wanted) !== -1) partial = element;
|
|
719
|
+
}
|
|
720
|
+
return exact || partial;
|
|
721
|
+
};
|
|
722
|
+
`,Xr=t=>`(() => {
|
|
723
|
+
${G1}
|
|
724
|
+
${t}
|
|
725
|
+
})()`,q1=({selector:t}={})=>Xr(`
|
|
726
|
+
var scopeSelector = ${JSON.stringify(t??"")};
|
|
727
|
+
var root = document;
|
|
728
|
+
if (scopeSelector) {
|
|
729
|
+
try { root = document.querySelector(scopeSelector); }
|
|
730
|
+
catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
|
|
731
|
+
if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
|
|
732
|
+
}
|
|
733
|
+
var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
|
|
734
|
+
var elements = [];
|
|
735
|
+
var visibleTotal = 0;
|
|
736
|
+
for (var i = 0; i < interactive.length; i += 1) {
|
|
737
|
+
var element = interactive[i];
|
|
738
|
+
if (!visible(element)) continue;
|
|
739
|
+
visibleTotal += 1;
|
|
740
|
+
if (elements.length >= MAX_ELEMENTS) continue;
|
|
741
|
+
|
|
742
|
+
var rect = element.getBoundingClientRect();
|
|
743
|
+
// Empty and default-valued fields are left out rather than serialized as
|
|
744
|
+
// "" and false. Repeated across a hundred entries that overhead dwarfed
|
|
745
|
+
// the information it carried.
|
|
746
|
+
var entry = {
|
|
747
|
+
selector: cssPath(element),
|
|
748
|
+
tag: element.tagName.toLowerCase(),
|
|
749
|
+
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
750
|
+
};
|
|
751
|
+
// The list covers the whole document so anything can be clicked without
|
|
752
|
+
// scrolling to it first, which means bounds alone do not say what is on
|
|
753
|
+
// screen — a negative y reads as a bug otherwise.
|
|
754
|
+
if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
|
|
755
|
+
var type = element.getAttribute('type');
|
|
756
|
+
if (type) entry.type = type;
|
|
757
|
+
var role = element.getAttribute('role');
|
|
758
|
+
if (role) entry.role = role;
|
|
759
|
+
var labelText = label(element);
|
|
760
|
+
if (labelText) entry.label = labelText;
|
|
761
|
+
if (element.disabled === true) entry.disabled = true;
|
|
762
|
+
// Flagged rather than described: reporting the accessible name of every
|
|
763
|
+
// element would cost more than it tells, while its absence on something
|
|
764
|
+
// clickable is a defect worth naming.
|
|
765
|
+
if (!accessibleName(element)) entry.missingAccessibleName = true;
|
|
766
|
+
elements.push(entry);
|
|
767
|
+
}
|
|
768
|
+
var body = document.body ? (document.body.innerText || '') : '';
|
|
769
|
+
var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
|
|
770
|
+
var docEl = document.documentElement;
|
|
771
|
+
var result = {
|
|
772
|
+
ok: true,
|
|
773
|
+
url: String(location.href),
|
|
774
|
+
title: String(document.title || ''),
|
|
775
|
+
scope: scopeSelector || 'document',
|
|
776
|
+
scrollY: Math.round(window.scrollY),
|
|
777
|
+
maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
|
|
778
|
+
text: text.slice(0, ${nc}),
|
|
779
|
+
elements: elements
|
|
780
|
+
};
|
|
781
|
+
// State what was dropped. A capped list that reports only its own length
|
|
782
|
+
// reads as the whole page, and the agent acts as if it had seen everything.
|
|
783
|
+
if (text.length > ${nc}) {
|
|
784
|
+
result.textTruncated = true;
|
|
785
|
+
result.textTotalChars = text.length;
|
|
786
|
+
}
|
|
787
|
+
if (visibleTotal > elements.length) {
|
|
788
|
+
result.elementsTruncated = true;
|
|
789
|
+
result.interactiveElementsOnPage = visibleTotal;
|
|
790
|
+
}
|
|
791
|
+
return result;
|
|
792
|
+
`),Q1=({selector:t,text:e})=>Xr(`
|
|
793
|
+
var selector = ${JSON.stringify(t??"")};
|
|
794
|
+
var text = ${JSON.stringify(e??"")};
|
|
795
|
+
var target = null;
|
|
796
|
+
if (selector) {
|
|
797
|
+
try { target = document.querySelector(selector); }
|
|
798
|
+
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
799
|
+
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
800
|
+
} else {
|
|
801
|
+
target = findByText(text);
|
|
802
|
+
if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
|
|
803
|
+
}
|
|
804
|
+
if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
|
|
805
|
+
target.scrollIntoView({ block: 'center', inline: 'center' });
|
|
806
|
+
target.click();
|
|
807
|
+
return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
|
|
808
|
+
`),Y1=({selector:t,value:e,submit:n})=>Xr(`
|
|
809
|
+
var selector = ${JSON.stringify(t)};
|
|
810
|
+
var value = ${JSON.stringify(e)};
|
|
811
|
+
var target = null;
|
|
812
|
+
try { target = document.querySelector(selector); }
|
|
813
|
+
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
814
|
+
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
815
|
+
|
|
816
|
+
var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
817
|
+
if (!editable) return { ok: false, error: selector + ' is not a text field' };
|
|
818
|
+
if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
|
|
819
|
+
|
|
820
|
+
target.scrollIntoView({ block: 'center' });
|
|
821
|
+
target.focus();
|
|
822
|
+
if (target.isContentEditable) {
|
|
823
|
+
target.textContent = value;
|
|
824
|
+
} else {
|
|
825
|
+
// Frameworks track the value through the native setter; assigning the
|
|
826
|
+
// property directly leaves React and friends unaware of the change.
|
|
827
|
+
var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
828
|
+
var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
|
|
829
|
+
if (setter && setter.set) setter.set.call(target, value);
|
|
830
|
+
else target.value = value;
|
|
831
|
+
}
|
|
832
|
+
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
833
|
+
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
834
|
+
|
|
835
|
+
if (${n?"true":"false"}) {
|
|
836
|
+
var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
|
|
837
|
+
target.dispatchEvent(new KeyboardEvent('keydown', enter));
|
|
838
|
+
target.dispatchEvent(new KeyboardEvent('keyup', enter));
|
|
839
|
+
var form = target.form;
|
|
840
|
+
if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
|
|
841
|
+
}
|
|
842
|
+
return { ok: true, selector: cssPath(target), url: String(location.href) };
|
|
843
|
+
`),X1=({selector:t,direction:e})=>Xr(`
|
|
844
|
+
var selector = ${JSON.stringify(t??"")};
|
|
845
|
+
var direction = ${JSON.stringify(e??"")};
|
|
846
|
+
|
|
847
|
+
var settle = function (extra) {
|
|
848
|
+
return new Promise(function (resolve) {
|
|
849
|
+
requestAnimationFrame(function () {
|
|
850
|
+
requestAnimationFrame(function () {
|
|
851
|
+
var doc = document.documentElement;
|
|
852
|
+
var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
853
|
+
var scrollY = Math.round(window.scrollY);
|
|
854
|
+
var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
|
|
855
|
+
result.atTop = scrollY <= 1;
|
|
856
|
+
result.atBottom = scrollY >= maxScrollY - 1;
|
|
857
|
+
for (var key in extra) {
|
|
858
|
+
if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
|
|
859
|
+
}
|
|
860
|
+
resolve(result);
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
});
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
if (selector) {
|
|
867
|
+
var target = null;
|
|
868
|
+
try { target = document.querySelector(selector); }
|
|
869
|
+
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
870
|
+
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
871
|
+
// Instant on purpose: the page's own smooth scrolling would still be
|
|
872
|
+
// animating when the next action runs against it.
|
|
873
|
+
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
874
|
+
return settle({ scrolledTo: cssPath(target) });
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
var doc = document.documentElement;
|
|
878
|
+
var page = Math.round(window.innerHeight * 0.85);
|
|
879
|
+
var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
|
|
880
|
+
if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
|
|
881
|
+
else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
|
|
882
|
+
else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
|
|
883
|
+
else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
|
|
884
|
+
else return { ok: false, error: 'Unknown scroll direction: ' + direction };
|
|
885
|
+
return settle({ direction: direction });
|
|
886
|
+
`),J1=["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"],Z1=({selector:t})=>Xr(`
|
|
887
|
+
var selector = ${JSON.stringify(t)};
|
|
888
|
+
var target = null;
|
|
889
|
+
try { target = document.querySelector(selector); }
|
|
890
|
+
catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
|
|
891
|
+
if (!target) return { ok: false, error: 'No element matches ' + selector };
|
|
892
|
+
|
|
893
|
+
var computed = window.getComputedStyle(target);
|
|
894
|
+
var styles = {};
|
|
895
|
+
var props = ${JSON.stringify(J1)};
|
|
896
|
+
for (var i = 0; i < props.length; i += 1) {
|
|
897
|
+
var value = computed.getPropertyValue(props[i]);
|
|
898
|
+
if (value) styles[props[i]] = String(value).trim();
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
var rect = target.getBoundingClientRect();
|
|
902
|
+
return {
|
|
903
|
+
ok: true,
|
|
904
|
+
selector: cssPath(target),
|
|
905
|
+
tag: target.tagName.toLowerCase(),
|
|
906
|
+
label: label(target),
|
|
907
|
+
bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
|
|
908
|
+
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
909
|
+
styles: styles
|
|
910
|
+
};
|
|
911
|
+
`),ew=t=>{const e=st.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=Nt();if(n.length===0)return null;let u;e[0]!==a?(u=a("contextPanel.browser.history.label"),e[0]=a,e[1]=u):u=e[1];let d;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let f;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(f=(p,g)=>s.jsxs("div",{role:"option","aria-selected":g===r,className:Ie("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",g===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:w=>{w.preventDefault(),i(p.url)},onPointerEnter:()=>l(g),children:[s.jsx(E,{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:p.title||$a(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsx("button",{type:"button",className:Ie("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(p.url)},children:s.jsx(E,{name:"close",className:"size-3","aria-hidden":"true"})})]},p.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],d=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=d}else d=e[8];let h;return e[15]!==u||e[16]!==d?(h=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":u,children:d}),e[15]=u,e[16]=d,e[17]=h):h=e[17],h},an=t=>{const e=st.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",u=l&&"text-foreground";let d;e[0]!==u?(d=Ie("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",u),e[0]=u,e[1]=d):d=e[1];let h;e[2]!==n?(h=s.jsx(E,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=h):h=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==d||e[10]!==h?(f=s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{type:"button",variant:a,size:"xs",className:d,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:h})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=d,e[10]=h,e[11]=f):f=e[11];let p;e[12]!==r?(p=s.jsx(Pt,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let g;return e[14]!==f||e[15]!==p?(g=s.jsxs(At,{children:[f,p]}),e[14]=f,e[15]=p,e[16]=g):g=e[16],g},ef=t=>{const e=st.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:u,onReload:d,onOpenExternal:h,canGoBack:f,canGoForward:p,isLoading:g,onAnnotate:w,onOpenDevTools:S,isAnnotating:x,onHardReload:m,onZoomIn:b,onZoomOut:y,onZoomReset:v,zoomPercent:N,onClearCookies:C,onClearCache:k,onToggleDeviceBar:D,isDeviceBarOpen:P}=t;let I;e[0]!==r?(I=r===void 0?[]:r,e[0]=r,e[1]=I):I=e[1];const M=I,_=N===void 0?100:N,{t:O}=Nt(),[U,L]=c.useState(!1),[F,R]=c.useState(-1);let j;e[2]!==U||e[3]!==M?(j=U?M:[],e[2]=U,e[3]=M,e[4]=j):j=e[4];const A=j;let B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{R(-1)},e[5]=B):B=e[5];let X;e[6]!==n||e[7]!==U?(X=[n,U],e[6]=n,e[7]=U,e[8]=X):X=e[8],c.useEffect(B,X);let H;e[9]!==l?(H=ke=>{L(!1),R(-1),l(ke)},e[9]=l,e[10]=H):H=e[10];const Z=H;let ce;e[11]!==F||e[12]!==Z||e[13]!==A?(ce=ke=>{if(A.length!==0){if(ke.key==="ArrowDown"||ke.key==="ArrowUp"){ke.preventDefault();const Qe=ke.key==="ArrowDown"?1:-1,We=A.length;R(z=>{const he=z+Qe;return he<-1?We-1:he>=We?-1:he});return}if(ke.key==="Escape"&&F>=0){ke.preventDefault(),R(-1);return}if(ke.key==="Enter"&&F>=0){ke.preventDefault();const Qe=A[F];Qe&&Z(Qe.url)}}},e[11]=F,e[12]=Z,e[13]=A,e[14]=ce):ce=e[14];const Y=ce;let se;e[15]!==O?(se=O("contextPanel.browser.back"),e[15]=O,e[16]=se):se=e[16];const oe=!f;let Se;e[17]!==a||e[18]!==oe||e[19]!==se?(Se=s.jsx(an,{icon:"arrow-left",label:se,onClick:a,disabled:oe}),e[17]=a,e[18]=oe,e[19]=se,e[20]=Se):Se=e[20];let K;e[21]!==O?(K=O("contextPanel.browser.forward"),e[21]=O,e[22]=K):K=e[22];const pe=!p;let je;e[23]!==u||e[24]!==K||e[25]!==pe?(je=s.jsx(an,{icon:"arrow-right",label:K,onClick:u,disabled:pe}),e[23]=u,e[24]=K,e[25]=pe,e[26]=je):je=e[26];let ne;e[27]!==g||e[28]!==O?(ne=O(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=O,e[29]=ne):ne=e[29];let T;e[30]!==d||e[31]!==ne?(T=s.jsx(an,{icon:"refresh",label:ne,onClick:d}),e[30]=d,e[31]=ne,e[32]=T):T=e[32];let G;e[33]!==m||e[34]!==O?(G=m?s.jsx(an,{icon:"restart",label:O("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=O,e[35]=G):G=e[35];let le;e[36]!==n||e[37]!==Z?(le=ke=>{ke.preventDefault(),Z(n)},e[36]=n,e[37]=Z,e[38]=le):le=e[38];let de;e[39]!==o?(de=ke=>o(ke.target.value),e[39]=o,e[40]=de):de=e[40];let ue,Oe;e[41]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>L(!0),Oe=()=>L(!1),e[41]=ue,e[42]=Oe):(ue=e[41],Oe=e[42]);const me=A.length>0;let Re;e[43]===Symbol.for("react.memo_cache_sentinel")?(Re=Ie("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]=Re):Re=e[43];let ye;e[44]!==O?(ye=O("contextPanel.browser.addressAria"),e[44]=O,e[45]=ye):ye=e[45];let q;e[46]!==n||e[47]!==Y||e[48]!==de||e[49]!==me||e[50]!==ye?(q=s.jsx("input",{value:n,onChange:de,onFocus:ue,onBlur:Oe,onKeyDown:Y,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":me,"aria-controls":"openchamber-browser-address-suggestions",className:Re,"aria-label":ye}),e[46]=n,e[47]=Y,e[48]=de,e[49]=me,e[50]=ye,e[51]=q):q=e[51];let we;e[52]!==i?(we=ke=>i?.(ke),e[52]=i,e[53]=we):we=e[53];let be;e[54]!==F||e[55]!==Z||e[56]!==we||e[57]!==A?(be=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(ew,{entries:A,activeIndex:F,onSelect:Z,onForget:we,onHighlight:R})}),e[54]=F,e[55]=Z,e[56]=we,e[57]=A,e[58]=be):be=e[58];let Ne;e[59]!==le||e[60]!==q||e[61]!==be?(Ne=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:le,children:[q,be]}),e[59]=le,e[60]=q,e[61]=be,e[62]=Ne):Ne=e[62];let ie;e[63]!==b||e[64]!==y||e[65]!==v||e[66]!==O||e[67]!==_?(ie=y&&b?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(an,{icon:"subtract",label:O("contextPanel.browser.zoomOut"),onClick:y}),_!==100&&v?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs(xt,{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":O("contextPanel.browser.zoomReset"),children:[_,"%"]})}),s.jsx(Pt,{sideOffset:6,children:O("contextPanel.browser.zoomReset")})]}):null,s.jsx(an,{icon:"add",label:O("contextPanel.browser.zoomIn"),onClick:b})]}):null,e[63]=b,e[64]=y,e[65]=v,e[66]=O,e[67]=_,e[68]=ie):ie=e[68];let ee;e[69]!==C||e[70]!==O?(ee=C?s.jsx(an,{icon:"delete-bin",label:O("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=O,e[71]=ee):ee=e[71];let V;e[72]!==k||e[73]!==O?(V=k?s.jsx(an,{icon:"database-2",label:O("contextPanel.browser.clearCache"),onClick:k}):null,e[72]=k,e[73]=O,e[74]=V):V=e[74];let $;e[75]!==P||e[76]!==D||e[77]!==O?($=D?s.jsx(an,{icon:"smartphone",label:O("contextPanel.browser.deviceToolbar"),onClick:D,pressed:P}):null,e[75]=P,e[76]=D,e[77]=O,e[78]=$):$=e[78];let ae;e[79]!==x||e[80]!==w||e[81]!==O?(ae=w?s.jsx(an,{icon:"markup",label:O("contextPanel.browser.annotate.toggle"),onClick:w,pressed:x}):null,e[79]=x,e[80]=w,e[81]=O,e[82]=ae):ae=e[82];let W;e[83]!==S||e[84]!==O?(W=S?s.jsx(an,{icon:"terminal-box",label:O("contextPanel.browser.devTools"),onClick:S}):null,e[83]=S,e[84]=O,e[85]=W):W=e[85];let ve;e[86]!==O?(ve=O("contextPanel.browser.openExternal"),e[86]=O,e[87]=ve):ve=e[87];let Fe;e[88]!==h||e[89]!==ve?(Fe=s.jsx(an,{icon:"external-link",label:ve,onClick:h}),e[88]=h,e[89]=ve,e[90]=Fe):Fe=e[90];let Ce;return e[91]!==Se||e[92]!==je||e[93]!==T||e[94]!==G||e[95]!==Ne||e[96]!==ie||e[97]!==ee||e[98]!==V||e[99]!==$||e[100]!==ae||e[101]!==W||e[102]!==Fe?(Ce=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Se,je,T,G,Ne,ie,ee,V,$,ae,W,Fe]}),e[91]=Se,e[92]=je,e[93]=T,e[94]=G,e[95]=Ne,e[96]=ie,e[97]=ee,e[98]=V,e[99]=$,e[100]=ae,e[101]=W,e[102]=Fe,e[103]=Ce):Ce=e[103],Ce},Mo={kind:"fill"},rc=240,tw=3840,tf=[{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}],oc=t=>Number.isFinite(t)?Math.round(Math.min(tw,Math.max(rc,t))):rc,Oo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},sf=t=>{const e=tf.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},sw=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},nw=(t,e)=>{const n=Oo(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}},rw=["mobile","tablet","desktop","fill"],ow={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},ic=t=>typeof t=="string"&&rw.includes(t),Zi=t=>t==="fill"?Mo:sf(ow[t])??Mo,ro=t=>{const e=Oo(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=Zi(n),i=Oo(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}},iw=t=>{const e=st.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=Nt();let u;e[0]!==n?(u=Oo(n),e[0]=n,e[1]=u):u=e[1];const d=u,h=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==d?(f=(oe,Se)=>{const K=Number.parseInt(Se,10);if(!Number.isFinite(K))return;const pe=d??{width:1280,height:800};r({kind:"custom",width:oc(oe==="width"?K:pe.width),height:oc(oe==="height"?K:pe.height)})},e[2]=r,e[3]=d,e[4]=f):f=e[4];const p=f;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=Ie("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=g):g=e[5];const w=g;let S;e[6]!==r?(S=oe=>{const Se=sf(oe.target.value);r(Se??Mo)},e[6]=r,e[7]=S):S=e[7];let x;e[8]!==a?(x=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=x):x=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=Ie("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 b;e[11]!==a?(b=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=b):b=e[12];let y;e[13]!==b?(y=s.jsx("option",{value:"",children:b}),e[13]=b,e[14]=y):y=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=tf.map(aw),e[15]=v):v=e[15];let N;e[16]!==h||e[17]!==S||e[18]!==x||e[19]!==y?(N=s.jsxs("select",{value:h,onChange:S,"aria-label":x,className:m,children:[y,v]}),e[16]=h,e[17]=S,e[18]=x,e[19]=y,e[20]=N):N=e[20];const C=d?String(d.width):"";let k;e[21]!==p?(k=oe=>p("width",oe.target.value),e[21]=p,e[22]=k):k=e[22];let D;e[23]!==a?(D=a("contextPanel.browser.device.width"),e[23]=a,e[24]=D):D=e[24];let P;e[25]!==C||e[26]!==k||e[27]!==D?(P=s.jsx("input",{value:C,onChange:k,placeholder:"—",inputMode:"numeric","aria-label":D,className:w}),e[25]=C,e[26]=k,e[27]=D,e[28]=P):P=e[28];let I;e[29]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=I):I=e[29];const M=d?String(d.height):"";let _;e[30]!==p?(_=oe=>p("height",oe.target.value),e[30]=p,e[31]=_):_=e[31];let O;e[32]!==a?(O=a("contextPanel.browser.device.height"),e[32]=a,e[33]=O):O=e[33];let U;e[34]!==M||e[35]!==_||e[36]!==O?(U=s.jsx("input",{value:M,onChange:_,placeholder:"—",inputMode:"numeric","aria-label":O,className:w}),e[34]=M,e[35]=_,e[36]=O,e[37]=U):U=e[37];let L;e[38]!==r||e[39]!==n?(L=()=>r(sw(n)),e[38]=r,e[39]=n,e[40]=L):L=e[40];const F=!d;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(E,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=j):j=e[43];let A;e[44]!==L||e[45]!==F||e[46]!==R?(A=s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:L,disabled:F,"aria-label":R,children:j})}),e[44]=L,e[45]=F,e[46]=R,e[47]=A):A=e[47];let B;e[48]!==a?(B=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=B):B=e[49];let X;e[50]!==B?(X=s.jsx(Pt,{sideOffset:6,children:B}),e[50]=B,e[51]=X):X=e[51];let H;e[52]!==A||e[53]!==X?(H=s.jsxs(At,{children:[A,X]}),e[52]=A,e[53]=X,e[54]=H):H=e[54];let Z;e[55]!==l||e[56]!==d?(Z=d&&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]=d,e[57]=Z):Z=e[57];let ce;e[58]===Symbol.for("react.memo_cache_sentinel")?(ce=["system","light","dark"],e[58]=ce):ce=e[58];let Y;e[59]!==i||e[60]!==o||e[61]!==a?(Y=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ce.map(oe=>s.jsx(xt,{type:"button",variant:i===oe?"secondary":"ghost",size:"xs",className:Ie("shrink-0 rounded-full px-2.5 typography-micro",i===oe?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(oe),"aria-pressed":i===oe,children:a(oe==="system"?"contextPanel.browser.device.schemeSystem":oe==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},oe))}),e[59]=i,e[60]=o,e[61]=a,e[62]=Y):Y=e[62];let se;return e[63]!==N||e[64]!==P||e[65]!==U||e[66]!==H||e[67]!==Z||e[68]!==Y?(se=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,P,I,U,H,Z,Y]}),e[63]=N,e[64]=P,e[65]=U,e[66]=H,e[67]=Z,e[68]=Y,e[69]=se):se=e[69],se};function aw(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const lw=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},cw=2e3,dw=()=>{if(typeof window>"u"||window.__AIWORKER_ELECTRON__)return!1;const t=Nn();if(!t)return!1;try{return!yr(new URL(t,window.location.href).toString())}catch{return!1}},nf=t=>{const e=st.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=Nt();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,u]=c.useState(l),d=yx(i),[h]=c.useState(dw);let f,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let P=!0,I=null;const M=new AbortController,_=()=>{i1(M.signal).then(O=>{P&&(u(O),I=setTimeout(_,cw))})};return _(),()=>{P=!1,I&&clearTimeout(I),M.abort()}},p=[],e[1]=f,e[2]=p):(f=e[1],p=e[2]),c.useEffect(f,p);const g=a.kind==="ready"?a.servers:null;let w;e[3]!==d||e[4]!==g?(w=c1({announced:d,discovered:g}),e[3]=d,e[4]=g,e[5]=w):w=e[5];const S=w;let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Td,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=x):x=e[6];let m;e[7]!==o?(m=o("contextPanel.browser.empty"),e[7]=o,e[8]=m):m=e[8];let b;e[9]!==m?(b=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=b):b=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]!==b?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[b,v]}),e[15]=v,e[16]=b,e[17]=N):N=e[17];let C;e[18]!==d||e[19]!==S||e[20]!==i||e[21]!==n||e[22]!==h||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:d.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),h?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(P=>s.jsxs(xt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{gx(i),n(P.url)},children:[s.jsx(E,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:$a(P.url)||P.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:lw(P.url)})]},P.port))})]}):null,e[18]=d,e[19]=S,e[20]=i,e[21]=n,e[22]=h,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 D;return e[29]!==N||e[30]!==C||e[31]!==k?(D=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:[x,N,C,k]}),e[29]=N,e[30]=C,e[31]=k,e[32]=D):D=e[32],D},Ls=t=>Math.round(t),uw=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,u])=>`${a}="${u}"`).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=${Ls(l.x)}, y=${Ls(l.y)}, width=${Ls(l.width)}, height=${Ls(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")},fw=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},mw=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},hw=({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: ${Ls(t.viewport.width)}x${Ls(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("",...uw(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(fw(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(mw(l,a)))),o.filter(l=>typeof l=="string").join(`
|
|
912
|
+
`)},pw=t=>{const e=st.c(7),{t:n}=Nt(),r=Je(xw),i=Je(bw),o=ji(yw),l=eh(ww);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async u=>{const d=r??(i?"draft":null);if(!d){Le.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(u.screenshot)try{await l(u.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:d},{source:"preview-annotation",fileLabel:u.payload.pageUrl||"browser",startLine:1,endLine:1,code:hw({payload:u.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Le.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},gw=()=>{const t=st.c(16),{t:e}=Nt();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 xw(t){return t.currentSessionId}function bw(t){return t.newSessionDraft?.open}function yw(t){return t.addDraft}function ww(t){return t.addAttachedFile}const Sw=3e4,vw=3,jw=250,kw={attempts:0,windowStartedAt:null},Cw=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=Sw,r=n?0:t.attempts;return r>=vw?null:{delayMs:jw*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Nw=-3,oo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",dr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Aw=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:f1),[o,l]=c.useState(e),[a,u]=c.useState(""),[d,h]=c.useState(!1),[f,p]=c.useState(!1),g=c.useRef(n);g.current=n;const w=c.useRef(kw);return c.useEffect(()=>{if(!t)return;const S=()=>{try{const I=t.getURL();return oo(I)?I:""}catch{return""}},x=()=>{try{h(t.canGoBack()),p(t.canGoForward())}catch{}},m=I=>{oo(I)&&(l(I),g.current(I))},b=()=>{const I=S();i({kind:"loading",url:I})},y=()=>{const I=S();let M="";try{M=t.getTitle()||""}catch{M=""}u(M),m(I),x(),i(_=>_.kind==="failed"&&_.url===I?_:{kind:"ready",url:I,title:M})},v=I=>{const M=dr(I);oo(M.url)&&(m(M.url),x())},N=I=>{const M=dr(I),_=Array.isArray(M.favicons)?M.favicons.find(Boolean):"",O=S();_&&O&&Vu.getState().resolve(O,_)},C=I=>{const M=dr(I);typeof M.title=="string"&&u(M.title)},k=I=>{const M=dr(I);if(M.isMainFrame===!1)return;const _=typeof M.errorCode=="number"?M.errorCode:0;_!==Nw&&i({kind:"failed",url:oo(M.validatedURL)?M.validatedURL:S(),code:_,description:typeof M.errorDescription=="string"?M.errorDescription:""})};let D=null;const P=()=>{const I=S(),M=Cw(w.current,Date.now());if(!M){i({kind:"failed",url:I,code:0,description:"",crashed:!0});return}w.current=M.state,i({kind:"loading",url:I}),D=setTimeout(()=>{D=null;try{t.reload()}catch{i({kind:"failed",url:I,code:0,description:"",crashed:!0})}},M.delayMs)};t.addEventListener("did-start-loading",b),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",P),t.addEventListener("crashed",P);try{!t.isLoading()&&S()&&y()}catch{}return()=>{D!==null&&clearTimeout(D),t.removeEventListener("render-process-gone",P),t.removeEventListener("crashed",P),t.removeEventListener("did-start-loading",b),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:d,canGoForward:f}},Dw=()=>typeof window<"u"&&!!window.__AIWORKER_ELECTRON__,Pw=4e4,io=.5,Iw=-3,Tw=4,Rw="persist:openchamber-browser",ac=20,Ew=600,Mw=2e4,Ow=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=Nt(),{currentTheme:i}=Zn(),o=c.useRef(null),[l,a]=c.useState(null),u=c.useCallback(ie=>{o.current=ie,a(ie)},[]),d=Te(ie=>ie.setContextPanelTabTargetPath),h=c.useRef(hr(t)),f=h.current!==ln?h.current:"",[p,g]=c.useState(f?null:ln),[w,S]=c.useState(f),[x,m]=c.useState(!1),[b,y]=c.useState(!1),[v,N]=c.useState(0),C=c.useRef(0),[k,D]=c.useState(!1),[P,I]=c.useState(Mo),M=c.useRef(P);M.current=P;const _=c.useRef([]),[O,U]=c.useState("system"),[L,F]=c.useState({width:0,height:0}),R=c.useRef(null),j=c.useRef(null),A=c.useRef(!1),B=c.useRef(Date.now()),X=c.useCallback(ie=>{!ie||ie===ln||!e||!n||d(e,n,ie)},[e,n,d]),H=Aw(l,{initialUrl:f,onUrlChange:c.useCallback(ie=>{const ee=Ar(ie);S(ee),X(ee)},[X])}),[Z,ce]=c.useState(null),Y=pw(e),se=gw(),oe=H.status.kind==="loading",Se=gr(Yu(e)),K=gr(ie=>ie.recordVisit),pe=gr(ie=>ie.forget);c.useEffect(()=>{H.status.kind==="ready"&&K(e,{url:Ar(H.status.url),title:H.status.title})},[e,H.status,K]);const je=c.useMemo(()=>Qu(Se,w),[Se,w]),ne=c.useCallback(ie=>{const ee=hr(ie);ee!==ln&&(S(ee),ce(null),tc(ee).then(V=>{const $=o.current;if(!$){g(V);return}try{$.loadURL(V)}catch{g(V)}}).catch(V=>{V instanceof _r&&ce(ee)}))},[]);c.useEffect(()=>{if(!f)return;let ie=!0;return tc(f).then(ee=>{ie&&g(ee)}).catch(ee=>{if(ie){if(ee instanceof _r){ce(f),g(ln);return}g(f)}}),()=>{ie=!1}},[]);const T=c.useMemo(()=>({executeJavaScript:async(ie,ee)=>{const V=o.current;if(!V)throw new Error("Browser view is not available");return V.executeJavaScript(ie,ee)},capturePage:async()=>{const ie=o.current;if(!ie)return null;const ee=ie.getWebContentsId();return Number.isFinite(ee)?await fr("desktop_browser_capture_page",{webContentsId:ee}):null}}),[]),G=c.useCallback(()=>{if(x){m(!1),bo(T);return}if(!H.url){Le.error(r("contextPanel.browser.annotate.noPage"));return}const ie=N1(i.metadata.variant==="light"?"light":"dark");m(!0),k1({host:T,theme:ie,labels:se}).then(async ee=>{m(!1),ee&&await Y(ee)}).catch(()=>{m(!1),Le.error(r("contextPanel.browser.annotate.failed"))})},[T,Y,i,x,H.url,se,r]);c.useEffect(()=>{if(!x)return;const ie=ee=>{th(ee)||ee.key!=="Escape"||(ee.preventDefault(),ee.stopImmediatePropagation(),m(!1),bo(T))};return window.addEventListener("keydown",ie,!0),()=>window.removeEventListener("keydown",ie,!0)},[T,x]);const le=c.useCallback(async(ie=8e3)=>{const ee=Date.now();for(;;){const V=o.current;if(!V)return!1;let $=!1;try{$=V.isLoading()}catch{return!1}if(!$)return!0;if(Date.now()-ee>ie)return!1;await new Promise(ae=>setTimeout(ae,120))}},[]),de=c.useCallback(async(ie,ee)=>{const V=o.current;if(!V)throw new Error("The browser panel is not ready");const $=()=>{ic(ee.viewport)&&(I(Zi(ee.viewport)),D(!0))};if(ie==="browser.back"||ie==="browser.forward"){const ke=ie==="browser.back";if(!(ke?V.canGoBack():V.canGoForward()))throw new Error(ke?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");ke?V.goBack():V.goForward(),await new Promise(z=>setTimeout(z,150)),await le();let We="";try{We=V.getTitle()||""}catch{We=""}return{url:Ar(V.getURL()),title:We}}if(ie==="browser.capture"){Te.getState().openContextBrowser(e,V.getURL());const ke=Date.now()+1200;let Qe=0,We=0;for(;We<2&&Date.now()<ke;){const Be=V.getBoundingClientRect().width;We=Be>=2&&Math.abs(Be-Qe)<.5?We+1:0,Qe=Be,await new Promise(Ae=>setTimeout(Ae,50))}await new Promise(Be=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Be()))}),await le();const z=await T.capturePage();if(!z)throw new Error("The page could not be captured");let he="";try{he=V.getTitle()||""}catch{he=""}return{...z,url:Ar(V.getURL()),title:he,viewport:ro(M.current)}}if(ie==="browser.resize"){if(!ic(ee.viewport))throw new Error("viewport is required");return $(),await new Promise(ke=>setTimeout(ke,200)),await le(),{viewport:ro(Zi(ee.viewport))}}if(ie==="browser.open"){const ke=typeof ee.url=="string"?ee.url:"";if(!ke)throw new Error("url is required");$(),ne(ke),await new Promise(z=>setTimeout(z,150));const Qe=await le(25e3);let We="";try{We=V.getTitle()||""}catch{We=""}return{url:hr(ke),title:We,opened:!0,settled:Qe,viewport:ro(M.current)}}await le();const ae=ke=>typeof ke=="string"&&ke?ke:void 0,ve=(()=>{switch(ie){case"browser.snapshot":return q1({selector:ae(ee.selector)});case"browser.click":return Q1({selector:ae(ee.selector),text:ae(ee.text)});case"browser.type":return Y1({selector:String(ee.selector??""),value:String(ee.value??""),submit:ee.submit===!0});case"browser.inspect":return Z1({selector:String(ee.selector??"")});case"browser.scroll":return X1({selector:ae(ee.selector),direction:ae(ee.direction)});default:return null}})();if(!ve)throw new Error(`Unsupported browser action: ${ie}`);const Fe=await V.executeJavaScript(ve,!0);if(!Fe||typeof Fe!="object")throw new Error("The page returned no result");const Ce=Fe;if(Ce.ok!==!0)throw new Error(typeof Ce.error=="string"&&Ce.error?Ce.error:"Browser action failed");if(ie==="browser.snapshot"){const ke=_.current;return{...Ce,viewport:ro(M.current),...ke.length>0?{consoleProblems:[...ke]}:{}}}return(ie==="browser.click"||ie==="browser.type"&&ee.submit===!0)&&(await new Promise(ke=>setTimeout(ke,150)),await le()),Fe},[T,e,ne,le]);c.useEffect(()=>R1({run:de}),[de]),c.useEffect(()=>{const ie=T;return()=>{bo(ie)}},[T]),c.useEffect(()=>{if(!l)return;const ie=V=>{const $=V;if(typeof $.level!="number"||$.level<2)return;const ae=$.sourceId?`${$.sourceId}${$.line?`:${$.line}`:""}`:"";_.current.push({level:$.level>=3?"error":"warning",message:String($.message??"").slice(0,400),source:ae}),_.current.length>ac&&_.current.splice(0,_.current.length-ac)},ee=()=>{_.current=[]};return l.addEventListener("console-message",ie),l.addEventListener("did-start-loading",ee),()=>{l.removeEventListener("console-message",ie),l.removeEventListener("did-start-loading",ee)}},[l]);const ue=c.useRef(new Set),Oe=c.useCallback(ie=>{ue.current.clear(),ne(ie)},[ne]);c.useEffect(()=>{if(!l)return;const ie=V=>{const $=dr(V),ae=typeof $.url=="string"?$.url:"";!ae||!sc(ae)||(V.preventDefault(),ne(ae))},ee=V=>{const $=dr(V);if($.isMainFrame===!1||$.errorCode===-3)return;const ae=typeof $.validatedURL=="string"?$.validatedURL:"";!ae||!sc(ae)||ue.current.has(ae)||(ue.current.add(ae),ne(ae))};return l.addEventListener("will-navigate",ie),l.addEventListener("did-fail-load",ee),()=>{l.removeEventListener("will-navigate",ie),l.removeEventListener("did-fail-load",ee)}},[ne,l]),c.useEffect(()=>{if(!l)return;const ie=ee=>{const V=ee.detail;ee.preventDefault(),V?.url&&ne(V.url)};return l.addEventListener("new-window",ie),()=>l.removeEventListener("new-window",ie)},[ne,l]);const me=c.useCallback(ie=>{const ee=Math.min(Tw,Math.max(Iw,ie));C.current=ee,N(ee);try{o.current?.setZoomLevel(ee)}catch{}},[]);c.useEffect(()=>{const ie=ee=>{if(!(ee instanceof CustomEvent))return;const V=ee.detail,$=o.current;!$||document.activeElement!==$||(V==="zoom-in"?me(C.current+io):V==="zoom-out"?me(C.current-io):V==="zoom-reset"&&me(0))};return window.addEventListener("aiworker:zoom",ie),()=>window.removeEventListener("aiworker:zoom",ie)},[me]);const Re=c.useCallback(ie=>{fr("desktop_browser_clear_data",{partition:Rw,cookies:ie==="cookies",cache:ie==="cache"}).then(()=>{Le.success(r(ie==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Le.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const ie=R.current;if(!ie||typeof ResizeObserver>"u")return;const ee=new ResizeObserver(V=>{const $=V[0]?.contentRect;$&&F({width:$.width,height:$.height})});return ee.observe(ie),()=>ee.disconnect()},[]);const ye=c.useCallback(ie=>{U(ie);const ee=o.current;if(!ee)return;let V=-1;try{V=ee.getWebContentsId()}catch{return}fr("desktop_browser_set_color_scheme",{webContentsId:V,scheme:ie}).catch($=>{U("system"),Le.error($ instanceof Error?$.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),q=c.useCallback(()=>{try{oe?o.current?.stop():o.current?.reload()}catch{}},[oe]),we=H.status;c.useEffect(()=>{const ie=()=>{y(!0);const $=setTimeout(()=>{try{o.current?.reload()}catch{}},Ew);return()=>clearTimeout($)};if(we.kind==="failed"){if(!r1(we.code,we.url)){y(!1);return}const $=Date.now(),ae=j.current?.url===we.url?j.current:{url:we.url,startedAt:$};if(j.current=ae,$-ae.startedAt>Pw){y(!1);return}return ie()}if(we.kind==="loading")return;if(j.current=null,we.kind!=="ready"||!we.url||!yr(we.url)){A.current=!0,y(!1);return}if(A.current||Date.now()-B.current>Mw){A.current=!0,y(!1);return}let ee=!1,V=null;return a1(Ar(we.url)).then($=>{if(!ee){if($===null||$<500){A.current=!0,y(!1);return}V=ie()}}),()=>{ee=!0,V?.()}},[we]);const be=H.status.kind==="failed"&&!b?H.status:null,Ne=nw(P,L);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(ef,{address:w,onAddressChange:S,onSubmit:Oe,suggestions:je,onForgetSuggestion:ie=>pe(e,ie),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:q,onOpenExternal:()=>{Uo(H.url||w)},canGoBack:H.canGoBack,canGoForward:H.canGoForward,isLoading:oe,onAnnotate:G,isAnnotating:x,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>me(v+io),onZoomOut:()=>me(v-io),onZoomReset:()=>me(0),zoomPercent:Math.round(Math.pow(1.2,v)*100),onClearCookies:()=>Re("cookies"),onClearCache:()=>Re("cache"),onToggleDeviceBar:()=>D(ie=>!ie),isDeviceBarOpen:k}),k?s.jsx(iw,{viewport:P,onViewportChange:I,colorScheme:O,onColorSchemeChange:ye,scale:Ne?.scale??1}):null,s.jsxs("div",{ref:R,className:Ie("relative min-h-0 flex-1 bg-background",Ne&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:u,src:p,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,p!==null&&!f&&!H.url&&!oe?s.jsx(nf,{onOpen:Oe,directory:e}):null,b?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,Z?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:Z})})]}):null,be&&!Z?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:be.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:be.crashed?r("contextPanel.browser.crashedHint"):be.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,oe?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]})]})},Fw=t=>{const e=st.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=Nt(),l=Te(_w);let a;e[0]!==n?(a=hr(n),e[0]=n,e[1]=a):a=e[1];const u=a,d=u!==ln?u:"",[h,f]=c.useState(d),[p,g]=c.useState(d);let w;e[2]!==d?(w=d?[d]:[],e[2]=d,e[3]=w):w=e[3];const[S,x]=c.useState(w),[m,b]=c.useState(d?0:-1),[y,v]=c.useReducer(Lw,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=se=>{!se||se===ln||!r||!i||l(r,i,se)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const C=N;let k;e[8]!==r?(k=Yu(r),e[8]=r,e[9]=k):k=e[9];const D=gr(k),P=gr($w),I=gr(Ww);let M;e[10]!==h||e[11]!==D?(M=Qu(D,h),e[10]=h,e[11]=D,e[12]=M):M=e[12];const _=M;let O;e[13]!==r||e[14]!==m||e[15]!==C||e[16]!==P?(O=se=>{const oe=hr(se);oe!==ln&&(f(oe),g(oe),C(oe),P(r,{url:oe}),x(Se=>{const K=m>=0?Se.slice(0,m+1):[];return K[K.length-1]===oe?(b(K.length-1),K):(b(K.length),[...K,oe])}))},e[13]=r,e[14]=m,e[15]=C,e[16]=P,e[17]=O):O=e[17];const U=O;let L;e[18]!==S||e[19]!==C?(L=se=>{const oe=S[se];oe&&(b(se),f(oe),g(oe),C(oe))},e[18]=S,e[19]=C,e[20]=L):L=e[20];const F=L;let R;e[21]!==r||e[22]!==I?(R=se=>I(r,se),e[21]=r,e[22]=I,e[23]=R):R=e[23];let j,A;e[24]!==F||e[25]!==m?(A=()=>F(m-1),j=()=>F(m+1),e[24]=F,e[25]=m,e[26]=j,e[27]=A):(j=e[26],A=e[27]);let B;e[28]!==h||e[29]!==p?(B=()=>{Uo(p||h)},e[28]=h,e[29]=p,e[30]=B):B=e[30];const X=m>0,H=m>=0&&m<S.length-1;let Z;e[31]!==h||e[32]!==U||e[33]!==_||e[34]!==j||e[35]!==B||e[36]!==X||e[37]!==H||e[38]!==R||e[39]!==A?(Z=s.jsx(ef,{address:h,onAddressChange:f,onSubmit:U,suggestions:_,onForgetSuggestion:R,onBack:A,onForward:j,onReload:v,onOpenExternal:B,canGoBack:X,canGoForward:H,isLoading:!1}),e[31]=h,e[32]=U,e[33]=_,e[34]=j,e[35]=B,e[36]=X,e[37]=H,e[38]=R,e[39]=A,e[40]=Z):Z=e[40];let ce;e[41]!==p||e[42]!==U||e[43]!==y||e[44]!==o?(ce=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:p?s.jsx("iframe",{src:p,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${p}|${y}`):s.jsx(nf,{onOpen:U})}),e[41]=p,e[42]=U,e[43]=y,e[44]=o,e[45]=ce):ce=e[45];let Y;return e[46]!==Z||e[47]!==ce?(Y=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Z,ce]}),e[46]=Z,e[47]=ce,e[48]=Y):Y=e[48],Y},Bw=t=>{const e=st.c(3),[n]=c.useState(Dw);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Ow,{...t}):s.jsx(Fw,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function _w(t){return t.setContextPanelTabTargetPath}function Lw(t){return t+1}function $w(t){return t.recordVisit}function Ww(t){return t.forget}const zw=Ln(()=>Bn(()=>import("./WalkthroughView-CpgA4s9w.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}))),Vw=Ln(()=>Bn(()=>import("./DiffView-BviYY3zL.js"),__vite__mapDeps([124,1,2,4,5,6,7,8,9,83,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,125,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.DiffView}))),Uw=Ln(()=>Bn(()=>import("./FilesView-D0ZU_nCt.js"),__vite__mapDeps([126,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,127,128,129,130,131,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,132,133,118,119,116,121,134,117,135])).then(t=>({default:t.FilesView}))),Kw=Ln(()=>Bn(()=>import("./GitView-CYgiDRH-.js"),__vite__mapDeps([136,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,137,115,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,85,113,114,116,117,118,119,120,121,122,123])).then(t=>({default:t.GitView}))),Hw=Ln(()=>Bn(()=>import("./LinearIssuesView-shqUS8nl.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])).then(t=>({default:t.LinearIssuesView}))),Gw=Ln(()=>Bn(()=>import("./PlanView-CLUWkGiG.js"),__vite__mapDeps([139,1,2,4,5,6,7,8,9,127,57,58,59,60,61,62,79,55,56,63,128,129,130,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,117,135,118,119,104,105,89,90,91,92,93,94,95,96,97,98,99,100,101,102,84])).then(t=>({default:t.PlanView}))),qw=320,Qw=1400,rf=600,Yw=100,Xw=24,Fo=new Map,Jw=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},lc=t=>Number.isFinite(t)?Math.min(Qw,Math.max(qw,Math.round(t))):rf,Zw=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},eS=(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},of=(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==="linear"?"contextPanel.mode.linear":t==="notes"?"contextRail.surface.notes":t==="terminal"?"layout.mainTab.terminal":"contextPanel.mode.context"),tS=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},sS=(t,e,n)=>{if(t.mode==="chat"){const r=ea(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"?$a(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?tS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):of(t.mode,n)},cc=(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(Eu,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(E,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(E,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(E,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(E,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(E,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(E,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(E,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(E,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(E,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="browser"){const n=nS(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(E,{name:"global",className:"h-3.5 w-3.5"})}},nS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},rS=200,oS=480,iS=({visible:t,active:e})=>{const{t:n}=Nt(),r=Te(b=>b.contextEditorTreeWidth),i=Te(b=>b.setContextEditorTreeWidth),[o,l]=c.useState(!1),a=c.useRef(0),u=c.useRef(r),d=c.useRef(null),h=c.useRef(null),f=c.useRef(null),p=c.useCallback(b=>Math.min(oS,Math.max(rS,Math.round(b))),[]),g=c.useCallback(b=>{const y=f.current;y&&(y.style.width=`${b}px`,y.style.setProperty("--oc-editor-tree-width",`${b}px`))},[]),w=b=>{if(t){try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}h.current=b.pointerId,l(!0),a.current=b.clientX,u.current=r,d.current=r,b.preventDefault()}},S=b=>{if(!o||h.current!==b.pointerId)return;const y=a.current-b.clientX,v=p(u.current+y);d.current!==v&&(d.current=v,g(v))},x=b=>{if(h.current!==b.pointerId)return;try{b.currentTarget.releasePointerCapture(b.pointerId)}catch{}const y=p(d.current??r);h.current=null,d.current=null,l(!1),i(y)},m=t?r:0;return s.jsxs("div",{ref:f,className:Ie("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${o?d.current??m:m}px`,"--oc-editor-tree-width":`${o?d.current??r:r}px`,overflowX:"clip",transitionProperty:o?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&s.jsx("div",{className:Ie("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",o&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:S,onPointerUp:x,onPointerCancel:x,role:"separator","aria-orientation":"vertical","aria-label":n("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Ie("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",o&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:s.jsx(Cy,{visible:t&&e})})]})},ea=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,aS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},lS=(t,e)=>{if(e.length===0)return Fo;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?Fo:r},cS=(t,e)=>{const n=kd(t),r=c.useRef(Fo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=lS(n.getState().session,i.current);return aS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Fo)},dS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,uS=()=>{const{t}=Nt(),e=er()??"",n=c.useMemo(()=>Jw(e),[e]),r=Te(ge=>n?ge.contextPanelByDirectory[n]:void 0),i=Te(ge=>ge.closeContextPanel),o=Te(ge=>ge.closeContextPanelTab),l=Te(ge=>ge.openContextPanelTab),a=Te(ge=>ge.toggleContextPanelExpanded),u=Te(ge=>ge.setContextPanelWidth),d=Te(ge=>ge.setActiveContextPanelTab),h=Te(ge=>ge.openContextBrowser);c.useEffect(()=>{if(e)return E1(ge=>h(e,ge))},[e,h]);const f=Te(ge=>ge.reorderContextPanelTabs),p=hn(ge=>ge.setSelectedPath),g=Te(ge=>ge.contextEditorTreeVisible),w=Te(ge=>ge.toggleContextEditorTree),S=Te(ge=>ge.openNewContextBrowserTab),x=Vu(ge=>ge.byOrigin),m=Te(ge=>ge.allowPromptingSubagentSessions),{themeMode:b,setThemeMode:y,lightThemeId:v,darkThemeId:N,currentTheme:C}=Zn(),k=c.useMemo(()=>r?.tabs??[],[r?.tabs]),D=k.find(ge=>ge.id===r?.activeTabId)??k[k.length-1]??null,P=!!(r?.isOpen&&D),I=!!(P&&r?.expanded),[M,_]=c.useState(null),O=D?.mode??null,U=O?r?.widthByMode?.[O]:void 0,L=O?r?.widthFractionByMode?.[O]:void 0,F=O?sh(O):.5,R=M??(typeof window<"u"?window.innerWidth:rf*2),j=L!=null&&M!=null?Math.round(L*M):U,A=lc(j??Math.round(F*R));c.useEffect(()=>{!n||!O||L!=null||U==null||M==null||u(n,O,U,M)},[O,M,n,U,L,u]);const B=c.useMemo(()=>{const ge=[];for(const Ye of k){if(Ye.mode!=="chat")continue;const bt=ea(Ye.dedupeKey);bt&&!ge.includes(bt)&&ge.push(bt)}return ge},[k]),X=cS(n||void 0,B),[H,Z]=c.useState(!1),ce=c.useRef(0),Y=c.useRef(A),se=c.useRef(null),oe=c.useRef(null),Se=c.useRef(null),K=c.useRef(new Map),pe=c.useRef(new Map),je=c.useRef(!1);c.useLayoutEffect(()=>{const ge=Se.current?.parentElement;if(!ge||typeof ResizeObserver>"u")return;const Ye=new ResizeObserver(()=>{_(ge.clientWidth||null)});return Ye.observe(ge),_(ge.clientWidth||null),()=>Ye.disconnect()},[]),c.useEffect(()=>{if(!P||je.current){je.current=P;return}const ge=window.requestAnimationFrame(()=>{Se.current?.focus({preventScroll:!0})});return je.current=!0,()=>window.cancelAnimationFrame(ge)},[P]);const ne=c.useRef(null),T=c.useRef(null),G=c.useCallback(()=>{T.current=null;const ge=Se.current,Ye=se.current;!ge||Ye===null||ge.style.setProperty("--oc-context-panel-width",`${Ye}px`)},[]);c.useEffect(()=>()=>{T.current!==null&&clearTimeout(T.current)},[]);const le=c.useCallback(ge=>{const Ye=lc(ge),bt=ne.current;return bt===null?Ye:Math.min(Ye,Math.max(1,bt))},[]),de=c.useCallback(ge=>{!P||I||!n||(oe.current=ge.pointerId,Z(!0),ce.current=ge.clientX,Y.current=A,se.current=A,ne.current=Zw(Se.current),document.documentElement.style.cursor="col-resize",ge.preventDefault())},[n,I,P,A]),ue=c.useCallback(()=>{const ge=le(se.current??A),Ye=ne.current;se.current=null,ne.current=null,T.current!==null&&(clearTimeout(T.current),T.current=null),document.documentElement.style.cursor="",n&&O&&u(n,O,ge,Ye??void 0),Z(!1),oe.current=null},[O,le,n,u,A]);c.useEffect(()=>{if(!H)return;const ge=jt=>{if(oe.current!==jt.pointerId)return;const fe=ce.current-jt.clientX,ze=le(Y.current+fe);se.current!==ze&&(se.current=ze,T.current===null&&(T.current=setTimeout(G,Yw)))},Ye=jt=>{oe.current===jt.pointerId&&ue()},bt=()=>{ue()};return window.addEventListener("pointermove",ge),window.addEventListener("pointerup",Ye),window.addEventListener("pointercancel",Ye),window.addEventListener("blur",bt),()=>{window.removeEventListener("pointermove",ge),window.removeEventListener("pointerup",Ye),window.removeEventListener("pointercancel",Ye),window.removeEventListener("blur",bt)}},[G,le,ue,H]),c.useEffect(()=>{H||(se.current=null,document.documentElement.style.cursor="")},[H]);const Oe=c.useCallback(()=>{n&&i(n)},[i,n]),me=c.useCallback(()=>{n&&a(n)},[n,a]),Re=c.useCallback(ge=>{ge.key==="Escape"&&(nh(ge.target)||(ge.preventDefault(),ge.stopPropagation(),Oe()))},[Oe]);c.useEffect(()=>{if(!(!n||!D)&&D.mode==="file"&&D.targetPath){p(n,D.targetPath,{allowOutsideRoot:!0});return}},[D,n,p]);const ye=c.useMemo(()=>k.filter(ge=>ge.mode==="chat"),[k]),q=P&&D?.mode==="chat"?D.id:null,we=P&&D?.mode==="chat"?ea(D.dedupeKey):null,be=Xg(ye,q);c.useEffect(()=>{if(!P||!n||!we||typeof window>"u")return;const ge=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ei(n,we,!1);return}Rd(we),ei(n,we,!0)};ge();const Ye=window.setInterval(ge,1e4);return window.addEventListener("focus",ge),window.addEventListener("blur",ge),document.addEventListener("visibilitychange",ge),()=>{window.clearInterval(Ye),window.removeEventListener("focus",ge),window.removeEventListener("blur",ge),document.removeEventListener("visibilitychange",ge),ei(n,we,!1)}},[we,n,P]);const Ne=c.useCallback((ge,Ye,bt)=>Jg(pe.current,ge,Ye,n||null,bt,{mode:b,lightThemeId:v,darkThemeId:N,currentTheme:C},{allowPromptingSubagentSessions:m}),[m,C,N,n,v,b]),ie=be&&we?Ne(be.id,we,be.readOnly):null;c.useEffect(()=>{const ge=new Set(k.map(Ye=>Ye.id));for(const Ye of pe.current.keys())ge.has(Ye)||pe.current.delete(Ye)},[k]);const ee=c.useCallback(ge=>{!n||D?.mode!=="diff"||l(n,{mode:"diff",targetPath:D.targetPath,stagedDiff:ge==="staged",diffScope:ge})},[D,n,l]),V=c.useCallback(()=>{if(typeof window>"u")return;const ge={themeMode:b,lightThemeId:v,darkThemeId:N,currentTheme:C};for(const Ye of K.current.values()){const bt=Ye.contentWindow;bt&&bt.postMessage({type:"aiworker:theme-sync",payload:ge},window.location.origin)}},[C,N,v,b]),$=c.useCallback(()=>{if(typeof window>"u")return;const ge={allowPromptingSubagentSessions:m};for(const Ye of K.current.values()){const bt=Ye.contentWindow;bt&&bt.postMessage({type:"aiworker:chat-settings-sync",payload:ge},window.location.origin)}},[m]),ae=c.useCallback((ge,Ye,bt)=>{const jt=Ye.contentWindow;jt&&jt.postMessage({type:gu,payload:{visible:q===ge}},bt)},[q]),W=c.useCallback(()=>{if(!(typeof window>"u"))for(const[ge,Ye]of K.current.entries())ae(ge,Ye,window.location.origin)},[ae]);c.useEffect(()=>{if(typeof window>"u")return;const ge=Ye=>{if(Ye.origin!==window.location.origin)return;const bt=Array.from(K.current.entries()).find(([,$e])=>$e.contentWindow===Ye.source);if(!bt)return;const jt=Ye.data;if(jt?.type===Zg){const[$e,J]=bt;ae($e,J,Ye.origin);return}if(jt?.type===ex){if(typeof jt.requestId!="string"||!jt.requestId)return;const $e=us(),J={apiBaseUrl:Nn(),clientToken:$r(),localOrigin:typeof window.__AIWORKER_LOCAL_ORIGIN__=="string"?window.__AIWORKER_LOCAL_ORIGIN__:"",runtimeHeaders:fd(),relayHostId:$e.startsWith("host:")?$e.slice(5):"",relay:am()??void 0};Ye.source?.postMessage({type:tx,requestId:jt.requestId,payload:J},Ye.origin);return}if(jt?.type==="aiworker:theme-sync-request"){V();return}if(jt?.type==="aiworker:chat-settings-request"){$();return}if(jt?.type!=="aiworker:cycle-theme-request")return;const fe=["light","dark","system"],it=(fe.indexOf(b)+1)%fe.length;y(fe[it])};return window.addEventListener("message",ge),()=>window.removeEventListener("message",ge)},[$,ae,V,y,b]),c.useLayoutEffect(()=>{k.some(Ye=>Ye.mode==="chat")&&(V(),$(),W())},[N,v,$,W,V,k,b]);const ve=D?.mode==="file"||D?.mode==="chat"||D?.mode==="browser",Fe=c.useMemo(()=>D?k.filter(ge=>ge.mode===D.mode):[],[D,k]),Ce=c.useMemo(()=>Fe.map(ge=>{const Ye=sS(ge,X,t),bt=dS(Ye,Xw),jt=eS(ge.targetPath,e);return{id:ge.id,label:bt,icon:cc(ge,x),title:jt?`${Ye}: ${jt}`:Ye,closeLabel:t("contextPanel.tab.closeTabAria",{label:bt})}}),[Fe,e,x,X,t]),ke=D?.mode==="context"?s.jsx(Uy,{}):D?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Kw,{isActive:P})}):D?.mode==="pr"?s.jsx(Jb,{}):D?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Hw,{})}):D?.mode==="notes"?s.jsx(ug,{}):D?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Gw,{targetPath:D.targetPath,savedProjectPlan:D.projectPlanId&&D.projectPlanRef?{projectRef:D.projectPlanRef,planId:D.projectPlanId}:null})}):null,Qe=c.useMemo(()=>k.filter(ge=>ge.mode==="browser"),[k]),We=c.useMemo(()=>k.filter(ge=>ge.mode==="diff"),[k]),z=c.useMemo(()=>k.find(ge=>ge.mode==="terminal")??null,[k]),he=c.useMemo(()=>k.some(ge=>ge.mode==="walkthrough"),[k]),Be=c.useMemo(()=>k.some(ge=>ge.mode==="file"),[k]),Ae=c.useMemo(()=>k.some(ge=>ge.mode==="file"&&ge.targetPath),[k]),at=D?.mode==="file",Ue=Te(ge=>ge.closeContextPanelTabs),ht=c.useCallback(ge=>{if(!n)return null;const{id:Ye,index:bt,allIds:jt,close:fe}=ge,ze=()=>Ue(n,jt.filter(Ve=>Ve!==Ye)),it=()=>Ue(n,jt.slice(0,bt)),$e=()=>Ue(n,jt.slice(bt+1)),J=()=>Ue(n,jt),re=jt.length>1,Pe=bt===0,_e=bt===jt.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Un,{onClick:fe,children:[s.jsx(E,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Oi,{}),s.jsxs(Un,{onClick:ze,disabled:!re,children:[s.jsx(E,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Un,{onClick:it,disabled:Pe,children:[s.jsx(E,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Un,{onClick:$e,disabled:_e,children:[s.jsx(E,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Oi,{}),s.jsxs(Un,{onClick:J,disabled:!re,children:[s.jsx(E,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[Ue,n,t]),ut=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ve?s.jsx(su,{items:Ce,activeId:D?.id??null,onSelect:ge=>{n&&d(n,ge)},onClose:ge=>{n&&o(n,ge)},onReorder:(ge,Ye)=>{n&&f(n,ge,Ye)},layoutMode:"scrollable",variant:"default",tabContextMenu:ht}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[D?cc(D,x):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:D?of(D.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[D?.mode==="browser"?s.jsx(xt,{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(E,{name:"add",className:"h-3.5 w-3.5"})}):null,at?s.jsx(xt,{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":g,children:s.jsx(E,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,s.jsx(xt,{type:"button",variant:"ghost",size:"sm",onClick:me,className:"h-7 w-7 p-0",title:t(I?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(I?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:I?s.jsx(E,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(xt,{type:"button",variant:"ghost",size:"sm",onClick:Oe,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Ct=P?I?{"--oc-context-panel-width":M!==null?`${M}px`:"100%",width:M!==null?`${M}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${A}px`}:{"--oc-context-panel-width":`${A}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:Se,"data-context-panel":"true",tabIndex:-1,inert:!P||void 0,className:Ie("flex min-h-0 flex-col overflow-hidden bg-background",I?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!P&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:Re,style:Ct,children:[P&&!I&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),P&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!I&&s.jsx("div",{className:Ie("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",H&&"bg-[var(--interactive-border)]"),onPointerDown:de,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Ie("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!P&&"pointer-events-none select-none opacity-0"),style:{width:I?M!==null?`${M}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!P,children:[ut,s.jsxs("div",{className:Ie("relative min-h-0 flex-1 overflow-hidden",H&&"pointer-events-none"),children:[Be?s.jsxs("div",{className:Ie("absolute inset-0 flex",at?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:Ae?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Uw,{mode:"editor-only",visible:P&&at})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(E,{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(iS,{visible:g,active:P&&at})]}):null,be&&we&&ie?s.jsx("iframe",{ref:ge=>{if(!ge){K.current.delete(be.id);return}K.current.set(be.id,ge)},src:ie,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:we}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{V(),$(),W()}},be.id):null,Qe.map(ge=>s.jsx("div",{className:Ie("absolute inset-0",D?.id!==ge.id&&"hidden"),children:s.jsx(Bw,{initialUrl:ge.targetPath??"",directory:n,tabID:ge.id})},ge.id)),We.map(ge=>s.jsx("div",{className:Ie("absolute inset-0",D?.id!==ge.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Vw,{visible:P&&D?.id===ge.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:ge.diffScope??(ge.stagedDiff?"staged":"working"),onDiffScopeChange:ee,targetFilePath:ge.targetPath,flushContent:!0})})},ge.id)),z?s.jsx("div",{className:Ie("absolute inset-0",D?.mode==="terminal"?"block":"hidden"),children:s.jsx(fg,{visible:P&&D?.mode==="terminal",directory:z.targetDirectory})}):null,he?s.jsx("div",{className:Ie("absolute inset-0",D?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(zw,{directory:e,visible:P&&D?.mode==="walkthrough"})})}):null,D?.mode!=="chat"&&!at&&D?.mode!=="browser"&&D?.mode!=="diff"&&D?.mode!=="terminal"&&D?.mode!=="walkthrough"?ke:null]})]})]})},fS=t=>{const e=st.c(42),{open:n,onOpenChange:r}=t,{t:i}=Nt(),o=Te(mS),l=Te(hS),a=Te(pS),u=Te(gS);let d;e[0]!==o?(d=Ed(o),e[0]=o,e[1]=d):d=e[1];const h=d,f=l.length===0;let p;if(e[2]!==l||e[3]!==h){let D;e[5]!==l?(D=P=>l.includes(P.id),e[5]=l,e[6]=D):D=e[6],p=h.every(D),e[2]=l,e[3]=h,e[4]=p}else p=e[4];const g=p;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(Rs,{children:w}),e[9]=w,e[10]=S):S=e[10];let x;e[11]!==i?(x=i("contextRail.configure.dialogDescription"),e[11]=i,e[12]=x):x=e[12];let m;e[13]!==x?(m=s.jsx(Es,{children:x}),e[13]=x,e[14]=m):m=e[14];let b;e[15]!==S||e[16]!==m?(b=s.jsxs($s,{children:[S,m]}),e[15]=S,e[16]=m,e[17]=b):b=e[17];let y;if(e[18]!==l||e[19]!==a||e[20]!==h||e[21]!==i){let D;e[23]!==l||e[24]!==a||e[25]!==i?(D=P=>s.jsx(rh,{settingsItem:`layout.context-rail.surface.${P.id}`,checked:!l.includes(P.id),onChange:I=>a(P.id,I),label:i(P.labelKey),ariaLabel:i(P.labelKey)},P.id),e[23]=l,e[24]=a,e[25]=i,e[26]=D):D=e[26],y=h.map(D),e[18]=l,e[19]=a,e[20]=h,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]!==f||e[30]!==g||e[31]!==u||e[32]!==i?(N=f?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[g?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(xt,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[29]=f,e[30]=g,e[31]=u,e[32]=i,e[33]=N):N=e[33];let C;e[34]!==N||e[35]!==b||e[36]!==v?(C=s.jsxs(js,{className:"max-w-md",children:[b,v,N]}),e[34]=N,e[35]=b,e[36]=v,e[37]=C):C=e[37];let k;return e[38]!==r||e[39]!==n||e[40]!==C?(k=s.jsx(vs,{open:n,onOpenChange:r,children:C}),e[38]=r,e[39]=n,e[40]=C,e[41]=k):k=e[41],k};function mS(t){return t.contextRailOrder}function hS(t){return t.contextRailHiddenSurfaces}function pS(t){return t.setContextRailSurfaceVisible}function gS(t){return t.setContextRailHiddenSurfaces}const af=150,xS=500,bS=[],yS=t=>t>99?"99+":String(t),wS=t=>{const e=st.c(51),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:u,badgeDescription:d,orderNumber:h,showOrderNumber:f,onSelect:p}=t;let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:w,listeners:S,setNodeRef:x,transform:m,transition:b,isDragging:y}=Qo(g);let v;e[2]!==a?(v=a!=null&&a>0?yS(a):null,e[2]=a,e[3]=v):v=e[3];const N=v;let C;e[4]!==m?(C=Yo.Translate.toString(m),e[4]=m,e[5]=C):C=e[5];let k;e[6]!==C||e[7]!==b?(k={transform:C,transition:b},e[6]=C,e[7]=b,e[8]=k):k=e[8];const D=y&&"z-10 opacity-70";let P;e[9]!==D?(P=Ie("relative",D),e[9]=D,e[10]=P):P=e[10];let I;e[11]!==p||e[12]!==n?(I=()=>p(n),e[11]=p,e[12]=n,e[13]=I):I=e[13];const M=u??o,_=r?"text-primary":"text-muted-foreground hover:text-foreground";let O;e[14]!==_?(O=Ie("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",_),e[14]=_,e[15]=O):O=e[15];let U;e[16]!==n.icon||e[17]!==n.id?(U=n.id==="diff"?s.jsx(Eu,{}):s.jsx(E,{name:n.icon,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.id,e[18]=U):U=e[18];let L;e[19]!==N||e[20]!==h||e[21]!==i||e[22]!==f?(L=f&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):N?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:N}):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]=h,e[21]=i,e[22]=f,e[23]=L):L=e[23];let F;e[24]!==w||e[25]!==r||e[26]!==S||e[27]!==O||e[28]!==U||e[29]!==L||e[30]!==I||e[31]!==M?(F=s.jsx(Dt,{asChild:!0,children:s.jsxs("button",{type:"button",...w,...S,onClick:I,"aria-label":M,"aria-pressed":r,className:O,children:[U,L]})}),e[24]=w,e[25]=r,e[26]=S,e[27]=O,e[28]=U,e[29]=L,e[30]=I,e[31]=M,e[32]=F):F=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 A;e[37]!==d?(A=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[37]=d,e[38]=A):A=e[38];let B;e[39]!==R||e[40]!==j||e[41]!==A?(B=s.jsx(Pt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[R,j,A]})}),e[39]=R,e[40]=j,e[41]=A,e[42]=B):B=e[42];let X;e[43]!==F||e[44]!==B?(X=s.jsxs(At,{delayDuration:af,children:[F,B]}),e[43]=F,e[44]=B,e[45]=X):X=e[45];let H;return e[46]!==x||e[47]!==X||e[48]!==k||e[49]!==P?(H=s.jsx("div",{ref:x,style:k,className:P,children:X}),e[46]=x,e[47]=X,e[48]=k,e[49]=P,e[50]=H):H=e[50],H},SS=()=>{const t=st.c(86),{t:e}=Nt(),n=er();let r;t[0]!==n?(r=n?or(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=we=>i?we.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Te(o),a=Te(vS),u=Te(jS),d=Te(kS),h=Te(CS),f=Te(NS),p=Te(AS),g=Te(DS),w=ba(PS),S=Ni(IS),x=Ni(TS),m=An(RS),b=An(ES),{screenWidth:y}=_n(),v=ya(i||null);let N;t[4]!==g?(N=Ai("switch_context_surface",g),t[4]=g,t[5]=N):N=t[5];const C=N,[k,D]=c.useState(!1);let P,I;t[6]!==C?(P=()=>{const we=new Set;let be=null,Ne=!1;const ie=MS,ee=()=>{rl(C,we)?!Ne&&be===null&&(be=setTimeout(()=>D(!0),xS)):(Ne=!1,be!==null&&(clearTimeout(be),be=null),D(!1))},V=W=>{if(we.add(W.key.toLowerCase()),ie(W.key)&&rl(C,we)){Ne=!0,be!==null&&(clearTimeout(be),be=null),D(!1);return}ee()},$=W=>{we.delete(W.key.toLowerCase()),ee()},ae=()=>{we.clear(),Ne=!1,be!==null&&(clearTimeout(be),be=null),D(!1)};return window.addEventListener("keydown",V,!0),window.addEventListener("keyup",$,!0),window.addEventListener("blur",ae),()=>{window.removeEventListener("keydown",V,!0),window.removeEventListener("keyup",$,!0),window.removeEventListener("blur",ae),be!==null&&clearTimeout(be)}},I=[C],t[6]=C,t[7]=P,t[8]=I):(P=t[7],I=t[8]),c.useEffect(P,I);let M;t[9]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{distance:8}},t[9]=M):M=t[9];let _;t[10]===Symbol.for("react.memo_cache_sentinel")?(_={activationConstraint:{delay:200,tolerance:6}},t[10]=_):_=t[10];const O=Vr(On(cu,M),On(lu,_)),U=l?.tabs??bS;let L;t[11]!==l?.activeTabId||t[12]!==U?(L=U.find(we=>we.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=U,t[13]=L):L=t[13];const F=L,R=l?.isOpen?F?.mode??null:null,j=v?.files.length??0;let A;t[14]!==d||t[15]!==u||t[16]!==b||t[17]!==x||t[18]!==w||t[19]!==y||t[20]!==U?(A=oh({railOrder:u,hiddenSurfaces:d,planModeEnabled:w,isVSCode:Pn(),screenWidth:y,tabs:U,linearConnected:x,githubConnected:b}),t[14]=d,t[15]=u,t[16]=b,t[17]=x,t[18]=w,t[19]=y,t[20]=U,t[21]=A):A=t[21];const B=A;let X,H;t[22]!==R||t[23]!==p||t[24]!==i||t[25]!==S||t[26]!==x?(H=()=>{!i||!S||x||R!=="linear"||p(i)},X=[R,p,i,S,x],t[22]=R,t[23]=p,t[24]=i,t[25]=S,t[26]=x,t[27]=X,t[28]=H):(X=t[27],H=t[28]),c.useEffect(H,X);let Z,ce;t[29]!==R||t[30]!==p||t[31]!==i||t[32]!==m||t[33]!==b?(Z=()=>{!i||!m||b||R!=="pr"||p(i)},ce=[R,p,i,m,b],t[29]=R,t[30]=p,t[31]=i,t[32]=m,t[33]=b,t[34]=Z,t[35]=ce):(Z=t[34],ce=t[35]),c.useEffect(Z,ce);const[Y,se]=c.useState(!1);let oe;t[36]!==h?(oe=we=>{const{active:be,over:Ne}=we;if(!Ne||be.id===Ne.id)return;const ie=Ed(Te.getState().contextRailOrder).map(OS),ee=ie.indexOf(be.id),V=ie.indexOf(Ne.id);ee===-1||V===-1||h(du(ie,ee,V))},t[36]=h,t[37]=oe):oe=t[37];const Se=oe;if(!i)return null;let K;t[38]!==e?(K=e("contextRail.aria.rail"),t[38]=e,t[39]=K):K=t[39];let pe;t[40]!==B?(pe=B.map(FS),t[40]=B,t[41]=pe):pe=t[41];let je;if(t[42]!==R||t[43]!==j||t[44]!==i||t[45]!==f||t[46]!==k||t[47]!==B||t[48]!==e||t[49]!==a){let we;t[51]!==R||t[52]!==j||t[53]!==i||t[54]!==f||t[55]!==k||t[56]!==e||t[57]!==a?(we=(be,Ne)=>{const ie=e(be.labelKey),ee=be.id==="git"&&!a?j:0,V=ee>0?ee:null;return s.jsx(wS,{surface:be,isActive:R===be.mode,showActivityDot:!1,label:ie,description:e(be.descriptionKey),badgeCount:V,badgeAriaLabel:V!==null?e(V===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ie,count:V}):null,badgeDescription:V!==null?e(V===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:V}):null,orderNumber:Ne+1,showOrderNumber:k,onSelect:$=>f(i,$.mode)},be.id)},t[51]=R,t[52]=j,t[53]=i,t[54]=f,t[55]=k,t[56]=e,t[57]=a,t[58]=we):we=t[58],je=B.map(we),t[42]=R,t[43]=j,t[44]=i,t[45]=f,t[46]=k,t[47]=B,t[48]=e,t[49]=a,t[50]=je}else je=t[50];let ne;t[59]!==pe||t[60]!==je?(ne=s.jsx(Io,{items:pe,strategy:_i,children:je}),t[59]=pe,t[60]=je,t[61]=ne):ne=t[61];let T;t[62]!==Se||t[63]!==O||t[64]!==ne?(T=s.jsx(Ur,{sensors:O,collisionDetection:Kr,onDragEnd:Se,children:ne}),t[62]=Se,t[63]=O,t[64]=ne,t[65]=T):T=t[65];let G;t[66]!==e?(G=e("contextRail.configure.open"),t[66]=e,t[67]=G):G=t[67];let le;t[68]===Symbol.for("react.memo_cache_sentinel")?(le=()=>se(!0),t[68]=le):le=t[68];let de;t[69]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(E,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[69]=de):de=t[69];let ue;t[70]!==G?(ue=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":G,onClick:le,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:de})}),t[70]=G,t[71]=ue):ue=t[71];let Oe;t[72]!==e?(Oe=e("contextRail.configure.open"),t[72]=e,t[73]=Oe):Oe=t[73];let me;t[74]!==Oe?(me=s.jsx(Pt,{side:"left",sideOffset:8,children:Oe}),t[74]=Oe,t[75]=me):me=t[75];let Re;t[76]!==ue||t[77]!==me?(Re=s.jsxs(At,{delayDuration:af,children:[ue,me]}),t[76]=ue,t[77]=me,t[78]=Re):Re=t[78];let ye;t[79]!==Y?(ye=s.jsx(fS,{open:Y,onOpenChange:se}),t[79]=Y,t[80]=ye):ye=t[80];let q;return t[81]!==K||t[82]!==T||t[83]!==Re||t[84]!==ye?(q=s.jsxs("nav",{"aria-label":K,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[T,Re,ye]}),t[81]=K,t[82]=T,t[83]=Re,t[84]=ye,t[85]=q):q=t[85],q};function vS(t){return t.workStatusPanelVisible}function jS(t){return t.contextRailOrder}function kS(t){return t.contextRailHiddenSurfaces}function CS(t){return t.setContextRailOrder}function NS(t){return t.openContextSurface}function AS(t){return t.closeContextPanel}function DS(t){return t.shortcutOverrides}function PS(t){return t.planModeEnabled}function IS(t){return t.hasChecked}function TS(t){return t.status?.connected===!0}function RS(t){return t.hasChecked}function ES(t){return t.status?.connected===!0}function MS(t){return t.length===1&&t>="0"&&t<="9"}function OS(t){return t.id}function FS(t){return t.id}const BS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),_S=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Er(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),LS=new Set,$S=[],ta=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},WS=()=>{const t=st.c(182),{t:e}=Nt(),n=Te(zS),r=Te(VS),i=Te(US),o=Te(KS),l=Te(HS),a=Te(GS),u=Te(qS),d=Te(QS),h=Te(YS),f=Te(XS),p=Te(JS),g=Te(ZS),w=Te(ev),S=Je(tv),x=Je(sv),m=Je(nv),b=Wr(rv);let y;t[0]!==n?(y=Xe=>n?Xe.activeSessions:$S,t[0]=n,t[1]=y):y=t[1];const v=Is(y);let N;t[2]!==n?(N=Xe=>n?Xe.ids:LS,t[2]=n,t[3]=N):N=t[3];const C=Wr(N);let k;t[4]!==n?(k=Xe=>n?Xe.rankById:Od,t[4]=n,t[5]=k):k=t[5];const D=ja(k),P=ts(ov),I=Ht(iv),M=Ht(av),_=er(),O=dd(lv),{files:U,git:L}=Sn(),F=Dn(cv),{isMobile:R}=_n();let j;t[6]!==_?(j=_?ta(_):null,t[6]=_,t[7]=j):j=t[7];const A=j,[B,X]=c.useState(""),Z=va(B,200).trim();let ce;t[8]!==B?(ce=B.trim(),t[8]=B,t[9]=ce):ce=t[9];const Y=ce;let se,oe;t[10]!==n?(se=()=>{n&&X("")},oe=[n],t[10]=n,t[11]=se,t[12]=oe):(se=t[11],oe=t[12]),c.useEffect(se,oe);let Se,K;t[13]!==v||t[14]!==F||t[15]!==L||t[16]!==n?(Se=()=>{if(!n||!L)return;const Xe=setTimeout(()=>{const nt=new Set;for(const St of v){const yt=Ts(St);!yt||nt.has(yt)||(nt.add(yt),F(yt,L))}},0);return()=>clearTimeout(Xe)},K=[n,v,L,F],t[13]=v,t[14]=F,t[15]=L,t[16]=n,t[17]=Se,t[18]=K):(Se=t[17],K=t[18]),c.useEffect(Se,K);let pe;t[19]!==r?(pe=()=>r(!1),t[19]=r,t[20]=pe):pe=t[20];const je=pe;let ne;t[21]!==je?(ne=Xe=>()=>{je(),Xe()},t[21]=je,t[22]=ne):ne=t[22];const T=ne;let G;t[23]!==I?.id||t[24]!==I?.path||t[25]!==P||t[26]!==m||t[27]!==R||t[28]!==u||t[29]!==d||t[30]!==p||t[31]!==S||t[32]!==T||t[33]!==g||t[34]!==w||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==b||t[39]!==a?(G=()=>{const Xe=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(E,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:T(()=>{l(!1),S()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(E,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:T(dv)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(E,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:T(uv)},{id:"toggle-sidebar",title:e(R?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(E,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(R?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:T(()=>{if(R){const{isSessionSwitcherOpen:nt}=Te.getState();l(!nt)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(E,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:T(()=>{P&&d(P,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(E,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:T(()=>{P&&u(P)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(E,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:T(fv)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(E,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:T(mv)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(E,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:T(()=>i(!0))}];return Xe.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(E,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:T(()=>{m&&P&&b({directory:P,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(E,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:T(()=>{m&&gn(m).then(nt=>{if(nt.ok){Le.success(e("sessions.sidebar.session.copyId.success"));return}Le.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(E,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:T(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(E,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:T(()=>{l(!1),g(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(E,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:T(()=>{P&&(w("notes"),d(P,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(E,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:T(()=>{P&&(w("todos"),d(P,"notes"))})}),Xe.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(E,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:T(hv)}),Vo()&&Xe.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(E,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:T(()=>{Mn("desktop_open_draft_mini_chat_window",{directory:ta(P||I?.path||""),projectId:I?.id??null}).catch(pv)})}),Xe},t[23]=I?.id,t[24]=I?.path,t[25]=P,t[26]=m,t[27]=R,t[28]=u,t[29]=d,t[30]=p,t[31]=S,t[32]=T,t[33]=g,t[34]=w,t[35]=l,t[36]=i,t[37]=e,t[38]=b,t[39]=a,t[40]=G):G=t[40],I?.id,I?.path;let le;t[41]!==G?(le=G(),t[41]=G,t[42]=le):le=t[42];const de=le;let ue;t[43]===Symbol.for("react.memo_cache_sentinel")?(ue=bn(),t[43]=ue):ue=t[43];const Oe=ue;let me,Re;t[44]===Symbol.for("react.memo_cache_sentinel")?(me=Pn(),Re=!Oe&&ha(),t[44]=me,t[45]=Re):(me=t[44],Re=t[45]);let ye;t[46]!==R?(ye={isVSCode:me,isWeb:Re,isDesktop:Oe,isMobile:R},t[46]=R,t[47]=ye):ye=t[47];const q=ye;let we;if(t[48]!==T||t[49]!==i||t[50]!==o||t[51]!==q){let Xe;t[53]!==q?(Xe=St=>St.isAvailable?St.isAvailable(q):!0,t[53]=q,t[54]=Xe):Xe=t[54];let nt;t[55]!==T||t[56]!==i||t[57]!==o?(nt=St=>{const yt=hg(St.slug)??"settings-3",It=(St.keywords??[]).join(" ");return{id:`settings:${St.slug}`,title:St.title,icon:St.slug==="mcp"?s.jsx(dh,{className:"mr-2 h-4 w-4"}):s.jsx(E,{name:yt,className:"mr-2 h-4 w-4"}),searchText:`${St.title} ${St.group} ${It}`,onSelect:T(()=>{o(St.slug),i(!0)})}},t[55]=T,t[56]=i,t[57]=o,t[58]=nt):nt=t[58],we=mg.filter(gv).filter(Xe).map(nt),t[48]=T,t[49]=i,t[50]=o,t[51]=q,t[52]=we}else we=t[52];const be=we;let Ne;if(t[59]!==v||t[60]!==C||t[61]!==D){const Xe=v.filter(xv);Ne=ih(Xe,C,D),t[59]=v,t[60]=C,t[61]=D,t[62]=Ne}else Ne=t[62];const ie=Ne,ee=Md(),V=Je(bv);let $;t[63]!==ee||t[64]!==V?($=(Xe,nt)=>{const St=V.get(Xe);return St?.branch?St.branch.trim()||null:nt&&ee.get(nt)?.trim()||null},t[63]=ee,t[64]=V,t[65]=$):$=t[65];const ae=$;let W;t[66]===Symbol.for("react.memo_cache_sentinel")?(W=[],t[66]=W):W=t[66];const[ve,Fe]=c.useState(W),[Ce,ke]=c.useState(""),Qe=BS(A,Z);let We;t[67]!==A||t[68]!==Qe||t[69]!==n||t[70]!==O||t[71]!==Fe||t[72]!==ke||t[73]!==Z?(We=()=>{if(!n){Fe([]),ke("");return}if(!Qe){Fe([]),ke("");return}if(!A){Fe([]),ke("");return}let Xe=!1;return O(A,Z,40,{type:"file"}).then(nt=>{Xe||(Fe(nt.map(yv)),ke(Qe))}).catch(()=>{Xe||(Fe([]),ke(Qe))}),()=>{Xe=!0}},t[67]=A,t[68]=Qe,t[69]=n,t[70]=O,t[71]=Fe,t[72]=ke,t[73]=Z,t[74]=We):We=t[74];let z;t[75]!==A||t[76]!==Qe||t[77]!==n||t[78]!==O||t[79]!==Z?(z=[n,A,Z,Qe,O],t[75]=A,t[76]=Qe,t[77]=n,t[78]=O,t[79]=Z,t[80]=z):z=t[80],c.useEffect(We,z);const he=Y.length>0;let Be;e:{if(!he){let nt;t[81]!==de?(nt=de.filter(wv).map(Sv),t[81]=de,t[82]=nt):nt=t[82],Be=nt;break e}let Xe;t[83]!==de||t[84]!==Y?(Xe=Er(de,Y,vv,{limit:7,noFuzzy:!0}),t[83]=de,t[84]=Y,t[85]=Xe):Xe=t[85],Be=Xe}const Ae=Be;let at;e:{if(!he){let nt;t[86]===Symbol.for("react.memo_cache_sentinel")?(nt=[],t[86]=nt):nt=t[86],at=nt;break e}let Xe;t[87]!==Y||t[88]!==be?(Xe=Er(be,Y,jv,{limit:7,noFuzzy:!0}),t[87]=Y,t[88]=be,t[89]=Xe):Xe=t[89],at=Xe}const Ue=at;let ht;e:{if(!he){let nt;t[90]!==ie?(nt=ie.slice(0,5).map(kv),t[90]=ie,t[91]=nt):nt=t[91],ht=nt;break e}let Xe;t[92]!==Y||t[93]!==ie?(Xe=Er(ie,Y,Cv,{limit:7,threshold:.2}),t[92]=Y,t[93]=ie,t[94]=Xe):Xe=t[94],ht=Xe}const ut=ht;let Ct;e:{if(!n){let nt;t[95]===Symbol.for("react.memo_cache_sentinel")?(nt=[],t[95]=nt):nt=t[95],Ct=nt;break e}let Xe;t[96]!==ve||t[97]!==Ce||t[98]!==Qe||t[99]!==Z?(Xe=_S(ve,Z,Qe,Ce),t[96]=ve,t[97]=Ce,t[98]=Qe,t[99]=Z,t[100]=Xe):Xe=t[100],Ct=Xe}const ge=Ct,Ye=n&&Qe.length>0&&Ce!==Qe;let bt;e:{if(!he){let nt;t[101]===Symbol.for("react.memo_cache_sentinel")?(nt=[],t[101]=nt):nt=t[101],bt=nt;break e}let Xe;if(t[102]!==Y||t[103]!==M){const nt=M.map(Nv);Xe=Er(nt,Y,Av,{limit:7,threshold:.4}),t[102]=Y,t[103]=M,t[104]=Xe}else Xe=t[104];bt=Xe}const jt=bt;let fe,ze,it,$e,J,re,Pe,_e,Ve,Ze,lt,rt,Ge,ot;if(t[105]!==ae||t[106]!==je||t[107]!==A||t[108]!==U||t[109]!==he||t[110]!==n||t[111]!==h||t[112]!==S||t[113]!==B||t[114]!==Ae||t[115]!==ge||t[116]!==jt||t[117]!==ut||t[118]!==Ue||t[119]!==r||t[120]!==x||t[121]!==f||t[122]!==e){const Xe=Ae.map(Dv),nt=Ue.map(Pv),St=ut.map(Iv),yt=he?ge.map(Tv):[],It=he?jt.map(Rv):[];let kt;e:{if(!he){kt=["commands","sessions"];break e}const ft=Ev,ct=[{key:"commands",score:ft(Ae)},{key:"settings",score:ft(Ue)},{key:"sessions",score:ft(ut)},{key:"files",score:ft(ge)},{key:"projects",score:ft(jt)}];ct.sort(Mv),kt=ct.map(Ov)}const Et=kt,Bt=ft=>{je(),x(ft.id,Ts(ft))},zt=async ft=>{if(!A)return;const ct=await _u(U,ft,{directory:A});if(!ct.ok){Le.error(Lu(ct.reason));return}h(A,ft),je()},Gt=(ft,ct)=>{je(),S({selectedProjectId:ft,directoryOverride:ct})},rs=ft=>qn(qr(ft,f));$e=vs,rt=n,Ge=r;let _t;t[137]!==e?(_t=e("commandPalette.title"),t[137]=e,t[138]=_t):_t=t[138];let Wt;t[139]!==_t?(Wt=s.jsx(Rs,{children:_t}),t[139]=_t,t[140]=Wt):Wt=t[140];let Me;t[141]!==e?(Me=e("commandPalette.description"),t[141]=e,t[142]=Me):Me=t[142];let qe;t[143]!==Me?(qe=s.jsx(Es,{children:Me}),t[143]=Me,t[144]=qe):qe=t[144],t[145]!==Wt||t[146]!==qe?(ot=s.jsxs($s,{className:"sr-only",children:[Wt,qe]}),t[145]=Wt,t[146]=qe,t[147]=ot):ot=t[147],it=js,Ze="overflow-hidden p-0",lt=!0,ze=uh,Pe=!1,_e="[&_[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 dt;t[148]!==e?(dt=e("commandPalette.input.placeholder"),t[148]=e,t[149]=dt):dt=t[149],t[150]!==B||t[151]!==dt?(Ve=s.jsx(fh,{value:B,onValueChange:X,placeholder:dt}),t[150]=B,t[151]=dt,t[152]=Ve):Ve=t[152],fe=mh;let wt;t[153]!==e?(wt=e("commandPalette.empty.noResults"),t[153]=e,t[154]=wt):wt=t[154],t[155]!==wt?(J=s.jsx(hh,{children:wt}),t[155]=wt,t[156]=J):J=t[156],re=Et.map(ft=>ft==="commands"&&Xe.length>0?s.jsx(jr,{children:Xe.map(ct=>s.jsxs(Mr,{value:ct.id,onSelect:ct.onSelect,children:[ct.icon,s.jsx("span",{children:ct.title}),ct.shortcutId?s.jsx(ah,{children:rs(ct.shortcutId)}):null]},ct.id))},"commands"):ft==="settings"&&nt.length>0?s.jsx(jr,{children:nt.map(Fv)},"settings"):ft==="sessions"&&St.length>0?s.jsx(jr,{children:St.map(ct=>{const Vt=ct.title||e("commandPalette.session.untitled"),Xt=Ts(ct),Jt=ae(ct.id,Xt);return s.jsxs(Mr,{value:`session:${ct.id}`,onSelect:()=>Bt(ct),children:[s.jsx(E,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:Vt}),Jt?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:Jt})]}):null]},ct.id)})},"sessions"):ft==="files"&&yt.length>0?s.jsx(jr,{children:yt.map(ct=>{const Vt=lh(ct.relativePath||ct.name,{maxLength:80});return s.jsxs(Mr,{value:`file:${ct.path}`,onSelect:()=>{zt(ct.path)},children:[s.jsx(Sa,{filePath:ct.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":ct.relativePath,children:Vt})]},`file:${ct.path}`)})},"files"):ft==="projects"&&It.length>0?s.jsx(jr,{children:It.map(ct=>{const Vt=ct.displayName;return s.jsxs(Mr,{value:`project:${ct.id}`,onSelect:()=>Gt(ct.id,ct.path),children:[s.jsx(E,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:Vt}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:ct.path})]},`project:${ct.id}`)})},"projects"):null),t[105]=ae,t[106]=je,t[107]=A,t[108]=U,t[109]=he,t[110]=n,t[111]=h,t[112]=S,t[113]=B,t[114]=Ae,t[115]=ge,t[116]=jt,t[117]=ut,t[118]=Ue,t[119]=r,t[120]=x,t[121]=f,t[122]=e,t[123]=fe,t[124]=ze,t[125]=it,t[126]=$e,t[127]=J,t[128]=re,t[129]=Pe,t[130]=_e,t[131]=Ve,t[132]=Ze,t[133]=lt,t[134]=rt,t[135]=Ge,t[136]=ot}else fe=t[123],ze=t[124],it=t[125],$e=t[126],J=t[127],re=t[128],Pe=t[129],_e=t[130],Ve=t[131],Ze=t[132],lt=t[133],rt=t[134],Ge=t[135],ot=t[136];let Ee;t[157]!==Ye||t[158]!==e?(Ee=Ye?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[157]=Ye,t[158]=e,t[159]=Ee):Ee=t[159];let Rt;t[160]!==fe||t[161]!==J||t[162]!==re||t[163]!==Ee?(Rt=s.jsxs(fe,{children:[J,re,Ee]}),t[160]=fe,t[161]=J,t[162]=re,t[163]=Ee,t[164]=Rt):Rt=t[164];let xe;t[165]!==ze||t[166]!==Pe||t[167]!==_e||t[168]!==Ve||t[169]!==Rt?(xe=s.jsxs(ze,{shouldFilter:Pe,className:_e,children:[Ve,Rt]}),t[165]=ze,t[166]=Pe,t[167]=_e,t[168]=Ve,t[169]=Rt,t[170]=xe):xe=t[170];let mt;t[171]!==it||t[172]!==Ze||t[173]!==lt||t[174]!==xe?(mt=s.jsx(it,{className:Ze,showCloseButton:lt,children:xe}),t[171]=it,t[172]=Ze,t[173]=lt,t[174]=xe,t[175]=mt):mt=t[175];let Tt;return t[176]!==$e||t[177]!==rt||t[178]!==Ge||t[179]!==ot||t[180]!==mt?(Tt=s.jsxs($e,{open:rt,onOpenChange:Ge,children:[ot,mt]}),t[176]=$e,t[177]=rt,t[178]=Ge,t[179]=ot,t[180]=mt,t[181]=Tt):Tt=t[181],Tt};function zS(t){return t.isCommandPaletteOpen}function VS(t){return t.setCommandPaletteOpen}function US(t){return t.setSettingsDialogOpen}function KS(t){return t.setSettingsPage}function HS(t){return t.setSessionSwitcherOpen}function GS(t){return t.toggleSidebar}function qS(t){return t.openContextOverview}function QS(t){return t.openContextSurface}function YS(t){return t.openContextFile}function XS(t){return t.shortcutOverrides}function JS(t){return t.openMultiRunLauncher}function ZS(t){return t.setArchivePageOpen}function ev(t){return t.setProjectContextTab}function tv(t){return t.openNewSessionDraft}function sv(t){return t.setCurrentSession}function nv(t){return t.currentSessionId}function rv(t){return t.toggle}function ov(t){return t.currentDirectory}function iv(t){return t.getActiveProject()}function av(t){return t.projects}function lv(t){return t.searchFiles}function cv(t){return t.ensureStatus}function dv(){Fd()}function uv(){xn.requestDirectoryDialog()}function fv(){ph.invoke("cycle_theme")}function mv(){Bd()}function hv(){window.dispatchEvent(new CustomEvent("aiworker:memory-debug-toggle"))}function pv(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function gv(t){return t.slug!=="home"}function xv(t){return!ch(t)}function bv(t){return t.worktreeMetadata}function yv(t){return{path:ta(t.path),name:t.name,relativePath:t.relativePath}}function wv(t){return!t.secondary}function Sv(t){return{item:t,score:0}}function vv(t){return t.searchText}function jv(t){return t.searchText}function kv(t){return{item:t,score:0}}function Cv(t){return t.title||""}function Nv(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Av(t){return t.searchText}function Dv(t){return t.item}function Pv(t){return t.item}function Iv(t){return t.item}function Tv(t){return t.item}function Rv(t){return t.item}function Ev(t){return t.length?t[0].score:1/0}function Mv(t,e){return t.score-e.score}function Ov(t){return t.key}function Fv(t){return s.jsxs(Mr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const dc=(t,e,n)=>qn(qr(t,e),n),Bv=()=>{const t=st.c(74),{t:e}=Nt(),n=Te(_v),r=Te(Lv),i=Te($v);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=Pn(),t[0]=o):o=t[0];const l=o;let a,u,d,h,f,p,g,w,S,x,m,b;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const j=[{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:[qn("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:[`${qn(Ai("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${qn(Ai("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=vs,m=n,b=r,u=js,S="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let A;t[17]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(E,{name:"command",className:"h-5 w-5"}),t[17]=A):A=t[17];let B;t[18]!==e?(B=e("helpDialog.title"),t[18]=e,t[19]=B):B=t[19];let X;t[20]!==B?(X=s.jsxs(Rs,{className:"flex items-center gap-2",children:[A,B]}),t[20]=B,t[21]=X):X=t[21];let H;t[22]!==e?(H=e("helpDialog.description"),t[22]=e,t[23]=H):H=t[23];let Z;t[24]!==H?(Z=s.jsx(Es,{children:H}),t[24]=H,t[25]=Z):Z=t[25],t[26]!==X||t[27]!==Z?(x=s.jsxs($s,{children:[X,Z]}),t[26]=X,t[27]=Z,t[28]=x):x=t[28],a=cn,p="flex-1 min-h-0 mt-3",g="pr-1",w=!0,h="space-y-4",f=j.map(ce=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(ce.categoryKey)}),s.jsx("div",{className:"space-y-1",children:ce.items.filter(Y=>!(l&&Y.id==="toggle_prompt_navigator")).map(Y=>{const se=Y.id?gh(Y.id):void 0,oe=Y.descriptionKey??(se?.customizable?se.settingsLabelKey:void 0);if(!oe||Y.id&&!qr(Y.id,i))return null;const Se=Y.id?dc(Y.id,i,e("settings.aiworker.keyboardShortcuts.unassigned")):Array.isArray(Y.keys)?Y.keys:Y.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:[Y.icon&&s.jsx(E,{name:Y.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(oe)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(Se)?Se:[Se]).map((K,pe)=>s.jsxs(c.Fragment,{children:[pe>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:K})]},`${K}-${pe}`))})]},Y.id||oe)})})]},ce.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=u,t[7]=d,t[8]=h,t[9]=f,t[10]=p,t[11]=g,t[12]=w,t[13]=S,t[14]=x,t[15]=m,t[16]=b}else a=t[5],u=t[6],d=t[7],h=t[8],f=t[9],p=t[10],g=t[11],w=t[12],S=t[13],x=t[14],m=t[15],b=t[16];let y;t[29]!==h||t[30]!==f?(y=s.jsx("div",{className:h,children:f}),t[29]=h,t[30]=f,t[31]=y):y=t[31];let v;t[32]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(E,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=v):v=t[32];let N;t[33]!==e?(N=e("helpDialog.proTips.title"),t[33]=e,t[34]=N):N=t[34];let C;t[35]!==N?(C=s.jsx("p",{className:"font-medium mb-1",children:N}),t[35]=N,t[36]=C):C=t[36];let k;t[37]!==i||t[38]!==e?(k=e("helpDialog.proTips.commandPalette",{shortcut:dc("open_command_palette",i,e("settings.aiworker.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=k):k=t[39];let D;t[40]!==k?(D=s.jsxs("li",{children:["• ",k]}),t[40]=k,t[41]=D):D=t[41];let P;t[42]!==e?(P=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=P):P=t[43];let I;t[44]!==P?(I=s.jsxs("li",{children:["• ",P]}),t[44]=P,t[45]=I):I=t[45];let M;t[46]!==e?(M=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=M):M=t[47];let _;t[48]!==M?(_=s.jsxs("li",{children:["• ",M]}),t[48]=M,t[49]=_):_=t[49];let O;t[50]!==D||t[51]!==I||t[52]!==_?(O=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[D,I,_]}),t[50]=D,t[51]=I,t[52]=_,t[53]=O):O=t[53];let U;t[54]!==C||t[55]!==O?(U=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[v,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[C,O]})]})}),t[54]=C,t[55]=O,t[56]=U):U=t[56];let L;t[57]!==a||t[58]!==y||t[59]!==U||t[60]!==p||t[61]!==g||t[62]!==w?(L=s.jsxs(a,{outerClassName:p,className:g,disableHorizontal:w,children:[y,U]}),t[57]=a,t[58]=y,t[59]=U,t[60]=p,t[61]=g,t[62]=w,t[63]=L):L=t[63];let F;t[64]!==u||t[65]!==L||t[66]!==S||t[67]!==x?(F=s.jsxs(u,{className:S,children:[x,L]}),t[64]=u,t[65]=L,t[66]=S,t[67]=x,t[68]=F):F=t[68];let R;return t[69]!==d||t[70]!==F||t[71]!==m||t[72]!==b?(R=s.jsx(d,{open:m,onOpenChange:b,children:F}),t[69]=d,t[70]=F,t[71]=m,t[72]=b,t[73]=R):R=t[73],R};function _v(t){return t.isHelpDialogOpen}function Lv(t){return t.setHelpDialogOpen}function $v(t){return t.shortcutOverrides}const Wv=()=>{const t=st.c(32),{t:e}=Nt(),n=Te(zv),r=Te(Vv),i=Te(Uv);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await gn(i)).ok){Le.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Le.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 u;t[5]!==a?(u=s.jsx(Rs,{children:a}),t[5]=a,t[6]=u):u=t[6];let d;t[7]!==e?(d=e("openCodeStatusDialog.description"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==d?(h=s.jsx(Es,{children:d}),t[9]=d,t[10]=h):h=t[10];let f;t[11]!==u||t[12]!==h?(f=s.jsxs($s,{children:[u,h]}),t[11]=u,t[12]=h,t[13]=f):f=t[13];let p;t[14]!==e?(p=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=p):p=t[15];let g;t[16]!==l||t[17]!==p?(g=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:p})}),t[16]=l,t[17]=p,t[18]=g):g=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 x;t[24]!==f||t[25]!==g||t[26]!==S?(x=s.jsxs(js,{className:"max-w-2xl",children:[f,g,S]}),t[24]=f,t[25]=g,t[26]=S,t[27]=x):x=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==x?(m=s.jsx(vs,{open:n,onOpenChange:r,children:x}),t[28]=n,t[29]=r,t[30]=x,t[31]=m):m=t[31],m};function zv(t){return t.isOpenCodeStatusDialogOpen}function Vv(t){return t.setOpenCodeStatusDialogOpen}function Uv(t){return t.openCodeStatusText}const Kv=t=>{const e=st.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let u,d;e[0]!==a||e[1]!==r||e[2]!==o?(u=()=>{if(!a||!r||typeof window>"u")return;const w=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(w)},d=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=u,e[4]=d):(u=e[3],d=e[4]),c.useEffect(u,d);let h,f;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const w=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("aiworker:sidebar-session-search",w),()=>window.removeEventListener("aiworker:sidebar-session-search",w)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=f):(h=e[8],f=e[9]),c.useEffect(h,f);let p,g;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{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)},g=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=g):(p=e[14],g=e[15]),c.useEffect(p,g)},Hv=t=>{const e=st.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const u=new Map(l.map(Gv)),d=[];a.forEach(p=>{const g=u.get(p);g&&(d.push(g),u.delete(p))});const h=[],f=[];return l.forEach(p=>{u.has(p.id)&&(p.isArchivedBucket?f.push(p):h.push(p))}),[...h,...d,...f]},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 Gv(t){return[t.id,t]}const ao="oc.sessions.projectCollapse",uc="oc.sessions.groupOrder",fc="oc.sessions.groupCollapse",mc=t=>{if(!t)return new Set;try{const e=Ea(br()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},qv=t=>{if(!t)return new Map;try{const e=xu(br(),Ea(br())).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}},Qv=t=>{const e=st.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=No(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>mc(o.getItem(ao)),e[1]=l):l=e[1];const[a,u]=c.useState(l);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>mc(o.getItem(fc)),e[2]=d):d=e[2];const[h,f]=c.useState(d);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>qv(o.getItem(uc)),e[3]=p):p=e[3];const[g,w]=c.useState(p),S=c.useRef(0),x=c.useRef(!1),m=c.useRef(!1),b=c.useRef(null),y=c.useRef(null);let v;e[4]!==n?(v=()=>{if(n)return;const pe=y.current;if(y.current=null,b.current=null,!pe)return;const{projects:je}=Ht.getState(),ne=je.map(T=>({...T,sidebarCollapsed:pe.has(T.id)}));Rr({projects:ne}).catch(Yv)},e[4]=n,e[5]=v):v=e[5];const N=v;let C;e[6]!==N||e[7]!==n?(C=pe=>{!globalThis.window||n||(y.current=pe,b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=C):C=e[8];const k=C;let D,P;e[9]===Symbol.for("react.memo_cache_sentinel")?(D=()=>()=>{globalThis.window&&b.current!==null&&window.clearTimeout(b.current),b.current=null,y.current=null},P=[],e[9]=D,e[10]=P):(D=e[9],P=e[10]),c.useEffect(D,P);let I,M;e[11]!==g?(M=()=>{if(m.current)try{o.setItem(uc,JSON.stringify(Object.fromEntries(g.entries())))}catch{}},I=[g,o],e[11]=g,e[12]=I,e[13]=M):(I=e[12],M=e[13]),c.useEffect(M,I);let _,O;e[14]!==h?(_=()=>{if(x.current)try{o.setItem(fc,JSON.stringify(Array.from(h)))}catch{}},O=[h,o],e[14]=h,e[15]=_,e[16]=O):(_=e[15],O=e[16]),c.useEffect(_,O);let U;e[17]!==r||e[18]!==k?(U=()=>{S.current=Date.now()+150,x.current=!0,f(new Set),u(()=>{const pe=new Set(r.map(Xv));try{o.setItem(ao,JSON.stringify(Array.from(pe)))}catch{}return k(pe),pe})},e[17]=r,e[18]=k,e[19]=U):U=e[19];const L=U;let F;e[20]!==k?(F=()=>{S.current=Date.now()+150,x.current=!0,f(new Set),u(()=>{const pe=new Set;try{o.setItem(ao,JSON.stringify([]))}catch{}return k(pe),pe})},e[20]=k,e[21]=F):F=e[21];const R=F;let j;e[22]!==k?(j=pe=>{S.current=Date.now()+150,u(je=>{const ne=new Set(je);ne.has(pe)?ne.delete(pe):ne.add(pe);try{o.setItem(ao,JSON.stringify(Array.from(ne)))}catch{}return k(ne),ne})},e[22]=k,e[23]=j):j=e[23];const A=j;let B;e[24]===Symbol.for("react.memo_cache_sentinel")?(B=pe=>{x.current=!0,f(je=>{const ne=new Set(je);return ne.has(pe)?ne.delete(pe):ne.add(pe),ne})},e[24]=B):B=e[24];const X=B;let H;e[25]===Symbol.for("react.memo_cache_sentinel")?(H=pe=>{m.current=!0,w(pe)},e[25]=H):H=e[25];const Z=H,{getOrderedGroups:ce}=Hv(g);let Y;e[26]!==h||e[27]!==a||e[28]!==g?(Y={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:g},e[26]=h,e[27]=a,e[28]=g,e[29]=Y):Y=e[29];const se=Y;let oe;e[30]!==L||e[31]!==R||e[32]!==ce||e[33]!==k||e[34]!==A?(oe={setCollapsedProjects:u,toggleProject:A,collapseAllProjects:L,expandAllProjects:R,scheduleCollapsedProjectsPersist:k,setCollapsedGroups:f,toggleGroup:X,setGroupOrderByProject:Z,getOrderedGroups:ce},e[30]=L,e[31]=R,e[32]=ce,e[33]=k,e[34]=A,e[35]=oe):oe=e[35];const Se=oe;let K;return e[36]!==Se||e[37]!==se?(K={state:se,actions:Se},e[36]=Se,e[37]=se,e[38]=K):K=e[38],K};function Yv(){}function Xv(t){return t.id}const Jv=5*6e4,Zv=t=>{const e=st.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:u}=Sn(),d=Dn(e0);let h,f;e[0]!==a||e[1]!==d||e[2]!==u||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!u||n.length===0){o(new Map);return}n.forEach(C=>{Di(()=>d(C.normalizedPath,u))})},f=[a,n,u,d,o],e[0]=a,e[1]=d,e[2]=u,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let p,g;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(k=>{C.set(k.id,i.get(k.normalizedPath)?.isGitRepo??null)}),o(C)},g=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=g):(p=e[11],g=e[12]),c.useEffect(p,g);let w;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=k=>{const D=i.get(k.normalizedPath)?.branch??"";return`${k.id}:${D}`},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 x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[18]=x):x=e[18];const m=c.useRef(x);let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=new Map,e[19]=b):b=e[19];const y=c.useRef(b);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 P=new Set(n.map(t0));for(const L of m.current.keys())P.has(L)||(m.current.delete(L),y.current.delete(L));const I=Date.now(),M=n.filter(L=>{const F=i.get(L.normalizedPath);if(F?.isGitRepo===!1)return m.current.delete(L.id),y.current.delete(L.id),!1;if(F?.isGitRepo!==!0||F.branch===null)return!1;const R=F.branch.trim(),j=`${L.normalizedPath}\0${R}`,A=m.current.get(L.id);if(A===j){const B=y.current.get(L.id);return B&&(B.at=I),!1}return!(A!==void 0&&I-(y.current.get(L.id)?.at??0)<Jv)});if(M.length===0)return;const _=await xh(M,2,async L=>{const F=i.get(L.normalizedPath)?.branch?.trim()??"",R=`${L.normalizedPath}\0${F}`,j=await Di(()=>qo(L.normalizedPath,F?{knownBranch:F}:void 0)).catch(s0);return{id:L.id,inputKey:R,branch:j}});if(C)return;const O=_.filter(n0);if(O.length===0)return;const U=Date.now();l(L=>{const F=new Map(L);return O.forEach(R=>{const{id:j,branch:A}=R;A&&F.set(j,A)}),F}),O.forEach(L=>{const{id:F,inputKey:R,branch:j}=L;m.current.set(F,R),j&&y.current.set(F,{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 e0(t){return t.ensureStatus}function t0(t){return t.id}function s0(){return null}function n0(t){return t.branch}const r0=t=>{const e=st.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(pg,{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(js,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(cn,{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 u;return e[6]!==r||e[7]!==n||e[8]!==a?(u=s.jsx(vs,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=u):u=e[9],u},o0=(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},xs=tr()((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,u=o.anchorId;r!==null&&o.scopeKey!==null&&r!==o.scopeKey?(l.clear(),a=r,u=null):a===null&&r!==null&&(a=r);const h=i&&i.length>0?[n,...i]:[n];if(l.has(n)){for(const p of h)l.delete(p);u===n&&(u=null)}else{for(const p of h)l.add(p);u=n}l.size===0?t({selectedIds:l,scopeKey:null,anchorId:null}):t({selectedIds:l,scopeKey:a,anchorId:u})},setRange:(n,r,i,o,l)=>{const a=e();if(i.length===0)return;const u=n&&i.includes(n)?n:i[0],d=i.indexOf(u),h=i.indexOf(r);if(d<0||h<0)return;const[f,p]=d<=h?[d,h]:[h,d],g=i.slice(f,p+1),w=o0(g,l),x=o!==null&&a.scopeKey!==null&&o!==a.scopeKey?new Set:new Set(a.selectedIds);for(const m of w)x.add(m);t({selectedIds:x,scopeKey:o??a.scopeKey,anchorId:u})},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 i0(t){const e=st.c(213),{t:n}=Nt(),{hideDirectoryControls:r,showProjectDisplayControls:i,showRecentControls:o,handleOpenDirectoryDialog:l,onOpenScheduled:a,onOpenMultiRun:u,canOpenMultiRun:d,onOpenArchive:h,headerActionIconClass:f,headerActionButtonClass:p,isSessionSearchOpen:g,setIsSessionSearchOpen:w,sessionSearchInputRef:S,sessionSearchQuery:x,setSessionSearchQuery:m,hasSessionSearchQuery:b,searchMatchCount:y,collapseAllProjects:v,expandAllProjects:N}=t,C=xs(y0),k=xs(b0),D=ls(x0),P=ls(g0),I=ls(p0),M=ls(h0),_=ls(m0),O=ls(f0),U=ls(u0),L=ls(d0),F=ls(c0),R=ls(l0),j=i&&F==="single";if(r)return null;let A;e[0]!==p?(A=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=p,e[1]=A):A=e[1];let B;e[2]!==n?(B=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=B):B=e[3];let X;e[4]!==f?(X=s.jsx(E,{name:"folder-add",className:f}),e[4]=f,e[5]=X):X=e[5];let H;e[6]!==l||e[7]!==A||e[8]!==B||e[9]!==X?(H=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,className:A,"aria-label":B,children:X})}),e[6]=l,e[7]=A,e[8]=B,e[9]=X,e[10]=H):H=e[10];let Z;e[11]!==n?(Z=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=Z):Z=e[12];let ce;e[13]!==Z?(ce=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Z})}),e[13]=Z,e[14]=ce):ce=e[14];let Y;e[15]!==H||e[16]!==ce?(Y=s.jsxs(At,{children:[H,ce]}),e[15]=H,e[16]=ce,e[17]=Y):Y=e[17];let se;e[18]!==p?(se=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=p,e[19]=se):se=e[19];let oe;e[20]!==n?(oe=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=oe):oe=e[21];let Se;e[22]!==f?(Se=s.jsx(E,{name:"calendar-schedule",className:f}),e[22]=f,e[23]=Se):Se=e[23];let K;e[24]!==a||e[25]!==se||e[26]!==oe||e[27]!==Se?(K=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:se,"aria-label":oe,children:Se})}),e[24]=a,e[25]=se,e[26]=oe,e[27]=Se,e[28]=K):K=e[28];let pe;e[29]!==n?(pe=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=pe):pe=e[30];let je;e[31]!==pe?(je=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:pe})}),e[31]=pe,e[32]=je):je=e[32];let ne;e[33]!==K||e[34]!==je?(ne=s.jsxs(At,{children:[K,je]}),e[33]=K,e[34]=je,e[35]=ne):ne=e[35];let T;e[36]!==p?(T=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=p,e[37]=T):T=e[37];let G;e[38]!==n?(G=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=G):G=e[39];const le=!d;let de;e[40]!==f?(de=s.jsx(bh,{className:f}),e[40]=f,e[41]=de):de=e[41];let ue;e[42]!==u||e[43]!==T||e[44]!==G||e[45]!==le||e[46]!==de?(ue=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:T,"aria-label":G,disabled:le,children:de})}),e[42]=u,e[43]=T,e[44]=G,e[45]=le,e[46]=de,e[47]=ue):ue=e[47];let Oe;e[48]!==n?(Oe=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=Oe):Oe=e[49];let me;e[50]!==Oe?(me=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Oe})}),e[50]=Oe,e[51]=me):me=e[51];let Re;e[52]!==ue||e[53]!==me?(Re=s.jsxs(At,{children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=Re):Re=e[54];let ye;e[55]!==p?(ye=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=p,e[56]=ye):ye=e[56];let q;e[57]!==n?(q=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=q):q=e[58];let we;e[59]!==f?(we=s.jsx(E,{name:"archive",className:f}),e[59]=f,e[60]=we):we=e[60];let be;e[61]!==h||e[62]!==ye||e[63]!==q||e[64]!==we?(be=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:ye,"aria-label":q,children:we})}),e[61]=h,e[62]=ye,e[63]=q,e[64]=we,e[65]=be):be=e[65];let Ne;e[66]!==n?(Ne=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=Ne):Ne=e[67];let ie;e[68]!==Ne?(ie=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ne})}),e[68]=Ne,e[69]=ie):ie=e[69];let ee;e[70]!==be||e[71]!==ie?(ee=s.jsxs(At,{children:[be,ie]}),e[70]=be,e[71]=ie,e[72]=ee):ee=e[72];let V;e[73]!==ne||e[74]!==Re||e[75]!==ee||e[76]!==Y?(V=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[Y,ne,Re,ee]}),e[73]=ne,e[74]=Re,e[75]=ee,e[76]=Y,e[77]=V):V=e[77];let $;e[78]!==w?($=()=>w(a0),e[78]=w,e[79]=$):$=e[79];let ae;e[80]!==p?(ae=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[80]=p,e[81]=ae):ae=e[81];let W;e[82]!==n?(W=n("sessions.sidebar.header.actions.searchSessions"),e[82]=n,e[83]=W):W=e[83];let ve;e[84]!==f?(ve=s.jsx(E,{name:"search",className:f}),e[84]=f,e[85]=ve):ve=e[85];let Fe;e[86]!==g||e[87]!==$||e[88]!==ae||e[89]!==W||e[90]!==ve?(Fe=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:$,className:ae,"aria-label":W,"aria-expanded":g,children:ve})}),e[86]=g,e[87]=$,e[88]=ae,e[89]=W,e[90]=ve,e[91]=Fe):Fe=e[91];let Ce;e[92]!==n?(Ce=n("sessions.sidebar.header.actions.searchSessions"),e[92]=n,e[93]=Ce):Ce=e[93];let ke;e[94]!==Ce?(ke=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ce})}),e[94]=Ce,e[95]=ke):ke=e[95];let Qe;e[96]!==Fe||e[97]!==ke?(Qe=s.jsxs(At,{children:[Fe,ke]}),e[96]=Fe,e[97]=ke,e[98]=Qe):Qe=e[98];const We=C&&"bg-interactive-hover text-primary";let z;e[99]!==p||e[100]!==We?(z=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent",We),e[99]=p,e[100]=We,e[101]=z):z=e[101];let he;e[102]!==C||e[103]!==n?(he=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[102]=C,e[103]=n,e[104]=he):he=e[104];let Be;e[105]!==f?(Be=s.jsx(E,{name:"checkbox-multiple",className:f}),e[105]=f,e[106]=Be):Be=e[106];let Ae;e[107]!==C||e[108]!==z||e[109]!==he||e[110]!==Be||e[111]!==k?(Ae=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:k,className:z,"aria-label":he,"aria-pressed":C,children:Be})}),e[107]=C,e[108]=z,e[109]=he,e[110]=Be,e[111]=k,e[112]=Ae):Ae=e[112];let at;e[113]!==C||e[114]!==n?(at=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[113]=C,e[114]=n,e[115]=at):at=e[115];let Ue;e[116]!==at?(Ue=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:at})}),e[116]=at,e[117]=Ue):Ue=e[117];let ht;e[118]!==Ae||e[119]!==Ue?(ht=s.jsxs(At,{children:[Ae,Ue]}),e[118]=Ae,e[119]=Ue,e[120]=ht):ht=e[120];let ut;e[121]!==p?(ut=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[121]=p,e[122]=ut):ut=e[122];let Ct;e[123]!==n?(Ct=n("sessions.sidebar.header.displayMode.label"),e[123]=n,e[124]=Ct):Ct=e[124];let ge;e[125]!==f?(ge=s.jsx(E,{name:"equalizer-2",className:f}),e[125]=f,e[126]=ge):ge=e[126];let Ye;e[127]!==ut||e[128]!==Ct||e[129]!==ge?(Ye=s.jsx(Dt,{asChild:!0,children:s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:ut,"aria-label":Ct,children:ge})})}),e[127]=ut,e[128]=Ct,e[129]=ge,e[130]=Ye):Ye=e[130];let bt;e[131]!==n?(bt=n("sessions.sidebar.header.displayMode.label"),e[131]=n,e[132]=bt):bt=e[132];let jt;e[133]!==bt?(jt=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:bt})}),e[133]=bt,e[134]=jt):jt=e[134];let fe;e[135]!==Ye||e[136]!==jt?(fe=s.jsxs(At,{children:[Ye,jt]}),e[135]=Ye,e[136]=jt,e[137]=fe):fe=e[137];let ze;e[138]!==n?(ze=n("sessions.sidebar.header.actions.sortProjects"),e[138]=n,e[139]=ze):ze=e[139];let it;e[140]!==ze?(it=s.jsx(ho,{children:ze}),e[140]=ze,e[141]=it):it=e[141];let $e;e[142]!==I||e[143]!==M||e[144]!==n?($e=[["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(yt=>{const[It,kt]=yt;return s.jsxs(Kt,{onClick:()=>{M(It),Rr({sidebarProjectSortOrder:It})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),I===It?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},It)}),e[142]=I,e[143]=M,e[144]=n,e[145]=$e):$e=e[145];let J;e[146]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(Os,{}),e[146]=J):J=e[146];let re;e[147]!==F||e[148]!==R||e[149]!==i||e[150]!==n?(re=i?s.jsxs(s.Fragment,{children:[s.jsx(ho,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(yt=>{const[It,kt]=yt;return s.jsxs(Kt,{onClick:()=>{R(It),Rr({sidebarProjectDisplayMode:It})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),F===It?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},It)}),s.jsx(Os,{})]}):null,e[147]=F,e[148]=R,e[149]=i,e[150]=n,e[151]=re):re=e[151];let Pe;e[152]!==n?(Pe=n("sessions.sidebar.header.grouping.label"),e[152]=n,e[153]=Pe):Pe=e[153];let _e;e[154]!==Pe?(_e=s.jsx(ho,{children:Pe}),e[154]=Pe,e[155]=_e):_e=e[155];let Ve;e[156]!==_||e[157]!==O||e[158]!==n?(Ve=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(yt=>{const[It,kt]=yt;return s.jsxs(Kt,{onClick:()=>{O(It),Rr({sidebarSessionGroupingMode:It})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(kt)}),_===It?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},It)}),e[156]=_,e[157]=O,e[158]=n,e[159]=Ve):Ve=e[159];let Ze;e[160]===Symbol.for("react.memo_cache_sentinel")?(Ze=s.jsx(Os,{}),e[160]=Ze):Ze=e[160];let lt;e[161]!==j||e[162]!==o||e[163]!==D||e[164]!==n||e[165]!==P?(lt=o&&!j?s.jsxs(Kt,{onClick:()=>{P(),Rr({sidebarShowRecentSection:!D})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),D?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[161]=j,e[162]=o,e[163]=D,e[164]=n,e[165]=P,e[166]=lt):lt=e[166];let rt;e[167]!==n?(rt=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[167]=n,e[168]=rt):rt=e[168];let Ge;e[169]!==rt?(Ge=s.jsx("span",{children:rt}),e[169]=rt,e[170]=Ge):Ge=e[170];let ot;e[171]!==U?(ot=U?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null,e[171]=U,e[172]=ot):ot=e[172];let Ee;e[173]!==Ge||e[174]!==ot||e[175]!==L?(Ee=s.jsxs(Kt,{onClick:L,className:"flex items-center justify-between",children:[Ge,ot]}),e[173]=Ge,e[174]=ot,e[175]=L,e[176]=Ee):Ee=e[176];let Rt;e[177]!==v||e[178]!==N||e[179]!==j||e[180]!==n?(Rt=j?null:s.jsxs(s.Fragment,{children:[s.jsx(Os,{}),s.jsxs(Kt,{onClick:v,className:"flex items-center gap-2",children:[s.jsx(E,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Kt,{onClick:N,className:"flex items-center gap-2",children:[s.jsx(E,{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]=Rt):Rt=e[181];let xe;e[182]!==it||e[183]!==$e||e[184]!==re||e[185]!==_e||e[186]!==Ve||e[187]!==lt||e[188]!==Ee||e[189]!==Rt?(xe=s.jsxs(Xs,{align:"end",className:"min-w-[180px]",children:[it,$e,J,re,_e,Ve,Ze,lt,Ee,Rt]}),e[182]=it,e[183]=$e,e[184]=re,e[185]=_e,e[186]=Ve,e[187]=lt,e[188]=Ee,e[189]=Rt,e[190]=xe):xe=e[190];let mt;e[191]!==fe||e[192]!==xe?(mt=s.jsxs(Js,{children:[fe,xe]}),e[191]=fe,e[192]=xe,e[193]=mt):mt=e[193];let Tt;e[194]!==Qe||e[195]!==ht||e[196]!==mt?(Tt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Qe,ht,mt]}),e[194]=Qe,e[195]=ht,e[196]=mt,e[197]=Tt):Tt=e[197];let Xe;e[198]!==V||e[199]!==Tt?(Xe=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[V,Tt]}),e[198]=V,e[199]=Tt,e[200]=Xe):Xe=e[200];let nt;e[201]!==b||e[202]!==g||e[203]!==y||e[204]!==S||e[205]!==x||e[206]!==w||e[207]!==m||e[208]!==n?(nt=g?s.jsxs("div",{className:"pb-1",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80",children:[b?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(E,{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:x,onChange:yt=>m(yt.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:yt=>{yt.key==="Escape"&&(yt.stopPropagation(),b?m(""):w(!1))}}),x.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(E,{name:"close",className:"h-3.5 w-3.5"})}):null]})]}):null,e[201]=b,e[202]=g,e[203]=y,e[204]=S,e[205]=x,e[206]=w,e[207]=m,e[208]=n,e[209]=nt):nt=e[209];let St;return e[210]!==Xe||e[211]!==nt?(St=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:[Xe,nt]})}),e[210]=Xe,e[211]=nt,e[212]=St):St=e[212],St}function a0(t){return!t}function l0(t){return t.setProjectDisplayMode}function c0(t){return t.projectDisplayMode}function d0(t){return t.toggleStickyZoneHeaders}function u0(t){return t.stickyZoneHeaders}function f0(t){return t.setSessionGroupingMode}function m0(t){return t.sessionGroupingMode}function h0(t){return t.setProjectSortOrder}function p0(t){return t.projectSortOrder}function g0(t){return t.toggleRecentSection}function x0(t){return t.showRecentSection}function b0(t){return t.toggleMode}function y0(t){return t.enabled}function w0(t){const e=st.c(8),{t:n}=Nt(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(E,{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 mi="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 S0(t){const e=st.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,u=l===void 0?!0:l,d=a===void 0?!0:a,{t:h}=Nt();if(!u&&!d)return null;let f;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==u||e[4]!==h?(f=u?s.jsxs(s.Fragment,{children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:mi,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(E,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:mi,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(E,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:mi,"aria-label":h("sessions.sidebar.footer.actions.aboutAiWorker"),children:s.jsx(E,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutAiWorker")})})]})]}):null,e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=h,e[5]=f):f=e[5];let p;e[6]!==o||e[7]!==d||e[8]!==h?(p=d?s.jsx(xt,{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:h("sessions.sidebar.footer.actions.update")}):null,e[6]=o,e[7]=d,e[8]=h,e[9]=p):p=e[9];let g;return e[10]!==f||e[11]!==p?(g=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[f,p]}),e[10]=f,e[11]=p,e[12]=g):g=e[12],g}const v0=t=>{for(const e of t.sessions.values())if(e.tabs.some(md))return!0;return!1},j0=()=>{const t=st.c(4),{terminal:e}=Sn(),n=Mt(v0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=k0,l=C0;if(n)return Ei(e,"",l,o);let a=N0;return a=Ei(e,"",l,u=>{o(u),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function k0(t){const e=Mt.getState(),n=gg(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function C0(){return new Map(Mt.getState().actionMutationRevisions)}function N0(){}const A0=t=>{const e=st.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:u,foldersMap:d,createFolder:h,addSessionToFolder:f}=t,p=r===void 0?!0:r;let g,w;e[0]!==f||e[1]!==h||e[2]!==p||e[3]!==d||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==u?(g=()=>{!p||o||!l||a||n.forEach(S=>{if(u.has(S.normalizedPath))return;const x=_d(S.normalizedPath),m=i.archivedSessionsByProject.get(S.id)??[],b=d[x]??[],y=new Map(b.map(D0));m.forEach(v=>{const N=yh(v,S.normalizedPath),C=N.toLowerCase();let k=y.get(C);k||(k=h(x,N),y.set(C,k)),k.sessionIds.includes(v.id)||f(x,k.id,v.id)})})},w=[n,p,i,o,l,a,u,d,h,f],e[0]=f,e[1]=h,e[2]=p,e[3]=d,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=u,e[10]=g,e[11]=w):(g=e[10],w=e[11]),c.useEffect(g,w)};function D0(t){return[t.name.toLowerCase(),t]}function P0({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 d=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!d)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const u=(o&&r.has(o)?o:null)??l;return!u||u===e?{kind:"none"}:{kind:"select-session",sessionId:u}}const I0=t=>{const e=st.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:u,newSessionDraftOpen:d,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let g,w;if(e[0]!==n){w=new Map,g=new Map;const C=(k,D,P,I)=>{w.has(k)||w.set(k,new Map);const M=w.get(k);I.forEach(_=>{const O=vt(_.worktree?.path??_.session.directory??P??D);M.set(_.session.id,{directory:O}),g.has(k)||g.set(k,{id:_.session.id,directory:O}),_.children.length>0&&C(k,D,O,_.children)})};n.forEach(k=>{k.groups.forEach(D=>{C(k.project.id,k.project.normalizedPath,D.directory,D.sessions)})}),e[0]=n,e[1]=g,e[2]=w}else g=e[1],w=e[2];let S;e[3]!==g||e[4]!==w?(S={metaByProject:w,firstSessionByProject:g},e[3]=g,e[4]=w,e[5]=S):S=e[5];const x=S,m=c.useRef(null);let b,y;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==u||e[11]!==h||e[12]!==d||e[13]!==f||e[14]!==n||e[15]!==x||e[16]!==o||e[17]!==p?(b=()=>{if(!r||d||Te.getState().isNewWorktreeDialogOpen||m.current===r)return;const C=n.find(I=>I.project.id===r);if(!C)return;const k=x.metaByProject.get(r);if(l&&k&&k.has(l)){m.current=r,o(I=>{if(I.get(r)===l)return I;const M=new Map(I);return M.set(r,l),M});return}const D=P0({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:k,metaByProject:x.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(D.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,D.kind==="open-draft"){h&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(D.kind!=="select-session")return;const P=k?.get(D.sessionId)?.directory??null;u(D.sessionId,P)},y=[r,i,l,a,u,d,h,f,n,x,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=u,e[11]=h,e[12]=d,e[13]=f,e[14]=n,e[15]=x,e[16]=o,e[17]=p,e[18]=b,e[19]=y):(b=e[18],y=e[19]),c.useLayoutEffect(b,y);let v,N;e[20]!==r||e[21]!==l||e[22]!==x||e[23]!==o?(v=()=>{if(!r||!l)return;const C=x.metaByProject.get(r);!C||!C.has(l)||o(k=>{if(k.get(r)===l)return k;const D=new Map(k);return D.set(r,l),D})},N=[r,l,x,o],e[20]=r,e[21]=l,e[22]=x,e[23]=o,e[24]=v,e[25]=N):(v=e[24],N=e[25]),c.useEffect(v,N)},T0=t=>{const e=st.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=Je(R0),a=Je(E0);let u;e[5]!==l||e[6]!==o?(u=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=u):u=e[7];const d=u;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[f,p]=c.useState(h);let g;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==d||e[14]!==a?(g={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:d,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=d,e[14]=a,e[15]=g):g=e[15],I0(g);let w,S;return e[16]!==f||e[17]!==i?(w=()=>{i(f)},S=[f,i],e[16]=f,e[17]=i,e[18]=w,e[19]=S):(w=e[18],S=e[19]),c.useEffect(w,S),null};function R0(t){return t.currentSessionId}function E0(t){return!!t.newSessionDraft?.open}const hc={selected:0,"active-project":1,expanded:2,visible:3,background:4};function lf(t){const e=new Map,n=(r,i,o)=>{const l=vt(r??null);if(!l)return;const a=e.get(l);a&&hc[a.priority]<=hc[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 u="background";a?u="expanded":i&&(u="visible"),n(l.directory,u,a?"worktree-expanded":"known-worktree")}}return n(t.currentDirectory,"selected","current-directory"),n(t.currentSessionDirectory,"selected","selected-session"),[...e.values()]}const M0=(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,pc=(t,e,n)=>{M0(t.get(e),n)&&t.set(e,n)},O0=t=>{const e=t;return vt(e.directory)??vt(e.project?.worktree)},F0=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)},B0=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const S=vt(w.normalizedPath);if(!S)continue;const x=l.get(S);(!x||w.id.localeCompare(x.id)<0)&&l.set(S,w),pc(o,S,{projectId:w.id,projectRoot:S,scopeDirectory:S,kind:"project"})}if(!r)for(const[w,S]of n){const x=vt(w),m=x?l.get(x):void 0;if(!(!m||!x))for(const b of S){const y=vt(b.path);y&&pc(o,y,{projectId:m.id,projectRoot:x,scopeDirectory:y,kind:"worktree"})}}const a=new Map,u=new Map,d=new Map,h=new Map,f=new Map,p=w=>{if(!w)return null;if(a.has(w))return a.get(w)??null;if(r){const b=o.get(w)??null;return a.set(w,b),b}const S=[];let x=w,m=null;for(;x;){if(a.has(x)){m=a.get(x)??null;break}if(S.push(x),m=o.get(x)??null,m)break;x=F0(x)}for(const b of S)a.set(b,m);return m},g=(w,S,x)=>{for(const m of w){const b=p(O0(m));if(!b)continue;u.set(m.id,b);const y=S.get(b.projectId);if(y?y.push(m):S.set(b.projectId,[m]),!x)continue;const v=x.get(b.scopeDirectory);v?v.add(m.id):x.set(b.scopeDirectory,new Set([m.id]))}};return g(t,d,f),g(i,h),{bySessionId:u,sessionsByProject:d,archivedSessionsByProject:h,sessionsByScope:f,directoryResolutions:a.size}},_0=t=>{const e=st.c(7),{ownership:n}=t;let r;e[0]!==n?(r=u=>n.sessionsByProject.get(u)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=u=>n.archivedSessionsByProject.get(u)??[],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},L0=(t,e)=>t.map(n=>{const r=vt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
913
|
+
`),$0=[],W0=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:u,buildGroupedSessions:d,hasSessionSearchQuery:h,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:p,buildGroupSearchText:g,foldersMap:w,standaloneGroups:S}=t,x=c.useRef(new Map),m=c.useMemo(()=>{const P=x.current,I=new Map;let M=0,_=0;const O=(L,F)=>L.length===F.length&&L.every((R,j)=>R===F[j]),U=e.map(L=>{const F=n(L.id),R=r(L.id),j=i.get(L.normalizedPath)??$0,A=o.has(L.id)?!!o.get(L.id):u,B=l.get(L.id)??null,X=L0(j,a),H=P.get(L.id);if(H&&H.project===L&&O(H.activeSessions,F)&&O(H.archivedSessions,R)&&H.availableWorktrees===j&&H.rootBranch===B&&H.worktreeBranchesKey===X&&H.isRepo===A&&H.buildGroupedSessions===d)return M+=1,I.set(L.id,H),H.section;if(_+=1,H){const se=H.project!==L?"project":O(H.activeSessions,F)?O(H.archivedSessions,R)?H.availableWorktrees!==j?"worktrees":H.rootBranch!==B?"branch":H.worktreeBranchesKey!==X?"worktreeBranches":H.isRepo!==A?"repo":"builder":"archived":"sessions";qs(`ui.sidebar.project_section.rebuilt_reason.${se}`)}const Z=Ld([...F,...R]),ce=d(Z,L.normalizedPath,j,B,A),Y={project:L,groups:ce};return I.set(L.id,{project:L,activeSessions:F,archivedSessions:R,availableWorktrees:j,rootBranch:B,worktreeBranchesKey:X,isRepo:A,buildGroupedSessions:d,section:Y}),Y});return x.current=I,M>0&&qs("ui.sidebar.project_section.reused",M),_>0&&qs("ui.sidebar.project_section.rebuilt",_),U},[e,n,r,i,o,u,d,l,a]),b=c.useMemo(()=>m,[m]),y=c.useMemo(()=>{const P=new WeakMap;if(!h)return P;const I=f.trim().toLowerCase(),M=I.startsWith("ses_"),_=U=>U.reduce((L,F)=>L+(!M||F.session.id.toLowerCase()===I?1:0)+_(F.children),0),O=U=>{const L=p(U.sessions,f),F=_(L),R=!M&&Ao([g(U)],f),j=vt(U.directory??null),A=j?w[j]??[]:[],B=M?0:A.filter(X=>Ao([X.name],f)).length;P.set(U,{filteredNodes:L,matchedSessionCount:F,folderNameMatchCount:B,groupMatches:R,hasMatch:R||F>0||B>0})};return b.forEach(U=>{U.groups.forEach(O)}),S.forEach(O),P},[h,b,S,p,f,g,w]),v=c.useMemo(()=>h?b.map(P=>({...P,groups:P.groups.filter(I=>y.get(I)?.hasMatch===!0)})).filter(P=>P.groups.length>0):b,[h,b,y]),N=h?v:b,C=c.useRef(new WeakMap),k=c.useMemo(()=>{const P=C.current;return N.map(I=>{const M=P.get(I);if(M&&M.query===f)return M.section;const _=I.groups.filter(A=>!A.isArchivedBucket),O=I.groups.filter(A=>A.isArchivedBucket),U=_.flatMap(A=>h?y.get(A)?.filteredNodes??[]:A.sessions),L=_.map(A=>({scopeKey:A.folderScopeKey??vt(A.directory??null),directory:A.directory??null})).filter(A=>!!A.scopeKey),F=_.find(A=>A.isMain)??null,R={id:"flat",label:F?.label??"",branch:F?.branch??null,description:F?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:F?.directory??I.project.normalizedPath,folderScopeKey:F?.folderScopeKey??I.project.normalizedPath,folderScopes:L,sessions:U};if(h){const A=_.map(B=>y.get(B)).filter(B=>!!B);y.set(R,{filteredNodes:U,matchedSessionCount:A.reduce((B,X)=>B+X.matchedSessionCount,0),folderNameMatchCount:A.reduce((B,X)=>B+X.folderNameMatchCount,0),groupMatches:A.some(B=>B.groupMatches),hasMatch:A.some(B=>B.hasMatch)})}const j={project:I.project,groups:[R,...O]};return P.set(I,{query:f,section:j}),j})},[y,h,f,N]),D=c.useMemo(()=>{if(!h)return 0;const P=(M,_)=>{const O=y.get(_);if(!O)return M;const U=O.folderNameMatchCount+(O.groupMatches?1:0);return M+O.matchedSessionCount+U},I=N.reduce((M,_)=>_.groups.reduce(P,M),0);return S.reduce(P,I)},[h,N,S,y]);return{projectSections:m,visibleProjectSections:b,groupSearchDataByGroup:y,searchableProjectSections:v,sectionsForRender:N,flatSectionsForRender:k,searchMatchCount:D}},z0=180,gc=150,V0=2,U0=8,xc=[-1,1,-2,2],hi=t=>`${t.directory}
|
|
914
|
+
${t.sessionId}`,K0=t=>t?.directory?.trim()||null,H0=({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),u=c.useRef(0),d=c.useMemo(()=>Pn(),[]),h=c.useCallback(()=>{u.current+=1,l.current=[],o.current.forEach(g=>window.clearTimeout(g)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||d))for(;a.current.size<V0&&l.current.length>0;){const g=l.current.shift();if(!g)break;if(g.generation!==u.current||Je.getState().currentSessionId===g.sessionId||Pi(g.sessionId,g.directory).renderable)continue;const S=hi(g);a.current.add(S),i({directory:g.directory,sessionID:g.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(S),f()})}},[t,d,i]),p=c.useCallback(g=>{const w=g?.id,S=K0(g);if(!t||d||!w||!S||w===e)return;const x={sessionId:w,directory:S,generation:u.current},m=hi(x);if(Pi(w,S).renderable||a.current.has(m)||l.current.some(v=>hi(v)===m))return;const b=o.current.get(m);b!==void 0&&window.clearTimeout(b);const y=window.setTimeout(()=>{if(o.current.delete(m),x.generation!==u.current)return;const v=l.current;v.length>=U0&&v.shift(),v.push(x),f()},z0);o.current.set(m,y)},[e,t,d,f]);c.useEffect(()=>{h()},[h,e,t,d]),c.useEffect(()=>{if(!t||d||!e||n.length===0)return;const g=window.setTimeout(()=>{const w=n.findIndex(S=>S.id===e);if(!(w<0))for(const S of xc)p(n[w+S])},gc);return()=>window.clearTimeout(g)},[e,t,d,p,n]),c.useEffect(()=>{if(!t||d||!e||r.length===0)return;const g=window.setTimeout(()=>{const w=r.findIndex(S=>S.id===e);if(!(w<0))for(const S of xc)p(r[w+S])},gc);return()=>window.clearTimeout(g)},[e,t,d,r,p]),c.useEffect(()=>h,[h])},G0=t=>{const e=st.c(3),n=Je(q0);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],H0(r),null};function q0(t){return t.currentSessionId}const Hr=t=>{const e=st.c(13),{directory:n,className:r}=t,{t:i}=Nt();let o;e[0]!==n?(o=lm(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=S=>S.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Mt(a)?.tabs.some(md))return null;let h;e[4]!==i?(h=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=h):h=e[5];const f=h;let p;e[6]!==r?(p=Ie("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=p):p=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(E,{name:"pulse",className:"size-3.5"}),e[8]=g):g=e[8];let w;return e[9]!==l||e[10]!==f||e[11]!==p?(w=s.jsx("span",{className:p,role:"img","aria-label":f,title:f,"data-action-directory":l,children:g}),e[9]=l,e[10]=f,e[11]=p,e[12]=w):w=e[12],w},wo=t=>{const e=st.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:u,alwaysShowActions:d}=t,h=d===void 0?!1:d,{currentTheme:f}=Zn(),p=i?ka[i]:null,g=o?Ca[o]??null:null,w=u!==void 0,S=w?h?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let x;e[0]!==h||e[1]!==w||e[2]!==u?(x=w?s.jsx("span",{className:Ie("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(E,{name:u?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=h,e[1]=w,e[2]=u,e[3]=x):x=e[3];let m;e[4]!==h||e[5]!==f||e[6]!==w||e[7]!==g||e[8]!==S||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==p?(m=l?s.jsx("span",{className:Ie("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",w&&h?"hidden":"inline-flex",S),style:a?{backgroundColor:a}:void 0,children:s.jsx(Na,{project:{id:n,iconImage:l},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:p?s.jsx(E,{name:p,className:"h-3.5 w-3.5",style:g?{color:g}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:g?{color:g}:void 0})})}):p?s.jsx(E,{name:p,className:Ie("h-3.5 w-3.5",S),style:g?{color:g}:void 0}):s.jsx(E,{name:"folder",className:Ie("h-3.5 w-3.5 text-muted-foreground/80",S),style:g?{color:g}:void 0}),e[4]=h,e[5]=f,e[6]=w,e[7]=g,e[8]=S,e[9]=n,e[10]=a,e[11]=l,e[12]=p,e[13]=m):m=e[13];let b;e[14]!==x||e[15]!==m?(b=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[x,m]}),e[14]=x,e[15]=m,e[16]=b):b=e[16];let y;e[17]!==r?(y=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=y):y=e[18];let v;return e[19]!==b||e[20]!==y?(v=s.jsxs(s.Fragment,{children:[b,y]}),e[19]=b,e[20]=y,e[21]=v):v=e[21],v},Q0=t=>{const e=st.c(63),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:f,isRepo:p,isDesktopShell:g,hideDirectoryControls:w,alwaysShowActions:S,onToggle:x,onNewSession:m,onNewWorktreeSession:b,onManageWorktrees:y,onRenameStart:v,onClose:N,sentinelRef:C,children:k,showCreateButtons:D,hideHeader:P,statusIndicator:I,openSidebarMenuKey:M,setOpenSidebarMenuKey:_,projectPickerOptions:O,onProjectSelect:U}=t,L=r===void 0?!1:r,F=D===void 0?!0:D,R=P===void 0?!1:P,j=I===void 0?null:I,{t:A}=Nt(),B=ls(J0);let X;e[0]!==L||e[1]!==n?(X={id:n,disabled:L},e[0]=L,e[1]=n,e[2]=X):X=e[2];const{attributes:H,listeners:Z,setNodeRef:ce,transform:Y,transition:se,isDragging:oe}=Qo(X),Se=c.useRef(!1),K=`project:${n}`,pe=M===K,[je,ne]=c.useState(!1),T=!!(O&&U);let G;e[3]!==K||e[4]!==_?(G=W=>{W&&ne(!1),_(W?K:null)},e[3]=K,e[4]=_,e[5]=G):G=e[5];const le=G;let de;e[6]!==w||e[7]!==p||e[8]!==N||e[9]!==y||e[10]!==m||e[11]!==v||e[12]!==F||e[13]!==A?(de=W=>s.jsxs(s.Fragment,{children:[F&&!p&&!w&&m&&s.jsxs(W,{onClick:m,children:[s.jsx(E,{name:"add",className:"mr-1.5 h-4 w-4"}),A("sessions.sidebar.project.actions.newSession")]}),p&&!w&&y&&s.jsxs(W,{onClick:y,children:[s.jsx(E,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),A("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(W,{onClick:v,children:[s.jsx(E,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),A("sessions.sidebar.project.actions.edit")]}),s.jsxs(W,{onClick:N,className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"close",className:"mr-1.5 h-4 w-4"}),A("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=w,e[7]=p,e[8]=N,e[9]=y,e[10]=m,e[11]=v,e[12]=F,e[13]=A,e[14]=de):de=e[14];const ue=de,Oe=Z0,me=ej,Re=tj;let ye;e[15]===Symbol.for("react.memo_cache_sentinel")?(ye=W=>{(W.button===2||W.button===0&&W.ctrlKey)&&(Se.current=!0)},e[15]=ye):ye=e[15];const q=ye;let we;e[16]!==x?(we=W=>{if(W.currentTarget.blur(),Se.current){Se.current=!1;return}x()},e[16]=x,e[17]=we):we=e[17];const be=we;let Ne;e[18]!==Y?(Ne=Yo.Transform.toString(Y),e[18]=Y,e[19]=Ne):Ne=e[19];let ie;e[20]!==Ne||e[21]!==se?(ie={transform:Ne,transition:se},e[20]=Ne,e[21]=se,e[22]=ie):ie=e[22];const ee=oe&&"opacity-30";let V;e[23]!==ee?(V=Ie("relative",ee),e[23]=ee,e[24]=V):V=e[24];let $;e[25]!==S||e[26]!==H||e[27]!==le||e[28]!==be||e[29]!==w||e[30]!==R||e[31]!==n||e[32]!==f||e[33]!==je||e[34]!==g||e[35]!==pe||e[36]!==T||e[37]!==p||e[38]!==Z||e[39]!==m||e[40]!==b||e[41]!==U||e[42]!==u||e[43]!==o||e[44]!==l||e[45]!==a||e[46]!==h||e[47]!==d||e[48]!==i||e[49]!==O||e[50]!==ue||e[51]!==C||e[52]!==F||e[53]!==j||e[54]!==B||e[55]!==A?($=R?null:s.jsxs(s.Fragment,{children:[g&&s.jsx("div",{ref:C,"data-project-id":n,className:"absolute top-0 h-px w-full pointer-events-none","aria-hidden":"true"}),s.jsxs(ou,{open:je,onOpenChange:ne,children:[s.jsx(ru,{render:s.jsx("div",{className:Ie("-ml-2.5 -mr-2 text-left group/project select-none",B&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":B?"true":void 0,onContextMenu:W=>{w||(W.preventDefault(),ne(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...H,children:[T?s.jsxs(Js,{children:[s.jsx(Ys,{asChild:!0,children:s.jsxs("button",{type:"button",className:Ie("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 transition-[padding]",p&&!w?S||pe?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":S||pe?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":A("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(wo,{id:n,projectLabel:i,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h}),s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(Hr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Xs,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:O?.map(W=>s.jsxs(Kt,{onClick:()=>U?.(W.id),className:"flex items-center justify-between gap-3",title:W.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(wo,{...W})}),W.id===n?s.jsx(E,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},W.id))})]}):s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:q,onClick:be,...Z,className:Ie("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]",p&&!w?S||pe?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":S||pe?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(wo,{id:n,projectLabel:i,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:f,alwaysShowActions:S}),j?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:j}):null,l?s.jsx(Hr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Pt,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Ie("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",F?"right-7":"right-0.5"),children:[F&&p&&!w&&b?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W=>{W.stopPropagation(),b()},className:Ie("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground transition-opacity",S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":A("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(E,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:A("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,w?null:s.jsxs(Js,{open:pe,onOpenChange:le,children:[s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie("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",pe?"opacity-100 pointer-events-auto":S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":A("sessions.sidebar.project.actions.projectMenu"),onPointerDown:me,onMouseDown:Re,onClick:Oe,children:s.jsx(E,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Xs,{align:"end",className:"min-w-[180px]",children:ue(Kt)})]})]}),F&&m?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W=>{W.stopPropagation(),m()},className:Ie("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":A(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(E,{name:"add",className:"h-4 w-4"})})}),s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:A(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(nu,{className:"min-w-[180px]",children:ue(Un)})]})]}),e[25]=S,e[26]=H,e[27]=le,e[28]=be,e[29]=w,e[30]=R,e[31]=n,e[32]=f,e[33]=je,e[34]=g,e[35]=pe,e[36]=T,e[37]=p,e[38]=Z,e[39]=m,e[40]=b,e[41]=U,e[42]=u,e[43]=o,e[44]=l,e[45]=a,e[46]=h,e[47]=d,e[48]=i,e[49]=O,e[50]=ue,e[51]=C,e[52]=F,e[53]=j,e[54]=B,e[55]=A,e[56]=$):$=e[56];let ae;return e[57]!==k||e[58]!==ce||e[59]!==ie||e[60]!==V||e[61]!==$?(ae=s.jsxs("div",{ref:ce,style:ie,className:V,children:[$,k]}),e[57]=k,e[58]=ce,e[59]=ie,e[60]=V,e[61]=$,e[62]=ae):ae=e[62],ae},Y0=t=>{const e=st.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:u,setActivatorNodeRef:d,transform:h,transition:f,isDragging:p}=Qo(l);let g;e[3]!==a||e[4]!==d?(g={listeners:a,setActivatorNodeRef:d},e[3]=a,e[4]=d,e[5]=g):g=e[5];const w=g;let S;e[6]!==h?(S=Yo.Transform.toString(h),e[6]=h,e[7]=S):S=e[7];let x;e[8]!==S||e[9]!==f?(x={transform:S,transition:f},e[8]=S,e[9]=f,e[10]=x):x=e[10];const m=p&&"opacity-50";let b;e[11]!==m?(b=Ie("space-y-0.5 rounded-md",m),e[11]=m,e[12]=b):b=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]!==u||e[17]!==x||e[18]!==b||e[19]!==y?(v=s.jsx("div",{ref:u,style:x,className:b,children:y}),e[16]=u,e[17]=x,e[18]=b,e[19]=y,e[20]=v):v=e[20],v},X0=c.memo(Y0);function J0(t){return t.stickyZoneHeaders}function Z0(t){t.stopPropagation()}function ej(t){t.stopPropagation()}function tj(t){t.stopPropagation()}const sj=(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}},cf=t=>{const e=st.c(9),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==r||e[1]!==n?(l=sj(n,r),e[0]=r,e[1]=n,e[2]=l):l=e[2];const a=l;let u;e[3]!==o||e[4]!==a.active?(u=p=>{if(!o)return null;for(const g of a.active){const w=p.statusById.get(g)?.status.type;if(w==="busy"||w==="retry")return"active"}return null},e[3]=o,e[4]=a.active,e[5]=u):u=e[5];const d=Aa(u);let h;e[6]!==o||e[7]!==a.unread?(h=p=>{if(!o)return null;for(const g of a.unread)if((p.index.session.unseenCount[g]??0)>0)return"unread";return null},e[6]=o,e[7]=a.unread,e[8]=h):h=e[8];const f=Da(h);return d??f};function df(t){const e=st.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 u;e[0]!==o||e[1]!==a?(u=Ie("h-1.5 w-1.5 shrink-0 rounded-full",a,o),e[0]=o,e[1]=a,e[2]=u):u=e[2];let d;return e[3]!==l||e[4]!==u?(d=s.jsx("span",{className:u,"aria-label":l,title:l}),e[3]=l,e[4]=u,e[5]=d):d=e[5],d}const nj=t=>{const e=st.c(11),{nodes:n,includeUnreadSubtasks:r}=t,{t:i}=Nt();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=cf(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 u;e[5]!==i?(u=i("sessions.sidebar.session.status.unread"),e[5]=i,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==u?(d=s.jsx(df,{state:l,activeLabel:a,unreadLabel:u}),e[7]=l,e[8]=a,e[9]=u,e[10]=d):d=e[10],d},rj=t=>{const e=st.c(82),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:u,onRename:d,onDelete:h,children:f,mobileVariant:p,alwaysShowActions:g,isRenaming:w,renameDraft:S,onRenameDraftChange:x,onRenameSave:m,onRenameCancel:b,droppableRef:y,isDropTarget:v,onNewSession:N,depth:C,hideActions:k,archivedBucket:D}=t,P=a===void 0?null:a,M=g===void 0?p===void 0?!1:p:g,_=w===void 0?!1:w,O=S===void 0?"":S,U=v===void 0?!1:v,L=k===void 0?!1:k,F=D===void 0?!1:D,{t:R}=Nt(),[j,A]=c.useState(!1),[B,X]=c.useState(""),H=c.useRef(null),Z=_||j,ce=_?O:B;let Y;e[0]!==n.name?(Y=()=>{X(n.name),A(!0)},e[0]=n.name,e[1]=Y):Y=e[1];const se=Y;let oe;e[2]!==ce||e[3]!==n.name||e[4]!==_||e[5]!==d||e[6]!==m?(oe=()=>{const Ce=ce.trim();Ce&&Ce!==n.name&&d(Ce),_&&m&&m(),A(!1),X("")},e[2]=ce,e[3]=n.name,e[4]=_,e[5]=d,e[6]=m,e[7]=oe):oe=e[7];const Se=oe;let K;e[8]!==_||e[9]!==b?(K=()=>{_&&b&&b(),A(!1),X("")},e[8]=_,e[9]=b,e[10]=K):K=e[10];const pe=K;let je;e[11]!==_||e[12]!==x?(je=Ce=>{_&&x?x(Ce):X(Ce)},e[11]=_,e[12]=x,e[13]=je):je=e[13];const ne=je;let T,G;e[14]!==_?(T=()=>{if(!_)return;const Ce=()=>{const We=H.current;We&&(We.focus(),We.select())},ke=requestAnimationFrame(Ce),Qe=window.setTimeout(Ce,0);return()=>{cancelAnimationFrame(ke),window.clearTimeout(Qe)}},G=[_],e[14]=_,e[15]=T,e[16]=G):(T=e[15],G=e[16]),c.useEffect(T,G);const le=l?"folder":"folder-open",de=U&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let ue;e[17]!==de?(ue=Ie("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",de),e[17]=de,e[18]=ue):ue=e[18];let Oe;e[19]!==u||e[20]!==Z?(Oe=Z?void 0:Ce=>{Ce.currentTarget.blur(),u()},e[19]=u,e[20]=Z,e[21]=Oe):Oe=e[21];const me=Z?void 0:"button",Re=Z?void 0:0;let ye;e[22]!==u||e[23]!==Z?(ye=Z?void 0:Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),u())},e[22]=u,e[23]=Z,e[24]=ye):ye=e[24];let q;e[25]!==n.name||e[26]!==l||e[27]!==R?(q=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]=q):q=e[28];const we=F?M?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":M?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let be;e[29]!==we?(be=Ie("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",we),e[29]=we,e[30]=be):be=e[30];const Ne=U?"text-primary":"text-muted-foreground";let ie;e[31]!==Ne?(ie=Ie("h-3.5 w-3.5 flex-shrink-0",Ne),e[31]=Ne,e[32]=ie):ie=e[32];let ee;e[33]!==le||e[34]!==ie?(ee=s.jsx(E,{name:le,className:ie}),e[33]=le,e[34]=ie,e[35]=ee):ee=e[35];let V;e[36]!==P||e[37]!==r||e[38]!==ce||e[39]!==n.name||e[40]!==pe||e[41]!==ne||e[42]!==Se||e[43]!==l||e[44]!==U||e[45]!==Z||e[46]!==i||e[47]!==R?(V=Z?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:ij,onMouseDown:aj,onSubmit:Ce=>{Ce.preventDefault(),Se()},children:[s.jsx("input",{ref:H,value:ce,onChange:Ce=>ne(Ce.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:lj,onPointerDown:cj,onMouseDown:dj,onKeyDown:Ce=>{if(Ce.key==="Escape"){Ce.stopPropagation(),pe();return}(Ce.key===" "||Ce.key==="Enter")&&Ce.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:uj,onPointerDown:fj,onMouseDown:mj,children:s.jsx(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),pe()},onPointerDown:hj,onMouseDown:pj,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:Ie("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]}),P?s.jsx(df,{state:P,activeLabel:R("sessions.sidebar.session.status.active"),unreadLabel:R("sessions.sidebar.session.status.unread")}):null,l?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=P,e[37]=r,e[38]=ce,e[39]=n.name,e[40]=pe,e[41]=ne,e[42]=Se,e[43]=l,e[44]=U,e[45]=Z,e[46]=i,e[47]=R,e[48]=V):V=e[48];let $;e[49]!==be||e[50]!==ee||e[51]!==V?($=s.jsxs("div",{className:be,children:[ee,V]}),e[49]=be,e[50]=ee,e[51]=V,e[52]=$):$=e[52];let ae;e[53]!==M||e[54]!==F||e[55]!==n.name||e[56]!==se||e[57]!==L||e[58]!==h||e[59]!==N||e[60]!==Z||e[61]!==R?(ae=!Z&&(!L||F)?s.jsx("div",{className:Ie("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",M?"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:[!F&&N?s.jsx("button",{type:"button",onClick:Ce=>{Ce.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(E,{name:"add",className:"h-3.5 w-3.5"})}):null,F?null:s.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),se()},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(E,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),h()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":F?R("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):R("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=M,e[54]=F,e[55]=n.name,e[56]=se,e[57]=L,e[58]=h,e[59]=N,e[60]=Z,e[61]=R,e[62]=ae):ae=e[62];let W;e[63]!==y||e[64]!==ue||e[65]!==Oe||e[66]!==me||e[67]!==Re||e[68]!==ye||e[69]!==q||e[70]!==$||e[71]!==ae?(W=s.jsxs("div",{ref:y,className:ue,onClick:Oe,role:me,tabIndex:Re,onKeyDown:ye,"aria-label":q,children:[$,ae]}),e[63]=y,e[64]=ue,e[65]=Oe,e[66]=me,e[67]=Re,e[68]=ye,e[69]=q,e[70]=$,e[71]=ae,e[72]=W):W=e[72];let ve;e[73]!==f||e[74]!==l||e[75]!==i||e[76]!==o||e[77]!==R?(ve=l?null:s.jsxs("div",{className:"pb-1",children:[o,i.length>0?f: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]=f,e[74]=l,e[75]=i,e[76]=o,e[77]=R,e[78]=ve):ve=e[78];let Fe;return e[79]!==W||e[80]!==ve?(Fe=s.jsxs("div",{className:"oc-folder",children:[W,ve]}),e[79]=W,e[80]=ve,e[81]=Fe):Fe=e[81],Fe},oj=c.memo(rj);function ij(t){return t.stopPropagation()}function aj(t){return t.stopPropagation()}function lj(t){return t.stopPropagation()}function cj(t){return t.stopPropagation()}function dj(t){return t.stopPropagation()}function uj(t){return t.stopPropagation()}function fj(t){return t.stopPropagation()}function mj(t){return t.stopPropagation()}function hj(t){return t.stopPropagation()}function pj(t){return t.stopPropagation()}const gj=t=>{const e=st.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 u;e[4]!==l||e[5]!==a?(u={id:l,data:a},e[4]=l,e[5]=a,e[6]=u):u=e[6];const{attributes:d,listeners:h,setNodeRef:f,isDragging:p}=Vg(u);let g;e[7]!==h?(g=m=>{m.stopPropagation(),h?.onPointerDown&&h.onPointerDown(m)},e[7]=h,e[8]=g):g=e[8];const w=g,S=p?"opacity-30":void 0;let x;return e[9]!==d||e[10]!==o||e[11]!==w||e[12]!==f||e[13]!==S?(x=s.jsx("div",{ref:f,...d,onPointerDown:w,className:S,children:o}),e[9]=d,e[10]=o,e[11]=w,e[12]=f,e[13]=S,e[14]=x):x=e[14],x},xj=t=>{const e=st.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:u}=Ug(l);let d;e[5]!==r||e[6]!==u||e[7]!==a?(d=r(a,u),e[5]=r,e[6]=u,e[7]=a,e[8]=d):d=e[8];let h;return e[9]!==d?(h=s.jsx(s.Fragment,{children:d}),e[9]=d,e[10]=h):h=e[10],h},bj=t=>{const e=st.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=Vr(On(Fi,l)),[u,d]=c.useState(null),[h,f]=c.useState("Session"),[p,g]=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 x;e[3]!==i?(x=k=>{d(null),g(null),S(null);const{active:D,over:P}=k;if(!P)return;const I=D.data.current,M=P.data.current;I?.type==="session"&&I.sessionId&&M?.type==="folder"&&M.folderId&&i(I.sessionId,M.folderId)},e[3]=i,e[4]=x):x=e[4];const m=x;let b,y;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=k=>{const D=k.active.data.current;if(D?.type==="session"&&D.sessionId){d(D.sessionId),f(D.sessionTitle??"Session");const P=k.active.rect.current.initial?.width,I=k.active.rect.current.initial?.height;g(typeof P=="number"?P:null),S(typeof I=="number"?I:null)}},y=()=>{d(null),g(null),S(null)},e[5]=b,e[6]=y):(b=e[5],y=e[6]);let v;e[7]!==w||e[8]!==u||e[9]!==h||e[10]!==p||e[11]!==r?(v=u&&r?s.jsxs("div",{style:{width:p?`${p}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(E,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:h})]}):null,e[7]=w,e[8]=u,e[9]=h,e[10]=p,e[11]=r,e[12]=v):v=e[12];let N;e[13]!==v?(N=s.jsx(Bi,{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(Ur,{sensors:a,collisionDetection:Kr,onDragStart:b,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},sa=(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)},Hn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Hn(n,e))return!0;return!1},yj=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!wh(r),wj=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,Sj=(t,e,n)=>{const r=new Map,i=o=>{const l=Ts(o.session)??vt(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}))},vj=(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})},jj=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 u=a.pop();if(!(!u||r.has(u))){r.add(u);for(const d of n.get(u)??[])a.push(d.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},kj=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(d=>[d.id,d])),i=new Map,o=new Set;for(const d of t){if(d.parentId&&!r.has(d.parentId)){o.add(d.id);continue}if(d.parentId){const p=i.get(d.parentId)??[];p.push(d.id),i.set(d.parentId,p)}const h=new Set;let f=d.id;for(;f;){if(h.has(f)){o.add(d.id);break}h.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,u=d=>{if(l.has(d))return!0;if(a.has(d))return!1;const h=r.get(d);if(!h)return!1;a.add(d);let f=o.has(d);return!f&&e.archivedBucket&&h.nodeCount===0?f=(i.get(d)??[]).some(u):(!f&&!e.searchQuery&&(f=!0),!f&&(h.nodeCount>0||!n&&Ao([h.name],e.searchQuery))&&(f=!0),f||(f=(i.get(d)??[]).some(u))),a.delete(d),f&&l.add(d),f};return t.forEach(d=>u(d.id)),new Set(t.filter(d=>l.has(d.id)).map(d=>d.id))},bc=new WeakMap;let yc=1;const Cj=t=>{const e=bc.get(t);if(e!==void 0)return e;const n=yc;return yc+=1,bc.set(t,n),n},Bo=t=>t.children.length===0?"":t.children.map(n=>{const r=Cj(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Bo(n)}`}).join("|"),uf=(t,e,n,r,i,o)=>{const l=us(),a=(u,d)=>{if(u.session.id!==d.session.id||u.children.length!==d.children.length)return!0;const h=u.session.directory??i,f=d.session.directory??o,p=ol(l,h??"",u.session.id),g=ol(l,f??"",d.session.id);return(p?n.has(p):!1)!==(g?r.has(g):!1)?!0:u.children.some((w,S)=>a(w,d.children[S]))};return a(t,e)},Nj=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,Gr=(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 d of a.children)if(l(d))return!0;return!1};return t.forEach(a=>l(a)),o};let na=!1;const ra=new Set;let wc=!1;function Aj(){for(const t of ra)t()}function za(t){na!==t&&(na=t,Aj())}function Dj(t){t.key==="Shift"&&za(!0)}function Pj(t){t.key==="Shift"&&za(!1)}function Ij(){za(!1)}function Tj(){wc||typeof window>"u"||(wc=!0,window.addEventListener("keydown",Dj),window.addEventListener("keyup",Pj),window.addEventListener("blur",Ij))}function Rj(t){return Tj(),ra.add(t),()=>{ra.delete(t)}}function Ej(){return na}function Mj(){return!1}function Oj(){return gt.useSyncExternalStore(Rj,Ej,Mj)}const Fj=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,ff=/^g[1-9]\d*$/,Dr=(t,e,n,r,i)=>{if(!Fj.test(t)||e!==void 0&&!ff.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}},So=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 Dr(n,void 0,e[1],e[2],void 0);if(e.length===4){const[,a,u,d]=e;return ff.test(a)?Dr(n,a,u,d,void 0):Dr(n,void 0,a,u,d)}const[,r,i,o,l]=e;return r===""?Dr(n,void 0,i,o,l):Dr(n,r,i,o,l)},Bj=t=>{const e=[t.groupSlug];return t.runGroup&&e.push(t.runGroup),e.push(t.providerID,t.modelID),t.index!==void 0&&e.push(String(t.index)),e.join("/")},_j=(t,e,n,r)=>{const i=[t];return r&&i.push(r),i.push(e,n,"fusion"),i.join("/")},mf=t=>{const e=st.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:u}=Nt(),d=qt(Lj),h=qt($j),f=qt(Wj);let p;e[0]!==d?(p=d(),e[0]=d,e[1]=p):p=e[1];const g=p;let w;e[2]!==g?(w=g.filter(zj),e[2]=g,e[3]=w):w=e[3];const S=w;let x,m;e[4]!==g.length||e[5]!==h?(x=()=>{g.length===0&&h()},m=[g.length,h],e[4]=g.length,e[5]=h,e[6]=x,e[7]=m):(x=e[6],m=e[7]),c.useEffect(x,m);let b,y;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==S||e[12]!==n?(b=()=>{if(o)return;const _=n.trim();if(_.length>0&&S.some(L=>L.name===_))return;const O=typeof f=="string"&&f.trim().length>0?f.trim():null;if(O&&S.some(L=>L.name===O)){r(O);return}const U=S[0]?.name;U&&r(U)},y=[f,o,r,S,n],e[8]=f,e[9]=o,e[10]=r,e[11]=S,e[12]=n,e[13]=b,e[14]=y):(b=e[13],y=e[14]),c.useEffect(b,y);const v=n.trim().length>0?n:void 0;let N;e[15]!==i?(N=Ie("max-w-full",i),e[15]=i,e[16]=N):N=e[16];let C;e[17]!==u?(C=u("multirun.agentSelector.placeholder"),e[17]=u,e[18]=C):C=e[18];let k;e[19]!==C?(k=s.jsx(As,{placeholder:C}),e[19]=C,e[20]=k):k=e[20];let D;e[21]!==l||e[22]!==N||e[23]!==k?(D=s.jsx(Bs,{id:l,size:"lg",className:N,children:k}),e[21]=l,e[22]=N,e[23]=k,e[24]=D):D=e[24];let P;e[25]!==S?(P=S.length>0&&s.jsx(Ii,{children:S.map(Vj)}),e[25]=S,e[26]=P):P=e[26];let I;e[27]!==a||e[28]!==P?(I=s.jsx(_s,{fitContent:!0,portalToBody:a,children:P}),e[27]=a,e[28]=P,e[29]=I):I=e[29];let M;return e[30]!==o||e[31]!==r||e[32]!==v||e[33]!==D||e[34]!==I?(M=s.jsxs(Fs,{value:v,onValueChange:r,disabled:o,children:[D,I]}),e[30]=o,e[31]=r,e[32]=v,e[33]=D,e[34]=I,e[35]=M):M=e[35],M};function Lj(t){return t.getVisibleAgents}function $j(t){return t.loadAgents}function Wj(t){return t.currentAgentName}function zj(t){return $d(t.mode)}function Vj(t){return s.jsx(ss,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const Uj="h-7",Lr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Kj=t=>{const e=st.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 u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=Ie("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",Uj),e[0]=u):u=e[0];let d;e[1]!==n.providerID?(d=s.jsx(Ti,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=d):d=e[2];let h;e[3]!==a?(h=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(E,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let p;e[6]!==o?(p=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=o,e[7]=p):p=e[7];let g;return e[8]!==d||e[9]!==h||e[10]!==p?(g=s.jsxs("div",{className:u,children:[d,h,p]}),e[8]=d,e[9]=h,e[10]=p,e[11]=g):g=e[11],g},hf=t=>{const e=st.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:u,maxModels:d,addButtonClassName:h,dropdownSide:f,dropdownClassName:p,containerClassName:g,triggerIcon:w}=t,S=u===void 0?!0:u,x=f===void 0?"top":f,{t:m}=Nt(),b=qt(Hj),y=qt(Gj),v=Te(qj),N=Te(Qj),{favoriteModelsList:C,recentModelsList:k}=Sh(),D=Te(Yj),P=Te(Xj),[I,M]=c.useState(!1),[_,O]=c.useState(""),[U,L]=c.useState(null),F=c.useRef(null),R=c.useRef(null),j=d===1,A=d===void 0||n.length<d||j;let B;if(e[0]!==n){B=new Map;for(const Ae of n){const at=`${Ae.providerID}:${Ae.modelID}`;B.set(at,(B.get(at)||0)+1)}e[0]=n,e[1]=B}else B=e[1];const X=B;let H;e[2]!==n?(H=Ae=>n.filter(Ue=>Ue.providerID===Ae.providerID&&Ue.modelID===Ae.modelID).findIndex(Ue=>Ue.instanceId===Ae.instanceId)+1,e[2]=n,e[3]=H):H=e[3];const Z=H;let ce,Y;e[4]!==x||e[5]!==I?(ce=()=>{if(!I||!R.current)return;const Ae=R.current.getBoundingClientRect();if(x==="bottom"){const ge=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Ae.bottom-16-112;L(Math.max(160,Math.min(320,ge)));return}let at=R.current.parentElement;for(;at&&!at.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const ut=getComputedStyle(at);if(ut.overflow==="auto"||ut.overflow==="hidden"||ut.overflowY==="auto"||ut.overflowY==="hidden")break;at=at.parentElement}const Ue=at?at.getBoundingClientRect().top:0,ht=Ae.top-Ue-16;L(Math.max(150,Math.min(300,ht)))},Y=[x,I],e[4]=x,e[5]=I,e[6]=ce,e[7]=Y):(ce=e[6],Y=e[7]),c.useEffect(ce,Y);let se,oe;e[8]!==A||e[9]!==I?(se=()=>{!A&&I&&(M(!1),O(""))},oe=[A,I],e[8]=A,e[9]=I,e[10]=se,e[11]=oe):(se=e[10],oe=e[11]),c.useEffect(se,oe);let Se,K;e[12]!==I?(Se=()=>{if(!I)return;const Ae=at=>{F.current&&!F.current.contains(at.target)&&(M(!1),O(""))};return document.addEventListener("mousedown",Ae),()=>document.removeEventListener("mousedown",Ae)},K=[I],e[12]=I,e[13]=Se,e[14]=K):(Se=e[13],K=e[14]),c.useEffect(Se,K);let pe;e[15]!==j||e[16]!==r||e[17]!==o||e[18]!==n.length?(pe=Ae=>{const at={providerID:Ae.providerID,modelID:Ae.modelID,displayName:Ae.model.name||Ae.modelID,instanceId:Lr()};j&&n.length>0&&o?o(0,at):r(at),j&&(M(!1),O(""))},e[15]=j,e[16]=r,e[17]=o,e[18]=n.length,e[19]=pe):pe=e[19];const je=pe;let ne;e[20]!==m?(ne=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=ne):ne=e[21];let T;e[22]!==m?(T=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=T):T=e[23];let G;e[24]!==m?(G=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=G):G=e[25];let le;e[26]!==m?(le=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=le):le=e[27];let de;e[28]!==m?(de=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=de):de=e[29];let ue;e[30]!==m?(ue=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=ue):ue=e[31];let Oe;e[32]!==m?(Oe=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=Oe):Oe=e[33];let me;e[34]!==m?(me=m("chat.modelControls.capabilities"),e[34]=m,e[35]=me):me=e[35];let Re;e[36]!==m?(Re=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=Re):Re=e[37];let ye;e[38]!==m?(ye=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=ye):ye=e[39];let q;e[40]!==m?(q=m("chat.modelControls.input"),e[40]=m,e[41]=q):q=e[41];let we;e[42]!==m?(we=m("chat.modelControls.output"),e[42]=m,e[43]=we):we=e[43];let be;e[44]!==m?(be=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=be):be=e[45];let Ne;e[46]!==ne||e[47]!==T||e[48]!==G||e[49]!==le||e[50]!==de||e[51]!==ue||e[52]!==Oe||e[53]!==me||e[54]!==Re||e[55]!==ye||e[56]!==q||e[57]!==we||e[58]!==be?(Ne={searchPlaceholder:ne,noResults:T,favorites:G,recent:le,keyboardHint:de,favorite:ue,unfavorite:Oe,capabilities:me,capabilityToolCalling:Re,capabilityReasoning:ye,input:q,output:we,costPerMillion:be},e[46]=ne,e[47]=T,e[48]=G,e[49]=le,e[50]=de,e[51]=ue,e[52]=Oe,e[53]=me,e[54]=Re,e[55]=ye,e[56]=q,e[57]=we,e[58]=be,e[59]=Ne):Ne=e[59];const ie=Ne;let ee;e[60]!==g?(ee=Ie("relative",g),e[60]=g,e[61]=ee):ee=e[61];const V=I?"":void 0;let $;e[62]!==h?($=Ie(Wd({size:"default"}),"w-fit",h),e[62]=h,e[63]=$):$=e[63];const ae=!A;let W;e[64]!==I?(W=()=>{M(!I)},e[64]=I,e[65]=W):W=e[65];let ve;e[66]!==w?(ve=w??s.jsx(E,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=w,e[67]=ve):ve=e[67];let Fe;e[68]!==a||e[69]!==m?(Fe=a??m("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=m,e[70]=Fe):Fe=e[70];let Ce;e[71]!==V||e[72]!==$||e[73]!==ae||e[74]!==W||e[75]!==ve||e[76]!==Fe?(Ce=s.jsxs("button",{ref:R,type:"button","data-popup-open":V,className:$,disabled:ae,onClick:W,children:[ve,Fe]}),e[71]=V,e[72]=$,e[73]=ae,e[74]=W,e[75]=ve,e[76]=Fe,e[77]=Ce):Ce=e[77];let ke;e[78]!==U||e[79]!==A||e[80]!==p||e[81]!==x||e[82]!==C||e[83]!==je||e[84]!==D||e[85]!==N||e[86]!==I||e[87]!==ie||e[88]!==X||e[89]!==y||e[90]!==P||e[91]!==b||e[92]!==k||e[93]!==_||e[94]!==v?(ke=I?s.jsx("div",{className:Ie("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",x==="top"?"bottom-full mb-1":"top-full mt-1",p),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(vh,{providers:b,providerOrder:P,favoriteModels:C,recentModels:k,modelsMetadata:y,hiddenModels:D,searchQuery:_,onSearchQueryChange:O,onSelect:je,labels:ie,selectionCount:Ae=>X.get(`${Ae.providerID}:${Ae.modelID}`)||0,disabled:!A,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:U?`${U}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:I,isFavorite:Ae=>N(Ae.providerID,Ae.modelID),onToggleFavorite:Ae=>v(Ae.providerID,Ae.modelID),onEscape:()=>{M(!1),O("")}})}):null,e[78]=U,e[79]=A,e[80]=p,e[81]=x,e[82]=C,e[83]=je,e[84]=D,e[85]=N,e[86]=I,e[87]=ie,e[88]=X,e[89]=y,e[90]=P,e[91]=b,e[92]=k,e[93]=_,e[94]=v,e[95]=ke):ke=e[95];let Qe;e[96]!==ee||e[97]!==Ce||e[98]!==ke?(Qe=s.jsxs("div",{className:ee,ref:F,children:[Ce,ke]}),e[96]=ee,e[97]=Ce,e[98]=ke,e[99]=Qe):Qe=e[99];let We;e[100]!==Z||e[101]!==X||e[102]!==i||e[103]!==o||e[104]!==b||e[105]!==n||e[106]!==S||e[107]!==m?(We=S&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Ae,at)=>{const Ue=`${Ae.providerID}:${Ae.modelID}`,ht=X.get(Ue)||1,ut=Z(Ae),ge=b.find(fe=>fe.id===Ae.providerID)?.models?.find(fe=>fe.id===Ae.modelID),Ye=ge?.variants?Object.keys(ge.variants):[],bt=Ye.length>0,jt=Ae.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Kj,{model:Ae,instanceIndex:ut,totalSameModel:ht,onRemove:()=>i(at)}),bt&&s.jsxs(Fs,{value:jt,onValueChange:fe=>{if(!o)return;o(at,{...Ae,variant:fe==="__default__"?void 0:fe})},children:[s.jsxs(Bs,{size:"sm",className:"gap-1.5",children:[s.jsx(E,{name:"brain-ai-3",className:Ie("h-3.5 w-3.5 flex-shrink-0",jt==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(As,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:fe=>fe==="__default__"?m("multirun.modelMultiSelect.variant.default"):fe})]}),s.jsxs(_s,{fitContent:!0,children:[s.jsx(ss,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),Ye.map(Jj)]})]})]},Ae.instanceId)})}),e[100]=Z,e[101]=X,e[102]=i,e[103]=o,e[104]=b,e[105]=n,e[106]=S,e[107]=m,e[108]=We):We=e[108];let z;e[109]!==Qe||e[110]!==We?(z=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[Qe,We]}),e[109]=Qe,e[110]=We,e[111]=z):z=e[111];let he;e[112]!==d||e[113]!==l||e[114]!==n.length||e[115]!==m?(he=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:d!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:l,max:d}):m("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=d,e[113]=l,e[114]=n.length,e[115]=m,e[116]=he):he=e[116];let Be;return e[117]!==z||e[118]!==he?(Be=s.jsxs("div",{className:"space-y-2",children:[z,he]}),e[117]=z,e[118]=he,e[119]=Be):Be=e[119],Be};function Hj(t){return t.providers}function Gj(t){return t.modelsMetadata}function qj(t){return t.toggleFavoriteModel}function Qj(t){return t.isFavoriteModel}function Yj(t){return t.hiddenModels}function Xj(t){return t.providerOrder}function Jj(t){return s.jsx(ss,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const Zj=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
|
|
915
|
+
|
|
916
|
+
--- RESULT ${n+1}: ${r} ---
|
|
917
|
+
${e.trim()}
|
|
918
|
+
--- END RESULT ${n+1} ---`},Sc=(t,e)=>Je.getState().getWorktreeMetadata(t)?.projectDirectory??e,e2=async t=>{const e=t.directory??void 0,n=kh(t.session.id,e);if(n.length===0&&t.directory){const i=(await Qs.withDirectory(t.directory,()=>Qs.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 al(l.parts??[]).trim()}return""}for(let r=n.length-1;r>=0;r-=1){const i=n[r];if(i.role==="assistant")return al(Ch(i.id,e)).trim()}return""};function t2({session:t,open:e,onOpenChange:n}){const{t:r}=Nt(),i=jh(),o=Is(j=>j.activeSessions),l=Is(j=>j.archivedSessions),a=qt(j=>j.providers),u=qt(j=>j.currentProviderId),d=qt(j=>j.currentModelId),h=qt(j=>j.currentAgentName),[f,p]=c.useState(u??""),[g,w]=c.useState(d??""),[S,x]=c.useState(()=>u&&d?[{providerID:u,modelID:d,instanceId:Lr()}]:[]),[m,b]=c.useState(""),[y,v]=c.useState(h??""),[N,C]=c.useState([]),[k,D]=c.useState(!1),P=c.useMemo(()=>So(t.title),[t.title]),I=c.useMemo(()=>{const j=new Map;for(const A of i)j.set(A.id,A);for(const A of o)j.set(A.id,A);for(const A of l)j.set(A.id,A);return t.id&&j.set(t.id,t),Array.from(j.values())},[o,l,i,t]);c.useEffect(()=>{if(!e||!P)return;const j=Je.getState().getDirectoryForSession(t.id),A=Sc(t.id,j),B=I.map(X=>{const H=So(X.title);if(!H||H.groupSlug!==P.groupSlug||H.fusion||(H.runGroup??null)!==(P.runGroup??null))return null;const Z=Je.getState().getDirectoryForSession(X.id)??Ts(X),ce=Sc(X.id,Z);return A&&ce&&A!==ce?null:{session:X,directory:Z,projectDirectory:ce}}).filter(X=>X!==null).sort((X,H)=>(X.session.time?.created??0)-(H.session.time?.created??0));C(B)},[I,e,P,t.id]);const _=a.find(j=>j.id===f)?.models.find(j=>j.id===g),O=_?.variants?Object.keys(_.variants):[],U=!!(P&&f&&g&&N.length>0&&!k),L=c.useCallback(j=>{x([j]),p(j.providerID),w(j.modelID),b("")},[]),F=S[0]?.displayName||S[0]?.modelID||r("multirun.fusion.model.placeholder"),R=async()=>{if(!(!P||!f||!g)){D(!0);try{const j=await Promise.all(N.map(Y=>e2(Y))),A=N.map((Y,se)=>({source:Y,text:j[se]??""})).filter(Y=>Y.text.trim().length>0);if(A.length===0){Le.error(r("multirun.fusion.toast.noOutputs"));return}const B=N[0]?.projectDirectory??N[0]?.directory??null,X=_j(P.groupSlug,f,g,P.runGroup),[H,Z]=await Promise.all([il("session.fusion.visible"),il("session.fusion.instructions")]),ce=await Je.getState().createSession(X,B,null);if(!ce)throw new Error("Failed to create fusion session");Je.getState().setCurrentSession(ce.id,B),n(!1),await Qs.sendMessage({id:ce.id,providerID:f,modelID:g,variant:m||void 0,agent:y||void 0,text:H,additionalParts:[{text:Z,synthetic:!0},...A.map((Y,se)=>({text:Zj(Y.source,Y.text,se),synthetic:!0})),{text:`
|
|
919
|
+
|
|
920
|
+
--- FUSION INPUTS END ---
|
|
921
|
+
Now write the final fused answer.`,synthetic:!0}],directory:B??Qs.getDirectory()})}catch(j){console.error("[MultiRunFusion] Failed to start fusion",j),Le.error(r("multirun.fusion.toast.failed"))}finally{D(!1)}}};return s.jsx(vs,{open:e,onOpenChange:n,children:s.jsxs(js,{className:"max-w-xl overflow-visible",children:[s.jsxs($s,{children:[s.jsx(Rs,{children:r("multirun.fusion.title")}),s.jsx(Es,{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(hf,{selectedModels:S,onAdd:L,onUpdate:(j,A)=>L(A),onRemove:()=>{x([]),p(""),w(""),b("")},maxModels:1,addButtonLabel:F,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:f?s.jsx(Ti,{providerId:f,className:"h-3.5 w-3.5 mr-1"}):void 0})}),O.length>0?s.jsxs(Fs,{value:m||"__default__",onValueChange:j=>b(j==="__default__"?"":j),children:[s.jsxs(Bs,{size:"lg",className:"w-fit",children:[s.jsx(E,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(As,{children:j=>j==="__default__"?r("multirun.modelMultiSelect.variant.default"):j})]}),s.jsxs(_s,{fitContent:!0,portalToBody:!0,children:[s.jsx(ss,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),O.map(j=>s.jsx(ss,{value:j,children:j},j))]})]}):null,s.jsx(mf,{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(Ti,{providerId:So(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(A=>A.filter(B=>B.session.id!==j.session.id)),className:"text-muted-foreground hover:text-foreground",children:s.jsx(E,{name:"close",className:"h-4 w-4"})})]},j.session.id))})]}),s.jsxs(yn,{children:[s.jsx(xt,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(xt,{onClick:R,disabled:!U,children:r(k?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function s2(t){const e=st.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 pf=async(t,e,n)=>{const r=n.getRuntimeKey(),i=vt(t.path);if(!i)throw new Error("Unable to resolve worktree project");const o=await n.listProjectWorktrees(t,{force:!0});if(n.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const l=n.getCurrentProjects(),a=l.find(w=>w.id===t.id)??null;if(!a||vt(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const u=Va({rawWorktreesByProjectRef:n.rawWorktreesByProjectRef,publishedWorktreesByProject:n.getPublishedWorktreesByProject(),runtimeKey:r}),d=o.map(w=>_o(w));d.sort((w,S)=>gf({metadata:w},{metadata:S}));const h=Nh(u.worktreesByProject,i,d,e?.projectDirectory);n2(n.rawWorktreesByProjectRef,r),n.rawWorktreesByProjectRef.current={runtimeKey:r,revision:n.rawWorktreesByProjectRef.current.revision,worktreesByProject:h};const f=n.getPublishedWorktreesByProject(),p=Ah(n.partitionWorktreesByRegisteredProject(l,h),f),g=[...p.values()].flat();return n.recordWorktreesSeen(g.map(w=>w.path),n.now()),n.worktreeMapsEqual(p,f)||n.publishTopology({availableWorktrees:g,availableWorktreesByProject:p}),d},n2=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),r2=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>_o(r))])),Va=t=>((t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey||t.rawWorktreesByProjectRef.current.worktreesByProject.size===0&&t.publishedWorktreesByProject.size>0)&&(t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.rawWorktreesByProjectRef.current.runtimeKey===t.runtimeKey?t.rawWorktreesByProjectRef.current.revision:0,worktreesByProject:r2(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),gf=(t,e)=>{const n=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=n.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},vc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},_o=t=>({...t,path:vt(t.path)??t.path,projectDirectory:vt(t.projectDirectory)??t.projectDirectory,worktreeRoot:vt(t.worktreeRoot??t.path)??t.worktreeRoot}),jc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=vt(e?.path??null)===n,a=l?e?.branch??"":i??"",u={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||vc(n):i||vc(n),name:l?e?.name:void 0,worktreeRoot:l?vt(e?.worktreeRoot??n)??n:n,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:i?"branch":void 0};return l&&e?{...e,...u}:u},kc=t=>{const e=vt(t.projectPath??null),n=vt(t.sourceDirectory??null)??vt(t.currentWorktree?.path??null),r=vt(t.discoveredWorktrees.find(h=>vt(h.projectDirectory??null))?.projectDirectory??null),i=vt(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=h=>{const f=vt(h.metadata.path??null);!f||l.has(f)||l.set(f,{...h,metadata:_o({...h.metadata,path:f})})};for(const h of t.discoveredWorktrees){const f=vt(h.path??null);f&&a({metadata:_o({...h,path:f,projectDirectory:vt(h.projectDirectory??null)??o??e??f}),isPrimary:o===f,isCurrent:n===f})}o&&!l.has(o)&&a({metadata:jc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:jc({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const u=[],d=[];for(const h of l.values()){if(h.isPrimary){u.push(h);continue}d.push(h)}return u.sort((h,f)=>h.metadata.path.localeCompare(f.metadata.path,void 0,{sensitivity:"base"})),d.sort(gf),[...u,...d]},o2=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=Va({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),l=(t.projectId?e.projects.find(d=>d.id===t.projectId)??null:null)??(t.sourceDirectory?e.resolveProject(t.sourceDirectory):null),a=vt(l?.path??null);return{cachedTargets:kc({projectPath:a,discoveredWorktrees:a?i.worktreesByProject.get(a)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!l||!a)throw new Error("Unable to resolve worktree project");const d=await pf(l,t.currentWorktree,e);return kc({projectPath:a,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},i2=t=>{if(t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey)return!1;if(t.rawWorktreesByProjectRef.current.revision!==t.capturedRevision)return t.requestRediscovery(),!1;const e=t.partitionWorktreesByRegisteredProject(t.projects,t.nextRawWorktreesByProject),n=[...e.values()].flat();return t.recordWorktreesSeen(n.map(r=>r.path),t.now()),t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.capturedRevision,worktreesByProject:new Map(t.nextRawWorktreesByProject)},t.worktreeMapsEqual(e,t.publishedWorktreesByProject)||t.publishTopology({availableWorktrees:n,availableWorktreesByProject:e}),!0},a2=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),l2=(t,e)=>vt(t.worktree?.path??null)===vt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,oa=6,lo=14,Cc=oa+14+6,pi=new WeakMap,c2=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;pi.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,pi.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},u=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const d=e.getBoundingClientRect().top-r;if(Math.abs(d)>.5&&(n.scrollTop+=d,qs("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(u)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),pi.set(n,a),l=window.requestAnimationFrame(u)},d2=c.memo(function(e){const n=st.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:u,onArchive:d,onDelete:h}=e,f=Oj(),p=f?i:r;let g;n[0]!==d||n[1]!==h||n[2]!==f?(g=C=>{if(f||C.shiftKey){h(C);return}d(C)},n[0]=d,n[1]=h,n[2]=f,n[3]=g):g=n[3];const w=g,S=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let x;n[4]!==o||n[5]!==S?(x=Ie("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]=x):x=n[6];const m=f?"delete-bin":"archive";let b;n[7]!==l||n[8]!==m?(b=s.jsx(E,{name:m,className:l}),n[7]=l,n[8]=m,n[9]=b):b=n[9];let y;n[10]!==w||n[11]!==p||n[12]!==u||n[13]!==a||n[14]!==x||n[15]!==b?(y=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:x,"aria-label":p,onPointerDown:a,onMouseDown:u,onClick:w,onKeyDown:y2,children:b})}),n[10]=w,n[11]=p,n[12]=u,n[13]=a,n[14]=x,n[15]=b,n[16]=y):y=n[16];let v;n[17]!==p?(v=s.jsx(Pt,{side:"left",sideOffset:8,children:p}),n[17]=p,n[18]=v):v=n[18];let N;return n[19]!==y||n[20]!==v?(N=s.jsxs(At,{children:[y,v]}),n[19]=y,n[20]=v,n[21]=N):N=n[21],N});function u2(t){qs("ui.sidebar_session_node.render");const{t:e}=Nt(),{node:n,depth:r=0,groupDirectory:i,projectId:o,archivedBucket:l=!1,pinnedSessionIds:a,expandedParents:u,hasSessionSearchQuery:d,normalizedSessionSearchQuery:h,notifyOnSubtasks:f,editingId:p,setEditingId:g,editTitle:w,setEditTitle:S,handleSaveEdit:x,handleCancelEdit:m,toggleParent:b,handleSessionSelect:y,handleSessionDoubleClick:v,handleShareSession:N,copiedSessionId:C,handleCopyShareUrl:k,handleCopySessionId:D,handleUnshareSession:P,openSidebarMenuKey:I,setOpenSidebarMenuKey:M,createFolderAndStartRename:_,handleDeleteSession:O,handleRestoreSession:U,startSessionWorktreeMenuLoad:L,mobileVariant:F,alwaysShowActions:R,secondaryMeta:j,renderContext:A="project",children:B}=t,X=Wr(De=>De.toggle),H=cs(De=>De.getFoldersForScope),Z=cs(De=>De.getSessionFolderId),ce=cs(De=>De.removeSessionFromFolder),Y=cs(De=>De.addSessionToFolder),se=Te(De=>De.openContextPanelTab),oe=c.useMemo(()=>Pn(),[]),Se=c.useMemo(()=>Vo(),[]),K=c.useContext(Dh),pe=oe?"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",je=oe?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",ne=oe,T=!l&&!F,G=oe?T&&ne?"group-hover:pr-18":T||ne?"group-hover:pr-14":"group-hover:pr-8":T?"group-hover:pr-7 group-focus-within:pr-7":"group-hover:pr-3 group-focus-within:pr-3",le=T?"pr-13":"pr-7",de=oe?T?"pr-18":"pr-14":T?"pr-7":"pr-3",ue=c.useRef(!1),[Oe,me]=c.useState(!1),Re=c.useRef(p);Re.current=p;const ye=c.useRef(null),q=c.useRef(!1),we=c.useRef(x);we.current=x;const[be,Ne]=c.useState(w),ie=c.useRef(be);ie.current=be;const ee=c.useRef(null),V=c.useRef(!1),$=c.useRef(null),ae=c.useRef(null),W=n.session,ve=W,Fe=Ht(c.useCallback(De=>{if(j?.projectLabel||!o)return null;const Ft=De.projects.find(Qt=>Qt.id===o);return Ft?Ft.label?.trim()||Fn(vt(Ft.path)??Ft.path,null)||Ft.path:null},[o,j?.projectLabel])),Ce=j?.projectLabel??(Fe?Pa(Fe):null),ke=j?.branchLabel??n.worktree?.branch??null,Qe=c.useMemo(()=>{if(oe)return null;const De=n.worktree?.branch?.trim(),Ft=vt(n.worktree?.path??null);return De&&Ft?Ho(Ft,De):null},[oe,n.worktree]),We=zd(Qe),z=We?`var(--pr-${We.visualState})`:void 0,he=ls(De=>De.sessionGroupingMode),Be=!!ke&&(A==="recent"||he==="flat"),Ae=c.useMemo(()=>{if(!We)return null;switch(We.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return We.canMerge===!0||We.mergeableState==="clean"||We.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return We.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}},[We,e]),at=Je(De=>De.currentSessionId===W.id),Ue=vt(W.directory??null)??vt(i??null),ht=o??Ue??null,ut=Ph(),Ct=Vd(),ge=oe,Ye=xs(De=>De.enabled),bt=xs(c.useCallback(De=>De.selectedIds.has(W.id),[W.id])),jt=xs(De=>De.toggleSelected),fe=xs(De=>De.setRange),ze=c.useCallback(De=>{const Ft=[],Qt=is=>{is.children.forEach(ws=>{Ft.push(ws.session.id),Qt(ws)})};return Qt(De),Ft},[]),it=c.useCallback(De=>{const Ft=[],Qt=is=>{is.children.forEach(ws=>{Ft.push(ws.session),Qt(ws)})};return Qt(De),Ft},[]),[$e,J]=c.useState(!1),[re,Pe]=c.useState(!0),_e=`${A}:${l?"archived":"active"}:${W.id}`,Ve=Ud(c.useCallback(De=>!!De.sessionMemoryState.get(Ih(W.id))?.isZombie,[W.id])),lt=pa(W.id)?.type??"idle",rt=lt==="busy"||lt==="retry",Ge=Th(W.id,rt),ot=Au(W.id),Ee=Ra(W.id,Ue),Rt=ot||Ee,xe=n.worktree??Je.getState().getWorktreeMetadata(W.id)??null,[mt,Tt]=c.useState([]),[Xe,nt]=c.useState(!1),[St,yt]=c.useState(!1),It=c.useRef(!1),kt=c.useRef(0),Et=Rh(W.id,Ue??void 0,{bootstrap:!1}),Bt=Eh(ve),zt=Bt?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(ll[Bt.status]),"aria-label":e(ll[Bt.status]),children:s.jsx(E,{name:"target",className:"h-3 w-3",style:{color:Mh[Bt.status]}})}):null,Gt=ve.title||e("sessions.sidebar.session.untitled"),rs=n.children.length>0,_t=Oh(a,Ue,W.id),Wt=_e,Me=d?!0:u.has(Wt),qe=c.useMemo(()=>Sj(n,Me,Ue),[Me,n,Ue]),dt=Fh(qe),wt=!!ve.parentID,ct=pd(W.id)>0&&(!wt||f),Vt=ve.time?.updated||ve.time?.created||Date.now(),Xt=Kd(Vt),Jt=Bh(Vt),ks=I===_e,[ns,Ws]=c.useState(!1),bs=ks||ns,os=c.useMemo(()=>So(ve.title)!==null,[ve.title]),[Zs,zs]=c.useState(!1),dn=c.useMemo(()=>ze(n).length,[ze,n]),Ds=c.useCallback(async De=>{const Ft=[];let Qt=0;for(const is of De)try{if(!Ue)throw new Error("Session directory is required for export");const ws=await ut({directory:Ue,sessionID:is.session.id});if(!ws)throw new Error("Session runtime changed during export");const ps=is.session.title||e("sessions.sidebar.session.export.untitledSubagent"),sn=is.session.agent,es=await Ds(is.children);Qt+=es.skipped,Ft.push({title:ps,agent:sn,records:ws,children:es.children})}catch{Qt+=ze(is).length+1}return{children:Ft,skipped:Qt}},[ze,ut,Ue,e]),fs=c.useCallback(De=>{De<=0||Le.warning(De===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:De}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:De}))},[e]),Ps=c.useCallback(async De=>{if(!Ue){Le.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Ft=await ut({directory:Ue,sessionID:W.id}).catch(()=>null);if(!Ft){Le.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Ft.length===0){Le.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Qt,is=0;if(De&&n.children.length>0){const es=await Ds(n.children);Qt=es.children,is=es.skipped}const ws=ju(Ft,ve.title??null,Qt),ps=Nu(ve.title??null),sn=await Cu(ws,ps);if(sn){Le.success(e("sessions.sidebar.session.export.success"),{action:{label:e(sb()),onClick:()=>{tb(sn).then(es=>{es||Le.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),fs(is);return}ku(ws,ps),Le.success(e("sessions.sidebar.session.export.success")),fs(is)},[Ds,ut,n.children,ve.title,W.id,Ue,fs,e]),Vs=c.useCallback(async()=>{if(n.children.length>0){Pe(!0),J(!0);return}await Ps(!1)},[Ps,n.children.length]),Us=c.useCallback(()=>{Ue&&Mn("desktop_open_session_mini_chat_window",{sessionId:W.id,directory:Ue,apiBaseUrl:Nn(),clientToken:$r()}).catch(De=>{console.warn("[session-sidebar] failed to open mini chat window",De)})},[W.id,Ue]);if(c.useEffect(()=>{if(p!==W.id)return;const De=Ft=>{const is=(Ft.target instanceof HTMLElement?Ft.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(W.id)}"]`);ae.current&&!is&&we.current(ie.current)};return document.addEventListener("mousedown",De),()=>document.removeEventListener("mousedown",De)},[p,W.id]),c.useLayoutEffect(()=>{if(p!==W.id){ee.current===W.id&&(ee.current=null);return}ee.current!==W.id&&(ee.current=W.id,V.current=!0,Ne(w))},[p,w,W.id]),c.useLayoutEffect(()=>{if(p!==W.id||!V.current)return;const De=$.current;!De||De.value!==w||(V.current=!1,De.focus(),De.select())},[p,w,be,W.id]),p===W.id)return s.jsx("div",{style:{paddingLeft:Cc+r*lo},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:ae,"data-session-rename-form":W.id,className:"flex w-full items-center gap-2",onSubmit:De=>{De.preventDefault(),x(be)},children:[s.jsx("input",{ref:$,value:be,onChange:De=>Ne(De.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:De=>Mi(De,m)}),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(E,{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(E,{name:"close",className:"size-4"})})]})})},W.id);const Cs=Et.length,en=dt===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:dt}),Ot=Nj({actionsAlwaysVisible:R&&!oe,menuOpen:bs,hideOnHoverClass:je}),$t=!Rt&&!rt&&ct&&!at,Yt=rt||$t,ys=e(rt?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),ms=s.jsx("span",{className:Ie("h-1.5 w-1.5 rounded-full",rt?"bg-primary":"bg-[var(--status-info)]"),"aria-label":ys,title:ys}),te=(rt||$t)&&Ge,Ke=!R&&rs&&(Rt||Yt||_t),tt=_t&&!Rt&&!Yt,Q=s.jsx(E,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),He=Rt||Yt||tt?s.jsx("span",{style:{left:oa+r*lo},className:Ie("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",Ke?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:Rt?s.jsx(E,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e(Ee?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}):Yt?ms:tt?Q:null}):null,et=rs&&!R&&(Rt||Yt||_t),pt=rs?s.jsx("span",{role:"button",tabIndex:0,onClick:De=>{De.stopPropagation(),De.currentTarget.blur(),b(Wt)},onKeyDown:De=>{(De.key==="Enter"||De.key===" ")&&(De.preventDefault(),De.stopPropagation(),b(Wt))},style:{minWidth:14,minHeight:14,left:oa+r*lo},className:Ie("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",et?"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(Me?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:Me?s.jsx(E,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(E,{name:"arrow-right-s",className:"h-3 w-3"})}):null,Ut=Ve?s.jsx(E,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Zt=De=>{De&&Ws(!1),M(De?_e:null)},Lt=De=>{if(!De&&ye.current){const{id:Ft,title:Qt}=ye.current;ye.current=null,g(Ft),S(Qt)}},hs=De=>{Ws(De)},tn=De=>{De.preventDefault(),De.stopPropagation(),M(ks?null:_e)},Sr=De=>{De.preventDefault(),De.stopPropagation()},sr=De=>{De.preventDefault(),De.stopPropagation()},Tf=De=>{De.preventDefault(),De.stopPropagation()},Rf=De=>{De.preventDefault(),De.stopPropagation()},Ef=De=>{De.preventDefault(),De.stopPropagation(),M(null),O(W,{archivedBucket:l})},Mf=De=>{De.preventDefault(),De.stopPropagation(),M(null),O(W,{archivedBucket:l,hardDelete:!0,skipConfirm:!0})},Of=De=>{De.preventDefault(),De.stopPropagation()},Ff=De=>{De.preventDefault(),De.stopPropagation()},Bf=De=>{De.preventDefault(),De.stopPropagation(),K?.vscode?.executeCommand("aiworker.openSessionInEditor",W.id,Gt)},Ua=De=>{if(ue.current){ue.current=!1;return}if(Ye){if(De?.preventDefault(),De?.stopPropagation(),De?.shiftKey){const Qt=Array.from(document.querySelectorAll("[data-session-row]")).map(ps=>ps.getAttribute("data-session-row")).filter(ps=>ps!==null&&ps.length>0),is=xs.getState().anchorId,ws=new Map;ws.set(W.id,ze(n)),fe(is,W.id,Qt,ht,ws);return}jt(W.id,ht,ze(n));return}De?.currentTarget&&c2(De.currentTarget),y(W.id,Ue)},_f=De=>{De.defaultPrevented||(De.target instanceof HTMLElement?De.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||Ua(De)},Lf=De=>{(De.button===2||De.button===0&&De.ctrlKey&&!Ye)&&(ue.current=!0)},$f=De=>{F&&De.pointerType==="touch"&&me(!0),De.button===0&&!at&&!Ye&&!ge&&Ue&&!Pi(W.id,Ue).renderable&&Ct({directory:Ue,sessionID:W.id}).catch(()=>{})},Ka=De=>{F&&De.pointerType==="touch"&&me(!1)},Wf=De=>{It.current=De,kt.current+=1;const Ft=kt.current;if(!De){nt(!1),yt(!1);return}const Qt=L({projectId:o??null,sourceDirectory:Ue,currentWorktree:xe});Tt(Qt.cachedTargets),nt(!0),yt(!1),Qt.refreshTargets.then(is=>{!It.current||kt.current!==Ft||(Tt(is),nt(!1),yt(!1))}).catch(()=>{!It.current||kt.current!==Ft||(nt(!1),yt(!0))})},Ha=({Item:De,Separator:Ft,Sub:Qt,SubTrigger:is,SubContent:ws})=>s.jsxs(s.Fragment,{children:[s.jsxs(De,{onClick:()=>{ye.current={id:W.id,title:Gt}},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsx(Vi,{sessionID:W.id,directory:Ue,open:bs,Item:De}),s.jsxs(De,{onClick:()=>D(W.id),className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(De,{onClick:()=>Ue&&X({directory:Ue,sessionId:W.id}),className:"[&>svg]:mr-1",children:[_t?s.jsx(E,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(E,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(_t?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),ve.share?s.jsxs(s.Fragment,{children:[s.jsx(De,{onClick:()=>{ve.share?.url&&k(ve.share.url,W.id)},className:"[&>svg]:mr-1",children:C===W.id?s.jsxs(s.Fragment,{children:[s.jsx(E,{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(E,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyLink")]})}),s.jsxs(De,{onClick:()=>P(W.id),className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"link-unlink-m",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(De,{onClick:()=>N(ve),className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"share-2",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.share")]}),s.jsxs(De,{onClick:()=>{Vs()},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),yj({isSubtaskSession:wt,archivedBucket:!!l,isVSCode:oe,sessionDirectory:Ue})?(()=>{const ps=wj({sessionDirectory:Ue,isStreaming:rt,isMovingToWorktree:ot}),sn=a2({targets:mt,isRefreshing:Xe,loadFailed:St});return s.jsxs(Qt,{onOpenChange:Wf,children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs(is,{disabled:ps,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":W.id,children:[s.jsx(E,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(Pt,{side:"right",className:"max-w-72",children:e(ot?"sessions.sidebar.session.moveToWorktree.tooltipMoving":rt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(ws,{className:"min-w-[220px]","data-session-worktree-submenu":W.id,children:[mt.map(es=>{const nn=vt(es.metadata.path??null)??es.metadata.path,vr=es.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):es.metadata.label||es.metadata.branch||es.metadata.name||es.metadata.path,gs=es.isCurrent||es.metadata.worktreeStatus!=="ready";return s.jsxs(De,{disabled:gs,title:es.metadata.path,"data-session-worktree-target":nn,onClick:()=>{gs||!Ue||Hi({kind:"existing",root:ve,descendants:it(n),sourceDirectory:Ue,destination:es.metadata,messages:Ui(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[s.jsx("span",{className:"truncate",children:vr}),es.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),es.isCurrent?s.jsx(E,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},nn)}),sn.refreshState==="loading"?s.jsx(De,{disabled:!0,"data-session-worktree-refresh-state":"loading",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.refreshing")}):null,sn.refreshState==="error"?s.jsx(De,{disabled:!0,"data-session-worktree-refresh-state":"error",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.loadFailed")}):null,s.jsx(Ft,{}),s.jsxs(De,{disabled:ps,"data-session-worktree-new-action":"true",onClick:()=>{ps||!Ue||Hi({kind:"quick",root:ve,descendants:it(n),sourceDirectory:Ue,messages:Ui(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,os?s.jsxs(De,{onClick:()=>zs(!0),className:"[&>svg]:mr-1",children:[s.jsx(s2,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,Ue&&!l?(()=>{const ps=[],sn=gs=>{const Ns=vt(gs??null);Ns&&!ps.includes(Ns)&&ps.push(Ns)};if(o&&!oe){const gs=Ht.getState().projects.find(nr=>nr.id===o),Ns=vt(gs?.path??null);sn(Ns),Ns&&(Je.getState().availableWorktreesByProject.get(Ns)??[]).forEach(nr=>sn(nr.path))}sn(Hd(Ue)),sn(Ue);const es=ps.flatMap(gs=>H(gs).map(Ns=>({scope:gs,folder:Ns}))),nn=es.find(({scope:gs,folder:Ns})=>Z(gs,W.id)===Ns.id)??null,vr=ps[0]??Ue;return s.jsxs(s.Fragment,{children:[s.jsx(Ft,{}),s.jsxs(Qt,{children:[s.jsxs(is,{className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(ws,{className:"min-w-[180px]",children:[es.length===0?s.jsx(De,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):es.map(({scope:gs,folder:Ns})=>{const nr=nn?.folder.id===Ns.id;return s.jsxs(De,{onClick:()=>{if(nr){ce(gs,W.id);return}nn&&nn.scope!==gs&&ce(nn.scope,W.id),Y(gs,Ns.id,W.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:Ns.name}),nr?s.jsx(E,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},Ns.id)}),s.jsx(Ft,{}),s.jsxs(De,{onClick:()=>{const gs=_(vr);gs&&(q.current=!0,nn&&nn.scope!==vr&&ce(nn.scope,W.id),Y(vr,gs.id,W.id))},children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),nn?s.jsxs(De,{onClick:()=>{ce(nn.scope,W.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,oe?null:s.jsxs(De,{disabled:!Ue,onClick:()=>{Ue&&se(Ue,{mode:"chat",dedupeKey:`session:${W.id}`,label:Gt,sessionTitleFallback:Gt})},className:"[&>svg]:mr-1",children:[s.jsx(E,{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")})]}),Se?s.jsxs(De,{disabled:!Ue,onClick:Us,className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(Ft,{}),l?null:s.jsxs(De,{className:"[&>svg]:mr-1",onClick:()=>O(W,{archivedBucket:l}),children:[s.jsx(E,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),l?s.jsxs(De,{className:"[&>svg]:mr-1",onClick:()=>U(W),children:[s.jsx(E,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(De,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>O(W,{archivedBucket:l,hardDelete:!0}),children:[s.jsx(E,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),zf=s.jsx(Xs,{align:"end",className:"min-w-[180px]",finalFocus:()=>q.current?(q.current=!1,!1):!Re.current,children:Ha({Item:Kt,Separator:Os,Sub:Lh,SubTrigger:$h,SubContent:Wh})}),Vf=s.jsx(Li,{children:s.jsx($i,{className:"app-region-no-drag z-50",children:s.jsx(Wi,{"data-slot":"dropdown-menu-content",finalFocus:()=>q.current?(q.current=!1,!1):!Re.current,style:{color:"var(--surface-elevated-foreground)"},className:Ie(Si,"min-w-[180px]"),children:Ha({Item:({className:De,...Ft})=>s.jsx(fu,{className:Ie(xd,De),...Ft}),Separator:({className:De,...Ft})=>s.jsx(uu,{className:Ie(gd,De),...Ft}),Sub:qg,SubTrigger:({className:De,children:Ft,...Qt})=>s.jsxs(Qg,{className:Ie(_h,De),...Qt,children:[Ft,s.jsx(E,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:De,children:Ft,...Qt})=>s.jsx(Li,{children:s.jsx($i,{className:"app-region-no-drag z-50",children:s.jsx(Wi,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Ie(Si,De),...Qt,children:Ft})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(gj,{sessionId:W.id,sessionDirectory:Ue??null,sessionTitle:Gt,children:s.jsxs(hu,{open:ns,onOpenChange:hs,onOpenChangeComplete:Lt,children:[s.jsxs(mu,{render:s.jsx("div",{"data-session-row":W.id,"data-session-scope":ht??"","data-session-archived":l?"1":"0","aria-current":at?"page":void 0,onClick:_f,style:{paddingLeft:Cc+r*lo},className:Ie("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-1.5",at&&!bt&&"bg-primary/10",bt&&"bg-interactive-selection")}),children:[He,pt,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onPointerDown:$f,onPointerUp:Ka,onPointerCancel:Ka,onMouseDown:Lf,onClick:De=>Ua(De),onDoubleClick:De=>{De.stopPropagation(),v(W.id,Gt)},className:Ie("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]",Oe&&"bg-interactive-hover/70",R?oe?G:le:bs?de:G),children:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:Ie("block min-w-0 flex-1 truncate typography-ui-label font-normal",at?"text-primary":ct?"text-foreground":"text-foreground/80"),children:po(Gt,h)}),!l&&Ue&&(A==="recent"||he==="flat"&&n.worktree&&vt(n.worktree.path)!==vt(n.worktree.projectDirectory))?s.jsx(Hr,{directory:Ue,className:R?void 0:bs?"mr-1":oe?"group-hover:mr-1":"group-hover:mr-1 group-focus-within:mr-1"}):null,R?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",children:te?s.jsx(jl,{sessionId:W.id,running:rt}):s.jsxs(s.Fragment,{children:[zt,Be?s.jsx(E,{name:"git-branch",className:Ie("h-3 w-3",!z&&"text-muted-foreground/60"),style:z?{color:z}:void 0}):null,Jt]})}):te||zt||Be||A==="recent"?s.jsx("div",{className:Ie("relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",bs?"hidden":oe?"group-hover:hidden":"group-hover:hidden group-focus-within:hidden"),children:s.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:te?s.jsx(jl,{sessionId:W.id,running:rt,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[zt,Be?s.jsx(E,{name:"git-branch",className:Ie("h-3 w-3",!z&&"text-muted-foreground/60"),style:z?{color:z}:void 0}):null,A==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:Jt}):null]})})}):null,Cs>0?s.jsxs("span",{className:Ie("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",Ot),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(E,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Cs})]}):null,dt>0?s.jsxs("span",{className:Ie("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",Ot),title:en,"aria-label":en,children:[s.jsx(E,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:dt})]}):null]})})}),oe?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:Gt}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:Xt,children:Jt})]}),Ce?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(E,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:Ce})]}):null,ke?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(E,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:z?{color:z}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:ke})]}):null,We&&Ae?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(E,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:z?{color:z}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:z?{color:z}:void 0,children:["#",We.number," · ",Ae]})]}):null]})})]})}),Ut&&!F?s.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 z-10",children:Ut}):null,s.jsxs("div",{className:Ie("absolute right-0 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",bs||R&&!oe?"opacity-100":Ie("opacity-0",pe)),children:[T?s.jsx(d2,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:R?"h-6 w-6":"h-4 w-4",iconSizeClass:R?"h-3.5 w-3.5":"h-2.5 w-2.5",onPointerDown:Tf,onMouseDown:Rf,onArchive:Ef,onDelete:Mf}):null,ne?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie("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",R?"h-6 w-6":"h-4 w-4"),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Of,onMouseDown:Ff,onClick:Bf,onKeyDown:De=>De.stopPropagation(),children:s.jsx(E,{name:"external-link",className:Ie(R?"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(Js,{open:ks,onOpenChange:Zt,onOpenChangeComplete:Lt,children:[s.jsx(Ys,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie("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",R?"h-6 w-6 opacity-100":bs?"h-4 w-4 opacity-100":Ie("h-4 w-4 opacity-0",pe)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Sr,onMouseDown:sr,onClick:tn,onKeyDown:De=>De.stopPropagation(),children:s.jsx(E,{name:"more-2",className:Ie(R?"h-3.5 w-3.5":"h-2.5 w-2.5")})})}),zf]})]})]}),Vf]})}),rs&&Me?B:null,s.jsx(vs,{open:$e,onOpenChange:J,children:s.jsxs(js,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs($s,{children:[s.jsx(Rs,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Es,{children:dn===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:dn}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:dn})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:re,onChange:De=>Pe(De.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(yn,{children:[s.jsx(xt,{type:"button",onClick:()=>J(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(xt,{type:"button",onClick:()=>{J(!1),Ps(re)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),os?s.jsx(t2,{session:ve,open:Zs,onOpenChange:zs}):null]},W.id)}const Nc=t=>vt(t.session.directory??null),f2=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),m2=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},Ac=t=>t.menuOpenSessionId??m2(t),co=(t,e,n)=>e?n.has(t.node.session.id)?!0:Hn(t.node,e):!1,ia=(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(ia(t.children[l],e.children[l],n,r,i))return!0;return!1},h2=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return ia(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||ia(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},p2=(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,g2=(t,e)=>{if(t.node.session.id!==e.node.session.id||!p2(t.node.session,e.node.session)||!l2(t.node,e.node))return"node";if(t.depth!==e.depth)return"depth";if(t.groupDirectory!==e.groupDirectory)return"groupDirectory";if(t.projectId!==e.projectId)return"projectId";if(t.archivedBucket!==e.archivedBucket)return"archivedBucket";if((t.renderContext??"project")!==(e.renderContext??"project"))return"renderContext";if(t.mobileVariant!==e.mobileVariant)return"mobileVariant";if(t.alwaysShowActions!==e.alwaysShowActions)return"alwaysShowActions";if(t.hasSessionSearchQuery!==e.hasSessionSearchQuery)return"hasSessionSearchQuery";if(t.normalizedSessionSearchQuery!==e.normalizedSessionSearchQuery)return"normalizedSessionSearchQuery";if(t.notifyOnSubtasks!==e.notifyOnSubtasks)return"notifyOnSubtasks";if(t.nodeStructureKey!==e.nodeStructureKey)return"nodeStructureKey";if(t.relativeTimeTick!==e.relativeTimeTick)return"relativeTimeTick";if(Nc(t.node)!==Nc(e.node))return"nodeDirectory";if(!f2(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&uf(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&h2(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(co(t,t.editingId,t.subtreeContainsEditing)||co(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editTitle!==e.editTitle&&(co(t,t.editingId,t.subtreeContainsEditing)||co(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.copiedSessionId!==e.copiedSessionId&&(Hn(t.node,t.copiedSessionId)||Hn(e.node,e.copiedSessionId)))return"copiedSessionId";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=Ac(t),i=Ac(e);if(Hn(t.node,r)||Hn(e.node,i))return"openSidebarMenuKey"}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.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.children===e.children?null:"callbacks"},x2=(t,e)=>{const n=g2(t,e);return n===null?!0:(qs(`ui.sidebar_session_node.props_changed.${n}`),!1)},b2=c.memo(u2,x2);function y2(t){return t.stopPropagation()}const w2=t=>{const{t:e}=Nt(),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=Te(se=>se.setSessionSwitcherOpen),a=Je(se=>se.setCurrentSession),u=Je(se=>se.updateSessionTitle),d=Je(se=>se.shareSession),h=Je(se=>se.unshareSession),f=Je(se=>se.deleteSession),p=Je(se=>se.deleteSessions),g=Je(se=>se.archiveSession),w=Je(se=>se.archiveSessions),S=Je(se=>se.unarchiveSession),{mobileVariant:x,allowReselect:m,onSessionSelected:b,isSessionSearchOpen:y,sessionSearchQuery:v,setSessionSearchQuery:N,setIsSessionSearchOpen:C,descendantIds:k,showDeletionDialog:D,setDeleteSessionConfirm:P,setEditingId:I,setEditTitle:M,setCopiedSessionId:_}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const O=c.useCallback((se,oe)=>{wi("navigation.session_select"),Te.getState().closeMainSurfaces();const Se=()=>{!y&&v.length===0||(N(""),C(!1))};if(x&&l(!1),se===Je.getState().currentSessionId){m&&b?.(se),Se();return}wi("navigation.session_state_set"),a(se,oe??null),b?.(se),Se()},[m,y,x,b,v,a,C,N,l]),U=c.useCallback((se,oe)=>{I(se),M(oe)},[M,I]),L=c.useCallback(async se=>{const oe=r.current;if(!oe)return;const Se=(se??i.current).trim();Se&&await u(oe,Se),I(null),M("")},[M,I,u]),F=c.useCallback(()=>{I(null),M("")},[M,I]),R=c.useCallback(async(se,oe)=>{try{return(await gn(se)).ok?(_(oe),n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{_(null),n.current=null},2e3),!0):!1}catch{return!1}},[_]),j=c.useCallback(async se=>{const oe=await d(se.id);if(!oe?.share?.url){Le.error(e("sessions.sidebar.session.share.error"));return}const Se=await R(oe.share.url,se.id);Le[Se?"success":"warning"](e("sessions.sidebar.session.share.successTitle"),{description:e(Se?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")})},[R,d,e]),A=c.useCallback((se,oe)=>{R(se,oe).then(Se=>{Se||Le.error(e("sessions.sidebar.session.share.copyUrlError"))})},[R,e]),B=c.useCallback(se=>{gn(se).then(oe=>{if(oe.ok){Le.success(e("sessions.sidebar.session.copyId.success"));return}Le.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(e("sessions.sidebar.session.copyId.error")))},[e]),X=c.useCallback(async se=>{await h(se)?Le.success(e("sessions.sidebar.session.unshare.success")):Le.error(e("sessions.sidebar.session.unshare.error"))},[e,h]),H=c.useCallback(async(se,oe,Se)=>{const K=oe?.archivedBucket===!0||oe?.hardDelete===!0,pe=Se?.descendantIds??k;if(pe.length===0){(K?await f(se.id):await g(se.id))?Le.success(e(K?"sessions.sidebar.session.delete.success":"sessions.sidebar.session.archive.success")):Le.error(e(K?"sessions.sidebar.session.delete.error":"sessions.sidebar.session.archive.error"));return}const je=[se.id,...pe];if(K){const{deletedIds:G,failedIds:le}=await p(je);if(le.length===0){const de=G.length;Le.success(de===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:de}):e("sessions.sidebar.bulkActions.deletedPlural",{count:de}))}else Le.error(e("sessions.sidebar.session.delete.error"));return}const{archivedIds:ne,failedIds:T}=await w(je);ne.length>0&&Le.success(ne.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:ne.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:ne.length})),T.length>0&&Le.error(T.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:T.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:T.length}))},[g,w,f,p,k,e]),Z=c.useCallback((se,oe)=>{const Se=oe?.archivedBucket===!0||oe?.hardDelete===!0,K=[...k];if(!D||oe?.skipConfirm===!0){H(se,oe,{descendantIds:K});return}P({session:se,descendantCount:K.length,descendantIds:K,archivedBucket:Se})},[k,H,P,D]),ce=c.useCallback(async()=>{const se=o.current;if(!se)return;const{session:oe,archivedBucket:Se,descendantIds:K}=se;P(null),await H(oe,{archivedBucket:Se},{descendantIds:K})},[H,P]),Y=c.useCallback(async se=>{await S(se.id)?Le.success(e("sessions.sidebar.session.restore.success")):Le.error(e("sessions.sidebar.session.restore.error"))},[e,S]);return c.useMemo(()=>({handleSessionSelect:O,handleSessionDoubleClick:U,handleSaveEdit:L,handleCancelEdit:F,handleShareSession:j,handleCopyShareUrl:A,handleCopySessionId:B,handleUnshareSession:X,handleDeleteSession:Z,handleRestoreSession:Y,confirmDeleteSession:ce}),[F,B,A,Z,Y,L,U,O,j,X,ce])};function S2(t){const e=st.c(71),{t:n}=Nt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let u,d,h,f,p,g,w,S,x,m;if(e[0]!==i||e[1]!==n||e[2]!==r){const A=n("sessions.sidebar.session.untitled");f=vs,x=!!r,e[13]!==i?(m=X=>{X||i(null)},e[13]=i,e[14]=m):m=e[14],h=js,w=!1,S="max-w-sm gap-5",d=$s;let B;e[15]!==n||e[16]!==r?.archivedBucket?(B=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=B):B=e[17],e[18]!==B?(g=s.jsx(Rs,{children:B}),e[18]=B,e[19]=g):g=e[19],u=Es,p=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||A,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||A,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||A,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||A,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||A}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||A}),e[0]=i,e[1]=n,e[2]=r,e[3]=u,e[4]=d,e[5]=h,e[6]=f,e[7]=p,e[8]=g,e[9]=w,e[10]=S,e[11]=x,e[12]=m}else u=e[3],d=e[4],h=e[5],f=e[6],p=e[7],g=e[8],w=e[9],S=e[10],x=e[11],m=e[12];let b;e[20]!==u||e[21]!==p?(b=s.jsx(u,{children:p}),e[20]=u,e[21]=p,e[22]=b):b=e[22];let y;e[23]!==d||e[24]!==g||e[25]!==b?(y=s.jsxs(d,{children:[g,b]}),e[23]=d,e[24]=g,e[25]=b,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(E,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(E,{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 D;e[34]!==C||e[35]!==k||e[36]!==v||e[37]!==N?(D=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]=D):D=e[38];let P;e[39]!==i?(P=()=>i(null),e[39]=i,e[40]=P):P=e[40];let I;e[41]!==n?(I=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=I):I=e[42];let M;e[43]!==P||e[44]!==I?(M=s.jsx("button",{type:"button",onClick:P,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:I}),e[43]=P,e[44]=I,e[45]=M):M=e[45];let _;e[46]!==a?(_=()=>{a()},e[46]=a,e[47]=_):_=e[47];let O;e[48]!==n||e[49]!==r?.archivedBucket?(O=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=O):O=e[50];let U;e[51]!==_||e[52]!==O?(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:O}),e[51]=_,e[52]=O,e[53]=U):U=e[53];let L;e[54]!==M||e[55]!==U?(L=s.jsxs("div",{className:"flex items-center gap-2",children:[M,U]}),e[54]=M,e[55]=U,e[56]=L):L=e[56];let F;e[57]!==D||e[58]!==L?(F=s.jsxs(yn,{className:"w-full sm:items-center sm:justify-between",children:[D,L]}),e[57]=D,e[58]=L,e[59]=F):F=e[59];let R;e[60]!==h||e[61]!==w||e[62]!==F||e[63]!==S||e[64]!==y?(R=s.jsxs(h,{showCloseButton:w,className:S,children:[y,F]}),e[60]=h,e[61]=w,e[62]=F,e[63]=S,e[64]=y,e[65]=R):R=e[65];let j;return e[66]!==f||e[67]!==R||e[68]!==x||e[69]!==m?(j=s.jsx(f,{open:x,onOpenChange:m,children:R}),e[66]=f,e[67]=R,e[68]=x,e[69]=m,e[70]=j):j=e[70],j}function v2(t){const e=st.c(57),{t:n}=Nt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,u=r?.archivedBucket===!0,d=r?.sessionCount??0;let h;e[0]!==u||e[1]!==d||e[2]!==n?(h=n(u?d===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":d===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=u,e[1]=d,e[2]=n,e[3]=h):h=e[3];const f=h;let p;e[4]!==u||e[5]!==d||e[6]!==n?(p=u?d===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:d}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:d}):d===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:d}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:d}),e[4]=u,e[5]=d,e[6]=n,e[7]=p):p=e[7];const g=p,w=!!r;let S;e[8]!==i?(S=j=>{j||i(null)},e[8]=i,e[9]=S):S=e[9];let x;e[10]!==f?(x=s.jsx(Rs,{children:f}),e[10]=f,e[11]=x):x=e[11];let m;e[12]!==g?(m=s.jsx(Es,{children:g}),e[12]=g,e[13]=m):m=e[13];let b;e[14]!==x||e[15]!==m?(b=s.jsxs($s,{children:[x,m]}),e[14]=x,e[15]=m,e[16]=b):b=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(E,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(E,{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 D;e[29]!==i?(D=()=>i(null),e[29]=i,e[30]=D):D=e[30];let P;e[31]!==n?(P=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=P):P=e[32];let I;e[33]!==D||e[34]!==P?(I=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[33]=D,e[34]=P,e[35]=I):I=e[35];let M;e[36]!==a?(M=()=>{a()},e[36]=a,e[37]=M):M=e[37];let _;e[38]!==u||e[39]!==n?(_=n(u?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=u,e[39]=n,e[40]=_):_=e[40];let O;e[41]!==M||e[42]!==_?(O=s.jsx("button",{type:"button",onClick:M,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]=M,e[42]=_,e[43]=O):O=e[43];let U;e[44]!==I||e[45]!==O?(U=s.jsxs("div",{className:"flex items-center gap-2",children:[I,O]}),e[44]=I,e[45]=O,e[46]=U):U=e[46];let L;e[47]!==k||e[48]!==U?(L=s.jsxs(yn,{className:"w-full sm:items-center sm:justify-between",children:[k,U]}),e[47]=k,e[48]=U,e[49]=L):L=e[49];let F;e[50]!==L||e[51]!==b?(F=s.jsxs(js,{showCloseButton:!1,className:"max-w-sm gap-5",children:[b,L]}),e[50]=L,e[51]=b,e[52]=F):F=e[52];let R;return e[53]!==w||e[54]!==F||e[55]!==S?(R=s.jsx(vs,{open:w,onOpenChange:S,children:F}),e[53]=w,e[54]=F,e[55]=S,e[56]=R):R=e[56],R}function j2(t){const e=st.c(36),{t:n}=Nt(),{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 u;e[2]!==n?(u=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=u):u=e[3];let d;e[4]!==u?(d=s.jsx(Rs,{children:u}),e[4]=u,e[5]=d):d=e[5];let h;e[6]!==n||e[7]!==r?(h=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=h):h=e[8];let f;e[9]!==h?(f=s.jsx(Es,{children:h}),e[9]=h,e[10]=f):f=e[10];let p;e[11]!==d||e[12]!==f?(p=s.jsxs($s,{children:[d,f]}),e[11]=d,e[12]=f,e[13]=p):p=e[13];let g;e[14]!==i?(g=()=>i(null),e[14]=i,e[15]=g):g=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]!==g||e[19]!==w?(S=s.jsx("button",{type:"button",onClick:g,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:w}),e[18]=g,e[19]=w,e[20]=S):S=e[20];let x;e[21]!==n?(x=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=x):x=e[22];let m;e[23]!==o||e[24]!==x?(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:x}),e[23]=o,e[24]=x,e[25]=m):m=e[25];let b;e[26]!==m||e[27]!==S?(b=s.jsxs(yn,{children:[S,m]}),e[26]=m,e[27]=S,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==p?(y=s.jsxs(js,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,b]}),e[29]=b,e[30]=p,e[31]=y):y=e[31];let v;return e[32]!==l||e[33]!==a||e[34]!==y?(v=s.jsx(vs,{open:l,onOpenChange:a,children:y}),e[32]=l,e[33]=a,e[34]=y,e[35]=v):v=e[35],v}const k2=new Set;function Lo(t){const e=st.c(142),{node:n,depth:r,groupDirectory:i,projectId:o,archivedBucket:l,secondaryMeta:a,renderContext:u,renderExtras:d,pinnedSessionIds:h,expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:S,setEditingId:x,editTitle:m,setEditTitle:b,toggleParent:y,openSidebarMenuKey:v,setOpenSidebarMenuKey:N,allowReselect:C,onSessionSelected:k,isSessionSearchOpen:D,sessionSearchQuery:P,setSessionSearchQuery:I,setIsSessionSearchOpen:M,deleteSessionConfirm:_,setDeleteSessionConfirm:O,startFolderRename:U,copiedSessionId:L,setCopiedSessionId:F,startSessionWorktreeMenuLoad:R,mobileVariant:j,alwaysShowActions:A}=t,B=r===void 0?0:r,X=l===void 0?!1:l,H=u===void 0?"project":u,Z=cs(D2),ce=cs(A2),Y=Te(N2),se=Te(C2);let oe;if(e[0]!==n){oe=[];const We=z=>z.children.forEach(he=>{oe.push(he.session.id),We(he)});We(n),e[0]=n,e[1]=oe}else oe=e[1];const Se=oe.join(`
|
|
922
|
+
`);let K;e[2]!==Se?(K=Se?Se.split(`
|
|
923
|
+
`):[],e[2]=Se,e[3]=K):K=e[3];const pe=K;let je;e[4]!==Z||e[5]!==U||e[6]!==ce?(je=(We,z)=>{if(!We)return null;z&&cs.getState().collapsedFolderIds.has(z)&&ce(z);const he=Z(We,"New folder",z);return U(We,he),he},e[4]=Z,e[5]=U,e[6]=ce,e[7]=je):je=e[7];const ne=je;let T;e[8]!==C||e[9]!==L||e[10]!==_||e[11]!==pe||e[12]!==m||e[13]!==S||e[14]!==D||e[15]!==j||e[16]!==k||e[17]!==P||e[18]!==F||e[19]!==O||e[20]!==b||e[21]!==x||e[22]!==M||e[23]!==I||e[24]!==Y?(T={mobileVariant:j,allowReselect:C,onSessionSelected:k,isSessionSearchOpen:D,sessionSearchQuery:P,setSessionSearchQuery:I,setIsSessionSearchOpen:M,descendantIds:pe,showDeletionDialog:Y,setDeleteSessionConfirm:O,deleteSessionConfirm:_,editingId:S,setEditingId:x,editTitle:m,setEditTitle:b,copiedSessionId:L,setCopiedSessionId:F},e[8]=C,e[9]=L,e[10]=_,e[11]=pe,e[12]=m,e[13]=S,e[14]=D,e[15]=j,e[16]=k,e[17]=P,e[18]=F,e[19]=O,e[20]=b,e[21]=x,e[22]=M,e[23]=I,e[24]=Y,e[25]=T):T=e[25];const G=w2(T),le=d?.childRenderExtrasFor,de=n.session.directory??i;let ue;e[26]!==X||e[27]!==o||e[28]!==H||e[29]!==de?(ue={groupDirectory:de,projectId:o,archivedBucket:X,renderContext:H},e[26]=X,e[27]=o,e[28]=H,e[29]=de,e[30]=ue):ue=e[30];const Oe=ue,me=G.handleSaveEdit,Re=G.handleCancelEdit,ye=G.handleSessionSelect,q=G.handleSessionDoubleClick,we=G.handleShareSession,be=G.handleCopyShareUrl,Ne=G.handleCopySessionId,ie=G.handleUnshareSession,ee=G.handleDeleteSession,V=G.handleRestoreSession,$=d?.subtreeContainsEditing??k2,ae=d?.menuOpenSessionId??null,W=d?.nodeStructureKey??"",ve=d?.relativeTimeTick;let Fe;if(e[31]!==C||e[32]!==A||e[33]!==Oe||e[34]!==le||e[35]!==L||e[36]!==_||e[37]!==B||e[38]!==m||e[39]!==S||e[40]!==f||e[41]!==p||e[42]!==D||e[43]!==j||e[44]!==n.children||e[45]!==g||e[46]!==w||e[47]!==k||e[48]!==v||e[49]!==h||e[50]!==P||e[51]!==F||e[52]!==O||e[53]!==b||e[54]!==x||e[55]!==M||e[56]!==N||e[57]!==I||e[58]!==U||e[59]!==R||e[60]!==y){let We;e[62]!==C||e[63]!==A||e[64]!==Oe||e[65]!==le||e[66]!==L||e[67]!==_||e[68]!==B||e[69]!==m||e[70]!==S||e[71]!==f||e[72]!==p||e[73]!==D||e[74]!==j||e[75]!==g||e[76]!==w||e[77]!==k||e[78]!==v||e[79]!==h||e[80]!==P||e[81]!==F||e[82]!==O||e[83]!==b||e[84]!==x||e[85]!==M||e[86]!==N||e[87]!==I||e[88]!==U||e[89]!==R||e[90]!==y?(We=z=>s.jsx(Lo,{node:z,pinnedSessionIds:h,expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:S,setEditingId:x,editTitle:m,copiedSessionId:L,setEditTitle:b,toggleParent:y,openSidebarMenuKey:v,setOpenSidebarMenuKey:N,allowReselect:C,onSessionSelected:k,isSessionSearchOpen:D,sessionSearchQuery:P,setSessionSearchQuery:I,setIsSessionSearchOpen:M,deleteSessionConfirm:_,setDeleteSessionConfirm:O,startFolderRename:U,setCopiedSessionId:F,startSessionWorktreeMenuLoad:R,mobileVariant:j,alwaysShowActions:A,depth:B+1,...Oe,renderExtras:le?.(z)},z.session.id),e[62]=C,e[63]=A,e[64]=Oe,e[65]=le,e[66]=L,e[67]=_,e[68]=B,e[69]=m,e[70]=S,e[71]=f,e[72]=p,e[73]=D,e[74]=j,e[75]=g,e[76]=w,e[77]=k,e[78]=v,e[79]=h,e[80]=P,e[81]=F,e[82]=O,e[83]=b,e[84]=x,e[85]=M,e[86]=N,e[87]=I,e[88]=U,e[89]=R,e[90]=y,e[91]=We):We=e[91],Fe=n.children.map(We),e[31]=C,e[32]=A,e[33]=Oe,e[34]=le,e[35]=L,e[36]=_,e[37]=B,e[38]=m,e[39]=S,e[40]=f,e[41]=p,e[42]=D,e[43]=j,e[44]=n.children,e[45]=g,e[46]=w,e[47]=k,e[48]=v,e[49]=h,e[50]=P,e[51]=F,e[52]=O,e[53]=b,e[54]=x,e[55]=M,e[56]=N,e[57]=I,e[58]=U,e[59]=R,e[60]=y,e[61]=Fe}else Fe=e[61];let Ce;e[92]!==A||e[93]!==X||e[94]!==L||e[95]!==ne||e[96]!==B||e[97]!==m||e[98]!==S||e[99]!==f||e[100]!==i||e[101]!==p||e[102]!==j||e[103]!==n||e[104]!==g||e[105]!==w||e[106]!==v||e[107]!==h||e[108]!==o||e[109]!==H||e[110]!==a||e[111]!==G.handleCancelEdit||e[112]!==G.handleCopySessionId||e[113]!==G.handleCopyShareUrl||e[114]!==G.handleDeleteSession||e[115]!==G.handleRestoreSession||e[116]!==G.handleSaveEdit||e[117]!==G.handleSessionDoubleClick||e[118]!==G.handleSessionSelect||e[119]!==G.handleShareSession||e[120]!==G.handleUnshareSession||e[121]!==b||e[122]!==x||e[123]!==N||e[124]!==R||e[125]!==$||e[126]!==ae||e[127]!==W||e[128]!==ve||e[129]!==Fe||e[130]!==y?(Ce=s.jsx(b2,{expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:S,setEditingId:x,editTitle:m,setEditTitle:b,handleSaveEdit:me,handleCancelEdit:Re,toggleParent:y,handleSessionSelect:ye,handleSessionDoubleClick:q,handleShareSession:we,copiedSessionId:L,handleCopyShareUrl:be,handleCopySessionId:Ne,handleUnshareSession:ie,openSidebarMenuKey:v,setOpenSidebarMenuKey:N,createFolderAndStartRename:ne,handleDeleteSession:ee,handleRestoreSession:V,startSessionWorktreeMenuLoad:R,mobileVariant:j,alwaysShowActions:A,pinnedSessionIds:h,node:n,depth:B,groupDirectory:i,projectId:o,archivedBucket:X,secondaryMeta:a,renderContext:H,subtreeContainsEditing:$,menuOpenSessionId:ae,nodeStructureKey:W,relativeTimeTick:ve,children:Fe}),e[92]=A,e[93]=X,e[94]=L,e[95]=ne,e[96]=B,e[97]=m,e[98]=S,e[99]=f,e[100]=i,e[101]=p,e[102]=j,e[103]=n,e[104]=g,e[105]=w,e[106]=v,e[107]=h,e[108]=o,e[109]=H,e[110]=a,e[111]=G.handleCancelEdit,e[112]=G.handleCopySessionId,e[113]=G.handleCopyShareUrl,e[114]=G.handleDeleteSession,e[115]=G.handleRestoreSession,e[116]=G.handleSaveEdit,e[117]=G.handleSessionDoubleClick,e[118]=G.handleSessionSelect,e[119]=G.handleShareSession,e[120]=G.handleUnshareSession,e[121]=b,e[122]=x,e[123]=N,e[124]=R,e[125]=$,e[126]=ae,e[127]=W,e[128]=ve,e[129]=Fe,e[130]=y,e[131]=Ce):Ce=e[131];let ke;e[132]!==_||e[133]!==n.session.id||e[134]!==G.confirmDeleteSession||e[135]!==O||e[136]!==se||e[137]!==Y?(ke=_?.session.id===n.session.id?s.jsx(S2,{value:_,setValue:O,showDeletionDialog:Y,setShowDeletionDialog:se,onConfirm:G.confirmDeleteSession}):null,e[132]=_,e[133]=n.session.id,e[134]=G.confirmDeleteSession,e[135]=O,e[136]=se,e[137]=Y,e[138]=ke):ke=e[138];let Qe;return e[139]!==Ce||e[140]!==ke?(Qe=s.jsxs(s.Fragment,{children:[Ce,ke]}),e[139]=Ce,e[140]=ke,e[141]=Qe):Qe=e[141],Qe}function C2(t){return t.setShowDeletionDialog}function N2(t){return t.showDeletionDialog}function A2(t){return t.toggleFolderCollapse}function D2(t){return t.createFolder}const P2=50,I2=28,Dc=[],T2=t=>{const e=st.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=cf(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},Pr=(t,e)=>e?t.sessions.some(n=>Hn(n,e)):!1,R2=(t,e,n)=>t.sessions.some(r=>uf(r,r,e,n,t.directory,t.directory)),E2=(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)},M2=(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)},O2=(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&&R2(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&E2(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&M2(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Pr(e.group,t.editingId)||Pr(e.group,e.editingId))||t.editTitle!==e.editTitle&&Pr(e.group,e.editingId)||t.copiedSessionId!==e.copiedSessionId&&(Pr(e.group,t.copiedSessionId)||Pr(e.group,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=Gr(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Gr(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??vt(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.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename};function F2(t){const{t:e}=Nt(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,groupSearchDataByGroup:u,visibleSessionCount:d,sessionBatchSize:h,collapsedGroups:f,hideDirectoryControls:p,showMoreGroupSessions:g,resetGroupSessionLimit:w,mobileVariant:S,alwaysShowActions:x,activeProjectId:m,setActiveProjectIdOnly:b,setSessionSwitcherOpen:y,openNewSessionDraft:v,pinnedSessionIds:N,sessionOrderIndex:C,notifyOnSubtasks:k,onToggleCollapsedGroup:D,dragHandleProps:P,compactBodyPadding:I=!1,scrollContainerRef:M,expandedParents:_,editingId:O,openSidebarMenuKey:U,editTitle:L,copiedSessionId:F,folderRename:R,setFolderRenameDraft:j,clearFolderRename:A}=t,B=cs(Me=>Me.toggleFolderCollapse),X=cs(Me=>Me.renameFolder),H=cs(Me=>Me.deleteFolder),Z=cs(Me=>Me.addSessionToFolder),ce=Te(Me=>Me.showDeletionDialog),[Y,se]=c.useState(null),oe=c.useCallback((Me,qe)=>{const dt=C.get(Me.session.id),wt=C.get(qe.session.id);if(dt!==void 0||wt!==void 0){if(dt===void 0)return 1;if(wt===void 0)return-1;if(dt!==wt)return dt-wt}return Gd(Me.session,qe.session,N,Od)},[N,C]),Se=l?u.get(n):null,K=l?!1:f.has(r),pe=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const Me=vt(n.directory??null),qe=n.branch?.trim();return Me&&qe?Ho(Me,qe):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),je=zd(pe),ne=je?`var(--pr-${je.visualState})`:void 0,T=Ia(),G=c.useMemo(()=>{const Me=n.folderScopes?.map(qe=>vt(qe.directory))??[vt(n.directory??null)];return[...new Set(Me.filter(qe=>!!qe))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(Me=>G.length>0?T.subscribeBootstrap(Me):()=>{},[G.length,T]),c.useCallback(()=>G.map(Me=>`${Me}\0${T.getBootstrapState(Me)??""}\0${T.getBootstrapFailure(Me)??""}`).join(""),[G,T]),c.useCallback(()=>"",[]));const le=G.some(Me=>{const qe=T.getBootstrapState(Me);return qe==="queued"||qe==="running"}),de=G.find(Me=>T.getBootstrapState(Me)==="failed")??null,ue=de?T.getBootstrapFailure(de):void 0,Oe=ue==="os-permission"&&cm(),[me,Re]=c.useState(!1),ye=c.useCallback(()=>{de&&T.requestBootstrap({directory:de,priority:K?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[T,de,n.isMain,K]),q=c.useCallback(async()=>{if(!(!de||!Oe||me)){Re(!0);try{(await dm(de)).success&&ye()}finally{Re(!1)}}},[Oe,de,me,ye]),we=h??(p?10:5),be=Math.max(we,d??we),Ne=l?Se?.groupMatches===!0:!1,ie=l,ee=c.useMemo(()=>[...ie?Se?.filteredNodes??[]:n.sessions].sort(oe),[oe,n.sessions,Se?.filteredNodes,ie]),V=n.folderScopeKey??vt(n.directory??null),$=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:V?[{scopeKey:V,directory:n.directory??null}]:[],[V,n.directory,n.folderScopes]),ae=cs(Jn(c.useCallback(Me=>$.map(({scopeKey:qe})=>Me.foldersMap[qe]??Dc),[$]))),W=c.useMemo(()=>$.flatMap(({scopeKey:Me,directory:qe},dt)=>(ae[dt]??Dc).map(ft=>({folder:ft,scopeKey:Me,scopeDirectory:qe}))),[ae,$]),ve=cs(Jn(c.useCallback(Me=>new Set(ae.flatMap(qe=>qe.filter(dt=>Me.collapsedFolderIds.has(dt.id)).map(dt=>dt.id))),[ae]))),Fe=c.useMemo(()=>{const Me=new Map,qe=dt=>{dt.forEach(wt=>{Me.set(wt.session.id,wt),wt.children.length>0&&qe(wt.children)})};return qe(ee),Me},[ee]),Ce=c.useMemo(()=>W.map(({folder:Me,scopeKey:qe,scopeDirectory:dt})=>{const wt=vj(Me.sessionIds,Fe).sort(oe);return{folder:Me,scopeKey:qe,scopeDirectory:dt,nodes:wt}}),[W,Fe,oe]),ke=c.useMemo(()=>{const Me=kj(Ce.map(({folder:qe,nodes:dt})=>({id:qe.id,name:qe.name,parentId:qe.parentId,nodeCount:dt.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:l?a:""});return Ce.filter(({folder:qe})=>Me.has(qe.id))},[Ce,n.isArchivedBucket,l,a]),Qe=O,We=U,z=_,he=c.useMemo(()=>new Set(ke.flatMap(Me=>Me.folder.sessionIds)),[ke]),Be=c.useMemo(()=>ee.filter(Me=>!he.has(Me.session.id)),[ee,he]),Ae=c.useMemo(()=>{const Me=new Map(ke.map(qe=>[qe.folder.id,qe]));return jj(ke.map(qe=>qe.folder)).map(qe=>Me.get(qe.id)).filter(qe=>!!qe)},[ke]),at=c.useMemo(()=>{const Me=new Map;return ke.forEach(qe=>{if(!qe.folder.parentId)return;const dt=Me.get(qe.folder.parentId)??[];dt.push(qe),Me.set(qe.folder.parentId,dt)}),Me},[ke]),Ue=c.useMemo(()=>{const Me=new Map(ke.map(wt=>[wt.folder.id,wt])),qe=new Map,dt=(wt,ft)=>{const ct=qe.get(wt);if(ct!==void 0)return ct;if(ft.has(wt))return[];ft.add(wt);const Vt=Me.get(wt),Xt=Vt?[...Vt.nodes]:[];for(const Jt of at.get(wt)??[])Xt.push(...dt(Jt.folder.id,ft));return qe.set(wt,Xt),Xt};return ke.forEach(({folder:wt})=>dt(wt.id,new Set)),qe},[ke,at]),ht="project",ut=c.useMemo(()=>{const Me=new Set;return sa(ee,Qe,Me),ke.forEach(({nodes:qe})=>{sa(qe,Qe,Me)}),Me},[ee,ke,Qe]),Ct=c.useMemo(()=>{if(!We)return null;const Me=Gr(ee,We,ht,!!n.isArchivedBucket);if(Me)return Me;for(const{nodes:qe}of ke){const dt=Gr(qe,We,ht,!!n.isArchivedBucket);if(dt)return dt}return null},[We,ee,ke,n.isArchivedBucket]),ge=c.useCallback(Me=>{const qe=new WeakMap,dt=wt=>{qe.set(wt,Bo(wt));for(const ft of wt.children)dt(ft)};return Me.forEach(dt),qe},[]),Ye=c.useMemo(()=>ge(ee),[ge,ee]),bt=c.useMemo(()=>{const Me=new WeakMap;return ke.forEach(({nodes:qe})=>{qe.forEach(dt=>Me.set(dt,Bo(dt)))}),Me},[ke]),jt=c.useCallback(Me=>Ye.get(Me)??bt.get(Me)??"",[Ye,bt]),fe=c.useCallback(Me=>({subtreeContainsEditing:ut,menuOpenSessionId:Ct,nodeStructureKey:jt(Me)}),[ut,Ct,jt]),ze=Be.length,it=n.isArchivedBucket||l?Be:Be.slice(0,be),$e=ze-it.length,J=!n.isArchivedBucket&&!l&&ze>we&&$e===0,re=n.isArchivedBucket===!0&&!l&&it.length>=P2,Pe=n.isArchivedBucket?"archived":"active",_e=re&&it.some(Me=>{if(Me.children.length===0)return!1;const qe=`project:${Pe}:${Me.session.id}`;return z.has(qe)}),Ve=c.useRef(null),[Ze,lt]=c.useState(null),[rt,Ge]=c.useState(0),[,ot]=c.useState(0);c.useEffect(()=>{if(!re)return;const Me=Ve.current;if(!Me||!globalThis.ResizeObserver)return;const qe=new ResizeObserver(()=>ot(dt=>dt+1));return qe.observe(Me),()=>qe.disconnect()},[re]),c.useLayoutEffect(()=>{if(!re){Ze!==null&<(null),rt!==0&&Ge(0);return}const Me=Ve.current;if(!Me)return;let qe=Ze;const dt=M?.current??null;if(dt&&dt.contains(Me)){if(qe=dt,qe!==Ze){lt(qe);return}}else if(!qe||!qe.contains(Me)){let ft=Me.parentElement;for(;ft;){const ct=window.getComputedStyle(ft);if(ct.overflowY==="auto"||ct.overflowY==="scroll"){qe=ft;break}ft=ft.parentElement}if(qe!==Ze){lt(qe);return}}if(!qe)return;const wt=Me.getBoundingClientRect().top-qe.getBoundingClientRect().top+qe.scrollTop;Ge(ft=>Math.abs(ft-wt)<1?ft:wt)});const Ee=re&&Ze!==null,Rt=rx({count:it.length,enabled:Ee,getScrollElement:()=>Ze,initialOffset:()=>Ze?.scrollTop??0,estimateSize:()=>I2,overscan:_e?20:8,scrollMargin:rt,getItemKey:Me=>it[Me]?.session.id??Me}),xe=c.useCallback(Me=>{const qe=[],dt=wt=>{wt.forEach(ft=>{qe.push(ft.session),ft.children.length>0&&dt(ft.children)})};return dt(Me),qe},[]),mt=c.useMemo(()=>xe(ee),[xe,ee]),Tt=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const Me=new Map,qe=new Map;for(const{folder:wt}of ke){if(!wt.parentId)continue;const ft=qe.get(wt.parentId)??[];ft.push(wt.id),qe.set(wt.parentId,ft)}const dt=(wt,ft)=>{if(ft.has(wt))return[];ft.add(wt);const ct=ke.find(({folder:Jt})=>Jt.id===wt),Vt=ct?xe(ct.nodes):[],Xt=qe.get(wt)??[];for(const Jt of Xt)Vt.push(...dt(Jt,ft));return Vt};for(const{folder:wt}of ke)Me.set(wt.id,dt(wt.id,new Set));return Me},[ke,xe,n.isArchivedBucket]);if(l&&!Ne&&Ae.length===0&&Be.length===0)return null;const Xe=!n.isMain&&!!n.branch,nt=n.branch&&zh(n.branch,n.label)?{label:n.branch}:null,St=K?s.jsx(nj,{nodes:ee,includeUnreadSubtasks:k}):null,yt=(Me,qe)=>{const{folder:dt,scopeKey:wt,scopeDirectory:ft,nodes:ct}=Me,Vt=Tt.get(dt.id)??[],Xt=R?.folderId===dt.id&&R?.scopeKey===wt,Jt=l?!1:ve.has(dt.id),ks=ns=>s.jsx(xj,{folderId:dt.id,children:(Ws,bs)=>s.jsx(oj,{folder:dt,displayName:qe,sessions:ct,isCollapsed:Jt,collapsedActivityState:ns,onToggle:()=>B(dt.id),onRename:os=>{X(wt,dt.id,os)},onDelete:()=>{if(n.isArchivedBucket){xn.requestDelete({sessions:Vt,mode:"session"});return}if(!ce){H(wt,dt.id);return}const os=ke.filter(({folder:zs})=>zs.parentId===dt.id).length,Zs=ct.length;se({scopeKey:wt,folderId:dt.id,folderName:dt.name,subFolderCount:os,sessionCount:Zs})},groupDirectory:ft??n.directory,projectId:i,mobileVariant:S,alwaysShowActions:x,isRenaming:Xt,renameDraft:Xt?R?.draft:void 0,onRenameDraftChange:j,onRenameSave:()=>{const os=R?.draft.trim()??"";os&&X(wt,dt.id,os),A()},onRenameCancel:A,droppableRef:Ws,isDropTarget:bs,depth:0,onNewSession:()=>{i&&i!==m&&b(i),S&&y(!1),v({selectedProjectId:i,directoryOverride:ft??n.directory,targetFolderId:dt.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:ct.map(os=>s.jsx(Lo,{node:os,pinnedSessionIds:N,expandedParents:_,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:k,editingId:O,editTitle:L,copiedSessionId:F,openSidebarMenuKey:U,mobileVariant:S,alwaysShowActions:x,groupDirectory:ft??n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ut,menuOpenSessionId:Ct,nodeStructureKey:jt(os),childRenderExtrasFor:fe},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,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},os.session.id))})},dt.id);return Jt?s.jsx(T2,{nodes:Ue.get(dt.id)??ct,includeUnreadSubtasks:k,children:ks},dt.id):ks(null)},It=()=>{const Me=new Map;for(const ft of ke){const ct=ft.folder.parentId;if(!ct)continue;const Vt=Me.get(ct);Vt?Vt.push(ft):Me.set(ct,[ft])}const qe=[],dt=new Set,wt=(ft,ct)=>{if(dt.has(ft.folder.id))return;dt.add(ft.folder.id);const Vt=ct?`${ct} / ${ft.folder.name}`:ft.folder.name;qe.push(yt(ft,Vt)),!(!l&&ve.has(ft.folder.id))&&(Me.get(ft.folder.id)??[]).forEach(Jt=>wt(Jt,Vt))};return Ae.forEach(ft=>wt(ft,"")),qe},kt=!!(!n.isMain&&n.worktree),Et=n.worktree?.worktreeStatus==="missing"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.worktreeMissing"),"aria-label":e("sessions.sidebar.group.worktreeMissing"),children:s.jsx(E,{name:"alert",className:"h-3 w-3"})}):null,Bt=x?kt?"pr-14":"pr-7":kt?"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",zt=de?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(ue==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":"sessions.sidebar.group.empty.loadFailed"),Oe?s.jsx(xt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:me,onClick:()=>{q()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(xt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:ye,children:e("sessions.sidebar.group.empty.retry")})]}):null,Gt=Me=>s.jsx(Lo,{node:Me,pinnedSessionIds:N,expandedParents:_,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:k,editingId:O,editTitle:L,copiedSessionId:F,openSidebarMenuKey:U,mobileVariant:S,alwaysShowActions:x,groupDirectory:n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ut,menuOpenSessionId:Ct,nodeStructureKey:jt(Me),childRenderExtrasFor:fe},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,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},Me.session.id),rs=s.jsxs(bj,{scopeKey:$[0]?.scopeKey??V,hasFolders:ke.length>0,onSessionDroppedOnFolder:(Me,qe)=>{const dt=ke.find(({folder:ft})=>ft.id===qe);if(!dt)return;const wt=cs.getState();for(const{scopeKey:ft}of $)ft!==dt.scopeKey&&wt.getSessionFolderId(ft,Me)&&wt.removeSessionFromFolder(ft,Me);Z(dt.scopeKey,qe,Me)},children:[It(),re?s.jsx("div",{ref:Ve,children:Ee?s.jsx("div",{style:{height:Rt.getTotalSize(),position:"relative"},children:Rt.getVirtualItems().map(Me=>{const qe=it[Me.index];return qe?s.jsx("div",{"data-index":Me.index,ref:Rt.measureElement,className:"[&_[data-session-row]]:my-px",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${Me.start-rt}px)`},children:Gt(qe)},qe.session.id):null})}):it.map(Gt)}):it.map(Gt),ze===0&&ke.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"):le?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):zt||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,ze>0&&zt?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:zt}):null,$e>0?s.jsx("button",{type:"button",onClick:()=>g(r,it.length,h??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,J?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]}),_t="pb-2",Wt=s.jsx(j2,{value:Y,setValue:se,onConfirm:()=>{const Me=Y;Me&&(H(Me.scopeKey,Me.folderId),se(null))}});return o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Ie("oc-group-body",_t),children:rs})}),Wt]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:Ie("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>D(r),role:"button",tabIndex:0,onKeyDown:Me=>{(Me.key==="Enter"||Me.key===" ")&&(Me.preventDefault(),D(r))},"aria-label":K?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!K,children:[s.jsxs("div",{ref:P?.setActivatorNodeRef,className:Ie("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",Bt),...P?.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:"typography-ui-label 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(E,{name:"archive",className:Ie("h-3.5 w-3.5 shrink-0 text-muted-foreground",x?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:Ie("text-muted-foreground h-3.5 w-3.5 items-center justify-center",x?"inline-flex":"hidden group-hover/gh:inline-flex"),children:K?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:po(n.label,a)}),Et,St]}):!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(E,{name:"git-branch",className:Ie("h-3.5 w-3.5 shrink-0",!ne&&"text-muted-foreground",x?"hidden":"group-hover/gh:hidden"),style:ne?{color:ne}:void 0}),s.jsx("span",{className:Ie("text-muted-foreground h-3.5 w-3.5 items-center justify-center",x?"inline-flex":"hidden group-hover/gh:inline-flex"),children:K?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(E,{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:po(n.label,a)}),Et,St,je?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:ne?{color:ne}:void 0,children:["#",je.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:po(n.label,a)}),St]})}),Xe&&nt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(E,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(E,{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:nt.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(Hr,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&mt.length>0?s.jsx("div",{className:Ie("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),xn.requestDelete({sessions:mt,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(E,{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:Ie("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),xn.requestDelete({sessions:mt,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(E,{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:Ie("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",x?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),i&&i!==m&&b(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(E,{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]}),K?null:s.jsx("div",{className:Ie("oc-group-body",_t),children:rs})]}),Wt]})}const vo=c.memo(F2,O2),B2=(t,e,n)=>e?t.filter(r=>r.project.id===n):t,_2=t=>t?"top-content":"empty-state",L2=(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}))},$2=48,W2=32,z2=24,gi=(t,e)=>Pa(t.label?.trim()||Fn(t.normalizedPath,e)||t.normalizedPath);function V2(t){const e=st.c(50);qs("ui.sidebar_projects_list.render");const{t:n}=Nt(),{model:r,view:i,actions:o}=t,l=r.state.editingId!==null,a=i.isDesktopShellRuntime&&i.stickyZoneHeaders&&!r.singleProjectMode;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{distance:8}},e[0]=u):u=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={coordinateGetter:Gg},e[1]=d):d=e[1];const h=Vr(On(Fi,u),On(Kg,d));let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={activationConstraint:{distance:8}},e[2]=f):f=e[2];const p=Vr(On(Fi,f)),g=c.useRef(null),w=c.useRef(0);let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=ne=>{const G=ne.scrollTop>1?Math.min(W2+ne.scrollTop,$2):0;w.current=G;const le=ne.closest(".oc-sticky-fade-root");le?.style.setProperty("--scroll-shadow-top-size",`${G}px`),le?.style.setProperty("--scroll-shadow-top-clear-size",`${Math.min(Math.max(G-8,0),z2)}px`)},e[3]=S):S=e[3];const x=S;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=ne=>{ne.target.closest("[data-overlay-scrollbar-thumb], [data-sidebar-sticky-header]")||ne.clientY-ne.currentTarget.getBoundingClientRect().top>=w.current||(ne.preventDefault(),ne.stopPropagation())},e[4]=m):m=e[4];const b=m,y=B2(r.sectionsForRender,r.singleProjectMode,r.singleProjectId),v=r.projectSections.length>0&&y.length>0,[N,C]=c.useState(!1);let k;e[5]!==a||e[6]!==v?(k=()=>{const ne=g.current,T=ne?.querySelector('[data-sidebar-activity-start="active-now"]');if(!a||!v||!ne||!T){C(!1);return}C(T.getBoundingClientRect().top<ne.getBoundingClientRect().top);const G=new IntersectionObserver(le=>{const de=le[0];if(!de)return;const ue=de.rootBounds?.top??ne.getBoundingClientRect().top;C(!de.isIntersecting&&de.boundingClientRect.top<ue)},{root:ne,threshold:0});return G.observe(T),()=>G.disconnect()},e[5]=a,e[6]=v,e[7]=k):k=e[7];let D;e[8]!==a||e[9]!==v||e[10]!==r.topContent?(D=[a,v,r.topContent],e[8]=a,e[9]=v,e[10]=r.topContent,e[11]=D):D=e[11],c.useLayoutEffect(k,D);let P,I;e[12]!==a||e[13]!==v?(P=()=>{a&&v&&g.current&&x(g.current)},I=[a,v,x],e[12]=a,e[13]=v,e[14]=P,e[15]=I):(P=e[14],I=e[15]),c.useLayoutEffect(P,I);let M=null;for(const ne of r.projectSections)r.stuckProjectHeaders.has(ne.project.id)&&(M=ne.project);const _=M??(r.hasSharedSessions?null:y[0]?.project??null),O=_?gi(_,i.homeDirectory):null;let U;if(e[16]!==r.projectSections||e[17]!==i.homeDirectory){let ne;e[19]!==i.homeDirectory?(ne=T=>({id:T.project.id,projectLabel:gi(T.project,i.homeDirectory),projectDescription:zr(T.project.normalizedPath,i.homeDirectory),projectIcon:T.project.icon,projectColor:T.project.color,projectIconImage:T.project.iconImage,projectIconBackground:T.project.iconBackground}),e[19]=i.homeDirectory,e[20]=ne):ne=e[20],U=r.projectSections.map(ne),e[16]=r.projectSections,e[17]=i.homeDirectory,e[18]=U}else U=e[18];const L=U;if(r.projectSections.length===0){let ne;return e[21]!==r.emptyState||e[22]!==r.topContent?(ne=s.jsxs(cn,{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[21]=r.emptyState,e[22]=r.topContent,e[23]=ne):ne=e[23],ne}if(r.sectionsForRender.length===0){const T=_2(r.topContentHasSearchMatches===!0)==="top-content"?r.topContent:r.searchEmptyState;let G;return e[24]!==T?(G=s.jsx(cn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:"space-y-1 pb-1 pl-2.5 pr-2",children:T}),e[24]=T,e[25]=G):G=e[25],G}const F="oc-sticky-fade-root relative flex min-h-0 flex-1";let R;e[26]!==a?(R=a?{"--scroll-shadow-top-size":"0px"}:void 0,e[26]=a,e[27]=R):R=e[27];const j=a?b:void 0,A=a?b:void 0,B=a?b:void 0,X=cn,H=!0,Z=!a,ce=96,Y="flex-1 min-h-0",se="oc-sidebar-scroller oc-sticky-fade-scroller space-y-1.5 pb-1 pl-2.5 pr-2 [overflow-anchor:none]";let oe;e[28]!==a?(oe=a?ne=>x(ne.currentTarget):void 0,e[28]=a,e[29]=oe):oe=e[29];const Se=i.showOnlyMainWorkspace?s.jsx("div",{className:"space-y-[0.6rem] py-1",children:(()=>{const ne=y.find(G=>G.project.id===r.activeProjectId)??y[0];if(!ne)return i.hasSessionSearchQuery?r.searchEmptyState:r.emptyState;const T=L2(ne);return T.length?T.map(G=>{const{group:le,groupKey:de,projectId:ue,hideGroupLabel:Oe}=G;return s.jsx(c.Fragment,{children:s.jsx(vo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:le,groupKey:de,projectId:ue,hideGroupLabel:Oe,visibleSessionCount:r.state.visibleSessionCountByGroup.get(de),compactBodyPadding:!0,scrollContainerRef:g})},de)}):s.jsx("div",{className:"py-1 text-left typography-micro text-muted-foreground",children:n("sessions.sidebar.empty.noSessions.title")})})()}):s.jsxs(Ur,{sensors:h,collisionDetection:Kr,onDragEnd:ne=>{if(l||i.projectSortOrder!=="manual")return;const{active:T,over:G}=ne;if(!G||T.id===G.id)return;const le=r.sectionsForRender.findIndex(ue=>ue.project.id===T.id),de=r.sectionsForRender.findIndex(ue=>ue.project.id===G.id);le===-1||de===-1||le===de||o.reorderProjects(le,de)},children:[s.jsx(Io,{items:y.map(G2),strategy:_i,children:y.map(ne=>{const T=ne.project,G=T.id,le=gi(T,i.homeDirectory),de=zr(T.normalizedPath,i.homeDirectory),ue=r.singleProjectMode?!1:i.collapsedProjects.has(G),Oe=r.projectRepoStatus.get(G);return s.jsx(Q0,{id:G,disabled:r.singleProjectMode||i.projectSortOrder!=="manual",projectLabel:le,projectDescription:de,projectDirectory:T.normalizedPath,projectIcon:T.icon,projectColor:T.color,projectIconImage:T.iconImage,projectIconBackground:T.iconBackground,isCollapsed:ue,isRepo:!!Oe,isDesktopShell:i.isDesktopShellRuntime,hideDirectoryControls:i.hideDirectoryControls,mobileVariant:i.mobileVariant,alwaysShowActions:i.alwaysShowActions,statusIndicator:ue?o.renderProjectStatusIndicator?.(G,ne.groups):null,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,projectPickerOptions:r.singleProjectMode?L:void 0,onProjectSelect:r.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{r.singleProjectMode||o.toggleProject(G)},onNewSession:()=>{G!==r.activeProjectId&&o.setActiveProjectIdOnly(G),i.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:G,directoryOverride:T.normalizedPath})},onNewWorktreeSession:()=>{G!==r.activeProjectId&&o.setActiveProjectIdOnly(G),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(G),onRenameStart:()=>o.openProjectEditDialog(G),onClose:()=>o.removeProject(G),sentinelRef:me=>{r.projectHeaderSentinelRefs.current.set(G,me)},showCreateButtons:!0,children:ue?null:s.jsx("div",{className:"space-y-0 pt-0.5 pb-0.5",children:(()=>{const me=ne.groups,Re=me.find(H2)??null,ye=Re?me.filter(q=>q.id!==Re.id):me;return s.jsxs(Ur,{sensors:p,collisionDetection:Kr,onDragEnd:q=>{if(l)return;const{active:we,over:be}=q;if(!be||we.id===be.id)return;const Ne=ye.findIndex($=>$.id===we.id),ie=ye.findIndex($=>$.id===be.id);if(Ne===-1||ie===-1||Ne===ie)return;const ee=du(ye,Ne,ie).map(K2),V=Re?[Re.id,...ee]:ee;o.setGroupOrderByProject($=>{const ae=new Map($);return ae.set(G,V),ae})},children:[Re?s.jsx(vo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:Re,groupKey:`${G}:${Re.id}`,projectId:G,hideGroupLabel:!0,visibleSessionCount:r.state.visibleSessionCountByGroup.get(`${G}:${Re.id}`),scrollContainerRef:g}):null,s.jsx(Io,{items:ye.map(U2),strategy:_i,children:ye.map(q=>{const we=`${G}:${q.id}`;return s.jsx(X0,{id:q.id,disabled:l,children:be=>s.jsx(vo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:q,groupKey:we,projectId:G,visibleSessionCount:r.state.visibleSessionCountByGroup.get(we),dragHandleProps:be,scrollContainerRef:g})},q.id)})}),s.jsx(Bi,{dropAnimation:null})]})})()})},G)})}),s.jsx(Bi,{dropAnimation:null})]});let K;e[30]!==X||e[31]!==r.topContent||e[32]!==Z||e[33]!==oe||e[34]!==Se?(K=s.jsxs(X,{ref:g,useScrollShadow:H,hideTopScrollShadow:Z,scrollShadowSize:ce,outerClassName:Y,className:se,onScroll:oe,children:[r.topContent,Se]}),e[30]=X,e[31]=r.topContent,e[32]=Z,e[33]=oe,e[34]=Se,e[35]=K):K=e[35];let pe;e[36]!==a||e[37]!==N||e[38]!==_||e[39]!==O||e[40]!==r.hasSharedSessions||e[41]!==n?(pe=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:_&&O?s.jsxs(s.Fragment,{children:[s.jsx(wo,{id:_.id,projectLabel:O,projectIcon:_.icon,projectColor:_.color,projectIconImage:_.iconImage,projectIconBackground:_.iconBackground}),s.jsx(Hr,{directory:_.normalizedPath,className:"ml-auto"})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:N?"history":"chat-4",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:n(N?"sessions.sidebar.activity.recentTitle":"sessions.sidebar.activity.chatsTitle")})]})}):null,e[36]=a,e[37]=N,e[38]=_,e[39]=O,e[40]=r.hasSharedSessions,e[41]=n,e[42]=pe):pe=e[42];let je;return e[43]!==R||e[44]!==j||e[45]!==A||e[46]!==B||e[47]!==K||e[48]!==pe?(je=s.jsxs("div",{className:F,style:R,onPointerDownCapture:j,onClickCapture:A,onContextMenuCapture:B,children:[K,pe]}),e[43]=R,e[44]=j,e[45]=A,e[46]=B,e[47]=K,e[48]=pe,e[49]=je):je=e[49],je}function U2(t){return t.id}function K2(t){return t.id}function H2(t){return t.isMain}function G2(t){return t.project.id}const q2=c.memo(V2),aa=new Map,Pc=(t,e)=>{for(const n of t){const r=vt(n??null);r&&!aa.has(r)&&aa.set(r,e)}},Ic=t=>{const e=vt(t??null);return e?aa.get(e)??0:0},Ir=t=>!!t.time?.archived,Q2=t=>{const{t:e}=Nt(),n=c.useRef(t.gitBranches);n.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),i=c.useCallback(a=>{const u=vt(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${u}`.toLowerCase()},[e]),o=c.useCallback((a,u)=>{if(!u)return a;const d=u.trim().toLowerCase(),h=d.startsWith("ses_");return a.flatMap(f=>{if(h&&Ir(f.session))return[];if(h?f.session.id.toLowerCase()===d:Ao([i(f.session)],u))return[f];const g=o(f.children,u);return g.length===0?[]:[{...f,children:g}]})},[i]),l=c.useCallback((a,u,d,h,f)=>{const p=vt(u??null),g=Ld(a),w=new Map(g.map(F=>[F.id,F])),S=new Map;g.forEach(F=>{const R=F.parentID;if(!R)return;const j=w.get(R);if(!j||Ir(j)!==Ir(F))return;const A=S.get(R)??[];A.push(F),S.set(R,A)});const x=new Map;d.forEach(F=>{if(F.path){const R=vt(F.path)??F.path;x.set(R,F)}});const m=F=>{const R=vt(F.directory??null),j=t.worktreeMetadata.get(F.id)??null;if(j)return j;if(R){const A=x.get(R)??null;if(A&&R!==p)return A}return null},b=new Set,y=F=>{b.add(F.id);const R=S.get(F.id)??[],j=[];for(const A of R)b.has(A.id)||j.push(y(A));return{session:F,children:j,worktree:m(F)}},v=g.filter(F=>{const R=F.parentID;if(!R)return!0;const j=w.get(R);return j?Ir(j)!==Ir(F):!0}),N=[],C=F=>{b.has(F.id)||N.push(y(F))};v.forEach(C),g.forEach(C);const k=new Map,D="__archived__",P=F=>{if(F.time?.archived)return D;if(t.isVSCode)return p??"__project_root__";const j=vt(t.worktreeMetadata.get(F.id)?.path??null)??Ts(F);return j?j!==p&&x.has(j)?j:j===p?p??"__project_root__":D:D};N.forEach(F=>{const R=P(F.session);k.has(R)||k.set(R,[]),k.get(R)?.push(F)});const I=p??"__project_root__",M=[{id:"root",label:f&&h&&h!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:h}):e("sessions.sidebar.grouping.projectRoot"),branch:h??null,description:p?zr(p,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:p,folderScopeKey:p,sessions:k.get(I)??[]}],_=new Map;d.forEach(F=>{const R=vt(F.path)??F.path,j=k.get(R)??[],A=j.length>0,B=j.reduce((X,H)=>{const Z=Vh(H.session,t.sessionOrderRanks);return Number.isFinite(Z)?Math.max(X,Z):X},0);_.set(R,{hasActiveSession:A,lastUpdatedAt:B})});const O=[...d].sort((F,R)=>{const j=vt(F.path)??F.path,A=vt(R.path)??R.path,B=_.get(j)??{hasActiveSession:!1,lastUpdatedAt:0},X=_.get(A)??{hasActiveSession:!1,lastUpdatedAt:0};if(B.hasActiveSession!==X.hasActiveSession)return B.hasActiveSession?-1:1;if(B.hasActiveSession&&X.hasActiveSession)return X.lastUpdatedAt-B.lastUpdatedAt;const H=Ic(F.path),Z=Ic(R.path);if(H!==Z)return Z-H;const ce=(F.label||F.branch||F.name||F.path||"").toLowerCase(),Y=(R.label||R.branch||R.name||R.path||"").toLowerCase();return ce.localeCompare(Y)});(t.isVSCode?[]:O).forEach(F=>{const R=vt(F.path)??F.path,j=n.current.get(R)?.trim()||null,A=F.branch?.trim()||null,X=!!(j&&A&&F.label&&cl(F.label)===cl(A))?j:F.label||F.name||Fn(R,t.homeDirectory)||R;M.push({id:`worktree:${R}`,label:X,branch:j||A,description:zr(R,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:F,directory:R,folderScopeKey:R,sessions:k.get(R)??[]})});const L=k.get(D)??[];return L.length>0&&M.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&&p?_d(p):null,sessions:L}),M},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},Y2=t=>{const e=st.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[u,d]=c.useState(a);let h;e[1]!==l||e[2]!==r||e[3]!==o?(h=()=>{if(!l||!r){d(X2);return}const g=Array.from(o.current.values()).find(J2)?.closest(".oc-sidebar-scroller")??null;if(!g)return;const w=new IntersectionObserver(S=>{d(x=>{const m=new Set(x);let b=!1;for(const y of S){const v=y.target.dataset.projectId;if(!v)continue;const N=y.rootBounds?.top??g.getBoundingClientRect().top,C=!y.isIntersecting&&y.boundingClientRect.top<N;m.has(v)!==C&&(b=!0,C?m.add(v):m.delete(v))}return b?m:x})},{root:g,threshold:0});return o.current.forEach(S=>{S&&w.observe(S)}),()=>w.disconnect()},e[1]=l,e[2]=r,e[3]=o,e[4]=h):h=e[4];let f;return e[5]!==l||e[6]!==r||e[7]!==o||e[8]!==i?(f=[l,r,o,i],e[5]=l,e[6]=r,e[7]=o,e[8]=i,e[9]=f):f=e[9],c.useEffect(h,f),u};function X2(t){return t.size===0?t:new Set}function J2(t){return t!==null}const Z2=t=>{const e=st.c(51),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:u,canRemoveFromFolder:d,onRestore:h,onDelete:f,onDone:p}=t,{t:g}=Nt(),w=!!r&&!o;let S;e[0]!==o||e[1]!==g?(S=g(o?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[0]=o,e[1]=g,e[2]=S):S=e[2];const x=S;let m;e[3]!==n||e[4]!==g?(m=g("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[3]=n,e[4]=g,e[5]=m):m=e[5];let b;e[6]!==m?(b=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:m}),e[6]=m,e[7]=b):b=e[7];let y;e[8]!==w||e[9]!==d||e[10]!==a||e[11]!==l||e[12]!==u||e[13]!==i||e[14]!==g?(y=w?s.jsxs(Js,{children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(Ys,{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":g("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(E,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:g("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(Xs,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(Kt,{disabled:!0,className:"text-muted-foreground",children:g("sessions.sidebar.folders.none")}):i.map(j=>s.jsx(Kt,{onClick:()=>l(j.id),children:s.jsx("span",{className:"flex-1 truncate",children:j.name})},j.id)),s.jsx(Os,{}),s.jsxs(Kt,{onClick:a,children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.newFolderEllipsis")]}),d?s.jsxs(Kt,{onClick:u,className:"text-destructive focus:text-destructive",children:[s.jsx(E,{name:"close",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[8]=w,e[9]=d,e[10]=a,e[11]=l,e[12]=u,e[13]=i,e[14]=g,e[15]=y):y=e[15];let v;e[16]!==o||e[17]!==h||e[18]!==g?(v=o?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":g("sessions.sidebar.bulkActions.restore"),children:s.jsx(E,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:g("sessions.sidebar.bulkActions.restore")})})]}):null,e[16]=o,e[17]=h,e[18]=g,e[19]=v):v=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=Ie("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(E,{name:"delete-bin",className:"h-4 w-4"}),e[21]=C):C=e[21];let k;e[22]!==x||e[23]!==f?(k=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:N,"aria-label":x,children:C})}),e[22]=x,e[23]=f,e[24]=k):k=e[24];let D;e[25]!==x?(D=s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:x})}),e[25]=x,e[26]=D):D=e[26];let P;e[27]!==k||e[28]!==D?(P=s.jsxs(At,{children:[k,D]}),e[27]=k,e[28]=D,e[29]=P):P=e[29];let I;e[30]!==g?(I=g("sessions.sidebar.header.actions.exitSelection"),e[30]=g,e[31]=I):I=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(E,{name:"close",className:"h-4 w-4"}),e[32]=M):M=e[32];let _;e[33]!==p||e[34]!==I?(_=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:p,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":I,children:M})}),e[33]=p,e[34]=I,e[35]=_):_=e[35];let O;e[36]!==g?(O=g("sessions.sidebar.header.actions.exitSelection"),e[36]=g,e[37]=O):O=e[37];let U;e[38]!==O?(U=s.jsx(Pt,{side:"top",sideOffset:4,children:s.jsx("p",{children:O})}),e[38]=O,e[39]=U):U=e[39];let L;e[40]!==_||e[41]!==U?(L=s.jsxs(At,{children:[_,U]}),e[40]=_,e[41]=U,e[42]=L):L=e[42];let F;e[43]!==P||e[44]!==L||e[45]!==y||e[46]!==v?(F=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[y,v,P,L]}),e[43]=P,e[44]=L,e[45]=y,e[46]=v,e[47]=F):F=e[47];let R;return e[48]!==F||e[49]!==b?(R=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5",children:[b,F]}),e[48]=F,e[49]=b,e[50]=R):R=e[50],R},ek=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},tk=t=>{const{t:e}=Nt(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,getFolderScopesForProject:o,addSessionsToFolder:l,removeSessionsFromFolders:a,createFolderAndStartRename:u,archiveSessions:d,unarchiveSessions:h,deleteSessions:f,setBulkDeleteConfirm:p}=t,g=xs(j=>j.enabled),w=xs(j=>j.selectedIds.size),S=w>0,x=xs(j=>j.selectedIds),m=xs(j=>j.scopeKey),b=c.useCallback(()=>{xs.getState().toggleMode()},[]),y=c.useCallback(()=>{xs.getState().disable()},[]),v=c.useMemo(()=>{if(!S||typeof document>"u")return!1;let j=!1,A=!1;for(const B of x){const X=document.querySelectorAll(`[data-session-row="${CSS.escape(B)}"]`);for(const H of X)H.getAttribute("data-session-archived")==="1"?A=!0:j=!0}return A&&!j},[S,x]),N=c.useMemo(()=>{if(m)return m;if(!S||typeof document>"u")return null;for(const j of x){const B=document.querySelector(`[data-session-row="${CSS.escape(j)}"]`)?.getAttribute("data-session-scope");if(B&&B.length>0)return B}return null},[S,x,m]),C=c.useMemo(()=>ek(N,o),[N,o]),k=c.useMemo(()=>C.flatMap(j=>i[j]??[]),[i,C]),D=c.useCallback(j=>{for(const A of C)if((i[A]??[]).some(B=>B.id===j))return A;return null},[i,C]),P=c.useMemo(()=>{if(!S)return!1;for(const j of C)for(const A of i[j]??[])for(const B of A.sessionIds)if(x.has(B))return!0;return!1},[i,C,S,x]),I=c.useCallback((j,A)=>{const B=Array.from(x);for(const X of C)X!==j&&a(X,B);l(j,A,B)},[l,a,x,C]),M=c.useCallback(j=>{if(!S)return;const A=D(j);A&&I(A,j)},[S,I,D]),_=c.useCallback(()=>{const j=C[0];if(!j||!S)return;const A=u(j);A&&I(j,A.id)},[u,S,I,C]),O=c.useCallback(()=>{if(!S)return;const j=Array.from(x);for(const A of C)a(A,j)},[a,x,C,S]),U=c.useCallback(async()=>{const j=Array.from(x);if(j.length!==0){if(v){const{deletedIds:A,failedIds:B}=await f(j);A.length>0&&Le.success(A.length===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:A.length}):e("sessions.sidebar.bulkActions.deletedPlural",{count:A.length})),B.length>0&&Le.error(B.length===1?e("sessions.sidebar.bulkActions.failedDeleteSingle",{count:B.length}):e("sessions.sidebar.bulkActions.failedDeletePlural",{count:B.length}))}else{const{archivedIds:A,failedIds:B}=await d(j);A.length>0&&Le.success(A.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:A.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:A.length})),B.length>0&&Le.error(B.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:B.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:B.length}))}xs.getState().clear()}},[d,v,f,x,e]),L=c.useCallback(()=>{if(!S)return;const j=x.size;if(!r){U();return}p({sessionCount:j,archivedBucket:v})},[v,U,x,r,p,S]),F=c.useCallback(async()=>{if(!S||!v)return;const j=Array.from(x),{restoredIds:A,failedIds:B}=await h(j);A.length>0&&Le.success(A.length===1?e("sessions.sidebar.bulkActions.restoredSingle",{count:A.length}):e("sessions.sidebar.bulkActions.restoredPlural",{count:A.length})),B.length>0&&Le.error(B.length===1?e("sessions.sidebar.bulkActions.failedRestoreSingle",{count:B.length}):e("sessions.sidebar.bulkActions.failedRestorePlural",{count:B.length})),xs.getState().clear()},[v,S,x,e,h]),R=c.useCallback(async()=>{p(null),await U()},[U]);return c.useEffect(()=>{if(!g)return;const j=typeof navigator<"u"&&/Macintosh|Mac OS X/.test(navigator.userAgent||""),A=B=>{if(n)return;const X=B.target;if(X&&(X.tagName==="INPUT"||X.tagName==="TEXTAREA"||X.isContentEditable))return;const H=j?B.metaKey:B.ctrlKey;if(B.key==="Escape"){B.preventDefault(),xs.getState().disable();return}if(H&&B.key==="Backspace"){B.preventDefault(),L();return}if(H&&(B.key==="a"||B.key==="A")){const Z=typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[];if(Z.length===0)return;B.preventDefault();const Y=xs.getState().scopeKey??Z[0]?.getAttribute("data-session-scope")??null,se=Se=>Y?Se.getAttribute("data-session-scope")===Y:!0,oe=Z.filter(se).map(Se=>Se.getAttribute("data-session-row")).filter(Se=>typeof Se=="string"&&Se.length>0);if(oe.length===0)return;xs.getState().replaceAll(oe,Y||null)}};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[L,n,g]),{selectionModeEnabled:g,hasSelection:S,selectedIdsSize:w,bulkScopeIsArchived:v,derivedSelectionScope:N,bulkScopeFolders:k,bulkCanRemoveFromFolder:P,handleToggleSelectionMode:b,handleExitSelectionMode:y,handleBulkMoveToFolder:M,handleBulkCreateFolderAndMove:_,handleBulkRemoveFromFolder:O,handleBulkDelete:L,handleBulkRestore:F,confirmBulkDelete:R}};function sk(t){const e=st.c(36),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=Te(uk),u=Te(dk),d=cs(ck),h=cs(lk),f=cs(ak),p=cs(ik),g=Je(ok),w=Je(rk),S=Je(nk);let x;e[0]!==h||e[1]!==i?(x=C=>{const k=h(C,"New folder");return i(C,k),k},e[0]=h,e[1]=i,e[2]=x):x=e[2];let m;e[3]!==f||e[4]!==g||e[5]!==S||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p||e[10]!==a||e[11]!==x||e[12]!==w?(m={isInlineEditing:r,showDeletionDialog:a,foldersMap:d,getFolderScopesForProject:n,addSessionsToFolder:f,removeSessionsFromFolders:p,createFolderAndStartRename:x,archiveSessions:g,unarchiveSessions:w,deleteSessions:S,setBulkDeleteConfirm:l},e[3]=f,e[4]=g,e[5]=S,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=a,e[11]=x,e[12]=w,e[13]=m):m=e[13];const b=tk(m);let y;e[14]!==b.bulkCanRemoveFromFolder||e[15]!==b.bulkScopeFolders||e[16]!==b.bulkScopeIsArchived||e[17]!==b.derivedSelectionScope||e[18]!==b.handleBulkCreateFolderAndMove||e[19]!==b.handleBulkDelete||e[20]!==b.handleBulkMoveToFolder||e[21]!==b.handleBulkRemoveFromFolder||e[22]!==b.handleBulkRestore||e[23]!==b.handleExitSelectionMode||e[24]!==b.hasSelection||e[25]!==b.selectedIdsSize||e[26]!==b.selectionModeEnabled?(y=b.selectionModeEnabled&&b.hasSelection?s.jsx(Z2,{selectedCount:b.selectedIdsSize,scopeKey:b.derivedSelectionScope,scopeFolders:b.bulkScopeFolders,archivedBucket:b.bulkScopeIsArchived,onMoveToFolder:b.handleBulkMoveToFolder,onCreateFolderAndMove:b.handleBulkCreateFolderAndMove,onRemoveFromFolder:b.handleBulkRemoveFromFolder,canRemoveFromFolder:b.bulkCanRemoveFromFolder,onRestore:b.handleBulkRestore,onDelete:b.handleBulkDelete,onDone:b.handleExitSelectionMode}):null,e[14]=b.bulkCanRemoveFromFolder,e[15]=b.bulkScopeFolders,e[16]=b.bulkScopeIsArchived,e[17]=b.derivedSelectionScope,e[18]=b.handleBulkCreateFolderAndMove,e[19]=b.handleBulkDelete,e[20]=b.handleBulkMoveToFolder,e[21]=b.handleBulkRemoveFromFolder,e[22]=b.handleBulkRestore,e[23]=b.handleExitSelectionMode,e[24]=b.hasSelection,e[25]=b.selectedIdsSize,e[26]=b.selectionModeEnabled,e[27]=y):y=e[27];let v;e[28]!==b.confirmBulkDelete||e[29]!==o||e[30]!==u||e[31]!==a?(v=s.jsx(v2,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:u,onConfirm:b.confirmBulkDelete}),e[28]=b.confirmBulkDelete,e[29]=o,e[30]=u,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 nk(t){return t.deleteSessions}function rk(t){return t.unarchiveSessions}function ok(t){return t.archiveSessions}function ik(t){return t.removeSessionsFromFolders}function ak(t){return t.addSessionsToFolder}function lk(t){return t.createFolder}function ck(t){return t.foldersMap}function dk(t){return t.setShowDeletionDialog}function uk(t){return t.showDeletionDialog}const Tc=7,fk=6e4,mk=()=>{const t=st.c(2),[e,n]=c.useState(0);let r,i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const o=setInterval(()=>{n(pk)},fk);return()=>clearInterval(o)},i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),c.useEffect(r,i),e};function hk(t){const{sections:e,variant:n="section",initialVisibleCount:r=Tc,batchSize:i=Tc}=t,{t:o}=Nt(),{pinnedSessionIds:l}=t,a=ls(y=>y.stickyZoneHeaders),[u,d]=c.useState(new Set),[h,f]=c.useState(new Map),p=n==="flat",g=c.useCallback(y=>{f(v=>{if(!v.has(y))return v;const N=new Map(v);return N.delete(y),N})},[]),w=c.useCallback(y=>{g(y),d(v=>{const N=new Set(v);return N.has(y)?N.delete(y):N.add(y),N})},[g]),S=c.useCallback((y,v,N)=>{f(C=>{const k=Math.min(N,v+i),D=new Map(C);return D.set(y,k),D})},[i]),x=mk(),m=c.useCallback(y=>{const v=new Set;sa(y,t.editingId,v);const N=Gr(y,t.openSidebarMenuKey,"recent",!1),C=new WeakMap,k=P=>{C.set(P,Bo(P)),P.children.forEach(k)};y.forEach(k);const D=P=>({subtreeContainsEditing:v,menuOpenSessionId:N,nodeStructureKey:C.get(P)??"",relativeTimeTick:x,childRenderExtrasFor:D});return P=>({subtreeContainsEditing:v,menuOpenSessionId:N,nodeStructureKey:C.get(P)??"",relativeTimeTick:x,childRenderExtrasFor:D})},[t.editingId,t.openSidebarMenuKey,x]),b=e.filter(y=>y.items.length>0||y.key==="chats");return b.length===0?null:s.jsx("div",{className:Ie(p?"space-y-0.5 pb-2":"space-y-2 pb-2"),children:b.map(y=>{const v=u.has(y.key),N=Math.max(r,h.get(y.key)??r),C=y.items.slice(0,N),k=y.items.length-C.length,D=y.key==="chats"&&!!t.renderChatsSection,P=!D&&!p&&y.items.length>r&&k===0,I=m(C.map(_=>_.node)),M=_=>s.jsx(Lo,{node:_.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:_.groupDirectory,projectId:_.projectId,secondaryMeta:_.secondaryMeta,renderContext:"recent",renderExtras:I(_.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,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},_.node.session.id);return p?s.jsxs("div",{className:"space-y-0.5",children:[C.map(M),k>0?s.jsx("button",{type:"button",onClick:()=>S(y.key,C.length,y.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]},y.key):s.jsxs("div",{className:"relative",children:[s.jsx("div",{"data-sidebar-activity-start":y.key,className:"pointer-events-none absolute inset-x-0 top-0 h-px","aria-hidden":"true"}),s.jsxs("div",{className:Ie("relative group/chats","-ml-2.5 -mr-2",!v&&"mb-1",a&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":a?"true":void 0,children:[s.jsxs("button",{type:"button",onClick:()=>w(y.key),className:Ie("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",y.key==="chats"?"pr-10":"pr-3.5"),"aria-expanded":!v,children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[s.jsx(E,{name:y.key==="chats"?"chat-4":"history",className:Ie("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:v?s.jsx(E,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(E,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:y.title})]}),y.key==="chats"&&t.onNewChat?s.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),t.onNewChat?.()},className:Ie("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(E,{name:"add",className:"h-4 w-4"})}):null]}),v?null:s.jsxs("div",{className:Ie("space-y-0.5"),children:[D?t.renderChatsSection?.(y.items):C.map(M),!D&&k>0?s.jsx("button",{type:"button",onClick:()=>S(y.key,C.length,y.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?s.jsx("button",{type:"button",onClick:()=>g(y.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]})]},y.key)})})}function pk(t){return t+1}const gk=t=>{const e=st.c(61),{projects:n,availableWorktreesByProject:r,gitBranches:i,homeDirectory:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,isDesktopShellRuntime:u,sessions:d,childrenMap:h,pinnedSessionIds:f,recentSessions:p,chatSessions:g,showRecentSection:w}=t,{t:S}=Nt();let x;if(e[0]!==r||e[1]!==i||e[2]!==o||e[3]!==n||e[4]!==d){x=new Map;for(const L of d){const F=vt(L.directory??null);if(!F)continue;let R=null,j=-1;for(const H of n){const Z=vt(H.normalizedPath);Z&&(F===Z||F.startsWith(`${Z}/`))&&Z.length>j&&(R=H,j=Z.length)}if(!R)continue;const A=r.get(R.normalizedPath)?.find(H=>vt(H.path)===F),B=Pa(R.label?.trim()||Fn(R.normalizedPath,o)||R.normalizedPath),X=A?.branch?.trim()||i.get(F)?.trim()||null;x.set(L.id,{projectId:R.id,groupDirectory:F,projectLabel:B,branchLabel:X&&X!=="HEAD"&&X!==B?X:null})}e[0]=r,e[1]=i,e[2]=o,e[3]=n,e[4]=d,e[5]=x}else x=e[5];const m=x;let b;e[6]!==m?(b=L=>m.get(L)??null,e[6]=m,e[7]=b):b=e[7];const y=b;let v;e[8]!==h?(v=L=>({session:L,children:(h.get(L.id)??[]).filter(xk).map(bk),worktree:null}),e[8]=h,e[9]=v):v=e[9];const N=v,C=l?a:"";let k;e[10]!==y||e[11]!==N||e[12]!==p||e[13]!==C?(k=xg({sessions:p,getSessionLocation:y,getSessionNode:N,query:C}),e[10]=y,e[11]=N,e[12]=p,e[13]=C,e[14]=k):k=e[14];const D=k;let P;e[15]!==S?(P=S("sessions.sidebar.activity.chatsTitle"),e[15]=S,e[16]=P):P=e[16];let I;if(e[17]!==g||e[18]!==N){let L;e[20]!==N?(L=F=>({node:N(F),projectId:null,groupDirectory:F.directory??null,secondaryMeta:null}),e[20]=N,e[21]=L):L=e[21],I=g.map(L),e[17]=g,e[18]=N,e[19]=I}else I=e[19];let M;e[22]!==P||e[23]!==I?(M={key:"chats",title:P,items:I},e[22]=P,e[23]=I,e[24]=M):M=e[24];let _;e[25]!==D||e[26]!==w||e[27]!==S||e[28]!==M?(_=[M,...w?D.map(L=>({...L,title:S("sessions.sidebar.activity.recentTitle")})):[]],e[25]=D,e[26]=w,e[27]=S,e[28]=M,e[29]=_):_=e[29];const O=_;let U;return e[30]!==u||e[31]!==f||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.startSessionWorktreeMenuLoad||e[58]!==t.toggleParent||e[59]!==O?(U=s.jsx(hk,{sections:O,variant:"section",isDesktopShellRuntime:u,pinnedSessionIds:f,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,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad}),e[30]=u,e[31]=f,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.startSessionWorktreeMenuLoad,e[58]=t.toggleParent,e[59]=O,e[60]=U):U=e[60],U};function xk(t){return!t.time?.archived}function bk(t){return{session:t,children:[],worktree:null}}const xf="oc.sessions.expandedParents.v3",yk=Ea(br()),wk=()=>{try{const t=globalThis.localStorage.getItem(xf);if(t===null)return new Set;const e=yk.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},Sk=()=>{const[t,e]=c.useState(wk),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=Uh(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(xf,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},vk=5*6e4,jk=[],kk=t=>!t.parentID,Ck=t=>{const e=st.c(293),{topology:n,view:r,actions:i}=t;let o,l,a,u,d;e[0]!==i?({alwaysShowActions:o,notifyOnSubtasks:l,projectViewActions:a,rowActions:u,...d}=i,e[0]=i,e[1]=o,e[2]=l,e[3]=a,e[4]=u,e[5]=d):(o=e[1],l=e[2],a=e[3],u=e[4],d=e[5]);const h=cs(Ak),f=cs(Dk),p=cs(Pk),g=r.projectView,{getOrderedGroups:w,setGroupOrderByProject:S,toggleGroup:x,toggleProject:m}=a;let b;e[6]!==n.isVSCode||e[7]!==n.knownDirectories?(b={knownDirectories:n.knownDirectories,isVSCode:n.isVSCode,isVisible:!0},e[6]=n.isVSCode,e[7]=n.knownDirectories,e[8]=b):b=e[8];const y=bg(b);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=(Ot,$t)=>{C(Yt=>new Map(Yt).set(Ot,$t+7))},e[10]=k):k=e[10];const D=k;let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P=Ot=>{C($t=>{if(!$t.has(Ot))return $t;const Yt=new Map($t);return Yt.delete(Ot),Yt})},e[11]=P):P=e[11];const I=P,M=ls(Ik),_=ls(Tk),O=ls(Rk),U=ls(Ek);let L;e[12]!==n.isVSCode?(L=!n.isVSCode&&!um(),e[12]=n.isVSCode,e[13]=L):L=e[13];const R=L&&_==="single",j=M&&!R;let A;e[14]!==y.pinnedSessionIds||e[15]!==y.rootSessions||e[16]!==y.sessionOrderRanks||e[17]!==j||e[18]!==n.isVSCode?(A={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]=A):A=e[19];const B=yg(A),[X,H]=c.useState(null),[Z,ce]=c.useState(""),[Y,se]=c.useState(null),[oe,Se]=c.useState(null),[K,pe]=c.useState(null),[je,ne]=c.useState(null);let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=(Ot,$t)=>{ne({scopeKey:Ot,folderId:$t.id,draft:$t.name})},e[20]=T):T=e[20];const G=T;let le;e[21]===Symbol.for("react.memo_cache_sentinel")?(le=Ot=>{ne($t=>$t?{...$t,draft:Ot}:null)},e[21]=le):le=e[21];const de=le;let ue;e[22]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>ne(null),e[22]=ue):ue=e[22];const Oe=ue,{expandedParents:me,toggleParent:Re}=Sk(),ye=Je(Mk);let q;e[23]!==ye?(q=(Ot,$t)=>{Ot!==Je.getState().currentSessionId&&ye(Ot,$t)},e[23]=ye,e[24]=q):q=e[24];const we=q,be=Vd();let Ne;e[25]!==y.pinnedSessionIds||e[26]!==y.sessionOrderRanks||e[27]!==n.gitBranches||e[28]!==n.isVSCode||e[29]!==n.worktreeMetadata||e[30]!==r.homeDirectory?(Ne={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]=Ne):Ne=e[31];const{buildGroupedSessions:ie,filterSessionNodesForSearch:ee,buildGroupSearchText:V}=Q2(Ne);let $;e[32]!==y.archivedSessions||e[33]!==y.sessions||e[34]!==n.availableWorktreesByProject||e[35]!==n.isVSCode||e[36]!==n.projects?($=B0(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]=$):$=e[37];const ae=$;let W;e[38]!==ae?(W={ownership:ae},e[38]=ae,e[39]=W):W=e[39];const{getSessionsForProject:ve,getArchivedSessionsForProject:Fe}=_0(W);let Ce;e:{if(n.isVSCode){Ce=null;break e}let Ot;e[40]!==y.chatSessions||e[41]!==r.homeDirectory?(Ot=Kh(r.homeDirectory)??y.chatSessions.map(Ok).find(Boolean)??null,e[40]=y.chatSessions,e[41]=r.homeDirectory,e[42]=Ot):Ot=e[42];const $t=Ot;if(!$t){Ce=null;break e}let Yt;if(e[43]!==$t||e[44]!==y.chatSessions){const Ke=[$t,...y.chatSessions.map(Fk).filter(Boolean)];let tt;e[46]!==Ke?(tt=new Set(Ke),e[46]=Ke,e[47]=tt):tt=e[47],Yt=Array.from(tt).filter(Bk).map(_k),e[43]=$t,e[44]=y.chatSessions,e[45]=Yt}else Yt=e[45];const ys=Yt;let ms;if(e[48]!==y.chatSessions||e[49]!==y.childrenMap){let Ke;e[51]!==y.childrenMap?(Ke=tt=>({session:tt,children:(y.childrenMap.get(tt.id)??[]).filter($k).map(Wk),worktree:null}),e[51]=y.childrenMap,e[52]=Ke):Ke=e[52],ms=y.chatSessions.filter(Lk).map(Ke),e[48]=y.chatSessions,e[49]=y.childrenMap,e[50]=ms}else ms=e[50];let te;e[53]!==$t||e[54]!==ys||e[55]!==ms?(te={id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:$t,folderScopeKey:$t,folderScopes:ys,draftTarget:"chat",sessions:ms},e[53]=$t,e[54]=ys,e[55]=ms,e[56]=te):te=e[56],Ce=te}const ke=Ce;let Qe;e[57]!==ke?(Qe=ke?[ke]:jk,e[57]=ke,e[58]=Qe):Qe=e[58];const We=Qe;let z;e[59]!==V||e[60]!==ie||e[61]!==ee||e[62]!==h||e[63]!==Fe||e[64]!==ve||e[65]!==We||e[66]!==n.availableWorktreesByProject||e[67]!==n.gitBranches||e[68]!==n.lastRepoStatus||e[69]!==n.projectRepoStatus||e[70]!==n.projectRootBranches||e[71]!==n.projects||e[72]!==r.hasSessionSearchQuery||e[73]!==r.normalizedSessionSearchQuery?(z={normalizedProjects:n.projects,getSessionsForProject:ve,getArchivedSessionsForProject:Fe,availableWorktreesByProject:n.availableWorktreesByProject,projectRepoStatus:n.projectRepoStatus,projectRootBranches:n.projectRootBranches,gitBranches:n.gitBranches,lastRepoStatus:n.lastRepoStatus,buildGroupedSessions:ie,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,filterSessionNodesForSearch:ee,buildGroupSearchText:V,foldersMap:h,standaloneGroups:We},e[59]=V,e[60]=ie,e[61]=ee,e[62]=h,e[63]=Fe,e[64]=ve,e[65]=We,e[66]=n.availableWorktreesByProject,e[67]=n.gitBranches,e[68]=n.lastRepoStatus,e[69]=n.projectRepoStatus,e[70]=n.projectRootBranches,e[71]=n.projects,e[72]=r.hasSessionSearchQuery,e[73]=r.normalizedSessionSearchQuery,e[74]=z):z=e[74];const{projectSections:he,groupSearchDataByGroup:Be,sectionsForRender:Ae,flatSectionsForRender:at,searchMatchCount:Ue}=W0(z),ht=r.onSearchMatchCountChange;let ut,Ct;e[75]!==ht||e[76]!==Ue?(ut=()=>{ht(Ue)},Ct=[ht,Ue],e[75]=ht,e[76]=Ue,e[77]=ut,e[78]=Ct):(ut=e[77],Ct=e[78]),c.useEffect(ut,Ct);let ge,Ye;e[79]!==ht?(ge=()=>()=>ht(0),Ye=[ht],e[79]=ht,e[80]=ge,e[81]=Ye):(ge=e[80],Ye=e[81]),c.useEffect(ge,Ye);const bt=Ia(),jt=`session-collection-expansion:${c.useId()}`;let fe,ze;e[82]!==bt||e[83]!==jt||e[84]!==he||e[85]!==g.collapsedGroups||e[86]!==g.collapsedProjects||e[87]!==r.activeProjectId?(fe=()=>(bt.setBootstrapDemand(jt,lf({projectSections:he,activeProjectId:r.activeProjectId,collapsedProjects:g.collapsedProjects,collapsedGroups:g.collapsedGroups,currentDirectory:null,currentSessionDirectory:null})),()=>bt.clearBootstrapDemand(jt)),ze=[bt,jt,he,g.collapsedProjects,g.collapsedGroups,r.activeProjectId],e[82]=bt,e[83]=jt,e[84]=he,e[85]=g.collapsedGroups,e[86]=g.collapsedProjects,e[87]=r.activeProjectId,e[88]=fe,e[89]=ze):(fe=e[88],ze=e[89]),c.useEffect(fe,ze);const it=r.useGroupedSections?Ae:at;let $e;e[90]!==it||e[91]!==r.showInlineArchived?($e=r.showInlineArchived?it:it.map(Uk),e[90]=it,e[91]=r.showInlineArchived,e[92]=$e):$e=e[92];const J=$e;let re;e[93]!==at?(re=Ot=>at.find(Yt=>Yt.project.id===Ot)?.groups.find(Kk)?.folderScopes??[],e[93]=at,e[94]=re):re=e[94];const Pe=re;let _e;e[95]===Symbol.for("react.memo_cache_sentinel")?(_e=new Map,e[95]=_e):_e=e[95];const Ve=c.useRef(_e);let Ze;e[96]!==he||e[97]!==r.isDesktopShellRuntime||e[98]!==r.stickyZoneHeaders?(Ze={enabled:r.stickyZoneHeaders,isDesktopShellRuntime:r.isDesktopShellRuntime,projectSections:he,projectHeaderSentinelRefs:Ve},e[96]=he,e[97]=r.isDesktopShellRuntime,e[98]=r.stickyZoneHeaders,e[99]=Ze):Ze=e[99];const lt=Y2(Ze);let rt;e[100]!==p||e[101]!==y.hasAuthoritativeGlobalSessions||e[102]!==f||e[103]!==h||e[104]!==ae||e[105]!==n.projects||e[106]!==r.isSessionsLoading||e[107]!==r.isWorktreeTopologyLoading||e[108]!==r.unresolvedWorktreeProjectPaths?(rt={enabled:!0,normalizedProjects:n.projects,ownership:ae,isSessionsLoading:r.isSessionsLoading,hasAuthoritativeGlobalSessions:y.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:r.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:r.unresolvedWorktreeProjectPaths,foldersMap:h,createFolder:f,addSessionToFolder:p},e[100]=p,e[101]=y.hasAuthoritativeGlobalSessions,e[102]=f,e[103]=h,e[104]=ae,e[105]=n.projects,e[106]=r.isSessionsLoading,e[107]=r.isWorktreeTopologyLoading,e[108]=r.unresolvedWorktreeProjectPaths,e[109]=rt):rt=e[109],A0(rt);const{github:Ge}=Sn(),ot=An(Hk),Ee=An(Gk),Rt=Hs(qk),xe=Hs(Qk),mt=Hs(Yk);let Tt;e[110]===Symbol.for("react.memo_cache_sentinel")?(Tt=new Set,e[110]=Tt):Tt=e[110];const Xe=c.useRef(Tt);let nt;e[111]!==Rt||e[112]!==Ge||e[113]!==Ee||e[114]!==ot||e[115]!==he||e[116]!==g.collapsedProjects||e[117]!==mt||e[118]!==xe||e[119]!==n.gitBranches?(nt=()=>{if(!Ge||!Ee||!ot?.connected)return;const Ot=new Map,$t=Date.now();he.forEach(Yt=>{g.collapsedProjects.has(Yt.project.id)||Yt.groups.forEach(ys=>{if(ys.isArchivedBucket||ys.isMain)return;const ms=vt(ys.directory??null),te=ys.branch?.trim()||n.gitBranches.get(ms||"")?.trim();if(!ms||!te)return;const Ke=Ho(ms,te),tt=Hs.getState().entries[Ke],Q=tt?.status?.pr?.state==="closed"||tt?.status?.pr?.state==="merged",He=`${ms}::${te}`,et=Math.max(tt?.lastRefreshAt??0,tt?.lastDiscoveryPollAt??0),pt=!!(tt?.isInitialStatusResolved&&(!tt.status?.pr||Q)&&(!Xe.current.has(He)||$t-et>=vk));(!tt||!tt.isInitialStatusResolved||pt)&&(pt&&Xe.current.add(He),Ot.set(Ke,{directory:ms,branch:te}))})}),Ot.forEach((Yt,ys)=>{Rt(ys),xe(ys,{...Yt,remoteName:null,canShow:!0,github:Ge,githubAuthChecked:Ee,githubConnected:ot.connected})}),Ot.size&&mt([...Ot.values()],{silent:!0,markInitialResolved:!0})},e[111]=Rt,e[112]=Ge,e[113]=Ee,e[114]=ot,e[115]=he,e[116]=g.collapsedProjects,e[117]=mt,e[118]=xe,e[119]=n.gitBranches,e[120]=nt):nt=e[120];const St=ot?.connected;let yt;e[121]!==Rt||e[122]!==Ge||e[123]!==Ee||e[124]!==he||e[125]!==g.collapsedProjects||e[126]!==mt||e[127]!==xe||e[128]!==St||e[129]!==n.gitBranches?(yt=[Rt,Ge,Ee,St,he,g.collapsedProjects,mt,xe,n.gitBranches],e[121]=Rt,e[122]=Ge,e[123]=Ee,e[124]=he,e[125]=g.collapsedProjects,e[126]=mt,e[127]=xe,e[128]=St,e[129]=n.gitBranches,e[130]=yt):yt=e[130],c.useEffect(nt,yt);let It;e[131]!==y.orderedSessions?(It=new Map(y.orderedSessions.map(Xk)),e[131]=y.orderedSessions,e[132]=It):It=e[132];const kt=It;let Et;if(e[133]!==w||e[134]!==J){let Ot;e[136]!==w?(Ot=$t=>{const Yt=w($t.project.id,$t.groups);return Yt===$t.groups?$t:{...$t,groups:Yt}},e[136]=w,e[137]=Ot):Ot=e[137],Et=J.map(Ot),e[133]=w,e[134]=J,e[135]=Et}else Et=e[135];const Bt=Et;let zt;e[138]!==he||e[139]!==O||e[140]!==R||e[141]!==r.activeProjectId?(zt=null,R&&(he.some(Ot=>Ot.project.id===O)?zt=O:he.some(Ot=>Ot.project.id===r.activeProjectId)?zt=r.activeProjectId:zt=he[0]?.project.id??null),e[138]=he,e[139]=O,e[140]=R,e[141]=r.activeProjectId,e[142]=zt):zt=e[142];const Gt=R&&!r.useGroupedSections?20:void 0;let rs;e[143]!==i.startSessionWorktreeMenuLoad||e[144]!==o||e[145]!==y.pinnedSessionIds||e[146]!==K||e[147]!==oe||e[148]!==Z||e[149]!==X||e[150]!==me||e[151]!==je||e[152]!==Be||e[153]!==l||e[154]!==g.collapsedGroups||e[155]!==u.allowReselect||e[156]!==u.isSessionSearchOpen||e[157]!==u.onSessionSelected||e[158]!==u.sessionSearchQuery||e[159]!==u.setIsSessionSearchOpen||e[160]!==u.setSessionSearchQuery||e[161]!==kt||e[162]!==Gt||e[163]!==Re||e[164]!==r.activeProjectId||e[165]!==r.hasSessionSearchQuery||e[166]!==r.hideDirectoryControls||e[167]!==r.mobileVariant||e[168]!==r.normalizedSessionSearchQuery?(rs={hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,groupSearchDataByGroup:Be,collapsedGroups:g.collapsedGroups,hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:o,activeProjectId:r.activeProjectId,notifyOnSubtasks:l,pinnedSessionIds:y.pinnedSessionIds,sessionOrderIndex:kt,expandedParents:me,editingId:X,editTitle:Z,copiedSessionId:K,sessionBatchSize:Gt,setEditingId:H,setEditTitle:ce,toggleParent:Re,allowReselect:u.allowReselect,onSessionSelected:u.onSessionSelected,isSessionSearchOpen:u.isSessionSearchOpen,sessionSearchQuery:u.sessionSearchQuery,setSessionSearchQuery:u.setSessionSearchQuery,setIsSessionSearchOpen:u.setIsSessionSearchOpen,deleteSessionConfirm:oe,setDeleteSessionConfirm:Se,startFolderRename:G,setCopiedSessionId:pe,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,folderRename:je,setFolderRenameDraft:de,clearFolderRename:Oe},e[143]=i.startSessionWorktreeMenuLoad,e[144]=o,e[145]=y.pinnedSessionIds,e[146]=K,e[147]=oe,e[148]=Z,e[149]=X,e[150]=me,e[151]=je,e[152]=Be,e[153]=l,e[154]=g.collapsedGroups,e[155]=u.allowReselect,e[156]=u.isSessionSearchOpen,e[157]=u.onSessionSelected,e[158]=u.sessionSearchQuery,e[159]=u.setIsSessionSearchOpen,e[160]=u.setSessionSearchQuery,e[161]=kt,e[162]=Gt,e[163]=Re,e[164]=r.activeProjectId,e[165]=r.hasSessionSearchQuery,e[166]=r.hideDirectoryControls,e[167]=r.mobileVariant,e[168]=r.normalizedSessionSearchQuery,e[169]=rs):rs=e[169];const _t=rs;let Wt;e[170]!==d.openNewSessionDraft||e[171]!==d.setActiveProjectIdOnly||e[172]!==d.setSessionSwitcherOpen||e[173]!==x?(Wt={showMoreGroupSessions:D,resetGroupSessionLimit:I,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,onToggleCollapsedGroup:x},e[170]=d.openNewSessionDraft,e[171]=d.setActiveProjectIdOnly,e[172]=d.setSessionSwitcherOpen,e[173]=x,e[174]=Wt):Wt=e[174];const Me=Wt;let qe;e[175]!==ke||e[176]!==Me||e[177]!==_t||e[178]!==Y?(qe=()=>ke?s.jsx(vo,{..._t,...Me,group:ke,groupKey:"managed-chats",projectId:null,hideGroupLabel:!0,sessionBatchSize:20,scrollContainerRef:void 0,openSidebarMenuKey:Y,setOpenSidebarMenuKey:se}):null,e[175]=ke,e[176]=Me,e[177]=_t,e[178]=Y,e[179]=qe):qe=e[179];const dt=qe;let wt;e[180]!==d||e[181]!==r.mobileVariant?(wt=()=>{Te.getState().closeMainSurfaces(),r.mobileVariant&&d.setSessionSwitcherOpen(!1),d.openNewSessionDraft({selectedProjectId:Hh,directoryOverride:null})},e[180]=d,e[181]=r.mobileVariant,e[182]=wt):wt=e[182];const ft=wt;let ct;e[183]!==i.startSessionWorktreeMenuLoad||e[184]!==o||e[185]!==y.chatSessions||e[186]!==y.childrenMap||e[187]!==y.pinnedSessionIds||e[188]!==K||e[189]!==oe||e[190]!==Z||e[191]!==X||e[192]!==me||e[193]!==ft||e[194]!==l||e[195]!==Y||e[196]!==B||e[197]!==dt||e[198]!==u.allowReselect||e[199]!==u.isSessionSearchOpen||e[200]!==u.onSessionSelected||e[201]!==u.sessionSearchQuery||e[202]!==u.setIsSessionSearchOpen||e[203]!==u.setSessionSearchQuery||e[204]!==M||e[205]!==R||e[206]!==Re||e[207]!==n.availableWorktreesByProject||e[208]!==n.gitBranches||e[209]!==n.isVSCode||e[210]!==n.projects||e[211]!==r.hasSessionSearchQuery||e[212]!==r.homeDirectory||e[213]!==r.isDesktopShellRuntime||e[214]!==r.mobileVariant||e[215]!==r.normalizedSessionSearchQuery?(ct=n.isVSCode?null:s.jsx(gk,{projects:n.projects,availableWorktreesByProject:n.availableWorktreesByProject,gitBranches:n.gitBranches,homeDirectory:r.homeDirectory,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,isDesktopShellRuntime:r.isDesktopShellRuntime,sessions:B,childrenMap:y.childrenMap,pinnedSessionIds:y.pinnedSessionIds,recentSessions:B,expandedParents:me,notifyOnSubtasks:l,editingId:X,editTitle:Z,copiedSessionId:K,openSidebarMenuKey:Y,mobileVariant:r.mobileVariant,alwaysShowActions:o,setEditingId:H,setEditTitle:ce,toggleParent:Re,setOpenSidebarMenuKey:se,allowReselect:u.allowReselect,onSessionSelected:u.onSessionSelected,isSessionSearchOpen:u.isSessionSearchOpen,sessionSearchQuery:u.sessionSearchQuery,setSessionSearchQuery:u.setSessionSearchQuery,setIsSessionSearchOpen:u.setIsSessionSearchOpen,deleteSessionConfirm:oe,setDeleteSessionConfirm:Se,startFolderRename:G,setCopiedSessionId:pe,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,chatSessions:y.chatSessions,renderChatsSection:dt,onNewChat:ft,showRecentSection:M&&!R}),e[183]=i.startSessionWorktreeMenuLoad,e[184]=o,e[185]=y.chatSessions,e[186]=y.childrenMap,e[187]=y.pinnedSessionIds,e[188]=K,e[189]=oe,e[190]=Z,e[191]=X,e[192]=me,e[193]=ft,e[194]=l,e[195]=Y,e[196]=B,e[197]=dt,e[198]=u.allowReselect,e[199]=u.isSessionSearchOpen,e[200]=u.onSessionSelected,e[201]=u.sessionSearchQuery,e[202]=u.setIsSessionSearchOpen,e[203]=u.setSessionSearchQuery,e[204]=M,e[205]=R,e[206]=Re,e[207]=n.availableWorktreesByProject,e[208]=n.gitBranches,e[209]=n.isVSCode,e[210]=n.projects,e[211]=r.hasSessionSearchQuery,e[212]=r.homeDirectory,e[213]=r.isDesktopShellRuntime,e[214]=r.mobileVariant,e[215]=r.normalizedSessionSearchQuery,e[216]=ct):ct=e[216];const Vt=ct;let Xt;e[217]!==Be||e[218]!==We||e[219]!==r.hasSessionSearchQuery?(Xt=r.hasSessionSearchQuery&&We.some(Ot=>Be.get(Ot)?.hasMatch===!0),e[217]=Be,e[218]=We,e[219]=r.hasSessionSearchQuery,e[220]=Xt):Xt=e[220];const Jt=Xt,ks=!!Vt;let ns;e[221]!==X||e[222]!==Y||e[223]!==N?(ns={editingId:X,openSidebarMenuKey:Y,setOpenSidebarMenuKey:se,visibleSessionCountByGroup:N},e[221]=X,e[222]=Y,e[223]=N,e[224]=ns):ns=e[224];let Ws;e[225]!==_t||e[226]!==Bt||e[227]!==he||e[228]!==Vt||e[229]!==zt||e[230]!==R||e[231]!==lt||e[232]!==ks||e[233]!==ns||e[234]!==Jt||e[235]!==n.projectRepoStatus||e[236]!==r.activeProjectId||e[237]!==r.emptyState||e[238]!==r.searchEmptyState?(Ws={topContent:Vt,topContentHasSearchMatches:Jt,hasSharedSessions:ks,sectionsForRender:Bt,projectSections:he,activeProjectId:r.activeProjectId,singleProjectMode:R,singleProjectId:zt,emptyState:r.emptyState,searchEmptyState:r.searchEmptyState,projectRepoStatus:n.projectRepoStatus,stuckProjectHeaders:lt,projectHeaderSentinelRefs:Ve,state:ns,groupProps:_t},e[225]=_t,e[226]=Bt,e[227]=he,e[228]=Vt,e[229]=zt,e[230]=R,e[231]=lt,e[232]=ks,e[233]=ns,e[234]=Jt,e[235]=n.projectRepoStatus,e[236]=r.activeProjectId,e[237]=r.emptyState,e[238]=r.searchEmptyState,e[239]=Ws):Ws=e[239];const bs=Ws;let os;e[240]!==o||e[241]!==g.collapsedProjects||e[242]!==r.hasSessionSearchQuery||e[243]!==r.hideDirectoryControls||e[244]!==r.homeDirectory||e[245]!==r.isDesktopShellRuntime||e[246]!==r.mobileVariant||e[247]!==r.normalizedSessionSearchQuery||e[248]!==r.projectSortOrder||e[249]!==r.showOnlyMainWorkspace||e[250]!==r.stickyZoneHeaders?(os={homeDirectory:r.homeDirectory,collapsedProjects:g.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[240]=o,e[241]=g.collapsedProjects,e[242]=r.hasSessionSearchQuery,e[243]=r.hideDirectoryControls,e[244]=r.homeDirectory,e[245]=r.isDesktopShellRuntime,e[246]=r.mobileVariant,e[247]=r.normalizedSessionSearchQuery,e[248]=r.projectSortOrder,e[249]=r.showOnlyMainWorkspace,e[250]=r.stickyZoneHeaders,e[251]=os):os=e[251];const Zs=os;let zs;e[252]!==Me||e[253]!==d.openNewSessionDraft||e[254]!==d.openNewWorktreeDialog||e[255]!==d.openProjectEditDialog||e[256]!==d.openWorktreesPage||e[257]!==d.removeProject||e[258]!==d.renderProjectStatusIndicator||e[259]!==d.reorderProjects||e[260]!==d.setActiveProjectIdOnly||e[261]!==d.setSessionSwitcherOpen||e[262]!==S||e[263]!==U||e[264]!==m?(zs={group:Me,toggleProject:m,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,openNewWorktreeDialog:d.openNewWorktreeDialog,openWorktreesPage:d.openWorktreesPage,openProjectEditDialog:d.openProjectEditDialog,removeProject:d.removeProject,reorderProjects:d.reorderProjects,setGroupOrderByProject:S,renderProjectStatusIndicator:d.renderProjectStatusIndicator,setSingleProjectId:U},e[252]=Me,e[253]=d.openNewSessionDraft,e[254]=d.openNewWorktreeDialog,e[255]=d.openProjectEditDialog,e[256]=d.openWorktreesPage,e[257]=d.removeProject,e[258]=d.renderProjectStatusIndicator,e[259]=d.reorderProjects,e[260]=d.setActiveProjectIdOnly,e[261]=d.setSessionSwitcherOpen,e[262]=S,e[263]=U,e[264]=m,e[265]=zs):zs=e[265];const dn=zs;let Ds;e[266]===Symbol.for("react.memo_cache_sentinel")?(Ds=s.jsx(j0,{}),e[266]=Ds):Ds=e[266];let fs;e[267]!==i.initialActiveSessionByProject||e[268]!==i.openNewSessionDraft||e[269]!==i.persistActiveSessionByProject||e[270]!==i.setSessionSwitcherOpen||e[271]!==ae.bySessionId||e[272]!==he||e[273]!==we||e[274]!==r.activeProjectId||e[275]!==r.mobileVariant?(fs=s.jsx(T0,{projectSections:he,activeProjectId:r.activeProjectId,initialActiveSessionByProject:i.initialActiveSessionByProject,persistActiveSessionByProject:i.persistActiveSessionByProject,mobileVariant:r.mobileVariant,openNewSessionDraft:i.openNewSessionDraft,setSessionSwitcherOpen:i.setSessionSwitcherOpen,sessionOwnerBySessionId:ae.bySessionId,handleSessionSelect:we}),e[267]=i.initialActiveSessionByProject,e[268]=i.openNewSessionDraft,e[269]=i.persistActiveSessionByProject,e[270]=i.setSessionSwitcherOpen,e[271]=ae.bySessionId,e[272]=he,e[273]=we,e[274]=r.activeProjectId,e[275]=r.mobileVariant,e[276]=fs):fs=e[276];let Ps;e[277]!==y.orderedSessions||e[278]!==be||e[279]!==B?(Ps=s.jsx(G0,{sortedSessions:y.orderedSessions,recentSessions:B,prefetchSession:be}),e[277]=y.orderedSessions,e[278]=be,e[279]=B,e[280]=Ps):Ps=e[280];let Vs;e[281]!==dn||e[282]!==bs||e[283]!==Zs?(Vs=s.jsx(q2,{model:bs,view:Zs,actions:dn}),e[281]=dn,e[282]=bs,e[283]=Zs,e[284]=Vs):Vs=e[284];const Us=X!==null;let Cs;e[285]!==Pe||e[286]!==Us?(Cs=s.jsx(sk,{getFolderScopesForProject:Pe,isInlineEditing:Us,startFolderRename:G}),e[285]=Pe,e[286]=Us,e[287]=Cs):Cs=e[287];let en;return e[288]!==fs||e[289]!==Ps||e[290]!==Vs||e[291]!==Cs?(en=s.jsxs(s.Fragment,{children:[Ds,fs,Ps,Vs,Cs]}),e[288]=fs,e[289]=Ps,e[290]=Vs,e[291]=Cs,e[292]=en):en=e[292],en},Nk=t=>{const e=st.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(Ck,{...t}):null,e[0]=t,e[1]=n):n=e[1],n};function Ak(t){return t.foldersMap}function Dk(t){return t.createFolder}function Pk(t){return t.addSessionToFolder}function Ik(t){return t.showRecentSection}function Tk(t){return t.projectDisplayMode}function Rk(t){return t.singleProjectId}function Ek(t){return t.setSingleProjectId}function Mk(t){return t.setCurrentSession}function Ok(t){return Hd(t.directory)}function Fk(t){return vt(t.directory??null)}function Bk(t){return!!t}function _k(t){return{scopeKey:t,directory:t}}function Lk(t){return!t.time?.archived&&kk(t)}function $k(t){return!t.time?.archived}function Wk(t){return{session:t,children:[],worktree:null}}function zk(t){return t.isArchivedBucket}function Vk(t){return!t.isArchivedBucket}function Uk(t){return t.groups.some(zk)?{...t,groups:t.groups.filter(Vk)}:t}function Kk(t){return!t.isArchivedBucket}function Hk(t){return t.status}function Gk(t){return t.hasChecked}function qk(t){return t.ensureEntry}function Qk(t){return t.setParams}function Yk(t){return t.refreshTargets}function Xk(t,e){return[t.id,e]}const bf=(t,e,n)=>{const r=new Set;for(const i of t){const o=vt(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=vt(o.path)?.toLowerCase();l&&r.add(l)}return r},Rc="oc.sessions.activeSessionByProject",Jk=[],Zk=xu(br(),br().min(1).catch("")),e4=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{wi("react.session_sidebar_render"),qs("ui.session_sidebar.render"),qs(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),qs(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=Nt(),[a,u]=c.useState(!1),[d,h]=c.useState(""),[f,p]=c.useState(0),g=c.useRef(null),w=c.useRef(null),[S,x]=c.useState(null),m=c.useMemo(()=>No(),[]),[b,y]=c.useState(new Map),v=Te(xe=>xe.isNewWorktreeDialogOpen),N=Te(xe=>xe.setNewWorktreeDialogOpen),[C,k]=c.useState(!1),D=c.useMemo(()=>{try{const xe=m.getItem(Rc);if(!xe)return new Map;const mt=Zk.safeParse(JSON.parse(xe));if(!mt.success)return new Map;const Tt=new Map;return Object.entries(mt.data).forEach(([Xe,nt])=>{nt&&Tt.set(Xe,nt)}),Tt}catch{return new Map}},[m]),P=c.useCallback(xe=>{try{m.setItem(Rc,JSON.stringify(Object.fromEntries(xe.entries())))}catch{}},[m]),[I,M]=c.useState(new Map),_=ts(xe=>xe.homeDirectory),O=Ht(xe=>xe.projects),U=Ht(xe=>xe.activeProjectId),L=Ht(xe=>xe.removeProject),F=Ht(xe=>xe.setActiveProjectIdOnly),R=Ht(xe=>xe.updateProjectMeta),j=Ht(xe=>xe.reorderProjects),A=Te(xe=>xe.setSettingsDialogOpen),B=Te(xe=>xe.toggleHelpDialog),X=Te(xe=>xe.setAboutDialogOpen),H=Te(xe=>xe.setSessionSwitcherOpen),Z=Te(xe=>xe.setScheduledTasksDialogOpen),ce=Te(xe=>xe.setArchivePageOpen),Y=Te(xe=>xe.setWorktreesPageProjectId),se=Te(xe=>xe.openMultiRunLauncher),oe=Te(xe=>xe.notifyOnSubtasks),Se=va(d,120),K=c.useMemo(()=>Se.trim().toLowerCase(),[Se]),pe=K.length>0;Kv({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:w,sessionSearchContainerRef:g});const je=Md(t),ne=c.useMemo(()=>Pn(),[]),T=Je(xe=>xe.setCurrentSession),G=Je(xe=>xe.worktreeMetadata),le=Je(xe=>xe.availableWorktreesByProject),de=Je(xe=>xe.openNewSessionDraft),ue=c.useMemo(()=>bf(O,le,{includeWorktrees:!ne}),[le,ne,O]),Oe=c.useCallback(xe=>{Te.getState().closeMainSurfaces(),de(xe),ne&&window.dispatchEvent(new CustomEvent("aiworker:navigate",{detail:{view:"chat"}}))},[ne,de]),me=Fr(Jn(xe=>({checkForUpdates:xe.checkForUpdates,available:xe.available,runtimeType:xe.runtimeType,info:xe.info,downloading:xe.downloading,downloaded:xe.downloaded,progress:xe.progress,error:xe.error,downloadUpdate:xe.downloadUpdate,restartToUpdate:xe.restartToUpdate}))),Re=us(),ye=c.useMemo(()=>`${Re}|${O.map(xe=>`${xe.id}:${vt(xe.path)??""}`).join("|")}`,[O,Re]),[q,we]=c.useState(ne?ye:null),[be,Ne]=c.useReducer(xe=>xe+1,0),ie=!ne&&q!==ye,[ee,V]=c.useState(new Set),$=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let xe=!1;return(async()=>{const Tt=Re,Xe=Ht.getState().projects;if(Xe.length===0||ne){xe||($.current={runtimeKey:null,revision:0,worktreesByProject:new Map},V(new Set),we(ye));return}const nt=Je.getState().availableWorktreesByProject,St=Va({rawWorktreesByProjectRef:$,publishedWorktreesByProject:nt,runtimeKey:Tt}),yt=St.revision,It=new Map(St.worktreesByProject),kt=new Set,Et=3;let Bt=0;const zt=Array.from({length:Et},async()=>{for(;;){const _t=Bt;if(Bt+=1,_t>=Xe.length)return;const Wt=Xe[_t],Me=vt(Wt.path);if(Me)try{const qe=await Di(async()=>Dn.getState().directories.get(Me)?.isGitRepo??await Ko(Me)?fl({id:Wt.id,path:Me}):null);if(qe===null){It.delete(Me);continue}if(xe)return;qe.length===0?It.delete(Me):It.set(Me,qe)}catch{kt.add(Me)}}});if(await Promise.all(zt),xe||us()!==Tt)return;const Gt=new Set(Xe.map(_t=>vt(_t.path)).filter(Boolean));for(const _t of It.keys())Gt.has(_t)||It.delete(_t);i2({rawWorktreesByProjectRef:$,runtimeKey:Tt,capturedRevision:yt,nextRawWorktreesByProject:It,publishedWorktreesByProject:nt,partitionWorktreesByRegisteredProject:ul,projects:Xe,worktreeMapsEqual:dl,recordWorktreesSeen:Pc,publishTopology:_t=>{Je.setState(_t)},requestRediscovery:()=>{Ne()},now:()=>Date.now()})&&(V(kt),we(ye))})(),()=>{xe=!0}},[ne,ye,Re,be]);const ae=c.useMemo(()=>bn(),[]),{isTablet:W}=_n(),ve=e||W,Fe=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]),Ce=c.useMemo(()=>O.find(xe=>xe.id===S)??null,[O,S]),ke=c.useCallback(xe=>{S&&R(S,{label:xe.label,icon:xe.icon,color:xe.color,iconBackground:xe.iconBackground,defaultModel:xe.defaultModel??null})},[S,R]),Qe=c.useCallback(()=>{N(!0)},[N]),We=c.useCallback(()=>{const xe=Fr.getState();if(xe.available&&xe.info){k(!0);return}me.checkForUpdates().then(()=>{const{available:mt,error:Tt}=Fr.getState();if(Tt){Le.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:Tt});return}if(!mt){Le.success(l("sessions.sidebar.updateCheck.latestVersion"));return}k(!0)})},[l,me]),z=c.useCallback(()=>{e&&H(!1),A(!0)},[e,H,A]),he=me.available&&(me.runtimeType==="desktop"||me.runtimeType==="web"),Be=c.useCallback(()=>{xn.requestDirectoryDialog()},[]),Ae=c.useMemo(()=>O.flatMap(xe=>{const mt=vt(xe.path);return mt?[{id:xe.id,path:xe.path,label:xe.label,normalizedPath:mt,icon:xe.icon??void 0,color:xe.color??void 0,iconImage:xe.iconImage??void 0,iconBackground:xe.iconBackground??void 0,addedAt:xe.addedAt,lastOpenedAt:xe.lastOpenedAt,sidebarCollapsed:xe.sidebarCollapsed}]:[]}),[O]),at=c.useMemo(()=>Ae.map(xe=>xe.normalizedPath),[Ae]),Ue=Gh(t?at:Jk);Zv({enabled:t,normalizedProjects:Ae,gitRepoStatus:Ue,setProjectRepoStatus:y,setProjectRootBranches:M});const ht=Je(xe=>xe.isLoading),ut=c.useRef(!1);U&&b.has(U)&&(ut.current=!!b.get(U));const Ct=ls(xe=>xe.showArchivedSessions),ge=ls(xe=>xe.projectSortOrder),Ye=ls(xe=>xe.stickyZoneHeaders),bt=Ht(xe=>xe.manualProjectOrder),jt={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:W,projects:O,activeProjectId:U,manualProjectOrder:bt,worktreeMetadata:G,availableWorktreesByProject:le,gitBranches:je,gitRepoStatus:Ue,updateStore:me,showArchivedSessions:Ct,projectSortOrder:ge,projectRepoStatus:b,projectRootBranches:I,resolvedWorktreeTopologyKey:q,unresolvedWorktreeProjectPaths:ee,isSessionSearchOpen:a,sessionSearchQuery:d,editingProjectDialogId:S,updateDialogOpen:C},fe=c.useRef(null),ze=fe.current;if(ze){let xe=!1;for(const mt of Object.keys(jt))Object.is(ze[mt],jt[mt])||(qs(`ui.session_sidebar.source.${mt}`),xe=!0);xe||qs("ui.session_sidebar.source.parent_or_context")}fe.current=jt;const it=c.useMemo(()=>wg(Ae,ge,bt),[Ae,ge,bt]),$e=Qv({isVSCode:ne,projects:it}),J=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]),re=ne&&Ct,_e=ls(xe=>xe.sessionGroupingMode)==="by-worktree"&&!ne,lt=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",Ge=c.useCallback(()=>{e&&H(!1),se()},[e,se,H]),ot=c.useMemo(()=>({projects:O,getCurrentProjects:()=>Ht.getState().projects,rawWorktreesByProjectRef:$,getPublishedWorktreesByProject:()=>Je.getState().availableWorktreesByProject,resolveProject:xe=>vi(xe),listProjectWorktrees:fl,partitionWorktreesByRegisteredProject:ul,worktreeMapsEqual:dl,recordWorktreesSeen:Pc,publishTopology:xe=>{Je.setState(xe)},getRuntimeKey:us,now:()=>Date.now()}),[O]),Ee=c.useCallback(xe=>{const mt=xe.projectId?O.find(Tt=>Tt.id===xe.projectId)??null:xe.sourceDirectory?vi(xe.sourceDirectory):null;return o2(xe,{...ot,projectRootBranch:mt?I.get(mt.id)??null:null})},[I,O,ot]);c.useEffect(()=>{if(!ne)return Yr(xe=>{if(xe.type==="session-created"){Ne();return}if(xe.type==="worktree-changed")for(const mt of qh(xe.directories)){const Tt=vt(mt.path);pf(mt,null,ot).then(()=>{Tt&&V(Xe=>{if(!Xe.has(Tt))return Xe;const nt=new Set(Xe);return nt.delete(Tt),nt})}).catch(()=>{Tt&&V(Xe=>new Set(Xe).add(Tt))})}})},[ne,ot]);const Rt=c.useCallback(()=>{Te.getState().closeMainSurfaces(),e&&H(!1),de()},[e,de,H]);return s.jsx(Ri,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:g,className:Ie("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[!i&&!ne?s.jsx(w0,{onNewSession:Rt}):null,s.jsx(i0,{hideDirectoryControls:i,showProjectDisplayControls:!ne,showRecentControls:!ne,handleOpenDirectoryDialog:Be,onOpenScheduled:()=>{e&&H(!1),Z(!0)},onOpenMultiRun:Ge,canOpenMultiRun:O.length>0,onOpenArchive:()=>{e&&H(!1),ce(!0)},headerActionIconClass:rt,headerActionButtonClass:lt,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:w,sessionSearchQuery:d,setSessionSearchQuery:h,hasSessionSearchQuery:pe,searchMatchCount:f,collapseAllProjects:$e.actions.collapseAllProjects,expandAllProjects:$e.actions.expandAllProjects}),s.jsx(Nk,{topology:{projects:it,availableWorktreesByProject:le,knownDirectories:ue,isVSCode:ne,worktreeMetadata:G,gitBranches:je,projectRepoStatus:b,projectRootBranches:I,lastRepoStatus:ut.current},view:{isVisible:t,hasSessionSearchQuery:pe,normalizedSessionSearchQuery:K,activeProjectId:U,showInlineArchived:re,useGroupedSections:_e,homeDirectory:_,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:ae,stickyZoneHeaders:Ye,projectSortOrder:ge,emptyState:Fe,searchEmptyState:J,isSessionsLoading:ht,isWorktreeTopologyLoading:ie,unresolvedWorktreeProjectPaths:ee,projectView:$e.state,onSearchMatchCountChange:p},actions:{rowActions:{allowReselect:r,onSessionSelected:n,isSessionSearchOpen:a,sessionSearchQuery:d,setSessionSearchQuery:h,setIsSessionSearchOpen:u},alwaysShowActions:ve,notifyOnSubtasks:oe,setActiveProjectIdOnly:F,setSessionSwitcherOpen:H,openNewSessionDraft:Oe,openNewWorktreeDialog:Qe,openWorktreesPage:xe=>{e&&H(!1),Y(xe)},openProjectEditDialog:x,removeProject:L,reorderProjects:j,startSessionWorktreeMenuLoad:Ee,initialActiveSessionByProject:D,persistActiveSessionByProject:P,projectViewActions:$e.actions}}),s.jsx(S0,{onOpenSettings:z,onOpenShortcuts:B,onOpenAbout:()=>X(!0),onOpenUpdate:We,showRuntimeButtons:!ne,showUpdateButton:he}),s.jsx(tu,{open:C,onOpenChange:k,info:me.info,downloading:me.downloading,downloaded:me.downloaded,progress:me.progress,error:me.error,onDownload:me.downloadUpdate,onRestart:me.restartToUpdate,runtimeType:me.runtimeType}),s.jsx(r0,{open:!!Ce,onOpenChange:xe=>{xe||x(null)},project:Ce,onSave:ke}),s.jsx(Sg,{open:v,onOpenChange:N,onWorktreeCreated:(xe,mt)=>{if(Te.getState().closeMainSurfaces(),e&&H(!1),mt?.sessionId){T(mt.sessionId,xe);return}de({directoryOverride:xe,preserveDirectoryOverride:!0})}})]})})},t4=c.memo(e4),jn=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,fn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},s4=()=>{const{t}=Nt(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,u]=c.useState([]),[d,h]=c.useState(!1),[f,p]=c.useState(!1),[g,w]=c.useState(!1),[S,x]=c.useState(!1),[m,b]=c.useState(new Set),y=Je(q=>q.getWorktreeMetadata),v=Je(q=>q.newSessionDraft),N=Je(q=>q.setNewSessionDraftTarget),C=Je(q=>q.setDraftBootstrapPendingDirectory),k=Qh,D=Je(q=>q.deleteSessions),P=Je(q=>q.archiveSessions),I=Te(q=>q.showDeletionDialog),M=Te(q=>q.setShowDeletionDialog),_=ts(q=>q.currentDirectory),O=ts(q=>q.homeDirectory),U=ts(q=>q.isHomeReady),L=Ht(q=>q.projects),F=Ht(q=>q.activeProjectId),{isMobile:R,isTablet:j,hasTouchInput:A}=_n(),B=R||j||A,X=c.useMemo(()=>{const we=(F?L.find(be=>be.id===F)??null:null)?.path??_;return fn(we)},[F,_,L]),H=c.useCallback(q=>{const be=fn(q.projectDirectory)||X;return{id:(L.find(ie=>fn(ie.path)===be)??null)?.id??`path:${be}`,path:be}},[X,L]),Z=S&&m.size>0,ce=c.useMemo(()=>{const q=o?.worktree;return q&&typeof q.branch=="string"&&q.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:we})=>typeof we.branch=="string"&&we.branch.trim().length>0)},[o?.worktree,a]),Y=o?.mode==="worktree",se=Y,oe=g||!Y||!ce,Se=g||!Y;c.useEffect(()=>{r||!U||L.length>0||(i(!0),n(!0))},[r,U,L.length]);const K=c.useCallback(q=>{l({sessions:q.sessions,dateLabel:q.dateLabel,mode:q.mode??"session",worktree:q.worktree??null})},[]),pe=c.useCallback(()=>{l(null),u([]),h(!1),p(!1),w(!1),x(!1),b(new Set)},[]),je=c.useCallback(async q=>{if(q.sessions.length===0)return;if(q.sessions.length===1){const ie=q.sessions[0];await k(ie.id)?Le.success(t("sessions.sidebar.session.delete.success")):Le.error(t("sessions.sidebar.session.delete.error"));return}const we=q.sessions.map(ie=>ie.id),{deletedIds:be,failedIds:Ne}=await D(we);if(be.length>0){const ie=Ne.length>0?Ne.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Ne.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Ne.length}):q.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:q.dateLabel}):void 0;Le.success(be.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:be.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:be.length}),{description:jn(ie)})}Ne.length>0&&Le.error(Ne.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Ne.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Ne.length}),{description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[k,D,t]);c.useEffect(()=>xn.onDeleteRequest(q=>{if(!I&&(q.mode??"session")==="session"){je(q);return}K(q)}),[K,I,je]),c.useEffect(()=>xn.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){u([]),h(!1),p(!1),x(!1),b(new Set);return}const q=o.sessions.map(Ne=>{const ie=y(Ne.id);return ie?{session:Ne,metadata:ie}:null}).filter(Ne=>!!Ne);u(q),h(!1),x(!1),b(new Set);const we=new Map;if(o.worktree?.path&&we.set(fn(o.worktree.path),o.worktree),q.forEach(({metadata:Ne})=>{Ne.path&&we.set(fn(Ne.path),Ne)}),we.size===0){x(!0);return}let be=!1;return(async()=>{const Ne=new Map,ie=new Set;await Promise.all(Array.from(we.entries()).map(async([ee,V])=>{try{const $=await Yh(V.path);Ne.set(ee,$),$?.isDirty&&ie.add(ee)}catch{V.status&&(Ne.set(ee,V.status),V.status.isDirty&&ie.add(ee))}})).catch(ee=>{console.warn("Failed to inspect worktree status before deletion:",ee)}),!be&&(b(ie),x(!0),l(ee=>{if(!ee?.worktree?.path)return ee;const V=fn(ee.worktree.path),$=Ne.get(V);if(!$)return ee;const ae=ee.worktree.status;return ae?.isDirty===$.isDirty&&ae?.ahead===$.ahead&&ae?.behind===$.behind&&ae?.upstream===$.upstream?ee:{...ee,worktree:{...ee.worktree,status:$}}}),u(ee=>ee.map(V=>{const $=fn(V.metadata.path),ae=Ne.get($);return ae?{session:V.session,metadata:{...V.metadata,status:ae}}:V})))})(),()=>{be=!0}},[o,y]),c.useEffect(()=>{ce||h(!1)},[ce]);const ne=c.useCallback(async(q,we,be)=>{const Ne=d&&ce,ie=H(q),ee=fn(q.path),V=fn(ie.path);try{await Sd(ie,q,{deleteRemoteBranch:Ne,deleteLocalBranch:we});const $=fn(v?.directoryOverride);return v?.open&&ee&&$===ee&&V&&(C(null),N({projectId:ie.id,directoryOverride:V},{force:!0})),fn(_)===ee&&V&&ts.getState().setDirectory(V,{showOverlay:!1}),!0}catch($){return Le.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:ti(q)}),{id:be,description:jn($ instanceof Error?$.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ce,_,d,H,v?.directoryOverride,v?.open,C,N,t]),T=c.useCallback((q,we,be)=>{const Ne=d&&ce,ie=Le.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:ti(q)}));(async()=>{try{if(we.length>0){const{failedIds:$}=await P(we);if($.length>0){Le.error($.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:$.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:$.length}),{id:ie,description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await ne(q,be,ie))return;const V=t(Ne?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Le.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:ti(q)}),{id:ie,description:jn(V)})}catch(ee){Le.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:ie,description:jn(ee instanceof Error?ee.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[P,ce,d,ne,t]),G=c.useCallback(async()=>{if(o){w(!0);try{const q=se,we=q&&d,be=q&&f;if(Y&&o.worktree){T(o.worktree,o.sessions.map(Ne=>Ne.id),be),pe();return}if(o.sessions.length===1){const Ne=o.sessions[0];if(!await k(Ne.id)){Le.error(t("sessions.sidebar.session.delete.error")),w(!1);return}const ee=!Y&&q?t(we?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;Le.success(t("sessions.sidebar.session.delete.success"),{description:jn(ee),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const Ne=o.sessions.map($=>$.id);let ie=[],ee=[];const V=await D(Ne);if(ie=V.deletedIds,ee=V.failedIds,ie.length>0){const $=!Y&&q?t(we?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,W=[ee.length>0?ee.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ee.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ee.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,$].filter(Boolean).join(" ");Le.success(ie.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ie.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ie.length}),{description:jn(W||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(ee.length>0&&(Le.error(ee.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ee.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ee.length}),{description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ie.length===0)){w(!1);return}}pe()}finally{w(!1)}}},[o,d,f,k,D,pe,se,Y,T,t]),le=o?.worktree??a[0]?.metadata??null,de=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}):"",ue=o?s.jsxs("div",{className:Ie(Y?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:Ie(Y?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[Y&&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:Ie(Y?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(q=>s.jsxs("li",{className:Ie(Y?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:Ie(!Y&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:q.title||t("sessions.sidebar.session.untitled")})]},q.id)),o.sessions.length>5&&s.jsx("li",{className:Ie(Y?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),Y?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(E,{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")}),le?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:le.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:le?zr(le.path,O):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),Z&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Oe=Y?ce?s.jsxs("button",{type:"button",onClick:()=>{oe||h(q=>!q)},disabled:oe,className:Ie("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",oe?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[d?s.jsx(E,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(E,{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,me=Y?s.jsxs("button",{type:"button",onClick:()=>{Se||p(q=>!q)},disabled:Se,className:Ie("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Se?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[f?s.jsx(E,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(E,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Re=Y?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:[me,Oe]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xt,{variant:"ghost",onClick:pe,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(xt,{variant:"destructive",onClick:G,disabled:g,children:t(g?"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:()=>M(!I),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":!I,children:[I?s.jsx(E,{name:"checkbox-blank",className:"size-4"}):s.jsx(E,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xt,{variant:"ghost",onClick:pe,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(xt,{variant:"destructive",onClick:G,disabled:g,children:g?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),ye=Y?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:[B?s.jsx(Go,{open:!!o,onClose:()=>{g||pe()},title:ye,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Re}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[de&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:de}),ue]})}):s.jsx(vs,{open:!!o,onOpenChange:q=>{if(!q){if(g)return;pe()}},children:s.jsxs(js,{className:Ie(Y?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs($s,{children:[s.jsxs(Rs,{className:Ie(Y&&"flex items-center gap-2"),children:[Y&&s.jsx(E,{name:"delete-bin",className:"h-5 w-5"}),ye]}),de&&s.jsx(Es,{children:de})]}),s.jsx("div",{className:Ie(Y&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:ue}),s.jsx(yn,{className:"mt-2 gap-2 pt-1 pb-1",children:Re})]})}),s.jsx(vg,{open:e,onOpenChange:n})]})};function n4(t){const e=st.c(64),{t:n}=Nt(),{value:r,onMoveSessionOnly:i,onMoveAllChanges:o,onCancel:l}=t,a=!!r;let u;e[0]!==l?(u=R=>{R||l()},e[0]=l,e[1]=u):u=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.session.moveToWorktree.confirm.title"),e[2]=n,e[3]=d):d=e[3];let h;e[4]!==d?(h=s.jsx(Rs,{children:d}),e[4]=d,e[5]=h):h=e[5];const f=r?.dirtyFileCount??0;let p;e[6]!==n||e[7]!==f?(p=n("sessions.sidebar.session.moveToWorktree.confirm.changedFiles",{count:f}),e[6]=n,e[7]=f,e[8]=p):p=e[8];let g;e[9]!==n?(g=n("sessions.sidebar.session.moveToWorktree.confirm.ownership"),e[9]=n,e[10]=g):g=e[10];let w;e[11]!==p||e[12]!==g?(w=s.jsxs(Es,{children:[p," ",g]}),e[11]=p,e[12]=g,e[13]=w):w=e[13];let S;e[14]!==h||e[15]!==w?(S=s.jsxs($s,{children:[h,w]}),e[14]=h,e[15]=w,e[16]=S):S=e[16];let x;e[17]!==n?(x=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnlyHelp"),e[17]=n,e[18]=x):x=e[18];let m;e[19]!==x?(m=s.jsx("p",{children:x}),e[19]=x,e[20]=m):m=e[20];let b;e[21]!==n?(b=n("sessions.sidebar.session.moveToWorktree.confirm.allChangesHelp"),e[21]=n,e[22]=b):b=e[22];let y;e[23]!==b?(y=s.jsx("p",{children:b}),e[23]=b,e[24]=y):y=e[24];let v;e[25]!==n||e[26]!==r?(v=r&&r.stagedFileCount>0?s.jsx("p",{"data-session-worktree-move-staged-warning":"true",children:n("sessions.sidebar.session.moveToWorktree.confirm.stagedWarning")}):null,e[25]=n,e[26]=r,e[27]=v):v=e[27];let N;e[28]!==n?(N=n("sessions.sidebar.session.moveToWorktree.confirm.baseWarning"),e[28]=n,e[29]=N):N=e[29];let C;e[30]!==N?(C=s.jsx("p",{children:N}),e[30]=N,e[31]=C):C=e[31];let k;e[32]!==m||e[33]!==y||e[34]!==v||e[35]!==C?(k=s.jsxs("div",{className:"space-y-2 typography-ui-label text-muted-foreground",children:[m,y,v,C]}),e[32]=m,e[33]=y,e[34]=v,e[35]=C,e[36]=k):k=e[36];let D;e[37]!==n?(D=n("sessions.sidebar.session.moveToWorktree.confirm.cancel"),e[37]=n,e[38]=D):D=e[38];let P;e[39]!==l||e[40]!==D?(P=s.jsx(xt,{type:"button",variant:"neutral","data-session-worktree-move-action":"cancel",onClick:l,children:D}),e[39]=l,e[40]=D,e[41]=P):P=e[41];let I;e[42]!==n?(I=n("sessions.sidebar.session.moveToWorktree.confirm.allChanges"),e[42]=n,e[43]=I):I=e[43];let M;e[44]!==o||e[45]!==I?(M=s.jsx(xt,{type:"button",variant:"outline","data-session-worktree-move-action":"all-changes",onClick:o,children:I}),e[44]=o,e[45]=I,e[46]=M):M=e[46];let _;e[47]!==n?(_=n("sessions.sidebar.session.moveToWorktree.confirm.sessionOnly"),e[47]=n,e[48]=_):_=e[48];let O;e[49]!==i||e[50]!==_?(O=s.jsx(xt,{type:"button",autoFocus:!0,"data-session-worktree-move-action":"session-only",onClick:i,children:_}),e[49]=i,e[50]=_,e[51]=O):O=e[51];let U;e[52]!==P||e[53]!==M||e[54]!==O?(U=s.jsxs(yn,{className:"gap-2 sm:justify-end",children:[P,M,O]}),e[52]=P,e[53]=M,e[54]=O,e[55]=U):U=e[55];let L;e[56]!==k||e[57]!==U||e[58]!==S?(L=s.jsxs(js,{id:"session-worktree-move-confirm-dialog",showCloseButton:!1,className:"max-w-md gap-5",children:[S,k,U]}),e[56]=k,e[57]=U,e[58]=S,e[59]=L):L=e[59];let F;return e[60]!==a||e[61]!==u||e[62]!==L?(F=s.jsx(vs,{open:a,onOpenChange:u,children:L}),e[60]=a,e[61]=u,e[62]=L,e[63]=F):F=e[63],F}function yf(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return bu.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function r4(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=bu.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 o4=[{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"}],i4={"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"},Gn=t=>i4[t]??t,wf=[0,1,2,3,4,5,6],Ec="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",la=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(Gn))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],Mc=()=>{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}`},jo=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},Oc=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},a4=(t,e,n)=>{const r=jo(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},Fc=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),l4=(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(),u=new Date(n,r,0).getDate(),d=[];for(let h=0;h<42;h+=1){const f=h-l+1;if(f<=0){const p=u+f;d.push({date:new Date(n,r-1,p),inCurrentMonth:!1});continue}if(f>a){d.push({date:new Date(n,r+1,f-a),inCurrentMonth:!1});continue}d.push({date:new Date(n,r,f),inCurrentMonth:!0})}return d},c4=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}},zn=(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")}`},wr=(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"},Bc=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:wr(t,{min:1,max:12}),uo=t=>/^[0-5][0-9]$/.test(t)?t:wr(t,{max:59}),d4=(t,e)=>wr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),_c=(t,e)=>wr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),u4=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}},f4=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}},m4=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return wf.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},h4=(t,e)=>[...t.slice(e),...t.slice(0,e)],Ms=t=>{const e=st.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},Lc=t=>{const e=st.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:u,pmLabel:d}=t;let h;e[0]!==n?(h=c4(n),e[0]=n,e[1]=h):h=e[1];const f=h,p=gt.useRef(null),g=gt.useRef(null),[w,S]=gt.useState(null),[x,m]=gt.useState(null),b=gt.useRef(null),y=gt.useRef(null);let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=q=>{b.current=q,S(q)},e[2]=v):v=e[2];const N=v;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=q=>{y.current=q,m(q)},e[3]=C):C=e[3];const k=C,D=S4,P=v4,I=j4;let M;e[4]!==r||e[5]!==f.meridiem||e[6]!==f.minute||e[7]!==i?(M=q=>{const we=q.replace(/\D/g,"").slice(0,2);N(we),we.length===2&&(r(i?I(D(we),f.minute):zn(Bc(we),f.minute,f.meridiem)),N(null),g.current?.focus())},e[4]=r,e[5]=f.meridiem,e[6]=f.minute,e[7]=i,e[8]=M):M=e[8];const _=M;let O;e[9]!==r||e[10]!==f.meridiem||e[11]!==f.minute||e[12]!==i?(O=()=>{const q=b.current;if(q!==null&&(N(null),q.length!==0)){if(i){r(I(D(q.padStart(2,"0")),f.minute));return}r(zn(Bc(q.padStart(2,"0")),f.minute,f.meridiem))}},e[9]=r,e[10]=f.meridiem,e[11]=f.minute,e[12]=i,e[13]=O):O=e[13];const U=O;let L;e[14]!==r||e[15]!==f.hour12||e[16]!==f.hour24||e[17]!==f.meridiem||e[18]!==i?(L=q=>{const we=q.replace(/\D/g,"").slice(0,2);k(we),we.length===2&&(r(i?I(f.hour24,uo(we)):zn(f.hour12,uo(we),f.meridiem)),k(null))},e[14]=r,e[15]=f.hour12,e[16]=f.hour24,e[17]=f.meridiem,e[18]=i,e[19]=L):L=e[19];const F=L;let R;e[20]!==r||e[21]!==f.hour12||e[22]!==f.hour24||e[23]!==f.meridiem||e[24]!==i?(R=()=>{const q=y.current;q!==null&&(k(null),q.length!==0&&r(i?I(f.hour24,uo(q.padStart(2,"0"))):zn(f.hour12,uo(q.padStart(2,"0")),f.meridiem)))},e[20]=r,e[21]=f.hour12,e[22]=f.hour24,e[23]=f.meridiem,e[24]=i,e[25]=R):R=e[25];const j=R;let A;e[26]!==r||e[27]!==f.hour12||e[28]!==f.hour24||e[29]!==f.meridiem||e[30]!==f.minute||e[31]!==i?(A=q=>r(i?I(P(f.hour24,q),f.minute):zn(d4(f.hour12,q),f.minute,f.meridiem)),e[26]=r,e[27]=f.hour12,e[28]=f.hour24,e[29]=f.meridiem,e[30]=f.minute,e[31]=i,e[32]=A):A=e[32];const B=A;let X;e[33]!==r||e[34]!==f.hour12||e[35]!==f.hour24||e[36]!==f.meridiem||e[37]!==f.minute||e[38]!==i?(X=q=>r(i?I(f.hour24,_c(f.minute,q)):zn(f.hour12,_c(f.minute,q),f.meridiem)),e[33]=r,e[34]=f.hour12,e[35]=f.hour24,e[36]=f.meridiem,e[37]=f.minute,e[38]=i,e[39]=X):X=e[39];const H=X;let Z;e[40]!==r||e[41]!==f.hour12||e[42]!==f.meridiem||e[43]!==f.minute?(Z=q=>{q!==f.meridiem&&r(zn(f.hour12,f.minute,q))},e[40]=r,e[41]=f.hour12,e[42]=f.meridiem,e[43]=f.minute,e[44]=Z):Z=e[44];const ce=Z;let Y;e[45]!==U||e[46]!==B?(Y=q=>{if(q.key==="ArrowRight"){q.preventDefault(),U(),g.current?.focus();return}(q.key==="ArrowUp"||q.key==="ArrowDown")&&(q.preventDefault(),N(null),B(q.key==="ArrowUp"?1:-1))},e[45]=U,e[46]=B,e[47]=Y):Y=e[47];const se=Y;let oe;e[48]!==j||e[49]!==H?(oe=q=>{if(q.key==="ArrowLeft"&&(q.currentTarget.selectionStart??0)===0){q.preventDefault(),j(),p.current?.focus();return}(q.key==="ArrowUp"||q.key==="ArrowDown")&&(q.preventDefault(),k(null),H(q.key==="ArrowUp"?1:-1))},e[48]=j,e[49]=H,e[50]=oe):oe=e[50];const Se=oe,K=i?"px-2":"pl-2 pr-1";let pe;e[51]!==K?(pe=Ie("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",K),e[51]=K,e[52]=pe):pe=e[52];const je=w??(i?f.hour24:f.hour12);let ne;e[53]!==_?(ne=q=>_(q.target.value),e[53]=_,e[54]=ne):ne=e[54];let T;e[55]===Symbol.for("react.memo_cache_sentinel")?(T=()=>N(""),e[55]=T):T=e[55];let G;e[56]!==U||e[57]!==o||e[58]!==se||e[59]!==je||e[60]!==ne?(G=s.jsx("input",{ref:p,inputMode:"numeric",value:je,onChange:ne,onKeyDown:se,onFocus:T,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]=se,e[59]=je,e[60]=ne,e[61]=G):G=e[61];let le;e[62]===Symbol.for("react.memo_cache_sentinel")?(le=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=le):le=e[62];const de=x??f.minute;let ue;e[63]!==F?(ue=q=>F(q.target.value),e[63]=F,e[64]=ue):ue=e[64];let Oe;e[65]===Symbol.for("react.memo_cache_sentinel")?(Oe=()=>k(""),e[65]=Oe):Oe=e[65];let me;e[66]!==j||e[67]!==l||e[68]!==Se||e[69]!==de||e[70]!==ue?(me=s.jsx("input",{ref:g,inputMode:"numeric",value:de,onChange:ue,onKeyDown:Se,onFocus:Oe,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]=Se,e[69]=de,e[70]=ue,e[71]=me):me=e[71];let Re;e[72]!==u||e[73]!==f.meridiem||e[74]!==a||e[75]!==d||e[76]!==ce||e[77]!==i?(Re=i?null:s.jsxs(Fs,{value:f.meridiem,onValueChange:q=>ce(q),children:[s.jsx(Bs,{"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(As,{})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"AM",children:u}),s.jsx(ss,{value:"PM",children:d})]})]}),e[72]=u,e[73]=f.meridiem,e[74]=a,e[75]=d,e[76]=ce,e[77]=i,e[78]=Re):Re=e[78];let ye;return e[79]!==pe||e[80]!==G||e[81]!==me||e[82]!==Re?(ye=s.jsxs("div",{className:pe,children:[G,le,me,Re]}),e[79]=pe,e[80]=G,e[81]=me,e[82]=Re,e[83]=ye):ye=e[83],ye},$c=t=>new Date(t.getFullYear(),t.getMonth(),1),p4=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},Wc=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),g4=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"]},zc=(t,e)=>{const n=Gn(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:g4(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:Mc(),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:Gn(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:Mc(),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}}},x4=(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(!yf(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")},b4=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))},y4=t=>{const e=st.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?yf(l):null,e[0]=l,e[1]=a):a=e[1];const u=a;let d;e:{if(!u?.valid||!l.trim()){let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A=[],e[2]=A):A=e[2],d=A;break e}let j;e[3]!==l||e[4]!==n.schedule.timezone?(j=r4(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=j):j=e[5],d=j}const h=d;let f;e[6]!==n.schedule.timezone||e[7]!==i?(f=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]=f):f=e[8];const p=f;let g;e[9]!==o?(g=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=g):g=e[10];let w;e[11]!==g?(w=s.jsx(Ms,{htmlFor:"sched-cron",required:!0,children:g}),e[11]=g,e[12]=w):w=e[12];let S;e[13]!==r?(S=j=>r(A=>({...A,schedule:{...A.schedule,cronExpression:j.target.value}})),e[13]=r,e[14]=S):S=e[14];let x;e[15]!==o?(x=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=x):x=e[16];let m;e[17]!==l||e[18]!==S||e[19]!==x?(m=s.jsx(Cn,{id:"sched-cron",value:l,onChange:S,placeholder:x,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=S,e[19]=x,e[20]=m):m=e[20];let b;e[21]!==l||e[22]!==u||e[23]!==o?(b=u&&!u.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=u,e[23]=o,e[24]=b):b=e[24];let y;e[25]!==w||e[26]!==m||e[27]!==b?(y=s.jsxs("div",{className:"flex flex-col gap-1",children:[w,m,b]}),e[25]=w,e[26]=m,e[27]=b,e[28]=y):y=e[28];let v;e[29]!==p||e[30]!==h||e[31]!==o?(v=h.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:h.map(p).join(", ")})]}):null,e[29]=p,e[30]=h,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=o4.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(A=>({...A,schedule:{...A.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 D;e[40]!==k?(D=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:k}),e[40]=k,e[41]=D):D=e[41];let P;e[42]!==C||e[43]!==D?(P=s.jsxs("div",{className:"flex flex-col gap-1",children:[C,D]}),e[42]=C,e[43]=D,e[44]=P):P=e[44];let I;e[45]!==o?(I=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=I):I=e[46];let M;e[47]!==I?(M=s.jsx(Ms,{children:I}),e[47]=I,e[48]=M):M=e[48];let _;e[49]!==r?(_=j=>{r(A=>({...A,schedule:{...A.schedule,timezone:j}}))},e[49]=r,e[50]=_):_=e[50];let O;e[51]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(As,{})}),e[51]=O):O=e[51];let U;e[52]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(_s,{children:la.map(k4)}),e[52]=U):U=e[52];let L;e[53]!==n.schedule.timezone||e[54]!==_?(L=s.jsxs(Fs,{value:n.schedule.timezone,onValueChange:_,children:[O,U]}),e[53]=n.schedule.timezone,e[54]=_,e[55]=L):L=e[55];let F;e[56]!==M||e[57]!==L?(F=s.jsxs("div",{className:"flex flex-col gap-1",children:[M,L]}),e[56]=M,e[57]=L,e[58]=F):F=e[58];let R;return e[59]!==y||e[60]!==v||e[61]!==P||e[62]!==F?(R=s.jsxs("div",{className:"flex flex-col gap-3",children:[y,v,P,F]}),e[59]=y,e[60]=v,e[61]=P,e[62]=F,e[63]=R):R=e[63],R};function w4(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=Nt(),a=qt(z=>z.loadProviders),u=qt(z=>z.loadAgents),d=qt(z=>z.providers),h=qt(z=>z.currentProviderId),f=qt(z=>z.currentModelId),p=qt(z=>z.currentVariant||""),g=qt(z=>z.currentAgentName||""),w=Te(z=>z.timeFormatPreference),S=Te(z=>z.weekStartPreference),x=Te(z=>z.isMobile),[m,b]=gt.useState(()=>zc(n,{providerID:h,modelID:f,variant:p,agent:g})),[y,v]=gt.useState(!1),[N,C]=gt.useState(!1),[k,D]=gt.useState(!1),[P,I]=gt.useState(""),[M,_]=gt.useState(!1),[O,U]=gt.useState(""),[L,F]=gt.useState(!1),[R,j]=gt.useState(""),[A,B]=gt.useState(()=>{const z=jo(n?.schedule?.date||"")||new Date;return new Date(z.getFullYear(),z.getMonth(),1)}),X=gt.useRef(null),H=gt.useRef(null),Z=gt.useRef(null),ce=gt.useRef(null),Y=gt.useRef(null),se=gt.useMemo(()=>f4(l),[l]),oe=gt.useMemo(()=>u4(l),[l]),Se=gt.useMemo(()=>w==="24h"?!0:w==="12h"?!1:se,[w,se]),K=gt.useMemo(()=>S==="sunday"?0:S==="monday"?1:oe,[S,oe]),pe=gt.useMemo(()=>{const z=m4(l);return h4(wf.map(he=>({value:he,label:z[he]||""})),K)},[l,K]);gt.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),u({source:"scheduledTaskEditor"}))},[e,a,u]),gt.useEffect(()=>{if(!e)return;b(zc(n,{providerID:h,modelID:f,variant:p,agent:g}));const z=jo(n?.schedule?.date||"")||new Date;B(new Date(z.getFullYear(),z.getMonth(),1)),C(!1),_(!1),D(!1),U(""),I("")},[e,n,h,f,p,g]),gt.useEffect(()=>{if(!N)return;const z=he=>{X.current&&!X.current.contains(he.target)&&C(!1)};return document.addEventListener("mousedown",z),()=>{document.removeEventListener("mousedown",z)}},[N]);const je=gt.useMemo(()=>{const he=d.find(Be=>Be.id===m.execution.providerID)?.models?.find(Be=>Be.id===m.execution.modelID);return he?.variants?Object.keys(he.variants):[]},[d,m.execution.providerID,m.execution.modelID]),ne=je.length>0,T=gt.useMemo(()=>!ne||!m.execution.variant?"__default":je.includes(m.execution.variant)?m.execution.variant:"__default",[m.execution.variant,ne,je]);gt.useEffect(()=>{ne||!m.execution.variant||b(z=>({...z,execution:{...z.execution,variant:""}}))},[ne,m.execution.variant]);const G=gt.useCallback((z,he)=>{b(Be=>{const Ae=new Set(Be.schedule.weekdays);return he?Ae.add(z):Ae.delete(z),{...Be,schedule:{...Be.schedule,weekdays:Array.from(Ae).sort((at,Ue)=>at-Ue)}}})},[]),le=gt.useCallback((z,he)=>{b(Be=>{const Ae=Be.schedule.times.slice();return Ae[z]=he,{...Be,schedule:{...Be.schedule,times:Ae}}})},[]),de=gt.useCallback(z=>{b(he=>{const Be=he.schedule.times.filter((Ae,at)=>at!==z);return{...he,schedule:{...he.schedule,times:Be.length>0?Be:["09:00"]}}})},[]),ue=gt.useCallback(()=>{b(z=>({...z,schedule:{...z.schedule,times:[...z.schedule.times,"12:00"]}}))},[]),Oe=gt.useMemo(()=>p4(),[]),me=gt.useMemo(()=>$c(Oe),[Oe]),Re=gt.useMemo(()=>{const z=jo(m.schedule.onceDate);return z?Wc(z,Oe)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(z):null},[m.schedule.onceDate,l,o,Oe]),ye=gt.useMemo(()=>$c(A).getTime()<=me.getTime(),[A,me]),q=gt.useMemo(()=>pe.map(z=>z.label),[pe]),we=gt.useCallback(z=>{b(he=>({...he,schedule:{...he.schedule,onceDate:z}}))},[]),be=gt.useCallback((z,he)=>{if(z.startsWith("/")){const Ue=z.indexOf(" "),ht=z.indexOf(`
|
|
924
|
+
`),ut=Math.min(Ue===-1?z.length:Ue,ht===-1?z.length:ht);if(he<=ut&&Ue===-1){U(z.substring(1,ut)),_(!0),D(!1),F(!1);return}}_(!1);const Be=z.substring(0,he),Ae=Be.lastIndexOf("#");if(Ae!==-1){const Ue=Ae>0?Be[Ae-1]:null,ht=Be.substring(Ae+1);if((!Ue||/\s/.test(Ue))&&!ht.includes(" ")&&!ht.includes(`
|
|
925
|
+
`)){j(ht),F(!0),D(!1);return}}F(!1);const at=Be.lastIndexOf("@");if(at!==-1){const Ue=at>0?Be[at-1]:null,ht=Be.substring(at+1);(!Ue||/\s/.test(Ue))&&!ht.includes(" ")&&!ht.includes(`
|
|
926
|
+
`)?(I(ht),D(!0)):D(!1);return}D(!1)},[]),Ne=gt.useCallback(z=>{b(he=>({...he,execution:{...he.execution,prompt:z}}))},[]),ie=gt.useCallback(z=>{const he=m.execution.prompt,Ae=H.current?.selectionStart??he.length,Ue=he.substring(0,Ae).lastIndexOf("@"),ht=z.relativePath&&z.relativePath.trim().length>0?z.relativePath.trim():z.path||z.name,ut=Ue!==-1?Ue:Ae,Ct=`${he.substring(0,ut)}@${ht} ${he.substring(Ae)}`,ge=ut+ht.length+2;Ne(Ct),D(!1),I(""),requestAnimationFrame(()=>{const Ye=H.current;Ye&&(Ye.selectionStart=ge,Ye.selectionEnd=ge,Ye.focus()),be(Ct,ge)})},[m.execution.prompt,Ne,be]),ee=gt.useCallback(z=>{const he=m.execution.prompt,Ae=H.current?.selectionStart??he.length,Ue=he.substring(0,Ae).lastIndexOf("@"),ht=Ue!==-1?Ue:Ae,ut=`${he.substring(0,ht)}@${z} ${he.substring(Ae)}`,Ct=ht+z.length+2;Ne(ut),D(!1),I(""),requestAnimationFrame(()=>{const ge=H.current;ge&&(ge.selectionStart=Ct,ge.selectionEnd=Ct,ge.focus()),be(ut,Ct)})},[m.execution.prompt,Ne,be]),V=gt.useCallback(z=>{const he=`/${z.name} `;Ne(he),_(!1),U(""),F(!1),requestAnimationFrame(()=>{const Be=H.current;Be&&(Be.focus(),Be.selectionStart=Be.value.length,Be.selectionEnd=Be.value.length),be(he,he.length)})},[Ne,be]),$=gt.useCallback((z,he)=>{const Be=m.execution.prompt,at=H.current?.selectionStart??Be.length,ht=Be.substring(0,at).lastIndexOf("#"),ut=ht!==-1?ht:at,Ct=`${Be.substring(0,ut)}#${he} ${Be.substring(at)}`,ge=ut+he.length+2;Ne(Ct),F(!1),j(""),requestAnimationFrame(()=>{const Ye=H.current;Ye&&(Ye.selectionStart=ge,Ye.selectionEnd=ge,Ye.focus()),be(Ct,ge)})},[m.execution.prompt,Ne,be]),ae=gt.useCallback(z=>{if(M&&ce.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")){z.preventDefault(),ce.current.handleKeyDown(z.key);return}k&&Z.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")&&(z.preventDefault(),Z.current.handleKeyDown(z.key)),L&&Y.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")&&(z.preventDefault(),Y.current.handleKeyDown(z.key))},[M,k,L]),W=gt.useCallback(async()=>{const z=x4(m,o);if(z){Le.error(z);return}const he={...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:b4(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(he),r(!1)}catch(Be){Le.error(Be instanceof Error?Be.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{v(!1)}},[m,r,i,o]),ve=gt.useId(),Fe=gt.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),Ce=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),ke=o("sessions.scheduledTasks.editor.description"),Qe=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(Ms,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(Cn,{id:"sched-name",value:m.name,onChange:z=>b(he=>({...he,name:z.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(Ms,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Fs,{value:m.schedule.kind,onValueChange:z=>{b(he=>({...he,schedule:{...he.schedule,kind:z,...z==="cron"&&!he.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(As,{children:z=>o(z==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":z==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":z==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(ss,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(ss,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(ss,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx(y4,{draft:m,setDraft:b,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:X,children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Ie(Wd({size:"default"}),"w-fit max-w-full"),onClick:()=>C(z=>!z),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(E,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:a4(m.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(E,{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:()=>B(z=>Fc(z,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:ye,children:s.jsx(E,{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(A)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>B(z=>Fc(z,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(E,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:q.map((z,he)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:z},`${z}-${he}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:l4(A,K).map(({date:z,inCurrentMonth:he})=>{const Be=Oc(z),Ae=Be===m.schedule.onceDate,at=Wc(z,Oe),Ue=z.getTime()<Oe.getTime(),ht=Ae?"bg-interactive-selection text-interactive-selection-foreground":Ue?"text-muted-foreground/40":he?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{Ue||(we(Be),C(!1))},disabled:Ue,className:["h-8 rounded-md typography-ui-label",ht,at&&!Ae?"ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50":"",Ue?"cursor-not-allowed opacity-45":""].join(" "),children:z.getDate()},Be)})}),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:Re||""}),s.jsx(xt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{we(Oc(Oe)),B(new Date(Oe.getFullYear(),Oe.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(Ms,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(Lc,{value:m.schedule.onceTime,use24Hour:Se,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:z=>b(he=>({...he,schedule:{...he.schedule,onceTime:z}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Fs,{value:m.schedule.timezone,onValueChange:z=>{b(he=>({...he,schedule:{...he.schedule,timezone:z}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(As,{})}),s.jsx(_s,{children:la.map(z=>s.jsx(ss,{value:z,children:z},z))})]})]})]})]}):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(Ms,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:pe.map(z=>{const he=m.schedule.weekdays.includes(z.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",he?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(ur,{checked:he,onChange:Be=>G(z.value,Be),ariaLabel:z.label}),s.jsx("button",{type:"button",onClick:()=>G(z.value,!he),className:"group-hover:text-foreground",children:z.label})]},z.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((z,he)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Lc,{value:z,use24Hour:Se,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:Be=>le(he,Be)}),m.schedule.times.length>1?s.jsx(xt,{type:"button",size:"icon",variant:"ghost",onClick:()=>de(he),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null]},he))}),s.jsx("div",{children:s.jsxs(xt,{type:"button",size:"sm",variant:"outline",onClick:ue,children:[s.jsx(E,{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(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Fs,{value:m.schedule.timezone,onValueChange:z=>{b(he=>({...he,schedule:{...he.schedule,timezone:z}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(As,{})}),s.jsx(_s,{children:la.map(z=>s.jsx(ss,{value:z,children:z},z))})]})]})]}),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(Ms,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Xh,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(z,he)=>{b(Be=>({...Be,execution:{...Be.execution,providerID:z,modelID:he,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Fs,{value:T,disabled:!ne,onValueChange:z=>{b(he=>({...he,execution:{...he.execution,variant:z==="__default"?"":z}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(As,{children:z=>z==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):z})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),je.map(z=>s.jsx(ss,{value:z,children:z},z))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Jh,{agentName:m.execution.agent,filter:z=>$d(z.mode),onChange:z=>b(he=>({...he,execution:{...he.execution,agent:z}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(lr,{id:"sched-prompt",ref:H,value:m.execution.prompt,onChange:z=>{const he=z.target.value;Ne(he);const Be=z.target.selectionStart??he.length;be(he,Be)},onKeyDown:ae,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),M?s.jsx(qd,{ref:ce,searchQuery:O,onCommandSelect:V,onClose:()=>_(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,k?s.jsx(Qd,{ref:Z,searchQuery:P,onFileSelect:ie,onAgentSelect:ee,onClose:()=>D(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,L?s.jsx(Yd,{ref:Y,searchQuery:R,onSnippetSelect:$,onClose:()=>F(!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(ur,{checked:m.execution.goalTokenBudget!==null,onChange:z=>b(he=>({...he,execution:{...he.execution,goalTokenBudget:z?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(Zh,{value:m.execution.goalTokenBudget,onValueChange:z=>{typeof z=="number"&&Number.isFinite(z)&&z>0&&b(he=>({...he,execution:{...he.execution,goalTokenBudget:Math.floor(z)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),We=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(ur,{checked:m.enabled,onChange:z=>b(he=>({...he,enabled:z})),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(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(Ec),onClick:()=>b(z=>({...z,execution:{...z.execution,permissionAutoAccept:!z.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(E,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(E,{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(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(Ec,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>b(z=>({...z,execution:{...z.execution,goalEnabled:!z.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(E,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(E,{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(xt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(xt,{type:"button",size:"sm",onClick:W,disabled:y,children:o(y?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return x?s.jsx(Go,{open:e,title:Ce,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:z=>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:Ce}),z]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:ke})]}),footer:We,children:Qe}):s.jsx(vs,{open:e,onOpenChange:z=>{!z&&Fe()||r(z)},children:s.jsxs(js,{"aria-describedby":ve,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Es,{id:ve,className:"sr-only",children:ke}),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(Rs,{className:"typography-ui-label font-medium text-foreground",children:Ce}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:ke})]})}),s.jsx(wa,{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:Qe})}),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:We})})]})})}function S4(t){return wr(t,{min:0,max:23})}function v4(t,e){return wr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function j4(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 k4(t){return s.jsx(ss,{value:t,children:t},t)}const C4=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))},N4=(t,e)=>{const n=C4(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:Gn(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:Gn(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:Gn(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:Gn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},A4=(t,e)=>!t||!Number.isFinite(t)?"":ep(t,e),Vc=(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 f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),p=Math.round(r%o/i),g=p>0?`${f}h ${p}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:g}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:g})}const u=Math.floor(r/l),d=Math.round(r%l/o),h=d>0?`${u}d ${d}h`:`${u}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:h}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:h})},D4={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"}},P4=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function I4(){const{t}=Nt(),e=Te(j=>j.isScheduledTasksDialogOpen),n=Te(j=>j.setScheduledTasksDialogOpen),r=Te(j=>j.isMobile),i=Te(j=>j.timeFormatPreference),o=Ht(j=>j.projects),l=Ht(j=>j.getActiveProject()),a=ts(j=>j.homeDirectory),{currentTheme:u}=Zn(),[d,h]=gt.useState(""),[f,p]=gt.useState([]),[g,w]=gt.useState(!0),[S,x]=gt.useState(!1),[m,b]=gt.useState(null),[y,v]=gt.useState(null),N=gt.useMemo(()=>o.find(j=>j.id===d)||null,[o,d]),C=gt.useCallback(j=>{const A=j.label?.trim()||Fn(j.path,a||void 0),B=j.icon?ka[j.icon]:null,X=j.color?Ca[j.color]:void 0,H=B?s.jsx(E,{name:B,className:"h-3.5 w-3.5 shrink-0",style:X?{color:X}:void 0}):s.jsx(E,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:X?{color:X}: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(Na,{project:{id:j.id,iconImage:j.iconImage??null},options:{themeVariant:u.metadata.variant,iconColor:u.colors.surface.foreground},className:"h-full w-full object-contain",fallback:H})}):H,s.jsx("span",{className:"truncate",children:A})]})},[a,u.metadata.variant,u.colors.surface.foreground]),k=gt.useCallback(async(j,A)=>{if(!j){p([]);return}A?.silent||w(!0);try{const B=await _g(j);B.sort((X,H)=>{if(X.enabled!==H.enabled)return X.enabled?-1:1;const Z=X.name.localeCompare(H.name);return Z!==0?Z:(X.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(H.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),p(B)}catch(B){Le.error(B instanceof Error?B.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),A?.silent||p([])}finally{A?.silent||w(!1)}},[t]);gt.useEffect(()=>{if(!e)return;const j=l?.id||o[0]?.id||"";h(j),j?k(j):(p([]),w(!1))},[e,l,o,k]),gt.useEffect(()=>{if(!e)return;let j=null;const A=Yr(B=>{B.type==="scheduled-task-ran"&&B.projectId===d&&(j&&clearTimeout(j),j=setTimeout(()=>{k(d,{silent:!0})},400))});return()=>{j&&clearTimeout(j),A()}},[e,d,k]);const D=gt.useCallback(async j=>{if(!d)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Nl(d,j),await k(d),Le.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[d,k,t]),P=gt.useCallback(async(j,A)=>{if(d){v(j.id),p(B=>B.map(X=>X.id===j.id?{...X,enabled:A}:X));try{j.loopFile?await Lg(d,j.id,A):await Nl(d,{...j,enabled:A}),await k(d,{silent:!0})}catch(B){Le.error(B instanceof Error?B.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await k(d,{silent:!0})}finally{v(null)}}},[d,k,t]),I=gt.useCallback(async j=>{if(!(!d||!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 $g(d,j.id):await Wg(d,j.id),await k(d,{silent:!0}),Le.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(B){Le.error(B instanceof Error?B.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{v(null)}}},[d,k,t]),M=gt.useCallback(j=>{if(!j.loopFile){b(j),x(!0);return}N?.path&&(n(!1),hn.getState().setSelectedPath(N.path,j.loopFile,{allowOutsideRoot:!0}),Te.getState().openContextFile(N.path,j.loopFile))},[N?.path,n]),_=gt.useCallback(async j=>{if(d){v(j.id);try{const{sessionId:A,persistError:B}=await zg(d,j.id);if(await Promise.all([k(d,{silent:!0}),Ta()]),B?Le.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Le.success(t("sessions.scheduledTasks.dialog.toast.started")),A){const X=o.find(H=>H.id===d);Je.getState().setCurrentSession(A,X?.path??null)}}catch(A){Le.error(A instanceof Error?A.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{v(null)}}},[d,o,k,t]),O=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(Fs,{value:d||"__none",onValueChange:j=>{const A=j==="__none"?"":j;h(A),A?k(A):p([])},children:[s.jsx(Bs,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(As,{children:C(N)}):s.jsx(As,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(_s,{children:[o.length===0?s.jsx(ss,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(j=>s.jsx(ss,{value:j.id,children:C(j)},j.id))]})]})]}),U=()=>{b(null),x(!0)},L=j=>{h(j),j?k(j):p([])},F=s.jsx("div",{className:"min-h-[280px]",children:g?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(d?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(j=>{const A=y===j.id,B=j.state?.lastStatus||"idle",X=D4[B],H=t(B==="success"?"sessions.scheduledTasks.dialog.status.success":B==="error"?"sessions.scheduledTasks.dialog.status.error":B==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),Z=j.state?.nextRunAt,ce=j.state?.lastRunAt;return s.jsxs("div",{className:Ie("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Ie("min-w-0",!j.enabled&&"opacity-60"),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:N4(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:Ie("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!j.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),Z?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:Vc(Z,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:A4(Z,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(E,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),B==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):ce?s.jsxs(s.Fragment,{children:[X.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${X.tone})`},children:[s.jsx(E,{name:X.Icon,className:"h-3.5 w-3.5"}),H]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:Vc(ce,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),j.state?.lastError?s.jsxs("div",{className:Ie("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!j.enabled&&"opacity-60"),style:P4("error"),children:[s.jsx(E,{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:Ie("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",j.enabled?"text-foreground":"text-muted-foreground",A&&"cursor-not-allowed opacity-50"),children:[s.jsx(ur,{checked:j.enabled,onChange:Y=>{P(j,Y)},ariaLabel:j.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:j.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:j.name}),disabled:A}),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(xt,{variant:"outline",size:"sm",onClick:()=>{_(j)},disabled:A,children:[s.jsx(E,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(xt,{variant:"outline",size:"sm",onClick:()=>M(j),disabled:A,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:j.name}),children:[s.jsx(E,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(xt,{variant:"destructive",size:"sm",onClick:()=>{I(j)},disabled:A,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:j.name}),children:s.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},j.id)})})}),R=s.jsxs("div",{className:"space-y-4",children:[O,F]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Go,{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(xt,{className:"w-full",onClick:U,disabled:!d,children:[s.jsx(E,{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:()=>L(j.id),className:Ie("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",d===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(xt,{size:"sm",onClick:U,disabled:!d,children:[s.jsx(E,{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:F})})]})]})}):null,s.jsx(w4,{open:S,task:m,onOpenChange:x,onSave:D})]})}const ko=100;function T4(){const t=st.c(106),{t:e}=Nt(),n=Te($4),r=Te(L4),i=Je(_4),o=Je(B4),l=ts(F4);let a;t[0]!==n?(a=Z=>n?Z.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const u=Is(Jn(a)),[d,h]=c.useState(""),[f,p]=c.useState(null),[g,w]=c.useState(ko);let S;t[2]!==d?(S=d.trim().toLowerCase(),t[2]=d,t[3]=S):S=t[3];const x=S;let m;e:{if(!n){let ce;t[4]===Symbol.for("react.memo_cache_sentinel")?(ce=[],t[4]=ce):ce=t[4],m=ce;break e}let Z;t[5]!==u?(Z=[...u].sort(O4),t[5]=u,t[6]=Z):Z=t[6],m=Z}const b=m;let y;if(t[7]!==l||t[8]!==b||t[9]!==e){const Z=new Map;for(const ce of b){const Y=vt(Ts(ce))??"",se=Z.get(Y);if(se){se.sessions.push(ce);continue}Z.set(Y,{directory:Y,label:Y?Fn(Y,l)||Y:e("sessions.archivePage.otherProjects"),sessions:[ce]})}y=[...Z.values()].sort(M4),t[7]=l,t[8]=b,t[9]=e,t[10]=y}else y=t[10];const v=y;let N;e:{if(x){if(x.startsWith("ses_")){let Y;if(t[11]!==x||t[12]!==b){let se;t[14]!==x?(se=oe=>oe.id.toLowerCase()===x,t[14]=x,t[15]=se):se=t[15],Y=b.filter(se),t[11]=x,t[12]=b,t[13]=Y}else Y=t[13];N=Y;break e}let ce;t[16]!==x||t[17]!==b?(ce=tp(b,x,E4),t[16]=x,t[17]=b,t[18]=ce):ce=t[18],N=ce;break e}if(f===null){N=b;break e}let Z;t[19]!==v||t[20]!==f?(Z=v.find(ce=>ce.directory===f)?.sessions??[],t[19]=v,t[20]=f,t[21]=Z):Z=t[21],N=Z}const C=N;let k,D,P,I,M,_,O,U,L,F;if(t[22]!==u.length||t[23]!==v||t[24]!==C||t[25]!==l||t[26]!==x||t[27]!==n||t[28]!==d||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==g){M=Symbol.for("react.early_return_sentinel");e:{const Z=C.slice(0,g);k=C.length-Z.length;const ce=u.length;let Y;t[45]===Symbol.for("react.memo_cache_sentinel")?(Y=ye=>{p(ye),w(ko)},t[45]=Y):Y=t[45];const se=Y;let oe;t[46]!==i||t[47]!==r?(oe=ye=>{const q=vt(Ts(ye));i(ye.id,q??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=oe):oe=t[48];const Se=oe;let K;t[49]!==e||t[50]!==o?(K=ye=>{o(ye.id).then(q=>{q?Le.success(e("sessions.sidebar.session.restore.success")):Le.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=K):K=t[51];const pe=K;if(!n){M=null;break e}let je;t[52]!==e?(je=(ye,q,we,be,Ne,ie,ee)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:Ne,title:ie,className:Ie("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",ee?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",be?"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:q}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:we})]}),ee?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>xn.requestDelete({sessions:ee,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:q}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(Pt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},ye),t[52]=e,t[53]=je):je=t[53];const ne=je;I="absolute inset-0 z-10 flex flex-col bg-background",D="flex min-h-0 flex-1";let T;if(t[54]!==ne||t[55]!==f||t[56]!==e||t[57]!==ce){let ye;t[59]===Symbol.for("react.memo_cache_sentinel")?(ye=()=>se(null),t[59]=ye):ye=t[59],T=ne("__all__",e("sessions.archivePage.allDirectories"),ce,f===null,ye),t[54]=ne,t[55]=f,t[56]=e,t[57]=ce,t[58]=T}else T=t[58];let G;if(t[60]!==v||t[61]!==ne||t[62]!==f){let ye;t[64]!==ne||t[65]!==f?(ye=q=>ne(q.directory||"__none__",q.label,q.sessions.length,f===q.directory,()=>se(q.directory),q.directory||void 0,q.sessions),t[64]=ne,t[65]=f,t[66]=ye):ye=t[66],G=v.map(ye),t[60]=v,t[61]=ne,t[62]=f,t[63]=G}else G=t[63];t[67]!==T||t[68]!==G?(P=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:[T,G]})}),t[67]=T,t[68]=G,t[69]=P):P=t[69],L="flex min-w-0 flex-1 flex-col";let le;t[70]===Symbol.for("react.memo_cache_sentinel")?(le=s.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t[70]=le):le=t[70];let de;t[71]===Symbol.for("react.memo_cache_sentinel")?(de=ye=>{h(ye.target.value),w(ko)},t[71]=de):de=t[71];let ue;t[72]!==e?(ue=e("sessions.archivePage.searchPlaceholder"),t[72]=e,t[73]=ue):ue=t[73];let Oe;t[74]!==d||t[75]!==ue?(Oe=s.jsxs("div",{className:"relative min-w-0 flex-1",children:[le,s.jsx("input",{value:d,onChange:de,placeholder:ue,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[74]=d,t[75]=ue,t[76]=Oe):Oe=t[76];let me;t[77]!==C.length||t[78]!==e?(me=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[77]=C.length,t[78]=e,t[79]=me):me=t[79];let Re;t[80]!==me?(Re=s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:me}),t[80]=me,t[81]=Re):Re=t[81],t[82]!==Oe||t[83]!==Re?(F=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Oe,Re]}),t[82]=Oe,t[83]=Re,t[84]=F):F=t[84],U="min-h-0 flex-1 overflow-y-auto px-6 py-3",_="mx-auto w-full max-w-3xl space-y-0.5",O=Z.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(x?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):Z.map(ye=>{const q=vt(Ts(ye))??"",we=q?Fn(q,l)||q: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:()=>Se(ye),role:"button",tabIndex:0,onKeyDown:be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),Se(ye))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:ye.title||e("sessions.sidebar.session.untitled")}),x&&we?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:q,children:we}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Kd(ye.time?.archived??ye.time?.updated??ye.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:be=>{be.stopPropagation(),pe(ye)},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:ye.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(E,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:be=>{be.stopPropagation(),xn.requestDelete({sessions:[ye],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:ye.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},ye.id)})}t[22]=u.length,t[23]=v,t[24]=C,t[25]=l,t[26]=x,t[27]=n,t[28]=d,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=g,t[35]=k,t[36]=D,t[37]=P,t[38]=I,t[39]=M,t[40]=_,t[41]=O,t[42]=U,t[43]=L,t[44]=F}else k=t[35],D=t[36],P=t[37],I=t[38],M=t[39],_=t[40],O=t[41],U=t[42],L=t[43],F=t[44];if(M!==Symbol.for("react.early_return_sentinel"))return M;let R;t[85]!==k||t[86]!==e?(R=k>0?s.jsx("button",{type:"button",onClick:()=>w(R4),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[85]=k,t[86]=e,t[87]=R):R=t[87];let j;t[88]!==R||t[89]!==_||t[90]!==O?(j=s.jsxs("div",{className:_,children:[O,R]}),t[88]=R,t[89]=_,t[90]=O,t[91]=j):j=t[91];let A;t[92]!==j||t[93]!==U?(A=s.jsx("div",{className:U,children:j}),t[92]=j,t[93]=U,t[94]=A):A=t[94];let B;t[95]!==A||t[96]!==L||t[97]!==F?(B=s.jsxs("div",{className:L,children:[F,A]}),t[95]=A,t[96]=L,t[97]=F,t[98]=B):B=t[98];let X;t[99]!==D||t[100]!==P||t[101]!==B?(X=s.jsxs("div",{className:D,children:[P,B]}),t[99]=D,t[100]=P,t[101]=B,t[102]=X):X=t[102];let H;return t[103]!==I||t[104]!==X?(H=s.jsx("div",{className:I,children:X}),t[103]=I,t[104]=X,t[105]=H):H=t[105],H}function R4(t){return t+ko}function E4(t){return[t.title]}function M4(t,e){return e.sessions.length-t.sessions.length}function O4(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function F4(t){return t.homeDirectory}function B4(t){return t.unarchiveSession}function _4(t){return t.setCurrentSession}function L4(t){return t.setArchivePageOpen}function $4(t){return t.isArchivePageOpen}function W4(){const t=st.c(18),{t:e}=Nt(),n=Te(U4),r=Te(V4),i=Ht(z4);let o;t[0]!==n?(o=g=>g.projects.find(w=>w.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Ht(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 u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(E,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=u):u=t[6];let d;t[7]!==e?(d=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=d):d=t[8];let h;t[9]!==a||t[10]!==d?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(xt,{size:"sm",onClick:a,children:[u,d]})}),t[9]=a,t[10]=d,t[11]=h):h=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(jg,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let p;return t[15]!==h||t[16]!==f?(p=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[h,f]})})}),t[15]=h,t[16]=f,t[17]=p):p=t[17],p}function z4(t){return t.setActiveProjectIdOnly}function V4(t){return t.setNewWorktreeDialogOpen}function U4(t){return t.worktreesPageProjectId}const ca=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),K4=(t,e)=>{const n=ca(t),r=ca(e);return`${n}-${r}`.substring(0,60)},Uc=(t,e)=>`${t}/${e}`,H4=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},Kc=(t,e)=>{const n=H4(e),r=t.directory,i=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};cp(t.id,n),Je.getState().markSessionAsAiWorkerCreated(t.id),Is.getState().upsertSession(i);try{Do().ensureChild(n,{bootstrap:!1}).setState(l=>{const a=l.session.findIndex(d=>d.id===t.id);if(a>=0&&l.session[a]===i)return l;const u=a>=0?l.session.map((d,h)=>h===a?i:d):[...l.session,i].sort((d,h)=>d.id.localeCompare(h.id));return{session:u,sessionTotal:Math.max(l.sessionTotal,u.length),limit:Math.max(l.limit,u.length)}})}catch{}return i},G4=()=>{const t=Ht.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=ts.getState().currentDirectory??null;if(r&&r.trim().length>0){const i=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${i}`,path:i}}return null},xi=tr()(pu(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}t({isLoading:!0,error:null});try{const a=G4();if(!a)return t({error:"Select a project",isLoading:!1}),null;const u=a.path,h=await Ko(u)&&e.isolateRuns!==!1,f=ca(n),p=h?await qo(u):void 0,g=h?await sp(u):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 P of N.models){const I=`${P.providerID}:${P.modelID}`;k.set(I,(k.get(I)||0)+1)}const D=new Map;for(const P of N.models){const I=`${P.providerID}:${P.modelID}`,M=k.get(I)||1,_=(D.get(I)||0)+1;D.set(I,_);const O=K4(P.providerID,P.modelID),U=r.length>1?`g${v+1}`:void 0,L=M>1?Uc(f,`${O}/${_}`):Uc(f,O),F=U?`${U}/${L}`:L,R=Bj({groupSlug:f,runGroup:U,providerID:P.providerID,modelID:P.modelID,index:M>1?_:void 0});try{if(!h){const X=await Qs.withDirectory(u,()=>Qs.createSession({title:R}));Kc(X,u),w.push({sessionId:X.id,worktreePath:u,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:C});continue}const j=await np(a,{preferredName:F,mode:"new",branchName:F,worktreeName:F,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:S,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:g}),A={...j,createdFromBranch:p,kind:"standard"};await rp(a)&&await op(j.path);const B=await Qs.withDirectory(j.path,()=>Qs.createSession({title:R}));Kc(B,j.path),Je.getState().setWorktreeMetadata(B.id,A),w.push({sessionId:B.id,worktreePath:j.path,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:C})}catch(j){console.warn("[MultiRun] Failed to create session:",j)}}}const x=l?.filter(v=>v.trim().length>0)??[];x.length>0&&ip(a,x).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const m=w.map(v=>v.sessionId),b=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=ap.getState().expandText;await Promise.allSettled(w.map(async N=>{try{const C=await v(N.prompt).catch(()=>N.prompt);await lp({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:f,sessionIds:m,firstSessionId:b}}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 Sf(t){const e=st.c(30),{git:n}=Sn(),r=Dd(t),i=Pd(t),o=dp(t),l=up(t),a=Dn(J4),u=Dn(X4);let d,h;e[0]!==t||e[1]!==u||e[2]!==n||e[3]!==i||e[4]!==o?(d=()=>{!t||!n||i!==null||o||u(t,n,{silent:!0})},h=[t,n,u,i,o],e[0]=t,e[1]=u,e[2]=n,e[3]=i,e[4]=o,e[5]=d,e[6]=h):(d=e[5],h=e[6]),c.useEffect(d,h);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(f=()=>{!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]=f):f=e[12];const p=r?.all;let g;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==p?(g=[t,n,i,p,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=p,e[18]=g):g=e[18],c.useEffect(f,g);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(Y4).sort(),e[20]=r.all,e[21]=C):C=e[21],S=C}const x=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(Q4).map(q4).sort(),e[23]=r.all,e[24]=C):C=e[24],m=C}const b=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]!==x||e[28]!==b?(N={localBranches:x,remoteBranches:b,isLoading:w,isGitRepository:v},e[25]=v,e[26]=w,e[27]=x,e[28]=b,e[29]=N):N=e[29],N}function q4(t){return t.replace(/^remotes\//,"")}function Q4(t){return t.startsWith("remotes/")}function Y4(t){return!t.startsWith("remotes/")}function X4(t){return t.fetchStatus}function J4(t){return t.fetchBranches}const Z4=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=Nt(),{localBranches:a,remoteBranches:u,isLoading:d,isGitRepository:h}=Sf(t),f=c.useMemo(()=>[...a,...u.map(g=>`remotes/${g}`)],[a,u]);c.useEffect(()=>{if(i||d||f.length===0||e&&f.includes(e))return;const g=e;let w=!1;return(async()=>{try{const x=t?await qo(t).catch(()=>null):null;if(w)return;const m=localStorage.getItem(kl),{sourceBranch:b,shouldClearSavedSourceBranch:y}=kg({branches:f,savedSourceBranch:m,rootBranch:x});if(y&&localStorage.removeItem(kl),w||g&&f.includes(g))return;b&&n(b)}catch{}})(),()=>{w=!0}},[f,t,i,d,n,e]);const p=i||!h||d;return s.jsxs("div",{children:[s.jsxs(Fs,{value:e,onValueChange:n,disabled:p,children:[s.jsx(Bs,{id:o,size:"lg",className:Ie("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(As,{placeholder:l(d?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(_s,{className:"max-h-[280px] max-w-[320px]",children:d?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&u.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(Ii,{children:[s.jsx(ml,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(g=>s.jsx(ss,{value:g,className:"whitespace-normal break-all",children:g},g))]}),a.length>0&&u.length>0&&s.jsx(fp,{}),u.length>0&&s.jsxs(Ii,{children:[s.jsx(ml,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),u.map(g=>s.jsx(ss,{value:`remotes/${g}`,className:"whitespace-normal break-all",children:g},`remotes/${g}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},e3=10*1024*1024,Co=t=>{const e=st.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Dt,{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(E,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(At,{children:[r,s.jsx(Pt,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Kn=t=>{const e=st.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 u=o&&o;let d;return e[6]!==a||e[7]!==u?(d=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,u]}),e[6]=a,e[7]=u,e[8]=d):d=e[8],d},t3=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=Nt(),[o,l]=c.useState(""),[a,u]=c.useState(()=>[{id:Lr(),prompt:"",models:[]}]),[d,h]=c.useState(""),[f,p]=c.useState([]),[g,w]=c.useState(!1),[S,x]=c.useState([]),[m,b]=c.useState(!1),[y,v]=c.useState(!1),[N,C]=c.useState(!0),k=c.useRef(null),D=ts(V=>V.currentDirectory??null),P=ts(V=>V.homeDirectory??null),I=c.useMemo(()=>{if(typeof window>"u")return null;const V=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof V=="string"&&V.trim().length>0?V.trim():null},[]),M=Ht(V=>V.activeProjectId),_=Ht(V=>V.setActiveProjectIdOnly),O=Ht(V=>V.projects),[U,L]=c.useState(()=>M??null);c.useEffect(()=>{if(M){L(M);return}!U&&O.length>0&&L(O[0].id)},[M,O,U]);const F=c.useMemo(()=>U?O.find(V=>V.id===U)??null:null,[O,U]),R=F?.path??D,j=c.useCallback(V=>{L(V),V!==M&&_(V)},[M,_]),{currentTheme:A}=Zn(),B=c.useCallback(V=>{const $=V.label?.trim()||Fn(V.path,P),ae=V.icon?ka[V.icon]:null,W=V.color?Ca[V.color]:void 0,ve=ae?s.jsx(E,{name:ae,className:"h-3.5 w-3.5 shrink-0",style:W?{color:W}:void 0}):s.jsx(E,{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:[V.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:V.iconBackground?{backgroundColor:V.iconBackground}:void 0,children:s.jsx(Na,{project:{id:V.id,iconImage:V.iconImage??null},options:{themeVariant:A.metadata.variant,iconColor:A.colors.surface.foreground},className:"h-full w-full object-contain",fallback:ve})}):ve,s.jsx("span",{className:"truncate",children:$})]})},[P,A.metadata.variant,A.colors.surface.foreground]),X=c.useMemo(()=>{if(F?.path)return{id:F.id,path:F.path};const V=D??I;return V?{id:`path:${V}`,path:V}:null},[F,D,I]),[H]=c.useState(()=>typeof window<"u"?bn():!1),Z=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),ce=vd(),Y=c.useMemo(()=>{if(typeof window>"u")return null;const V=window.__AIWORKER_MACOS_MAJOR__;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(typeof navigator>"u")return null;const $=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!$)return null;const ae=Number.parseInt($[1],10),W=Number.parseInt($[2],10);return Number.isNaN(ae)?null:ae===10?W:ae},[]),se=c.useMemo(()=>H&&Z||ce?"pl-[88px]":"pl-3",[H,Z,ce]),oe=c.useMemo(()=>!H||!Z||Y===null?"":Y>=26?"h-12":Y<=15?"h-14":"",[H,Z,Y]),Se=c.useCallback(async V=>{V.target.closest("button, a, input, select, textarea")||V.button===0&&H&&await mp()},[H]);c.useEffect(()=>{if(!n)return;const V=$=>{$.key==="Escape"&&($.preventDefault(),$.stopPropagation(),n())};return window.addEventListener("keydown",V,!0),()=>window.removeEventListener("keydown",V,!0)},[n]);const[K,pe]=c.useState(""),{isLoading:je,isGitRepository:ne}=Sf(R),T=c.useRef(!1),G=ne===!0,le=G&&N;c.useEffect(()=>{if(ne===!1){T.current=!0,C(!1);return}ne===!0&&T.current&&(T.current=!1,C(!0))},[ne]);const de=xi(V=>V.createMultiRun),ue=xi(V=>V.error),Oe=xi(V=>V.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&u(V=>{const $=[...V];return $.length>0&&!$[0].prompt.trim()&&($[0]={...$[0],prompt:t}),$})},[t]),c.useEffect(()=>{if(!X)return;let V=!1;return v(!0),(async()=>{try{const $=await hp(X);V||x($)}catch{}finally{V||v(!1)}})(),()=>{V=!0}},[X]);const me=c.useCallback((V,$)=>{u(ae=>ae.map(W=>W.id===V?{...W,...$}:W))},[]),Re=c.useCallback(V=>{u($=>$.filter(ae=>ae.id!==V))},[]),ye=c.useCallback(()=>{u(V=>[...V,{id:Lr(),prompt:"",models:[]}])},[]),q=async V=>{const $=V.target.files;if(!$)return;let ae=0;for(let W=0;W<$.length;W++){const ve=$[W];if(ve.size>e3){Le.error(i("multirun.launcher.toast.fileTooLarge",{fileName:ve.name}));continue}try{const Fe=await new Promise((Ce,ke)=>{const Qe=new FileReader;Qe.onload=()=>Ce(Qe.result),Qe.onerror=ke,Qe.readAsDataURL(ve)});p(Ce=>[...Ce,{id:Lr(),filename:ve.name,mimeType:ve.type||"application/octet-stream",size:ve.size,dataUrl:Fe}]),ae++}catch(Fe){console.error("File attach failed",Fe),Le.error(i("multirun.launcher.toast.attachFailed",{fileName:ve.name}))}}ae>0&&Le.success(ae===1?i("multirun.launcher.toast.attachedSingle",{count:ae}):i("multirun.launcher.toast.attachedPlural",{count:ae})),k.current&&(k.current.value="")},we=V=>{p($=>$.filter(ae=>ae.id!==V))},be=c.useMemo(()=>a.reduce((V,$)=>V+$.models.length,0),[a]),Ne=async V=>{V.preventDefault();const $=a.filter(ae=>ae.prompt.trim()&&ae.models.length>=1);if($.length!==0&&!(be<1)){w(!0),Oe();try{U&&U!==M&&_(U);const ae=f.map(ke=>({mime:ke.mimeType,filename:ke.filename,url:ke.dataUrl})),W=S.filter(ke=>ke.trim().length>0),ve=$.map(ke=>({prompt:ke.prompt.trim(),models:ke.models.map(Qe=>({providerID:Qe.providerID,modelID:Qe.modelID,displayName:Qe.displayName,variant:Qe.variant}))})),Fe={name:o.trim(),groups:ve,agent:d||void 0,worktreeBaseBranch:le?K:void 0,isolateRuns:le,files:ae.length>0?ae:void 0,setupCommands:W.length>0?W:void 0},Ce=await de(Fe);Ce&&(Ce.firstSessionId&&Je.getState().setCurrentSession(Ce.firstSessionId),e?.())}finally{w(!1)}}},ie=!!(o.trim()&&a.some(V=>V.prompt.trim()&&V.models.length>=1)&&be>=1&&R&&!je&&(ne===!1||!le||K)),ee=S.filter(V=>V.trim()).length;return s.jsxs("form",{onSubmit:Ne,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:Se,className:Ie("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",se,oe),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(At,{children:[s.jsx(Dt,{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(E,{name:"close",className:"h-5 w-5"})})}),s.jsx(Pt,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(wa,{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(Kn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),O.length>0?s.jsxs(Fs,{value:U??void 0,onValueChange:j,children:[s.jsx(Bs,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:F?s.jsx(As,{children:B(F)}):s.jsx(As,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(_s,{fitContent:!0,children:O.map(V=>s.jsx(ss,{value:V.id,className:"max-w-[24rem]",children:B(V)},V.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(Kn,{htmlFor:"group-name",required:!0,info:s.jsx(Co,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(Cn,{id:"group-name",value:o,onChange:V=>l(V.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(Kn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Co,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(Z4,{directory:R,value:K,onChange:pe,disabled:!le,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(ur,{checked:N,onChange:C,disabled:!G,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(Kn,{htmlFor:"multirun-agent",info:s.jsx(Co,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(mf,{value:d,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(ki,{open:m,onOpenChange:b,children:[s.jsxs(Ad,{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(E,{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")}),ee>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:ee}),s.jsx(E,{name:"arrow-down-s",className:Ie("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(Ci,{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((V,$)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(Cn,{value:V,onChange:ae=>{const W=[...S];W[$]=ae.target.value,x(W)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>x(S.filter((ae,W)=>W!==$)),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(E,{name:"close",className:"h-3.5 w-3.5"})})]},`${V}-${$}`)),s.jsxs("button",{type:"button",onClick:()=>x([...S,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(E,{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(Kn,{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:q,accept:"*/*"}),s.jsxs(At,{children:[s.jsx(Dt,{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(E,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(Pt,{children:i("multirun.launcher.attachments.tooltip")})]}),f.map(V=>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:[V.mimeType.startsWith("image/")?s.jsx(E,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(E,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:V.filename,children:V.filename}),s.jsx("button",{type:"button",onClick:()=>we(V.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(E,{name:"close",className:"h-3 w-3"})})]},V.id))]})]}),a.map((V,$)=>s.jsx(s3,{group:V,groupIndex:$,canRemove:a.length>1,onUpdate:me,onRemove:Re},V.id)),s.jsxs("button",{type:"button",onClick:ye,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(E,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),ue&&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:ue})]})})}),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:[!le&&ne!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(E,{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(xt,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(xt,{type:"submit",size:"sm",disabled:!ie||g,children:g?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:be})})})]})})]})},s3=t=>{const e=st.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=Nt(),[u,d]=c.useState(!1),[h,f]=c.useState(""),[p,g]=c.useState(!1),[w,S]=c.useState(""),[x,m]=c.useState(!1),[b,y]=c.useState(""),v=c.useRef(null),N=c.useRef(null),C=c.useRef(null),k=c.useRef(null);let D;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(D=W=>{o(n.id,{models:[...n.models,W]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=D):D=e[3];const P=D;let I;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(I=W=>{o(n.id,{models:n.models.filter((ve,Fe)=>Fe!==W)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=I):I=e[7];const M=I;let _;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(_=(W,ve)=>{o(n.id,{models:n.models.map((Fe,Ce)=>Ce===W?ve:Fe)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=_):_=e[11];const O=_;let U;e[12]===Symbol.for("react.memo_cache_sentinel")?(U=(W,ve)=>{if(W.startsWith("/")){const Qe=W.indexOf(" "),We=W.indexOf(`
|
|
927
|
+
`),z=Math.min(Qe===-1?W.length:Qe,We===-1?W.length:We);if(ve<=z&&Qe===-1){S(W.substring(1,z)),g(!0),d(!1),m(!1);return}}g(!1);const Fe=W.substring(0,ve),Ce=Fe.lastIndexOf("#");if(Ce!==-1){const Qe=Ce>0?Fe[Ce-1]:null,We=Fe.substring(Ce+1);if((!Qe||/\s/.test(Qe))&&!We.includes(" ")&&!We.includes(`
|
|
928
|
+
`)){y(We),m(!0),d(!1);return}}m(!1);const ke=Fe.lastIndexOf("@");if(ke!==-1){const Qe=ke>0?Fe[ke-1]:null,We=Fe.substring(ke+1);(!Qe||/\s/.test(Qe))&&!We.includes(" ")&&!We.includes(`
|
|
929
|
+
`)?(f(We),d(!0)):d(!1);return}d(!1)},e[12]=U):U=e[12];const L=U;let F;e[13]!==n.id||e[14]!==o?(F=W=>{o(n.id,{prompt:W})},e[13]=n.id,e[14]=o,e[15]=F):F=e[15];const R=F;let j;e[16]!==n.prompt||e[17]!==R?(j=W=>{const ve=n.prompt,Ce=v.current?.selectionStart??ve.length,Qe=ve.substring(0,Ce).lastIndexOf("@"),We=W.relativePath&&W.relativePath.trim().length>0?W.relativePath.trim():W.path||W.name,z=Qe!==-1?Qe:Ce,he=`${ve.substring(0,z)}@${We} ${ve.substring(Ce)}`,Be=z+We.length+2;R(he),d(!1),f(""),requestAnimationFrame(()=>{const Ae=v.current;Ae&&(Ae.selectionStart=Be,Ae.selectionEnd=Be,Ae.focus()),L(he,Be)})},e[16]=n.prompt,e[17]=R,e[18]=j):j=e[18];const A=j;let B;e[19]!==n.prompt||e[20]!==R?(B=W=>{const ve=n.prompt,Ce=v.current?.selectionStart??ve.length,Qe=ve.substring(0,Ce).lastIndexOf("@"),We=Qe!==-1?Qe:Ce,z=`${ve.substring(0,We)}@${W} ${ve.substring(Ce)}`,he=We+W.length+2;R(z),d(!1),f(""),requestAnimationFrame(()=>{const Be=v.current;Be&&(Be.selectionStart=he,Be.selectionEnd=he,Be.focus()),L(z,he)})},e[19]=n.prompt,e[20]=R,e[21]=B):B=e[21];const X=B;let H;e[22]!==R?(H=W=>{const ve=`/${W.name} `;R(ve),g(!1),S(""),m(!1),requestAnimationFrame(()=>{const Fe=v.current;Fe&&(Fe.focus(),Fe.selectionStart=Fe.value.length,Fe.selectionEnd=Fe.value.length),L(ve,ve.length)})},e[22]=R,e[23]=H):H=e[23];const Z=H;let ce;e[24]!==n.prompt||e[25]!==R?(ce=(W,ve)=>{const Fe=n.prompt,ke=v.current?.selectionStart??Fe.length,We=Fe.substring(0,ke).lastIndexOf("#"),z=We!==-1?We:ke,he=`${Fe.substring(0,z)}#${ve} ${Fe.substring(ke)}`,Be=z+ve.length+2;R(he),m(!1),y(""),requestAnimationFrame(()=>{const Ae=v.current;Ae&&(Ae.selectionStart=Be,Ae.selectionEnd=Be,Ae.focus()),L(he,Be)})},e[24]=n.prompt,e[25]=R,e[26]=ce):ce=e[26];const Y=ce;let se;e[27]!==p||e[28]!==u||e[29]!==x?(se=W=>{if(p&&C.current&&(W.key==="Enter"||W.key==="ArrowUp"||W.key==="ArrowDown"||W.key==="Escape"||W.key==="Tab")){W.preventDefault(),C.current.handleKeyDown(W.key);return}u&&N.current&&(W.key==="Enter"||W.key==="ArrowUp"||W.key==="ArrowDown"||W.key==="Escape"||W.key==="Tab")&&(W.preventDefault(),N.current.handleKeyDown(W.key)),x&&k.current&&(W.key==="Enter"||W.key==="ArrowUp"||W.key==="ArrowDown"||W.key==="Escape"||W.key==="Tab")&&(W.preventDefault(),k.current.handleKeyDown(W.key))},e[27]=p,e[28]=u,e[29]=x,e[30]=se):se=e[30];const oe=se,Se=r+1;let K;e[31]!==a||e[32]!==Se?(K=a("multirun.launcher.groups.groupLabel",{index:Se}),e[31]=a,e[32]=Se,e[33]=K):K=e[33];let pe;e[34]!==K?(pe=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:K}),e[34]=K,e[35]=pe):pe=e[35];let je;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(je=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(E,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=je):je=e[40];let ne;e[41]!==pe||e[42]!==je?(ne=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[pe,je]}),e[41]=pe,e[42]=je,e[43]=ne):ne=e[43];let T;e[44]!==a?(T=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=T):T=e[45];let G;e[46]!==T?(G=s.jsx(Kn,{required:!0,children:T}),e[46]=T,e[47]=G):G=e[47];const le=n.prompt;let de;e[48]!==R?(de=W=>{const ve=W.target.value;R(ve);const Fe=W.target.selectionStart??ve.length;L(ve,Fe)},e[48]=R,e[49]=de):de=e[49];let ue;e[50]!==a?(ue=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=ue):ue=e[51];let Oe;e[52]!==n.prompt||e[53]!==oe||e[54]!==de||e[55]!==ue?(Oe=s.jsx(lr,{ref:v,value:le,onChange:de,onKeyDown:oe,placeholder:ue,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]=oe,e[54]=de,e[55]=ue,e[56]=Oe):Oe=e[56];let me;e[57]!==w||e[58]!==Z||e[59]!==p?(me=p?s.jsx(qd,{ref:C,searchQuery:w,onCommandSelect:Z,onClose:()=>g(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=w,e[58]=Z,e[59]=p,e[60]=me):me=e[60];let Re;e[61]!==X||e[62]!==A||e[63]!==h||e[64]!==u?(Re=u?s.jsx(Qd,{ref:N,searchQuery:h,onFileSelect:A,onAgentSelect:X,onClose:()=>d(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=X,e[62]=A,e[63]=h,e[64]=u,e[65]=Re):Re=e[65];let ye;e[66]!==Y||e[67]!==x||e[68]!==b?(ye=x?s.jsx(Yd,{ref:k,searchQuery:b,onSnippetSelect:Y,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=Y,e[67]=x,e[68]=b,e[69]=ye):ye=e[69];let q;e[70]!==Oe||e[71]!==me||e[72]!==Re||e[73]!==ye?(q=s.jsxs("div",{className:"relative",children:[Oe,me,Re,ye]}),e[70]=Oe,e[71]=me,e[72]=Re,e[73]=ye,e[74]=q):q=e[74];let we;e[75]!==G||e[76]!==q?(we=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[G,q]}),e[75]=G,e[76]=q,e[77]=we):we=e[77];let be;e[78]!==a?(be=a("multirun.launcher.models.info"),e[78]=a,e[79]=be):be=e[79];let Ne;e[80]!==be?(Ne=s.jsx(Co,{children:be}),e[80]=be,e[81]=Ne):Ne=e[81];let ie;e[82]!==a?(ie=a("multirun.launcher.models.label"),e[82]=a,e[83]=ie):ie=e[83];let ee;e[84]!==Ne||e[85]!==ie?(ee=s.jsx(Kn,{required:!0,info:Ne,children:ie}),e[84]=Ne,e[85]=ie,e[86]=ee):ee=e[86];let V;e[87]!==n.models||e[88]!==P||e[89]!==M||e[90]!==O?(V=s.jsx(hf,{selectedModels:n.models,onAdd:P,onRemove:M,onUpdate:O,minModels:1}),e[87]=n.models,e[88]=P,e[89]=M,e[90]=O,e[91]=V):V=e[91];let $;e[92]!==ee||e[93]!==V?($=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ee,V]}),e[92]=ee,e[93]=V,e[94]=$):$=e[94];let ae;return e[95]!==ne||e[96]!==we||e[97]!==$?(ae=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[ne,we,$]}),e[95]=ne,e[96]=we,e[97]=$,e[98]=ae):ae=e[98],ae},n3=t=>{const e=new Map;for(const n of t){const r=Ts(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},r3=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},o3=t=>{const e=st.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,u;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const d=us(),h=n3(i),f=l.current?.runtimeKey===d?l.current.identities:null;for(const p of r3(f,h))pp({runtimeKey:d,...p});l.current={runtimeKey:d,identities:h}},u=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=u):(a=e[3],u=e[4]),c.useEffect(a,u)},i3=new Map,a3=t=>{const e=st.c(26),{isVSCode:n}=t,r=Ia(),i=Ht(l3),o=Ht(c3),l=ts(d3),a=Je(u3);let u;e[0]!==n?(u=I=>n?i3:I.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const d=Je(u),h=!n;let f;e[2]!==d||e[3]!==i||e[4]!==h?(f=bf(i,d,{includeWorktrees:h}),e[2]=d,e[3]=i,e[4]=h,e[5]=f):f=e[5];const p=f,g=Is(f3),w=Is(m3),S=Is(h3),x=`session-list-sync:${c.useId()}`;let m,b;e[6]!==o||e[7]!==x||e[8]!==r||e[9]!==l||e[10]!==a||e[11]!==p||e[12]!==i?(m=()=>(r.setBootstrapDemand(x,lf({knownDirectories:p,activeProjectDirectory:vt(i.find(I=>I.id===o)?.path??null),activeProjectId:o,collapsedProjects:new Set,collapsedGroups:new Set,currentDirectory:l,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(x)),b=[o,x,r,l,a,p,i],e[6]=o,e[7]=x,e[8]=r,e[9]=l,e[10]=a,e[11]=p,e[12]=i,e[13]=m,e[14]=b):(m=e[13],b=e[14]),c.useEffect(m,b);const y=c.useRef(null);let v,N;e[15]!==n||e[16]!==p?(v=()=>{const I=new Set(p),M=y.current;y.current=I;const _=M?[...I].filter(O=>!M.has(O)):n?[...I]:[];_.length&&xa(_,Po())},N=[n,p],e[15]=n,e[16]=p,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(p3,C);let k;e[20]!==w||e[21]!==g?(k=[...g,...w],e[20]=w,e[21]=g,e[22]=k):k=e[22];const D=k;let P;e[23]!==D||e[24]!==S?(P={enabled:!0,hasAuthoritativeGlobalSessions:S,sessions:D},e[23]=D,e[24]=S,e[25]=P):P=e[25],o3(P)};function l3(t){return t.projects}function c3(t){return t.activeProjectId}function d3(t){return t.currentDirectory}function u3(t){return t.currentSessionDirectory}function f3(t){return t.activeSessions}function m3(t){return t.archivedSessions}function h3(t){return t.status==="ready"}function p3(){let t=null,e=!1;const n=new Set,r=Yr(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(),Ta(Po());return}const o=[...n];n.clear(),o.length&&xa(o,Po())},500)});return()=>{t&&clearTimeout(t),r()}}const g3=Ln(()=>Bn(()=>import("./SettingsWindow-DbgEnZ6T.js"),__vite__mapDeps([140,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,141,84,142,127,128,129,130,118,119,104,105,89,90,91,92,93,94,95,96,97,98,99,100,101,102,143,144])).then(t=>({default:t.SettingsWindow}))),x3=()=>{const t=st.c(58);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],a3(e),Cg();const n=Te(b3),r=Te(y3),i=Te(w3),o=Te(S3),[l,a]=c.useState(!1);let u,d;t[1]!==i?(u=()=>{i&&a(!0)},d=[i],t[1]=i,t[2]=u,t[3]=d):(u=t[2],d=t[3]),c.useEffect(u,d);const h=Te(v3),f=Te(j3),p=Te(k3),g=Te(C3),w=Te(N3),S=Te(A3),x=g||w||!!S||h;let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[4]=m):m=t[4],c.useEffect(P3,m);const{isMobile:b}=_n();Ng();const y=nb();let v,N;t[5]!==b||t[6]!==r?(v=()=>{Te.getState().isMobile!==b&&r(b)},N=[b,r],t[5]=b,t[6]=r,t[7]=v,t[8]=N):(v=t[7],N=t[8]),c.useEffect(v,N);let C,k,D,P;t[9]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(WS,{}),k=s.jsx(Bv,{}),D=s.jsx(Wv,{}),P=s.jsx(s4,{}),t[9]=C,t[10]=k,t[11]=D,t[12]=P):(C=t[9],k=t[10],D=t[11],P=t[12]);let I;t[13]!==y?(I=s.jsx(n4,{value:y,onMoveSessionOnly:I3,onMoveAllChanges:T3,onCancel:fb}),t[13]=y,t[14]=I):I=t[14];let M;t[15]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(Sb,{}),t[15]=M):M=t[15];let _;t[16]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(wb,{}),t[16]=_):_=t[16];let O;t[17]!==n?(O=s.jsx(t4,{isVisible:n}),t[17]=n,t[18]=O):O=t[18];let U;t[19]!==b||t[20]!==n||t[21]!==O?(U=s.jsx(yb,{isOpen:n,isMobile:b,className:"border-border",topBar:_,children:O}),t[19]=b,t[20]=n,t[21]=O,t[22]=U):U=t[22];let L;t[23]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(xb,{}),t[23]=L):L=t[23];const F=x&&"invisible";let R;t[24]!==F?(R=Ie("absolute inset-0",F),t[24]=F,t[25]=R):R=t[25];const j=!i&&!x;let A;t[26]!==j?(A=s.jsx(Gs,{children:s.jsx(iu,{active:j})}),t[26]=j,t[27]=A):A=t[27];let B;t[28]!==R||t[29]!==A?(B=s.jsx("div",{className:R,children:A}),t[28]=R,t[29]=A,t[30]=B):B=t[30];let X;t[31]!==h||t[32]!==p||t[33]!==f?(X=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Gs,{children:s.jsx(t3,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[31]=h,t[32]=p,t[33]=f,t[34]=X):X=t[34];let H;t[35]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Gs,{children:s.jsx(I4,{})}),t[35]=H):H=t[35];let Z;t[36]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Gs,{children:s.jsx(T4,{})}),t[36]=Z):Z=t[36];let ce;t[37]===Symbol.for("react.memo_cache_sentinel")?(ce=s.jsx(Gs,{children:s.jsx(W4,{})}),t[37]=ce):ce=t[37];let Y;t[38]!==B||t[39]!==X?(Y=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[B,X,H,Z,ce]}),t[38]=B,t[39]=X,t[40]=Y):Y=t[40];let se;t[41]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx(uS,{}),t[41]=se):se=t[41];let oe;t[42]!==Y?(oe=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:[Y,se]})})}),t[42]=Y,t[43]=oe):oe=t[43];let Se;t[44]===Symbol.for("react.memo_cache_sentinel")?(Se=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Gs,{children:s.jsx(SS,{})})}),t[44]=Se):Se=t[44];let K;t[45]!==oe?(K=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[L,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[oe,Se]})]}),t[45]=oe,t[46]=K):K=t[46];let pe;t[47]!==U||t[48]!==K?(pe=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[U,K]}),t[47]=U,t[48]=K,t[49]=pe):pe=t[49];let je;t[50]!==i||t[51]!==o||t[52]!==l?(je=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(g3,{open:i,onOpenChange:o})}):null,t[50]=i,t[51]=o,t[52]=l,t[53]=je):je=t[53];let ne;return t[54]!==I||t[55]!==pe||t[56]!==je?(ne=s.jsx(Ag,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[C,k,D,P,I,M,pe,je]})}),t[54]=I,t[55]=pe,t[56]=je,t[57]=ne):ne=t[57],ne};function b3(t){return t.isSidebarOpen}function y3(t){return t.setIsMobile}function w3(t){return t.isSettingsDialogOpen}function S3(t){return t.setSettingsDialogOpen}function v3(t){return t.isMultiRunLauncherOpen}function j3(t){return t.setMultiRunLauncherOpen}function k3(t){return t.multiRunLauncherPrefillPrompt}function C3(t){return t.isScheduledTasksDialogOpen}function N3(t){return t.isArchivePageOpen}function A3(t){return t.worktreesPageProjectId}function D3(){return Te.getState().closeMainSurfaces()}function P3(){const t=D3,e=Je.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function I3(){return Ru(!1)}function T3(){return Ru(!0)}const vf=12,R3=[{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"}],E3=t=>{const e=st.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,u=r===void 0?0:r,d=o===void 0?900:o,h=l===void 0?R3:l,f=gt.useRef(!1);let p,g;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},g=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=g):(p=e[2],g=e[3]),gt.useEffect(p,g);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w=Array.from({length:vf},M3),e[4]=w):w=e[4];const S=w;if(!n)return null;let x;e[5]!==i?(x=Ie("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=x):x=e[6];let m;if(e[7]!==u||e[8]!==h||e[9]!==d){let y;e[11]!==u||e[12]!==d?(y=v=>{const N={"--burst-delay":`${v.delay}ms`,"--burst-x":`${v.x}%`,"--burst-y":`${v.y}%`,"--firework-color":`var(${v.colorVar})`,"--firework-duration":`${d}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:S.map((C,k)=>{const D=C.x*v.radius,P=C.y*v.radius,I={"--translate-x":`${D}px`,"--translate-y":`${P}px`,"--particle-delay":`${C.delay}ms`,color:`var(${v.colorVar})`};return s.jsx("span",{className:"firework-particle",style:I},`${v.id}-${k}-${u}`)})},`${v.id}-${u}`)},e[11]=u,e[12]=d,e[13]=y):y=e[13],m=h.map(y),e[7]=u,e[8]=h,e[9]=d,e[10]=m}else m=e[10];let b;return e[14]!==u||e[15]!==x||e[16]!==m?(b=s.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":u,children:m}),e[14]=u,e[15]=x,e[16]=m,e[17]=b):b=e[17],b};function M3(t,e){const n=Math.PI*2*e/vf;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const O3=t=>{const e=st.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]=gt.useState(o),u=gt.useRef(null);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},e[3]=d):d=e[3];const h=d;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(F3)},e[4]=f):f=e[4];const p=f;let g;e[5]!==i?(g=()=>{h(),a(B3),u.current=window.setTimeout(()=>{a(_3),u.current=null},i)},e[5]=i,e[6]=g):g=e[6];const w=g;let S,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>h(),x=[h],e[7]=S,e[8]=x):(S=e[7],x=e[8]),gt.useEffect(S,x);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=m):m=e[12],m};function F3(t){return t.isActive?{...t,isActive:!1}:t}function B3(t){return{isActive:!0,cycle:t.cycle+1}}function _3(t){return t.isActive?{...t,isActive:!1}:t}const jf=c.createContext(void 0),L3=t=>{const e=st.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=O3();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 u=a;let d;e[3]!==i||e[4]!==r?(d=s.jsx(E3,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let h;return e[6]!==n||e[7]!==d||e[8]!==u?(h=s.jsxs(jf.Provider,{value:u,children:[n,d]}),e[6]=n,e[7]=d,e[8]=u,e[9]=h):h=e[9],h},v5=()=>{const t=c.useContext(jf);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},da="aiworker_requests_in_flight",kf=1e3,$3=300*1e3,$o=Math.ceil($3/kf),W3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(da)==="1"}catch{return!1}},Cf=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let z3=1;const V3=(t,e)=>{const n=window.__aiworkerRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},U3=t=>{const e=window.__aiworkerRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Nf=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},xr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},K3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=z3++;V3(o,Date.now());try{return await e(r,i)}finally{U3(o)}};window.fetch=n},Hc=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Tr=t=>{t.length>$o&&t.splice(0,t.length-$o)},H3=()=>{const t=window.__aiworkerRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Nf(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(xr(e,50)),t.p90Samples.push(xr(e,90)),t.p99Samples.push(xr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Tr(t.samples),Tr(t.p50Samples),Tr(t.p90Samples),Tr(t.p99Samples),Tr(t.maxSamples),t.lastSampleAt=Date.now()},G3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(H3,kf))},Gc=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},qc=t=>{if(!(typeof window>"u"))try{if(t){Gc(),Hc(),window.localStorage.setItem(da,"1"),window.__aiworkerRequestsInFlight__=Cf(),K3(),G3();return}window.localStorage.removeItem(da),Gc(),Hc(),delete window.__aiworkerRequestsInFlight__}catch{}},q3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;if(!t)return;const e=Cf();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},ua=()=>{if(typeof window>"u")return Qc();const t=window.__aiworkerRequestsInFlight__;if(!W3()||!t)return Qc();const e=Nf(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:xr(e,50),ageP90:xr(e,90),ageP99:xr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:$o}},Qc=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:$o});function Q3(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const Af=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`},fa=t=>`${(t/1e3).toFixed(2)} s`,Ss=t=>{const e=st.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},Yc=t=>{const e=st.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=Nt();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 u;e[8]!==r.entries?(u=r.entries.reduce(J3,0),e[8]=r.entries,e[9]=u):u=e[9];const d=u;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?Af(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==h||e[19]!==p?(g=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,p]}),e[18]=h,e[19]=p,e[20]=g):g=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(Ss,{label:w,value:r.entries.length}),e[23]=r.entries.length,e[24]=w,e[25]=S):S=e[25];let x;e[26]!==o?(x=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=x):x=e[27];let m;e[28]!==x||e[29]!==d?(m=s.jsx(Ss,{label:x,value:d}),e[28]=x,e[29]=d,e[30]=m):m=e[30];let b;e[31]!==o?(b=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=b):b=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]!==b||e[37]!==y?(v=s.jsx(Ss,{label:b,value:y}),e[36]=b,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:[g,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(cn,{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},Xc=t=>{const e=st.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,u=n.reduce(Z3,0),d=r>0?52/r:0;let h;e[0]!==u||e[1]!==a?(h=v=>a-u+v,e[0]=u,e[1]=a,e[2]=h):h=e[2];const f=h;let p;e[3]!==d?(p=v=>56-v*d,e[3]=d,e[4]=p):p=e[4];const g=p;let w;e[5]!==l?(w=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=w):w=e[6];const S=`0 0 ${a} 56`;let x;e[7]!==a?(x=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=x):x=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==g){let v;e[13]!==f||e[14]!==g?(v=(N,C)=>{const k=N.samples.length;if(k===0)return null;const D=N.samples.map((I,M)=>`${f(M)},${g(I).toFixed(2)}`),P=`M ${D.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${f(0)},56 L ${D.join(" L ")} L ${f(k-1)},56 Z`,fill:`color-mix(in srgb, ${N.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:P,fill:"none",stroke:N.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=g,e[15]=v):v=e[15],m=n.map(v),e[9]=n,e[10]=f,e[11]=g,e[12]=m}else m=e[12];let b;e[16]!==o||e[17]!==S||e[18]!==x||e[19]!==m?(b=s.jsxs("svg",{viewBox:S,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[x,m]}),e[16]=o,e[17]=S,e[18]=x,e[19]=m,e[20]=b):b=e[20];let y;return e[21]!==w||e[22]!==b?(y=s.jsxs("div",{className:"relative w-full",children:[w,b]}),e[21]=w,e[22]=b,e[23]=y):y=e[23],y},Y3=t=>{const e=st.c(100),{onClose:n}=t,{t:r}=Nt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),u=Je(eC),d=Ud(tC),h=Id(),f=gp(sC),p=Hs(nC),[g,w]=c.useState(rC),[S,x]=c.useState(oC),[m,b]=c.useState(iC),y=[{label:"p50",current:m.ageP50,samples:m.p50Samples,color:"var(--status-success)"},{label:"p90",current:m.ageP90,samples:m.p90Samples,color:"var(--status-info)"},{label:"p99",current:m.ageP99,samples:m.p99Samples,color:"var(--status-warning)"},{label:"max",current:m.ageMax,samples:m.maxSamples,color:"var(--status-error)"}];let v;e[0]!==m.samples?(v=m.samples.reduce(aC,0),e[0]=m.samples,e[1]=v):v=e[1];const N=v,C=y.reduce(cC,0);let k;e[2]!==g.entries?(k=new Map,g.entries.forEach(Be=>{k.set(Be.metric,Be.count)}),e[2]=g.entries,e[3]=k):k=e[3];let D;e[4]!==k?(D=k.get("ui.message_list.render")??0,e[4]=k,e[5]=D):D=e[5];let P;e[6]!==k?(P=k.get("ui.message_list.render.streaming")??0,e[6]=k,e[7]=P):P=e[7];let I;e[8]!==k?(I=k.get("ui.chat_message.render")??0,e[8]=k,e[9]=I):I=e[9];let M;e[10]!==k?(M=k.get("ui.chat_message.render.streaming")??0,e[10]=k,e[11]=M):M=e[11];let _;e[12]!==k?(_=k.get("ui.chat_message.render.static_during_stream")??0,e[12]=k,e[13]=_):_=e[13];let O;e[14]!==k?(O=k.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=k,e[15]=O):O=e[15];let U;e[16]!==D||e[17]!==P||e[18]!==I||e[19]!==M||e[20]!==_||e[21]!==O?(U={messageListRender:D,messageListRenderStreaming:P,chatMessageRender:I,chatMessageRenderStreaming:M,chatMessageRenderStaticDuringStream:_,chatMessageRenderStaticOutsideActiveTurnDuringStream:O},e[16]=D,e[17]=P,e[18]=I,e[19]=M,e[20]=_,e[21]=O,e[22]=U):U=e[22];const L=U;let F,R;e[23]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const Be=()=>{w(fo()),x(mo()),b(ua())};Be();const Ae=window.setInterval(Be,500);return()=>window.clearInterval(Ae)},F=[],e[23]=F,e[24]=R):(F=e[23],R=e[24]),c.useEffect(R,F);let j,A;e[25]!==l?(j=()=>{if(l==="idle")return;const Be=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Be)},A=[l],e[25]=l,e[26]=j,e[27]=A):(j=e[26],A=e[27]),c.useEffect(j,A);let B=0,X=0,H=0;for(const Be of Object.keys(f)){const Ae=f[Be]??[];X=X+Ae.length;for(const at of Ae)at.role==="user"?H=H+1:at.role==="assistant"&&(B=B+1)}let Z;e[28]!==B||e[29]!==X||e[30]!==H?(Z={assistant:B,total:X,user:H},e[28]=B,e[29]=X,e[30]=H,e[31]=Z):Z=e[31];const ce=Z;let Y;if(e[32]!==u||e[33]!==f||e[34]!==d||e[35]!==h||e[36]!==r){let Be;e[38]!==u||e[39]!==f||e[40]!==d||e[41]!==r?(Be=Ae=>{const at=f[Ae.id]??[];let Ue=0,ht=0;for(const Ct of at)Ct.role==="user"?ht=ht+1:Ct.role==="assistant"&&(Ue=Ue+1);const ut=d.get(Ae.id);return{id:Ae.id,title:Ae.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:Ue,messageCount:at.length,userMessageCount:ht,isStreaming:ut?.isStreaming||!1,isZombie:ut?.isZombie||!1,backgroundCount:ut?.backgroundMessageCount||0,lastAccessed:ut?.lastAccessedAt||0,isCurrent:Ae.id===u}},e[38]=u,e[39]=f,e[40]=d,e[41]=r,e[42]=Be):Be=e[42],Y=h.map(Be).sort(dC),e[32]=u,e[33]=f,e[34]=d,e[35]=h,e[36]=r,e[37]=Y}else Y=e[37];const se=Y;let oe;e[43]!==f?(oe=Object.keys(f),e[43]=f,e[44]=oe):oe=e[44];const Se=oe.length;let K;e[45]===Symbol.for("react.memo_cache_sentinel")?(K=async()=>{try{const Be={generatedAt:new Date().toISOString(),ui:fo(),vscode:mo()};await navigator.clipboard.writeText(JSON.stringify(Be,null,2)),a("copied")}catch{a("error")}},e[45]=K):K=e[45];const pe=K,je=bp,ne="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let T;e[46]===Symbol.for("react.memo_cache_sentinel")?(T={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=T):T=e[46];let G;e[47]!==i?(G=Q3(i),e[47]=i,e[48]=G):G=e[48];let le;e[49]!==G?(le=s.jsx(E,{name:G,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=G,e[50]=le):le=e[50];let de;e[51]!==r?(de=r("memoryDebugPanel.title"),e[51]=r,e[52]=de):de=e[52];let ue;e[53]!==de?(ue=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:de}),e[53]=de,e[54]=ue):ue=e[54];let Oe;e[55]!==le||e[56]!==ue?(Oe=s.jsxs("div",{className:"flex items-center gap-2",children:[le,ue]}),e[55]=le,e[56]=ue,e[57]=Oe):Oe=e[57];let me;e[58]!==i?(me=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(xt,{size:"xs",variant:"ghost",onClick:pe,children:s.jsx(E,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(xt,{size:"xs",variant:"ghost",onClick:()=>{fm(),w(fo()),x(mo())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=me):me=e[59];let Re;e[60]!==i?(Re=i==="requests"?s.jsx(xt,{size:"xs",variant:"ghost",onClick:()=>{q3(),b(ua())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=Re):Re=e[61];let ye;e[62]!==n?(ye=n?s.jsx(xt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=ye):ye=e[63];let q;e[64]!==me||e[65]!==Re||e[66]!==ye?(q=s.jsxs("div",{className:"flex items-center gap-1",children:[me,Re,ye]}),e[64]=me,e[65]=Re,e[66]=ye,e[67]=q):q=e[67];let we;e[68]!==Oe||e[69]!==q?(we=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Oe,q]}),e[68]=Oe,e[69]=q,e[70]=we):we=e[70];let be;e[71]===Symbol.for("react.memo_cache_sentinel")?(be={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=be):be=e[71];const Ne=i==="memory"?"secondary":"ghost";let ie;e[72]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>o("memory"),e[72]=ie):ie=e[72];let ee;e[73]!==r?(ee=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=ee):ee=e[74];let V;e[75]!==Ne||e[76]!==ee?(V=s.jsx(xt,{size:"sm",variant:Ne,className:"flex-1",onClick:ie,children:ee}),e[75]=Ne,e[76]=ee,e[77]=V):V=e[77];const $=i==="streaming"?"secondary":"ghost";let ae;e[78]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>o("streaming"),e[78]=ae):ae=e[78];let W;e[79]!==r?(W=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=W):W=e[80];let ve;e[81]!==$||e[82]!==W?(ve=s.jsx(xt,{size:"sm",variant:$,className:"flex-1",onClick:ae,children:W}),e[81]=$,e[82]=W,e[83]=ve):ve=e[83];const Fe=i==="requests"?"secondary":"ghost";let Ce;e[84]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>o("requests"),e[84]=Ce):Ce=e[84];let ke;e[85]!==r?(ke=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=ke):ke=e[86];let Qe;e[87]!==Fe||e[88]!==ke?(Qe=s.jsx(xt,{size:"sm",variant:Fe,className:"flex-1",onClick:Ce,children:ke}),e[87]=Fe,e[88]=ke,e[89]=Qe):Qe=e[89];let We;e[90]!==V||e[91]!==ve||e[92]!==Qe?(We=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:be,children:[V,ve,Qe]}),e[90]=V,e[91]=ve,e[92]=Qe,e[93]=We):We=e[93];const z=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(Ss,{label:r("memoryDebugPanel.metric.totalMessages"),value:ce.total}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Se} / ${hl.MAX_SESSIONS}`}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.userMessages"),value:ce.user}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ce.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:xp()})})]}),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:hl.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:p})]})]}),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(cn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:se.map(Be=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Be.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:Be.title}),Be.isStreaming?s.jsx(E,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Be.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:Be.assistantMessageCount,user:Be.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Be.messageCount})}),Be.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Be.backgroundCount]}):null]})]},Be.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(xt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(uC),currentSessionId:u,cachedSessions:Object.keys(f),messageRoleCounts:ce,sessionMessageRoleCounts:se.map(fC),memoryStates:Object.fromEntries(d)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(Pt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?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(xt,{size:"xs",variant:"outline",onClick:pe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Ss,{label:r("memoryDebugPanel.metric.uiMetrics"),value:g.entries.length}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:S.entries.length}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.messageListRenders"),value:L.messageListRender}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:L.messageListRenderStreaming}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:L.chatMessageRender}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:L.chatMessageRenderStreaming}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:L.chatMessageRenderStaticDuringStream}),s.jsx(Ss,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:L.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Yc,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:g,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),S.entries.length>0?s.jsx(Yc,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:S,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(Ss,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(Ss,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?Af(m.durationMs):r("memoryDebugPanel.common.idle")})]}),m.samples.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:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.peak})]})]}),s.jsx(Xc,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${N}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:fa(m.peakAgeMs)})]}),s.jsx(Xc,{series:y.map(mC),peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:fa(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:y.map(hC)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:m.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let he;return e[94]!==je||e[95]!==T||e[96]!==we||e[97]!==We||e[98]!==z?(he=s.jsxs(je,{className:ne,style:T,children:[we,We,z]}),e[94]=je,e[95]=T,e[96]=we,e[97]=We,e[98]=z,e[99]=he):he=e[99],he},X3=Y3;function J3(t,e){return t+e.count}function Z3(t,e){return Math.max(t,e.samples.length)}function eC(t){return t.currentSessionId}function tC(t){return t.sessionMemoryState}function sC(t){return t.message}function nC(t){return t.totalRequestCount}function rC(){return fo()}function oC(){return mo()}function iC(){return ua()}function aC(t,e){return Math.max(t,e)}function lC(t,e){return Math.max(t,e)}function cC(t,e){return e.samples.reduce(lC,t)}function dC(t,e){return e.lastAccessed-t.lastAccessed}function uC(t){return{id:t.id,title:t.title}}function fC(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function mC(t){return{samples:t.samples,color:t.color}}function hC(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:fa(t.current)})]},t.label)}const pC=()=>{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()??"":""},gC=async()=>{const t=pC()||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")},Jc="aiworker:menu-action",bi="aiworker:check-for-updates",xC=t=>{const e=Je(m=>m.openNewSessionDraft),n=Te(m=>m.toggleCommandPalette),r=Te(m=>m.setCommandPaletteOpen),i=Te(m=>m.toggleHelpDialog),o=Te(m=>m.toggleSidebar),l=Te(m=>m.setSessionSwitcherOpen),a=Te(m=>m.setSettingsDialogOpen),u=Te(m=>m.setAboutDialogOpen),d=Fr(m=>m.checkForUpdates),{setThemeMode:h}=Zn(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,d().then(()=>{const{available:m,error:b}=Fr.getState();if(b){Le.error("Failed to check for updates",{description:b});return}m||Le.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[d]),g=c.useCallback(()=>{xn.requestDirectoryDialog()},[]),w=c.useCallback(m=>{const b=yp();if(b.length===0)return;const y=Je.getState().currentSessionId,v=b.findIndex(k=>k.id===y);let N=m>0?0:b.length-1;v>=0&&(N=(v+m+b.length)%b.length);const C=b[N];C&&(l(!1),Je.getState().setCurrentSession(C.id))},[l]),S=c.useCallback(m=>{const{activeProjectId:b,projects:y,setActiveProject:v}=Ht.getState();if(y.length===0)return;const N=y.findIndex(D=>D.id===b);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)},[]),x=c.useCallback(m=>{switch(m){case"about":u(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const b=Je.getState(),y=ts.getState().currentDirectory;e(b.currentSessionId&&y?{directoryOverride:y}:void 0)}break;case"new-worktree-session":l(!1),Fd();break;case"change-workspace":g();break;case"toggle-right-sidebar":{const b=ts.getState().currentDirectory;if(!b)break;const y=Te.getState(),v=or(b),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 b=ts.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"git");break}case"open-right-sidebar-files":{const b=ts.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"file");break}case"toggle-terminal":{const b=ts.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"terminal");break}case"toggle-terminal-expanded":{const b=ts.getState().currentDirectory;if(!b)break;const y=or(b),v=Te.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 b=new Event("aiworker:copy",{cancelable:!0});!window.dispatchEvent(b)||gC();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":wp();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":ts.getState().goBack();break;case"go-forward":ts.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":{Bd().catch(()=>{Le.error("Failed to collect OpenCode status")});break}}},[g,S,w,t,e,u,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=y=>{const v=y.detail;v&&x(v)},b=()=>{p()};return window.addEventListener(Jc,m),window.addEventListener(bi,b),()=>{window.removeEventListener(Jc,m),window.removeEventListener(bi,b)}},[x,p]),c.useEffect(()=>{if(typeof window>"u")return;const b=window.__AIWORKER_DESKTOP__?.listen;if(typeof b!="function")return;let y=null,v=null;return b("aiworker:menu-action",N=>{const C=N?.payload;typeof C=="string"&&x(C)}).then(N=>{y=N}).catch(()=>{}),b("aiworker:check-for-updates",()=>{window.dispatchEvent(new Event(bi))}).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{}})()}},[x])},bC="aiworker:tray-action",Zc=5e3,yC=500,Df=20,ed=()=>{if(typeof window>"u")return!1;const t=window.__AIWORKER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},td=()=>typeof window<"u"&&window.__AIWORKER_ELECTRON__?.trayEnabled!==!1,wC=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},SC=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Pf=(t,e)=>Gd(t,e,Wr.getState().ids,ja.getState().rankById),vC=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},jC=(t,e,n,r,i)=>{if(!t)return"";const o=hd(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||vC(t),u=go(t);let d=u&&i.get(u)||"";if(!d){for(const[h,f]of Dn.getState().directories)if(go(h)===u){d=f.status?.current??"";break}}if(!d)for(const h of r.values()){const f=h.find(p=>go(p.path)===u);if(f?.branch){d=f.branch;break}}return d?`${a} · ${d}`:a},kC=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ar.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 jp){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const u=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;u.push({label:Cp(h),value:kp(f.valueLabel,p)})}const d=!a.ok&&a.error?a.error:u.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:u,status:d})}return{mode:r,groups:o}},CC=async()=>{try{if(Wo())return"Local AiWorker";const t=window.__AIWORKER_LOCAL_ORIGIN__||window.location.origin,e=Nn();if(e&&Qa(e,t))return"Local AiWorker";const r=(await ld()).hosts.find(i=>e?Qa(e,mm(i)):!1);return r?.label?.trim()?cd(r.label.trim()):"Instance"}catch{return""}},NC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Do()}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(go(o)??o,a.vcs.branch);for(const u of a.session)u?.id&&r.set(u.id,u.title);for(const[u,d]of Object.entries(a.session_status??{})){const h=d?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",p=t.get(u);(!p||p==="idle")&&t.set(u,f)}for(const[u,d]of Object.entries(a.permission??{}))for(const h of d??[]){if(!h?.id)continue;const f=h.sessionID||u;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:wC(h),directory:o})}for(const[u,d]of Object.entries(a.question??{}))for(const h of d??[]){if(!h?.id)continue;const f=h.sessionID||u;n.push({kind:"question",id:h.id,sessionId:f,sessionTitle:"",label:SC(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},AC=()=>{const t=Is.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Pf).slice(0,Df).forEach(r=>{const i=Ts(r);i&&e.add(i)});const n=new Map;for(const r of t){if(!r?.id)continue;const i=Ts(r);if(!i||!e.has(i))continue;const o=n.get(i)??[];o.push(r.id),n.set(i,o)}return n},DC=t=>{const e=NC(),n=Da.getState().index.session,r=Is.getState().activeSessions,i=new Map(e.titleById),o=new Map;for(const x of r)if(x?.id&&(x.title&&i.set(x.id,x.title),x.parentID)){const m=o.get(x.parentID)??[];m.push(x.id),o.set(x.parentID,m)}const l=x=>{const m=[],b=[...o.get(x)??[]],y=new Set;for(;b.length;){const v=b.pop();y.has(v)||(y.add(v),m.push(v),b.push(...o.get(v)??[]))}return m},a=Aa.getState().statusById,u=x=>{const m=e.statusById.get(x);return m&&m!=="idle"?m:a.get(x)?.status.type??m??"idle"},d=x=>{const m=x.map(b=>u(b));return m.includes("busy")?"busy":m.includes("retry")?"retry":"idle"},h=Ht.getState().projects,f=Je.getState().availableWorktreesByProject,p=r.filter(x=>x?.id&&!x.parentID).slice().sort(Pf).slice(0,Df).map(x=>{const m=[x.id,...l(x.id)],b=Ts(x)??"";return{id:x.id,title:x.title||"Untitled session",status:d(m),branch:b?e.branchByDirectory.get(b)??"":"",unseen:m.reduce((y,v)=>y+(n.unseenCount[v]??0),0),hasError:m.some(y=>n.unseenHasError[y]??!1),directory:b,subtitle:jC(b,x,h,f,e.branchByDirectory)}}),g=e.approvals.map(x=>({...x,sessionTitle:i.get(x.sessionId)||""})),w=Te.getState();let S=0;if(w.dockBadgeEnabled)for(const x of r){if(!x?.id||x.parentID)continue;let m=n.unseenCount[x.id]??0;m===0&&w.notifyOnSubtasks&&(m=l(x.id).reduce((b,y)=>b+(n.unseenCount[y]??0),0)),m>0&&(S+=1)}return{sessions:p,approvals:g,instanceName:t,usage:kC(),dockBadgeCount:S}},PC=()=>{c.useEffect(()=>{if(!ed()||!td()||!Vo())return;let t=!1,e="",n=null,r="";const i=()=>{if(t)return;const C=DC(r),k=JSON.stringify(C);k!==e&&(e=k,Mn("desktop_tray_update",C))};CC().then(C=>{t||(r=C,i())});const o=async()=>{const C=AC();await Promise.all([...C.entries()].map(async([k,D])=>{const P=await Qs.getSessionStatusForDirectory(k).catch(()=>null);t||P===null||Sp(k,P,D)}))},l=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,i()},yC))},a=new Map,u=()=>{if(t)return;let C;try{C=Do()}catch{return}const k=new Set;for(const[D,P]of C.children.entries())k.add(D),a.has(D)||a.set(D,P.subscribe(()=>l()));for(const[D,P]of a)k.has(D)||(P(),a.delete(D))};let d=null;try{d=Do().subscribeRegistry(()=>{u(),l()})}catch{}u();const h=Da.subscribe(()=>l()),f=Is.subscribe(()=>l()),p=Ht.subscribe(()=>l()),g=Je.subscribe(()=>l()),w=Dn.subscribe(()=>l()),S=Te.subscribe(()=>l()),x=Aa.subscribe(()=>l()),m=ja.subscribe(()=>l()),b=Wr.subscribe(()=>l());o();const y=window.setInterval(()=>{o()},Zc),v=ar.subscribe(()=>l());ar.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:C,results:k}=ar.getState();C.length>0&&C.some(P=>!k.some(I=>I.providerId===P))&&ar.getState().fetchQuotas(C)});const N=window.setInterval(()=>{u(),i()},Zc);return i(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(N),window.clearInterval(y),h(),f(),p(),g(),w(),S(),x(),m(),b(),v(),d?.();for(const C of a.values())C();a.clear()}},[]),c.useEffect(()=>{if(!ed()||!td()||typeof window>"u")return;const e=window.__AIWORKER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&vp(i.sessionId,i.id,i.response).catch(()=>{Le.error("Failed to respond to permission request")})};let r=null;return e(bC,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{}}},[])},IC=45e3,TC=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,IC);return()=>r(i)},RC=t=>{const e=st.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return TC(EC,MC)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function EC(){Np(Po())}function MC(){Ta()}const OC="/api/notifications/stream",FC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),BC=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="aiworker: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}},_C=t=>{const e=st.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||bn()||!ha()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(ud().sse(OC));return o.onmessage=LC,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function LC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Te.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&FC())return;const r=BC(e);if(!r)return;zo()?.notifications?.notifyAgentCompletion(r)}const $C=6e4,WC=t=>{const e=st.c(10),n=Te(zC),r=Ap(VC),o=Dg(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:$C})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let u,d;e[5]!==n||e[6]!==r||e[7]!==o?(u=()=>{if(n)return Yr(h=>{h.type==="agent-memory-changed"&&r(o)})},d=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=u,e[9]=d):(u=e[8],d=e[9]),c.useEffect(u,d)};function zC(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function VC(t){return t.load}const sd="pwa-install-toast-shown",nd="pwa-install-toast-dismissed",UC=()=>{const t=st.c(6),{browserTab:e}=Pg(),{t:n}=Nt(),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"||!ha()||!e)return;let u=null,d=null;const h=()=>{d!==null&&(Le.dismiss(d),d=null)},f=async()=>{if(!u)return;const w=u;u=null,h(),await w.prompt();const{outcome:S}=await w.userChoice;S==="accepted"&&Le.success(r.current("pwa.installPrompt.started"))},p=w=>{const S=w;if(typeof S.prompt!="function")return;S.preventDefault(),u=S;const x=No(),m=hm();Ig({dismissed:x.getItem(nd),sessionShown:m.getItem(sd),hasActiveToast:d!==null})&&(m.setItem(sd,"true"),d=Le.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{No().setItem(nd,"true"),h()}}}))},g=()=>{u=null,h(),Le.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",g),()=>{h(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",g)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},KC=({open:t,onOpenChange:e})=>{const{t:n}=Nt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[u,d]=c.useState(!1),[h,f]=c.useState(!1),[p,g]=c.useState(null),[w,S]=c.useState(!1);c.useCallback(async()=>{},[p,u,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const b=await ds("/api/system/info");if(b.ok){const y=await b.json();if(typeof y.aiworkerVersion=="string"&&y.aiworkerVersion.trim()){o(y.aiworkerVersion);return}}}catch{}o(await Dp())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const y=await ds("/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(()=>{{g(null),S(!1);return}},[t,r]);const x=i;return s.jsx(vs,{open:t,onOpenChange:e,children:s.jsx(js,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Td,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"AiWorker"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[x&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:x})}),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://roweb.cn/roweb/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(E,{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(E,{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(E,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@aiworker_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},rd=t=>{if(!(typeof window>"u")){if(t){window.location.href="aiworker://focus/mcp-auth";return}window.location.replace("/")}},yi=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},HC=(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 AiWorker and click Authorize again.":n},GC=()=>{const t=Pp(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),u=yi(a,"code"),d=Ip(a),h=Tp(a),f=yi(a,"error"),p=yi(a,"error_description");if(f){h&&ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(p??f);return}(async()=>{try{if(!u)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into AiWorker manually.");let g=d,w=!1;if(h){const S=await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(S.ok){const x=await S.json().catch(()=>null);w=x?.origin===Rp,i(w),!g&&x?.name?.trim()&&(g={name:x.name.trim(),directory:typeof x.directory=="string"&&x.directory.trim()?x.directory.trim():null})}}if(!g?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into AiWorker manually.");await t(g.name,u,g.directory),h&&await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),w&&rd(!0),l("Authorization completed. You can close this tab and return to AiWorker.")}catch(g){h&&await ds(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(HC(g,"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:Ep,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:Ie("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(xt,{type:"button",onClick:()=>rd(r),children:"Return to AiWorker"})})]})})},od=Ln(()=>Bn(()=>import("./OnboardingScreen-CTuu4lgo.js"),__vite__mapDeps([145,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}))),qC=()=>{const t=st.c(3),e=Te(e5),n=Te(t5);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(KC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},QC=t=>{const e=st.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=Nt();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 u;e[6]!==a?(u=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==u?(d=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,u]}),e[8]=l,e[9]=u,e[10]=d):d=e[10];let h;e[11]!==r||e[12]!==i?(h=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=i,e[13]=h):h=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==h?(f=s.jsx(xt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let p;return e[18]!==d||e[19]!==f?(p=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:[d,f]})}),e[18]=d,e[19]=f,e[20]=p):p=e[20],p},id=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",YC=()=>{if(typeof window>"u"||!nx())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}},XC=()=>typeof window>"u"?!1:window.location.pathname===_p,JC=t=>{const e=st.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=ts(s5),l=Je(n5),a=Je(r5),u=Cd(),d=c.useRef(null);let h;e[0]!==n.directory?(h=id(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let p;e[2]!==o?(p=id(o),e[2]=o,e[3]=p):p=e[3];const g=p;let w,S;if(e[4]!==g||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==u?(w=()=>{if(r||f&&g!==f)return;const N=`${f}
|
|
930
|
+
${n.sessionId}`;d.current===N&&l||(d.current=N,a(n.sessionId,n.directory),u.ensureSessionRenderable(n.sessionId,!0))},S=[g,l,n.directory,n.sessionId,f,r,a,u],e[4]=g,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=u,e[12]=w,e[13]=S):(w=e[12],S=e[13]),c.useEffect(w,S),f&&g!==f)return null;let x;e[14]!==i?(x=s.jsx(Xd,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=x):x=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(au,{}),e[16]=m):m=e[16];let b;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(b=s.jsx(iu,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=b):b=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Jd,{}),e[21]=y):y=e[21];let v;return e[22]!==x||e[23]!==b?(v=s.jsxs(s.Fragment,{children:[x,m,b,y]}),e[22]=x,e[23]=b,e[24]=v):v=e[24],v};function ZC({apis:t}){c.useEffect(()=>{pm("App:mounted"),gm()&&console.info("[startup-trace] enabled. Run console.table(window.__AIWORKER_STARTUP_TRACE__) after startup.")},[]);const e=qt(T=>T.initializeApp),n=qt(T=>T.isInitialized),r=qt(T=>T.isConnected),i=qt(T=>T.providers.length),o=qt(T=>T.agents.length),l=qt(T=>T.loadProviders),a=qt(T=>T.loadAgents),u=Je(T=>T.error),d=Je(T=>T.clearError),h=ts(T=>T.currentDirectory),f=ts(T=>T.setDirectory),p=ts(T=>T.isSwitchingDirectory),[g,w]=c.useState(!1),S=An(T=>T.refreshStatus),x=Ni(T=>T.refreshStatus),[m,b]=c.useState(()=>t.runtime.isVSCode),[y,v]=c.useState(!1),[N,C]=c.useState(!1),[k,D]=c.useState(0),[P,I]=c.useState(0),[M,_]=c.useState(!1),O=Te(T=>T.wideChatLayoutEnabled),U=Te(T=>T.mobileKeyboardMode),L=c.useMemo(()=>bn(),[]),F=ba(T=>T.setPlanModeEnabled),[R,j]=c.useState(()=>Ya()),[A,B]=c.useState(()=>{const T=Xa();return T!==null?Ja({isDesktopShell:!0,bootOutcome:T}):null}),X=c.useRef(!1),H=c.useMemo(()=>YC(),[]),Z=!H||y,ce=c.useMemo(()=>XC(),[]);c.useEffect(()=>(Za(g),()=>{Za(!1)}),[g]),c.useEffect(()=>(qc(g),()=>{qc(!1)}),[g]),c.useEffect(()=>{xm(U)},[U]),c.useEffect(()=>{b(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>ma(T=>{Tg(T),I(G=>G+1),C(!1),D(G=>G+1)}),[]);const Y=pl(T=>{const G=us();return Object.values(T.runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===G).map(le=>`${le.originalSessionID}:${le.phase}:${le.lastForwardedMessageID??""}:${le.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(H)return;const T=us(),G=Object.values(pl.getState().runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===T);for(const le of G)Mp(le.originalSessionID)},[Y,H,P]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",O),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[O]),c.useEffect(()=>(el(t),()=>el(null)),[t]),c.useEffect(()=>{H||(S(t.github,{force:!0}),x(t.linear,{force:!0}))},[t.github,t.linear,H,r,S,x,P]),Op();const se=R==="valid",oe=A?.screen==="main";c.useEffect(()=>{if(!bm({isDesktopShell:L,isInitialized:n,bootOutcomeKnown:se,bootViewIsMain:oe}))return;const T=setTimeout(()=>{const G=document.getElementById("initial-loading");G&&(G.classList.add("fade-out"),setTimeout(()=>{G.remove()},300))},150);return()=>clearTimeout(T)},[L,n,se,oe]),c.useEffect(()=>{if(!L||R!=="malformed")return;const T=document.getElementById("initial-loading");T&&(T.textContent="Desktop startup failed — please restart the app.")},[L,R]),c.useEffect(()=>{if(L)return;const T=setTimeout(()=>{const G=document.getElementById("initial-loading");G&&!n&&(G.classList.add("fade-out"),setTimeout(()=>{G.remove()},300))},5e3);return()=>clearTimeout(T)},[L,n]),c.useEffect(()=>{let T=!1;return(async()=>{const le=await ds("/health",{method:"GET"}).catch(()=>null);if(!le||!le.ok||T)return;const de=await le.json().catch(()=>null);if(!de||T)return;const ue=de.planModeExperimentalEnabled;F(ue===!0||ue===1||ue==="1"||ue==="true")})(),()=>{T=!0}},[F]),c.useEffect(()=>{m||e()},[e,m]),c.useEffect(()=>{if(m||n)return;let T=!0,G,le=0;const de=10,ue=1e3,Oe=async()=>{if(!T)return;if(le>=de){C(!0);return}const me=qt.getState();if(me.isInitialized){C(!1);return}le+=1,await me.initializeApp();const Re=qt.getState();if(!T)return;if(Re.isInitialized){C(!1);return}if(le>=de){C(!0);return}const ye=Math.min(ue*Math.pow(2,le-1),16e3);G=setTimeout(Oe,ye)};return G=setTimeout(Oe,ue),()=>{T=!1,G&&clearTimeout(G)}},[k,n,m]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!N)return;const T=document.getElementById("initial-loading");T&&(T.classList.add("fade-out"),setTimeout(()=>{T.remove()},300))},[N]),c.useEffect(()=>{if(m||!r||i>0&&o>0)return;let T=!0,G=0;const le=15,de=async()=>{const Oe=qt.getState();if(!(Oe.providers.length>0&&Oe.agents.length>0))try{Oe.providers.length===0&&await l({source:"startupRecovery"}),qt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};de();const ue=setInterval(()=>{if(T){if(++G>=le){clearInterval(ue);return}de()}},2e3);return()=>{T=!1,clearInterval(ue)}},[r,m,a,l,i,o]),c.useEffect(()=>{p||m||r&&Qs.setDirectory(h)},[h,p,r,m]),c.useEffect(()=>{if(!H||typeof window>"u")return;const T=de=>{v(de?.visible===!0)},G=de=>{if(de.origin!==window.location.origin||de.source!==window.parent)return;const ue=de.data;ue?.type===gu&&T(ue.payload)},le=window;return le.__aiworkerSetEmbeddedVisibility=T,window.addEventListener("message",G),sx(),()=>{window.removeEventListener("message",G),le.__aiworkerSetEmbeddedVisibility===T&&delete le.__aiworkerSetEmbeddedVisibility}},[H]),c.useEffect(()=>{!H?.directory||m||h!==H.directory&&f(H.directory,{showOverlay:!1})},[h,H,m,f]),c.useEffect(()=>{if(!H||typeof window>"u")return;const T=G=>{G.storageArea===window.localStorage&&G.key==="ui-store"&&Te.persist.rehydrate()};return window.addEventListener("storage",T),()=>{window.removeEventListener("storage",T)}},[H]),c.useEffect(()=>{if(typeof window>"u")return;const T=G=>{const le=G.detail,de=typeof le?.sessionId=="string"?le.sessionId.trim():"";if(!de)return;const ue=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null;Je.getState().setCurrentSession(de,ue)};return window.addEventListener("aiworker:open-session",T),()=>window.removeEventListener("aiworker:open-session",T)},[]),c.useEffect(()=>{if(typeof window>"u")return;const T=()=>{Mn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("aiworker:open-mini-chat",T),()=>window.removeEventListener("aiworker:open-mini-chat",T)},[]),c.useEffect(()=>{if(typeof window>"u")return;const T=()=>{const G=Je.getState().currentSessionId;G&&Rd(G)};return window.addEventListener("focus",T),()=>window.removeEventListener("focus",T)},[]),c.useEffect(()=>{if(typeof window>"u")return;const T=G=>{const le=G.detail,de=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null,ue=typeof le?.projectId=="string"&&le.projectId.trim().length>0?le.projectId.trim():null,Oe=!!(de||ue);Te.getState().setSessionSwitcherOpen(!1),Je.getState().openNewSessionDraft({target:Oe?"project":"chat",selectedProjectId:Oe?ue:null,directoryOverride:Oe?de:null,preserveDirectoryOverride:!!de})};return window.addEventListener("aiworker:open-draft-session",T),()=>window.removeEventListener("aiworker:open-draft-session",T)},[]),c.useEffect(()=>{typeof window>"u"||!n||p||X.current||(X.current=!0,window.__aiworkerAppReady=!0,window.dispatchEvent(new Event("aiworker:app-ready")))},[n,p]),Fp({enabled:Z}),_C({enabled:Z}),WC(h||null),UC(),Bp(),Xp(),Rg();const Se=c.useCallback(()=>{w(T=>!T)},[]);xC(Se),PC(),RC(!H),c.useEffect(()=>{if(H)return;const T=()=>w(G=>!G);return window.addEventListener("aiworker:memory-debug-toggle",T),()=>window.removeEventListener("aiworker:memory-debug-toggle",T)},[H]),c.useEffect(()=>{H||u&&setTimeout(()=>d(),5e3)},[d,H,u]),c.useEffect(()=>{if(!L||R!=="not-injected")return;let T=!1,G=0;const le=200,de=2e3,ue=50,Oe=()=>{if(T)return;G++;const me=Ya();if(me!=="not-injected"){if(T=!0,j(me),me==="valid"){const ye=Xa();ye&&B(Ja({isDesktopShell:!0,bootOutcome:ye}))}return}const Re=Math.min(le*Math.pow(1.1,G),de);if(G>=ue){const ye=document.getElementById("initial-loading");ye&&!ye.textContent?.includes("taking longer")&&(ye.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Oe,Re)};return window.setTimeout(Oe,le),()=>{T=!0}},[L,R]);const K=c.useCallback(async()=>{if(ym({isDesktopShell:bn(),isDesktopLocalOriginActive:Wo()})){await wm();return}window.location.reload()},[]),pe=c.useCallback(async()=>{if(!M){C(!1),_(!0);try{await qt.getState().initializeApp()}finally{_(!1)}qt.getState().isInitialized||D(T=>T+1)}},[M]),je=T=>{if(T.screen==="recovery")return T.variant};if(L&&A&&A.screen!=="main"){if(A.screen==="chooser")return s.jsx(Gs,{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(od,{mode:"first-launch",localAvailable:A.localAvailable!==!1,onCliAvailable:K,onChooseRemote:()=>{}})})})});const T=je(A),G=A.screen==="recovery"&&"url"in A?A.url:void 0;return s.jsx(Gs,{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(od,{mode:"recovery",recoveryVariant:T,recoveryHostUrl:G,recoveryHostLabel:void 0,localAvailable:A.localAvailable!==!1,onCliAvailable:K})})})})}if(H)return s.jsx(Gs,{children:s.jsx(gl,{sdk:Qs.getSdkClient(),directory:h||"",children:s.jsx(xl,{apis:t,children:s.jsx(Ri,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(JC,{embeddedSessionChat:H,isVSCodeRuntime:m,embeddedBackgroundWorkEnabled:Z}),s.jsx(bl,{}),s.jsx(yl,{})]})})})},P)});if(ce)return s.jsx(Gs,{children:s.jsx(GC,{})});if(N&&!n&&!m&&!H)return s.jsx(Gs,{children:s.jsx(QC,{onRetry:()=>{pe()},isRetrying:M})});const ne=!n&&!L;return s.jsx(Gs,{children:s.jsx(gl,{sdk:Qs.getSdkClient(),directory:h||"",children:s.jsx(xl,{apis:t,children:s.jsx(L3,{children:s.jsx(Ri,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:L?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Xd,{embeddedBackgroundWorkEnabled:Z}),s.jsx(au,{}),s.jsx(x3,{}),s.jsx(Jd,{}),s.jsx(bl,{}),s.jsx(yl,{}),!ne&&s.jsxs(s.Fragment,{children:[s.jsx(Eg,{}),s.jsx(qC,{}),g&&s.jsx(X3,{onClose:()=>w(!1)})]})]})})})})},P)})}function e5(t){return t.isAboutDialogOpen}function t5(t){return t.setAboutDialogOpen}function s5(t){return t.currentDirectory}function n5(t){return t.currentSessionId}function r5(t){return t.setCurrentSession}const o5=typeof window<"u"&&window.__AIWORKER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Lp();Sm().then(()=>{Promise.all([vm(),$p()]).catch(t=>{console.error("[main] settings init failed:",t)}),Wp(),zp(),Vp()}).catch(t=>{console.error("[main] appearance init failed:",t)});const If=document.getElementById("root");if(!If)throw new Error("Root element not found");Up();Uf.createRoot(If).render(s.jsx(gt.StrictMode,{children:s.jsx(Kp,{children:s.jsx(Hp,{children:s.jsx(Gp,{children:s.jsx(qp,{children:s.jsx(ZC,{apis:o5})})})})})}));const j5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Bb as W,Nb as a,v5 as b,Lu as g,j5 as m,Fb as u,_u as v};
|