@aiworker/web 1.23.1 → 1.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-teB3HmBT.js → CodeMirrorCommentWidgets-pFeKzADY.js} +1 -1
- package/dist/assets/{DiffView-DC9RX3MF.js → DiffView-BYwAHIlW.js} +3 -3
- package/dist/assets/{DirtyBranchSwitchDialog-DwPkzXsS.js → DirtyBranchSwitchDialog-BeyJczAi.js} +1 -1
- package/dist/assets/{FilesView-BFZkuu4O.js → FilesView-lrP5OlzK.js} +6 -6
- package/dist/assets/{GitView-B_x52MHY.js → GitView-CCUK73JL.js} +4 -4
- package/dist/assets/{JsonTreeView-cmAzUTiw.js → JsonTreeView-CqUi8Ytj.js} +1 -1
- package/dist/assets/{LinearIssuesView-Dehh5afm.js → LinearIssuesView-C0WwIDQN.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-DgNOqqhE.js → MarkdownImageGallery-0NXPad4K.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DusmMZ_p.js → MarkdownRendererImpl-q-rUxBkU.js} +4 -4
- package/dist/assets/{OnboardingScreen-B8fm1H4m.js → OnboardingScreen-Cy6xZ-IQ.js} +1 -1
- package/dist/assets/{PatchDiff-BVr7gJU0.js → PatchDiff-DuYWs-7m.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DzLt-nel.js → PierreDiffViewer-C51SEtjJ.js} +1 -1
- package/dist/assets/{PlanView-BmQUYT_z.js → PlanView-k63mHfFF.js} +1 -1
- package/dist/assets/SettingsView-DNJXHPYC.js +28 -0
- package/dist/assets/{SettingsWindow-Dy3M6ZB9.js → SettingsWindow-DFMJqIkx.js} +1 -1
- package/dist/assets/{ToolOutputDialog-cTl_eLIH.js → ToolOutputDialog-B4kBDjLK.js} +4 -4
- package/dist/assets/{ToolPartDiffPreview-C_3iYNJQ.js → ToolPartDiffPreview-DhVBmwis.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-CAWthkoy.js → VirtualizedFileDiff-C-MFNoKo.js} +1 -1
- package/dist/assets/{WalkthroughView-C7AHOpCA.js → WalkthroughView-hmnM70S9.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-BkiDSlTW.js → computeVirtualFileMetrics-Bv64vrxY.js} +1 -1
- package/dist/assets/{de-DJsQr-p7.js → de-i-51iOMQ.js} +2 -2
- package/dist/assets/{es-BuYMlA9g.js → es-CNkqJISC.js} +3 -3
- package/dist/assets/{fr-ePDay33C.js → fr-a9t4bHWo.js} +3 -3
- package/dist/assets/index-BvwlOZOg.js +40 -0
- package/dist/assets/{index-n6O3hklM.js → index-C-KjDH6t.js} +1 -1
- package/dist/assets/index-n5p3SnES.css +1 -0
- package/dist/assets/{isDiffPlainText-GMdPz-71.js → isDiffPlainText-B0pMS3gs.js} +1 -1
- package/dist/assets/{isFilePlainText-BVuH1zH9.js → isFilePlainText-IXDeiXmH.js} +1 -1
- package/dist/assets/{ja-BzR9xOY_.js → ja-C2HQKC-_.js} +3 -3
- package/dist/assets/{ko-BEjHAm14.js → ko-CvVt6P_Q.js} +3 -3
- package/dist/assets/main-6ZT1mvpO.js +930 -0
- package/dist/assets/{main-D3ZDQglc.js → main-BeWvA5d9.js} +2 -2
- package/dist/assets/markdownCore-DTW1POUM.js +5 -0
- package/dist/assets/{miniChat-d01k801U.js → miniChat-DzMGD1Hv.js} +2 -2
- package/dist/assets/{mobile-D7VV-Ufz.js → mobile-CrDSF4dQ.js} +2 -2
- package/dist/assets/{patchFileDiff-CdztVMz0.js → patchFileDiff-DHG-znZQ.js} +3 -3
- package/dist/assets/{pl-rQmpxNIF.js → pl-CQi2SXLP.js} +3 -3
- package/dist/assets/{pt-BR-CorbsSW-.js → pt-BR-FdnmJOe8.js} +3 -3
- package/dist/assets/{renderElectronMiniChatApp-BGG9UIlh.js → renderElectronMiniChatApp-BuaS0XYk.js} +2 -2
- package/dist/assets/renderMobileApp-hxXJf_Db.js +25 -0
- package/dist/assets/runtimeEndpointReset-DB4KI-ED.js +41 -0
- package/dist/assets/{scheduledTasksApi-BEuUF_cj.js → scheduledTasksApi-DZaxQ19y.js} +1 -1
- package/dist/assets/{shikiHighlight-BzXUjlby.js → shikiHighlight-B1goMnV6.js} +1 -1
- package/dist/assets/{tr-CoAMXPtI.js → tr-BwD9HLzh.js} +2 -2
- package/dist/assets/{uk-YlAX0rRU.js → uk-BWNCwGJO.js} +3 -3
- package/dist/assets/{useAppFontEffects-Cwyhjfl5.js → useAppFontEffects-cYK1WODe.js} +130 -130
- package/dist/assets/useGitComparison-DIetwQtj.js +1 -0
- package/dist/assets/{useInlineCommentController-DDkpBEU8.js → useInlineCommentController-DscFZWyI.js} +2 -2
- package/dist/assets/{useRootScrollLock-CwjoWuC4.js → useRootScrollLock-CE3HJBOu.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-Cb1YnICj.js → vendor-codemirror-language-data-CsvoASYk.js} +2 -2
- package/dist/assets/{vendor-remixicon-react-Dil0zKKT.js → vendor-remixicon-react-BDmGmFCA.js} +1 -1
- package/dist/assets/{web-components-LV3vjTxy.js → web-components-HM6S8xyb.js} +1 -1
- package/dist/assets/{zh-CN-DDYg0Jl7.js → zh-CN-CH6L_7cX.js} +6 -6
- package/dist/assets/{zh-TW-CQKaCayr.js → zh-TW--py9VFnc.js} +3 -3
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/lib/opencode/DOCUMENTATION.md +14 -0
- package/server/lib/opencode/openchamber-routes.js +72 -14
- package/server/lib/opencode/openchamber-routes.test.js +71 -3
- package/server/lib/opencode/settings-helpers.js +5 -0
- package/server/lib/opencode/settings-helpers.test.js +13 -1
- package/server/lib/opencode/settings-registry.json +3 -0
- package/dist/assets/SettingsView-ChWmAcZT.js +0 -28
- package/dist/assets/index-BD8ILbxF.js +0 -40
- package/dist/assets/index-zhgg-SDz.css +0 -1
- package/dist/assets/main-BydQ1tr_.js +0 -930
- package/dist/assets/markdownCore-Cb2MdZnV.js +0 -5
- package/dist/assets/renderMobileApp-BRP3J1iv.js +0 -25
- package/dist/assets/runtimeEndpointReset-BhT_-c52.js +0 -41
- package/dist/assets/useGitComparison-BCZVefdE.js +0 -1
|
@@ -0,0 +1,930 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-hmnM70S9.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-cYK1WODe.js","assets/index-BvwlOZOg.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-n5p3SnES.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-CsvoASYk.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-DHG-znZQ.js","assets/runtimeEndpointReset-DB4KI-ED.js","assets/VirtualizedFileDiff-C-MFNoKo.js","assets/web-components-HM6S8xyb.js","assets/computeVirtualFileMetrics-Bv64vrxY.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-B0pMS3gs.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-C51SEtjJ.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-DscFZWyI.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/useRootScrollLock-CE3HJBOu.js","assets/scheduledTasksApi-DZaxQ19y.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-BYwAHIlW.js","assets/useGitComparison-DIetwQtj.js","assets/FilesView-lrP5OlzK.js","assets/shikiHighlight-B1goMnV6.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-CqUi8Ytj.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-IXDeiXmH.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-pFeKzADY.js","assets/GitView-CCUK73JL.js","assets/DirtyBranchSwitchDialog-BeyJczAi.js","assets/LinearIssuesView-C0WwIDQN.js","assets/PlanView-k63mHfFF.js","assets/SettingsWindow-DFMJqIkx.js","assets/SettingsView-DNJXHPYC.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/OnboardingScreen-Cy6xZ-IQ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as et,R as c,j as s,r as gt,h as Hm}from"./vendor-react-BUCujlKS.js";import{E as bn,F as Wo,G as Gm,H as id,h as us,x as zo,u as Te,I as Et,J as Ha,K as qm,L as Pn,N as Qm,o as St,O as Ys,P as Vo,Q as ad,R as Ym,S as Xm,T as Jm,U as Zm,V as ld,A as fa,n as ss,W as Mn,X as $r,e as Nn,Y as ef,a as fs,Z as tf,_ as sf,$ as nf,a0 as cd,v as hn,B as Xs,a1 as rf,a2 as of,a3 as Ga,a4 as af,a5 as dd,a6 as lf,a7 as ud,f as cf,a8 as df,a9 as or,aa as ha,d as No,t as Rr,q as cs,ab as md,ac as uf,ad as mf,ae as wi,af as ff,ag as hf,i as pf,ah as mo,ai as fo,aj as gf,ak as qa,al as xf,am as bf,an as yf,ao as wf,ap as Qa,aq as Ya,ar as Xa,as as Ja,at as Sf,z as Za,au as vf,av as jf,aw as kf,C as Cf,D as Nf}from"./index-BvwlOZOg.js";import{_ as Bn}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as Nt,h as Ie,bc as Vt,I as E,g as gn,t as _e,ap as Js,bd as Os,ar as Zs,ao as en,R as Zn,Y as Sn,ae as er,be as _n,o as Uo,bf as el,bg as Af,bh as Df,a9 as At,aa as Dt,ab as Pt,b as Ht,y as Ze,G as Pf,bi as fd,bj as Jr,u as $s,A as pa,r as Ps,C as hd,bk as Si,bl as If,bm as pd,bn as gd,bo as xd,bp as ga,bq as Ko,br as bd,bs as yd,bt as Tf,bu as tl,bv as Rf,bw as Ef,bx as xa,by as vi,bz as Mf,bA as Of,N as wd,bB as Ff,l as Yt,bC as Bf,n as ar,bD as Sd,p as _f,bE as vd,bF as Lf,bG as $f,bH as Wf,bI as jd,bJ as kd,bK as zf,aE as ba,bL as qn,bM as qr,bN as Vf,bO as vs,bP as js,bQ as Ws,bR as Is,bS as Ts,bT as yn,B as xt,bU as dn,ax as Qs,bV as Uf,bW as Kf,aC as An,bX as ho,bY as qs,bZ as Ho,b_ as Cd,b$ as ji,c0 as ki,c1 as Ci,c2 as Hf,c3 as Fs,c4 as Bs,c5 as Ns,c6 as _s,c7 as ns,V as Cn,c8 as lr,c9 as sl,ca as ur,cb as Nd,Q as Go,af as Gf,ag as ya,ah as Ad,H as Dd,J as Dn,cc as qo,a4 as wa,cd as qf,ce as Qf,av as Yf,cf as Xf,cg as Jf,ch as Zf,aw as Sa,ci as Pd,cj as mr,ck as Id,cl as eh,cm as th,cn as Qr,co as sh,aK as Yr,cp as nh,cq as ir,O as Td,cr as rh,cs as oh,ct as Ln,cu as ih,cv as ah,az as lh,cw as ei,cx as Rd,cy as Ed,cz as ch,aD as Ni,cA as Ai,cB as dh,cC as nl,cD as Er,c as Wr,d as va,a0 as uh,cE as Md,cF as jr,cG as Mr,cH as mh,cI as fh,cJ as hh,Z as Od,ay as ph,cK as gh,cL as xh,cM as bh,cN as yh,cO as Fd,cP as xn,cQ as wh,cR as Bd,cS as Sh,cT as Di,cU as vh,cV as jh,cW as _d,cX as kh,cY as Ld,a2 as Ao,cZ as Pi,T as ja,S as ka,U as Ca,c_ as Na,a as Aa,a1 as Ch,c$ as rl,d0 as Ii,d1 as $d,d2 as Nh,aq as Wd,d3 as Ah,P as Ti,K as Dh,d4 as ol,d5 as Ph,d6 as il,d7 as Ih,d8 as Th,d9 as Rh,da as ds,db as Eh,dc as Fn,dd as Da,de as zd,df as Mh,dg as Vd,dh as Ud,di as Oh,D as Fh,dj as Bh,dk as _h,dl as Lh,dm as al,dn as $h,dp as Wh,dq as Kd,E as zh,dr as po,ds as Hd,dt as Vh,du as Uh,dv as Kh,dw as Hh,e as Gd,dx as Pa,dy as Gh,dz as zr,dA as qh,dB as ll,dC as Qh,dD as Yh,$ as Xh,dE as Jh,aW as cl,a6 as dl,a5 as ul,dF as Zh,aR as Ri,dG as ep,L as tp,M as ti,dH as sp,dI as np,dJ as qd,dK as Qd,dL as Yd,dM as rp,F as Ia,dN as op,a3 as ip,dO as ap,dP as lp,dQ as cp,dR as dp,dS as up,dT as mp,dU as fp,dV as hp,dW as Do,ai as pp,dX as gp,dY as ml,dZ as xp,d_ as bp,d$ as yp,e0 as wp,e1 as Po,e2 as Sp,e3 as fl,e4 as vp,e5 as jp,e6 as kp,e7 as Cp,e8 as Np,e9 as Ap,ea as go,eb as Dp,i as Pp,ec as Ip,ed as Tp,ee as Rp,ef as Ep,a7 as Mp,eg as Op,eh as Fp,ei as Bp,ej as _p,ek as hl,el as Lp,aL as $p,aM as Wp,aN as zp,aP as pl,aQ as gl,aT as xl,aU as bl,aS as Xd,aV as Jd,em as Vp,b7 as Up,b8 as Kp,b9 as Hp,ba as Gp,bb as qp,b1 as Qp,b3 as Yp,b4 as Xp,b5 as Jp,b6 as Zp}from"./useAppFontEffects-cYK1WODe.js";import{v as yl,w as si,x as un,y as Ei,z as wl,A as eg,E as tg,F as sg,G as ng,H as rg,I as og,J as ig,K as ag,L as Ta,M as lg,b as cg,c as Zd,U as eu,h as Mi,j as tu,Q as dg,i as ug,f as mg,R as su,V as Oi,W as Un,X as nu,Y as ru,P as fg,T as hg,Z as pg,_ as gg,$ as xg,a as ou,a0 as bg,S as Sl,r as yg,a1 as wg,a2 as iu,a3 as Sg,a4 as vg,u as Fr,s as jg,N as kg,D as Cg,a5 as Ng,a6 as vl,a7 as Ag,o as Dg,m as Pg,q as au,t as Ig,a8 as Tg,a9 as Rg,aa as Eg,l as Mg,n as Og,O as lu,C as Fg}from"./runtimeEndpointReset-DB4KI-ED.js";import{u as cu,S as jl,C as Bg,W as du,f as _g,a as Lg}from"./useRootScrollLock-CE3HJBOu.js";import{u as Wn,O as kl,D as $g,a as Wg,b as zg,n as Vg,f as Ug,c as Cl,s as Kg,d as Hg,e as Gg,r as qg}from"./scheduledTasksApi-DZaxQ19y.js";import{f as Vr,h as On,T as uu,M as mu,D as Ur,j as Kr,d as Qg,P as Fi,b as Yg,k as Bi,i as Xg}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Qo,S as Io,h as Jg,a as fu,v as _i,s as Zg}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Yo}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as hu,M as pu,C as gu,a as Li,b as $i,c as Wi,d as xu,e as ex,f as tx}from"./vendor-base-ui-BY_5qla_.js";import{c as tr,u as Jn,d as bu,p as sx}from"./vendor-zustand-BAGL70zf.js";import{g as nx,a as rx,E as yu,b as ox,c as ix,d as ax,e as lx,i as cx}from"./contextPanelEmbeddedChat-BdA6bdky.js";import{c as Ra,s as br,r as wu}from"./vendor-zod-B6551dwG.js";import{u as dx}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{d as Su}from"./vendor-cron-parser-CUcP7OfX.js";const ux="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",mx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",ni=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__AIWORKER_PLATFORM__==="darwin"?ux:t.id==="terminal"?mx:void 0}),Nl=t=>{const e=et.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 m;return e[6]!==u?(m=s.jsx("span",{className:h,children:u}),e[6]=u,e[7]=m):m=e[7],m},fx=t=>{const e=et.c(75),{directory:n,className:r}=t,{t:i}=Nt(),o=Wn(hx),l=Wn(px),a=Wn(gx),u=Wn(xx),d=Wn(bx),h=Wn(yx),m=Wn(wx);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(ie=>ie.id===o)??l.find(Sx)??l[0]??kl[0],e[3]=l,e[4]=o,e[5]=K):K=e[5];const he=K;if(he){let ie;e[6]!==he?(ie=ni(he),e[6]=he,e[7]=ie):ie=e[7],S=ie;break e}let be;e[8]===Symbol.for("react.memo_cache_sentinel")?(be=ni(kl[0]),e[8]=be):be=e[8],S=be}const x=S;if(!w||!n||l.length===0)return null;let f;e[9]!==n?(f=async K=>{await Gm(n,K.id,K.appName)||await id(n,K.appName)},e[9]=n,e[10]=f):f=e[10];const b=f;let y;e[11]!==b||e[12]!==m?(y=async K=>{await m(K.id),await b(K)},e[11]=b,e[12]=m,e[13]=y):y=e[13];const v=y;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await gn(n)).ok&&_e.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(Nl,{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(Js,{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(Vt,{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=he=>{const be=ni(he);return s.jsxs(Vt,{className:"flex items-center gap-2",onClick:()=>{v(he)},children:[s.jsx(Nl,{label:he.label,iconDataUrl:he.iconDataUrl,fallbackIconDataUrl:be.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:he.label}),x.id===he.id?s.jsx(E,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},he.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(Vt,{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 te;e[64]!==H||e[65]!==ce||e[66]!==Y?(te=s.jsxs(Zs,{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]=te):te=e[67];let se;e[68]!==R||e[69]!==te?(se=s.jsxs(en,{children:[R,te]}),e[68]=R,e[69]=te,e[70]=se):se=e[70];let ve;return e[71]!==O||e[72]!==se||e[73]!==k?(ve=s.jsxs("div",{className:k,children:[O,se]}),e[71]=O,e[72]=se,e[73]=k,e[74]=ve):ve=e[74],ve};function hx(t){return t.selectedAppId}function px(t){return t.availableApps}function gx(t){return t.isCacheStale}function xx(t){return t.isScanning}function bx(t){return t.initialize}function yx(t){return t.loadInstalledApps}function wx(t){return t.selectApp}function Sx(t){return t.id===$g}const To=new Map,zi=new Set,vu=()=>{for(const t of zi)t()},ri=(t,e)=>{const n=t.trim();n&&(e.length===0?To.delete(n):To.set(n,[...e]),vu())},vx=t=>{To.delete(t.trim())&&vu()},ju=[],jx=t=>To.get(t.trim())??ju,kx=t=>(zi.add(t),()=>{zi.delete(t)}),Cx=t=>{const e=et.c(2);let n;return e[0]!==t?(n=()=>jx(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(kx,n,Nx)};function Nx(){return ju}const Ax=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Dx=["dev","start","preview","serve"];async function Px(t,e,n){if(!t)return null;const r=Rx(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Ex(n);if(i){const o=await Mx(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 Ix(t)){const i=await Tx(),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 Ix(t){const e=`${t}/index.html`,n=await Ro(e,t);return typeof n=="string"&&n.trim().length>0}async function Tx(){try{const t=await us("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Rx(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Dx.some(i=>n.includes(i)))return e}return null}function Ex(t){for(const{pattern:e}of Ax)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Mx(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 us(`/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 us(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Ox(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 fn="__aiworker_auto_discover_preview__",Fx=15e3,Bx=3e3,oi=t=>t.id===fn?"scan-2":ag.find(n=>n.key===t.icon)?.Icon??"play",_x=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}},Lx=({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(),m=c.useMemo(()=>bn(),[]),p=yl(J=>J.instances),g=yl(J=>J.load),w=Te(J=>J.terminalShell),S=Te(J=>J.terminalLoginShells.includes(J.terminalShell)),x=Te(J=>J.setSettingsPage),f=Te(J=>J.setSettingsDialogOpen),b=Te(J=>J.setSettingsProjectsSelectedId),y=Te(J=>J.openContextPreview),v=Et(J=>J.ensureDirectory),N=Et(J=>J.reconcileServerSessions),C=Et(J=>J.setTabLabel),k=Et(J=>J.setTabIconKey),D=Et(J=>J.setActiveTab),P=Et(J=>J.setConnecting),I=Et(J=>J.setTabSessionId),M=Et(J=>J.setTabPurpose),_=Et(J=>J.allocateActionExecution),O=Et(J=>J.setTabLifecycle),U=Et(J=>J.setTabPreviewUrl),L=Et(J=>J.matchesActionExecution),F=Et(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({}),te=c.useRef({}),se=c.useRef(new Set),ve=c.useRef(0),[K,he]=c.useState({}),be=t?.id??null,ie=t?.path??"",T=c.useMemo(()=>be?{id:be,path:ie}:null,[be,ie]);c.useEffect(()=>{m&&g().catch(()=>{})},[m,g]);const Q=c.useCallback(async J=>{await Uo(J)},[]),le=c.useCallback(async()=>{if(!T)return;const J=ve.current+1;ve.current=J,Z(!0);try{const re=await el(T);if(ve.current!==J)return;A.current=re;const ke=re.projectActions;j(ke),X(Fe=>Fe===fn||Fe&&ke.some(Ue=>Ue.id===Fe)?Fe:null)}catch{if(ve.current!==J)return}finally{ve.current===J&&Z(!1)}},[T]),me=c.useMemo(()=>si(e||T?.path||""),[e,T?.path]),ue=c.useMemo(()=>si(T?.path||""),[T?.path]),Ce=c.useMemo(()=>si(d||"")||me,[d,me]),xe=c.useRef(Ce);c.useEffect(()=>{xe.current=Ce},[Ce]);const Re=Et(J=>me?J.getDirectoryState(me):void 0),we=Et(J=>ue&&ue!==me?J.getDirectoryState(ue):void 0),G=c.useMemo(()=>{const J=me?[{directory:me,state:Re}]:[];return ue&&ue!==me&&J.push({directory:ue,state:we}),J},[Re,me,ue,we]),Se=c.useMemo(()=>{const J=me?[me]:[];return ue&&ue!==me&&J.push(ue),J},[me,ue]),ge=c.useCallback(J=>J.id!==fn&&J.runIn==="parent"&&ue||me,[me,ue]),Ae=c.useCallback((J,re,ke)=>`${J}::${re}::${ke}`,[]),oe=c.useCallback((J,re,ke=Et.getState())=>J?ke.getDirectoryState(J)?.tabs.find(Fe=>Fe.purpose.type==="project-action"&&Fe.purpose.actionId===re)??null:null,[]),ne=c.useMemo(()=>{const J={};for(const{directory:re,state:ke}of G)for(const Fe of ke?.tabs??[]){if(Fe.purpose.type!=="project-action"||!Fe.purpose.executionId||!Fe.terminalSessionId||Fe.lifecycle==="idle"||Fe.lifecycle==="exited")continue;const Ue=un(re,Fe.purpose.actionId),st=Ae(re,Fe.purpose.actionId,Fe.purpose.executionId);J[Ue]={directory:re,actionId:Fe.purpose.actionId,tabId:Fe.id,sessionId:Fe.terminalSessionId,executionId:Fe.purpose.executionId,status:Fe.lifecycle==="stopping"?"stopping":K[st]?"waiting-for-preview":"running"}}return J},[Ae,K,G]),z=c.useCallback((J,re,ke)=>{const Fe=un(J,re),Ue=Ae(J,re,ke),it=ce.current[Fe]?.executionId===ke,rt=globalThis.window,qe=at=>{rt?.clearTimeout(te.current[at]),delete te.current[at]};it&&(delete ce.current[Fe],qe(Fe)),Y.current[Ue]?.(),delete Y.current[Ue],qe(Ue),he(at=>{if(!at[Ue])return at;const Oe={...at};return delete Oe[Ue],Oe})},[Ae]),$=c.useCallback(J=>{Y.current[J]?.(),delete Y.current[J]},[]),ae=c.useCallback(J=>{window.clearTimeout(te.current[J]),delete te.current[J]},[]);c.useEffect(()=>{const J=Y.current,re=te.current;return()=>{for(const ke of Object.keys(J))$(ke);for(const ke of Object.keys(re))ae(ke)}},[ae,$]),c.useEffect(()=>{const J=new Set(Se);for(const re of Object.values(ce.current))J.has(re.directory)||z(re.directory,re.actionId,re.executionId);for(const re of Object.keys(Y.current)){const ke=re.split("::",1)[0]??"";J.has(ke)||$(re)}},[z,$,Se]);const W=c.useCallback((J,re)=>{Te.getState().openContextPanelTab(J,{mode:"terminal",targetDirectory:re===J?null:re})},[]),je=c.useMemo(()=>B?R.find(J=>J.id===B)??null:null,[R,B]),Ee=c.useMemo(()=>({id:fn,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),Ne=!h,Be=c.useMemo(()=>Ne?[Ee,...R]:R,[R,Ee,Ne]);c.useEffect(()=>{le()},[le]),c.useEffect(()=>{const J=Se.map(re=>Ei(a,re,F,ke=>N(re,ke.sessions,{startedActionMutationRevisions:ke.startedActionMutationRevisions})));return()=>{for(const re of J)re()}},[F,N,a,Se]),c.useEffect(()=>{for(const{directory:J,state:re}of G)if(J)for(const ke of re?.tabs??[]){if(ke.purpose.type!=="project-action")continue;const Fe=ke.purpose.actionId,Ue=Be.find(rt=>rt.id===Fe),st=Ue?.name??Fe,it=Ue?.icon||"play";ke.label!==st&&C(J,ke.id,st),ke.iconKey!==it&&k(J,ke.id,it)}},[Be,k,C,G]),c.useEffect(()=>{const J=globalThis.window;if(!J)return;const re=ke=>{const Fe=ke.detail;be&&(Fe?.projectId&&Fe.projectId!==be||le())};return J.addEventListener(wl,re),()=>{J.removeEventListener(wl,re)}},[le,be]),c.useEffect(()=>{B&&(B===fn&&Ne||R.some(J=>J.id===B)||X(null))},[R,Ne,B]),c.useEffect(()=>{const J=ke=>{delete te.current[ke];const Fe=ce.current[ke];if(!Fe||Fe.openedUrl)return;const Ue=Ae(Fe.directory,Fe.actionId,Fe.executionId),st=Fe.announced;if(st.length!==0){if(window.clearTimeout(te.current[Ue]),delete te.current[Ue],Fe.openedUrl=!0,he(it=>{if(!it[Ue])return it;const rt={...it};return delete rt[Ue],rt}),st.length===1){ri(Fe.directory,[]),U(Fe.directory,Fe.tabId,st[0],{locked:!1,autoOpened:!0}),y(Fe.directory,st[0]);return}Fe.offering=!0,ri(Fe.directory,st),Te.getState().openContextSurface(Fe.directory,"browser"),_e.info(o("projectActions.toast.multipleServers"))}},re=()=>{const ke=Et.getState(),Fe=ke.sessions,Ue=ne;for(const[st,it]of Object.entries(Ue)){const qe=Fe.get(it.directory)?.tabs.find(yt=>yt.id===it.tabId);if(!qe||qe.terminalSessionId!==it.sessionId){z(it.directory,it.actionId,it.executionId);continue}const at=ce.current[st],Oe=at?.executionId===it.executionId?at:{hostDirectory:xe.current||it.directory,directory:it.directory,tabId:it.tabId,actionId:it.actionId,executionId:it.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ce.current[st]=Oe;const ye=Be.find(yt=>yt.id===it.actionId),mt=ke.getBuffer(it.directory,it.tabId).chunks;if(!ye||mt.length===0)continue;const bt=mt.filter(yt=>Oe.lastSeenChunkId===null||yt.id>Oe.lastSeenChunkId);if(bt.length===0)continue;const It=bt.map(yt=>yt.data).join(""),Je=`${Oe.tail}${It}`;if(Oe.openInPreview&&(!Oe.openedUrl||Oe.offering)){const yt=og(Je),Tt=Oe.announced.length;for(const Rt of yt)Oe.announced.includes(Rt)||Oe.announced.push(Rt);const Ct=Oe.announced.length-Tt;Oe.offering&&Ct>0?ri(it.directory,Oe.announced):!Oe.openedUrl&&Tt===0&&Oe.announced.length>0&&(window.clearTimeout(te.current[st]),te.current[st]=window.setTimeout(()=>J(st),Bx))}const lt=!Oe.openedUrl&&ye.autoOpenUrl===!0&&!Oe.openInPreview?ig(Je):null,vt=bt[bt.length-1]?.id??Oe.lastSeenChunkId;if(Oe.lastSeenChunkId=vt,Oe.tail=Je.slice(-512),lt)if(Oe.openedUrl=!0,Oe.openInPreview){const yt=Ue[st];yt&&(U(yt.directory,yt.tabId,lt,{locked:!1,autoOpened:!1,expectedExecutionId:yt.executionId}),yt.status==="waiting-for-preview"&&he(Tt=>{const Ct=Ae(yt.directory,yt.actionId,yt.executionId);if(!Tt[Ct])return Tt;const Rt={...Tt};return delete Rt[Ct],Rt}),window.clearTimeout(te.current[st]),delete te.current[st],y(yt.directory,lt))}else Q(lt),_e.success(o("projectActions.toast.openedUrlFromOutput"));ce.current[st]=Oe}for(const st of Object.keys(ce.current))if(!Ue[st]){const it=ce.current[st],rt=it?Fe.get(it.directory)?.tabs.find(at=>at.id===it.tabId):void 0;if(rt?.purpose.type==="project-action"&&rt.purpose.executionId===it?.executionId&&!!rt.terminalSessionId&&rt.lifecycle!=="idle"&&rt.lifecycle!=="exited")continue;delete ce.current[st],window.clearTimeout(te.current[st]),delete te.current[st]}};return re(),Et.subscribe((ke,Fe)=>{(ke.sessions!==Fe.sessions||ke.buffers!==Fe.buffers)&&re()})},[z,xe,Be,Ae,y,Q,ne,U,o]),c.useEffect(()=>{for(const{directory:J,state:re}of G)for(const ke of re?.tabs??[]){if(ke.purpose.type!=="project-action"||!ke.purpose.executionId||!ke.terminalSessionId||ke.lifecycle!=="running")continue;const Fe=ke.purpose.actionId,Ue=ke.purpose.executionId,st=Ae(J,Fe,Ue);if(Y.current[st])continue;const it=a.connect(ke.terminalSessionId,{onEvent:rt=>{if(!L(J,ke.id,Ue))return;rt.type==="snapshot"&&(Et.getState().replaceBuffer(J,ke.id,rt.data??"",rt.sequence??0,Ha(rt)),rt.status==="running"&&Et.getState().setTabLifecycle(J,ke.id,"running",{expectedExecutionId:Ue}),rt.status==="exited"&&(Et.getState().setTabLifecycle(J,ke.id,"exited",{expectedExecutionId:Ue}),Et.getState().setTabPurpose(J,ke.id,{type:"project-action",actionId:Fe,executionId:null}),z(J,Fe,Ue)));const qe=rt.type==="data"?rt.data??"":"";qe&&Et.getState().appendToBuffer(J,ke.id,qe,rt.sequence,rt.replayData),rt.type==="exit"&&(Et.getState().setTabLifecycle(J,ke.id,"exited",{expectedExecutionId:Ue}),Et.getState().setTabPurpose(J,ke.id,{type:"project-action",actionId:Fe,executionId:null}),z(J,Fe,Ue))},onError:(rt,qe)=>{!qe||!L(J,ke.id,Ue)||(Et.getState().setTabLifecycle(J,ke.id,"exited",{expectedExecutionId:Ue}),Et.getState().setTabSessionId(J,ke.id,null,{expectedExecutionId:Ue}),Et.getState().setTabPurpose(J,ke.id,{type:"project-action",actionId:Fe,executionId:null}),z(J,Fe,Ue))}});Y.current[st]=it.close}},[z,Ae,L,a,G]);const ze=c.useCallback(async J=>{const re=ge(J);if(!re)throw new Error(o("projectActions.error.noActiveDirectory"));const ke=un(re,J.id);v(re);const Fe=Et.getState(),Ue=oe(re,J.id,Fe),st=Ue?.id??Fe.createTab(re);C(re,st,J.name),k(re,st,J.icon||"play"),Ue||M(re,st,{type:"project-action",actionId:J.id,executionId:null}),D(re,st);const rt=Et.getState().getDirectoryState(re)?.tabs.find(qe=>qe.id===st);return{executionDirectory:re,key:ke,tabId:st,sessionId:rt?.terminalSessionId??null,executionId:rt?.purpose.type==="project-action"?rt.purpose.executionId:null}},[v,ge,oe,D,k,C,M,o]),We=c.useCallback(async J=>{if(u.isVSCode||!i&&h)return;if(!me){_e.error(o("projectActions.error.noActiveDirectoryForAction"));return}const re=un(ge(J),J.id),ke=ne[re];if(ke&&ke.status==="running"||se.current.has(re))return;se.current.add(re);let Fe=null;try{const Ue=J.id===fn?await(async()=>{const[Ct,Rt]=await Promise.all([Af({id:T?.id??"",path:me}),Ox(me)]),Bt=await Px(me,Ct.actions,Rt);if(!Bt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:fn,name:o("projectActions.actions.autoDiscover"),command:Bt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Bt.previewUrlHint||""}})():J,st=Ue.autoOpenUrl===!0&&(Ue.openUrl||"").trim().length>0,it=!st&&J.id!==fn,rt=xe.current||me,{executionDirectory:qe,key:at,tabId:Oe}=await ze(Ue),ye=eg(Ue.command);if(!ye)throw new Error(o("projectActions.error.failedToRunAction"));const mt=Ue.autoOpenUrl===!0&&m&&(Ue.desktopOpenSshForward||"").trim().length>0,bt=Ue.autoOpenUrl?_x(Ue.openUrl):null,It=Ue.autoOpenUrl&&m?tg(Ue.desktopOpenSshForward,p):null;if(a.listSessions){const Ct=oe(qe,Ue.id);if(Ct?.purpose.type==="project-action"&&Ct.purpose.executionId===null){const Rt=await sg(a,qe,{captureStartedActionMutationRevisions:F});Rt&&N(qe,Rt.sessions,{startedActionMutationRevisions:Rt.startedActionMutationRevisions})}}const Je=oe(qe,Ue.id);let lt,vt;if(Je?.lifecycle==="running"&&Je.terminalSessionId&&Je.purpose.type==="project-action"&&Je.purpose.executionId)lt=Je.terminalSessionId,vt=Je.purpose.executionId;else{const Ct=Je?.purpose.type==="project-action"?Je.purpose.executionId:null;Ct&&z(qe,Ue.id,Ct);const Rt=_(qe,Oe,Ue.id);if(!Rt)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));Fe={directory:qe,tabId:Oe,id:Rt},P(qe,Oe,!0,{expectedExecutionId:Rt});const Bt=await ng({terminal:a,createOptions:{cwd:qe,shell:w,loginShell:S,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:ye,isRunStillExpected:()=>L(qe,Oe,Rt),purpose:{type:"project-action",actionId:Ue.id,executionId:Rt}});if(!L(qe,Oe,Rt)){Bt.sessionId===Rt&&await a.close(Bt.sessionId).catch(()=>{});return}vt=Bt.purpose?.type==="project-action"?Bt.purpose.executionId:Rt,lt=Bt.sessionId,M(qe,Oe,{type:"project-action",actionId:Ue.id,executionId:vt}),I(qe,Oe,lt,{expectedExecutionId:vt}),P(qe,Oe,!1,{expectedExecutionId:vt})}it&&rt&&W(rt,qe),ce.current[at]={hostDirectory:rt,directory:qe,tabId:Oe,actionId:Ue.id,executionId:vt,lastSeenChunkId:null,openedUrl:!!It||!!bt||st,tail:"",openInPreview:Ue.id===fn,announced:[],offering:!1};const yt=Ae(qe,Ue.id,vt);P(qe,Oe,!0,{expectedExecutionId:vt});const Tt=a.connect(lt,{onEvent:Ct=>{if(!L(qe,Oe,vt)||Ct.purpose?.type==="project-action"&&Ct.purpose.executionId!==vt)return;Ct.type==="snapshot"&&(Et.getState().replaceBuffer(qe,Oe,Ct.data??"",Ct.sequence??0,Ha(Ct)),Et.getState().setConnecting(qe,Oe,!1,{expectedExecutionId:vt}),Ct.purpose?.type==="project-action"&&Et.getState().setTabPurpose(qe,Oe,{type:"project-action",actionId:Ct.purpose.actionId,executionId:Ct.purpose.executionId}),Ct.status==="running"&&Et.getState().setTabLifecycle(qe,Oe,"running",{expectedExecutionId:vt}),Ct.status==="exited"&&(Et.getState().setTabLifecycle(qe,Oe,"exited",{expectedExecutionId:vt}),Et.getState().setTabPurpose(qe,Oe,{type:"project-action",actionId:Ue.id,executionId:null}),z(qe,Ue.id,vt)));const Rt=Ct.type==="data"?Ct.data??"":"";Rt&&Et.getState().appendToBuffer(qe,Oe,Rt,Ct.sequence,Ct.replayData),Ct.type==="exit"&&(Et.getState().setTabLifecycle(qe,Oe,"exited",{expectedExecutionId:vt}),Et.getState().setConnecting(qe,Oe,!1,{expectedExecutionId:vt}),Et.getState().setTabPurpose(qe,Oe,{type:"project-action",actionId:Ue.id,executionId:null}),z(qe,Ue.id,vt))},onError:(Ct,Rt)=>{L(qe,Oe,vt)&&(Et.getState().setConnecting(qe,Oe,!1,{expectedExecutionId:vt}),Rt&&(Et.getState().setTabLifecycle(qe,Oe,"exited",{expectedExecutionId:vt}),Et.getState().setTabSessionId(qe,Oe,null,{expectedExecutionId:vt}),Et.getState().setTabPurpose(qe,Oe,{type:"project-action",actionId:Ue.id,executionId:null}),z(qe,Ue.id,vt)))}});if(!L(qe,Oe,vt)){Tt.close();return}Y.current[yt]?.(),Y.current[yt]=Tt.close,window.clearTimeout(te.current[yt]),delete te.current[yt],Ue.id===fn&&!bt&&(he(Ct=>({...Ct,[yt]:!0})),te.current[yt]=window.setTimeout(()=>{delete te.current[yt];const Ct=ce.current[at];!Ct||Ct.executionId!==vt||Ct.openedUrl||Ct.offering||L(qe,Oe,vt)&&(he(Rt=>{if(!Rt[yt])return Rt;const Bt={...Rt};return delete Bt[yt],Bt}),Et.getState().setActiveTab(qe,Oe),W(Ct.hostDirectory,qe))},Fx)),It?(U(qe,Oe,null,{locked:!0,expectedExecutionId:vt}),Q(It),_e.success(o("projectActions.toast.openedForwardedUrl"))):bt?(U(qe,Oe,bt,{locked:!0,autoOpened:!0,expectedExecutionId:vt}),y(rt,bt),_e.success(o("projectActions.toast.openedActionUrl"))):st?(U(qe,Oe,null,{locked:!0,expectedExecutionId:vt}),_e.error(o("projectActions.error.invalidCustomUrlFormat"))):mt?(U(qe,Oe,null,{locked:!0,expectedExecutionId:vt}),_e.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):U(qe,Oe,null,{locked:!1,autoOpened:!1,expectedExecutionId:vt})}catch(Ue){if(Fe&&L(Fe.directory,Fe.tabId,Fe.id)){const{directory:st,tabId:it,id:rt}=Fe;z(st,J.id,rt),O(st,it,"exited",{expectedExecutionId:rt}),M(st,it,{type:"project-action",actionId:J.id,executionId:null})}if(Ue instanceof Error&&Ue.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Ue instanceof Error&&(Ue.message==="COMMAND_MODE_UNSUPPORTED"||Ue.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){_e.error(o("projectActions.error.failedToCreateTerminalSession"));return}_e.error(Ue instanceof Error?Ue.message:o("projectActions.error.failedToRunAction"))}finally{se.current.delete(re)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,xe,p,ze,i,h,m,me,S,w,Q,y,ne,W,u.isVSCode,ge,L,z,Ae,oe,N,_,F,P,O,M,U,I,T?.id,o,a]),V=c.useCallback(async J=>{const re=un(ge(J),J.id),ke=ne[re];ke&&await rg({terminal:a,sessionId:ke.sessionId,isExecutionStillCurrent:()=>L(ke.directory,ke.tabId,ke.executionId),markStopping:()=>{O(ke.directory,ke.tabId,"stopping",{expectedExecutionId:ke.executionId})},restoreRunning:()=>{O(ke.directory,ke.tabId,"running",{expectedExecutionId:ke.executionId})},clearSession:()=>{I(ke.directory,ke.tabId,null,{expectedExecutionId:ke.executionId})},finalizeExit:()=>{O(ke.directory,ke.tabId,"exited",{expectedExecutionId:ke.executionId}),M(ke.directory,ke.tabId,{type:"project-action",actionId:ke.actionId,executionId:null}),z(ke.directory,ke.actionId,ke.executionId)}})},[z,ge,L,ne,O,M,I,a]),fe=c.useCallback(()=>{const J=je??Be[0];if(!J)return;const re=un(ge(J),J.id),ke=ne[re];if(ke?.status!=="stopping"){if(ke){V(J);return}We(J)}},[Be,ge,We,ne,je,V]),Me=c.useCallback(async J=>{if(J.source==="shared"&&T){const re=A.current?.trust.trusted?A.current:await el(T);if(A.current=re,!await Df(T,re))return;A.current={...re,trust:{...re.trust,trusted:!0}}}await We(J)},[We,T]),Pe=c.useCallback((J,re=!1)=>{if(X(J.id),!re){Me(J);return}const ke=un(ge(J),J.id),Fe=ne[ke];if(Fe?.status!=="stopping"){if(Fe){V(J);return}Me(J)}},[ge,Me,ne,V]),ot=c.useCallback(()=>{T?.id&&(b(T.id),x("projects"),f(!0))},[f,x,b,T?.id]),Ke=je??Be[0]??null,ht=Ke?ne[un(ge(Ke),Ke.id)]:null,ft=Et(J=>ht?J.getDirectoryState(ht.directory)?.tabs.find(re=>re.id===ht.tabId)?.previewUrl??null:null);if(u.isVSCode||!i&&h||!T||!me)return null;const kt=je??Be[0]??null;if(!kt)return null;const pe=oi(kt),Ye=un(ge(kt),kt.id),wt=ne[Ye],jt=wt?.status==="stopping",de=wt?.status==="waiting-for-preview",Ve=!!(wt&&ft),ct=()=>{!wt||!ft||y(wt.directory,ft)},Le=kt.id===fn;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:fe,"aria-label":wt?o("projectActions.actions.stopNamedAria",{name:kt.name}):o("projectActions.actions.runNamedAria",{name:kt.name}),children:jt||de?s.jsx(E,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):wt?s.jsx(E,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(E,{name:pe,className:"h-5 w-5"})})}),Le?s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ve?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:ct,children:s.jsx(E,{name:"global",className:"h-4 w-4"})})}),s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(en,{children:[s.jsx(Js,{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(Zs,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Vt,{className:"flex items-center gap-2",onClick:ot,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,{}),Be.map(J=>{const re=oi(J),ke=un(ge(J),J.id),Fe=ne[ke],Ue=!!Fe,st=Fe?.status==="stopping";return s.jsxs(Vt,{className:"flex items-center gap-2",onClick:()=>{Pe(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,st||Fe?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ue?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:fe,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":wt?o("projectActions.actions.stopNamedAria",{name:kt.name}):o("projectActions.actions.runNamedAria",{name:kt.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:jt||de?s.jsx(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):wt?s.jsx(E,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(E,{name:pe,className:"h-4 w-4"})})})}),Le?s.jsx(Pt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ve?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ct,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(en,{children:[s.jsx(Js,{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(Zs,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Vt,{className:"flex items-center gap-2",onClick:ot,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,{}),Be.map(J=>{const re=oi(J),ke=un(ge(J),J.id),Fe=ne[ke],Ue=!!Fe,st=Fe?.status==="stopping";return s.jsxs(Vt,{className:"flex items-center gap-2",onClick:()=>{Pe(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,st||Fe?.status==="waiting-for-preview"?s.jsx(E,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ue?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(/\/+$/,"")},$x=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Or(n??"");if(i){const o=fd(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function Wx(){const t=Ht(w=>w.projects),e=Ht(w=>w.activeProjectId),n=Ze(w=>w.availableWorktreesByProject),r=Ze(w=>w.currentSessionId),i=Pf(r??null),o=Ze(w=>r?w.worktreeMetadata.get(r)?.path??"":""),l=Ze(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(()=>$x({projects:t,worktreesByProject:n,directory:d,activeProjectId:e}),[e,d,t,n]),m=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&&m&&(g.current={projectRef:p,directory:m})},[m,p]),c.useMemo(()=>p&&m?{projectRef:p,directory:m}:g.current,[p,m])}const zx=({transform:t})=>({...t,y:0}),Vx={Item:Vt,Separator:Os},Ux={Item:({className:t,...e})=>s.jsx(pu,{className:Ie(gd,t),...e}),Separator:({className:t,...e})=>s.jsx(hu,{className:Ie(pd,t),...e})},Kx=t=>{const e=et.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:u,onMenuOpenChangeComplete:d,children:h}=t,{t:m}=Nt(),[p,g]=c.useState(!1),[w,S]=c.useState(!1),[x,f]=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]!==m||e[3]!==n.session.title?(P=n.session.title?.trim()||m("sessions.sidebar.session.untitled"),e[2]=m,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=Ps(n.session),e[5]=n.session,e[6]=U):U=e[6];const L=Ta(O,U),F=_?.type==="busy"||_?.type==="retry",j=hd(n.id)>0&&!r&&!F,A=F||j;let B;e[7]!==F||e[8]!==m?(B=m(F?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=F,e[8]=m,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=Ce=>({session:n.session,open:p||x,isActive:r,select:()=>o(n),closeOtherTabs:()=>u(n.id),components:Ce}),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 te=D&&"z-10 opacity-60";let se;e[22]!==te?(se=Ie("session-tab-slot flex h-7 w-44 shrink-0 touch-none",te),e[22]=te,e[23]=se):se=e[23];const ve=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 he;e[26]!==d?(he=Ce=>d?.(Ce),e[26]=d,e[27]=he):he=e[27];let be;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]!==m||e[43]!==n||e[44]!==I?(be=s.jsx(gu,{render:Ce=>s.jsxs("div",{...Ce,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:xe=>{(xe.key==="Enter"||xe.key===" ")&&(xe.preventDefault(),o(n))},onAuxClick:xe=>{xe.button===1&&(xe.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":m("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:Gx,onPointerDown:qx,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(en,{open:p,onOpenChange:xe=>{g(xe),xe&&S(!0)},onOpenChangeComplete:xe=>{xe||S(!1),d?.(xe)},children:[s.jsx(Js,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":m("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(Zs,{align:"start",className:"min-w-[190px]",children:a(Z(Vx))})]}),s.jsx("button",{type:"button","aria-label":m("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]=m,e[43]=n,e[44]=I,e[45]=be):be=e[45];let ie,T;e[46]===Symbol.for("react.memo_cache_sentinel")?(ie={color:"var(--surface-elevated-foreground)"},T=Ie(Si,"min-w-[190px]"),e[46]=ie,e[47]=T):(ie=e[46],T=e[47]);let Q;e[48]!==Z||e[49]!==a?(Q=a(Z(Ux)),e[48]=Z,e[49]=a,e[50]=Q):Q=e[50];let le;e[51]!==Q?(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:ie,className:T,children:Q})})}),e[51]=Q,e[52]=le):le=e[52];let me;e[53]!==x||e[54]!==he||e[55]!==be||e[56]!==le?(me=s.jsxs(xu,{open:x,onOpenChange:f,onOpenChangeComplete:he,children:[be,le]}),e[53]=x,e[54]=he,e[55]=be,e[56]=le,e[57]=me):me=e[57];let ue;return e[58]!==y||e[59]!==v||e[60]!==N||e[61]!==se||e[62]!==ve||e[63]!==K||e[64]!==me||e[65]!==Y?(ue=s.jsx("div",{ref:N,style:Y,className:se,"data-active":ve,...K,...y,...v,children:me}),e[58]=y,e[59]=v,e[60]=N,e[61]=se,e[62]=ve,e[63]=K,e[64]=me,e[65]=Y,e[66]=ue):ue=e[66],ue},Hx=t=>{const e=et.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=Nt(),u=Jr(Qx),d=Jr(Yx),h=Jr(Xx),m=Jr(Jx),p=Ze(Zx),g=Ze(eb),w=$s(tb);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 f;if(e[4]!==w){f=new Map;for(const xe of w)f.set(xe.id,xe);e[4]=w,e[5]=f}else f=e[5];const b=f;let y;if(e[6]!==b||e[7]!==u){y=[];for(const xe of u){const Re=b.get(xe);Re&&y.push({id:xe,session:Re})}e[6]=b,e[7]=u,e[8]=y}else y=e[8];const v=y;let N;e[9]!==g?(N=xe=>{g(xe.id,Ps(xe.session))},e[9]=g,e[10]=N):N=e[10];const C=N,k=sb;let D;e[11]!==h||e[12]!==p||e[13]!==C||e[14]!==v?(D=xe=>{if(h(xe),p&&p!==xe){const Re=v.find(we=>we.id===xe);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(mu,I),On(uu,M));let O;e[18]!==m?(O=xe=>{const{active:Re,over:we}=xe;we&&Re.id!==we.id&&m(String(Re.id),String(we.id))},e[18]=m,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 xe=L.current;if(!xe)return;const Re=xe.scrollLeft>2,we=xe.scrollLeft+xe.clientWidth<xe.scrollWidth-2;j(G=>G.left===Re&&G.right===we?G:{left:Re,right:we})},e[21]=A):A=e[21];const B=A;let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{B();const xe=L.current;if(!xe||!globalThis.ResizeObserver)return;const Re=new ResizeObserver(B);return Re.observe(xe),()=>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 te;e[28]!==v?(te=v.map(nb),e[28]=v,e[29]=te):te=e[29];const se=te;let ve;e[30]!==p||e[31]!==v?(ve=!p||!v.some(xe=>xe.id===p),e[30]=p,e[31]=v,e[32]=ve):ve=e[32];const K=ve;let he;e[33]!==a?(he=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=he):he=e[34];let be;e[35]!==Y?(be=Y?{maskImage:Y,WebkitMaskImage:Y}:void 0,e[35]=Y,e[36]=be):be=e[36];let ie;e[37]===Symbol.for("react.memo_cache_sentinel")?(ie=[zx],e[37]=ie):ie=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(xe=>s.jsx(Kx,{tab:xe,isActive:xe.id===p,suppressControls:xe.id===p&&l,onSelect:C,onClose:k,renderMenu:n,closeOtherTabs:P,onMenuOpenChangeComplete:r,children:xe.id===p?o:null},xe.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 Q;e[47]!==T||e[48]!==se?(Q=s.jsx(Io,{items:se,strategy:Jg,children:T}),e[47]=T,e[48]=se,e[49]=Q):Q=e[49];let le;e[50]!==U||e[51]!==_||e[52]!==Q?(le=s.jsx(Ur,{sensors:_,collisionDetection:Kr,modifiers:ie,onDragEnd:U,children:Q}),e[50]=U,e[51]=_,e[52]=Q,e[53]=le):le=e[53];let me;e[54]!==o||e[55]!==K?(me=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]=me):me=e[56];let ue;e[57]!==be||e[58]!==le||e[59]!==me?(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:be,children:[le,me]}),e[57]=be,e[58]=le,e[59]=me,e[60]=ue):ue=e[60];let Ce;return e[61]!==he||e[62]!==ue?(Ce=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":he,children:ue}),e[61]=he,e[62]=ue,e[63]=Ce):Ce=e[63],Ce};function Gx(t){return t.stopPropagation()}function qx(t){return t.stopPropagation()}function Qx(t){return t.tabIds}function Yx(t){return t.ensureTab}function Xx(t){return t.closeOtherTabs}function Jx(t){return t.reorderTabs}function Zx(t){return t.currentSessionId}function eb(t){return t.setCurrentSession}function tb(t){return t.activeSessions}function sb(t){If(t)}function nb(t){return t.id}function rb(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 ob(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 ib(t){const e=t.info.role==="user"?"User":"Assistant",n=rb(t.info.time?.created),r=ob(t),i=n&&r?`${n} (${r})`:n||r;return i?`**${e}**
|
|
3
|
+
|
|
4
|
+
*${i}*`:`**${e}**`}function ku(t){const e=ib(t),n=lg(t.parts,{user:t.info.role==="user"});return n?`${e}
|
|
5
|
+
|
|
6
|
+
${n}`:""}function Cu(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(ku).filter(Boolean).join(`
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
`),l=[i+o];for(const a of t.children)l.push(Cu(a,e+1));return l.join(`
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
`)}function Nu(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(ku).filter(Boolean).join(`
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
`);let a=o+l;if(n&&n.length>0){const u=n.map(d=>Cu(d,1)).join(`
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
`);a+=`
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
`+u}return a}function Au(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 Du(t,e){const n=await qm(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 ab(t){const e=zo()?.files;if(e?.revealPath)try{return!!(await e.revealPath(t))?.success}catch{return!1}return await Qm(t)?!0:id(t)}function lb(){return xd()}function Pu(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=et.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=Nt(),{pending:a,disabled:u,hint:d,run:h}=cg(n,r,i),m=a?"loader-4":"ai-generate-2",p=a?"mr-2 size-4 animate-spin":"mr-2 size-4";let g;e[0]!==m||e[1]!==p?(g=s.jsx(E,{name:m,className:p}),e[0]=m,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 f;return e[13]!==S||e[14]!==x?(f=s.jsxs(At,{children:[S,x]}),e[13]=S,e[14]=x,e[15]=f):f=e[15],f}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})),Iu=t=>{const e=et.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)},cb=()=>$n(yb),Tu=()=>$n.getState().confirmation,Ea=t=>{$n.setState(e=>e.confirmation===t?e:{...e,confirmation:t})},Al=(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}})},db="Unable to apply your changes in the destination directory",ub=t=>t.status===400&&t.message.includes(db),mb=async(t,e)=>{try{const u=(await bd(t,{mode:"light"})).current?.trim();if(u)return u}catch{}const n=St(t),r=St(e)??e,i=Ze.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>St(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},Dl=t=>{for(const e of t){const n=Rf(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class Ru extends Error{changesMayBeInDestination;constructor(e,n,r){super(e,{cause:n}),this.name="IncompleteRollbackError",this.changesMayBeInDestination=r}}const fb=(t,e,n)=>{const r=e.map(({sessionId:i,error:o})=>`${i}: ${o.message}`).join(", ");return new Ru(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${r}`,{moveError:t,rollbackFailures:e},n)},hb=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(Ef(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await yd(o,n,e,!1),Ze.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 Eu extends Error{constructor(e){super(e.message,{cause:e}),this.name="ChangesMayBeInDestinationError"}}const Pl=async(t,e,n)=>{try{await wd(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},Il=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)}},Mu=async(t,e)=>{if($n.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Al(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,Ze.getState().getWorktreeMetadata(a.id)]));Dl(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,u]of n.entries()){Dl(n.slice(a));const d=u.id===t.root.id&&t.moveChanges;try{await yd(u,t.sourceDirectory,i.directory,d)}catch(h){throw d&&Tf(h)&&(l=!0),h}o.push(u),u.id!==t.root.id&&Ze.getState().setWorktreeMetadata(u.id,tl(i.metadata))}}catch(a){const u=a instanceof Error?a:new Error(String(a)),d=await hb(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await Il(t.sourceDirectory,i?.directory),d.length>0)throw fb(u,d,l);if(l)throw new Eu(u);if(i?.onMoveFailure)return i.onMoveFailure(u);throw u}return Ze.getState().setWorktreeMetadata(t.root.id,tl(i.metadata)),await Il(t.sourceDirectory,i.directory),i.directory}finally{Al(t.root.id,!1)}},pb=async t=>{const e=St(t.sourceDirectory)??t.sourceDirectory,n=St(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 Mu(t,async()=>({directory:t.destination.path,metadata:t.destination}))},gb=async t=>Mu(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 mb(t.sourceDirectory,e.path):null,r=await Mf(e,n?{startRef:n}:{});try{await Of(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return Pl(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>Pl(e,r,i)}}),xb=(t,e,n)=>e instanceof Eu?t.changesMayBeInDestination:e instanceof Ru&&e.changesMayBeInDestination?`${e.message} ${t.changesMayBeInDestination}`:n&&ub(e)?t.applyChangesFailed:e.message,Ki=(t,e)=>{(t.kind==="existing"?pb({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination,moveChanges:e}):gb({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,moveChanges:e})).then(()=>_e.success(t.messages.success)).catch(r=>{const i=r instanceof Error?r:new Error(String(r));_e.error(t.messages.failure,{description:xb(t.messages,i,e)})})},bb=()=>{const t=Tu();t&&(cr(t.intent.root.id,!1),Ea(null))},Ou=t=>{const e=Tu();if(!e)return;const{intent:n}=e;Ea(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 bd(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;Ea({intent:t,dirtyFileCount:r.files.length,stagedFileCount:i})}catch{_e.error(t.messages.failure,{description:t.messages.sourceVerificationFailed}),cr(t.root.id,!1)}})())};function yb(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",wb=c.memo(function(e){const n=et.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:u,iconClassName:d,pressed:h}=e,m=r===void 0?!0:r,p=h===void 0?!1:h;if(!m)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 f;n[3]!==u||n[4]!==x?(f=s.jsx(E,{name:u,className:x}),n[3]=u,n[4]=x,n[5]=f):f=n[5];let b;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==S||n[10]!==f?(b=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:S,children:f})}),n[6]=o,n[7]=l,n[8]=p,n[9]=S,n[10]=f,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}),Sb=c.memo(function(e){const n=et.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:u,shortcutLabel:d,remoteUpdateInfo:h,remoteUpdateChecking:m,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 f=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let b;n[7]!==f?(b=Ie(Eo,f),n[7]=f,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(Js,{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]!==m||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||""}):m?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(Ff,{embedded:!0,open:l,onOpenChange:kb,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=g,n[30]=m,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(Zs,{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(en,{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}),vb=(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(/\/+$/,"")},Tl=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,jb=()=>{Ys("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=Yt(q=>q.getCurrentModel),a=Ze(q=>q.getContextUsage),u=Ze(q=>!!q.newSessionDraft?.open),d=Ze(q=>q.currentSessionId),h=Bf(d??""),m=pa(d??""),p=Iu(d??""),g=$s(Jn(c.useCallback(q=>{if(!d)return null;const Qe=[...q.activeSessions,...q.archivedSessions].find(pt=>pt.id===d);if(!Qe)return null;const nt=Qe;return{title:Qe.title??null,directory:nt.directory??null,created:Qe.time?.created??null,slug:nt.slug??null,shareUrl:Qe.share?.url??null,parentId:Qe.parentID??null}},[d]))),w=Ht(Jn(q=>{if(!q.activeProjectId)return null;const Qe=q.projects.find(nt=>nt.id===q.activeProjectId);return Qe?{id:Qe.id,path:Qe.path,label:Qe.label}:null})),S=c.useMemo(()=>{if(!w)return null;const q=w.label?.trim();if(q)return q;const Qe=w.path.split(/[\\/]/).filter(Boolean);return Qe[Qe.length-1]??null},[w]),x=ar(q=>q.loadSettings),{isMobile:f}=_n(),b=c.useRef(null),[y,v]=c.useState(()=>typeof window>"u"?!1:bn()),N=c.useMemo(()=>Vo(),[]),C=Sd(),[k,D]=c.useState(!1),P=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:I,side:M}=cu(),_=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 Qe=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Qe)return null;const nt=Number.parseInt(Qe[1],10),pt=Number.parseInt(Qe[2],10);return Number.isNaN(nt)?null:nt===10?pt:nt},[]);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=>vb(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,te]=c.useState(!0),[se,ve]=c.useState(!1),[K,he]=c.useState(null),[be,ie]=c.useState(!1),[T,Q]=c.useState(null),le=c.useMemo(()=>Pn(),[]),me=Te(q=>q.workStatusPanelVisible),ue=Te(q=>q.workStatusPanelEnabled),Ce=Te(q=>q.setWorkStatusPanelEnabled),xe=Te(q=>q.workStatusPanelFits),Re=Te(q=>q.workStatusOverlayOpen),we=Te(q=>q.setWorkStatusOverlayOpen),Se=ue&&xe||Re,ge=c.useCallback(()=>{if(ue&&!xe){we(!Re);return}Ce(!ue)},[we,Ce,Re,ue,xe]),Ae=!le&&!me&&!!j&&j.totalTokens>0,oe=j&&j.contextLimit>0?Math.min(999,j.totalTokens/j.contextLimit*100):0,ne=c.useCallback(async()=>{if(!(typeof window>"u"||!y))try{if(Wo()){ce("Local"),te(!0);return}te(!1);const q=await ad(),Qe=Ym(),nt=Xm([Jm(Qe),...q.hosts]);if(nt.id===Zm){ce("Local"),te(!0);return}ce(ld(nt.label.trim()||"Instance"))}catch{ce("Local"),te(!0)}},[y]);gt.useEffect(()=>(ne(),fa(()=>{ne()})),[ne]);const z=c.useCallback(async()=>{if(Y){he(null),Q(null);return}ie(!0),Q(null);try{const q=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Qe=await us(`/api/openchamber/update-check?${q.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Qe.ok)throw new Error(`Server responded with ${Qe.status}`);const nt=await Qe.json();he({available:nt.available??!1,version:nt.version,currentVersion:nt.currentVersion??"unknown",body:nt.body,nextSuggestedCheckInSec:typeof nt.nextSuggestedCheckInSec=="number"?nt.nextSuggestedCheckInSec:void 0,packageManager:nt.packageManager,updateCommand:nt.updateCommand})}catch(q){he(null),Q(q instanceof Error?q.message:t("header.services.remoteUpdate.error"))}finally{ie(!1)}},[Y,t]);c.useEffect(()=>{he(null),Q(null),ve(!1)},[Y,Z]),c.useEffect(()=>{if(!y||Y)return;const q=3e3,Qe=3600*1e3;let nt=!1,pt=null;const zt=as=>{pt=window.setTimeout(()=>{if(nt||typeof document<"u"&&document.visibilityState!=="visible"){zt(Qe);return}z().finally(()=>{nt||zt(Qe)})},as)};return zt(q),()=>{nt=!0,pt!==null&&window.clearTimeout(pt)}},[z,Y,Z,y]);const $=c.useCallback(()=>{if(K?.available){ve(!0);return}z()},[z,K?.available]);_f(),c.useEffect(()=>{x()},[x]);const ae=d?g??null:null,W=c.useRef(null),[je,Ee]=c.useState(0);c.useEffect(()=>{if(!d){W.current&&(W.current=null,Ee(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 Qe=q.expiresAt-Date.now();if(Qe<=0){W.current=null,Ee(pt=>pt+1);return}const nt=window.setTimeout(()=>{W.current?.sessionId===d&&(W.current=null),Ee(pt=>pt+1)},Qe);return()=>{window.clearTimeout(nt)}},[d,ae]);const Ne=(()=>{if(ae)return ae;if(!d)return null;const q=W.current;return q&&q.sessionId===d&&q.expiresAt>Date.now()?q.session:null})(),Be=Ze(q=>d?q.worktreeMetadata.get(d)?.path??"":""),ze=Ze(q=>d?q.worktreeMetadata.get(d)?.branch?.trim()??null:null),We=vd(q=>d?q.getAttachment(d):void 0),V=c.useMemo(()=>We?Lf(We,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,We]),fe=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]),Me=c.useMemo(()=>vn(Be||""),[Be]),Pe=c.useMemo(()=>{const q=typeof Ne?.directory=="string"?Ne.directory:"";return vn(q||"")},[Ne?.directory]),ot=Ta(d??"",Pe),Ke=Ze(q=>q.newSessionDraft?.open?vn(q.newSessionDraft.bootstrapPendingDirectory??q.newSessionDraft.directoryOverride??""):""),ht=Ze(q=>q.newSessionDraft.target),ft=Ze(q=>q.newSessionDraft.selectedProjectId),kt=Ze(q=>q.currentSessionDirectory),pe=ss(q=>q.homeDirectory),Ye=c.useMemo(()=>Me||Pe||Ke,[Ke,Pe,Me]),wt=Te(c.useCallback(q=>{const Qe=vn(Ye||"");return Qe?Tl(q.contextPanelByDirectory[Qe]):null},[Ye])),jt=Ze(q=>{const Qe=vn(Me||Pe||"");if(!Qe)return null;for(const nt of q.availableWorktreesByProject.values()){const zt=nt.find(as=>vn(as.path)===Qe)?.branch?.trim();if(zt)return zt}return null}),Ve=$f(Ye||null)||ze||jt,ct=u?ht==="chat":Wf(Pe||kt,pe),Le=!ct&&!me&&!!(S||Ve||!u&&fe),J=c.useMemo(()=>{if(!d)return S??"AiWorker";const q=Ne?.title?.trim();return q&&q.length>0?q:"Untitled Session"},[S,Ne?.title,d]),re=jd(Ye||void 0,{bootstrap:!1}),ke=kd(),Fe=Ze(q=>q.updateSessionTitle),Ue=Ze(q=>q.shareSession),st=Ze(q=>q.unshareSession),it=Ze(q=>q.archiveSessions),rt=Ze(q=>q.deleteSessions),[qe,at]=c.useState(!1),[Oe,ye]=c.useState(!1),mt=c.useRef(null),[bt,It]=c.useState(""),[Je,lt]=c.useState(null),vt=c.useRef(null),yt=c.useCallback(()=>{d&&(It(Ne?.title?.trim()||J),at(!0))},[Ne?.title,d,J]),Tt=c.useRef(yt);Tt.current=yt;const Ct=c.useCallback(q=>{q&&(q.focus(),q.select())},[]);c.useEffect(()=>{if(ye(!1),lt(null),d&&mt.current===d){mt.current=null,Tt.current();return}at(!1),It("")},[d]);const Rt=c.useCallback(async()=>{if(!d)return;const q=bt.trim();q&&q!==Ne?.title?.trim()&&await Fe(d,q),at(!1)},[Ne?.title,d,bt,Fe]);c.useEffect(()=>{if(!qe)return;const q=Qe=>{const nt=Qe.target;(!nt||!vt.current?.contains(nt))&&Rt()};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[qe,Rt]);const Bt=c.useCallback(q=>{q&&gn(q).then(Qe=>{_e[Qe.ok?"success":"error"](t(Qe.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(t("sessions.sidebar.session.copyId.error")))},[t]),Gt=c.useCallback(async q=>{if(!q)return;const Qe=await Ue(q);if(Qe?.share?.url){const nt=await gn(Qe.share.url);_e[nt.ok?"success":"warning"](t("sessions.sidebar.session.share.successTitle"),{description:t(nt.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}_e.error(t("sessions.sidebar.session.share.error"))},[Ue,t]),qt=c.useCallback(q=>{q&&gn(q).then(Qe=>{_e[Qe.ok?"success":"error"](t(Qe.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>_e.error(t("sessions.sidebar.session.share.copyUrlError")))},[t]),Ut=c.useCallback(async q=>{if(!q)return;const Qe=await st(q);_e[Qe?"success":"error"](t(Qe?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[t,st]),Wt=c.useCallback(async()=>{if(!d||!Ye){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}try{await ke.loadCompleteHistory(d,Ye)}catch{_e.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}const q=zf(re.getState(),d).list;if(q.length===0){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Qe=Nu(q,Ne?.title??null),nt=Pu(Ne?.title??null);await Du(Qe,nt)||Au(Qe,nt),_e.success(t("sessions.sidebar.session.export.success"))},[Ne?.title,d,re,Ye,ke,t]),Ft=m?.type==="busy"||m?.type==="retry",Kt=c.useCallback(()=>{if(!d||!Pe||Ft||p)return;const q=$s.getState().activeSessions,Qe=q.find(zt=>zt.id===d);if(!Qe)return;const nt=[],pt=[d];for(let zt=0;zt<pt.length;zt+=1){const as=pt[zt];for(const Lt of q)Lt.parentID===as&&(nt.push(Lt),pt.push(Lt.id))}Hi({kind:"quick",root:Qe,descendants:nt,sourceDirectory:Pe,messages:Ui(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Ft,p,Pe,t]),$e=c.useCallback(async()=>{if(!Je)return;const q=Je.action,Qe=[Je.sessionId,...Zd(Je.sessionId,[],q==="delete")];if(lt(null),(q==="archive"?await it(Qe):await rt(Qe)).failedIds.length>0){_e.error(t(q==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}_e.success(t(q==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[it,rt,Je,t]),Xe=Te(q=>q.isScheduledTasksDialogOpen),ut=Te(q=>q.isArchivePageOpen),dt=Te(q=>q.worktreesPageProjectId),Ge=Te(q=>q.isMultiRunLauncherOpen),_t=Ht(q=>{if(!dt)return null;const Qe=q.projects.find(nt=>nt.id===dt);return Qe?.label?.trim()||Qe?.path?.split("/").pop()||null}),Qt=c.useMemo(()=>Xe?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:ut?{title:t("sessions.archivePage.title"),subtitle:null}:dt?{title:t("sessions.worktreesPage.title",{project:_t??""}),subtitle:null}:Ge?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[ut,Ge,Xe,t,dt,_t]),Zt=c.useMemo(()=>vn(Ye||w?.path||""),[w?.path,Ye]),rs=Wx(),es=ba(q=>q.planModeEnabled),zs=Ze(q=>q.isSessionPlanAvailable),ys=es&&d?zs(d):!1,Rs=c.useRef("");c.useEffect(()=>{if(!es||!d)return;const q=`${d||"none"}:${Pe||"none"}:${Ne?.created||0}:${Ne?.slug||"none"}`;Rs.current!==q&&(Rs.current=q)},[es,ys,Ne?.slug,Ne?.created,d,Pe]);const is=c.useCallback(()=>{Mn("desktop_open_draft_mini_chat_window",{directory:ct?"":Ke,projectId:ct?null:ft,apiBaseUrl:Nn(),clientToken:$r()}).catch(q=>{console.warn("[header] failed to open draft mini chat window",q)})},[Ke,ft,ct]),Vs=c.useCallback(()=>{if(u){is();return}d&&Mn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Pe||vn(kt||"")||Me,apiBaseUrl:Nn(),clientToken:$r()}).catch(q=>{console.warn("[header] failed to open session mini chat window",q)})},[d,is,u,kt,Pe,Me]),Us=c.useCallback(()=>{const q=vn(Ye||"");if(!q)return;const Qe=Te.getState().contextPanelByDirectory[q];if(Tl(Qe)==="context"){r(q);return}n(q)},[r,n,Ye]),As=wt==="context",hs=Eo,Ds=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",Ds)},[Ds]);const Ks=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Hs=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";gt.useEffect(()=>{if(!y||!P){D(!1);return}let q=!1;const Qe=async()=>{try{const pt=await Mn("desktop_is_window_fullscreen");q||D(pt===!0)}catch{q||D(!1)}},nt=()=>{Qe()};return Qe(),window.addEventListener("aiworker:window-resized",nt),()=>{q=!0,window.removeEventListener("aiworker:window-resized",nt)}},[y,P]);const ks=c.useMemo(()=>!y||!P||_===null?"":_>=26?"h-12":_<=15?"h-14":"",[y,P,_]),tn=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]),Mt=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;Mt();const q=b.current;if(!q||typeof ResizeObserver>"u")return()=>{};let Qe=0;const nt=()=>{Qe||(Qe=requestAnimationFrame(()=>{Qe=0,Mt()}))},pt=new ResizeObserver(nt);return pt.observe(q),window.addEventListener("resize",nt),window.addEventListener("orientationchange",nt),()=>{Qe&&cancelAnimationFrame(Qe),pt.disconnect(),window.removeEventListener("resize",nt),window.removeEventListener("orientationchange",nt)}},[Mt]),gt.useEffect(()=>{Mt()},[Mt,f,ks]);const $t=c.useCallback(async q=>{const Qe=q.target;Qe.closest(".app-region-no-drag")||Qe.closest("button, a, input, select, textarea")||q.button===0&&y&&await ef()},[y]),Xt=c.useCallback(q=>qn(qr(q,i)),[i]);Vf({rename_current_session:()=>{if(!d||f)return!1;yt()},toggle_services_menu:()=>{if(X){H(!1);return}H(!0),ne()}});const ps=s.jsxs(s.Fragment,{children:[rs?s.jsx(Lx,{projectRef:rs.projectRef,directory:rs.directory,className:"mr-2"}):null,s.jsx(fx,{directory:Zt,className:"mr-1"}),y?s.jsx(Sb,{isDesktopApp:y,currentInstanceLabel:Z,currentInstanceIsLocal:Y,isDesktopServicesOpen:X,setIsDesktopServicesOpen:H,refreshCurrentInstanceLabel:ne,shortcutLabel:Xt,remoteUpdateInfo:K,remoteUpdateChecking:be,remoteUpdateError:T,onOpenRemoteUpdate:$}):null]}),ms=N&&(u||!!d),ee=c.useCallback(({session:q,open:Qe,isActive:nt,select:pt,closeOtherTabs:zt,components:as})=>{const{Item:Lt,Separator:Es}=as,sn=q.share?.url??null,Sr=nt&&!le&&!ct&&Ne&&!Ne.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Lt,{onClick:()=>{nt||pt(),mt.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:Qe,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(Es,{}),sn?s.jsxs(s.Fragment,{children:[s.jsxs(Lt,{onClick:()=>qt(sn),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Lt,{onClick:()=>{Ut(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:()=>{Gt(q.id)},children:[s.jsx(E,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),nt?s.jsxs(Lt,{onClick:()=>{Wt()},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:!Pe||Ft||p,onClick:Kt,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":Ft?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Es,{}),s.jsxs(Lt,{onClick:zt,children:[s.jsx(E,{name:"close-circle",className:"mr-2 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(Es,{}),s.jsxs(Lt,{onClick:()=>lt({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:()=>lt({action:"delete",sessionId:q.id}),children:[s.jsx(E,{name:"delete-bin",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Bt,qt,Ne,Wt,ct,Ft,p,le,Kt,Pe,Gt,t,Ut]),He=()=>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",ks),style:tn,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:Ks}}),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:Hs}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Qt?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:Qt.title}),Qt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Qt.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:[ot?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(jl,{align:"start",children:s.jsx("button",{type:"button",className:hs,"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:[qe?s.jsxs("form",{ref:vt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:q=>q.stopPropagation(),onSubmit:q=>{q.preventDefault(),Rt()},children:[s.jsx("input",{ref:Ct,value:bt,onChange:q=>It(q.target.value),onKeyDown:q=>Mi(q,()=>at(!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:()=>at(!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}),Le?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,Ve?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:Ve})]}):null,!u&&fe?s.jsxs("span",{className:Ie("inline-flex min-w-0 items-center gap-0.5",fe==="attention"||fe==="invalid"||fe==="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:V})]}):null]}):null]}),s.jsx("div",{className:Ie("flex h-[18px] shrink-0 items-center justify-center",Le?"self-start":"self-center"),children:d&&!u&&!qe?s.jsxs(en,{open:Oe,onOpenChange:ye,onOpenChangeComplete:q=>{!q&&mt.current&&mt.current===d&&(mt.current=null,yt())},children:[s.jsx(Js,{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(Zs,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Vt,{onClick:()=>{mt.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:Pe,open:Oe,Item:Vt}),s.jsxs(Vt,{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,{}),Ne?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Vt,{onClick:()=>qt(Ne?.shareUrl),children:[s.jsx(E,{name:"file-copy",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Vt,{onClick:()=>{d&&Ut(d)},children:[s.jsx(E,{name:"link-unlink-m",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Vt,{onClick:()=>{d&&Gt(d)},children:[s.jsx(E,{name:"share-2",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.share")]}),s.jsxs(Vt,{onClick:()=>{Wt()},children:[s.jsx(E,{name:"download",className:"mr-2 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),!le&&!ct&&Ne&&!Ne.parentId?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Vt,{disabled:!Pe||Ft||p,onClick:Kt,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":Ft?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Os,{}),s.jsxs(Vt,{onClick:()=>{d&<({action:"archive",sessionId:d})},children:[s.jsx(E,{name:"inbox-archive",className:"mr-2 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Vt,{className:"text-destructive focus:text-destructive",onClick:()=>{d&<({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(jl,{align:"start",children:s.jsx("button",{type:"button",className:hs,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(E,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Hx,{renderMenu:ee,suppressActiveTabControls:qe,onMenuOpenChangeComplete:q=>{!q&&mt.current&&mt.current===d&&(mt.current=null,yt())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:qe?s.jsxs("form",{ref:vt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:q=>q.stopPropagation(),onSubmit:q=>{q.preventDefault(),Rt()},children:[s.jsx("input",{ref:Ct,value:bt,onChange:q=>It(q.target.value),onKeyDown:q=>Mi(q,()=>at(!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:()=>at(!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})})})]}),Qt||le||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Ae&&j?s.jsx(Bg,{totalTokens:j.totalTokens,percentage:oe,colorPercentage:j.percentage,contextLimit:j.contextLimit,outputLimit:j.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Us,pressed:As,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(wb,{visible:ms,title:t(u?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(u?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Vs,className:Ie(hs,"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":Se,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:ge,className:Ie(Eo,"mr-1",Se?"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&&!xe?Re?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":ue?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ps,s.jsx(du,{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:He()}),s.jsx(vs,{open:Je!==null,onOpenChange:q=>{q||lt(null)},children:s.jsxs(js,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:Je?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Ts,{children:Je?.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:()=>lt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(xt,{variant:"destructive",size:"sm",onClick:()=>{$e()},children:Je?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(eu,{open:se,onOpenChange:ve,info:K,downloading:!1,downloaded:!1,progress:null,error:T,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function kb(){}const Rl=280,El=168,Ml=500,Cb=({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),m=c.useRef(l||Rl),p=c.useRef(null),g=c.useRef(null),w=c.useRef(null),S=c.useCallback(k=>Math.min(Ml,Math.max(El,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 f=Math.min(Ml,Math.max(El,l||Rl)),b=t?f:0,y=k=>{if(t){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}g.current=k.pointerId,d(!0),h.current=k.clientX,m.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(m.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:f}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(dn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Qs,{children:n})})]})]})},Nb=()=>{const t=et.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},Ol="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors",Ab=()=>{const t=et.c(32),{t:e}=Nt(),n=Te(Db),r=Te(Pb),i=c.useRef(null),o=qn(qr("toggle_sidebar",r)),{usesFramelessChrome:l,side:a}=cu(),u=Tb;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 m="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(du,{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(Ol,"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 f;t[9]!==e?(f=e("header.actions.openSessionsAria"),t[9]=e,t[10]=f):f=t[10];let b,y;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=Ie(Ol,"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]!==f||t[14]!==n?(v=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":f,className:b,children:y})}),t[13]=f,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:m,style:p,children:I}),t[29]=I,t[30]=p,t[31]=M):M=t[31],M};function Db(t){return t.toggleSidebar}function Pb(t){return t.shortcutOverrides}function Ib(t){console.warn("[titlebar] failed to open app menu",t)}function Tb(t){const e=t.currentTarget.getBoundingClientRect();Mn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(Ib)}function Fu(t){const e=et.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 Fl=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Rb(t,e,n){const r=et.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([Uf(t),Kf(t)]).catch(Eb);if(u)return;const m=Fl(d),p=Fl(h);if(!m||!p||p===m)return;const g=n||"",w=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:m,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 Eb(){return["",""]}const Bl="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Mb=async(t,e)=>{if(t)return t.authActivate(e);const n=await us("/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},_l=({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 Mb(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??[],m=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(Bl,t),title:m,children:p}):s.jsxs(en,{children:[s.jsx(Js,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(Bl,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:m,disabled:o,children:p})}),s.jsxs(Zs,{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(Vt,{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",Bu=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),_u=()=>new Xo("This AiWorker server has no walkthrough API",{code:"server-unsupported"}),Ob=t=>!Bu(t)&&(t.ok||t.status===404),Ma=async(t,e)=>{if(Ob(t))throw _u();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})},Lu=async t=>{if(!Bu(t))throw _u();try{return await t.json()}catch{throw new Xo("The server returned a malformed walkthrough response")}};async function Fb(t,e,n={}){const r=await us(Jo,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?Lu(r):Ma(r,"Failed to load walkthrough")}async function Bb(t,e,n={}){const r=await us(`${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?Lu(r):Ma(r,"Failed to generate walkthrough")}async function _b(t,e){const n=await us(`${Jo}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Ma(n,"Failed to cancel walkthrough generation")}async function Lb(t,e,n){const r=await us(`${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},$b=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)=>`${fs()}\0${t}\0${$b(e)}`,Ll=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"},on=new Map,Cr=new Map,Wb=1e3,zb=tr()(bu((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;on.get(o)?.abort();const a=new AbortController;on.set(o,a),t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??kr,status:"loading",error:null}}}));try{const u=await Fb(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:Ll(u)}}}))}finally{on.get(o)===a&&on.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=In(n,r);on.get(o)?.abort();const l=new AbortController;on.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(()=>{Lb(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(()=>{})},Wb));try{const u=await Bb(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:Ll(u)}}}))}finally{a(),on.get(o)===l&&on.delete(o)}},cancel:(n,r)=>{const i=In(n,r);_b(n,r).catch(()=>{}),on.get(i)?.abort(),on.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 on.values())n.abort();on.clear();for(const n of Cr.values())clearInterval(n);Cr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),Vb="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)]",Ub=3e4,$l=20,$u=(t,e)=>JSON.stringify([fs(),t,e]),Kb=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}},Wl=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),Zr=new Map,Hb=t=>{const e=Object.entries(t);return e.length<=$l?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,$l))},zl=tr()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=$u(r,i),a=o?.includeCheckDetails??!1,u=e().entries[l],d=u&&u.result&&Date.now()-u.fetchedAt<Ub&&(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]??Wl(),isLoading:!0,error:null}}}));try{const w=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(S=>({entries:Hb({...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]??Wl(),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=Kb(l);u&&u.directory===n&&(r==null||u.number===r)||(o[l]=a)}return{entries:o}})}})),Gb=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}:{}}},qb=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)},Vl=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"}},Qb=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"},Yb=[2e3,5e3],Xb=600,Ul=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):""},Jb=(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},Zb=(t,e)=>`${t}::${e}`,Oa=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=Oa(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)},ey=t=>t.startsWith("pr-"),ty=(t,e)=>{const n=Oa(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=>!ey(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Nr=new Map,eo=Uo;function sy(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 ny=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=Nt(),u=Te(ee=>ee.timeFormatPreference),{github:d}=Sn(),h=An(ee=>ee.status),m=An(ee=>ee.hasChecked),p=Te(ee=>ee.setSettingsDialogOpen),g=Te(ee=>ee.setSettingsPage),w=Ze(ee=>ee.currentSessionId),S=Ze(ee=>!!ee.newSessionDraft?.open),{isMobile:x,hasTouchInput:f,screenWidth:b}=_n(),y=Te(ee=>ee.openContextSurface),v=zb(ee=>ee.requestSource),N=!x&&b>=768&&!Pn(),C=c.useCallback(()=>{g("integrations"),p(!0)},[p,g]),k=c.useMemo(()=>Zb(t,e),[t,e]),D=c.useMemo(()=>Nr.get(k)??null,[k]),P=qs(ee=>ee.ensureEntry),I=qs(ee=>ee.setParams),M=qs(ee=>ee.startWatching),_=qs(ee=>ee.stopWatching),O=qs(ee=>ee.refresh),U=qs(ee=>ee.updateStatus),[L,F]=c.useState(()=>D?.title??Ul(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 ee=typeof D?.targetBaseBranch=="string"?Rn(D.targetBaseBranch):"";return ee||Rn(n)}),[Y,te]=c.useState("squash"),[se,ve]=c.useState(!1),[K,he]=c.useState(!1),[be,ie]=c.useState(!1),[T,Q]=c.useState(!1),[le,me]=c.useState(!1),[ue,Ce]=c.useState(!1),[xe,Re]=c.useState(null),[we,G]=c.useState(""),[Se,ge]=c.useState(""),[Ae,oe]=c.useState(!1),[ne,z]=c.useState(!1),[$,ae]=c.useState(()=>li(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r})),[W,je]=c.useState(!1),{detectedUpstream:Ee,upstreamBranches:Ne}=sy(t,d);c.useEffect(()=>{je(!1)},[t]);const Be=i.some(ee=>ee.name==="upstream"),We=!!(t&&e&&n&&(e!==n||(Be||Ee!==null))),V=c.useMemo(()=>Ho(t,e,$?.name??null),[t,e,$?.name]),fe=qs(ee=>ee.entries[V]),Me=fe?.isLoading??!1,Pe=fe?.status??null,ot=fe?.error??null,Ke=fe?.isInitialStatusResolved??!1,ht=c.useMemo(()=>{const ee=W?null:$?.name?.trim()||null,He=new Set;for(const Qe of o){const nt=Jb(Qe,ee);!nt||nt==="HEAD"||He.add(nt)}if(W)for(const Qe of Ne)Qe&&Qe!=="HEAD"&&He.add(Qe);const tt=Rn(n);tt&&tt!=="HEAD"&&He.add(tt);const q=Rn(Z);return q&&q!=="HEAD"&&He.add(q),Array.from(He).sort((Qe,nt)=>Qe.localeCompare(nt))},[n,o,$?.name,Z,Ne,W]);c.useEffect(()=>{if(i.length===0){$&&ae(null);return}(!$||!i.some(ee=>ee.name===$.name))&&ae(li(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r}))},[D?.selectedRemoteName,i,$,r]),c.useEffect(()=>{const ee=Rn(n);if(!Z&&ee){ce(ee);return}if(ht.length!==0&&!ht.includes(Z)){const He=ht.includes(ee)?ee:ht[0];He&&ce(He)}},[ht,n,Z]);const[ft,kt]=c.useState(()=>D?.activeSegment??"overview"),[pe,Ye]=c.useState(new Set),[wt,jt]=c.useState(new Set),de=c.useRef(new Set),Ve=c.useRef(null),ct=c.useRef(!1),Le=c.useRef(new Set),J=c.useRef([]);c.useEffect(()=>{Ee&&!Be&&je(!0)},[Ee,Be]),c.useEffect(()=>{W&&Ee?.defaultBranch&&ce(Ee.defaultBranch)},[W,Ee?.defaultBranch]);const re=Pe?.pr??null,ke=re?.state==="merged"||re?.state==="closed",Fe=ke?null:re,Ue=Fe?$u(t,Fe.number):null,st=zl(ee=>Ue?ee.entries[Ue]:void 0),it=zl(ee=>ee.ensure),rt=st?.result??null,qe=st?.isLoading??!1,at=c.useCallback(ee=>{kt(ee);const He=Nr.get(k);He&&Nr.set(k,{...He,activeSegment:ee})},[k]);c.useEffect(()=>{!Fe||!d?.prContext||ft==="overview"||it(d,t,Fe.number,{includeCheckDetails:ft==="checks",sourceRepo:Pe?.repo??null})},[ft,t,it,d,Fe,Pe?.repo]);const Oe=Pe?.checks??null,ye=(Oe?.pending??0)>0,mt=rt?.checkRuns??null,bt=rt?.fetchedAt;c.useEffect(()=>{if(!mt||mt.length===0)return;const ee=Gb(mt);U(V,He=>{if(!He?.pr||typeof bt=="number"&&typeof He.fetchedAt=="number"&&bt<He.fetchedAt)return He;const tt=He.checks;return tt&&tt.state===ee.state&&tt.total===ee.total&&tt.success===ee.success&&tt.failure===ee.failure&&tt.pending===ee.pending&&tt.inProgress===ee.inProgress&&tt.queued===ee.queued&&tt.startedAt===ee.startedAt?He:{...He,checks:ee,...typeof bt=="number"?{fetchedAt:bt}:{}}})},[mt,bt,V,U]),c.useEffect(()=>{if(ft!=="checks"||!ye||!re||!d?.prContext)return;const ee=window.setInterval(()=>{it(d,t,re.number,{includeCheckDetails:!0,sourceRepo:Pe?.repo??null,force:!0})},qb);return()=>window.clearInterval(ee)},[ft,ye,t,it,d,re,Pe?.repo]);const[It,Je]=c.useState(()=>Date.now());c.useEffect(()=>{if(!ye)return;Je(Date.now());const ee=window.setInterval(()=>Je(Date.now()),3e4);return()=>window.clearInterval(ee)},[ye]);const lt=re?`${t}#${re.number}`:null,vt=!!(lt&&xe===lt);c.useEffect(()=>{if(!d?.prContext||!re||typeof re.body=="string"&&re.body.length>0)return;const ee=`${t}#${re.number}`;if(de.current.has(ee))return;de.current.add(ee),Re(ee);let He=!1;return it(d,t,re.number,{sourceRepo:Pe?.repo??null}).then(tt=>{if(He)return;const q=tt?.pr;q&&U(V,Qe=>!Qe?.pr||Qe.pr.number!==re.number?Qe:{...Qe,pr:{...Qe.pr,body:q.body||""}})}).catch(()=>{}).finally(()=>{He||Re(tt=>tt===ee?null:tt)}),()=>{He=!0}},[t,it,d,re,V,Pe?.repo,U]),c.useEffect(()=>{if(!re){Ce(!1),G(""),ge(""),Ve.current=null;return}const ee=Ve.current!==null&&Ve.current!==re.number;ee&&Ce(!1),(!ue||ee)&&(G(re.title||""),ge(re.body||"")),Ve.current=re.number},[ue,re]);const yt=c.useCallback(ee=>{if(!ee)return"";const He=Date.parse(ee);return Number.isFinite(He)?Cd(He,u,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):ee},[u]),Tt=c.useMemo(()=>{const ee=h?.user?.login;return typeof ee=="string"?ee.trim():""},[h]),Ct=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)]",[]),Rt=c.useCallback(ee=>{const He=Tt.toLowerCase(),tt=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return ee.replace(tt,(q,Qe,nt)=>{const pt=`@${nt}`,zt=nt.toLowerCase();return`${Qe}[${pt}](https://github.com/${zt}${He&&zt===He?"?oc-self-mention=1":""})`})},[Tt]),Bt=c.useMemo(()=>{const ee=(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})),He=(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=[...ee,...He];return tt.sort((q,Qe)=>{const nt=q.createdAt?Date.parse(q.createdAt):0,pt=Qe.createdAt?Date.parse(Qe.createdAt):0,zt=Number.isFinite(nt)?nt:0,as=Number.isFinite(pt)?pt:0;return zt-as}),tt},[rt,a]),Gt=c.useCallback(()=>{const ee=w??(S?"draft":null);return ee?{directory:t,sessionKey:ee}:(_e.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[w,t,S,a]),qt=c.useCallback((ee,He)=>{const tt=He.authorLogin?`@${He.authorLogin}`:He.authorName,q=He.path?` · ${He.path}${He.line?`:${He.line}`:""}`:"";ji.getState().addDraft(ee,{source:"pr-comment",fileLabel:`PR #${re?.number??""} ${tt}${q}`,startLine:He.line??0,endLine:He.line??0,code:He.body,language:"markdown",text:""})},[re?.number]),Ut=c.useCallback((ee,He)=>{const tt=ee.status||"unknown",q=ee.conclusion??void 0,Qe=q?`${tt} / ${q}`:tt,nt=ee.app?.name||ee.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:He?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[He?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:ee.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:nt?`${nt} · ${Qe}`:Qe})]}),ee.detailsUrl?s.jsx(xt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:ee.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),ee.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:ee.output.title}):null,ee.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:ee.output.summary}):null,ee.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:ee.output.text}):null,Array.isArray(ee.annotations)&&ee.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",ee.annotations.length>20?` (showing 20/${ee.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:ee.annotations.slice(0,20).map((pt,zt)=>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||zt}:${zt}`))})]}):null,ee.job?.steps&&ee.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:ee.job.steps.map((pt,zt)=>{const as=(pt.conclusion||"").toLowerCase(),Lt=as&&!["success","neutral","skipped"].includes(as),Es=`${ee.id??"run"}:${ee.job?.jobId??"job"}:${pt.number??zt}:${pt.name}`,sn=pe.has(Es);return Lt?s.jsxs(ki,{open:sn,children:[s.jsxs("button",{type:"button",onClick:()=>{Ye(Sr=>{const sr=new Set(Sr);return sr.has(Es)?sr.delete(Es):sr.add(Es),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:[sn?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]})})]},Es):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]},Es)})})]}):null]})},[pe,yt,a]),[Wt,Ft]=c.useState(!1),[Kt,$e]=c.useState(!1),Xe=c.useCallback(async()=>{if(!d?.prContext){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!re)return;const ee=Gt();if(ee){Ft(!0);try{const He=await it(d,t,re.number,{includeCheckDetails:!0,sourceRepo:Pe?.repo??null});if(!He){_e.error(a("gitView.pr.toast.loadChecksFailed"));return}const q=(He.checkRuns??[]).filter(nt=>ai(nt.conclusion));if(q.length===0){_e.message(a("gitView.pr.toast.noFailedChecks"));return}const Qe=ji.getState();for(const nt of q){const pt=(nt.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
|
+
`)),zt=(nt.job?.steps??[]).filter(Lt=>ai(Lt.conclusion)).map(Lt=>`step ${Lt.number??"?"}: ${Lt.name} → ${Lt.conclusion}`),as=[`check: ${nt.job?.workflowName?`${nt.job.workflowName} / ${nt.name}`:nt.name}`,`status: ${nt.status??"unknown"} / ${nt.conclusion??"unknown"}`,nt.detailsUrl?`url: ${nt.detailsUrl}`:null,nt.output?.title?`title: ${nt.output.title}`:null,nt.output?.summary?`summary:
|
|
38
|
+
${nt.output.summary}`:null,zt.length>0?`failed steps:
|
|
39
|
+
${zt.join(`
|
|
40
|
+
`)}`:null,pt.length>0?`annotations:
|
|
41
|
+
${pt.join(`
|
|
42
|
+
---
|
|
43
|
+
`)}`:null].filter(Boolean).join(`
|
|
44
|
+
|
|
45
|
+
`);Qe.addDraft(ee,{source:"pr-check",fileLabel:`PR #${re.number} · ${nt.name}`,startLine:0,endLine:0,code:as,language:"text",text:""})}}catch(He){const tt=He instanceof Error?He.message:String(He);_e.error(a("gitView.pr.toast.loadChecksFailed"),{description:tt})}finally{Ft(!1)}}},[t,it,d,re,Gt,Pe?.repo,a]),ut=c.useCallback(async()=>{if(!d?.prContext){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!re)return;const ee=Gt();if(ee){$e(!0);try{if(!await it(d,t,re.number,{sourceRepo:Pe?.repo??null})){_e.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(Bt.length===0){_e.message(a("gitView.pr.toast.noPrComments"));return}for(const tt of Bt)qt(ee,tt)}catch(He){const tt=He instanceof Error?He.message:String(He);_e.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:tt})}finally{$e(!1)}}},[qt,t,it,d,re,Gt,Pe?.repo,a,Bt]),dt=c.useCallback(async ee=>{const He=Gt();He&&qt(He,ee)},[qt,Gt]),Ge=c.useCallback(async ee=>{await O(V,ee)},[V,O]),[_t,Qt]=c.useState(!1),Zt=c.useRef(!0);c.useEffect(()=>(Zt.current=!0,()=>{Zt.current=!1}),[]);const rs=c.useCallback(async()=>{if(_t)return;Qt(!0);const ee=Date.now();try{await Ge({force:!0})}finally{const He=Xb-(Date.now()-ee);He>0&&await new Promise(tt=>window.setTimeout(tt,He)),Zt.current&&Qt(!1)}},[_t,Ge]),es=c.useCallback(()=>{J.current.forEach(ee=>{window.clearTimeout(ee)}),J.current=Yb.map(ee=>window.setTimeout(()=>{Ge({force:!0,silent:!0,markInitialResolved:!0})},ee))},[Ge]);c.useEffect(()=>{if(!d?.prStatus||!We||i.length<=1||ct.current||Pe?.pr)return;const ee=`${k}::${$?.name??""}`;if(Le.current.has(ee))return;Le.current.add(ee);const He=ty(i,r).filter(Qe=>Qe.name!==$?.name);if(He.length===0)return;let tt=!1;return(async()=>{for(const Qe of He){if(tt)return;try{if(!(await d.prStatus(t,e,Qe.name))?.pr)continue;if(tt)return;ae(pt=>pt?.name===Qe.name?pt:Qe);return}catch{}}})(),()=>{tt=!0}},[e,We,t,d,i,$?.name,k,Pe?.pr,r]),c.useEffect(()=>{P(V),I(V,{directory:t,branch:e,remoteName:$?.name??null,canShow:We,github:d,githubAuthChecked:m,githubConnected:h?.connected??null})},[e,We,t,P,d,m,h?.connected,V,$?.name,I]),c.useEffect(()=>(M(V),()=>{_(V)}),[V,M,_]),c.useEffect(()=>{const ee=Nr.get(k)??null;F(ee?.title??Ul(e)),j(ee?.body??""),B(ee?.draft??!1),ce(ee?.targetBaseBranch?Rn(ee.targetBaseBranch):Rn(n));const He=li(i,{selectedRemoteName:ee?.selectedRemoteName,trackingBranch:r});ae(tt=>tt?.name===He?.name?tt:He)},[n,e,i,k,r]),c.useEffect(()=>{Ge({markInitialResolved:!0})},[V,Ge]),c.useEffect(()=>{!We||!$?.name||Ge({force:!0,silent:!0,markInitialResolved:!0})},[We,Ge,$?.name]),c.useEffect(()=>{const ee=Pe?.resolvedRemoteName?.trim();if(!ee||ct.current)return;const He=i.find(tt=>tt.name===ee);He&&ae(tt=>tt?.name===He.name?tt:He)},[i,Pe?.resolvedRemoteName]),c.useEffect(()=>{const ee=()=>{const tt=qs.getState().entries[V]?.lastRefreshAt??0;Date.now()-tt>6e4&&Ge({force:!0,silent:!0})},He=()=>{document.visibilityState==="visible"&&ee()};return window.addEventListener("focus",ee),document.addEventListener("visibilitychange",He),()=>{window.removeEventListener("focus",ee),document.removeEventListener("visibilitychange",He)}},[V,Ge]),c.useEffect(()=>{m&&h?.connected===!1&&Ge({force:!0,silent:!0,markInitialResolved:!0})},[m,h,Ge]),c.useEffect(()=>{!t||!e||Nr.set(k,{title:L,body:R,draft:A,additionalContext:X,targetBaseBranch:Z,selectedRemoteName:$?.name,activeSegment:ft})},[k,L,R,A,X,Z,$?.name,t,e,ft]),c.useEffect(()=>{const ee=J.current;return()=>{ee.forEach(He=>{window.clearTimeout(He)}),J.current=[]}},[]);const zs=c.useCallback(async()=>{if(!se&&t){ve(!0);try{const He={base:W&&Ee?.defaultBranchSha?Ee.defaultBranchSha:Z,head:e};X&&(He.context=X);const tt=await Hf(t,He);tt.title?.trim()&&F(tt.title.trim()),tt.body?.trim()&&j(tt.body.trim()),l?.()}catch(ee){const He=ee instanceof Error?ee.message:String(ee);_e.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:He})}finally{ve(!1)}}},[X,e,Ee?.defaultBranchSha,t,se,l,Z,a,W]),ys=c.useCallback(async()=>{if(!d?.prCreate){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}const ee=L.trim();if(!ee){_e.error(a("gitView.pr.toast.titleRequired"));return}const He=Z.trim();if(!He){_e.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!W&&He===e){_e.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}he(!0);try{const tt=Oa(r),q=W&&Ee,Qe=await d.prCreate({directory:t,title:ee,head:e,base:He,...R.trim()?{body:R}:{},draft:A,...q?{targetRepo:{owner:Ee.owner,repo:Ee.repo},headRemote:"origin"}:{...$?{remote:$.name}:{},...tt&&tt!==$?.name?{headRemote:tt}:{}}});_e.success(a("gitView.pr.toast.prCreated")),U(V,nt=>nt&&{...nt,pr:Qe}),await Ge({force:!0}),es()}catch(tt){const q=tt instanceof Error?tt.message:String(tt);_e.error(a("gitView.pr.toast.createPrFailed"),{description:q})}finally{he(!1)}},[R,e,Ee,t,A,d,V,Ge,es,$,Z,L,r,U,W,a]),Rs=c.useCallback(async ee=>{if(!d?.prMerge){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}Q(!0);try{const He=await d.prMerge({directory:t,number:ee.number,method:Y});He.merged?_e.success(a("gitView.pr.toast.prMerged")):_e.message(a("gitView.pr.toast.prNotMerged"),{description:He.message||a("gitView.pr.notMergeable")}),await Ge({force:!0}),es()}catch(He){const tt=He instanceof Error?He.message:String(He);_e.error(a("gitView.pr.toast.mergeFailed"),{description:tt}),ee.url&&eo(ee.url)}finally{Q(!1)}},[t,d,Y,Ge,es,a]),is=c.useCallback(async ee=>{if(!d?.prReady){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}me(!0);try{await d.prReady({directory:t,number:ee.number}),_e.success(a("gitView.pr.toast.markedReady")),await Ge({force:!0}),es()}catch(He){const tt=He instanceof Error?He.message:String(He);_e.error(a("gitView.pr.toast.markReadyFailed"),{description:tt}),ee.url&&eo(ee.url)}finally{me(!1)}},[t,d,Ge,es,a]),Vs=c.useCallback(async ee=>{if(!d?.prUpdate){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}const He=we.trim();if(!He){_e.error(a("gitView.pr.toast.titleRequired"));return}ie(!0);try{const tt=await d.prUpdate({directory:t,number:ee.number,title:He,body:Se});U(V,q=>q&&{...q,pr:{...q.pr??ee,...tt}}),Ce(!1),_e.success(a("gitView.pr.toast.prUpdated")),await Ge({force:!0}),es()}catch(tt){const q=tt instanceof Error?tt.message:String(tt);_e.error(a("gitView.pr.toast.updatePrFailed"),{description:q})}finally{ie(!1)}},[t,Se,we,d,V,Ge,es,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(_l,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const Us=Pe?.repo?.url||null,As=W&&Ee?.url?Ee.url:Us,hs=!!Pe?.canMerge,Ds=!!Pe?.connected,Ks=m&&Pe?.connected===!1,Hs=Qb(Pe),ks=Hs?`var(--pr-${Hs})`:"var(--status-info)",tn=Hs==="draft"?"git-pr-draft":Hs==="merged"?"git-merge":Hs==="closed"?"git-close-pull-request":"git-pull-request",Mt=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=Oe?Oe.total>0?`${Oe.success}/${Oe.total} ${a("gitView.pr.checks.label")}`:`${Oe.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:tn,className:"size-4 shrink-0",style:{color:ks}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(E,{name:tn,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",Vb),onClick:()=>{v(t,{kind:"pr",number:re.number,sourceRepo:Pe?.repo?{owner:Pe.repo.owner,repo:Pe.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:Me||_t,onClick:()=>{rs()},"aria-label":a("gitView.pr.actions.refreshAria"),children:Me||_t?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(_l,{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:ks},children:Mt}),Oe?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${Vl(Oe.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:[hs&&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:()=>is(re),disabled:le||T||be||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,hs?s.jsxs(s.Fragment,{children:[s.jsxs(Fs,{value:Y,onValueChange:ee=>te(ee),disabled:T||re.state!=="open",children:[s.jsx(Bs,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(Ns,{})}),s.jsxs(_s,{children:[s.jsx(ns,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(ns,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(ns,{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:()=>Rs(re),disabled:T||le||re.state!=="open"||re.draft||be||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:[Ks?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,ot?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:ot}),As?s.jsx(xt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:As,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(E,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!re&&!Ke&&!ot&&!Ks?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&&!ke?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(tu,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Oe&&Oe.total>0?`${a("gitView.pr.segment.checks")} ${Oe.success}/${Oe.total}`:a("gitView.pr.segment.checks"),icon:Oe?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Vl(Oe.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:ft,onSelect:ee=>at(ee),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),ft==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[hs&&re.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,hs?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:we,onChange:ee=>G(ee.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f}):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:()=>{Ce(!1),G(re.title||""),ge(re.body||"")},disabled:be,"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:()=>Vs(re),disabled:be||!we.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:be?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:()=>Ce(!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:Se,onChange:ee=>ge(ee.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f}):null,ue?null:re.body?.trim()?s.jsx(sl,{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(vt?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,ft==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Oe&&Oe.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:[Oe.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Oe.success/Oe.total*100}%`}}):null,Oe.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Oe.failure/Oe.total*100}%`}}):null,Oe.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Oe.pending/Oe.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Oe.success,"/",Oe.total," ",a("gitView.pr.checks.label")]}),(Oe.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(Oe.startedAt,void 0,It)]}):null]}):null,Oe?.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:Xe,disabled:Wt,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[Wt?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((ee,He)=>{const tt=`${ee.id??"run"}:${ee.name}:${He}`,q=ee.status==="in_progress",Qe=ee.status==="queued",nt=ai(ee.conclusion),pt=wt.has(tt),zt=!!(ee.output?.title||ee.output?.summary||ee.output?.text||(ee.annotations?.length??0)>0||(ee.job?.steps?.length??0)>0||ee.detailsUrl),as=ee.job?.workflowName,Lt=q?ii(ee.startedAt,void 0,It):ii(ee.startedAt,ee.completedAt);return s.jsxs("div",{className:Ie("rounded-md border border-border/40",nt&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!zt,onClick:()=>{jt(Es=>{const sn=new Set(Es);return sn.has(tt)?sn.delete(tt):sn.add(tt),sn})},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)]"}):Qe?s.jsx(E,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):nt?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:as&&as!==ee.name?`${as} / ${ee.name}`:ee.name}),Lt?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:Lt}):null,zt?s.jsx(E,{name:"arrow-down-s",className:Ie("size-4 shrink-0 text-muted-foreground transition-transform",pt&&"rotate-180")}):null]}),pt&&zt?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:Ut(ee,{hideHeader:!0})}):null]},tt)})}):qe?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,ft==="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:ut,disabled:Kt,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Kt?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((ee,He)=>{const tt=(ee.authorName||"?").charAt(0).toUpperCase(),q=He===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:ee.avatarUrl?s.jsx("img",{src:ee.avatarUrl,alt:ee.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:[ee.authorName,ee.authorLogin&&ee.authorLogin!==ee.authorName?` · @${ee.authorLogin}`:""]}),ee.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:yt(ee.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:()=>{dt(ee)},"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:[ee.context,ee.path?` · ${ee.path}`:"",ee.line?`:${ee.line}`:""]}),s.jsx(sl,{content:Rt(ee.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",Ct].filter(Boolean).join(" "),enableFileReferences:!1})]})]},ee.id)})})}):qe&&!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&&ke?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:ks}}),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&&Ee?"upstream":"remote",")"]})]})]}),As?s.jsx(xt,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:As,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:ee=>F(ee.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f})]}),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(Ns,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(_s,{children:ht.map(ee=>s.jsx(ns,{value:ee,children:ee},ee))})]}):s.jsx(Cn,{value:Z,onChange:ee=>ce(ee.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:ee=>j(ee.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:f?"on":"off",autoCapitalize:f?"sentences":"off",spellCheck:f})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":A,onClick:()=>B(ee=>!ee),onKeyDown:ee=>{(ee.key===" "||ee.key==="Enter")&&(ee.preventDefault(),B(He=>!He))},children:[s.jsx(ur,{size:"sm",checked:A,onChange:ee=>B(ee),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:()=>z(!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:Ae,onOpenChange:oe,children:[s.jsxs(Nd,{className:"flex w-full items-center justify-between rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-2 hover:bg-[var(--interactive-hover)]",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:Ae?a("gitView.pr.actions.hide"):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:ee=>H(ee.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:ne,onClose:()=>z(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(xt,{size:"sm",onClick:()=>z(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(lr,{value:X,onChange:ee=>H(ee.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:zs,disabled:se||K,children:[se?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:ys,disabled:K||!Ds||!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=>`${fs()}::${t}`,ry=()=>{const t=et.c(115),{t:e}=Nt(),{git:n}=Sn(),r=er(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=Gf(r??null),a=ya(o??null),u=Ad(o??null),d=Dd(o??null),{ensureAll:h,ensureNestedRepos:m,selectNestedRepo:p}=Dn(Jn(oy)),g=Ze(iy),w=Ze(ay),S=Ze(ly),x=Ze(cy);let f;t[0]!==r?(f=ci(r),t[0]=r,t[1]=f):f=t[1];const b=f;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=je=>ci(je.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=vd(D),I=P&&!P.degraded&&!P.legacy?P.worktreeRoot??void 0:void 0,M=Rb(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 je=W.trim();L(je&&je!=="HEAD"?je: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,te;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}},te=[o,n],t[35]=n,t[36]=o,t[37]=Y,t[38]=te):(Y=t[37],te=t[38]),c.useEffect(Y,te);let se,ve;t[39]!==n||t[40]!==o?(se=()=>{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}},ve=[o,n],t[39]=n,t[40]=o,t[41]=se,t[42]=ve):(se=t[41],ve=t[42]),c.useEffect(se,ve);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(dy).sort(),t[44]=u.all,t[45]=$):$=t[45],K=$}const he=K;let be;e:{if(!u?.all){let ae;t[46]===Symbol.for("react.memo_cache_sentinel")?(ae=[],t[46]=ae):ae=t[46],be=ae;break e}let $;t[47]!==u.all?($=u.all.filter(uy).map(my).sort(),t[47]=u.all,t[48]=$):$=t[48],be=$}const ie=be;let T;t[49]!==ie||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 ie){const je=W.indexOf("/");je>0&&$.add(W.slice(0,je))}return $.size===0&&Z&&$.add("origin"),Array.from($).map(W=>({name:W,fetchUrl:Z??"",pushUrl:Z??""}))},t[49]=ie,t[50]=Z,t[51]=B,t[52]=a?.tracking,t[53]=T):T=t[53],a?.tracking;let Q;t[54]!==T?(Q=T(),t[54]=T,t[55]=Q):Q=t[55];const le=Q,me=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 Ce=ue,xe=(Ce&&u?.defaultBranches?.[Ce])??u?.defaultBranches?.origin;let Re;t[58]!==me||t[59]!==xe||t[60]!==le||t[61]!==he||t[62]!==U||t[63]!==M?.createdFromBranch?(Re=()=>dg({remoteNames:new Set(le.map(fy)),localBranches:he,worktreeCreatedFromBranch:M?.createdFromBranch,rootBranchHint:U,defaultBranch:xe,headBranch:me}),t[58]=me,t[59]=xe,t[60]=le,t[61]=he,t[62]=U,t[63]=M?.createdFromBranch,t[64]=Re):Re=t[64],M?.createdFromBranch;let we;t[65]!==Re?(we=Re(),t[65]=Re,t[66]=we):we=t[66];const G=we;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 je;t[72]!==e?(je=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=je):je=t[73];let Ee;t[74]!==je?(Ee=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:je}),t[74]=je,t[75]=Ee):Ee=t[75];let Ne;return t[76]!==W||t[77]!==Ee?(Ne=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[$,W,Ee]}),t[76]=W,t[77]=Ee,t[78]=Ne):Ne=t[78],Ne}if(i===!1&&d!==!0){let $;t[79]!==r||t[80]!==m?($=()=>{m(r,{force:!0})},t[79]=r,t[80]=m,t[81]=$):$=t[81];let ae;return t[82]!==d||t[83]!==l||t[84]!==i||t[85]!==$?(ae=s.jsx(ug,{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(!me){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 je;t[92]!==e?(je=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=je):je=t[93];let Ee;t[94]!==je?(Ee=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:je}),t[94]=je,t[95]=Ee):Ee=t[95];let Ne;return t[96]!==W||t[97]!==Ee?(Ne=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[$,W,Ee]}),t[96]=W,t[97]=Ee,t[98]=Ne):Ne=t[98],Ne}const Se=i===!1&&Array.isArray(l)&&l.length>0;let ge;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==p||t[103]!==Se?(ge=Se?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(mg,{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]=Se,t[104]=ge):ge=t[104];const Ae=o??r,oe=a?.tracking??void 0;let ne;t[105]!==G||t[106]!==me||t[107]!==ie||t[108]!==B||t[109]!==Ae||t[110]!==oe?(ne=s.jsx(dn,{as:wa,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(ny,{directory:Ae,branch:me,baseBranch:G,trackingBranch:oe,remotes:B,remoteBranches:ie})}),t[105]=G,t[106]=me,t[107]=ie,t[108]=B,t[109]=Ae,t[110]=oe,t[111]=ne):ne=t[111];let z;return t[112]!==ge||t[113]!==ne?(z=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ge,ne]}),t[112]=ge,t[113]=ne,t[114]=z):z=t[114],z};function oy(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function iy(t){return t.currentSessionId}function ay(t){return t.newSessionDraft}function ly(t){return t.worktreeMetadata}function cy(t){return t.availableWorktrees}function dy(t){return!t.startsWith("remotes/")}function uy(t){return t.startsWith("remotes/")}function my(t){return t.replace(/^remotes\//,"")}function fy(t){return t.name}const Gi=2e4,hy=(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)=>Jf(Zf.getState().dictionary,t,e),py=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"},gy=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 us(`/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()},Wu=async(t,e,n)=>{if(qf(e)||Qf(e)||Yf(e))return{ok:!0};try{const r=await gy(t,e,n);return Xf(r)?{ok:!1,reason:"binary"}:hy(r,Gi)>Gi?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:py(r)}}},zu=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")},Kl=8;let qi=null;const Vu=t=>{qi={x:t.clientX,y:t.clientY}},Uu=t=>{const e=qi;return qi=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=Kl&&Math.abs(t.clientY-e.y)<=Kl},Hl=3,fr=t=>Array.from(t.types).includes("Files"),xy=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]:[]})},Gl=t=>{const e=t.name;return!e||e==="."||e===".."||e.includes("/")||e.includes("\\")?null:e},by=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),ls=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},Fa=(t,e)=>{const n=ls(e),r=ls(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},yy=(t,e)=>{const n=Fa(t,e);if(n!==".")return n;const r=ls(t);return r.split("/").filter(Boolean).pop()??r},wy=t=>{const e=ls(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},Sy=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),vy=new Set(["node_modules"]),jy=t=>vy.has(t),ky=t=>{const e=ls(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Cy=8,pn=new Map,Ba=t=>JSON.stringify([fs(),t]),Ny=t=>{const e=Ba(t),n=pn.get(e);return n?(n.touchedAt=Date.now(),pn.delete(e),pn.set(e,n),n):null},di=t=>{const e=Ba(t),n=pn.get(e);if(n)return n.touchedAt=Date.now(),n;if(pn.size>=Cy){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},Ku=(t,e)=>s.jsx(Sa,{filePath:t,extension:e}),Ay=t=>{const e=et.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},Dy=t=>{const e=et.c(87),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:u,isDropTarget:d,canUpload:h,permissions:m,downloadFile:p,onSelect:g,onToggle:w,onRevealPath:S,onOpenDialog:x,onSetDropTarget:f,onDropFiles:b}=t,{t:y}=Nt(),v=n.type==="directory";let N;e[0]!==v||e[1]!==n.path?(N=v?n.path:wy(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}=m,_=!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:je=>{je.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:je=>{je.stopPropagation(),gn(n.path).then(Ee=>{if(Ee.ok){_e.success(y("sidebarFilesTree.toast.pathCopied"));return}_e.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:je=>{je.stopPropagation(),p(n.path).catch(Ee=>{console.error("Download failed:",Ee),_e.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:je=>{je.stopPropagation(),S(n.path)},children:[s.jsx(E,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",y(xd())]}),v&&(D||P)&&s.jsxs(s.Fragment,{children:[s.jsx(W,{}),D&&s.jsxs(ae,{onClick:je=>{je.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:je=>{je.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:je=>{je.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 te=Y;let se;e[24]!==n.path||e[25]!==r?(se=$=>{Vu($);const ae=Fa(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]=se):se=e[26];const ve=se;let K;e[27]!==H?(K=$=>{Uu($)&&H()},e[27]=H,e[28]=K):K=e[28];const he=K;let be;e[29]!==h||e[30]!==f||e[31]!==C?(be=$=>{!h||!C||!fr($.dataTransfer)||($.preventDefault(),$.stopPropagation(),$.dataTransfer.dropEffect="copy",f(C))},e[29]=h,e[30]=f,e[31]=C,e[32]=be):be=e[32];const ie=be;let T;e[33]!==h||e[34]!==f||e[35]!==C?(T=$=>{!h||!C||!fr($.dataTransfer)||$.relatedTarget instanceof Node&&$.currentTarget.contains($.relatedTarget)||($.stopPropagation(),f(null))},e[33]=h,e[34]=f,e[35]=C,e[36]=T):T=e[36];const Q=T;let le;e[37]!==h||e[38]!==b||e[39]!==C?(le=$=>{!h||!C||!fr($.dataTransfer)||($.preventDefault(),$.stopPropagation(),b(C,$.dataTransfer))},e[37]=h,e[38]=b,e[39]=C,e[40]=le):le=e[40];const me=le;let ue;e[41]!==B||e[42]!==Q||e[43]!==ie||e[44]!==me?(ue=s.jsx("div",{className:"group relative flex items-center",onContextMenu:B,onDragEnter:ie,onDragOver:ie,onDragLeave:Q,onDrop:me}),e[41]=B,e[42]=Q,e[43]=ie,e[44]=me,e[45]=ue):ue=e[45];const Ce=d?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let xe;e[46]!==Ce?(xe=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",Ce),e[46]=Ce,e[47]=xe):xe=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"}):Ku(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 we;e[53]!==n.name||e[54]!==n.path?(we=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]=we):we=e[55];let G;e[56]!==v||e[57]!==a?(G=!v&&a&&s.jsx(Ay,{status:a}),e[56]=v,e[57]=a,e[58]=G):G=e[58];let Se;e[59]!==u||e[60]!==v?(Se=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]=Se):Se=e[61];let ge;e[62]!==B||e[63]!==he||e[64]!==ve||e[65]!==H||e[66]!==xe||e[67]!==Re||e[68]!==we||e[69]!==G||e[70]!==Se?(ge=s.jsxs("button",{type:"button",onClick:H,onContextMenu:B,draggable:!0,onDragStart:ve,onDragEnd:he,className:xe,children:[Re,we,G,Se]}),e[62]=B,e[63]=he,e[64]=ve,e[65]=H,e[66]=xe,e[67]=Re,e[68]=we,e[69]=G,e[70]=Se,e[71]=ge):ge=e[71];let Ae;e[72]!==L||e[73]!==U||e[74]!==te||e[75]!==y?(Ae=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(en,{open:L,onOpenChange:F,children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Js,{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(Zs,{align:"end",side:"bottom",onCloseAutoFocus:()=>F(!1),children:te({Item:Vt,Separator:Os})})]})}),e[72]=L,e[73]=U,e[74]=te,e[75]=y,e[76]=Ae):Ae=e[76];let oe;e[77]!==ue||e[78]!==ge||e[79]!==Ae?(oe=s.jsxs(nu,{render:ue,children:[ge,Ae]}),e[77]=ue,e[78]=ge,e[79]=Ae,e[80]=oe):oe=e[80];let ne;e[81]!==te?(ne=s.jsx(su,{className:"min-w-[180px]",children:te({Item:Un,Separator:Oi})}),e[81]=te,e[82]=ne):ne=e[82];let z;return e[83]!==R||e[84]!==oe||e[85]!==ne?(z=s.jsxs(ru,{open:R,onOpenChange:j,children:[oe,ne]}),e[83]=R,e[84]=oe,e[85]=ne,e[86]=z):z=e[86],z},Py=(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,Iy=c.memo(Dy,Py),Ty=t=>{const e=et.c(6),{visible:n}=t,r=n===void 0?!0:n,i=Dn(Ey),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(Ry,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},Ry=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:n}=Nt(),{files:r,runtime:i}=Sn(),o=tf(i.platform),l=er()??"",a=ls(l.trim()),u=Ba(a),d=sf(),h=nf(),m=cd(de=>de.searchFiles),p=Te(de=>de.openContextFile),g=ya(t?l:null),[w,S]=c.useState(""),x=Pd(w,200),f=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 Wg,[]);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 de=Ny(a);de?(L({...de.childrenByDir}),R({...de.loadErrorsByDir}),j.current=new Set(de.loadedDirs)):(L({}),R({}),j.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const de=di(a);de.childrenByDir=U},[a,U]),c.useEffect(()=>{if(!a)return;const de=di(a);de.loadErrorsByDir=F},[a,F]),c.useEffect(()=>{if(!a)return;const de=di(a);de.loadedDirs=new Set(j.current)},[a,U,F]),c.useEffect(()=>()=>{if(!a)return;const de=pn.get(u);de&&de.loadedDirs.size===0&&Object.keys(de.childrenByDir).length===0&&pn.delete(u)},[u,a]);const X=c.useMemo(()=>[],[]),H=c.useMemo(()=>[],[]),Z=hn(de=>a?de.byRoot[a]?.expandedPaths??X:X),ce=c.useMemo(()=>new Set(Z),[Z]),Y=hn(de=>a?de.byRoot[a]?.selectedPath??null:null),te=hn(de=>de.setSelectedPath),se=hn(de=>de.addOpenPath),ve=hn(de=>de.removeOpenPathsByPrefix),K=hn(de=>de.toggleExpandedPath),he=hn(de=>de.collapseAllExpandedPaths),be=Te(de=>a?de.contextPanelByDirectory[a]?.tabs??H:H),ie=c.useMemo(()=>new Set(be.map(de=>de.mode==="file"?de.targetPath:null).filter(de=>typeof de=="string"&&de.length>0).map(de=>ls(de))),[be]),[T,Q]=c.useState(null),[le,me]=c.useState(null),[ue,Ce]=c.useState(""),[xe,Re]=c.useState(!1),we=!!r.writeFile,G=!!r.createDirectory,Se=!!r.rename,ge=!!r.delete,Ae=!!r.revealPath,oe=!!r.uploadFile,ne=c.useMemo(()=>({canRename:Se,canCreateFile:we,canCreateFolder:G,canDelete:ge,canReveal:Ae}),[Se,we,G,ge,Ae]),z=c.useCallback(de=>{r.revealPath&&r.revealPath(de).catch(()=>{_e.error(n("sidebarFilesTree.toast.revealFailed"))})},[r,n]),$=c.useCallback((de,Ve)=>{Q(de),me(Ve),Ce(de==="rename"&&Ve.name||""),Re(!1)},[]),ae=c.useCallback((de,Ve)=>{const ct=Ve.filter(Le=>Le&&typeof Le.name=="string"&&Le.name.length>0).filter(Le=>d||!Le.name.startsWith(".")).filter(Le=>h||!jy(Le.name)).map(Le=>{const J=Le.name,re=ls(Le.path||""),ke=re?Sy(re)?re:ls(`${de}/${re}`):ls(`${de}/${J}`),Fe=Le.isDirectory?"directory":"file",Ue=Fe==="file"&&J.includes(".")?J.split(".").pop()?.toLowerCase():void 0;return{name:J,path:ke,type:Fe,extension:Ue}});return by(ct)},[h,d]),W=c.useCallback(async(de,Ve,ct=!1)=>{if(!e.current||Ve?.())return;const Le=ls(de.trim());if(!Le||!ct&&j.current.has(Le))return;const J=fs();return A.run(Le,async re=>{const ke=()=>!re()||fs()!==J;try{const Fe=r.listDirectory?(await r.listDirectory(Le)).entries:await Xs.listLocalDirectory(Le);if(ke())return;const Ue=ae(Le,Fe);j.current=new Set(j.current),j.current.add(Le),R(st=>{if(!st[Le])return st;const it={...st};return delete it[Le],it}),L(st=>st[Le]&&zg(st[Le],Ue)?st:{...st,[Le]:Ue})}catch(Fe){if(ke())return;const Ue=Fe instanceof Error?Fe.message:String(Fe??"");console.error("Failed to load sidebar directory:",Fe),R(st=>({...st,[Le]:Ue}))}},ct)},[A,r,ae]),je=c.useCallback(async()=>{if(!a)return;B.current?.abort();const de=new AbortController;B.current=de,A.clear();try{const ct=(hn.getState().byRoot[a]?.expandedPaths??[]).map(re=>ls(re)).filter(re=>!!re&&re!==a&&re.startsWith(`${a}/`)),Le=[a,...ct];j.current=new Set(j.current);for(const re of Le)j.current.delete(re);R(re=>{if(Object.keys(re).length===0)return re;const ke={...re};let Fe=!1;for(const Ue of Le)Ue in ke&&(delete ke[Ue],Fe=!0);return Fe?ke:re});const J=()=>de.signal.aborted;await W(a,J);for(let re=0;re<ct.length&&!de.signal.aborted;re+=3){const ke=ct.slice(re,re+3);await Promise.all(ke.map(Fe=>W(Fe,J)))}}catch(Ve){if(de.signal.aborted)return;console.error("Failed to refresh sidebar tree:",Ve)}finally{B.current===de&&(B.current=null)}},[A,W,a]),Ee=c.useCallback(async de=>{if(!de){await je();return}const Ve=ls(de);j.current=new Set(j.current),j.current.delete(Ve),await W(Ve,void 0,!0)},[W,je]);c.useEffect(()=>{a&&(B.current?.abort(),j.current=new Set,A.clear(),R({}),L(de=>Object.keys(de).length===0?de:{}),W(a))},[A,W,a,d,h]),c.useEffect(()=>{if(!t||!a||Z.length===0)return;const de=Z.map(Le=>ls(Le)).filter(Le=>!!Le&&Le!==a&&Le.startsWith(`${a}/`)&&!j.current.has(Le)&&!A.has(Le)).sort((Le,J)=>Le.split("/").length-J.split("/").length);if(de.length===0)return;let Ve=!1;const ct=()=>Ve;return(async()=>{for(let Le=0;Le<de.length&&!Ve;Le+=3){const J=de.slice(Le,Le+3);await Promise.all(J.map(re=>W(re,ct)))}})(),()=>{Ve=!0}},[A,Z,W,a,t]);const Ne=c.useRef(t);c.useEffect(()=>{const de=t&&!Ne.current;Ne.current=t,de&&je()},[je,t]),c.useEffect(()=>{if(!t)return;if(!l){y([]),N(!1);return}const de=x.trim();if(!de){y([]),N(!1);return}let Ve=!1;return N(!0),m(l,de,150,{includeHidden:d,respectGitignore:!h,type:"file"}).then(ct=>{if(Ve)return;const J=ct.filter(re=>h||!ky(re.path)).map(re=>({name:re.name,path:ls(re.path),type:"file",extension:re.extension,relativePath:re.relativePath}));y(J)}).catch(()=>{Ve||y([])}).finally(()=>{Ve||N(!1)}),()=>{Ve=!0}},[l,x,m,d,h,t]);const Be=c.useMemo(()=>{const de=new Map;if(!g?.files)return de;for(const Ve of g.files)Ve.index==="A"||Ve.working_dir==="?"?de.set(Ve.path,"git-added"):Ve.index==="D"?de.set(Ve.path,"git-deleted"):(Ve.index==="M"||Ve.working_dir==="M")&&de.set(Ve.path,"git-modified");return de},[g]),ze=c.useMemo(()=>{const de=new Map;if(!g?.files||!a)return de;for(const Ve of g.files){const ct=Ve.index==="M"||Ve.working_dir==="M",Le=Ve.index==="A"||Ve.working_dir==="?";if(!ct&&!Le)continue;const J=Ve.path.split("/");if(J.length<=1)continue;let re=a;for(let ke=0;ke<J.length-1;ke++){re=`${re}/${J[ke]}`;let Fe=de.get(re);Fe||(Fe={modified:0,added:0},de.set(re,Fe)),ct&&Fe.modified++,Le&&Fe.added++}}return de},[g,a]),We=c.useCallback(de=>{if(ie.has(de))return"open";if(Be.size===0)return null;const Ve=de.startsWith(a+"/")?de.slice(a.length+1):de;return Be.get(Ve)??null},[ie,Be,a]),V=c.useCallback(de=>{if(ze.size===0)return null;const Ve=ze.get(de);return Ve&&Ve.modified+Ve.added>0?Ve:null},[ze]),fe=c.useCallback(async de=>{if(!a)return;const Ve=await Wu(r,de.path,{directory:a});if(!Ve.ok){_e.error(zu(Ve.reason));return}te(a,de.path),se(a,de.path),p(a,de.path)},[se,r,p,a,te]),Me=c.useCallback(async de=>{const Ve=ls(de);a&&(K(a,Ve),j.current.has(Ve)||await W(Ve))},[W,a,K]),Pe=c.useCallback(async(de,Ve,ct=!1)=>{const Le=r.uploadFile;if(!Le||Ve.length===0||_.current||!a)return;const J=a,re=fs();_.current=!0,P(!0),k(de),ct&&M(null);const ke=[];for(let qe=0;qe<Ve.length;qe+=Hl){const at=Ve.slice(qe,qe+Hl),Oe=await Promise.all(at.map(async ye=>{const mt=Gl(ye);if(!mt||fs()!==re)return"failed";try{return(await Le(ls(`${de}/${mt}`),ye,{directory:J,overwrite:ct})).success?"uploaded":"failed"}catch(bt){return!ct&&rf(bt)&&bt.reason==="already-exists"?"conflict":"failed"}}));ke.push(...Oe)}const Fe=ke.filter(qe=>qe==="uploaded").length,Ue=ke.filter(qe=>qe==="failed").length,st=Ve.filter((qe,at)=>ke[at]==="conflict"),it=Ve.flatMap((qe,at)=>{const Oe=Gl(qe);return ke[at]==="uploaded"&&Oe?[ls(`${de}/${Oe}`)]:[]}),rt=O.current===J&&fs()===re;try{it.length>0&&Vg({runtimeKey:re,paths:it}),Fe>0&&rt&&await Ee(de),Fe>0&&_e.success(n(st.length>0?"sidebarFilesTree.toast.uploadedWithoutConflicts":"sidebarFilesTree.toast.uploaded")),Ue>0&&_e.error(n("sidebarFilesTree.toast.uploadFailed")),st.length>0&&rt&&M({directory:de,files:st,runtimeKey:re,workspaceRoot:J})}finally{_.current=!1,P(!1),k(null)}},[r.uploadFile,Ee,a,n]),ot=c.useCallback((de,Ve)=>{const ct=xy(Ve);ct.length!==0&&Pe(de,ct)},[Pe]),Ke=c.useCallback(de=>{!oe||_.current||!a||!fr(de.dataTransfer)||(de.preventDefault(),de.dataTransfer.dropEffect="copy",k(a))},[oe,a]),ht=c.useCallback(de=>{fr(de.dataTransfer)&&(de.relatedTarget instanceof Node&&de.currentTarget.contains(de.relatedTarget)||k(null))},[]),ft=c.useCallback(de=>{!oe||_.current||!a||!fr(de.dataTransfer)||(de.preventDefault(),ot(a,de.dataTransfer))},[oe,ot,a]),kt=c.useCallback(async de=>{if(de?.preventDefault(),!le||!T)return;Re(!0);const Ve=()=>Re(!1),ct=()=>Q(null);if(T==="createFile"){if(!ue.trim()){_e.error(n("sidebarFilesTree.toast.filenameRequired")),Ve();return}if(!r.writeFile){_e.error(n("sidebarFilesTree.toast.writeNotSupported")),Ve();return}const Le=le.path,J=Le?`${Le}/`:"",re=ls(`${J}${ue.trim()}`);await r.writeFile(re,"").then(async ke=>{ke.success&&(_e.success(n("sidebarFilesTree.toast.fileCreated")),await Ee(Le)),ct()}).catch(()=>_e.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ve);return}if(T==="createFolder"){if(!ue.trim()){_e.error(n("sidebarFilesTree.toast.folderNameRequired")),Ve();return}const Le=le.path,J=Le?`${Le}/`:"",re=ls(`${J}${ue.trim()}`);await r.createDirectory(re).then(async ke=>{ke.success&&(_e.success(n("sidebarFilesTree.toast.folderCreated")),await Ee(Le)),ct()}).catch(()=>_e.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ve);return}if(T==="rename"){if(!ue.trim()){_e.error(n("sidebarFilesTree.toast.nameRequired")),Ve();return}if(!r.rename){_e.error(n("sidebarFilesTree.toast.renameNotSupported")),Ve();return}const Le=le.path,J=Le.split("/").slice(0,-1).join("/"),re=J?`${J}/`:"",ke=ls(`${re}${ue.trim()}`);await r.rename(Le,ke).then(async Fe=>{Fe.success&&(_e.success(n("sidebarFilesTree.toast.renamedSuccessfully")),await Ee(J),a&&ve(a,Le),(Y===Le||Y&&Y.startsWith(`${Le}/`))&&te(a,null)),ct()}).catch(()=>_e.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ve);return}if(T==="delete"){if(!r.delete){_e.error(n("sidebarFilesTree.toast.deleteNotSupported")),Ve();return}const Le=le.path,J=Le.split("/").slice(0,-1).join("/");await r.delete(Le).then(async re=>{re.success&&(_e.success(n("sidebarFilesTree.toast.deletedSuccessfully")),await Ee(J),a&&ve(a,Le),(Y===Le||Y&&Y.startsWith(Le+"/"))&&te(a,null)),ct()}).catch(()=>_e.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Ve);return}Ve()},[T,le,ue,r,Ee,ve,a,Y,te,n]);function pe(de,Ve){const ct=U[de]??[];return ct.map((Le,J)=>{const re=Le.type==="directory",ke=re&&ce.has(Le.path),Fe=Y===Le.path,Ue=J===ct.length-1;return s.jsxs("li",{className:"relative",children:[Ve>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),Ue&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(Iy,{node:Le,root:a,isExpanded:ke,isActive:Fe,isBrowserClient:o,status:re?void 0:We(Le.path),badge:re?V(Le.path):void 0,isDropTarget:re&&C===Le.path,canUpload:oe&&!D,permissions:ne,downloadFile:r.downloadFile,onSelect:fe,onToggle:Me,onRevealPath:z,onOpenDialog:$,onSetDropTarget:k,onDropFiles:ot}),re&&ke&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[F[Le.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[Le.path],children:F[Le.path]}),s.jsxs(xt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ee(Le.path)},children:[s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):null,pe(Le.path,Ve+1)]})]},Le.path)})}const Ye=!!(a&&U[a]),wt=a?F[a]:null,jt=C?yy(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:[we&&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")})]}),G&&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:()=>{je()},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&&he(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:f,value:w,onChange:de=>S(de.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(""),f.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(dn,{outerClassName:"h-full min-h-0",className:Ie("p-2",C===a&&"bg-interactive-selection/10"),onDragEnter:Ke,onDragOver:Ke,onDragLeave:ht,onDrop:ft,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(de=>{const Ve=Y===de.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>fe(de),draggable:!0,onDragStart:ct=>{Vu(ct);const Le=de.relativePath||Fa(a??"",de.path);!Le||Le==="."||(ct.dataTransfer.setData("application/x-openchamber-file-path",Le),ct.dataTransfer.effectAllowed="copy")},onDragEnd:ct=>{Uu(ct)&&fe(de)},className:Ie("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",Ve?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:de.path,children:[Ku(de.path,de.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:de.relativePath??de.path})]})},de.path)}):wt?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:wt}),s.jsxs(xt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{je()},children:[s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):Ye&&a?pe(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:de=>!de&&M(null),children:s.jsxs(js,{children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:n("sidebarFilesTree.dialog.uploadConflicts.title")}),s.jsx(Ts,{children:n("sidebarFilesTree.dialog.uploadConflicts.description",{path:I?.directory??""})})]}),s.jsx(dn,{outerClassName:"max-h-52",className:"flex flex-col gap-1 pr-2",children:I?.files.map((de,Ve)=>s.jsx("div",{className:"truncate rounded-md bg-muted px-2 py-1 typography-meta",title:de.name,children:de.name},`${de.name}-${de.size}-${Ve}`))}),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!==fs()||I.workspaceRoot!==a){M(null);return}Pe(I.directory,I.files,!0)}},disabled:D,children:n("sidebarFilesTree.dialog.uploadConflicts.replace")})]})]})}),s.jsx(vs,{open:!!T,onOpenChange:de=>!de&&Q(null),children:s.jsxs(js,{children:[s.jsxs(Ws,{children:[s.jsxs(Is,{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(Ts,{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:de=>Ce(de.target.value),placeholder:n(T==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:de=>{de.key==="Enter"&&kt()},autoFocus:!0})}),s.jsxs(yn,{children:[s.jsx(xt,{variant:"outline",onClick:()=>Q(null),disabled:xe,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(xt,{variant:T==="delete"?"destructive":"default",onClick:()=>{kt()},disabled:xe||T!=="delete"&&!ue.trim(),children:xe?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):n(T==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function Ey(t){return t.runtimeKey}const ql=60,My=t=>{try{return new URL(t).origin}catch{return""}},ui=new Set,Hu=tr()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=My(n);!i||!r||e().byOrigin[i]||ui.has(i)||(ui.add(i),mr("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)}))}})),_a=t=>t,Qi=t=>{const e=_a(t).type;return typeof e=="string"?e:""},Oy=t=>{const e=_a(t).tool;return typeof e=="string"?e:""},Fy=t=>{const e=_a(t).text;return typeof e=="string"?e:""},By=t=>{const e=Qi(t);return e==="tool"?Oy(t).trim().toLowerCase()||"tool":e||"unknown"},_y=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=By(n);e.includes(r)||e.push(r)}return e.join(" + ")},Ly=t=>t.replace(/\s+/g," ").trim(),$y=t=>{for(const n of t)if(Qi(n)==="text"){const r=Ly(Fy(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"}`},Wy=(t,e,n)=>`${n(t)} / ${n(e)}`,zy=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Vy=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=zy(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,mi=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}},Uy=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Gs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+Gs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+Gs(n),0):0,Ky=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...xo,assistant:Gs(n.text)+Gs(n.content)};const i=Uy(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Gs(n.input)+Gs(n.output)+Gs(n.error)+Gs(n.call?.input)+Gs(n.call?.output)+Gs(n.call?.error)+Gs(n.raw)+Math.round(Gs(n.metadata)*.25)+Math.round(Gs(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}},Ql=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),Hy=t=>{const e=Qr(t.info);return e.isUser?"user":e.role==="assistant"?"assistant":e.role==="tool"?"tool":"other"},Gy=(t,e)=>{if(t.length===0)return{...xo};const n=t.reduce((r,i)=>{const o=Hy(i);let l={...xo};for(const a of i.parts)l=Ql(l,Ky(a,o));return Ql(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()),qy=(t,e)=>!t||!Number.isFinite(t)?"-":Cd(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Qy=(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}},Yy=()=>{const t=et.c(203),{t:e}=Nt(),n=Te(Xy);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=Ze(Jy),h=Ze(Zy),m=Id(h??void 0),p=eh(d??"",h??void 0),g=Yt(e1);let w;t[1]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),o(t1),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,f;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},f=[],t[5]=x,t[6]=f):(x=t[5],f=t[6]),c.useEffect(x,f);let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=async(at,Oe)=>{(await gn(Oe)).ok?(a(at),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{a(mt=>mt===at?null:mt),u.current=null},2e3)):a(null)},t[7]=b):b=t[7];const y=b;let v;t[8]!==d||t[9]!==m?(v=d?m.find(at=>at.id===d)??null:null,t[8]=d,t[9]=m,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(s1);let at;t[19]!==p?(at=p.filter(n1),t[19]=p,t[20]=at):at=t[20],M=at;let Oe=null;for(let mt=C.length-1;mt>=0;mt=mt-1,mt){const bt=C[mt];if(mi(bt).total>0){Oe=bt;break}}P=Oe?mi(Oe):Yi,k=th({input:P.input,cache:{read:P.cacheRead,write:P.cacheWrite}}),I=C.reduce(r1,0);const ye=Oe?.info??null;D=Qy(g,ye?.providerID||"",ye?.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 at=[...p].reverse().find(o1)?.info?.system||"";L=Gy(p,at),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,te=Z??N?.time?.created??null;let se;t[26]!==j||t[27]!==B||t[28]!==A||t[29]!==R?(se={user:R,assistant:j,tool:A,other:B},t[26]=j,t[27]=B,t[28]=A,t[29]=R,t[30]=se):se=t[30];let ve;t[31]!==C.length||t[32]!==X||t[33]!==k||t[34]!==O||t[35]!==_||t[36]!==p.length||t[37]!==Y||t[38]!==te||t[39]!==se||t[40]!==ce||t[41]!==P||t[42]!==I||t[43]!==U||t[44]!==M.length?(ve={sessionTitle:ce,messagesCount:p.length,userMessagesCount:M.length,assistantMessagesCount:C.length,createdAt:Y,lastActivityAt:te,providerModel:_,tokenBreakdown:P,usagePercent:U,cacheHitRate:k,totalAssistantCost:I,contextLimit:O,breakdown:se,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]=te,t[39]=se,t[40]=ce,t[41]=P,t[42]=I,t[43]=U,t[44]=M.length,t[45]=ve):ve=t[45];const K=ve;if(!d){let at;t[46]!==e?(at=e("contextSidebar.empty.openSession"),t[46]=e,t[47]=at):at=t[47];let Oe;return t[48]!==at?(Oe=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:at}),t[48]=at,t[49]=Oe):Oe=t[49],Oe}let he;t[50]!==e?(he=e("contextSidebar.breakdown.user"),t[50]=e,t[51]=he):he=t[51];let be;t[52]!==he||t[53]!==K.breakdown.user?(be={key:"user",label:he,value:K.breakdown.user,color:"var(--status-success)"},t[52]=he,t[53]=K.breakdown.user,t[54]=be):be=t[54];let ie;t[55]!==e?(ie=e("contextSidebar.breakdown.assistant"),t[55]=e,t[56]=ie):ie=t[56];let T;t[57]!==ie||t[58]!==K.breakdown.assistant?(T={key:"assistant",label:ie,value:K.breakdown.assistant,color:"var(--primary-base)"},t[57]=ie,t[58]=K.breakdown.assistant,t[59]=T):T=t[59];let Q;t[60]!==e?(Q=e("contextSidebar.breakdown.toolCalls"),t[60]=e,t[61]=Q):Q=t[61];let le;t[62]!==Q||t[63]!==K.breakdown.tool?(le={key:"tool",label:Q,value:K.breakdown.tool,color:"var(--status-warning)"},t[62]=Q,t[63]=K.breakdown.tool,t[64]=le):le=t[64];let me;t[65]!==e?(me=e("contextSidebar.breakdown.other"),t[65]=e,t[66]=me):me=t[66];let ue;t[67]!==me||t[68]!==K.breakdown.other?(ue={key:"other",label:me,value:K.breakdown.other,color:"var(--surface-muted-foreground)"},t[67]=me,t[68]=K.breakdown.other,t[69]=ue):ue=t[69];let Ce;t[70]!==be||t[71]!==T||t[72]!==le||t[73]!==ue?(Ce=[be,T,le,ue],t[70]=be,t[71]=T,t[72]=le,t[73]=ue,t[74]=Ce):Ce=t[74];const xe=Ce;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 we;t[77]!==K.providerModel.modelName||t[78]!==K.providerModel.providerName?(we=s.jsxs("span",{children:[K.providerModel.providerName," / ",K.providerModel.modelName]}),t[77]=K.providerModel.modelName,t[78]=K.providerModel.providerName,t[79]=we):we=t[79];let G;t[80]!==n||t[81]!==K.createdAt?(G=K.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:qy(K.createdAt,n)})]}),t[80]=n,t[81]=K.createdAt,t[82]=G):G=t[82];let Se;t[83]!==we||t[84]!==G?(Se=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:[we,G]}),t[83]=we,t[84]=G,t[85]=Se):Se=t[85];let ge;t[86]!==Re||t[87]!==Se?(ge=s.jsxs("div",{className:"mb-6",children:[Re,Se]}),t[86]=Re,t[87]=Se,t[88]=ge):ge=t[88];let Ae;t[89]!==e?(Ae=e("contextSidebar.section.context"),t[89]=e,t[90]=Ae):Ae=t[90];let oe;t[91]!==Ae?(oe=s.jsx("span",{className:"typography-micro text-muted-foreground",children:Ae}),t[91]=Ae,t[92]=oe):oe=t[92];let ne;t[93]!==K.tokenBreakdown.total?(ne=Vn(K.tokenBreakdown.total),t[93]=K.tokenBreakdown.total,t[94]=ne):ne=t[94];let z;t[95]!==K.contextLimit?(z=K.contextLimit?` / ${Vn(K.contextLimit)}`:"",t[95]=K.contextLimit,t[96]=z):z=t[96];let $;t[97]!==ne||t[98]!==z?($=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[ne,z]}),t[97]=ne,t[98]=z,t[99]=$):$=t[99];let ae;t[100]!==oe||t[101]!==$?(ae=s.jsxs("div",{className:"flex items-baseline justify-between",children:[oe,$]}),t[100]=oe,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 je;t[105]!==W?(je=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]=je):je=t[106];let Ee;t[107]!==e||t[108]!==K.usagePercent?(Ee=e("contextSidebar.context.percentUsed",{percent:K.usagePercent.toFixed(1)}),t[107]=e,t[108]=K.usagePercent,t[109]=Ee):Ee=t[109];let Ne;t[110]!==Ee?(Ne=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Ee}),t[110]=Ee,t[111]=Ne):Ne=t[111];let Be;t[112]!==ae||t[113]!==je||t[114]!==Ne?(Be=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ae,je,Ne]}),t[112]=ae,t[113]=je,t[114]=Ne,t[115]=Be):Be=t[115];let ze;t[116]!==e?(ze=e("contextSidebar.stats.messages"),t[116]=e,t[117]=ze):ze=t[117];let We;t[118]!==K.messagesCount?(We=Vn(K.messagesCount),t[118]=K.messagesCount,t[119]=We):We=t[119];let V;t[120]!==ze||t[121]!==We?(V={label:ze,value:We},t[120]=ze,t[121]=We,t[122]=V):V=t[122];let fe;t[123]!==e?(fe=e("contextSidebar.stats.user"),t[123]=e,t[124]=fe):fe=t[124];let Me;t[125]!==K.userMessagesCount?(Me=Vn(K.userMessagesCount),t[125]=K.userMessagesCount,t[126]=Me):Me=t[126];let Pe;t[127]!==fe||t[128]!==Me?(Pe={label:fe,value:Me},t[127]=fe,t[128]=Me,t[129]=Pe):Pe=t[129];let ot;t[130]!==e?(ot=e("contextSidebar.stats.assistant"),t[130]=e,t[131]=ot):ot=t[131];let Ke;t[132]!==K.assistantMessagesCount?(Ke=Vn(K.assistantMessagesCount),t[132]=K.assistantMessagesCount,t[133]=Ke):Ke=t[133];let ht;t[134]!==ot||t[135]!==Ke?(ht={label:ot,value:Ke},t[134]=ot,t[135]=Ke,t[136]=ht):ht=t[136];let ft;t[137]!==e?(ft=e("contextSidebar.stats.cost"),t[137]=e,t[138]=ft):ft=t[138];let kt;t[139]!==K.totalAssistantCost?(kt=_g(K.totalAssistantCost),t[139]=K.totalAssistantCost,t[140]=kt):kt=t[140];let pe;t[141]!==ft||t[142]!==kt?(pe={label:ft,value:kt},t[141]=ft,t[142]=kt,t[143]=pe):pe=t[143];let Ye;t[144]!==V||t[145]!==Pe||t[146]!==ht||t[147]!==pe?(Ye=[V,Pe,ht,pe],t[144]=V,t[145]=Pe,t[146]=ht,t[147]=pe,t[148]=Ye):Ye=t[148];const wt=Ye;let jt;t[149]!==wt?(jt=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:wt.map(i1)}),t[149]=wt,t[150]=jt):jt=t[150];let de;t[151]!==e?(de=e("contextSidebar.section.lastAssistantMessage"),t[151]=e,t[152]=de):de=t[152];let Ve;t[153]!==de?(Ve=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:de}),t[153]=de,t[154]=Ve):Ve=t[154];let ct;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?(ct=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(a1)}),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]=ct):ct=t[163];let Le;t[164]!==Ve||t[165]!==ct?(Le=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Ve,ct]}),t[164]=Ve,t[165]=ct,t[166]=Le):Le=t[166];let J;t[167]!==xe||t[168]!==K.breakdownTotal?(J=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:xe.map(at=>at.value<=0||K.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${at.value/K.breakdownTotal*100}%`,backgroundColor:at.color}},at.key))}),t[167]=xe,t[168]=K.breakdownTotal,t[169]=J):J=t[169];let re;t[170]!==xe||t[171]!==K.breakdownTotal?(re=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:xe.map(at=>{const Oe=K.breakdownTotal>0?at.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:at.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[at.label," ",s.jsxs("span",{className:"tabular-nums",children:[Oe.toFixed(0),"%"]})]})]},at.key)})}),t[170]=xe,t[171]=K.breakdownTotal,t[172]=re):re=t[172];let ke;t[173]!==J||t[174]!==re?(ke=s.jsxs("div",{className:"mb-6",children:[J,re]}),t[173]=J,t[174]=re,t[175]=ke):ke=t[175];let Fe;t[176]!==e?(Fe=e("contextSidebar.section.rawMessages"),t[176]=e,t[177]=Fe):Fe=t[177];let Ue;t[178]!==Fe?(Ue=s.jsx("div",{className:"typography-micro text-muted-foreground",children:Fe}),t[178]=Fe,t[179]=Ue):Ue=t[179];let st;if(t[180]!==l||t[181]!==i||t[182]!==p||t[183]!==e||t[184]!==n){let at;t[186]!==l||t[187]!==i||t[188]!==e||t[189]!==n?(at=Oe=>{const mt=Qr(Oe.info).role,bt=mt==="assistant",It=mt==="user",Je=i[Oe.info.id]===!0,lt=l===Oe.info.id,vt=Oe.info.time?.created??null,yt=_y(Oe.parts),Tt=bt?mi({info:Oe.info,parts:Oe.parts}):null,Ct=It?$y(Oe.parts):"",Rt=Vy(vt,n),Bt=yt||"—",Gt=Tt?Wy(Tt.input,Tt.output,Vn):"",qt=mt||"unknown",Ut=yt?`${qt}: ${yt}`:qt,Wt=Je?JSON.stringify({info:Oe.info,parts:Oe.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":Je,onClick:()=>{o(Ft=>({...Ft,[Oe.info.id]:Ft[Oe.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:bt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[It?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",Ct]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:bt?Bt:Ut}),bt&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Gt})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Rt})]})}),Je&&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:Ft=>{Ft.stopPropagation(),y(Oe.info.id,Wt)},"aria-label":e(lt?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(lt?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:lt?s.jsx(E,{name:"check",className:"size-3.5"}):s.jsx(E,{name:"file-copy",className:"size-3.5"})})}),s.jsx(sh,{language:"json",code:Wt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Oe.info.id)},t[186]=l,t[187]=i,t[188]=e,t[189]=n,t[190]=at):at=t[190],st=[...p].reverse().map(at),t[180]=l,t[181]=i,t[182]=p,t[183]=e,t[184]=n,t[185]=st}else st=t[185];let it;t[191]!==st?(it=s.jsx("div",{className:"mt-2.5 space-y-1",children:st}),t[191]=st,t[192]=it):it=t[192];let rt;t[193]!==Ue||t[194]!==it?(rt=s.jsxs("div",{children:[Ue,it]}),t[193]=Ue,t[194]=it,t[195]=rt):rt=t[195];let qe;return t[196]!==ge||t[197]!==Be||t[198]!==jt||t[199]!==Le||t[200]!==ke||t[201]!==rt?(qe=s.jsx(dn,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ge,Be,jt,Le,ke,rt]})}),t[196]=ge,t[197]=Be,t[198]=jt,t[199]=Le,t[200]=ke,t[201]=rt,t[202]=qe):qe=t[202],qe};function Xy(t){return t.timeFormatPreference}function Jy(t){return t.currentSessionId}function Zy(t){return t.currentSessionDirectory}function e1(t){return t.providers}function t1(t){return Object.keys(t).length>0?{}:t}function s1(t){return Qr(t.info).role==="assistant"}function n1(t){return Qr(t.info).isUser}function r1(t,e){const n=En(e.info.cost);return t+n}function o1(t){return Qr(t.info).isUser&&typeof t.info.system=="string"}function i1(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 a1(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 Gu=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),l1=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return Gu.has(n.toLowerCase())},cn="about:blank",hr=t=>{const e=t.trim();if(!e)return cn;const n=e.includes("://")?e:`${l1(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?cn:r.toString()}catch{return cn}},yr=t=>{try{return Gu.has(new URL(t).hostname.toLowerCase())}catch{return!1}},La=t=>{if(!t||t===cn)return"";try{return new URL(t).host||t}catch{return t}},c1=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),d1=(t,e)=>c1.has(t)&&yr(e),u1=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"},m1=async t=>{try{const e=await us("/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(u1)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},f1=async t=>{try{const e=await us("/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}},h1=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}},p1=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=h1(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",g1=`(() => {
|
|
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
|
+
})();`,x1=(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
|
+
});`},b1={kind:"idle"},wn=t=>typeof t=="object"&&t!==null,kn=t=>typeof t=="number"&&Number.isFinite(t),Yl=t=>wn(t)&&Object.values(t).every(e=>typeof e=="string"),$a=t=>wn(t)&&kn(t.x)&&kn(t.y)&&kn(t.width)&&kn(t.height),qu=t=>wn(t)&&kn(t.x)&&kn(t.y),y1=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"),w1=t=>wn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&$a(t.bounds)&&qu(t.center)&&Yl(t.attributes)&&Yl(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(y1),S1=t=>wn(t)&&typeof t.id=="string"&&w1(t.element),v1=t=>wn(t)&&typeof t.id=="string"&&$a(t.rect),j1=t=>wn(t)&&typeof t.id=="string"&&$a(t.bounds)&&Array.isArray(t.points)&&t.points.every(qu),k1=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(S1)&&Array.isArray(t.regions)&&t.regions.every(v1)&&Array.isArray(t.strokes)&&t.strokes.every(j1),C1=1600,N1=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}),A1=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 N1(`data:${e};base64,${t}`),h=Math.max(1,d.naturalWidth||n),m=Math.max(1,d.naturalHeight||r),p=h/Math.max(1,i||h),g=m/Math.max(1,o||m),w=Math.min(1,C1/h),S=document.createElement("canvas");S.width=Math.max(1,Math.floor(h*w)),S.height=Math.max(1,Math.floor(m*w));const x=S.getContext("2d");if(!x)return null;x.scale(w,w),x.drawImage(d,0,0,h,m);const f=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=f(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}},D1="({ width: window.innerWidth, height: window.innerHeight })",P1=async t=>{try{const e=await t.executeJavaScript(D1,!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(g1,!1)}catch{}},I1=async({host:t,theme:e,labels:n})=>{const r=x1(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!k1(i))return await bo(t),null;const o=i;try{const l=await P1(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const u=await A1({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}}},an={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)"},T1=()=>{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()}},R1=t=>{const e=T1();if(!e)return{...an,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)`)||an.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",an.primary),primarySoft:r("--primary",16,an.primarySoft),primaryFaint:r("--primary",10,an.primaryFaint),primaryContrast:n("--primary-foreground",an.primaryContrast),surface:n("--surface-background",an.surface),surfaceElevated:n("--surface-elevated",an.surfaceElevated),border:n("--border",an.border),text:n("--foreground",an.text),mutedText:n("--muted-foreground",an.mutedText)}}catch{return{...an,colorScheme:t}}finally{e.dispose()}},E1=2e3,M1=50;let Qn=null,pr=null,Br=null;const O1=async t=>{try{const e=await us("/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 us("/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)}},F1=async(t=E1)=>{const e=Date.now()+t;for(;!Qn&&Date.now()<e;)await new Promise(n=>setTimeout(n,M1));return Qn},B1=async t=>{const e=t.action==="browser.open",n=Qn;if(!(!n&&!(e&&pr))&&await O1(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 F1();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)})}},Qu=()=>{Br||(Br=Yr(t=>{t.type==="browser-control-request"&&B1({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Yu=()=>{Qn||pr||!Br||(Br(),Br=null)},_1=t=>(Qn=t,Qu(),()=>{Qn===t&&(Qn=null),Yu()}),L1=t=>(pr=t,Qu(),()=>{pr===t&&(pr=null),Yu()}),$1=50,W1=6,z1=2048,V1=200,Xu=t=>{const e=hr(String(t??"").trim());if(!e||e.length>z1)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},U1=(t,e)=>{const n=Xu(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,V1)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,$1)},K1=(t,e)=>{const n=Xu(e);return t.filter(r=>r.url!==n)},H1=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Ju=(t,e,n=W1)=>{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=H1(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},Xl=20,yo=t=>{const e=St((t||"").trim());return e?JSON.stringify([fs(),e]):""},G1=t=>{const e=Object.keys(t);if(e.length<=Xl)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,Xl);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},gr=tr()(sx(t=>({byProject:{},recordVisit:(e,n)=>{const r=yo(e);r&&t(i=>{const o=i.byProject[r]??[],l=U1(o,{...n,at:Date.now()});return l===o?i:{byProject:G1({...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]:K1(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:of(),partialize:t=>({byProject:t.byProject})})),q1=[],Zu=t=>e=>{const n=yo(t);return(n?e.byProject[n]:void 0)??q1},Ji=new Map,Zo=new Map,Yn=new Map,Xn=new Set,Q1=async(t,e)=>{if(!Ga()){Xn.delete(t),ir(t,{type:"close"});return}if(await af(Nn()),!Xn.has(t)||!Ga())return;const n=dd().websocket(`/api/dev-tunnel?port=${e}`),r=lf(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"})}};nh(({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),Q1(t,e).catch(()=>{Xn.delete(t),ir(t,{type:"close"})})}});const em=()=>typeof window<"u"&&!!window.__AIWORKER_ELECTRON__,tm=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}},sm=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}},Jl=(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}},Zl=(t,e)=>{try{Zo.set(e,new URL(t).origin)}catch{}};class _r extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const ec=async t=>{if(!t||!em()||!yr(t))return t;const e=Nn();if(!tm(e))return t;const n=sm(t);if(!n)return t;const r=`${e}|${n}`,i=Ji.get(r);if(i)return Zl(t,i),Jl(t,i);try{const o=await mr("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:cf(),targetKey:fs(),clientToken:$r(),requestHeaders:ud()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new _r(t);return Ji.set(r,o.localPort),Zl(t,o.localPort),Jl(t,o.localPort)}catch(o){throw o instanceof _r?o:new _r(t)}},tc=t=>{if(!t||!em()||!yr(t)||!tm(Nn()))return!1;const e=sm(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}},Y1=()=>{Ji.clear(),Zo.clear(),Xn.clear();for(const t of Yn.values())t.close();Yn.clear(),mr("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&fa(Y1);const sc=6e3,X1=120,J1=80,Z1=`
|
|
608
|
+
var MAX_ELEMENTS = ${X1};
|
|
609
|
+
var MAX_LABEL_CHARS = ${J1};
|
|
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
|
+
${Z1}
|
|
724
|
+
${t}
|
|
725
|
+
})()`,ew=({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, ${sc}),
|
|
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 > ${sc}) {
|
|
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
|
+
`),tw=({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
|
+
`),sw=({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
|
+
`),nw=({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
|
+
`),rw=["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"],ow=({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(rw)};
|
|
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
|
+
`),iw=t=>{const e=et.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 m;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(m=(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||La(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]=m):m=e[14],d=n.map(m),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},ln=t=>{const e=et.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 m;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==d||e[10]!==h?(m=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]=m):m=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]!==m||e[15]!==p?(g=s.jsxs(At,{children:[m,p]}),e[14]=m,e[15]=p,e[16]=g):g=e[16],g},nm=t=>{const e=et.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:u,onReload:d,onOpenExternal:h,canGoBack:m,canGoForward:p,isLoading:g,onAnnotate:w,onOpenDevTools:S,isAnnotating:x,onHardReload:f,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=Be=>{L(!1),R(-1),l(Be)},e[9]=l,e[10]=H):H=e[10];const Z=H;let ce;e[11]!==F||e[12]!==Z||e[13]!==A?(ce=Be=>{if(A.length!==0){if(Be.key==="ArrowDown"||Be.key==="ArrowUp"){Be.preventDefault();const ze=Be.key==="ArrowDown"?1:-1,We=A.length;R(V=>{const fe=V+ze;return fe<-1?We-1:fe>=We?-1:fe});return}if(Be.key==="Escape"&&F>=0){Be.preventDefault(),R(-1);return}if(Be.key==="Enter"&&F>=0){Be.preventDefault();const ze=A[F];ze&&Z(ze.url)}}},e[11]=F,e[12]=Z,e[13]=A,e[14]=ce):ce=e[14];const Y=ce;let te;e[15]!==O?(te=O("contextPanel.browser.back"),e[15]=O,e[16]=te):te=e[16];const se=!m;let ve;e[17]!==a||e[18]!==se||e[19]!==te?(ve=s.jsx(ln,{icon:"arrow-left",label:te,onClick:a,disabled:se}),e[17]=a,e[18]=se,e[19]=te,e[20]=ve):ve=e[20];let K;e[21]!==O?(K=O("contextPanel.browser.forward"),e[21]=O,e[22]=K):K=e[22];const he=!p;let be;e[23]!==u||e[24]!==K||e[25]!==he?(be=s.jsx(ln,{icon:"arrow-right",label:K,onClick:u,disabled:he}),e[23]=u,e[24]=K,e[25]=he,e[26]=be):be=e[26];let ie;e[27]!==g||e[28]!==O?(ie=O(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=O,e[29]=ie):ie=e[29];let T;e[30]!==d||e[31]!==ie?(T=s.jsx(ln,{icon:"refresh",label:ie,onClick:d}),e[30]=d,e[31]=ie,e[32]=T):T=e[32];let Q;e[33]!==f||e[34]!==O?(Q=f?s.jsx(ln,{icon:"restart",label:O("contextPanel.browser.hardReload"),onClick:f}):null,e[33]=f,e[34]=O,e[35]=Q):Q=e[35];let le;e[36]!==n||e[37]!==Z?(le=Be=>{Be.preventDefault(),Z(n)},e[36]=n,e[37]=Z,e[38]=le):le=e[38];let me;e[39]!==o?(me=Be=>o(Be.target.value),e[39]=o,e[40]=me):me=e[40];let ue,Ce;e[41]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>L(!0),Ce=()=>L(!1),e[41]=ue,e[42]=Ce):(ue=e[41],Ce=e[42]);const xe=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 we;e[44]!==O?(we=O("contextPanel.browser.addressAria"),e[44]=O,e[45]=we):we=e[45];let G;e[46]!==n||e[47]!==Y||e[48]!==me||e[49]!==xe||e[50]!==we?(G=s.jsx("input",{value:n,onChange:me,onFocus:ue,onBlur:Ce,onKeyDown:Y,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":xe,"aria-controls":"openchamber-browser-address-suggestions",className:Re,"aria-label":we}),e[46]=n,e[47]=Y,e[48]=me,e[49]=xe,e[50]=we,e[51]=G):G=e[51];let Se;e[52]!==i?(Se=Be=>i?.(Be),e[52]=i,e[53]=Se):Se=e[53];let ge;e[54]!==F||e[55]!==Z||e[56]!==Se||e[57]!==A?(ge=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(iw,{entries:A,activeIndex:F,onSelect:Z,onForget:Se,onHighlight:R})}),e[54]=F,e[55]=Z,e[56]=Se,e[57]=A,e[58]=ge):ge=e[58];let Ae;e[59]!==le||e[60]!==G||e[61]!==ge?(Ae=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:le,children:[G,ge]}),e[59]=le,e[60]=G,e[61]=ge,e[62]=Ae):Ae=e[62];let oe;e[63]!==b||e[64]!==y||e[65]!==v||e[66]!==O||e[67]!==_?(oe=y&&b?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(ln,{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(ln,{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]=oe):oe=e[68];let ne;e[69]!==C||e[70]!==O?(ne=C?s.jsx(ln,{icon:"delete-bin",label:O("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=O,e[71]=ne):ne=e[71];let z;e[72]!==k||e[73]!==O?(z=k?s.jsx(ln,{icon:"database-2",label:O("contextPanel.browser.clearCache"),onClick:k}):null,e[72]=k,e[73]=O,e[74]=z):z=e[74];let $;e[75]!==P||e[76]!==D||e[77]!==O?($=D?s.jsx(ln,{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(ln,{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(ln,{icon:"terminal-box",label:O("contextPanel.browser.devTools"),onClick:S}):null,e[83]=S,e[84]=O,e[85]=W):W=e[85];let je;e[86]!==O?(je=O("contextPanel.browser.openExternal"),e[86]=O,e[87]=je):je=e[87];let Ee;e[88]!==h||e[89]!==je?(Ee=s.jsx(ln,{icon:"external-link",label:je,onClick:h}),e[88]=h,e[89]=je,e[90]=Ee):Ee=e[90];let Ne;return e[91]!==ve||e[92]!==be||e[93]!==T||e[94]!==Q||e[95]!==Ae||e[96]!==oe||e[97]!==ne||e[98]!==z||e[99]!==$||e[100]!==ae||e[101]!==W||e[102]!==Ee?(Ne=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[ve,be,T,Q,Ae,oe,ne,z,$,ae,W,Ee]}),e[91]=ve,e[92]=be,e[93]=T,e[94]=Q,e[95]=Ae,e[96]=oe,e[97]=ne,e[98]=z,e[99]=$,e[100]=ae,e[101]=W,e[102]=Ee,e[103]=Ne):Ne=e[103],Ne},Mo={kind:"fill"},nc=240,aw=3840,rm=[{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}],rc=t=>Number.isFinite(t)?Math.round(Math.min(aw,Math.max(nc,t))):nc,Oo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},om=t=>{const e=rm.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},lw=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},cw=(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}},dw=["mobile","tablet","desktop","fill"],uw={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},oc=t=>typeof t=="string"&&dw.includes(t),Zi=t=>t==="fill"?Mo:om(uw[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}},mw=t=>{const e=et.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 m;e[2]!==r||e[3]!==d?(m=(se,ve)=>{const K=Number.parseInt(ve,10);if(!Number.isFinite(K))return;const he=d??{width:1280,height:800};r({kind:"custom",width:rc(se==="width"?K:he.width),height:rc(se==="height"?K:he.height)})},e[2]=r,e[3]=d,e[4]=m):m=e[4];const p=m;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=se=>{const ve=om(se.target.value);r(ve??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 f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=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]=f):f=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=rm.map(fw),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:f,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=se=>p("width",se.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?(_=se=>p("height",se.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(lw(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(se=>s.jsx(xt,{type:"button",variant:i===se?"secondary":"ghost",size:"xs",className:Ie("shrink-0 rounded-full px-2.5 typography-micro",i===se?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(se),"aria-pressed":i===se,children:a(se==="system"?"contextPanel.browser.device.schemeSystem":se==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},se))}),e[59]=i,e[60]=o,e[61]=a,e[62]=Y):Y=e[62];let te;return e[63]!==N||e[64]!==P||e[65]!==U||e[66]!==H||e[67]!==Z||e[68]!==Y?(te=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]=te):te=e[69],te};function fw(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const hw=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},pw=2e3,gw=()=>{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}},im=t=>{const e=et.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=Cx(i),[h]=c.useState(gw);let m,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{let P=!0,I=null;const M=new AbortController,_=()=>{m1(M.signal).then(O=>{P&&(u(O),I=setTimeout(_,pw))})};return _(),()=>{P=!1,I&&clearTimeout(I),M.abort()}},p=[],e[1]=m,e[2]=p):(m=e[1],p=e[2]),c.useEffect(m,p);const g=a.kind==="ready"?a.servers:null;let w;e[3]!==d||e[4]!==g?(w=p1({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 f;e[7]!==o?(f=o("contextPanel.browser.empty"),e[7]=o,e[8]=f):f=e[8];let b;e[9]!==f?(b=s.jsx("span",{className:"typography-ui-header text-foreground",children:f}),e[9]=f,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:()=>{vx(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:La(P.url)||P.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:hw(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),xw=(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")},bw=(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)}`},yw=(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)}`},ww=({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("",...xw(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(bw(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(yw(l,a)))),o.filter(l=>typeof l=="string").join(`
|
|
912
|
+
`)},Sw=t=>{const e=et.c(7),{t:n}=Nt(),r=Ze(jw),i=Ze(kw),o=ji(Cw),l=rh(Nw);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){_e.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:ww({payload:u.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),_e.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},vw=()=>{const t=et.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 jw(t){return t.currentSessionId}function kw(t){return t.newSessionDraft?.open}function Cw(t){return t.addDraft}function Nw(t){return t.addAttachedFile}const Aw=3e4,Dw=3,Pw=250,Iw={attempts:0,windowStartedAt:null},Tw=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=Aw,r=n?0:t.attempts;return r>=Dw?null:{delayMs:Pw*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Rw=-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},Ew=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:b1),[o,l]=c.useState(e),[a,u]=c.useState(""),[d,h]=c.useState(!1),[m,p]=c.useState(!1),g=c.useRef(n);g.current=n;const w=c.useRef(Iw);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{}},f=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),f(I),x(),i(_=>_.kind==="failed"&&_.url===I?_:{kind:"ready",url:I,title:M})},v=I=>{const M=dr(I);oo(M.url)&&(f(M.url),x())},N=I=>{const M=dr(I),_=Array.isArray(M.favicons)?M.favicons.find(Boolean):"",O=S();_&&O&&Hu.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;_!==Rw&&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=Tw(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:m}},Mw=()=>typeof window<"u"&&!!window.__AIWORKER_ELECTRON__,Ow=4e4,io=.5,Fw=-3,Bw=4,_w="persist:openchamber-browser",ic=20,Lw=600,$w=2e4,Ww=({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(oe=>{o.current=oe,a(oe)},[]),d=Te(oe=>oe.setContextPanelTabTargetPath),h=c.useRef(hr(t)),m=h.current!==cn?h.current:"",[p,g]=c.useState(m?null:cn),[w,S]=c.useState(m),[x,f]=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(oe=>{!oe||oe===cn||!e||!n||d(e,n,oe)},[e,n,d]),H=Ew(l,{initialUrl:m,onUrlChange:c.useCallback(oe=>{const ne=Ar(oe);S(ne),X(ne)},[X])}),[Z,ce]=c.useState(null),Y=Sw(e),te=vw(),se=H.status.kind==="loading",ve=gr(Zu(e)),K=gr(oe=>oe.recordVisit),he=gr(oe=>oe.forget);c.useEffect(()=>{H.status.kind==="ready"&&K(e,{url:Ar(H.status.url),title:H.status.title})},[e,H.status,K]);const be=c.useMemo(()=>Ju(ve,w),[ve,w]),ie=c.useCallback(oe=>{const ne=hr(oe);ne!==cn&&(S(ne),ce(null),ec(ne).then(z=>{const $=o.current;if(!$){g(z);return}try{$.loadURL(z)}catch{g(z)}}).catch(z=>{z instanceof _r&&ce(ne)}))},[]);c.useEffect(()=>{if(!m)return;let oe=!0;return ec(m).then(ne=>{oe&&g(ne)}).catch(ne=>{if(oe){if(ne instanceof _r){ce(m),g(cn);return}g(m)}}),()=>{oe=!1}},[]);const T=c.useMemo(()=>({executeJavaScript:async(oe,ne)=>{const z=o.current;if(!z)throw new Error("Browser view is not available");return z.executeJavaScript(oe,ne)},capturePage:async()=>{const oe=o.current;if(!oe)return null;const ne=oe.getWebContentsId();return Number.isFinite(ne)?await mr("desktop_browser_capture_page",{webContentsId:ne}):null}}),[]),Q=c.useCallback(()=>{if(x){f(!1),bo(T);return}if(!H.url){_e.error(r("contextPanel.browser.annotate.noPage"));return}const oe=R1(i.metadata.variant==="light"?"light":"dark");f(!0),I1({host:T,theme:oe,labels:te}).then(async ne=>{f(!1),ne&&await Y(ne)}).catch(()=>{f(!1),_e.error(r("contextPanel.browser.annotate.failed"))})},[T,Y,i,x,H.url,te,r]);c.useEffect(()=>{if(!x)return;const oe=ne=>{oh(ne)||ne.key!=="Escape"||(ne.preventDefault(),ne.stopImmediatePropagation(),f(!1),bo(T))};return window.addEventListener("keydown",oe,!0),()=>window.removeEventListener("keydown",oe,!0)},[T,x]);const le=c.useCallback(async(oe=8e3)=>{const ne=Date.now();for(;;){const z=o.current;if(!z)return!1;let $=!1;try{$=z.isLoading()}catch{return!1}if(!$)return!0;if(Date.now()-ne>oe)return!1;await new Promise(ae=>setTimeout(ae,120))}},[]),me=c.useCallback(async(oe,ne)=>{const z=o.current;if(!z)throw new Error("The browser panel is not ready");const $=()=>{oc(ne.viewport)&&(I(Zi(ne.viewport)),D(!0))};if(oe==="browser.back"||oe==="browser.forward"){const Be=oe==="browser.back";if(!(Be?z.canGoBack():z.canGoForward()))throw new Error(Be?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Be?z.goBack():z.goForward(),await new Promise(V=>setTimeout(V,150)),await le();let We="";try{We=z.getTitle()||""}catch{We=""}return{url:Ar(z.getURL()),title:We}}if(oe==="browser.capture"){Te.getState().openContextBrowser(e,z.getURL());const Be=Date.now()+1200;let ze=0,We=0;for(;We<2&&Date.now()<Be;){const Me=z.getBoundingClientRect().width;We=Me>=2&&Math.abs(Me-ze)<.5?We+1:0,ze=Me,await new Promise(Pe=>setTimeout(Pe,50))}await new Promise(Me=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Me()))}),await le();const V=await T.capturePage();if(!V)throw new Error("The page could not be captured");let fe="";try{fe=z.getTitle()||""}catch{fe=""}return{...V,url:Ar(z.getURL()),title:fe,viewport:ro(M.current)}}if(oe==="browser.resize"){if(!oc(ne.viewport))throw new Error("viewport is required");return $(),await new Promise(Be=>setTimeout(Be,200)),await le(),{viewport:ro(Zi(ne.viewport))}}if(oe==="browser.open"){const Be=typeof ne.url=="string"?ne.url:"";if(!Be)throw new Error("url is required");$(),ie(Be),await new Promise(V=>setTimeout(V,150));const ze=await le(25e3);let We="";try{We=z.getTitle()||""}catch{We=""}return{url:hr(Be),title:We,opened:!0,settled:ze,viewport:ro(M.current)}}await le();const ae=Be=>typeof Be=="string"&&Be?Be:void 0,je=(()=>{switch(oe){case"browser.snapshot":return ew({selector:ae(ne.selector)});case"browser.click":return tw({selector:ae(ne.selector),text:ae(ne.text)});case"browser.type":return sw({selector:String(ne.selector??""),value:String(ne.value??""),submit:ne.submit===!0});case"browser.inspect":return ow({selector:String(ne.selector??"")});case"browser.scroll":return nw({selector:ae(ne.selector),direction:ae(ne.direction)});default:return null}})();if(!je)throw new Error(`Unsupported browser action: ${oe}`);const Ee=await z.executeJavaScript(je,!0);if(!Ee||typeof Ee!="object")throw new Error("The page returned no result");const Ne=Ee;if(Ne.ok!==!0)throw new Error(typeof Ne.error=="string"&&Ne.error?Ne.error:"Browser action failed");if(oe==="browser.snapshot"){const Be=_.current;return{...Ne,viewport:ro(M.current),...Be.length>0?{consoleProblems:[...Be]}:{}}}return(oe==="browser.click"||oe==="browser.type"&&ne.submit===!0)&&(await new Promise(Be=>setTimeout(Be,150)),await le()),Ee},[T,e,ie,le]);c.useEffect(()=>_1({run:me}),[me]),c.useEffect(()=>{const oe=T;return()=>{bo(oe)}},[T]),c.useEffect(()=>{if(!l)return;const oe=z=>{const $=z;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>ic&&_.current.splice(0,_.current.length-ic)},ne=()=>{_.current=[]};return l.addEventListener("console-message",oe),l.addEventListener("did-start-loading",ne),()=>{l.removeEventListener("console-message",oe),l.removeEventListener("did-start-loading",ne)}},[l]);const ue=c.useRef(new Set),Ce=c.useCallback(oe=>{ue.current.clear(),ie(oe)},[ie]);c.useEffect(()=>{if(!l)return;const oe=z=>{const $=dr(z),ae=typeof $.url=="string"?$.url:"";!ae||!tc(ae)||(z.preventDefault(),ie(ae))},ne=z=>{const $=dr(z);if($.isMainFrame===!1||$.errorCode===-3)return;const ae=typeof $.validatedURL=="string"?$.validatedURL:"";!ae||!tc(ae)||ue.current.has(ae)||(ue.current.add(ae),ie(ae))};return l.addEventListener("will-navigate",oe),l.addEventListener("did-fail-load",ne),()=>{l.removeEventListener("will-navigate",oe),l.removeEventListener("did-fail-load",ne)}},[ie,l]),c.useEffect(()=>{if(!l)return;const oe=ne=>{const z=ne.detail;ne.preventDefault(),z?.url&&ie(z.url)};return l.addEventListener("new-window",oe),()=>l.removeEventListener("new-window",oe)},[ie,l]);const xe=c.useCallback(oe=>{const ne=Math.min(Bw,Math.max(Fw,oe));C.current=ne,N(ne);try{o.current?.setZoomLevel(ne)}catch{}},[]);c.useEffect(()=>{const oe=ne=>{if(!(ne instanceof CustomEvent))return;const z=ne.detail,$=o.current;!$||document.activeElement!==$||(z==="zoom-in"?xe(C.current+io):z==="zoom-out"?xe(C.current-io):z==="zoom-reset"&&xe(0))};return window.addEventListener("aiworker:zoom",oe),()=>window.removeEventListener("aiworker:zoom",oe)},[xe]);const Re=c.useCallback(oe=>{mr("desktop_browser_clear_data",{partition:_w,cookies:oe==="cookies",cache:oe==="cache"}).then(()=>{_e.success(r(oe==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>_e.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const oe=R.current;if(!oe||typeof ResizeObserver>"u")return;const ne=new ResizeObserver(z=>{const $=z[0]?.contentRect;$&&F({width:$.width,height:$.height})});return ne.observe(oe),()=>ne.disconnect()},[]);const we=c.useCallback(oe=>{U(oe);const ne=o.current;if(!ne)return;let z=-1;try{z=ne.getWebContentsId()}catch{return}mr("desktop_browser_set_color_scheme",{webContentsId:z,scheme:oe}).catch($=>{U("system"),_e.error($ instanceof Error?$.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),G=c.useCallback(()=>{try{se?o.current?.stop():o.current?.reload()}catch{}},[se]),Se=H.status;c.useEffect(()=>{const oe=()=>{y(!0);const $=setTimeout(()=>{try{o.current?.reload()}catch{}},Lw);return()=>clearTimeout($)};if(Se.kind==="failed"){if(!d1(Se.code,Se.url)){y(!1);return}const $=Date.now(),ae=j.current?.url===Se.url?j.current:{url:Se.url,startedAt:$};if(j.current=ae,$-ae.startedAt>Ow){y(!1);return}return oe()}if(Se.kind==="loading")return;if(j.current=null,Se.kind!=="ready"||!Se.url||!yr(Se.url)){A.current=!0,y(!1);return}if(A.current||Date.now()-B.current>$w){A.current=!0,y(!1);return}let ne=!1,z=null;return f1(Ar(Se.url)).then($=>{if(!ne){if($===null||$<500){A.current=!0,y(!1);return}z=oe()}}),()=>{ne=!0,z?.()}},[Se]);const ge=H.status.kind==="failed"&&!b?H.status:null,Ae=cw(P,L);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(nm,{address:w,onAddressChange:S,onSubmit:Ce,suggestions:be,onForgetSuggestion:oe=>he(e,oe),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:G,onOpenExternal:()=>{Uo(H.url||w)},canGoBack:H.canGoBack,canGoForward:H.canGoForward,isLoading:se,onAnnotate:Q,isAnnotating:x,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>xe(v+io),onZoomOut:()=>xe(v-io),onZoomReset:()=>xe(0),zoomPercent:Math.round(Math.pow(1.2,v)*100),onClearCookies:()=>Re("cookies"),onClearCache:()=>Re("cache"),onToggleDeviceBar:()=>D(oe=>!oe),isDeviceBarOpen:k}),k?s.jsx(mw,{viewport:P,onViewportChange:I,colorScheme:O,onColorSchemeChange:we,scale:Ae?.scale??1}):null,s.jsxs("div",{ref:R,className:Ie("relative min-h-0 flex-1 bg-background",Ae&&"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:Ae?{width:`${Ae.width}px`,height:`${Ae.height}px`,transform:`scale(${Ae.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!m&&!H.url&&!se?s.jsx(im,{onOpen:Ce,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,ge&&!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:ge.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ge.crashed?r("contextPanel.browser.crashedHint"):ge.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,se?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]})]})},zw=t=>{const e=et.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=Nt(),l=Te(Uw);let a;e[0]!==n?(a=hr(n),e[0]=n,e[1]=a):a=e[1];const u=a,d=u!==cn?u:"",[h,m]=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),[f,b]=c.useState(d?0:-1),[y,v]=c.useReducer(Kw,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=te=>{!te||te===cn||!r||!i||l(r,i,te)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const C=N;let k;e[8]!==r?(k=Zu(r),e[8]=r,e[9]=k):k=e[9];const D=gr(k),P=gr(Hw),I=gr(Gw);let M;e[10]!==h||e[11]!==D?(M=Ju(D,h),e[10]=h,e[11]=D,e[12]=M):M=e[12];const _=M;let O;e[13]!==r||e[14]!==f||e[15]!==C||e[16]!==P?(O=te=>{const se=hr(te);se!==cn&&(m(se),g(se),C(se),P(r,{url:se}),x(ve=>{const K=f>=0?ve.slice(0,f+1):[];return K[K.length-1]===se?(b(K.length-1),K):(b(K.length),[...K,se])}))},e[13]=r,e[14]=f,e[15]=C,e[16]=P,e[17]=O):O=e[17];const U=O;let L;e[18]!==S||e[19]!==C?(L=te=>{const se=S[te];se&&(b(te),m(se),g(se),C(se))},e[18]=S,e[19]=C,e[20]=L):L=e[20];const F=L;let R;e[21]!==r||e[22]!==I?(R=te=>I(r,te),e[21]=r,e[22]=I,e[23]=R):R=e[23];let j,A;e[24]!==F||e[25]!==f?(A=()=>F(f-1),j=()=>F(f+1),e[24]=F,e[25]=f,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=f>0,H=f>=0&&f<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(nm,{address:h,onAddressChange:m,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(im,{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},Vw=t=>{const e=et.c(3),[n]=c.useState(Mw);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Ww,{...t}):s.jsx(zw,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Uw(t){return t.setContextPanelTabTargetPath}function Kw(t){return t+1}function Hw(t){return t.recordVisit}function Gw(t){return t.forget}const qw=Ln(()=>Bn(()=>import("./WalkthroughView-hmnM70S9.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}))),Qw=Ln(()=>Bn(()=>import("./DiffView-BYwAHIlW.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}))),Yw=Ln(()=>Bn(()=>import("./FilesView-lrP5OlzK.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}))),Xw=Ln(()=>Bn(()=>import("./GitView-CCUK73JL.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}))),Jw=Ln(()=>Bn(()=>import("./LinearIssuesView-C0WwIDQN.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}))),Zw=Ln(()=>Bn(()=>import("./PlanView-k63mHfFF.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}))),eS=320,tS=1400,am=600,sS=100,nS=24,Fo=new Map,rS=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},ac=t=>Number.isFinite(t)?Math.min(tS,Math.max(eS,Math.round(t))):am,oS=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},iS=(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},lm=(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"),aS=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},lS=(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"?La(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?aS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):lm(t.mode,n)},lc=(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(Fu,{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=cS(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"})}},cS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},dS=200,uS=480,mS=({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),m=c.useRef(null),p=c.useCallback(b=>Math.min(uS,Math.max(dS,Math.round(b))),[]),g=c.useCallback(b=>{const y=m.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)},f=t?r:0;return s.jsxs("div",{ref:m,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??f:f}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(Ty,{visible:t&&e})})]})},ea=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,fS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},hS=(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},pS=(t,e)=>{const n=jd(t),r=c.useRef(Fo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=hS(n.getState().session,i.current);return fS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Fo)},gS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,xS=()=>{const{t}=Nt(),e=er()??"",n=c.useMemo(()=>rS(e),[e]),r=Te(pe=>n?pe.contextPanelByDirectory[n]:void 0),i=Te(pe=>pe.closeContextPanel),o=Te(pe=>pe.closeContextPanelTab),l=Te(pe=>pe.openContextPanelTab),a=Te(pe=>pe.toggleContextPanelExpanded),u=Te(pe=>pe.setContextPanelWidth),d=Te(pe=>pe.setActiveContextPanelTab),h=Te(pe=>pe.openContextBrowser);c.useEffect(()=>{if(e)return L1(pe=>h(e,pe))},[e,h]);const m=Te(pe=>pe.reorderContextPanelTabs),p=hn(pe=>pe.setSelectedPath),g=Te(pe=>pe.contextEditorTreeVisible),w=Te(pe=>pe.toggleContextEditorTree),S=Te(pe=>pe.openNewContextBrowserTab),x=Hu(pe=>pe.byOrigin),f=Te(pe=>pe.allowPromptingSubagentSessions),{themeMode:b,setThemeMode:y,lightThemeId:v,darkThemeId:N,currentTheme:C}=Zn(),k=c.useMemo(()=>r?.tabs??[],[r?.tabs]),D=k.find(pe=>pe.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?ih(O):.5,R=M??(typeof window<"u"?window.innerWidth:am*2),j=L!=null&&M!=null?Math.round(L*M):U,A=ac(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 pe=[];for(const Ye of k){if(Ye.mode!=="chat")continue;const wt=ea(Ye.dedupeKey);wt&&!pe.includes(wt)&&pe.push(wt)}return pe},[k]),X=pS(n||void 0,B),[H,Z]=c.useState(!1),ce=c.useRef(0),Y=c.useRef(A),te=c.useRef(null),se=c.useRef(null),ve=c.useRef(null),K=c.useRef(new Map),he=c.useRef(new Map),be=c.useRef(!1);c.useLayoutEffect(()=>{const pe=ve.current?.parentElement;if(!pe||typeof ResizeObserver>"u")return;const Ye=new ResizeObserver(()=>{_(pe.clientWidth||null)});return Ye.observe(pe),_(pe.clientWidth||null),()=>Ye.disconnect()},[]),c.useEffect(()=>{if(!P||be.current){be.current=P;return}const pe=window.requestAnimationFrame(()=>{ve.current?.focus({preventScroll:!0})});return be.current=!0,()=>window.cancelAnimationFrame(pe)},[P]);const ie=c.useRef(null),T=c.useRef(null),Q=c.useCallback(()=>{T.current=null;const pe=ve.current,Ye=te.current;!pe||Ye===null||pe.style.setProperty("--oc-context-panel-width",`${Ye}px`)},[]);c.useEffect(()=>()=>{T.current!==null&&clearTimeout(T.current)},[]);const le=c.useCallback(pe=>{const Ye=ac(pe),wt=ie.current;return wt===null?Ye:Math.min(Ye,Math.max(1,wt))},[]),me=c.useCallback(pe=>{!P||I||!n||(se.current=pe.pointerId,Z(!0),ce.current=pe.clientX,Y.current=A,te.current=A,ie.current=oS(ve.current),document.documentElement.style.cursor="col-resize",pe.preventDefault())},[n,I,P,A]),ue=c.useCallback(()=>{const pe=le(te.current??A),Ye=ie.current;te.current=null,ie.current=null,T.current!==null&&(clearTimeout(T.current),T.current=null),document.documentElement.style.cursor="",n&&O&&u(n,O,pe,Ye??void 0),Z(!1),se.current=null},[O,le,n,u,A]);c.useEffect(()=>{if(!H)return;const pe=jt=>{if(se.current!==jt.pointerId)return;const de=ce.current-jt.clientX,Ve=le(Y.current+de);te.current!==Ve&&(te.current=Ve,T.current===null&&(T.current=setTimeout(Q,sS)))},Ye=jt=>{se.current===jt.pointerId&&ue()},wt=()=>{ue()};return window.addEventListener("pointermove",pe),window.addEventListener("pointerup",Ye),window.addEventListener("pointercancel",Ye),window.addEventListener("blur",wt),()=>{window.removeEventListener("pointermove",pe),window.removeEventListener("pointerup",Ye),window.removeEventListener("pointercancel",Ye),window.removeEventListener("blur",wt)}},[Q,le,ue,H]),c.useEffect(()=>{H||(te.current=null,document.documentElement.style.cursor="")},[H]);const Ce=c.useCallback(()=>{n&&i(n)},[i,n]),xe=c.useCallback(()=>{n&&a(n)},[n,a]),Re=c.useCallback(pe=>{pe.key==="Escape"&&(ah(pe.target)||lh(pe.target)||(pe.preventDefault(),pe.stopPropagation(),Ce()))},[Ce]);c.useEffect(()=>{if(!(!n||!D)&&D.mode==="file"&&D.targetPath){p(n,D.targetPath,{allowOutsideRoot:!0});return}},[D,n,p]);const we=c.useMemo(()=>k.filter(pe=>pe.mode==="chat"),[k]),G=P&&D?.mode==="chat"?D.id:null,Se=P&&D?.mode==="chat"?ea(D.dedupeKey):null,ge=nx(we,G);c.useEffect(()=>{if(!P||!n||!Se||typeof window>"u")return;const pe=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ei(n,Se,!1);return}Rd(Se),ei(n,Se,!0)};pe();const Ye=window.setInterval(pe,1e4);return window.addEventListener("focus",pe),window.addEventListener("blur",pe),document.addEventListener("visibilitychange",pe),()=>{window.clearInterval(Ye),window.removeEventListener("focus",pe),window.removeEventListener("blur",pe),document.removeEventListener("visibilitychange",pe),ei(n,Se,!1)}},[Se,n,P]);const Ae=c.useCallback((pe,Ye,wt)=>rx(he.current,pe,Ye,n||null,wt,{mode:b,lightThemeId:v,darkThemeId:N,currentTheme:C},{allowPromptingSubagentSessions:f}),[f,C,N,n,v,b]),oe=ge&&Se?Ae(ge.id,Se,ge.readOnly):null;c.useEffect(()=>{const pe=new Set(k.map(Ye=>Ye.id));for(const Ye of he.current.keys())pe.has(Ye)||he.current.delete(Ye)},[k]);const ne=c.useCallback(pe=>{!n||D?.mode!=="diff"||l(n,{mode:"diff",targetPath:D.targetPath,stagedDiff:pe==="staged",diffScope:pe})},[D,n,l]),z=c.useCallback(()=>{if(typeof window>"u")return;const pe={themeMode:b,lightThemeId:v,darkThemeId:N,currentTheme:C};for(const Ye of K.current.values()){const wt=Ye.contentWindow;wt&&wt.postMessage({type:"aiworker:theme-sync",payload:pe},window.location.origin)}},[C,N,v,b]),$=c.useCallback(()=>{if(typeof window>"u")return;const pe={allowPromptingSubagentSessions:f};for(const Ye of K.current.values()){const wt=Ye.contentWindow;wt&&wt.postMessage({type:"aiworker:chat-settings-sync",payload:pe},window.location.origin)}},[f]),ae=c.useCallback((pe,Ye,wt)=>{const jt=Ye.contentWindow;jt&&jt.postMessage({type:yu,payload:{visible:G===pe}},wt)},[G]),W=c.useCallback(()=>{if(!(typeof window>"u"))for(const[pe,Ye]of K.current.entries())ae(pe,Ye,window.location.origin)},[ae]);c.useEffect(()=>{if(typeof window>"u")return;const pe=Ye=>{if(Ye.origin!==window.location.origin)return;const wt=Array.from(K.current.entries()).find(([,Le])=>Le.contentWindow===Ye.source);if(!wt)return;const jt=Ye.data;if(jt?.type===ox){const[Le,J]=wt;ae(Le,J,Ye.origin);return}if(jt?.type===ix){if(typeof jt.requestId!="string"||!jt.requestId)return;const Le=fs(),J={apiBaseUrl:Nn(),clientToken:$r(),localOrigin:typeof window.__AIWORKER_LOCAL_ORIGIN__=="string"?window.__AIWORKER_LOCAL_ORIGIN__:"",runtimeHeaders:ud(),relayHostId:Le.startsWith("host:")?Le.slice(5):"",relay:df()??void 0};Ye.source?.postMessage({type:ax,requestId:jt.requestId,payload:J},Ye.origin);return}if(jt?.type==="aiworker:theme-sync-request"){z();return}if(jt?.type==="aiworker:chat-settings-request"){$();return}if(jt?.type!=="aiworker:cycle-theme-request")return;const de=["light","dark","system"],ct=(de.indexOf(b)+1)%de.length;y(de[ct])};return window.addEventListener("message",pe),()=>window.removeEventListener("message",pe)},[$,ae,z,y,b]),c.useLayoutEffect(()=>{k.some(Ye=>Ye.mode==="chat")&&(z(),$(),W())},[N,v,$,W,z,k,b]);const je=D?.mode==="file"||D?.mode==="chat"||D?.mode==="browser",Ee=c.useMemo(()=>D?k.filter(pe=>pe.mode===D.mode):[],[D,k]),Ne=c.useMemo(()=>Ee.map(pe=>{const Ye=lS(pe,X,t),wt=gS(Ye,nS),jt=iS(pe.targetPath,e);return{id:pe.id,label:wt,icon:lc(pe,x),title:jt?`${Ye}: ${jt}`:Ye,closeLabel:t("contextPanel.tab.closeTabAria",{label:wt})}}),[Ee,e,x,X,t]),Be=D?.mode==="context"?s.jsx(Yy,{}):D?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Xw,{isActive:P})}):D?.mode==="pr"?s.jsx(ry,{}):D?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Jw,{})}):D?.mode==="notes"?s.jsx(fg,{}):D?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Zw,{targetPath:D.targetPath,savedProjectPlan:D.projectPlanId&&D.projectPlanRef?{projectRef:D.projectPlanRef,planId:D.projectPlanId}:null})}):null,ze=c.useMemo(()=>k.filter(pe=>pe.mode==="browser"),[k]),We=c.useMemo(()=>k.filter(pe=>pe.mode==="diff"),[k]),V=c.useMemo(()=>k.find(pe=>pe.mode==="terminal")??null,[k]),fe=c.useMemo(()=>k.some(pe=>pe.mode==="walkthrough"),[k]),Me=c.useMemo(()=>k.some(pe=>pe.mode==="file"),[k]),Pe=c.useMemo(()=>k.some(pe=>pe.mode==="file"&&pe.targetPath),[k]),ot=D?.mode==="file",Ke=Te(pe=>pe.closeContextPanelTabs),ht=c.useCallback(pe=>{if(!n)return null;const{id:Ye,index:wt,allIds:jt,close:de}=pe,Ve=()=>Ke(n,jt.filter(Ue=>Ue!==Ye)),ct=()=>Ke(n,jt.slice(0,wt)),Le=()=>Ke(n,jt.slice(wt+1)),J=()=>Ke(n,jt),re=jt.length>1,ke=wt===0,Fe=wt===jt.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Un,{onClick:de,children:[s.jsx(E,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Oi,{}),s.jsxs(Un,{onClick:Ve,disabled:!re,children:[s.jsx(E,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Un,{onClick:ct,disabled:ke,children:[s.jsx(E,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Un,{onClick:Le,disabled:Fe,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")]})]})},[Ke,n,t]),ft=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[je?s.jsx(tu,{items:Ne,activeId:D?.id??null,onSelect:pe=>{n&&d(n,pe)},onClose:pe=>{n&&o(n,pe)},onReorder:(pe,Ye)=>{n&&m(n,pe,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?lc(D,x):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:D?lm(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,ot?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:xe,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:Ce,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"})})]})]}),kt=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:ve,"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:kt,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:me,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:[ft,s.jsxs("div",{className:Ie("relative min-h-0 flex-1 overflow-hidden",H&&"pointer-events-none"),children:[Me?s.jsxs("div",{className:Ie("absolute inset-0 flex",ot?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:Pe?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Yw,{mode:"editor-only",visible:P&&ot})}):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(mS,{visible:g,active:P&&ot})]}):null,ge&&Se&&oe?s.jsx("iframe",{ref:pe=>{if(!pe){K.current.delete(ge.id);return}K.current.set(ge.id,pe)},src:oe,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:Se}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{z(),$(),W()}},ge.id):null,ze.map(pe=>s.jsx("div",{className:Ie("absolute inset-0",D?.id!==pe.id&&"hidden"),children:s.jsx(Vw,{initialUrl:pe.targetPath??"",directory:n,tabID:pe.id})},pe.id)),We.map(pe=>s.jsx("div",{className:Ie("absolute inset-0",D?.id!==pe.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Qw,{visible:P&&D?.id===pe.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:pe.diffScope??(pe.stagedDiff?"staged":"working"),onDiffScopeChange:ne,targetFilePath:pe.targetPath,flushContent:!0})})},pe.id)),V?s.jsx("div",{className:Ie("absolute inset-0",D?.mode==="terminal"?"block":"hidden"),children:s.jsx(hg,{visible:P&&D?.mode==="terminal",directory:V.targetDirectory})}):null,fe?s.jsx("div",{className:Ie("absolute inset-0",D?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(qw,{directory:e,visible:P&&D?.mode==="walkthrough"})})}):null,D?.mode!=="chat"&&!ot&&D?.mode!=="browser"&&D?.mode!=="diff"&&D?.mode!=="terminal"&&D?.mode!=="walkthrough"?Be:null]})]})]})},bS=t=>{const e=et.c(42),{open:n,onOpenChange:r}=t,{t:i}=Nt(),o=Te(yS),l=Te(wS),a=Te(SS),u=Te(vS);let d;e[0]!==o?(d=Ed(o),e[0]=o,e[1]=d):d=e[1];const h=d,m=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(Is,{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 f;e[13]!==x?(f=s.jsx(Ts,{children:x}),e[13]=x,e[14]=f):f=e[14];let b;e[15]!==S||e[16]!==f?(b=s.jsxs(Ws,{children:[S,f]}),e[15]=S,e[16]=f,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(ch,{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]!==m||e[30]!==g||e[31]!==u||e[32]!==i?(N=m?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]=m,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 yS(t){return t.contextRailOrder}function wS(t){return t.contextRailHiddenSurfaces}function SS(t){return t.setContextRailSurfaceVisible}function vS(t){return t.setContextRailHiddenSurfaces}const cm=150,jS=500,kS=[],CS=t=>t>99?"99+":String(t),NS=t=>{const e=et.c(51),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:u,badgeDescription:d,orderNumber:h,showOrderNumber:m,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:f,transition:b,isDragging:y}=Qo(g);let v;e[2]!==a?(v=a!=null&&a>0?CS(a):null,e[2]=a,e[3]=v):v=e[3];const N=v;let C;e[4]!==f?(C=Yo.Translate.toString(f),e[4]=f,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(Fu,{}):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]!==m?(L=m&&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]=m,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:cm,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},AS=()=>{const t=et.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=Se=>i?Se.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Te(o),a=Te(DS),u=Te(PS),d=Te(IS),h=Te(TS),m=Te(RS),p=Te(ES),g=Te(MS),w=ba(OS),S=Ni(FS),x=Ni(BS),f=An(_S),b=An(LS),{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 Se=new Set;let ge=null,Ae=!1;const oe=$S,ne=()=>{nl(C,Se)?!Ae&&ge===null&&(ge=setTimeout(()=>D(!0),jS)):(Ae=!1,ge!==null&&(clearTimeout(ge),ge=null),D(!1))},z=W=>{if(Se.add(W.key.toLowerCase()),oe(W.key)&&nl(C,Se)){Ae=!0,ge!==null&&(clearTimeout(ge),ge=null),D(!1);return}ne()},$=W=>{Se.delete(W.key.toLowerCase()),ne()},ae=()=>{Se.clear(),Ae=!1,ge!==null&&(clearTimeout(ge),ge=null),D(!1)};return window.addEventListener("keydown",z,!0),window.addEventListener("keyup",$,!0),window.addEventListener("blur",ae),()=>{window.removeEventListener("keydown",z,!0),window.removeEventListener("keyup",$,!0),window.removeEventListener("blur",ae),ge!==null&&clearTimeout(ge)}},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(mu,M),On(uu,_)),U=l?.tabs??kS;let L;t[11]!==l?.activeTabId||t[12]!==U?(L=U.find(Se=>Se.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=dh({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]!==f||t[33]!==b?(Z=()=>{!i||!f||b||R!=="pr"||p(i)},ce=[R,p,i,f,b],t[29]=R,t[30]=p,t[31]=i,t[32]=f,t[33]=b,t[34]=Z,t[35]=ce):(Z=t[34],ce=t[35]),c.useEffect(Z,ce);const[Y,te]=c.useState(!1);let se;t[36]!==h?(se=Se=>{const{active:ge,over:Ae}=Se;if(!Ae||ge.id===Ae.id)return;const oe=Ed(Te.getState().contextRailOrder).map(WS),ne=oe.indexOf(ge.id),z=oe.indexOf(Ae.id);ne===-1||z===-1||h(fu(oe,ne,z))},t[36]=h,t[37]=se):se=t[37];const ve=se;if(!i)return null;let K;t[38]!==e?(K=e("contextRail.aria.rail"),t[38]=e,t[39]=K):K=t[39];let he;t[40]!==B?(he=B.map(zS),t[40]=B,t[41]=he):he=t[41];let be;if(t[42]!==R||t[43]!==j||t[44]!==i||t[45]!==m||t[46]!==k||t[47]!==B||t[48]!==e||t[49]!==a){let Se;t[51]!==R||t[52]!==j||t[53]!==i||t[54]!==m||t[55]!==k||t[56]!==e||t[57]!==a?(Se=(ge,Ae)=>{const oe=e(ge.labelKey),ne=ge.id==="git"&&!a?j:0,z=ne>0?ne:null;return s.jsx(NS,{surface:ge,isActive:R===ge.mode,showActivityDot:!1,label:oe,description:e(ge.descriptionKey),badgeCount:z,badgeAriaLabel:z!==null?e(z===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:oe,count:z}):null,badgeDescription:z!==null?e(z===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:z}):null,orderNumber:Ae+1,showOrderNumber:k,onSelect:$=>m(i,$.mode)},ge.id)},t[51]=R,t[52]=j,t[53]=i,t[54]=m,t[55]=k,t[56]=e,t[57]=a,t[58]=Se):Se=t[58],be=B.map(Se),t[42]=R,t[43]=j,t[44]=i,t[45]=m,t[46]=k,t[47]=B,t[48]=e,t[49]=a,t[50]=be}else be=t[50];let ie;t[59]!==he||t[60]!==be?(ie=s.jsx(Io,{items:he,strategy:_i,children:be}),t[59]=he,t[60]=be,t[61]=ie):ie=t[61];let T;t[62]!==ve||t[63]!==O||t[64]!==ie?(T=s.jsx(Ur,{sensors:O,collisionDetection:Kr,onDragEnd:ve,children:ie}),t[62]=ve,t[63]=O,t[64]=ie,t[65]=T):T=t[65];let Q;t[66]!==e?(Q=e("contextRail.configure.open"),t[66]=e,t[67]=Q):Q=t[67];let le;t[68]===Symbol.for("react.memo_cache_sentinel")?(le=()=>te(!0),t[68]=le):le=t[68];let me;t[69]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(E,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[69]=me):me=t[69];let ue;t[70]!==Q?(ue=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":Q,onClick:le,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:me})}),t[70]=Q,t[71]=ue):ue=t[71];let Ce;t[72]!==e?(Ce=e("contextRail.configure.open"),t[72]=e,t[73]=Ce):Ce=t[73];let xe;t[74]!==Ce?(xe=s.jsx(Pt,{side:"left",sideOffset:8,children:Ce}),t[74]=Ce,t[75]=xe):xe=t[75];let Re;t[76]!==ue||t[77]!==xe?(Re=s.jsxs(At,{delayDuration:cm,children:[ue,xe]}),t[76]=ue,t[77]=xe,t[78]=Re):Re=t[78];let we;t[79]!==Y?(we=s.jsx(bS,{open:Y,onOpenChange:te}),t[79]=Y,t[80]=we):we=t[80];let G;return t[81]!==K||t[82]!==T||t[83]!==Re||t[84]!==we?(G=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,we]}),t[81]=K,t[82]=T,t[83]=Re,t[84]=we,t[85]=G):G=t[85],G};function DS(t){return t.workStatusPanelVisible}function PS(t){return t.contextRailOrder}function IS(t){return t.contextRailHiddenSurfaces}function TS(t){return t.setContextRailOrder}function RS(t){return t.openContextSurface}function ES(t){return t.closeContextPanel}function MS(t){return t.shortcutOverrides}function OS(t){return t.planModeEnabled}function FS(t){return t.hasChecked}function BS(t){return t.status?.connected===!0}function _S(t){return t.hasChecked}function LS(t){return t.status?.connected===!0}function $S(t){return t.length===1&&t>="0"&&t<="9"}function WS(t){return t.id}function zS(t){return t.id}const VS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),US=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Er(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),KS=new Set,HS=[],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},GS=()=>{const t=et.c(182),{t:e}=Nt(),n=Te(qS),r=Te(QS),i=Te(YS),o=Te(XS),l=Te(JS),a=Te(ZS),u=Te(ev),d=Te(tv),h=Te(sv),m=Te(nv),p=Te(rv),g=Te(ov),w=Te(iv),S=Ze(av),x=Ze(lv),f=Ze(cv),b=Wr(dv);let y;t[0]!==n?(y=Je=>n?Je.activeSessions:HS,t[0]=n,t[1]=y):y=t[1];const v=$s(y);let N;t[2]!==n?(N=Je=>n?Je.ids:KS,t[2]=n,t[3]=N):N=t[3];const C=Wr(N);let k;t[4]!==n?(k=Je=>n?Je.rankById:Od,t[4]=n,t[5]=k):k=t[5];const D=va(k),P=ss(uv),I=Ht(mv),M=Ht(fv),_=er(),O=cd(hv),{files:U,git:L}=Sn(),F=Dn(pv),{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=Pd(B,200).trim();let ce;t[8]!==B?(ce=B.trim(),t[8]=B,t[9]=ce):ce=t[9];const Y=ce;let te,se;t[10]!==n?(te=()=>{n&&X("")},se=[n],t[10]=n,t[11]=te,t[12]=se):(te=t[11],se=t[12]),c.useEffect(te,se);let ve,K;t[13]!==v||t[14]!==F||t[15]!==L||t[16]!==n?(ve=()=>{if(!n||!L)return;const Je=setTimeout(()=>{const lt=new Set;for(const vt of v){const yt=Ps(vt);!yt||lt.has(yt)||(lt.add(yt),F(yt,L))}},0);return()=>clearTimeout(Je)},K=[n,v,L,F],t[13]=v,t[14]=F,t[15]=L,t[16]=n,t[17]=ve,t[18]=K):(ve=t[17],K=t[18]),c.useEffect(ve,K);let he;t[19]!==r?(he=()=>r(!1),t[19]=r,t[20]=he):he=t[20];const be=he;let ie;t[21]!==be?(ie=Je=>()=>{be(),Je()},t[21]=be,t[22]=ie):ie=t[22];const T=ie;let Q;t[23]!==I?.id||t[24]!==I?.path||t[25]!==P||t[26]!==f||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?(Q=()=>{const Je=[{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(gv)},{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(xv)},{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:lt}=Te.getState();l(!lt)}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(bv)},{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(yv)},{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 Je.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(()=>{f&&P&&b({directory:P,sessionId:f})})},{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(()=>{f&&gn(f).then(lt=>{if(lt.ok){_e.success(e("sessions.sidebar.session.copyId.success"));return}_e.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(e("sessions.sidebar.session.copyId.error")))})},{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"))})}),Je.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(wv)}),Vo()&&Je.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(Sv)})}),Je},t[23]=I?.id,t[24]=I?.path,t[25]=P,t[26]=f,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]=Q):Q=t[40],I?.id,I?.path;let le;t[41]!==Q?(le=Q(),t[41]=Q,t[42]=le):le=t[42];const me=le;let ue;t[43]===Symbol.for("react.memo_cache_sentinel")?(ue=bn(),t[43]=ue):ue=t[43];const Ce=ue;let xe,Re;t[44]===Symbol.for("react.memo_cache_sentinel")?(xe=Pn(),Re=!Ce&&ha(),t[44]=xe,t[45]=Re):(xe=t[44],Re=t[45]);let we;t[46]!==R?(we={isVSCode:xe,isWeb:Re,isDesktop:Ce,isMobile:R},t[46]=R,t[47]=we):we=t[47];const G=we;let Se;if(t[48]!==T||t[49]!==i||t[50]!==o||t[51]!==G){let Je;t[53]!==G?(Je=vt=>vt.isAvailable?vt.isAvailable(G):!0,t[53]=G,t[54]=Je):Je=t[54];let lt;t[55]!==T||t[56]!==i||t[57]!==o?(lt=vt=>{const yt=gg(vt.slug)??"settings-3",Tt=(vt.keywords??[]).join(" ");return{id:`settings:${vt.slug}`,title:vt.title,icon:vt.slug==="mcp"?s.jsx(ph,{className:"mr-2 h-4 w-4"}):s.jsx(E,{name:yt,className:"mr-2 h-4 w-4"}),searchText:`${vt.title} ${vt.group} ${Tt}`,onSelect:T(()=>{o(vt.slug),i(!0)})}},t[55]=T,t[56]=i,t[57]=o,t[58]=lt):lt=t[58],Se=pg.filter(vv).filter(Je).map(lt),t[48]=T,t[49]=i,t[50]=o,t[51]=G,t[52]=Se}else Se=t[52];const ge=Se;let Ae;if(t[59]!==v||t[60]!==C||t[61]!==D){const Je=v.filter(jv);Ae=uh(Je,C,D),t[59]=v,t[60]=C,t[61]=D,t[62]=Ae}else Ae=t[62];const oe=Ae,ne=Md(),z=Ze(kv);let $;t[63]!==ne||t[64]!==z?($=(Je,lt)=>{const vt=z.get(Je);return vt?.branch?vt.branch.trim()||null:lt&&ne.get(lt)?.trim()||null},t[63]=ne,t[64]=z,t[65]=$):$=t[65];const ae=$;let W;t[66]===Symbol.for("react.memo_cache_sentinel")?(W=[],t[66]=W):W=t[66];const[je,Ee]=c.useState(W),[Ne,Be]=c.useState(""),ze=VS(A,Z);let We;t[67]!==A||t[68]!==ze||t[69]!==n||t[70]!==O||t[71]!==Ee||t[72]!==Be||t[73]!==Z?(We=()=>{if(!n){Ee([]),Be("");return}if(!ze){Ee([]),Be("");return}if(!A){Ee([]),Be("");return}let Je=!1;return O(A,Z,40,{type:"file"}).then(lt=>{Je||(Ee(lt.map(Cv)),Be(ze))}).catch(()=>{Je||(Ee([]),Be(ze))}),()=>{Je=!0}},t[67]=A,t[68]=ze,t[69]=n,t[70]=O,t[71]=Ee,t[72]=Be,t[73]=Z,t[74]=We):We=t[74];let V;t[75]!==A||t[76]!==ze||t[77]!==n||t[78]!==O||t[79]!==Z?(V=[n,A,Z,ze,O],t[75]=A,t[76]=ze,t[77]=n,t[78]=O,t[79]=Z,t[80]=V):V=t[80],c.useEffect(We,V);const fe=Y.length>0;let Me;e:{if(!fe){let lt;t[81]!==me?(lt=me.filter(Nv).map(Av),t[81]=me,t[82]=lt):lt=t[82],Me=lt;break e}let Je;t[83]!==me||t[84]!==Y?(Je=Er(me,Y,Dv,{limit:7,noFuzzy:!0}),t[83]=me,t[84]=Y,t[85]=Je):Je=t[85],Me=Je}const Pe=Me;let ot;e:{if(!fe){let lt;t[86]===Symbol.for("react.memo_cache_sentinel")?(lt=[],t[86]=lt):lt=t[86],ot=lt;break e}let Je;t[87]!==Y||t[88]!==ge?(Je=Er(ge,Y,Pv,{limit:7,noFuzzy:!0}),t[87]=Y,t[88]=ge,t[89]=Je):Je=t[89],ot=Je}const Ke=ot;let ht;e:{if(!fe){let lt;t[90]!==oe?(lt=oe.slice(0,5).map(Iv),t[90]=oe,t[91]=lt):lt=t[91],ht=lt;break e}let Je;t[92]!==Y||t[93]!==oe?(Je=Er(oe,Y,Tv,{limit:7,threshold:.2}),t[92]=Y,t[93]=oe,t[94]=Je):Je=t[94],ht=Je}const ft=ht;let kt;e:{if(!n){let lt;t[95]===Symbol.for("react.memo_cache_sentinel")?(lt=[],t[95]=lt):lt=t[95],kt=lt;break e}let Je;t[96]!==je||t[97]!==Ne||t[98]!==ze||t[99]!==Z?(Je=US(je,Z,ze,Ne),t[96]=je,t[97]=Ne,t[98]=ze,t[99]=Z,t[100]=Je):Je=t[100],kt=Je}const pe=kt,Ye=n&&ze.length>0&&Ne!==ze;let wt;e:{if(!fe){let lt;t[101]===Symbol.for("react.memo_cache_sentinel")?(lt=[],t[101]=lt):lt=t[101],wt=lt;break e}let Je;if(t[102]!==Y||t[103]!==M){const lt=M.map(Rv);Je=Er(lt,Y,Ev,{limit:7,threshold:.4}),t[102]=Y,t[103]=M,t[104]=Je}else Je=t[104];wt=Je}const jt=wt;let de,Ve,ct,Le,J,re,ke,Fe,Ue,st,it,rt,qe,at;if(t[105]!==ae||t[106]!==be||t[107]!==A||t[108]!==U||t[109]!==fe||t[110]!==n||t[111]!==h||t[112]!==S||t[113]!==B||t[114]!==Pe||t[115]!==pe||t[116]!==jt||t[117]!==ft||t[118]!==Ke||t[119]!==r||t[120]!==x||t[121]!==m||t[122]!==e){const Je=Pe.map(Mv),lt=Ke.map(Ov),vt=ft.map(Fv),yt=fe?pe.map(Bv):[],Tt=fe?jt.map(_v):[];let Ct;e:{if(!fe){Ct=["commands","sessions"];break e}const dt=Lv,Ge=[{key:"commands",score:dt(Pe)},{key:"settings",score:dt(Ke)},{key:"sessions",score:dt(ft)},{key:"files",score:dt(pe)},{key:"projects",score:dt(jt)}];Ge.sort($v),Ct=Ge.map(Wv)}const Rt=Ct,Bt=dt=>{be(),x(dt.id,Ps(dt))},Gt=async dt=>{if(!A)return;const Ge=await Wu(U,dt,{directory:A});if(!Ge.ok){_e.error(zu(Ge.reason));return}h(A,dt),be()},qt=(dt,Ge)=>{be(),S({selectedProjectId:dt,directoryOverride:Ge})},Ut=dt=>qn(qr(dt,m));Le=vs,rt=n,qe=r;let Wt;t[137]!==e?(Wt=e("commandPalette.title"),t[137]=e,t[138]=Wt):Wt=t[138];let Ft;t[139]!==Wt?(Ft=s.jsx(Is,{children:Wt}),t[139]=Wt,t[140]=Ft):Ft=t[140];let Kt;t[141]!==e?(Kt=e("commandPalette.description"),t[141]=e,t[142]=Kt):Kt=t[142];let $e;t[143]!==Kt?($e=s.jsx(Ts,{children:Kt}),t[143]=Kt,t[144]=$e):$e=t[144],t[145]!==Ft||t[146]!==$e?(at=s.jsxs(Ws,{className:"sr-only",children:[Ft,$e]}),t[145]=Ft,t[146]=$e,t[147]=at):at=t[147],ct=js,st="overflow-hidden p-0",it=!0,Ve=gh,ke=!1,Fe="[&_[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 Xe;t[148]!==e?(Xe=e("commandPalette.input.placeholder"),t[148]=e,t[149]=Xe):Xe=t[149],t[150]!==B||t[151]!==Xe?(Ue=s.jsx(xh,{value:B,onValueChange:X,placeholder:Xe}),t[150]=B,t[151]=Xe,t[152]=Ue):Ue=t[152],de=bh;let ut;t[153]!==e?(ut=e("commandPalette.empty.noResults"),t[153]=e,t[154]=ut):ut=t[154],t[155]!==ut?(J=s.jsx(yh,{children:ut}),t[155]=ut,t[156]=J):J=t[156],re=Rt.map(dt=>dt==="commands"&&Je.length>0?s.jsx(jr,{children:Je.map(Ge=>s.jsxs(Mr,{value:Ge.id,onSelect:Ge.onSelect,children:[Ge.icon,s.jsx("span",{children:Ge.title}),Ge.shortcutId?s.jsx(mh,{children:Ut(Ge.shortcutId)}):null]},Ge.id))},"commands"):dt==="settings"&<.length>0?s.jsx(jr,{children:lt.map(zv)},"settings"):dt==="sessions"&&vt.length>0?s.jsx(jr,{children:vt.map(Ge=>{const _t=Ge.title||e("commandPalette.session.untitled"),Qt=Ps(Ge),Zt=ae(Ge.id,Qt);return s.jsxs(Mr,{value:`session:${Ge.id}`,onSelect:()=>Bt(Ge),children:[s.jsx(E,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:_t}),Zt?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:Zt})]}):null]},Ge.id)})},"sessions"):dt==="files"&&yt.length>0?s.jsx(jr,{children:yt.map(Ge=>{const _t=fh(Ge.relativePath||Ge.name,{maxLength:80});return s.jsxs(Mr,{value:`file:${Ge.path}`,onSelect:()=>{Gt(Ge.path)},children:[s.jsx(Sa,{filePath:Ge.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":Ge.relativePath,children:_t})]},`file:${Ge.path}`)})},"files"):dt==="projects"&&Tt.length>0?s.jsx(jr,{children:Tt.map(Ge=>{const _t=Ge.displayName;return s.jsxs(Mr,{value:`project:${Ge.id}`,onSelect:()=>qt(Ge.id,Ge.path),children:[s.jsx(E,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:_t}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:Ge.path})]},`project:${Ge.id}`)})},"projects"):null),t[105]=ae,t[106]=be,t[107]=A,t[108]=U,t[109]=fe,t[110]=n,t[111]=h,t[112]=S,t[113]=B,t[114]=Pe,t[115]=pe,t[116]=jt,t[117]=ft,t[118]=Ke,t[119]=r,t[120]=x,t[121]=m,t[122]=e,t[123]=de,t[124]=Ve,t[125]=ct,t[126]=Le,t[127]=J,t[128]=re,t[129]=ke,t[130]=Fe,t[131]=Ue,t[132]=st,t[133]=it,t[134]=rt,t[135]=qe,t[136]=at}else de=t[123],Ve=t[124],ct=t[125],Le=t[126],J=t[127],re=t[128],ke=t[129],Fe=t[130],Ue=t[131],st=t[132],it=t[133],rt=t[134],qe=t[135],at=t[136];let Oe;t[157]!==Ye||t[158]!==e?(Oe=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]=Oe):Oe=t[159];let ye;t[160]!==de||t[161]!==J||t[162]!==re||t[163]!==Oe?(ye=s.jsxs(de,{children:[J,re,Oe]}),t[160]=de,t[161]=J,t[162]=re,t[163]=Oe,t[164]=ye):ye=t[164];let mt;t[165]!==Ve||t[166]!==ke||t[167]!==Fe||t[168]!==Ue||t[169]!==ye?(mt=s.jsxs(Ve,{shouldFilter:ke,className:Fe,children:[Ue,ye]}),t[165]=Ve,t[166]=ke,t[167]=Fe,t[168]=Ue,t[169]=ye,t[170]=mt):mt=t[170];let bt;t[171]!==ct||t[172]!==st||t[173]!==it||t[174]!==mt?(bt=s.jsx(ct,{className:st,showCloseButton:it,children:mt}),t[171]=ct,t[172]=st,t[173]=it,t[174]=mt,t[175]=bt):bt=t[175];let It;return t[176]!==Le||t[177]!==rt||t[178]!==qe||t[179]!==at||t[180]!==bt?(It=s.jsxs(Le,{open:rt,onOpenChange:qe,children:[at,bt]}),t[176]=Le,t[177]=rt,t[178]=qe,t[179]=at,t[180]=bt,t[181]=It):It=t[181],It};function qS(t){return t.isCommandPaletteOpen}function QS(t){return t.setCommandPaletteOpen}function YS(t){return t.setSettingsDialogOpen}function XS(t){return t.setSettingsPage}function JS(t){return t.setSessionSwitcherOpen}function ZS(t){return t.toggleSidebar}function ev(t){return t.openContextOverview}function tv(t){return t.openContextSurface}function sv(t){return t.openContextFile}function nv(t){return t.shortcutOverrides}function rv(t){return t.openMultiRunLauncher}function ov(t){return t.setArchivePageOpen}function iv(t){return t.setProjectContextTab}function av(t){return t.openNewSessionDraft}function lv(t){return t.setCurrentSession}function cv(t){return t.currentSessionId}function dv(t){return t.toggle}function uv(t){return t.currentDirectory}function mv(t){return t.getActiveProject()}function fv(t){return t.projects}function hv(t){return t.searchFiles}function pv(t){return t.ensureStatus}function gv(){Fd()}function xv(){xn.requestDirectoryDialog()}function bv(){wh.invoke("cycle_theme")}function yv(){Bd()}function wv(){window.dispatchEvent(new CustomEvent("aiworker:memory-debug-toggle"))}function Sv(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function vv(t){return t.slug!=="home"}function jv(t){return!hh(t)}function kv(t){return t.worktreeMetadata}function Cv(t){return{path:ta(t.path),name:t.name,relativePath:t.relativePath}}function Nv(t){return!t.secondary}function Av(t){return{item:t,score:0}}function Dv(t){return t.searchText}function Pv(t){return t.searchText}function Iv(t){return{item:t,score:0}}function Tv(t){return t.title||""}function Rv(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Ev(t){return t.searchText}function Mv(t){return t.item}function Ov(t){return t.item}function Fv(t){return t.item}function Bv(t){return t.item}function _v(t){return t.item}function Lv(t){return t.length?t[0].score:1/0}function $v(t,e){return t.score-e.score}function Wv(t){return t.key}function zv(t){return s.jsxs(Mr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const cc=(t,e,n)=>qn(qr(t,e),n),Vv=()=>{const t=et.c(74),{t:e}=Nt(),n=Te(Uv),r=Te(Kv),i=Te(Hv);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,m,p,g,w,S,x,f,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,f=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(Is,{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(Ts,{children:H}),t[24]=H,t[25]=Z):Z=t[25],t[26]!==X||t[27]!==Z?(x=s.jsxs(Ws,{children:[X,Z]}),t[26]=X,t[27]=Z,t[28]=x):x=t[28],a=dn,p="flex-1 min-h-0 mt-3",g="pr-1",w=!0,h="space-y-4",m=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 te=Y.id?Sh(Y.id):void 0,se=Y.descriptionKey??(te?.customizable?te.settingsLabelKey:void 0);if(!se||Y.id&&!qr(Y.id,i))return null;const ve=Y.id?cc(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(se)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(ve)?ve:[ve]).map((K,he)=>s.jsxs(c.Fragment,{children:[he>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:K})]},`${K}-${he}`))})]},Y.id||se)})})]},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]=m,t[10]=p,t[11]=g,t[12]=w,t[13]=S,t[14]=x,t[15]=f,t[16]=b}else a=t[5],u=t[6],d=t[7],h=t[8],m=t[9],p=t[10],g=t[11],w=t[12],S=t[13],x=t[14],f=t[15],b=t[16];let y;t[29]!==h||t[30]!==m?(y=s.jsx("div",{className:h,children:m}),t[29]=h,t[30]=m,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:cc("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]!==f||t[72]!==b?(R=s.jsx(d,{open:f,onOpenChange:b,children:F}),t[69]=d,t[70]=F,t[71]=f,t[72]=b,t[73]=R):R=t[73],R};function Uv(t){return t.isHelpDialogOpen}function Kv(t){return t.setHelpDialogOpen}function Hv(t){return t.shortcutOverrides}const Gv=()=>{const t=et.c(32),{t:e}=Nt(),n=Te(qv),r=Te(Qv),i=Te(Yv);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await gn(i)).ok){_e.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}_e.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(Is,{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(Ts,{children:d}),t[9]=d,t[10]=h):h=t[10];let m;t[11]!==u||t[12]!==h?(m=s.jsxs(Ws,{children:[u,h]}),t[11]=u,t[12]=h,t[13]=m):m=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]!==m||t[25]!==g||t[26]!==S?(x=s.jsxs(js,{className:"max-w-2xl",children:[m,g,S]}),t[24]=m,t[25]=g,t[26]=S,t[27]=x):x=t[27];let f;return t[28]!==n||t[29]!==r||t[30]!==x?(f=s.jsx(vs,{open:n,onOpenChange:r,children:x}),t[28]=n,t[29]=r,t[30]=x,t[31]=f):f=t[31],f};function qv(t){return t.isOpenCodeStatusDialogOpen}function Qv(t){return t.setOpenCodeStatusDialogOpen}function Yv(t){return t.openCodeStatusText}const Xv=t=>{const e=et.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,m;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)},m=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=m):(h=e[8],m=e[9]),c.useEffect(h,m);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)},Jv=t=>{const e=et.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(Zv)),d=[];a.forEach(p=>{const g=u.get(p);g&&(d.push(g),u.delete(p))});const h=[],m=[];return l.forEach(p=>{u.has(p.id)&&(p.isArchivedBucket?m.push(p):h.push(p))}),[...h,...d,...m]},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 Zv(t){return[t.id,t]}const ao="oc.sessions.projectCollapse",dc="oc.sessions.groupOrder",uc="oc.sessions.groupCollapse",mc=t=>{if(!t)return new Set;try{const e=Ra(br()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},e0=t=>{if(!t)return new Map;try{const e=wu(br(),Ra(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}},t0=t=>{const e=et.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(uc)),e[2]=d):d=e[2];const[h,m]=c.useState(d);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>e0(o.getItem(dc)),e[3]=p):p=e[3];const[g,w]=c.useState(p),S=c.useRef(0),x=c.useRef(!1),f=c.useRef(!1),b=c.useRef(null),y=c.useRef(null);let v;e[4]!==n?(v=()=>{if(n)return;const he=y.current;if(y.current=null,b.current=null,!he)return;const{projects:be}=Ht.getState(),ie=be.map(T=>({...T,sidebarCollapsed:he.has(T.id)}));Rr({projects:ie}).catch(s0)},e[4]=n,e[5]=v):v=e[5];const N=v;let C;e[6]!==N||e[7]!==n?(C=he=>{!globalThis.window||n||(y.current=he,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(f.current)try{o.setItem(dc,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(uc,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,m(new Set),u(()=>{const he=new Set(r.map(n0));try{o.setItem(ao,JSON.stringify(Array.from(he)))}catch{}return k(he),he})},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,m(new Set),u(()=>{const he=new Set;try{o.setItem(ao,JSON.stringify([]))}catch{}return k(he),he})},e[20]=k,e[21]=F):F=e[21];const R=F;let j;e[22]!==k?(j=he=>{S.current=Date.now()+150,u(be=>{const ie=new Set(be);ie.has(he)?ie.delete(he):ie.add(he);try{o.setItem(ao,JSON.stringify(Array.from(ie)))}catch{}return k(ie),ie})},e[22]=k,e[23]=j):j=e[23];const A=j;let B;e[24]===Symbol.for("react.memo_cache_sentinel")?(B=he=>{x.current=!0,m(be=>{const ie=new Set(be);return ie.has(he)?ie.delete(he):ie.add(he),ie})},e[24]=B):B=e[24];const X=B;let H;e[25]===Symbol.for("react.memo_cache_sentinel")?(H=he=>{f.current=!0,w(he)},e[25]=H):H=e[25];const Z=H,{getOrderedGroups:ce}=Jv(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 te=Y;let se;e[30]!==L||e[31]!==R||e[32]!==ce||e[33]!==k||e[34]!==A?(se={setCollapsedProjects:u,toggleProject:A,collapseAllProjects:L,expandAllProjects:R,scheduleCollapsedProjectsPersist:k,setCollapsedGroups:m,toggleGroup:X,setGroupOrderByProject:Z,getOrderedGroups:ce},e[30]=L,e[31]=R,e[32]=ce,e[33]=k,e[34]=A,e[35]=se):se=e[35];const ve=se;let K;return e[36]!==ve||e[37]!==te?(K={state:te,actions:ve},e[36]=ve,e[37]=te,e[38]=K):K=e[38],K};function s0(){}function n0(t){return t.id}const r0=5*6e4,o0=t=>{const e=et.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:u}=Sn(),d=Dn(i0);let h,m;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))})},m=[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]=m):(h=e[5],m=e[6]),c.useEffect(h,m);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 f=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(a0));for(const L of f.current.keys())P.has(L)||(f.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 f.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=f.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)<r0)});if(M.length===0)return;const _=await vh(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(l0);return{id:L.id,inputKey:R,branch:j}});if(C)return;const O=_.filter(c0);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;f.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 i0(t){return t.ensureStatus}function a0(t){return t.id}function l0(){return null}function c0(t){return t.branch}const d0=t=>{const e=et.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(xg,{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(dn,{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},u0=(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},bs=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[m,p]=d<=h?[d,h]:[h,d],g=i.slice(m,p+1),w=u0(g,l),x=o!==null&&a.scopeKey!==null&&o!==a.scopeKey?new Set:new Set(a.selectedIds);for(const f of w)x.add(f);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 m0(t){const e=et.c(213),{t:n}=Nt(),{hideDirectoryControls:r,showProjectDisplayControls:i,showRecentControls:o,handleOpenDirectoryDialog:l,onOpenScheduled:a,onOpenMultiRun:u,canOpenMultiRun:d,onOpenArchive:h,headerActionIconClass:m,headerActionButtonClass:p,isSessionSearchOpen:g,setIsSessionSearchOpen:w,sessionSearchInputRef:S,sessionSearchQuery:x,setSessionSearchQuery:f,hasSessionSearchQuery:b,searchMatchCount:y,collapseAllProjects:v,expandAllProjects:N}=t,C=bs(C0),k=bs(k0),D=cs(j0),P=cs(v0),I=cs(S0),M=cs(w0),_=cs(y0),O=cs(b0),U=cs(x0),L=cs(g0),F=cs(p0),R=cs(h0),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]!==m?(X=s.jsx(E,{name:"folder-add",className:m}),e[4]=m,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 te;e[18]!==p?(te=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=p,e[19]=te):te=e[19];let se;e[20]!==n?(se=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=se):se=e[21];let ve;e[22]!==m?(ve=s.jsx(E,{name:"calendar-schedule",className:m}),e[22]=m,e[23]=ve):ve=e[23];let K;e[24]!==a||e[25]!==te||e[26]!==se||e[27]!==ve?(K=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:te,"aria-label":se,children:ve})}),e[24]=a,e[25]=te,e[26]=se,e[27]=ve,e[28]=K):K=e[28];let he;e[29]!==n?(he=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=he):he=e[30];let be;e[31]!==he?(be=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:he})}),e[31]=he,e[32]=be):be=e[32];let ie;e[33]!==K||e[34]!==be?(ie=s.jsxs(At,{children:[K,be]}),e[33]=K,e[34]=be,e[35]=ie):ie=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 Q;e[38]!==n?(Q=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=Q):Q=e[39];const le=!d;let me;e[40]!==m?(me=s.jsx(jh,{className:m}),e[40]=m,e[41]=me):me=e[41];let ue;e[42]!==u||e[43]!==T||e[44]!==Q||e[45]!==le||e[46]!==me?(ue=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:T,"aria-label":Q,disabled:le,children:me})}),e[42]=u,e[43]=T,e[44]=Q,e[45]=le,e[46]=me,e[47]=ue):ue=e[47];let Ce;e[48]!==n?(Ce=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=Ce):Ce=e[49];let xe;e[50]!==Ce?(xe=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ce})}),e[50]=Ce,e[51]=xe):xe=e[51];let Re;e[52]!==ue||e[53]!==xe?(Re=s.jsxs(At,{children:[ue,xe]}),e[52]=ue,e[53]=xe,e[54]=Re):Re=e[54];let we;e[55]!==p?(we=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=p,e[56]=we):we=e[56];let G;e[57]!==n?(G=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=G):G=e[58];let Se;e[59]!==m?(Se=s.jsx(E,{name:"archive",className:m}),e[59]=m,e[60]=Se):Se=e[60];let ge;e[61]!==h||e[62]!==we||e[63]!==G||e[64]!==Se?(ge=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,className:we,"aria-label":G,children:Se})}),e[61]=h,e[62]=we,e[63]=G,e[64]=Se,e[65]=ge):ge=e[65];let Ae;e[66]!==n?(Ae=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=Ae):Ae=e[67];let oe;e[68]!==Ae?(oe=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ae})}),e[68]=Ae,e[69]=oe):oe=e[69];let ne;e[70]!==ge||e[71]!==oe?(ne=s.jsxs(At,{children:[ge,oe]}),e[70]=ge,e[71]=oe,e[72]=ne):ne=e[72];let z;e[73]!==ie||e[74]!==Re||e[75]!==ne||e[76]!==Y?(z=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[Y,ie,Re,ne]}),e[73]=ie,e[74]=Re,e[75]=ne,e[76]=Y,e[77]=z):z=e[77];let $;e[78]!==w?($=()=>w(f0),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 je;e[84]!==m?(je=s.jsx(E,{name:"search",className:m}),e[84]=m,e[85]=je):je=e[85];let Ee;e[86]!==g||e[87]!==$||e[88]!==ae||e[89]!==W||e[90]!==je?(Ee=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:$,className:ae,"aria-label":W,"aria-expanded":g,children:je})}),e[86]=g,e[87]=$,e[88]=ae,e[89]=W,e[90]=je,e[91]=Ee):Ee=e[91];let Ne;e[92]!==n?(Ne=n("sessions.sidebar.header.actions.searchSessions"),e[92]=n,e[93]=Ne):Ne=e[93];let Be;e[94]!==Ne?(Be=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ne})}),e[94]=Ne,e[95]=Be):Be=e[95];let ze;e[96]!==Ee||e[97]!==Be?(ze=s.jsxs(At,{children:[Ee,Be]}),e[96]=Ee,e[97]=Be,e[98]=ze):ze=e[98];const We=C&&"bg-interactive-hover text-primary";let V;e[99]!==p||e[100]!==We?(V=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent",We),e[99]=p,e[100]=We,e[101]=V):V=e[101];let fe;e[102]!==C||e[103]!==n?(fe=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[102]=C,e[103]=n,e[104]=fe):fe=e[104];let Me;e[105]!==m?(Me=s.jsx(E,{name:"checkbox-multiple",className:m}),e[105]=m,e[106]=Me):Me=e[106];let Pe;e[107]!==C||e[108]!==V||e[109]!==fe||e[110]!==Me||e[111]!==k?(Pe=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:k,className:V,"aria-label":fe,"aria-pressed":C,children:Me})}),e[107]=C,e[108]=V,e[109]=fe,e[110]=Me,e[111]=k,e[112]=Pe):Pe=e[112];let ot;e[113]!==C||e[114]!==n?(ot=n(C?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[113]=C,e[114]=n,e[115]=ot):ot=e[115];let Ke;e[116]!==ot?(Ke=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ot})}),e[116]=ot,e[117]=Ke):Ke=e[117];let ht;e[118]!==Pe||e[119]!==Ke?(ht=s.jsxs(At,{children:[Pe,Ke]}),e[118]=Pe,e[119]=Ke,e[120]=ht):ht=e[120];let ft;e[121]!==p?(ft=Ie(p,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[121]=p,e[122]=ft):ft=e[122];let kt;e[123]!==n?(kt=n("sessions.sidebar.header.displayMode.label"),e[123]=n,e[124]=kt):kt=e[124];let pe;e[125]!==m?(pe=s.jsx(E,{name:"equalizer-2",className:m}),e[125]=m,e[126]=pe):pe=e[126];let Ye;e[127]!==ft||e[128]!==kt||e[129]!==pe?(Ye=s.jsx(Dt,{asChild:!0,children:s.jsx(Js,{asChild:!0,children:s.jsx("button",{type:"button",className:ft,"aria-label":kt,children:pe})})}),e[127]=ft,e[128]=kt,e[129]=pe,e[130]=Ye):Ye=e[130];let wt;e[131]!==n?(wt=n("sessions.sidebar.header.displayMode.label"),e[131]=n,e[132]=wt):wt=e[132];let jt;e[133]!==wt?(jt=s.jsx(Pt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:wt})}),e[133]=wt,e[134]=jt):jt=e[134];let de;e[135]!==Ye||e[136]!==jt?(de=s.jsxs(At,{children:[Ye,jt]}),e[135]=Ye,e[136]=jt,e[137]=de):de=e[137];let Ve;e[138]!==n?(Ve=n("sessions.sidebar.header.actions.sortProjects"),e[138]=n,e[139]=Ve):Ve=e[139];let ct;e[140]!==Ve?(ct=s.jsx(ho,{children:Ve}),e[140]=Ve,e[141]=ct):ct=e[141];let Le;e[142]!==I||e[143]!==M||e[144]!==n?(Le=[["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[Tt,Ct]=yt;return s.jsxs(Vt,{onClick:()=>{M(Tt),Rr({sidebarProjectSortOrder:Tt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ct)}),I===Tt?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},Tt)}),e[142]=I,e[143]=M,e[144]=n,e[145]=Le):Le=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[Tt,Ct]=yt;return s.jsxs(Vt,{onClick:()=>{R(Tt),Rr({sidebarProjectDisplayMode:Tt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ct)}),F===Tt?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},Tt)}),s.jsx(Os,{})]}):null,e[147]=F,e[148]=R,e[149]=i,e[150]=n,e[151]=re):re=e[151];let ke;e[152]!==n?(ke=n("sessions.sidebar.header.grouping.label"),e[152]=n,e[153]=ke):ke=e[153];let Fe;e[154]!==ke?(Fe=s.jsx(ho,{children:ke}),e[154]=ke,e[155]=Fe):Fe=e[155];let Ue;e[156]!==_||e[157]!==O||e[158]!==n?(Ue=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(yt=>{const[Tt,Ct]=yt;return s.jsxs(Vt,{onClick:()=>{O(Tt),Rr({sidebarSessionGroupingMode:Tt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ct)}),_===Tt?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null]},Tt)}),e[156]=_,e[157]=O,e[158]=n,e[159]=Ue):Ue=e[159];let st;e[160]===Symbol.for("react.memo_cache_sentinel")?(st=s.jsx(Os,{}),e[160]=st):st=e[160];let it;e[161]!==j||e[162]!==o||e[163]!==D||e[164]!==n||e[165]!==P?(it=o&&!j?s.jsxs(Vt,{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]=it):it=e[166];let rt;e[167]!==n?(rt=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[167]=n,e[168]=rt):rt=e[168];let qe;e[169]!==rt?(qe=s.jsx("span",{children:rt}),e[169]=rt,e[170]=qe):qe=e[170];let at;e[171]!==U?(at=U?s.jsx(E,{name:"check",className:"h-4 w-4 text-primary"}):null,e[171]=U,e[172]=at):at=e[172];let Oe;e[173]!==qe||e[174]!==at||e[175]!==L?(Oe=s.jsxs(Vt,{onClick:L,className:"flex items-center justify-between",children:[qe,at]}),e[173]=qe,e[174]=at,e[175]=L,e[176]=Oe):Oe=e[176];let ye;e[177]!==v||e[178]!==N||e[179]!==j||e[180]!==n?(ye=j?null:s.jsxs(s.Fragment,{children:[s.jsx(Os,{}),s.jsxs(Vt,{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(Vt,{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]=ye):ye=e[181];let mt;e[182]!==ct||e[183]!==Le||e[184]!==re||e[185]!==Fe||e[186]!==Ue||e[187]!==it||e[188]!==Oe||e[189]!==ye?(mt=s.jsxs(Zs,{align:"end",className:"min-w-[180px]",children:[ct,Le,J,re,Fe,Ue,st,it,Oe,ye]}),e[182]=ct,e[183]=Le,e[184]=re,e[185]=Fe,e[186]=Ue,e[187]=it,e[188]=Oe,e[189]=ye,e[190]=mt):mt=e[190];let bt;e[191]!==de||e[192]!==mt?(bt=s.jsxs(en,{children:[de,mt]}),e[191]=de,e[192]=mt,e[193]=bt):bt=e[193];let It;e[194]!==ze||e[195]!==ht||e[196]!==bt?(It=s.jsxs("div",{className:"flex items-center gap-1.5",children:[ze,ht,bt]}),e[194]=ze,e[195]=ht,e[196]=bt,e[197]=It):It=e[197];let Je;e[198]!==z||e[199]!==It?(Je=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[z,It]}),e[198]=z,e[199]=It,e[200]=Je):Je=e[200];let lt;e[201]!==b||e[202]!==g||e[203]!==y||e[204]!==S||e[205]!==x||e[206]!==w||e[207]!==f||e[208]!==n?(lt=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.jsx(ou,{inputRef:S,value:x,onSearch:f,onClose:()=>w(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear")})]}):null,e[201]=b,e[202]=g,e[203]=y,e[204]=S,e[205]=x,e[206]=w,e[207]=f,e[208]=n,e[209]=lt):lt=e[209];let vt;return e[210]!==Je||e[211]!==lt?(vt=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:[Je,lt]})}),e[210]=Je,e[211]=lt,e[212]=vt):vt=e[212],vt}function f0(t){return!t}function h0(t){return t.setProjectDisplayMode}function p0(t){return t.projectDisplayMode}function g0(t){return t.toggleStickyZoneHeaders}function x0(t){return t.stickyZoneHeaders}function b0(t){return t.setSessionGroupingMode}function y0(t){return t.sessionGroupingMode}function w0(t){return t.setProjectSortOrder}function S0(t){return t.projectSortOrder}function v0(t){return t.toggleRecentSection}function j0(t){return t.showRecentSection}function k0(t){return t.toggleMode}function C0(t){return t.enabled}function N0(t){const e=et.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 fi="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 A0(t){const e=et.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 m;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==u||e[4]!==h?(m=u?s.jsxs(s.Fragment,{children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:fi,"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:fi,"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:fi,"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]=m):m=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]!==m||e[11]!==p?(g=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[m,p]}),e[10]=m,e[11]=p,e[12]=g):g=e[12],g}const D0=t=>{for(const e of t.sessions.values())if(e.tabs.some(md))return!0;return!1},P0=()=>{const t=et.c(4),{terminal:e}=Sn(),n=Et(D0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=I0,l=T0;if(n)return Ei(e,"",l,o);let a=R0;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 I0(t){const e=Et.getState(),n=bg(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 T0(){return new Map(Et.getState().actionMutationRevisions)}function R0(){}const E0=t=>{const e=et.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:u,foldersMap:d,createFolder:h,addSessionToFolder:m}=t,p=r===void 0?!0:r;let g,w;e[0]!==m||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),f=i.archivedSessionsByProject.get(S.id)??[],b=d[x]??[],y=new Map(b.map(M0));f.forEach(v=>{const N=kh(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)||m(x,k.id,v.id)})})},w=[n,p,i,o,l,a,u,d,h,m],e[0]=m,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 M0(t){return[t.name.toLowerCase(),t]}function O0({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,m])=>h!==t&&m.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 F0=t=>{const e=et.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:u,newSessionDraftOpen:d,mobileVariant:h,openNewSessionDraft:m,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=St(_.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,f=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]!==m||e[14]!==n||e[15]!==x||e[16]!==o||e[17]!==p?(b=()=>{if(!r||d||Te.getState().isNewWorktreeDialogOpen||f.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)){f.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=O0({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&&(f.current=r);return}if(f.current=r,D.kind==="open-draft"){h&&p(!1),m({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,m,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]=m,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)},B0=t=>{const e=et.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=Ze(_0),a=Ze(L0);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[m,p]=c.useState(h);let g;e[10]!==m||e[11]!==n||e[12]!==l||e[13]!==d||e[14]!==a?(g={...n,activeSessionByProject:m,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:d,newSessionDraftOpen:a},e[10]=m,e[11]=n,e[12]=l,e[13]=d,e[14]=a,e[15]=g):g=e[15],F0(g);let w,S;return e[16]!==m||e[17]!==i?(w=()=>{i(m)},S=[m,i],e[16]=m,e[17]=i,e[18]=w,e[19]=S):(w=e[18],S=e[19]),c.useEffect(w,S),null};function _0(t){return t.currentSessionId}function L0(t){return!!t.newSessionDraft?.open}const fc={selected:0,"active-project":1,expanded:2,visible:3,background:4};function dm(t){const e=new Map,n=(r,i,o)=>{const l=St(r??null);if(!l)return;const a=e.get(l);a&&fc[a.priority]<=fc[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 $0=(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,hc=(t,e,n)=>{$0(t.get(e),n)&&t.set(e,n)},W0=t=>{const e=t;return St(e.directory)??St(e.project?.worktree)},z0=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const S=St(w.normalizedPath);if(!S)continue;const x=l.get(S);(!x||w.id.localeCompare(x.id)<0)&&l.set(S,w),hc(o,S,{projectId:w.id,projectRoot:S,scopeDirectory:S,kind:"project"})}if(!r)for(const[w,S]of n){const x=St(w),f=x?l.get(x):void 0;if(!(!f||!x))for(const b of S){const y=St(b.path);y&&hc(o,y,{projectId:f.id,projectRoot:x,scopeDirectory:y,kind:"worktree"})}}const a=new Map,u=new Map,d=new Map,h=new Map,m=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,f=null;for(;x;){if(a.has(x)){f=a.get(x)??null;break}if(S.push(x),f=o.get(x)??null,f)break;x=uf(x)}for(const b of S)a.set(b,f);return f},g=(w,S,x)=>{for(const f of w){const b=p(W0(f));if(!b)continue;u.set(f.id,b);const y=S.get(b.projectId);if(y?y.push(f):S.set(b.projectId,[f]),!x)continue;const v=x.get(b.scopeDirectory);v?v.add(f.id):x.set(b.scopeDirectory,new Set([f.id]))}};return g(t,d,m),g(i,h),{bySessionId:u,sessionsByProject:d,archivedSessionsByProject:h,sessionsByScope:m,directoryResolutions:a.size}},V0=t=>{const e=et.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},U0=(t,e)=>t.map(n=>{const r=St(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
913
|
+
`),K0=[],H0=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:u,buildGroupedSessions:d,hasSessionSearchQuery:h,normalizedSessionSearchQuery:m,filterSessionNodesForSearch:p,buildGroupSearchText:g,foldersMap:w,standaloneGroups:S}=t,x=c.useRef(new Map),f=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)??K0,A=o.has(L.id)?!!o.get(L.id):u,B=l.get(L.id)??null,X=U0(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 te=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";Ys(`ui.sidebar.project_section.rebuilt_reason.${te}`)}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&&Ys("ui.sidebar.project_section.reused",M),_>0&&Ys("ui.sidebar.project_section.rebuilt",_),U},[e,n,r,i,o,u,d,l,a]),b=c.useMemo(()=>f,[f]),y=c.useMemo(()=>{const P=new WeakMap;if(!h)return P;const I=m.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,m),F=_(L),R=!M&&Ao([g(U)],m),j=St(U.directory??null),A=j?w[j]??[]:[],B=M?0:A.filter(X=>Ao([X.name],m)).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,m,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===m)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??St(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:m,section:j}),j})},[y,h,m,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:f,visibleProjectSections:b,groupSearchDataByGroup:y,searchableProjectSections:v,sectionsForRender:N,flatSectionsForRender:k,searchMatchCount:D}},G0=180,pc=150,q0=2,Q0=8,gc=[-1,1,-2,2],hi=t=>`${t.directory}
|
|
914
|
+
${t.sessionId}`,Y0=t=>t?.directory?.trim()||null,X0=({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()},[]),m=c.useCallback(()=>{if(!(!t||d))for(;a.current.size<q0&&l.current.length>0;){const g=l.current.shift();if(!g)break;if(g.generation!==u.current||Ze.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),m()})}},[t,d,i]),p=c.useCallback(g=>{const w=g?.id,S=Y0(g);if(!t||d||!w||!S||w===e)return;const x={sessionId:w,directory:S,generation:u.current},f=hi(x);if(Pi(w,S).renderable||a.current.has(f)||l.current.some(v=>hi(v)===f))return;const b=o.current.get(f);b!==void 0&&window.clearTimeout(b);const y=window.setTimeout(()=>{if(o.current.delete(f),x.generation!==u.current)return;const v=l.current;v.length>=Q0&&v.shift(),v.push(x),m()},G0);o.current.set(f,y)},[e,t,d,m]);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 gc)p(n[w+S])},pc);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 gc)p(r[w+S])},pc);return()=>window.clearTimeout(g)},[e,t,d,r,p]),c.useEffect(()=>h,[h])},J0=t=>{const e=et.c(3),n=Ze(Z0);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],X0(r),null};function Z0(t){return t.currentSessionId}const Hr=t=>{const e=et.c(13),{directory:n,className:r}=t,{t:i}=Nt();let o;e[0]!==n?(o=mf(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],!Et(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 m=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]!==m||e[11]!==p?(w=s.jsx("span",{className:p,role:"img","aria-label":m,title:m,"data-action-directory":l,children:g}),e[9]=l,e[10]=m,e[11]=p,e[12]=w):w=e[12],w},wo=t=>{const e=et.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:m}=Zn(),p=i?ja[i]:null,g=o?ka[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 f;e[4]!==h||e[5]!==m||e[6]!==w||e[7]!==g||e[8]!==S||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==p?(f=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(Ca,{project:{id:n,iconImage:l},options:{themeVariant:m.metadata.variant,iconColor:m.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]=m,e[6]=w,e[7]=g,e[8]=S,e[9]=n,e[10]=a,e[11]=l,e[12]=p,e[13]=f):f=e[13];let b;e[14]!==x||e[15]!==f?(b=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[x,f]}),e[14]=x,e[15]=f,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},ej=t=>{const e=et.c(63),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:u,projectIconImage:d,projectIconBackground:h,isCollapsed:m,isRepo:p,isDesktopShell:g,hideDirectoryControls:w,alwaysShowActions:S,onToggle:x,onNewSession:f,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=cs(nj);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:te,isDragging:se}=Qo(X),ve=c.useRef(!1),K=`project:${n}`,he=M===K,[be,ie]=c.useState(!1),T=!!(O&&U);let Q;e[3]!==K||e[4]!==_?(Q=W=>{W&&ie(!1),_(W?K:null)},e[3]=K,e[4]=_,e[5]=Q):Q=e[5];const le=Q;let me;e[6]!==w||e[7]!==p||e[8]!==N||e[9]!==y||e[10]!==f||e[11]!==v||e[12]!==F||e[13]!==A?(me=W=>s.jsxs(s.Fragment,{children:[F&&!p&&!w&&f&&s.jsxs(W,{onClick:f,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]=f,e[11]=v,e[12]=F,e[13]=A,e[14]=me):me=e[14];const ue=me,Ce=rj,xe=oj,Re=ij;let we;e[15]===Symbol.for("react.memo_cache_sentinel")?(we=W=>{(W.button===2||W.button===0&&W.ctrlKey)&&(ve.current=!0)},e[15]=we):we=e[15];const G=we;let Se;e[16]!==x?(Se=W=>{if(W.currentTarget.blur(),ve.current){ve.current=!1;return}x()},e[16]=x,e[17]=Se):Se=e[17];const ge=Se;let Ae;e[18]!==Y?(Ae=Yo.Transform.toString(Y),e[18]=Y,e[19]=Ae):Ae=e[19];let oe;e[20]!==Ae||e[21]!==te?(oe={transform:Ae,transition:te},e[20]=Ae,e[21]=te,e[22]=oe):oe=e[22];const ne=se&&"opacity-30";let z;e[23]!==ne?(z=Ie("relative",ne),e[23]=ne,e[24]=z):z=e[24];let $;e[25]!==S||e[26]!==H||e[27]!==le||e[28]!==ge||e[29]!==w||e[30]!==R||e[31]!==n||e[32]!==m||e[33]!==be||e[34]!==g||e[35]!==he||e[36]!==T||e[37]!==p||e[38]!==Z||e[39]!==f||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(ru,{open:be,onOpenChange:ie,children:[s.jsx(nu,{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(),ie(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...H,children:[T?s.jsxs(en,{children:[s.jsx(Js,{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||he?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":S||he?"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(Zs,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:O?.map(W=>s.jsxs(Vt,{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:G,onClick:ge,...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||he?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":S||he?"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:m,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(en,{open:he,onOpenChange:le,children:[s.jsx(Js,{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",he?"opacity-100 pointer-events-auto":S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":A("sessions.sidebar.project.actions.projectMenu"),onPointerDown:xe,onMouseDown:Re,onClick:Ce,children:s.jsx(E,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Zs,{align:"end",className:"min-w-[180px]",children:ue(Vt)})]})]}),F&&f?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(),f()},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(su,{className:"min-w-[180px]",children:ue(Un)})]})]}),e[25]=S,e[26]=H,e[27]=le,e[28]=ge,e[29]=w,e[30]=R,e[31]=n,e[32]=m,e[33]=be,e[34]=g,e[35]=he,e[36]=T,e[37]=p,e[38]=Z,e[39]=f,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]!==oe||e[60]!==z||e[61]!==$?(ae=s.jsxs("div",{ref:ce,style:oe,className:z,children:[$,k]}),e[57]=k,e[58]=ce,e[59]=oe,e[60]=z,e[61]=$,e[62]=ae):ae=e[62],ae},tj=t=>{const e=et.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:m,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]!==m?(x={transform:S,transition:m},e[8]=S,e[9]=m,e[10]=x):x=e[10];const f=p&&"opacity-50";let b;e[11]!==f?(b=Ie("space-y-0.5 rounded-md",f),e[11]=f,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},sj=c.memo(tj);function nj(t){return t.stickyZoneHeaders}function rj(t){t.stopPropagation()}function oj(t){t.stopPropagation()}function ij(t){t.stopPropagation()}const aj=(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}},um=t=>{const e=et.c(9),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==r||e[1]!==n?(l=aj(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=Na(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 m=Aa(h);return d??m};function mm(t){const e=et.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 lj=t=>{const e=et.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=um(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(mm,{state:l,activeLabel:a,unreadLabel:u}),e[7]=l,e[8]=a,e[9]=u,e[10]=d):d=e[10],d},cj=t=>{const e=et.c(82),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:u,onRename:d,onDelete:h,children:m,mobileVariant:p,alwaysShowActions:g,isRenaming:w,renameDraft:S,onRenameDraftChange:x,onRenameSave:f,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 te=Y;let se;e[2]!==ce||e[3]!==n.name||e[4]!==_||e[5]!==d||e[6]!==f?(se=()=>{const Ne=ce.trim();Ne&&Ne!==n.name&&d(Ne),_&&f&&f(),A(!1),X("")},e[2]=ce,e[3]=n.name,e[4]=_,e[5]=d,e[6]=f,e[7]=se):se=e[7];const ve=se;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 he=K;let be;e[11]!==_||e[12]!==x?(be=Ne=>{_&&x?x(Ne):X(Ne)},e[11]=_,e[12]=x,e[13]=be):be=e[13];const ie=be;let T,Q;e[14]!==_?(T=()=>{if(!_)return;const Ne=()=>{const We=H.current;We&&(We.focus(),We.select())},Be=requestAnimationFrame(Ne),ze=window.setTimeout(Ne,0);return()=>{cancelAnimationFrame(Be),window.clearTimeout(ze)}},Q=[_],e[14]=_,e[15]=T,e[16]=Q):(T=e[15],Q=e[16]),c.useEffect(T,Q);const le=l?"folder":"folder-open",me=U&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let ue;e[17]!==me?(ue=Ie("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",me),e[17]=me,e[18]=ue):ue=e[18];let Ce;e[19]!==u||e[20]!==Z?(Ce=Z?void 0:Ne=>{Ne.currentTarget.blur(),u()},e[19]=u,e[20]=Z,e[21]=Ce):Ce=e[21];const xe=Z?void 0:"button",Re=Z?void 0:0;let we;e[22]!==u||e[23]!==Z?(we=Z?void 0:Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),u())},e[22]=u,e[23]=Z,e[24]=we):we=e[24];let G;e[25]!==n.name||e[26]!==l||e[27]!==R?(G=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]=G):G=e[28];const Se=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 ge;e[29]!==Se?(ge=Ie("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",Se),e[29]=Se,e[30]=ge):ge=e[30];const Ae=U?"text-primary":"text-muted-foreground";let oe;e[31]!==Ae?(oe=Ie("h-3.5 w-3.5 flex-shrink-0",Ae),e[31]=Ae,e[32]=oe):oe=e[32];let ne;e[33]!==le||e[34]!==oe?(ne=s.jsx(E,{name:le,className:oe}),e[33]=le,e[34]=oe,e[35]=ne):ne=e[35];let z;e[36]!==P||e[37]!==r||e[38]!==ce||e[39]!==n.name||e[40]!==he||e[41]!==ie||e[42]!==ve||e[43]!==l||e[44]!==U||e[45]!==Z||e[46]!==i||e[47]!==R?(z=Z?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:uj,onMouseDown:mj,onSubmit:Ne=>{Ne.preventDefault(),ve()},children:[s.jsx("input",{ref:H,value:ce,onChange:Ne=>ie(Ne.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:fj,onPointerDown:hj,onMouseDown:pj,onKeyDown:Ne=>{if(Ne.key==="Escape"){Ne.stopPropagation(),he();return}(Ne.key===" "||Ne.key==="Enter")&&Ne.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:gj,onPointerDown:xj,onMouseDown:bj,children:s.jsx(E,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Ne=>{Ne.stopPropagation(),he()},onPointerDown:yj,onMouseDown:wj,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(mm,{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]=he,e[41]=ie,e[42]=ve,e[43]=l,e[44]=U,e[45]=Z,e[46]=i,e[47]=R,e[48]=z):z=e[48];let $;e[49]!==ge||e[50]!==ne||e[51]!==z?($=s.jsxs("div",{className:ge,children:[ne,z]}),e[49]=ge,e[50]=ne,e[51]=z,e[52]=$):$=e[52];let ae;e[53]!==M||e[54]!==F||e[55]!==n.name||e[56]!==te||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:Ne=>{Ne.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:Ne=>{Ne.stopPropagation(),te()},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:Ne=>{Ne.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]=te,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]!==Ce||e[66]!==xe||e[67]!==Re||e[68]!==we||e[69]!==G||e[70]!==$||e[71]!==ae?(W=s.jsxs("div",{ref:y,className:ue,onClick:Ce,role:xe,tabIndex:Re,onKeyDown:we,"aria-label":G,children:[$,ae]}),e[63]=y,e[64]=ue,e[65]=Ce,e[66]=xe,e[67]=Re,e[68]=we,e[69]=G,e[70]=$,e[71]=ae,e[72]=W):W=e[72];let je;e[73]!==m||e[74]!==l||e[75]!==i||e[76]!==o||e[77]!==R?(je=l?null:s.jsxs("div",{className:"pb-1",children:[o,i.length>0?m: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]=m,e[74]=l,e[75]=i,e[76]=o,e[77]=R,e[78]=je):je=e[78];let Ee;return e[79]!==W||e[80]!==je?(Ee=s.jsxs("div",{className:"oc-folder",children:[W,je]}),e[79]=W,e[80]=je,e[81]=Ee):Ee=e[81],Ee},dj=c.memo(cj);function uj(t){return t.stopPropagation()}function mj(t){return t.stopPropagation()}function fj(t){return t.stopPropagation()}function hj(t){return t.stopPropagation()}function pj(t){return t.stopPropagation()}function gj(t){return t.stopPropagation()}function xj(t){return t.stopPropagation()}function bj(t){return t.stopPropagation()}function yj(t){return t.stopPropagation()}function wj(t){return t.stopPropagation()}const Sj=t=>{const e=et.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:m,isDragging:p}=Qg(u);let g;e[7]!==h?(g=f=>{f.stopPropagation(),h?.onPointerDown&&h.onPointerDown(f)},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]!==m||e[13]!==S?(x=s.jsx("div",{ref:m,...d,onPointerDown:w,className:S,children:o}),e[9]=d,e[10]=o,e[11]=w,e[12]=m,e[13]=S,e[14]=x):x=e[14],x},vj=t=>{const e=et.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}=Yg(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},jj=t=>{const e=et.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,m]=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 f=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),m(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]!==f||e[17]!==a||e[18]!==N?(C=s.jsxs(Ur,{sensors:a,collisionDetection:Kr,onDragStart:b,onDragCancel:y,onDragEnd:f,children:[o,N]}),e[15]=o,e[16]=f,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},kj=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!Ch(r),Cj=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,Nj=(t,e,n)=>{const r=new Map,i=o=>{const l=Ps(o.session)??St(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}))},Aj=(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})},Dj=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},Pj=(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 m=d.id;for(;m;){if(h.has(m)){o.add(d.id);break}h.add(m),m=r.get(m)?.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 m=o.has(d);return!m&&e.archivedBucket&&h.nodeCount===0?m=(i.get(d)??[]).some(u):(!m&&!e.searchQuery&&(m=!0),!m&&(h.nodeCount>0||!n&&Ao([h.name],e.searchQuery))&&(m=!0),m||(m=(i.get(d)??[]).some(u))),a.delete(d),m&&l.add(d),m};return t.forEach(d=>u(d.id)),new Set(t.filter(d=>l.has(d.id)).map(d=>d.id))},xc=new WeakMap;let bc=1;const Ij=t=>{const e=xc.get(t);if(e!==void 0)return e;const n=bc;return bc+=1,xc.set(t,n),n},Bo=t=>t.children.length===0?"":t.children.map(n=>{const r=Ij(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Bo(n)}`}).join("|"),fm=(t,e,n,r,i,o)=>{const l=fs(),a=(u,d)=>{if(u.session.id!==d.session.id||u.children.length!==d.children.length)return!0;const h=u.session.directory??i,m=d.session.directory??o,p=rl(l,h??"",u.session.id),g=rl(l,m??"",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)},Tj=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 yc=!1;function Rj(){for(const t of ra)t()}function Wa(t){na!==t&&(na=t,Rj())}function Ej(t){t.key==="Shift"&&Wa(!0)}function Mj(t){t.key==="Shift"&&Wa(!1)}function Oj(){Wa(!1)}function Fj(){yc||typeof window>"u"||(yc=!0,window.addEventListener("keydown",Ej),window.addEventListener("keyup",Mj),window.addEventListener("blur",Oj))}function Bj(t){return Fj(),ra.add(t),()=>{ra.delete(t)}}function _j(){return na}function Lj(){return!1}function $j(){return gt.useSyncExternalStore(Bj,_j,Lj)}const Wj=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,hm=/^g[1-9]\d*$/,Dr=(t,e,n,r,i)=>{if(!Wj.test(t)||e!==void 0&&!hm.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 hm.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)},zj=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("/")},Vj=(t,e,n,r)=>{const i=[t];return r&&i.push(r),i.push(e,n,"fusion"),i.join("/")},pm=t=>{const e=et.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:u}=Nt(),d=Yt(Uj),h=Yt(Kj),m=Yt(Hj);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(Gj),e[2]=g,e[3]=w):w=e[3];const S=w;let x,f;e[4]!==g.length||e[5]!==h?(x=()=>{g.length===0&&h()},f=[g.length,h],e[4]=g.length,e[5]=h,e[6]=x,e[7]=f):(x=e[6],f=e[7]),c.useEffect(x,f);let b,y;e[8]!==m||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 m=="string"&&m.trim().length>0?m.trim():null;if(O&&S.some(L=>L.name===O)){r(O);return}const U=S[0]?.name;U&&r(U)},y=[m,o,r,S,n],e[8]=m,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(Ns,{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(qj)}),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 Uj(t){return t.getVisibleAgents}function Kj(t){return t.loadAgents}function Hj(t){return t.currentAgentName}function Gj(t){return $d(t.mode)}function qj(t){return s.jsx(ns,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const Qj="h-7",Lr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Yj=t=>{const e=et.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",Qj),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 m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(E,{name:"close",className:"h-3.5 w-3.5"}),e[5]=m):m=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:m}),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},gm=t=>{const e=et.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:u,maxModels:d,addButtonClassName:h,dropdownSide:m,dropdownClassName:p,containerClassName:g,triggerIcon:w}=t,S=u===void 0?!0:u,x=m===void 0?"top":m,{t:f}=Nt(),b=Yt(Xj),y=Yt(Jj),v=Te(Zj),N=Te(e2),{favoriteModelsList:C,recentModelsList:k}=Nh(),D=Te(t2),P=Te(s2),[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 Pe of n){const ot=`${Pe.providerID}:${Pe.modelID}`;B.set(ot,(B.get(ot)||0)+1)}e[0]=n,e[1]=B}else B=e[1];const X=B;let H;e[2]!==n?(H=Pe=>n.filter(Ke=>Ke.providerID===Pe.providerID&&Ke.modelID===Pe.modelID).findIndex(Ke=>Ke.instanceId===Pe.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 Pe=R.current.getBoundingClientRect();if(x==="bottom"){const pe=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Pe.bottom-16-112;L(Math.max(160,Math.min(320,pe)));return}let ot=R.current.parentElement;for(;ot&&!ot.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const ft=getComputedStyle(ot);if(ft.overflow==="auto"||ft.overflow==="hidden"||ft.overflowY==="auto"||ft.overflowY==="hidden")break;ot=ot.parentElement}const Ke=ot?ot.getBoundingClientRect().top:0,ht=Pe.top-Ke-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 te,se;e[8]!==A||e[9]!==I?(te=()=>{!A&&I&&(M(!1),O(""))},se=[A,I],e[8]=A,e[9]=I,e[10]=te,e[11]=se):(te=e[10],se=e[11]),c.useEffect(te,se);let ve,K;e[12]!==I?(ve=()=>{if(!I)return;const Pe=ot=>{F.current&&!F.current.contains(ot.target)&&(M(!1),O(""))};return document.addEventListener("mousedown",Pe),()=>document.removeEventListener("mousedown",Pe)},K=[I],e[12]=I,e[13]=ve,e[14]=K):(ve=e[13],K=e[14]),c.useEffect(ve,K);let he;e[15]!==j||e[16]!==r||e[17]!==o||e[18]!==n.length?(he=Pe=>{const ot={providerID:Pe.providerID,modelID:Pe.modelID,displayName:Pe.model.name||Pe.modelID,instanceId:Lr()};j&&n.length>0&&o?o(0,ot):r(ot),j&&(M(!1),O(""))},e[15]=j,e[16]=r,e[17]=o,e[18]=n.length,e[19]=he):he=e[19];const be=he;let ie;e[20]!==f?(ie=f("multirun.modelMultiSelect.search.placeholder"),e[20]=f,e[21]=ie):ie=e[21];let T;e[22]!==f?(T=f("multirun.modelMultiSelect.search.noResults"),e[22]=f,e[23]=T):T=e[23];let Q;e[24]!==f?(Q=f("multirun.modelMultiSelect.sections.favorites"),e[24]=f,e[25]=Q):Q=e[25];let le;e[26]!==f?(le=f("multirun.modelMultiSelect.sections.recent"),e[26]=f,e[27]=le):le=e[27];let me;e[28]!==f?(me=f("multirun.modelMultiSelect.keyboard.hint"),e[28]=f,e[29]=me):me=e[29];let ue;e[30]!==f?(ue=f("settings.agents.modelSelector.actions.favorite"),e[30]=f,e[31]=ue):ue=e[31];let Ce;e[32]!==f?(Ce=f("settings.agents.modelSelector.actions.unfavorite"),e[32]=f,e[33]=Ce):Ce=e[33];let xe;e[34]!==f?(xe=f("chat.modelControls.capabilities"),e[34]=f,e[35]=xe):xe=e[35];let Re;e[36]!==f?(Re=f("chat.modelControls.capability.toolCalling"),e[36]=f,e[37]=Re):Re=e[37];let we;e[38]!==f?(we=f("chat.modelControls.capability.reasoning"),e[38]=f,e[39]=we):we=e[39];let G;e[40]!==f?(G=f("chat.modelControls.input"),e[40]=f,e[41]=G):G=e[41];let Se;e[42]!==f?(Se=f("chat.modelControls.output"),e[42]=f,e[43]=Se):Se=e[43];let ge;e[44]!==f?(ge=f("chat.modelControls.costPerMillion"),e[44]=f,e[45]=ge):ge=e[45];let Ae;e[46]!==ie||e[47]!==T||e[48]!==Q||e[49]!==le||e[50]!==me||e[51]!==ue||e[52]!==Ce||e[53]!==xe||e[54]!==Re||e[55]!==we||e[56]!==G||e[57]!==Se||e[58]!==ge?(Ae={searchPlaceholder:ie,noResults:T,favorites:Q,recent:le,keyboardHint:me,favorite:ue,unfavorite:Ce,capabilities:xe,capabilityToolCalling:Re,capabilityReasoning:we,input:G,output:Se,costPerMillion:ge},e[46]=ie,e[47]=T,e[48]=Q,e[49]=le,e[50]=me,e[51]=ue,e[52]=Ce,e[53]=xe,e[54]=Re,e[55]=we,e[56]=G,e[57]=Se,e[58]=ge,e[59]=Ae):Ae=e[59];const oe=Ae;let ne;e[60]!==g?(ne=Ie("relative",g),e[60]=g,e[61]=ne):ne=e[61];const z=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 je;e[66]!==w?(je=w??s.jsx(E,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=w,e[67]=je):je=e[67];let Ee;e[68]!==a||e[69]!==f?(Ee=a??f("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=f,e[70]=Ee):Ee=e[70];let Ne;e[71]!==z||e[72]!==$||e[73]!==ae||e[74]!==W||e[75]!==je||e[76]!==Ee?(Ne=s.jsxs("button",{ref:R,type:"button","data-popup-open":z,className:$,disabled:ae,onClick:W,children:[je,Ee]}),e[71]=z,e[72]=$,e[73]=ae,e[74]=W,e[75]=je,e[76]=Ee,e[77]=Ne):Ne=e[77];let Be;e[78]!==U||e[79]!==A||e[80]!==p||e[81]!==x||e[82]!==C||e[83]!==be||e[84]!==D||e[85]!==N||e[86]!==I||e[87]!==oe||e[88]!==X||e[89]!==y||e[90]!==P||e[91]!==b||e[92]!==k||e[93]!==_||e[94]!==v?(Be=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(Ah,{providers:b,providerOrder:P,favoriteModels:C,recentModels:k,modelsMetadata:y,hiddenModels:D,searchQuery:_,onSearchQueryChange:O,onSelect:be,labels:oe,selectionCount:Pe=>X.get(`${Pe.providerID}:${Pe.modelID}`)||0,disabled:!A,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:U?`${U}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:I,isFavorite:Pe=>N(Pe.providerID,Pe.modelID),onToggleFavorite:Pe=>v(Pe.providerID,Pe.modelID),onEscape:()=>{M(!1),O("")}})}):null,e[78]=U,e[79]=A,e[80]=p,e[81]=x,e[82]=C,e[83]=be,e[84]=D,e[85]=N,e[86]=I,e[87]=oe,e[88]=X,e[89]=y,e[90]=P,e[91]=b,e[92]=k,e[93]=_,e[94]=v,e[95]=Be):Be=e[95];let ze;e[96]!==ne||e[97]!==Ne||e[98]!==Be?(ze=s.jsxs("div",{className:ne,ref:F,children:[Ne,Be]}),e[96]=ne,e[97]=Ne,e[98]=Be,e[99]=ze):ze=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]!==f?(We=S&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Pe,ot)=>{const Ke=`${Pe.providerID}:${Pe.modelID}`,ht=X.get(Ke)||1,ft=Z(Pe),pe=b.find(de=>de.id===Pe.providerID)?.models?.find(de=>de.id===Pe.modelID),Ye=pe?.variants?Object.keys(pe.variants):[],wt=Ye.length>0,jt=Pe.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Yj,{model:Pe,instanceIndex:ft,totalSameModel:ht,onRemove:()=>i(ot)}),wt&&s.jsxs(Fs,{value:jt,onValueChange:de=>{if(!o)return;o(ot,{...Pe,variant:de==="__default__"?void 0:de})},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(Ns,{placeholder:f("multirun.modelMultiSelect.variant.placeholder"),children:de=>de==="__default__"?f("multirun.modelMultiSelect.variant.default"):de})]}),s.jsxs(_s,{fitContent:!0,children:[s.jsx(ns,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:f("multirun.modelMultiSelect.variant.default")}),Ye.map(n2)]})]})]},Pe.instanceId)})}),e[100]=Z,e[101]=X,e[102]=i,e[103]=o,e[104]=b,e[105]=n,e[106]=S,e[107]=f,e[108]=We):We=e[108];let V;e[109]!==ze||e[110]!==We?(V=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[ze,We]}),e[109]=ze,e[110]=We,e[111]=V):V=e[111];let fe;e[112]!==d||e[113]!==l||e[114]!==n.length||e[115]!==f?(fe=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:d!==void 0?f("multirun.modelMultiSelect.validation.minToMax",{min:l,max:d}):f("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=d,e[113]=l,e[114]=n.length,e[115]=f,e[116]=fe):fe=e[116];let Me;return e[117]!==V||e[118]!==fe?(Me=s.jsxs("div",{className:"space-y-2",children:[V,fe]}),e[117]=V,e[118]=fe,e[119]=Me):Me=e[119],Me};function Xj(t){return t.providers}function Jj(t){return t.modelsMetadata}function Zj(t){return t.toggleFavoriteModel}function e2(t){return t.isFavoriteModel}function t2(t){return t.hiddenModels}function s2(t){return t.providerOrder}function n2(t){return s.jsx(ns,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const r2=(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} ---`},wc=(t,e)=>Ze.getState().getWorktreeMetadata(t)?.projectDirectory??e,o2=async t=>{const e=t.directory??void 0,n=Ph(t.session.id,e);if(n.length===0&&t.directory){const i=(await Xs.withDirectory(t.directory,()=>Xs.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 il(l.parts??[]).trim()}return""}for(let r=n.length-1;r>=0;r-=1){const i=n[r];if(i.role==="assistant")return il(Ih(i.id,e)).trim()}return""};function i2({session:t,open:e,onOpenChange:n}){const{t:r}=Nt(),i=Dh(),o=$s(j=>j.activeSessions),l=$s(j=>j.archivedSessions),a=Yt(j=>j.providers),u=Yt(j=>j.currentProviderId),d=Yt(j=>j.currentModelId),h=Yt(j=>j.currentAgentName),[m,p]=c.useState(u??""),[g,w]=c.useState(d??""),[S,x]=c.useState(()=>u&&d?[{providerID:u,modelID:d,instanceId:Lr()}]:[]),[f,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=Ze.getState().getDirectoryForSession(t.id),A=wc(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=Ze.getState().getDirectoryForSession(X.id)??Ps(X),ce=wc(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===m)?.models.find(j=>j.id===g),O=_?.variants?Object.keys(_.variants):[],U=!!(P&&m&&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||!m||!g)){D(!0);try{const j=await Promise.all(N.map(Y=>o2(Y))),A=N.map((Y,te)=>({source:Y,text:j[te]??""})).filter(Y=>Y.text.trim().length>0);if(A.length===0){_e.error(r("multirun.fusion.toast.noOutputs"));return}const B=N[0]?.projectDirectory??N[0]?.directory??null,X=Vj(P.groupSlug,m,g,P.runGroup),[H,Z]=await Promise.all([ol("session.fusion.visible"),ol("session.fusion.instructions")]),ce=await Ze.getState().createSession(X,B,null);if(!ce)throw new Error("Failed to create fusion session");Ze.getState().setCurrentSession(ce.id,B),n(!1),await Xs.sendMessage({id:ce.id,providerID:m,modelID:g,variant:f||void 0,agent:y||void 0,text:H,additionalParts:[{text:Z,synthetic:!0},...A.map((Y,te)=>({text:r2(Y.source,Y.text,te),synthetic:!0})),{text:`
|
|
919
|
+
|
|
920
|
+
--- FUSION INPUTS END ---
|
|
921
|
+
Now write the final fused answer.`,synthetic:!0}],directory:B??Xs.getDirectory()})}catch(j){console.error("[MultiRunFusion] Failed to start fusion",j),_e.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(Ws,{children:[s.jsx(Is,{children:r("multirun.fusion.title")}),s.jsx(Ts,{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(gm,{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:m?s.jsx(Ti,{providerId:m,className:"h-3.5 w-3.5 mr-1"}):void 0})}),O.length>0?s.jsxs(Fs,{value:f||"__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(Ns,{children:j=>j==="__default__"?r("multirun.modelMultiSelect.variant.default"):j})]}),s.jsxs(_s,{fitContent:!0,portalToBody:!0,children:[s.jsx(ns,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),O.map(j=>s.jsx(ns,{value:j,children:j},j))]})]}):null,s.jsx(pm,{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 a2(t){const e=et.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 xm=async(t,e,n)=>{const r=n.getRuntimeKey(),i=St(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||St(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const u=za({rawWorktreesByProjectRef:n.rawWorktreesByProjectRef,publishedWorktreesByProject:n.getPublishedWorktreesByProject(),runtimeKey:r}),d=o.map(w=>_o(w));d.sort((w,S)=>bm({metadata:w},{metadata:S}));const h=Th(u.worktreesByProject,i,d,e?.projectDirectory);l2(n.rawWorktreesByProjectRef,r),n.rawWorktreesByProjectRef.current={runtimeKey:r,revision:n.rawWorktreesByProjectRef.current.revision,worktreesByProject:h};const m=n.getPublishedWorktreesByProject(),p=Rh(n.partitionWorktreesByRegisteredProject(l,h),m),g=[...p.values()].flat();return n.recordWorktreesSeen(g.map(w=>w.path),n.now()),n.worktreeMapsEqual(p,m)||n.publishTopology({availableWorktrees:g,availableWorktreesByProject:p}),d},l2=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),c2=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>_o(r))])),za=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:c2(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),bm=(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"})},Sc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},_o=t=>({...t,path:St(t.path)??t.path,projectDirectory:St(t.projectDirectory)??t.projectDirectory,worktreeRoot:St(t.worktreeRoot??t.path)??t.worktreeRoot}),vc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=St(e?.path??null)===n,a=l?e?.branch??"":i??"",u={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||Sc(n):i||Sc(n),name:l?e?.name:void 0,worktreeRoot:l?St(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},jc=t=>{const e=St(t.projectPath??null),n=St(t.sourceDirectory??null)??St(t.currentWorktree?.path??null),r=St(t.discoveredWorktrees.find(h=>St(h.projectDirectory??null))?.projectDirectory??null),i=St(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=h=>{const m=St(h.metadata.path??null);!m||l.has(m)||l.set(m,{...h,metadata:_o({...h.metadata,path:m})})};for(const h of t.discoveredWorktrees){const m=St(h.path??null);m&&a({metadata:_o({...h,path:m,projectDirectory:St(h.projectDirectory??null)??o??e??m}),isPrimary:o===m,isCurrent:n===m})}o&&!l.has(o)&&a({metadata:vc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:vc({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,m)=>h.metadata.path.localeCompare(m.metadata.path,void 0,{sensitivity:"base"})),d.sort(bm),[...u,...d]},d2=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=za({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=St(l?.path??null);return{cachedTargets:jc({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 xm(l,t.currentWorktree,e);return jc({projectPath:a,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},u2=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},m2=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),f2=(t,e)=>St(t.worktree?.path??null)===St(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,oa=6,lo=14,kc=oa+14+6,pi=new WeakMap,h2=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,Ys("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)},p2=c.memo(function(e){const n=et.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:u,onArchive:d,onDelete:h}=e,m=$j(),p=m?i:r;let g;n[0]!==d||n[1]!==h||n[2]!==m?(g=C=>{if(m||C.shiftKey){h(C);return}d(C)},n[0]=d,n[1]=h,n[2]=m,n[3]=g):g=n[3];const w=g,S=m?"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 f=m?"delete-bin":"archive";let b;n[7]!==l||n[8]!==f?(b=s.jsx(E,{name:f,className:l}),n[7]=l,n[8]=f,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:k2,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 g2(t){Ys("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:m,editingId:p,setEditingId:g,editTitle:w,setEditTitle:S,handleSaveEdit:x,handleCancelEdit:f,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=ds(De=>De.getFoldersForScope),Z=ds(De=>De.getSessionFolderId),ce=ds(De=>De.removeSessionFromFolder),Y=ds(De=>De.addSessionToFolder),te=Te(De=>De.openContextPanelTab),se=c.useMemo(()=>Pn(),[]),ve=c.useMemo(()=>Vo(),[]),K=c.useContext(Eh),he=se?"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",be=se?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",ie=se,T=!l&&!F,Q=se?T&&ie?"group-hover:pr-18":T||ie?"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",me=se?T?"pr-18":"pr-14":T?"pr-7":"pr-3",ue=c.useRef(!1),[Ce,xe]=c.useState(!1),Re=c.useRef(p);Re.current=p;const we=c.useRef(null),G=c.useRef(!1),Se=c.useRef(x);Se.current=x;const[ge,Ae]=c.useState(w),oe=c.useRef(ge);oe.current=ge;const ne=c.useRef(null),z=c.useRef(!1),$=c.useRef(null),ae=c.useRef(null),W=n.session,je=W,Ee=Ht(c.useCallback(De=>{if(j?.projectLabel||!o)return null;const Ot=De.projects.find(Jt=>Jt.id===o);return Ot?Ot.label?.trim()||Fn(St(Ot.path)??Ot.path,null)||Ot.path:null},[o,j?.projectLabel])),Ne=j?.projectLabel??(Ee?Da(Ee):null),Be=j?.branchLabel??n.worktree?.branch??null,ze=c.useMemo(()=>{if(se)return null;const De=n.worktree?.branch?.trim(),Ot=St(n.worktree?.path??null);return De&&Ot?Ho(Ot,De):null},[se,n.worktree]),We=zd(ze),V=We?`var(--pr-${We.visualState})`:void 0,fe=cs(De=>De.sessionGroupingMode),Me=!!Be&&(A==="recent"||fe==="flat"),Pe=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]),ot=Ze(De=>De.currentSessionId===W.id),Ke=St(W.directory??null)??St(i??null),ht=o??Ke??null,ft=Mh(),kt=Vd(),pe=se,Ye=bs(De=>De.enabled),wt=bs(c.useCallback(De=>De.selectedIds.has(W.id),[W.id])),jt=bs(De=>De.toggleSelected),de=bs(De=>De.setRange),Ve=c.useCallback(De=>{const Ot=[],Jt=os=>{os.children.forEach(ws=>{Ot.push(ws.session.id),Jt(ws)})};return Jt(De),Ot},[]),ct=c.useCallback(De=>{const Ot=[],Jt=os=>{os.children.forEach(ws=>{Ot.push(ws.session),Jt(ws)})};return Jt(De),Ot},[]),[Le,J]=c.useState(!1),[re,ke]=c.useState(!0),Fe=`${A}:${l?"archived":"active"}:${W.id}`,Ue=Ud(c.useCallback(De=>!!De.sessionMemoryState.get(Oh(W.id))?.isZombie,[W.id])),it=pa(W.id)?.type??"idle",rt=it==="busy"||it==="retry",qe=Fh(W.id,rt),at=Iu(W.id),Oe=Ta(W.id,Ke),ye=at||Oe,mt=n.worktree??Ze.getState().getWorktreeMetadata(W.id)??null,[bt,It]=c.useState([]),[Je,lt]=c.useState(!1),[vt,yt]=c.useState(!1),Tt=c.useRef(!1),Ct=c.useRef(0),Rt=Bh(W.id,Ke??void 0,{bootstrap:!1}),Bt=_h(je),Gt=Bt?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(al[Bt.status]),"aria-label":e(al[Bt.status]),children:s.jsx(E,{name:"target",className:"h-3 w-3",style:{color:Lh[Bt.status]}})}):null,qt=je.title||e("sessions.sidebar.session.untitled"),Ut=n.children.length>0,Wt=$h(a,Ke,W.id),Ft=Fe,Kt=d?!0:u.has(Ft),$e=c.useMemo(()=>Nj(n,Kt,Ke),[Kt,n,Ke]),Xe=Wh($e),ut=!!je.parentID,Ge=hd(W.id)>0&&(!ut||m),_t=je.time?.updated||je.time?.created||Date.now(),Qt=Kd(_t),Zt=zh(_t),rs=I===Fe,[es,zs]=c.useState(!1),ys=rs||es,Rs=c.useMemo(()=>So(je.title)!==null,[je.title]),[is,Vs]=c.useState(!1),Us=c.useMemo(()=>Ve(n).length,[Ve,n]),As=c.useCallback(async De=>{const Ot=[];let Jt=0;for(const os of De)try{if(!Ke)throw new Error("Session directory is required for export");const ws=await ft({directory:Ke,sessionID:os.session.id});if(!ws)throw new Error("Session runtime changed during export");const gs=os.session.title||e("sessions.sidebar.session.export.untitledSubagent"),nn=os.session.agent,ts=await As(os.children);Jt+=ts.skipped,Ot.push({title:gs,agent:nn,records:ws,children:ts.children})}catch{Jt+=Ve(os).length+1}return{children:Ot,skipped:Jt}},[Ve,ft,Ke,e]),hs=c.useCallback(De=>{De<=0||_e.warning(De===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:De}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:De}))},[e]),Ds=c.useCallback(async De=>{if(!Ke){_e.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Ot=await ft({directory:Ke,sessionID:W.id}).catch(()=>null);if(!Ot){_e.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Ot.length===0){_e.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Jt,os=0;if(De&&n.children.length>0){const ts=await As(n.children);Jt=ts.children,os=ts.skipped}const ws=Nu(Ot,je.title??null,Jt),gs=Pu(je.title??null),nn=await Du(ws,gs);if(nn){_e.success(e("sessions.sidebar.session.export.success"),{action:{label:e(lb()),onClick:()=>{ab(nn).then(ts=>{ts||_e.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),hs(os);return}Au(ws,gs),_e.success(e("sessions.sidebar.session.export.success")),hs(os)},[As,ft,n.children,je.title,W.id,Ke,hs,e]),Ks=c.useCallback(async()=>{if(n.children.length>0){ke(!0),J(!0);return}await Ds(!1)},[Ds,n.children.length]),Hs=c.useCallback(()=>{Ke&&Mn("desktop_open_session_mini_chat_window",{sessionId:W.id,directory:Ke,apiBaseUrl:Nn(),clientToken:$r()}).catch(De=>{console.warn("[session-sidebar] failed to open mini chat window",De)})},[W.id,Ke]);if(c.useEffect(()=>{if(p!==W.id)return;const De=Ot=>{const os=(Ot.target instanceof HTMLElement?Ot.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(W.id)}"]`);ae.current&&!os&&Se.current(oe.current)};return document.addEventListener("mousedown",De),()=>document.removeEventListener("mousedown",De)},[p,W.id]),c.useLayoutEffect(()=>{if(p!==W.id){ne.current===W.id&&(ne.current=null);return}ne.current!==W.id&&(ne.current=W.id,z.current=!0,Ae(w))},[p,w,W.id]),c.useLayoutEffect(()=>{if(p!==W.id||!z.current)return;const De=$.current;!De||De.value!==w||(z.current=!1,De.focus(),De.select())},[p,w,ge,W.id]),p===W.id)return s.jsx("div",{style:{paddingLeft:kc+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(ge)},children:[s.jsx("input",{ref:$,value:ge,onChange:De=>Ae(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,f)}),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:f,"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 ks=Rt.length,tn=Xe===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:Xe}),Mt=Tj({actionsAlwaysVisible:R&&!se,menuOpen:ys,hideOnHoverClass:be}),$t=!ye&&!rt&&Ge&&!ot,Xt=rt||$t,ps=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":ps,title:ps}),ee=(rt||$t)&&qe,He=!R&&Ut&&(ye||Xt||Wt),tt=Wt&&!ye&&!Xt,q=s.jsx(E,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),Qe=ye||Xt||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",He?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:ye?s.jsx(E,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e(Oe?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}):Xt?ms:tt?q:null}):null,nt=Ut&&!R&&(ye||Xt||Wt),pt=Ut?s.jsx("span",{role:"button",tabIndex:0,onClick:De=>{De.stopPropagation(),De.currentTarget.blur(),b(Ft)},onKeyDown:De=>{(De.key==="Enter"||De.key===" ")&&(De.preventDefault(),De.stopPropagation(),b(Ft))},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",nt?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto":""),"aria-label":e(Kt?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:Kt?s.jsx(E,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(E,{name:"arrow-right-s",className:"h-3 w-3"})}):null,zt=Ue?s.jsx(E,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,as=De=>{De&&zs(!1),M(De?Fe:null)},Lt=De=>{if(!De&&we.current){const{id:Ot,title:Jt}=we.current;we.current=null,g(Ot),S(Jt)}},Es=De=>{zs(De)},sn=De=>{De.preventDefault(),De.stopPropagation(),M(rs?null:Fe)},Sr=De=>{De.preventDefault(),De.stopPropagation()},sr=De=>{De.preventDefault(),De.stopPropagation()},Em=De=>{De.preventDefault(),De.stopPropagation()},Mm=De=>{De.preventDefault(),De.stopPropagation()},Om=De=>{De.preventDefault(),De.stopPropagation(),M(null),O(W,{archivedBucket:l})},Fm=De=>{De.preventDefault(),De.stopPropagation(),M(null),O(W,{archivedBucket:l,hardDelete:!0,skipConfirm:!0})},Bm=De=>{De.preventDefault(),De.stopPropagation()},_m=De=>{De.preventDefault(),De.stopPropagation()},Lm=De=>{De.preventDefault(),De.stopPropagation(),K?.vscode?.executeCommand("aiworker.openSessionInEditor",W.id,qt)},Va=De=>{if(ue.current){ue.current=!1;return}if(Ye){if(De?.preventDefault(),De?.stopPropagation(),De?.shiftKey){const Jt=Array.from(document.querySelectorAll("[data-session-row]")).map(gs=>gs.getAttribute("data-session-row")).filter(gs=>gs!==null&&gs.length>0),os=bs.getState().anchorId,ws=new Map;ws.set(W.id,Ve(n)),de(os,W.id,Jt,ht,ws);return}jt(W.id,ht,Ve(n));return}De?.currentTarget&&h2(De.currentTarget),y(W.id,Ke)},$m=De=>{De.defaultPrevented||(De.target instanceof HTMLElement?De.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||Va(De)},Wm=De=>{(De.button===2||De.button===0&&De.ctrlKey&&!Ye)&&(ue.current=!0)},zm=De=>{F&&De.pointerType==="touch"&&xe(!0),De.button===0&&!ot&&!Ye&&!pe&&Ke&&!Pi(W.id,Ke).renderable&&kt({directory:Ke,sessionID:W.id}).catch(()=>{})},Ua=De=>{F&&De.pointerType==="touch"&&xe(!1)},Vm=De=>{Tt.current=De,Ct.current+=1;const Ot=Ct.current;if(!De){lt(!1),yt(!1);return}const Jt=L({projectId:o??null,sourceDirectory:Ke,currentWorktree:mt});It(Jt.cachedTargets),lt(!0),yt(!1),Jt.refreshTargets.then(os=>{!Tt.current||Ct.current!==Ot||(It(os),lt(!1),yt(!1))}).catch(()=>{!Tt.current||Ct.current!==Ot||(lt(!1),yt(!0))})},Ka=({Item:De,Separator:Ot,Sub:Jt,SubTrigger:os,SubContent:ws})=>s.jsxs(s.Fragment,{children:[s.jsxs(De,{onClick:()=>{we.current={id:W.id,title:qt}},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:Ke,open:ys,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:()=>Ke&&X({directory:Ke,sessionId:W.id}),className:"[&>svg]:mr-1",children:[Wt?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(Wt?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),je.share?s.jsxs(s.Fragment,{children:[s.jsx(De,{onClick:()=>{je.share?.url&&k(je.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(je),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:()=>{Ks()},className:"[&>svg]:mr-1",children:[s.jsx(E,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),kj({isSubtaskSession:ut,archivedBucket:!!l,isVSCode:se,sessionDirectory:Ke})?(()=>{const gs=Cj({sessionDirectory:Ke,isStreaming:rt,isMovingToWorktree:at}),nn=m2({targets:bt,isRefreshing:Je,loadFailed:vt});return s.jsxs(Jt,{onOpenChange:Vm,children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsxs(os,{disabled:gs,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(at?"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:[bt.map(ts=>{const rn=St(ts.metadata.path??null)??ts.metadata.path,vr=ts.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):ts.metadata.label||ts.metadata.branch||ts.metadata.name||ts.metadata.path,xs=ts.isCurrent||ts.metadata.worktreeStatus!=="ready";return s.jsxs(De,{disabled:xs,title:ts.metadata.path,"data-session-worktree-target":rn,onClick:()=>{xs||!Ke||Hi({kind:"existing",root:je,descendants:ct(n),sourceDirectory:Ke,destination:ts.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}),ts.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),ts.isCurrent?s.jsx(E,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},rn)}),nn.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,nn.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(Ot,{}),s.jsxs(De,{disabled:gs,"data-session-worktree-new-action":"true",onClick:()=>{gs||!Ke||Hi({kind:"quick",root:je,descendants:ct(n),sourceDirectory:Ke,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,Rs?s.jsxs(De,{onClick:()=>Vs(!0),className:"[&>svg]:mr-1",children:[s.jsx(a2,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,Ke&&!l?(()=>{const gs=[],nn=xs=>{const Cs=St(xs??null);Cs&&!gs.includes(Cs)&&gs.push(Cs)};if(o&&!se){const xs=Ht.getState().projects.find(nr=>nr.id===o),Cs=St(xs?.path??null);nn(Cs),Cs&&(Ze.getState().availableWorktreesByProject.get(Cs)??[]).forEach(nr=>nn(nr.path))}nn(Hd(Ke)),nn(Ke);const ts=gs.flatMap(xs=>H(xs).map(Cs=>({scope:xs,folder:Cs}))),rn=ts.find(({scope:xs,folder:Cs})=>Z(xs,W.id)===Cs.id)??null,vr=gs[0]??Ke;return s.jsxs(s.Fragment,{children:[s.jsx(Ot,{}),s.jsxs(Jt,{children:[s.jsxs(os,{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:[ts.length===0?s.jsx(De,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):ts.map(({scope:xs,folder:Cs})=>{const nr=rn?.folder.id===Cs.id;return s.jsxs(De,{onClick:()=>{if(nr){ce(xs,W.id);return}rn&&rn.scope!==xs&&ce(rn.scope,W.id),Y(xs,Cs.id,W.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:Cs.name}),nr?s.jsx(E,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},Cs.id)}),s.jsx(Ot,{}),s.jsxs(De,{onClick:()=>{const xs=_(vr);xs&&(G.current=!0,rn&&rn.scope!==vr&&ce(rn.scope,W.id),Y(vr,xs.id,W.id))},children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),rn?s.jsxs(De,{onClick:()=>{ce(rn.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,se?null:s.jsxs(De,{disabled:!Ke,onClick:()=>{Ke&&te(Ke,{mode:"chat",dedupeKey:`session:${W.id}`,label:qt,sessionTitleFallback:qt})},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")})]}),ve?s.jsxs(De,{disabled:!Ke,onClick:Hs,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(Ot,{}),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")]})]}),Um=s.jsx(Zs,{align:"end",className:"min-w-[180px]",finalFocus:()=>G.current?(G.current=!1,!1):!Re.current,children:Ka({Item:Vt,Separator:Os,Sub:Uh,SubTrigger:Kh,SubContent:Hh})}),Km=s.jsx(Li,{children:s.jsx($i,{className:"app-region-no-drag z-50",children:s.jsx(Wi,{"data-slot":"dropdown-menu-content",finalFocus:()=>G.current?(G.current=!1,!1):!Re.current,style:{color:"var(--surface-elevated-foreground)"},className:Ie(Si,"min-w-[180px]"),children:Ka({Item:({className:De,...Ot})=>s.jsx(pu,{className:Ie(gd,De),...Ot}),Separator:({className:De,...Ot})=>s.jsx(hu,{className:Ie(pd,De),...Ot}),Sub:ex,SubTrigger:({className:De,children:Ot,...Jt})=>s.jsxs(tx,{className:Ie(Vh,De),...Jt,children:[Ot,s.jsx(E,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:De,children:Ot,...Jt})=>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),...Jt,children:Ot})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(Sj,{sessionId:W.id,sessionDirectory:Ke??null,sessionTitle:qt,children:s.jsxs(xu,{open:es,onOpenChange:Es,onOpenChangeComplete:Lt,children:[s.jsxs(gu,{render:s.jsx("div",{"data-session-row":W.id,"data-session-scope":ht??"","data-session-archived":l?"1":"0","aria-current":ot?"page":void 0,onClick:$m,style:{paddingLeft:kc+r*lo},className:Ie("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-1.5",ot&&!wt&&"bg-primary/10",wt&&"bg-interactive-selection")}),children:[Qe,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:zm,onPointerUp:Ua,onPointerCancel:Ua,onMouseDown:Wm,onClick:De=>Va(De),onDoubleClick:De=>{De.stopPropagation(),v(W.id,qt)},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]",Ce&&"bg-interactive-hover/70",R?se?Q:le:ys?me:Q),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",ot?"text-primary":Ge?"text-foreground":"text-foreground/80"),children:po(qt,h)}),!l&&Ke&&(A==="recent"||fe==="flat"&&n.worktree&&St(n.worktree.path)!==St(n.worktree.projectDirectory))?s.jsx(Hr,{directory:Ke,className:R?void 0:ys?"mr-1":se?"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:ee?s.jsx(Sl,{sessionId:W.id,running:rt}):s.jsxs(s.Fragment,{children:[Gt,Me?s.jsx(E,{name:"git-branch",className:Ie("h-3 w-3",!V&&"text-muted-foreground/60"),style:V?{color:V}:void 0}):null,Zt]})}):ee||Gt||Me||A==="recent"?s.jsx("div",{className:Ie("relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",ys?"hidden":se?"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:ee?s.jsx(Sl,{sessionId:W.id,running:rt,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[Gt,Me?s.jsx(E,{name:"git-branch",className:Ie("h-3 w-3",!V&&"text-muted-foreground/60"),style:V?{color:V}:void 0}):null,A==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:Zt}):null]})})}):null,ks>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",Mt),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:ks})]}):null,Xe>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",Mt),title:tn,"aria-label":tn,children:[s.jsx(E,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Xe})]}):null]})})}),se?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:qt}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:Qt,children:Zt})]}),Ne?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:Ne})]}):null,Be?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:V?{color:V}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:Be})]}):null,We&&Pe?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:V?{color:V}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:V?{color:V}:void 0,children:["#",We.number," · ",Pe]})]}):null]})})]})}),zt&&!F?s.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 z-10",children:zt}):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",ys||R&&!se?"opacity-100":Ie("opacity-0",he)),children:[T?s.jsx(p2,{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:Em,onMouseDown:Mm,onArchive:Om,onDelete:Fm}):null,ie?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:Bm,onMouseDown:_m,onClick:Lm,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(en,{open:rs,onOpenChange:as,onOpenChangeComplete:Lt,children:[s.jsx(Js,{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":ys?"h-4 w-4 opacity-100":Ie("h-4 w-4 opacity-0",he)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Sr,onMouseDown:sr,onClick:sn,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")})})}),Um]})]})]}),Km]})}),Ut&&Kt?B:null,s.jsx(vs,{open:Le,onOpenChange:J,children:s.jsxs(js,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Ws,{children:[s.jsx(Is,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Ts,{children:Us===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:Us}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:Us})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:re,onChange:De=>ke(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),Ds(re)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),Rs?s.jsx(i2,{session:je,open:is,onOpenChange:Vs}):null]},W.id)}const Cc=t=>St(t.session.directory??null),x2=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),b2=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},Nc=t=>t.menuOpenSessionId??b2(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},y2=(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}`)},w2=(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,S2=(t,e)=>{if(t.node.session.id!==e.node.session.id||!w2(t.node.session,e.node.session)||!f2(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(Cc(t.node)!==Cc(e.node))return"nodeDirectory";if(!x2(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&fm(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&y2(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=Nc(t),i=Nc(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"},v2=(t,e)=>{const n=S2(t,e);return n===null?!0:(Ys(`ui.sidebar_session_node.props_changed.${n}`),!1)},j2=c.memo(g2,v2);function k2(t){return t.stopPropagation()}const C2=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(te=>te.setSessionSwitcherOpen),a=Ze(te=>te.setCurrentSession),u=Ze(te=>te.updateSessionTitle),d=Ze(te=>te.shareSession),h=Ze(te=>te.unshareSession),m=Ze(te=>te.deleteSession),p=Ze(te=>te.deleteSessions),g=Ze(te=>te.archiveSession),w=Ze(te=>te.archiveSessions),S=Ze(te=>te.unarchiveSession),{mobileVariant:x,allowReselect:f,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((te,se)=>{wi("navigation.session_select"),Te.getState().closeMainSurfaces();const ve=()=>{!y&&v.length===0||(N(""),C(!1))};if(x&&l(!1),te===Ze.getState().currentSessionId){f&&b?.(te),ve();return}wi("navigation.session_state_set"),a(te,se??null),b?.(te),ve()},[f,y,x,b,v,a,C,N,l]),U=c.useCallback((te,se)=>{I(te),M(se)},[M,I]),L=c.useCallback(async te=>{const se=r.current;if(!se)return;const ve=(te??i.current).trim();ve&&await u(se,ve),I(null),M("")},[M,I,u]),F=c.useCallback(()=>{I(null),M("")},[M,I]),R=c.useCallback(async(te,se)=>{try{return(await gn(te)).ok?(_(se),n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{_(null),n.current=null},2e3),!0):!1}catch{return!1}},[_]),j=c.useCallback(async te=>{const se=await d(te.id);if(!se?.share?.url){_e.error(e("sessions.sidebar.session.share.error"));return}const ve=await R(se.share.url,te.id);_e[ve?"success":"warning"](e("sessions.sidebar.session.share.successTitle"),{description:e(ve?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")})},[R,d,e]),A=c.useCallback((te,se)=>{R(te,se).then(ve=>{ve||_e.error(e("sessions.sidebar.session.share.copyUrlError"))})},[R,e]),B=c.useCallback(te=>{gn(te).then(se=>{if(se.ok){_e.success(e("sessions.sidebar.session.copyId.success"));return}_e.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(e("sessions.sidebar.session.copyId.error")))},[e]),X=c.useCallback(async te=>{await h(te)?_e.success(e("sessions.sidebar.session.unshare.success")):_e.error(e("sessions.sidebar.session.unshare.error"))},[e,h]),H=c.useCallback(async(te,se,ve)=>{const K=se?.archivedBucket===!0||se?.hardDelete===!0,he=ve?.descendantIds??k;await yg(K?"delete":"archive",te,he,{archiveSession:g,archiveSessions:w,deleteSession:m,deleteSessions:p},e)},[g,w,m,p,k,e]),Z=c.useCallback((te,se)=>{const ve=se?.archivedBucket===!0||se?.hardDelete===!0,K=Zd(te.id,k,ve);if(!D||se?.skipConfirm===!0){H(te,se,{descendantIds:K});return}P({session:te,descendantCount:K.length,descendantIds:K,archivedBucket:ve})},[k,H,P,D]),ce=c.useCallback(async()=>{const te=o.current;if(!te)return;const{session:se,archivedBucket:ve,descendantIds:K}=te;P(null),await H(se,{archivedBucket:ve},{descendantIds:K})},[H,P]),Y=c.useCallback(async te=>{await S(te.id)?_e.success(e("sessions.sidebar.session.restore.success")):_e.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 N2(t){const e=et.c(71),{t:n}=Nt(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let u,d,h,m,p,g,w,S,x,f;if(e[0]!==i||e[1]!==n||e[2]!==r){const A=n("sessions.sidebar.session.untitled");m=vs,x=!!r,e[13]!==i?(f=X=>{X||i(null)},e[13]=i,e[14]=f):f=e[14],h=js,w=!1,S="max-w-sm gap-5",d=Ws;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(Is,{children:B}),e[18]=B,e[19]=g):g=e[19],u=Ts,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]=m,e[7]=p,e[8]=g,e[9]=w,e[10]=S,e[11]=x,e[12]=f}else u=e[3],d=e[4],h=e[5],m=e[6],p=e[7],g=e[8],w=e[9],S=e[10],x=e[11],f=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]!==m||e[67]!==R||e[68]!==x||e[69]!==f?(j=s.jsx(m,{open:x,onOpenChange:f,children:R}),e[66]=m,e[67]=R,e[68]=x,e[69]=f,e[70]=j):j=e[70],j}function A2(t){const e=et.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 m=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]!==m?(x=s.jsx(Is,{children:m}),e[10]=m,e[11]=x):x=e[11];let f;e[12]!==g?(f=s.jsx(Ts,{children:g}),e[12]=g,e[13]=f):f=e[13];let b;e[14]!==x||e[15]!==f?(b=s.jsxs(Ws,{children:[x,f]}),e[14]=x,e[15]=f,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 D2(t){const e=et.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(Is,{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 m;e[9]!==h?(m=s.jsx(Ts,{children:h}),e[9]=h,e[10]=m):m=e[10];let p;e[11]!==d||e[12]!==m?(p=s.jsxs(Ws,{children:[d,m]}),e[11]=d,e[12]=m,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 f;e[23]!==o||e[24]!==x?(f=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]=f):f=e[25];let b;e[26]!==f||e[27]!==S?(b=s.jsxs(yn,{children:[S,f]}),e[26]=f,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 P2=new Set;function Lo(t){const e=et.c(142),{node:n,depth:r,groupDirectory:i,projectId:o,archivedBucket:l,secondaryMeta:a,renderContext:u,renderExtras:d,pinnedSessionIds:h,expandedParents:m,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:S,setEditingId:x,editTitle:f,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=ds(E2),ce=ds(R2),Y=Te(T2),te=Te(I2);let se;if(e[0]!==n){se=[];const We=V=>V.children.forEach(fe=>{se.push(fe.session.id),We(fe)});We(n),e[0]=n,e[1]=se}else se=e[1];const ve=se.join(`
|
|
922
|
+
`);let K;e[2]!==ve?(K=ve?ve.split(`
|
|
923
|
+
`):[],e[2]=ve,e[3]=K):K=e[3];const he=K;let be;e[4]!==Z||e[5]!==U||e[6]!==ce?(be=(We,V)=>{if(!We)return null;V&&ds.getState().collapsedFolderIds.has(V)&&ce(V);const fe=Z(We,"New folder",V);return U(We,fe),fe},e[4]=Z,e[5]=U,e[6]=ce,e[7]=be):be=e[7];const ie=be;let T;e[8]!==C||e[9]!==L||e[10]!==_||e[11]!==he||e[12]!==f||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:he,showDeletionDialog:Y,setDeleteSessionConfirm:O,deleteSessionConfirm:_,editingId:S,setEditingId:x,editTitle:f,setEditTitle:b,copiedSessionId:L,setCopiedSessionId:F},e[8]=C,e[9]=L,e[10]=_,e[11]=he,e[12]=f,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 Q=C2(T),le=d?.childRenderExtrasFor,me=n.session.directory??i;let ue;e[26]!==X||e[27]!==o||e[28]!==H||e[29]!==me?(ue={groupDirectory:me,projectId:o,archivedBucket:X,renderContext:H},e[26]=X,e[27]=o,e[28]=H,e[29]=me,e[30]=ue):ue=e[30];const Ce=ue,xe=Q.handleSaveEdit,Re=Q.handleCancelEdit,we=Q.handleSessionSelect,G=Q.handleSessionDoubleClick,Se=Q.handleShareSession,ge=Q.handleCopyShareUrl,Ae=Q.handleCopySessionId,oe=Q.handleUnshareSession,ne=Q.handleDeleteSession,z=Q.handleRestoreSession,$=d?.subtreeContainsEditing??P2,ae=d?.menuOpenSessionId??null,W=d?.nodeStructureKey??"",je=d?.relativeTimeTick;let Ee;if(e[31]!==C||e[32]!==A||e[33]!==Ce||e[34]!==le||e[35]!==L||e[36]!==_||e[37]!==B||e[38]!==f||e[39]!==S||e[40]!==m||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]!==Ce||e[65]!==le||e[66]!==L||e[67]!==_||e[68]!==B||e[69]!==f||e[70]!==S||e[71]!==m||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=V=>s.jsx(Lo,{node:V,pinnedSessionIds:h,expandedParents:m,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:S,setEditingId:x,editTitle:f,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,...Ce,renderExtras:le?.(V)},V.session.id),e[62]=C,e[63]=A,e[64]=Ce,e[65]=le,e[66]=L,e[67]=_,e[68]=B,e[69]=f,e[70]=S,e[71]=m,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],Ee=n.children.map(We),e[31]=C,e[32]=A,e[33]=Ce,e[34]=le,e[35]=L,e[36]=_,e[37]=B,e[38]=f,e[39]=S,e[40]=m,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]=Ee}else Ee=e[61];let Ne;e[92]!==A||e[93]!==X||e[94]!==L||e[95]!==ie||e[96]!==B||e[97]!==f||e[98]!==S||e[99]!==m||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]!==Q.handleCancelEdit||e[112]!==Q.handleCopySessionId||e[113]!==Q.handleCopyShareUrl||e[114]!==Q.handleDeleteSession||e[115]!==Q.handleRestoreSession||e[116]!==Q.handleSaveEdit||e[117]!==Q.handleSessionDoubleClick||e[118]!==Q.handleSessionSelect||e[119]!==Q.handleShareSession||e[120]!==Q.handleUnshareSession||e[121]!==b||e[122]!==x||e[123]!==N||e[124]!==R||e[125]!==$||e[126]!==ae||e[127]!==W||e[128]!==je||e[129]!==Ee||e[130]!==y?(Ne=s.jsx(j2,{expandedParents:m,hasSessionSearchQuery:p,normalizedSessionSearchQuery:g,notifyOnSubtasks:w,editingId:S,setEditingId:x,editTitle:f,setEditTitle:b,handleSaveEdit:xe,handleCancelEdit:Re,toggleParent:y,handleSessionSelect:we,handleSessionDoubleClick:G,handleShareSession:Se,copiedSessionId:L,handleCopyShareUrl:ge,handleCopySessionId:Ae,handleUnshareSession:oe,openSidebarMenuKey:v,setOpenSidebarMenuKey:N,createFolderAndStartRename:ie,handleDeleteSession:ne,handleRestoreSession:z,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:je,children:Ee}),e[92]=A,e[93]=X,e[94]=L,e[95]=ie,e[96]=B,e[97]=f,e[98]=S,e[99]=m,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]=Q.handleCancelEdit,e[112]=Q.handleCopySessionId,e[113]=Q.handleCopyShareUrl,e[114]=Q.handleDeleteSession,e[115]=Q.handleRestoreSession,e[116]=Q.handleSaveEdit,e[117]=Q.handleSessionDoubleClick,e[118]=Q.handleSessionSelect,e[119]=Q.handleShareSession,e[120]=Q.handleUnshareSession,e[121]=b,e[122]=x,e[123]=N,e[124]=R,e[125]=$,e[126]=ae,e[127]=W,e[128]=je,e[129]=Ee,e[130]=y,e[131]=Ne):Ne=e[131];let Be;e[132]!==_||e[133]!==n.session.id||e[134]!==Q.confirmDeleteSession||e[135]!==O||e[136]!==te||e[137]!==Y?(Be=_?.session.id===n.session.id?s.jsx(N2,{value:_,setValue:O,showDeletionDialog:Y,setShowDeletionDialog:te,onConfirm:Q.confirmDeleteSession}):null,e[132]=_,e[133]=n.session.id,e[134]=Q.confirmDeleteSession,e[135]=O,e[136]=te,e[137]=Y,e[138]=Be):Be=e[138];let ze;return e[139]!==Ne||e[140]!==Be?(ze=s.jsxs(s.Fragment,{children:[Ne,Be]}),e[139]=Ne,e[140]=Be,e[141]=ze):ze=e[141],ze}function I2(t){return t.setShowDeletionDialog}function T2(t){return t.showDeletionDialog}function R2(t){return t.toggleFolderCollapse}function E2(t){return t.createFolder}const M2=50,O2=28,Ac=[],F2=t=>{const e=et.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=um(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,B2=(t,e,n)=>t.sessions.some(r=>fm(r,r,e,n,t.directory,t.directory)),_2=(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)},L2=(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)},$2=(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&&B2(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&_2(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&L2(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??St(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 W2(t){const{t:e}=Nt(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,groupSearchDataByGroup:u,visibleSessionCount:d,sessionBatchSize:h,collapsedGroups:m,hideDirectoryControls:p,showMoreGroupSessions:g,resetGroupSessionLimit:w,mobileVariant:S,alwaysShowActions:x,activeProjectId:f,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=ds($e=>$e.toggleFolderCollapse),X=ds($e=>$e.renameFolder),H=ds($e=>$e.deleteFolder),Z=ds($e=>$e.addSessionToFolder),ce=Te($e=>$e.showDeletionDialog),[Y,te]=c.useState(null),se=c.useCallback(($e,Xe)=>{const ut=C.get($e.session.id),dt=C.get(Xe.session.id);if(ut!==void 0||dt!==void 0){if(ut===void 0)return 1;if(dt===void 0)return-1;if(ut!==dt)return ut-dt}return Gd($e.session,Xe.session,N,Od)},[N,C]),ve=l?u.get(n):null,K=l?!1:m.has(r),he=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const $e=St(n.directory??null),Xe=n.branch?.trim();return $e&&Xe?Ho($e,Xe):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),be=zd(he),ie=be?`var(--pr-${be.visualState})`:void 0,T=Pa(),Q=c.useMemo(()=>{const $e=n.folderScopes?.map(Xe=>St(Xe.directory))??[St(n.directory??null)];return[...new Set($e.filter(Xe=>!!Xe))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback($e=>Q.length>0?T.subscribeBootstrap($e):()=>{},[Q.length,T]),c.useCallback(()=>Q.map($e=>`${$e}\0${T.getBootstrapState($e)??""}\0${T.getBootstrapFailure($e)??""}\0${T.getInitializationState($e)??""}\0${T.getInitializationFailure($e)??""}`).join(""),[Q,T]),c.useCallback(()=>"",[]));const le=Q.some($e=>{const Xe=T.getBootstrapState($e);return Xe==="queued"||Xe==="running"}),me=Q.find($e=>T.getBootstrapState($e)==="failed"||T.getInitializationState($e)==="failed")??null,ue=me!==null&&T.getBootstrapState(me)==="failed",Ce=me?ue?T.getBootstrapFailure(me):T.getInitializationFailure(me):void 0,xe=Ce==="os-permission"&&ff(),[Re,we]=c.useState(!1),G=c.useCallback(()=>{me&&T.requestBootstrap({directory:me,priority:K?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[T,me,n.isMain,K]),Se=c.useCallback(async()=>{if(!(!me||!xe||Re)){we(!0);try{(await hf(me)).success&&G()}finally{we(!1)}}},[xe,me,Re,G]),ge=h??(p?10:5),Ae=Math.max(ge,d??ge),oe=l?ve?.groupMatches===!0:!1,ne=l,z=c.useMemo(()=>[...ne?ve?.filteredNodes??[]:n.sessions].sort(se),[se,n.sessions,ve?.filteredNodes,ne]),$=n.folderScopeKey??St(n.directory??null),ae=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:$?[{scopeKey:$,directory:n.directory??null}]:[],[$,n.directory,n.folderScopes]),W=ds(Jn(c.useCallback($e=>ae.map(({scopeKey:Xe})=>$e.foldersMap[Xe]??Ac),[ae]))),je=c.useMemo(()=>ae.flatMap(({scopeKey:$e,directory:Xe},ut)=>(W[ut]??Ac).map(Ge=>({folder:Ge,scopeKey:$e,scopeDirectory:Xe}))),[W,ae]),Ee=ds(Jn(c.useCallback($e=>new Set(W.flatMap(Xe=>Xe.filter(ut=>$e.collapsedFolderIds.has(ut.id)).map(ut=>ut.id))),[W]))),Ne=c.useMemo(()=>{const $e=new Map,Xe=ut=>{ut.forEach(dt=>{$e.set(dt.session.id,dt),dt.children.length>0&&Xe(dt.children)})};return Xe(z),$e},[z]),Be=c.useMemo(()=>je.map(({folder:$e,scopeKey:Xe,scopeDirectory:ut})=>{const dt=Aj($e.sessionIds,Ne).sort(se);return{folder:$e,scopeKey:Xe,scopeDirectory:ut,nodes:dt}}),[je,Ne,se]),ze=c.useMemo(()=>{const $e=Pj(Be.map(({folder:Xe,nodes:ut})=>({id:Xe.id,name:Xe.name,parentId:Xe.parentId,nodeCount:ut.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:l?a:""});return Be.filter(({folder:Xe})=>$e.has(Xe.id))},[Be,n.isArchivedBucket,l,a]),We=O,V=U,fe=_,Me=c.useMemo(()=>new Set(ze.flatMap($e=>$e.folder.sessionIds)),[ze]),Pe=c.useMemo(()=>z.filter($e=>!Me.has($e.session.id)),[z,Me]),ot=c.useMemo(()=>{const $e=new Map(ze.map(Xe=>[Xe.folder.id,Xe]));return Dj(ze.map(Xe=>Xe.folder)).map(Xe=>$e.get(Xe.id)).filter(Xe=>!!Xe)},[ze]),Ke=c.useMemo(()=>{const $e=new Map;return ze.forEach(Xe=>{if(!Xe.folder.parentId)return;const ut=$e.get(Xe.folder.parentId)??[];ut.push(Xe),$e.set(Xe.folder.parentId,ut)}),$e},[ze]),ht=c.useMemo(()=>{const $e=new Map(ze.map(dt=>[dt.folder.id,dt])),Xe=new Map,ut=(dt,Ge)=>{const _t=Xe.get(dt);if(_t!==void 0)return _t;if(Ge.has(dt))return[];Ge.add(dt);const Qt=$e.get(dt),Zt=Qt?[...Qt.nodes]:[];for(const rs of Ke.get(dt)??[])Zt.push(...ut(rs.folder.id,Ge));return Xe.set(dt,Zt),Zt};return ze.forEach(({folder:dt})=>ut(dt.id,new Set)),Xe},[ze,Ke]),ft="project",kt=c.useMemo(()=>{const $e=new Set;return sa(z,We,$e),ze.forEach(({nodes:Xe})=>{sa(Xe,We,$e)}),$e},[z,ze,We]),pe=c.useMemo(()=>{if(!V)return null;const $e=Gr(z,V,ft,!!n.isArchivedBucket);if($e)return $e;for(const{nodes:Xe}of ze){const ut=Gr(Xe,V,ft,!!n.isArchivedBucket);if(ut)return ut}return null},[V,z,ze,n.isArchivedBucket]),Ye=c.useCallback($e=>{const Xe=new WeakMap,ut=dt=>{Xe.set(dt,Bo(dt));for(const Ge of dt.children)ut(Ge)};return $e.forEach(ut),Xe},[]),wt=c.useMemo(()=>Ye(z),[Ye,z]),jt=c.useMemo(()=>{const $e=new WeakMap;return ze.forEach(({nodes:Xe})=>{Xe.forEach(ut=>$e.set(ut,Bo(ut)))}),$e},[ze]),de=c.useCallback($e=>wt.get($e)??jt.get($e)??"",[wt,jt]),Ve=c.useCallback($e=>({subtreeContainsEditing:kt,menuOpenSessionId:pe,nodeStructureKey:de($e)}),[kt,pe,de]),ct=Pe.length,Le=n.isArchivedBucket||l?Pe:Pe.slice(0,Ae),J=ct-Le.length,re=!n.isArchivedBucket&&!l&&ct>ge&&J===0,ke=n.isArchivedBucket===!0&&!l&&Le.length>=M2,Fe=n.isArchivedBucket?"archived":"active",Ue=ke&&Le.some($e=>{if($e.children.length===0)return!1;const Xe=`project:${Fe}:${$e.session.id}`;return fe.has(Xe)}),st=c.useRef(null),[it,rt]=c.useState(null),[qe,at]=c.useState(0),[,Oe]=c.useState(0);c.useEffect(()=>{if(!ke)return;const $e=st.current;if(!$e||!globalThis.ResizeObserver)return;const Xe=new ResizeObserver(()=>Oe(ut=>ut+1));return Xe.observe($e),()=>Xe.disconnect()},[ke]),c.useLayoutEffect(()=>{if(!ke){it!==null&&rt(null),qe!==0&&at(0);return}const $e=st.current;if(!$e)return;let Xe=it;const ut=M?.current??null;if(ut&&ut.contains($e)){if(Xe=ut,Xe!==it){rt(Xe);return}}else if(!Xe||!Xe.contains($e)){let Ge=$e.parentElement;for(;Ge;){const _t=window.getComputedStyle(Ge);if(_t.overflowY==="auto"||_t.overflowY==="scroll"){Xe=Ge;break}Ge=Ge.parentElement}if(Xe!==it){rt(Xe);return}}if(!Xe)return;const dt=$e.getBoundingClientRect().top-Xe.getBoundingClientRect().top+Xe.scrollTop;at(Ge=>Math.abs(Ge-dt)<1?Ge:dt)});const ye=ke&&it!==null,mt=dx({count:Le.length,enabled:ye,getScrollElement:()=>it,initialOffset:()=>it?.scrollTop??0,estimateSize:()=>O2,overscan:Ue?20:8,scrollMargin:qe,getItemKey:$e=>Le[$e]?.session.id??$e}),bt=c.useCallback($e=>{const Xe=[],ut=dt=>{dt.forEach(Ge=>{Xe.push(Ge.session),Ge.children.length>0&&ut(Ge.children)})};return ut($e),Xe},[]),It=c.useMemo(()=>bt(z),[bt,z]),Je=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const $e=new Map,Xe=new Map;for(const{folder:dt}of ze){if(!dt.parentId)continue;const Ge=Xe.get(dt.parentId)??[];Ge.push(dt.id),Xe.set(dt.parentId,Ge)}const ut=(dt,Ge)=>{if(Ge.has(dt))return[];Ge.add(dt);const _t=ze.find(({folder:rs})=>rs.id===dt),Qt=_t?bt(_t.nodes):[],Zt=Xe.get(dt)??[];for(const rs of Zt)Qt.push(...ut(rs,Ge));return Qt};for(const{folder:dt}of ze)$e.set(dt.id,ut(dt.id,new Set));return $e},[ze,bt,n.isArchivedBucket]);if(l&&!oe&&ot.length===0&&Pe.length===0)return null;const lt=!n.isMain&&!!n.branch,vt=n.branch&&Gh(n.branch,n.label)?{label:n.branch}:null,yt=K?s.jsx(lj,{nodes:z,includeUnreadSubtasks:k}):null,Tt=($e,Xe)=>{const{folder:ut,scopeKey:dt,scopeDirectory:Ge,nodes:_t}=$e,Qt=Je.get(ut.id)??[],Zt=R?.folderId===ut.id&&R?.scopeKey===dt,rs=l?!1:Ee.has(ut.id),es=zs=>s.jsx(vj,{folderId:ut.id,children:(ys,Rs)=>s.jsx(dj,{folder:ut,displayName:Xe,sessions:_t,isCollapsed:rs,collapsedActivityState:zs,onToggle:()=>B(ut.id),onRename:is=>{X(dt,ut.id,is)},onDelete:()=>{if(n.isArchivedBucket){xn.requestDelete({sessions:Qt,mode:"session"});return}if(!ce){H(dt,ut.id);return}const is=ze.filter(({folder:Us})=>Us.parentId===ut.id).length,Vs=_t.length;te({scopeKey:dt,folderId:ut.id,folderName:ut.name,subFolderCount:is,sessionCount:Vs})},groupDirectory:Ge??n.directory,projectId:i,mobileVariant:S,alwaysShowActions:x,isRenaming:Zt,renameDraft:Zt?R?.draft:void 0,onRenameDraftChange:j,onRenameSave:()=>{const is=R?.draft.trim()??"";is&&X(dt,ut.id,is),A()},onRenameCancel:A,droppableRef:ys,isDropTarget:Rs,depth:0,onNewSession:()=>{i&&i!==f&&b(i),S&&y(!1),v({selectedProjectId:i,directoryOverride:Ge??n.directory,targetFolderId:ut.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:_t.map(is=>s.jsx(Lo,{node:is,pinnedSessionIds:N,expandedParents:_,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,notifyOnSubtasks:k,editingId:O,editTitle:L,copiedSessionId:F,openSidebarMenuKey:U,mobileVariant:S,alwaysShowActions:x,groupDirectory:Ge??n.directory,projectId:i,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:kt,menuOpenSessionId:pe,nodeStructureKey:de(is),childRenderExtrasFor:Ve},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},is.session.id))})},ut.id);return rs?s.jsx(F2,{nodes:ht.get(ut.id)??_t,includeUnreadSubtasks:k,children:es},ut.id):es(null)},Ct=()=>{const $e=new Map;for(const Ge of ze){const _t=Ge.folder.parentId;if(!_t)continue;const Qt=$e.get(_t);Qt?Qt.push(Ge):$e.set(_t,[Ge])}const Xe=[],ut=new Set,dt=(Ge,_t)=>{if(ut.has(Ge.folder.id))return;ut.add(Ge.folder.id);const Qt=_t?`${_t} / ${Ge.folder.name}`:Ge.folder.name;Xe.push(Tt(Ge,Qt)),!(!l&&Ee.has(Ge.folder.id))&&($e.get(Ge.folder.id)??[]).forEach(rs=>dt(rs,Qt))};return ot.forEach(Ge=>dt(Ge,"")),Xe},Rt=!!(!n.isMain&&n.worktree),Bt=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,Gt=x?Rt?"pr-14":"pr-7":Rt?"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",qt=me?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Ce==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":ue?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),xe?s.jsx(xt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:Re,onClick:()=>{Se()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(xt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:G,children:e("sessions.sidebar.group.empty.retry")})]}):null,Ut=$e=>s.jsx(Lo,{node:$e,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:kt,menuOpenSessionId:pe,nodeStructureKey:de($e),childRenderExtrasFor:Ve},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.session.id),Wt=s.jsxs(jj,{scopeKey:ae[0]?.scopeKey??$,hasFolders:ze.length>0,onSessionDroppedOnFolder:($e,Xe)=>{const ut=ze.find(({folder:Ge})=>Ge.id===Xe);if(!ut)return;const dt=ds.getState();for(const{scopeKey:Ge}of ae)Ge!==ut.scopeKey&&dt.getSessionFolderId(Ge,$e)&&dt.removeSessionFromFolder(Ge,$e);Z(ut.scopeKey,Xe,$e)},children:[Ct(),ke?s.jsx("div",{ref:st,children:ye?s.jsx("div",{style:{height:mt.getTotalSize(),position:"relative"},children:mt.getVirtualItems().map($e=>{const Xe=Le[$e.index];return Xe?s.jsx("div",{"data-index":$e.index,ref:mt.measureElement,className:"[&_[data-session-row]]:my-px",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${$e.start-qe}px)`},children:Ut(Xe)},Xe.session.id):null})}):Le.map(Ut)}):Le.map(Ut),ct===0&&ze.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")]}):qt||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,ct>0&&qt?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:qt}):null,J>0?s.jsx("button",{type:"button",onClick:()=>g(r,Le.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,re?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]}),Ft="pb-2",Kt=s.jsx(D2,{value:Y,setValue:te,onConfirm:()=>{const $e=Y;$e&&(H($e.scopeKey,$e.folderId),te(null))}});return o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Ie("oc-group-body",Ft),children:Wt})}),Kt]}):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:$e=>{($e.key==="Enter"||$e.key===" ")&&($e.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]",Gt),...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)}),Bt,yt]}):!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",!ie&&"text-muted-foreground",x?"hidden":"group-hover/gh:hidden"),style:ie?{color:ie}: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)}),Bt,yt,be?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:ie?{color:ie}:void 0,children:["#",be.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)}),yt]})}),lt&&vt?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:vt.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(Hr,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&It.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:$e=>{$e.stopPropagation(),xn.requestDelete({sessions:It,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:$e=>{$e.stopPropagation(),xn.requestDelete({sessions:It,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:$e=>{$e.stopPropagation(),i&&i!==f&&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",Ft),children:Wt})]}),Kt]})}const vo=c.memo(W2,$2),z2=(t,e,n)=>e?t.filter(r=>r.project.id===n):t,V2=t=>t?"top-content":"empty-state",U2=(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}))},K2=48,H2=32,G2=24,gi=(t,e)=>Da(t.label?.trim()||Fn(t.normalizedPath,e)||t.normalizedPath);function q2(t){const e=et.c(50);Ys("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:Zg},e[1]=d):d=e[1];const h=Vr(On(Fi,u),On(Xg,d));let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m={activationConstraint:{distance:8}},e[2]=m):m=e[2];const p=Vr(On(Fi,m)),g=c.useRef(null),w=c.useRef(0);let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=ie=>{const Q=ie.scrollTop>1?Math.min(H2+ie.scrollTop,K2):0;w.current=Q;const le=ie.closest(".oc-sticky-fade-root");le?.style.setProperty("--scroll-shadow-top-size",`${Q}px`),le?.style.setProperty("--scroll-shadow-top-clear-size",`${Math.min(Math.max(Q-8,0),G2)}px`)},e[3]=S):S=e[3];const x=S;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=ie=>{ie.target.closest("[data-overlay-scrollbar-thumb], [data-sidebar-sticky-header]")||ie.clientY-ie.currentTarget.getBoundingClientRect().top>=w.current||(ie.preventDefault(),ie.stopPropagation())},e[4]=f):f=e[4];const b=f,y=z2(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 ie=g.current,T=ie?.querySelector('[data-sidebar-activity-start="active-now"]');if(!a||!v||!ie||!T){C(!1);return}C(T.getBoundingClientRect().top<ie.getBoundingClientRect().top);const Q=new IntersectionObserver(le=>{const me=le[0];if(!me)return;const ue=me.rootBounds?.top??ie.getBoundingClientRect().top;C(!me.isIntersecting&&me.boundingClientRect.top<ue)},{root:ie,threshold:0});return Q.observe(T),()=>Q.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 ie of r.projectSections)r.stuckProjectHeaders.has(ie.project.id)&&(M=ie.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 ie;e[19]!==i.homeDirectory?(ie=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]=ie):ie=e[20],U=r.projectSections.map(ie),e[16]=r.projectSections,e[17]=i.homeDirectory,e[18]=U}else U=e[18];const L=U;if(r.projectSections.length===0){let ie;return e[21]!==r.emptyState||e[22]!==r.topContent?(ie=s.jsxs(dn,{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]=ie):ie=e[23],ie}if(r.sectionsForRender.length===0){const T=V2(r.topContentHasSearchMatches===!0)==="top-content"?r.topContent:r.searchEmptyState;let Q;return e[24]!==T?(Q=s.jsx(dn,{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]=Q):Q=e[25],Q}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=dn,H=!0,Z=!a,ce=96,Y="flex-1 min-h-0",te="oc-sidebar-scroller oc-sticky-fade-scroller space-y-1.5 pb-1 pl-2.5 pr-2 [overflow-anchor:none]";let se;e[28]!==a?(se=a?ie=>x(ie.currentTarget):void 0,e[28]=a,e[29]=se):se=e[29];const ve=i.showOnlyMainWorkspace?s.jsx("div",{className:"space-y-[0.6rem] py-1",children:(()=>{const ie=y.find(Q=>Q.project.id===r.activeProjectId)??y[0];if(!ie)return i.hasSessionSearchQuery?r.searchEmptyState:r.emptyState;const T=U2(ie);return T.length?T.map(Q=>{const{group:le,groupKey:me,projectId:ue,hideGroupLabel:Ce}=Q;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:me,projectId:ue,hideGroupLabel:Ce,visibleSessionCount:r.state.visibleSessionCountByGroup.get(me),compactBodyPadding:!0,scrollContainerRef:g})},me)}):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:ie=>{if(l||i.projectSortOrder!=="manual")return;const{active:T,over:Q}=ie;if(!Q||T.id===Q.id)return;const le=r.sectionsForRender.findIndex(ue=>ue.project.id===T.id),me=r.sectionsForRender.findIndex(ue=>ue.project.id===Q.id);le===-1||me===-1||le===me||o.reorderProjects(le,me)},children:[s.jsx(Io,{items:y.map(J2),strategy:_i,children:y.map(ie=>{const T=ie.project,Q=T.id,le=gi(T,i.homeDirectory),me=zr(T.normalizedPath,i.homeDirectory),ue=r.singleProjectMode?!1:i.collapsedProjects.has(Q),Ce=r.projectRepoStatus.get(Q);return s.jsx(ej,{id:Q,disabled:r.singleProjectMode||i.projectSortOrder!=="manual",projectLabel:le,projectDescription:me,projectDirectory:T.normalizedPath,projectIcon:T.icon,projectColor:T.color,projectIconImage:T.iconImage,projectIconBackground:T.iconBackground,isCollapsed:ue,isRepo:!!Ce,isDesktopShell:i.isDesktopShellRuntime,hideDirectoryControls:i.hideDirectoryControls,mobileVariant:i.mobileVariant,alwaysShowActions:i.alwaysShowActions,statusIndicator:ue?o.renderProjectStatusIndicator?.(Q,ie.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(Q)},onNewSession:()=>{Q!==r.activeProjectId&&o.setActiveProjectIdOnly(Q),i.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:Q,directoryOverride:T.normalizedPath})},onNewWorktreeSession:()=>{Q!==r.activeProjectId&&o.setActiveProjectIdOnly(Q),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(Q),onRenameStart:()=>o.openProjectEditDialog(Q),onClose:()=>o.removeProject(Q),sentinelRef:xe=>{r.projectHeaderSentinelRefs.current.set(Q,xe)},showCreateButtons:!0,children:ue?null:s.jsx("div",{className:"space-y-0 pt-0.5 pb-0.5",children:(()=>{const xe=ie.groups,Re=xe.find(X2)??null,we=Re?xe.filter(G=>G.id!==Re.id):xe;return s.jsxs(Ur,{sensors:p,collisionDetection:Kr,onDragEnd:G=>{if(l)return;const{active:Se,over:ge}=G;if(!ge||Se.id===ge.id)return;const Ae=we.findIndex($=>$.id===Se.id),oe=we.findIndex($=>$.id===ge.id);if(Ae===-1||oe===-1||Ae===oe)return;const ne=fu(we,Ae,oe).map(Y2),z=Re?[Re.id,...ne]:ne;o.setGroupOrderByProject($=>{const ae=new Map($);return ae.set(Q,z),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:`${Q}:${Re.id}`,projectId:Q,hideGroupLabel:!0,visibleSessionCount:r.state.visibleSessionCountByGroup.get(`${Q}:${Re.id}`),scrollContainerRef:g}):null,s.jsx(Io,{items:we.map(Q2),strategy:_i,children:we.map(G=>{const Se=`${Q}:${G.id}`;return s.jsx(sj,{id:G.id,disabled:l,children:ge=>s.jsx(vo,{...r.groupProps,...o.group,editingId:r.state.editingId,openSidebarMenuKey:r.state.openSidebarMenuKey,setOpenSidebarMenuKey:r.state.setOpenSidebarMenuKey,group:G,groupKey:Se,projectId:Q,visibleSessionCount:r.state.visibleSessionCountByGroup.get(Se),dragHandleProps:ge,scrollContainerRef:g})},G.id)})}),s.jsx(Bi,{dropAnimation:null})]})})()})},Q)})}),s.jsx(Bi,{dropAnimation:null})]});let K;e[30]!==X||e[31]!==r.topContent||e[32]!==Z||e[33]!==se||e[34]!==ve?(K=s.jsxs(X,{ref:g,useScrollShadow:H,hideTopScrollShadow:Z,scrollShadowSize:ce,outerClassName:Y,className:te,onScroll:se,children:[r.topContent,ve]}),e[30]=X,e[31]=r.topContent,e[32]=Z,e[33]=se,e[34]=ve,e[35]=K):K=e[35];let he;e[36]!==a||e[37]!==N||e[38]!==_||e[39]!==O||e[40]!==r.hasSharedSessions||e[41]!==n?(he=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]=he):he=e[42];let be;return e[43]!==R||e[44]!==j||e[45]!==A||e[46]!==B||e[47]!==K||e[48]!==he?(be=s.jsxs("div",{className:F,style:R,onPointerDownCapture:j,onClickCapture:A,onContextMenuCapture:B,children:[K,he]}),e[43]=R,e[44]=j,e[45]=A,e[46]=B,e[47]=K,e[48]=he,e[49]=be):be=e[49],be}function Q2(t){return t.id}function Y2(t){return t.id}function X2(t){return t.isMain}function J2(t){return t.project.id}const Z2=c.memo(q2),aa=new Map,Dc=(t,e)=>{for(const n of t){const r=St(n??null);r&&!aa.has(r)&&aa.set(r,e)}},Pc=t=>{const e=St(t??null);return e?aa.get(e)??0:0},Ir=t=>!!t.time?.archived,ek=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=St(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(m=>{if(h&&Ir(m.session))return[];if(h?m.session.id.toLowerCase()===d:Ao([i(m.session)],u))return[m];const g=o(m.children,u);return g.length===0?[]:[{...m,children:g}]})},[i]),l=c.useCallback((a,u,d,h,m)=>{const p=St(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=St(F.path)??F.path;x.set(R,F)}});const f=F=>{const R=St(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:f(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=St(t.worktreeMetadata.get(F.id)?.path??null)??Ps(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:m&&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=St(F.path)??F.path,j=k.get(R)??[],A=j.length>0,B=j.reduce((X,H)=>{const Z=qh(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=St(F.path)??F.path,A=St(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=Pc(F.path),Z=Pc(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=St(F.path)??F.path,j=n.current.get(R)?.trim()||null,A=F.branch?.trim()||null,X=!!(j&&A&&F.label&&ll(F.label)===ll(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}},tk=t=>{const e=et.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(sk);return}const g=Array.from(o.current.values()).find(nk)?.closest(".oc-sidebar-scroller")??null;if(!g)return;const w=new IntersectionObserver(S=>{d(x=>{const f=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;f.has(v)!==C&&(b=!0,C?f.add(v):f.delete(v))}return b?f: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 m;return e[5]!==l||e[6]!==r||e[7]!==o||e[8]!==i?(m=[l,r,o,i],e[5]=l,e[6]=r,e[7]=o,e[8]=i,e[9]=m):m=e[9],c.useEffect(h,m),u};function sk(t){return t.size===0?t:new Set}function nk(t){return t!==null}const rk=t=>{const e=et.c(51),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:u,canRemoveFromFolder:d,onRestore:h,onDelete:m,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 f;e[3]!==n||e[4]!==g?(f=g("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[3]=n,e[4]=g,e[5]=f):f=e[5];let b;e[6]!==f?(b=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:f}),e[6]=f,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(en,{children:[s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx(Js,{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(Zs,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(Vt,{disabled:!0,className:"text-muted-foreground",children:g("sessions.sidebar.folders.none")}):i.map(j=>s.jsx(Vt,{onClick:()=>l(j.id),children:s.jsx("span",{className:"flex-1 truncate",children:j.name})},j.id)),s.jsx(Os,{}),s.jsxs(Vt,{onClick:a,children:[s.jsx(E,{name:"add",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.newFolderEllipsis")]}),d?s.jsxs(Vt,{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]!==m?(k=s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,className:N,"aria-label":x,children:C})}),e[22]=x,e[23]=m,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},ok=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},ik=t=>{const{t:e}=Nt(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,getFolderScopesForProject:o,addSessionsToFolder:l,removeSessionsFromFolders:a,createFolderAndStartRename:u,archiveSessions:d,unarchiveSessions:h,deleteSessions:m,setBulkDeleteConfirm:p}=t,g=bs(j=>j.enabled),w=bs(j=>j.selectedIds.size),S=w>0,x=bs(j=>j.selectedIds),f=bs(j=>j.scopeKey),b=c.useCallback(()=>{bs.getState().toggleMode()},[]),y=c.useCallback(()=>{bs.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(f)return f;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,f]),C=c.useMemo(()=>ok(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 m(j);A.length>0&&_e.success(A.length===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:A.length}):e("sessions.sidebar.bulkActions.deletedPlural",{count:A.length})),B.length>0&&_e.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&&_e.success(A.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:A.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:A.length})),B.length>0&&_e.error(B.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:B.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:B.length}))}bs.getState().clear()}},[d,v,m,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&&_e.success(A.length===1?e("sessions.sidebar.bulkActions.restoredSingle",{count:A.length}):e("sessions.sidebar.bulkActions.restoredPlural",{count:A.length})),B.length>0&&_e.error(B.length===1?e("sessions.sidebar.bulkActions.failedRestoreSingle",{count:B.length}):e("sessions.sidebar.bulkActions.failedRestorePlural",{count:B.length})),bs.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(),bs.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=bs.getState().scopeKey??Z[0]?.getAttribute("data-session-scope")??null,te=ve=>Y?ve.getAttribute("data-session-scope")===Y:!0,se=Z.filter(te).map(ve=>ve.getAttribute("data-session-row")).filter(ve=>typeof ve=="string"&&ve.length>0);if(se.length===0)return;bs.getState().replaceAll(se,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 ak(t){const e=et.c(36),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=Te(gk),u=Te(pk),d=ds(hk),h=ds(fk),m=ds(mk),p=ds(uk),g=Ze(dk),w=Ze(ck),S=Ze(lk);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 f;e[3]!==m||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?(f={isInlineEditing:r,showDeletionDialog:a,foldersMap:d,getFolderScopesForProject:n,addSessionsToFolder:m,removeSessionsFromFolders:p,createFolderAndStartRename:x,archiveSessions:g,unarchiveSessions:w,deleteSessions:S,setBulkDeleteConfirm:l},e[3]=m,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]=f):f=e[13];const b=ik(f);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(rk,{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(A2,{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 lk(t){return t.deleteSessions}function ck(t){return t.unarchiveSessions}function dk(t){return t.archiveSessions}function uk(t){return t.removeSessionsFromFolders}function mk(t){return t.addSessionsToFolder}function fk(t){return t.createFolder}function hk(t){return t.foldersMap}function pk(t){return t.setShowDeletionDialog}function gk(t){return t.showDeletionDialog}const Ic=7,xk=6e4,bk=()=>{const t=et.c(2),[e,n]=c.useState(0);let r,i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const o=setInterval(()=>{n(wk)},xk);return()=>clearInterval(o)},i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),c.useEffect(r,i),e};function yk(t){const{sections:e,variant:n="section",initialVisibleCount:r=Ic,batchSize:i=Ic}=t,{t:o}=Nt(),{pinnedSessionIds:l}=t,a=cs(y=>y.stickyZoneHeaders),[u,d]=c.useState(new Set),[h,m]=c.useState(new Map),p=n==="flat",g=c.useCallback(y=>{m(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)=>{m(C=>{const k=Math.min(N,v+i),D=new Map(C);return D.set(y,k),D})},[i]),x=bk(),f=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=f(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 wk(t){return t+1}const Sk=t=>{const e=et.c(61),{projects:n,availableWorktreesByProject:r,gitBranches:i,homeDirectory:o,hasSessionSearchQuery:l,normalizedSessionSearchQuery:a,isDesktopShellRuntime:u,sessions:d,childrenMap:h,pinnedSessionIds:m,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=St(L.directory??null);if(!F)continue;let R=null,j=-1;for(const H of n){const Z=St(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=>St(H.path)===F),B=Da(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 f=x;let b;e[6]!==f?(b=L=>f.get(L)??null,e[6]=f,e[7]=b):b=e[7];const y=b;let v;e[8]!==h?(v=L=>iu(h,L),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=wg({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]!==m||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(yk,{sections:O,variant:"section",isDesktopShellRuntime:u,pinnedSessionIds:m,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]=m,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},ym="oc.sessions.expandedParents.v3",vk=Ra(br()),jk=()=>{try{const t=globalThis.localStorage.getItem(ym);if(t===null)return new Set;const e=vk.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},kk=()=>{const[t,e]=c.useState(jk),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=Qh(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(ym,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},Ck=5*6e4,Nk=[],Ak=t=>!t.parentID,Dk=t=>{const e=et.c(294),{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=ds(Ik),m=ds(Tk),p=ds(Rk),g=r.projectView,{getOrderedGroups:w,setGroupOrderByProject:S,toggleGroup:x,toggleProject:f}=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=Sg(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=(Mt,$t,Xt)=>{const ps=Xt===void 0?7:Xt;C(ms=>new Map(ms).set(Mt,$t+ps))},e[10]=k):k=e[10];const D=k;let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P=Mt=>{C($t=>{if(!$t.has(Mt))return $t;const Xt=new Map($t);return Xt.delete(Mt),Xt})},e[11]=P):P=e[11];const I=P,M=cs(Ek),_=cs(Mk),O=cs(Ok),U=cs(Fk);let L;e[12]!==n.isVSCode?(L=!n.isVSCode&&!pf(),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=vg(A),[X,H]=c.useState(null),[Z,ce]=c.useState(""),[Y,te]=c.useState(null),[se,ve]=c.useState(null),[K,he]=c.useState(null),[be,ie]=c.useState(null);let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=(Mt,$t)=>{ie({scopeKey:Mt,folderId:$t.id,draft:$t.name})},e[20]=T):T=e[20];const Q=T;let le;e[21]===Symbol.for("react.memo_cache_sentinel")?(le=Mt=>{ie($t=>$t?{...$t,draft:Mt}:null)},e[21]=le):le=e[21];const me=le;let ue;e[22]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>ie(null),e[22]=ue):ue=e[22];const Ce=ue,{expandedParents:xe,toggleParent:Re}=kk(),we=Ze(Bk);let G;e[23]!==we?(G=(Mt,$t)=>{Mt!==Ze.getState().currentSessionId&&we(Mt,$t)},e[23]=we,e[24]=G):G=e[24];const Se=G,ge=Vd();let Ae;e[25]!==y.pinnedSessionIds||e[26]!==y.sessionOrderRanks||e[27]!==n.gitBranches||e[28]!==n.isVSCode||e[29]!==n.worktreeMetadata||e[30]!==r.homeDirectory?(Ae={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]=Ae):Ae=e[31];const{buildGroupedSessions:oe,filterSessionNodesForSearch:ne,buildGroupSearchText:z}=ek(Ae);let $;e[32]!==y.archivedSessions||e[33]!==y.sessions||e[34]!==n.availableWorktreesByProject||e[35]!==n.isVSCode||e[36]!==n.projects?($=z0(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:je,getArchivedSessionsForProject:Ee}=V0(W);let Ne;e:{if(n.isVSCode){Ne=null;break e}let Mt;e[40]!==y.chatSessions||e[41]!==r.homeDirectory?(Mt=Yh(r.homeDirectory)??y.chatSessions.map(_k).find(Boolean)??null,e[40]=y.chatSessions,e[41]=r.homeDirectory,e[42]=Mt):Mt=e[42];const $t=Mt;if(!$t){Ne=null;break e}let Xt;if(e[43]!==$t||e[44]!==y.chatSessions){const He=[$t,...y.chatSessions.map(Lk).filter(Boolean)];let tt;e[46]!==He?(tt=new Set(He),e[46]=He,e[47]=tt):tt=e[47],Xt=Array.from(tt).filter($k).map(Wk),e[43]=$t,e[44]=y.chatSessions,e[45]=Xt}else Xt=e[45];const ps=Xt;let ms;if(e[48]!==y.chatSessions||e[49]!==y.childrenMap){let He;e[51]!==y.childrenMap?(He=tt=>iu(y.childrenMap,tt),e[51]=y.childrenMap,e[52]=He):He=e[52],ms=y.chatSessions.filter(zk).map(He),e[48]=y.chatSessions,e[49]=y.childrenMap,e[50]=ms}else ms=e[50];let ee;e[53]!==$t||e[54]!==ps||e[55]!==ms?(ee={id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:$t,folderScopeKey:$t,folderScopes:ps,draftTarget:"chat",sessions:ms},e[53]=$t,e[54]=ps,e[55]=ms,e[56]=ee):ee=e[56],Ne=ee}const Be=Ne;let ze;e[57]!==Be?(ze=Be?[Be]:Nk,e[57]=Be,e[58]=ze):ze=e[58];const We=ze;let V;e[59]!==z||e[60]!==oe||e[61]!==ne||e[62]!==h||e[63]!==Ee||e[64]!==je||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?(V={normalizedProjects:n.projects,getSessionsForProject:je,getArchivedSessionsForProject:Ee,availableWorktreesByProject:n.availableWorktreesByProject,projectRepoStatus:n.projectRepoStatus,projectRootBranches:n.projectRootBranches,gitBranches:n.gitBranches,lastRepoStatus:n.lastRepoStatus,buildGroupedSessions:oe,hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,filterSessionNodesForSearch:ne,buildGroupSearchText:z,foldersMap:h,standaloneGroups:We},e[59]=z,e[60]=oe,e[61]=ne,e[62]=h,e[63]=Ee,e[64]=je,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]=V):V=e[74];const{projectSections:fe,groupSearchDataByGroup:Me,sectionsForRender:Pe,flatSectionsForRender:ot,searchMatchCount:Ke}=H0(V),ht=r.onSearchMatchCountChange;let ft,kt;e[75]!==ht||e[76]!==Ke?(ft=()=>{ht(Ke)},kt=[ht,Ke],e[75]=ht,e[76]=Ke,e[77]=ft,e[78]=kt):(ft=e[77],kt=e[78]),c.useEffect(ft,kt);let pe,Ye;e[79]!==ht?(pe=()=>()=>ht(0),Ye=[ht],e[79]=ht,e[80]=pe,e[81]=Ye):(pe=e[80],Ye=e[81]),c.useEffect(pe,Ye);const wt=Pa(),jt=`session-collection-expansion:${c.useId()}`;let de,Ve;e[82]!==wt||e[83]!==jt||e[84]!==fe||e[85]!==g.collapsedGroups||e[86]!==g.collapsedProjects||e[87]!==r.activeProjectId?(de=()=>(wt.setBootstrapDemand(jt,dm({projectSections:fe,activeProjectId:r.activeProjectId,collapsedProjects:g.collapsedProjects,collapsedGroups:g.collapsedGroups,currentDirectory:null,currentSessionDirectory:null})),()=>wt.clearBootstrapDemand(jt)),Ve=[wt,jt,fe,g.collapsedProjects,g.collapsedGroups,r.activeProjectId],e[82]=wt,e[83]=jt,e[84]=fe,e[85]=g.collapsedGroups,e[86]=g.collapsedProjects,e[87]=r.activeProjectId,e[88]=de,e[89]=Ve):(de=e[88],Ve=e[89]),c.useEffect(de,Ve);const ct=r.useGroupedSections?Pe:ot;let Le;e[90]!==ct||e[91]!==r.showInlineArchived?(Le=r.showInlineArchived?ct:ct.map(Kk),e[90]=ct,e[91]=r.showInlineArchived,e[92]=Le):Le=e[92];const J=Le;let re;e[93]!==ot?(re=Mt=>ot.find(Xt=>Xt.project.id===Mt)?.groups.find(Hk)?.folderScopes??[],e[93]=ot,e[94]=re):re=e[94];const ke=re;let Fe;e[95]===Symbol.for("react.memo_cache_sentinel")?(Fe=new Map,e[95]=Fe):Fe=e[95];const Ue=c.useRef(Fe);let st;e[96]!==fe||e[97]!==r.isDesktopShellRuntime||e[98]!==r.stickyZoneHeaders?(st={enabled:r.stickyZoneHeaders,isDesktopShellRuntime:r.isDesktopShellRuntime,projectSections:fe,projectHeaderSentinelRefs:Ue},e[96]=fe,e[97]=r.isDesktopShellRuntime,e[98]=r.stickyZoneHeaders,e[99]=st):st=e[99];const it=tk(st);let rt;e[100]!==p||e[101]!==y.hasAuthoritativeGlobalSessions||e[102]!==m||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:m,addSessionToFolder:p},e[100]=p,e[101]=y.hasAuthoritativeGlobalSessions,e[102]=m,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],E0(rt);const{github:qe}=Sn(),at=An(Gk),Oe=An(qk),ye=qs(Qk),mt=qs(Yk),bt=qs(Xk);let It;e[110]===Symbol.for("react.memo_cache_sentinel")?(It=new Set,e[110]=It):It=e[110];const Je=c.useRef(It);let lt;e[111]!==ye||e[112]!==qe||e[113]!==Oe||e[114]!==at||e[115]!==fe||e[116]!==g.collapsedProjects||e[117]!==bt||e[118]!==mt||e[119]!==n.gitBranches?(lt=()=>{if(!qe||!Oe||!at?.connected)return;const Mt=new Map,$t=Date.now();fe.forEach(Xt=>{g.collapsedProjects.has(Xt.project.id)||Xt.groups.forEach(ps=>{if(ps.isArchivedBucket||ps.isMain)return;const ms=St(ps.directory??null),ee=ps.branch?.trim()||n.gitBranches.get(ms||"")?.trim();if(!ms||!ee)return;const He=Ho(ms,ee),tt=qs.getState().entries[He],q=tt?.status?.pr?.state==="closed"||tt?.status?.pr?.state==="merged",Qe=`${ms}::${ee}`,nt=Math.max(tt?.lastRefreshAt??0,tt?.lastDiscoveryPollAt??0),pt=!!(tt?.isInitialStatusResolved&&(!tt.status?.pr||q)&&(!Je.current.has(Qe)||$t-nt>=Ck));(!tt||!tt.isInitialStatusResolved||pt)&&(pt&&Je.current.add(Qe),Mt.set(He,{directory:ms,branch:ee}))})}),Mt.forEach((Xt,ps)=>{ye(ps),mt(ps,{...Xt,remoteName:null,canShow:!0,github:qe,githubAuthChecked:Oe,githubConnected:at.connected})}),Mt.size&&bt([...Mt.values()],{silent:!0,markInitialResolved:!0})},e[111]=ye,e[112]=qe,e[113]=Oe,e[114]=at,e[115]=fe,e[116]=g.collapsedProjects,e[117]=bt,e[118]=mt,e[119]=n.gitBranches,e[120]=lt):lt=e[120];const vt=at?.connected;let yt;e[121]!==ye||e[122]!==qe||e[123]!==Oe||e[124]!==fe||e[125]!==g.collapsedProjects||e[126]!==bt||e[127]!==mt||e[128]!==vt||e[129]!==n.gitBranches?(yt=[ye,qe,Oe,vt,fe,g.collapsedProjects,bt,mt,n.gitBranches],e[121]=ye,e[122]=qe,e[123]=Oe,e[124]=fe,e[125]=g.collapsedProjects,e[126]=bt,e[127]=mt,e[128]=vt,e[129]=n.gitBranches,e[130]=yt):yt=e[130],c.useEffect(lt,yt);let Tt;e[131]!==y.orderedSessions?(Tt=new Map(y.orderedSessions.map(Jk)),e[131]=y.orderedSessions,e[132]=Tt):Tt=e[132];const Ct=Tt;let Rt;if(e[133]!==w||e[134]!==J){let Mt;e[136]!==w?(Mt=$t=>{const Xt=w($t.project.id,$t.groups);return Xt===$t.groups?$t:{...$t,groups:Xt}},e[136]=w,e[137]=Mt):Mt=e[137],Rt=J.map(Mt),e[133]=w,e[134]=J,e[135]=Rt}else Rt=e[135];const Bt=Rt;let Gt;e[138]!==fe||e[139]!==O||e[140]!==R||e[141]!==r.activeProjectId?(Gt=null,R&&(fe.some(Mt=>Mt.project.id===O)?Gt=O:fe.some(Mt=>Mt.project.id===r.activeProjectId)?Gt=r.activeProjectId:Gt=fe[0]?.project.id??null),e[138]=fe,e[139]=O,e[140]=R,e[141]=r.activeProjectId,e[142]=Gt):Gt=e[142];const qt=R&&!r.useGroupedSections?20:void 0;let Ut;e[143]!==i.startSessionWorktreeMenuLoad||e[144]!==o||e[145]!==y.pinnedSessionIds||e[146]!==K||e[147]!==se||e[148]!==Z||e[149]!==X||e[150]!==xe||e[151]!==be||e[152]!==Me||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]!==Ct||e[162]!==qt||e[163]!==Re||e[164]!==r.activeProjectId||e[165]!==r.hasSessionSearchQuery||e[166]!==r.hideDirectoryControls||e[167]!==r.mobileVariant||e[168]!==r.normalizedSessionSearchQuery?(Ut={hasSessionSearchQuery:r.hasSessionSearchQuery,normalizedSessionSearchQuery:r.normalizedSessionSearchQuery,groupSearchDataByGroup:Me,collapsedGroups:g.collapsedGroups,hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:o,activeProjectId:r.activeProjectId,notifyOnSubtasks:l,pinnedSessionIds:y.pinnedSessionIds,sessionOrderIndex:Ct,expandedParents:xe,editingId:X,editTitle:Z,copiedSessionId:K,sessionBatchSize:qt,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:se,setDeleteSessionConfirm:ve,startFolderRename:Q,setCopiedSessionId:he,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,folderRename:be,setFolderRenameDraft:me,clearFolderRename:Ce},e[143]=i.startSessionWorktreeMenuLoad,e[144]=o,e[145]=y.pinnedSessionIds,e[146]=K,e[147]=se,e[148]=Z,e[149]=X,e[150]=xe,e[151]=be,e[152]=Me,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]=Ct,e[162]=qt,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]=Ut):Ut=e[169];const Wt=Ut;let Ft;e[170]!==d.openNewSessionDraft||e[171]!==d.setActiveProjectIdOnly||e[172]!==d.setSessionSwitcherOpen||e[173]!==x?(Ft={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]=Ft):Ft=e[174];const Kt=Ft;let $e;e[175]!==Be||e[176]!==Kt||e[177]!==Wt||e[178]!==Y||e[179]!==N?($e=()=>Be?s.jsx(vo,{...Wt,...Kt,group:Be,groupKey:"managed-chats",projectId:null,hideGroupLabel:!0,visibleSessionCount:N.get("managed-chats"),scrollContainerRef:void 0,openSidebarMenuKey:Y,setOpenSidebarMenuKey:te}):null,e[175]=Be,e[176]=Kt,e[177]=Wt,e[178]=Y,e[179]=N,e[180]=$e):$e=e[180];const Xe=$e;let ut;e[181]!==d||e[182]!==r.mobileVariant?(ut=()=>{Te.getState().closeMainSurfaces(),r.mobileVariant&&d.setSessionSwitcherOpen(!1),d.openNewSessionDraft({selectedProjectId:Xh,directoryOverride:null})},e[181]=d,e[182]=r.mobileVariant,e[183]=ut):ut=e[183];const dt=ut;let Ge;e[184]!==i.startSessionWorktreeMenuLoad||e[185]!==o||e[186]!==y.chatSessions||e[187]!==y.childrenMap||e[188]!==y.pinnedSessionIds||e[189]!==K||e[190]!==se||e[191]!==Z||e[192]!==X||e[193]!==xe||e[194]!==dt||e[195]!==l||e[196]!==Y||e[197]!==B||e[198]!==Xe||e[199]!==u.allowReselect||e[200]!==u.isSessionSearchOpen||e[201]!==u.onSessionSelected||e[202]!==u.sessionSearchQuery||e[203]!==u.setIsSessionSearchOpen||e[204]!==u.setSessionSearchQuery||e[205]!==M||e[206]!==R||e[207]!==Re||e[208]!==n.availableWorktreesByProject||e[209]!==n.gitBranches||e[210]!==n.isVSCode||e[211]!==n.projects||e[212]!==r.hasSessionSearchQuery||e[213]!==r.homeDirectory||e[214]!==r.isDesktopShellRuntime||e[215]!==r.mobileVariant||e[216]!==r.normalizedSessionSearchQuery?(Ge=n.isVSCode?null:s.jsx(Sk,{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:xe,notifyOnSubtasks:l,editingId:X,editTitle:Z,copiedSessionId:K,openSidebarMenuKey:Y,mobileVariant:r.mobileVariant,alwaysShowActions:o,setEditingId:H,setEditTitle:ce,toggleParent:Re,setOpenSidebarMenuKey:te,allowReselect:u.allowReselect,onSessionSelected:u.onSessionSelected,isSessionSearchOpen:u.isSessionSearchOpen,sessionSearchQuery:u.sessionSearchQuery,setSessionSearchQuery:u.setSessionSearchQuery,setIsSessionSearchOpen:u.setIsSessionSearchOpen,deleteSessionConfirm:se,setDeleteSessionConfirm:ve,startFolderRename:Q,setCopiedSessionId:he,startSessionWorktreeMenuLoad:i.startSessionWorktreeMenuLoad,chatSessions:y.chatSessions,renderChatsSection:Xe,onNewChat:dt,showRecentSection:M&&!R}),e[184]=i.startSessionWorktreeMenuLoad,e[185]=o,e[186]=y.chatSessions,e[187]=y.childrenMap,e[188]=y.pinnedSessionIds,e[189]=K,e[190]=se,e[191]=Z,e[192]=X,e[193]=xe,e[194]=dt,e[195]=l,e[196]=Y,e[197]=B,e[198]=Xe,e[199]=u.allowReselect,e[200]=u.isSessionSearchOpen,e[201]=u.onSessionSelected,e[202]=u.sessionSearchQuery,e[203]=u.setIsSessionSearchOpen,e[204]=u.setSessionSearchQuery,e[205]=M,e[206]=R,e[207]=Re,e[208]=n.availableWorktreesByProject,e[209]=n.gitBranches,e[210]=n.isVSCode,e[211]=n.projects,e[212]=r.hasSessionSearchQuery,e[213]=r.homeDirectory,e[214]=r.isDesktopShellRuntime,e[215]=r.mobileVariant,e[216]=r.normalizedSessionSearchQuery,e[217]=Ge):Ge=e[217];const _t=Ge;let Qt;e[218]!==Me||e[219]!==We||e[220]!==r.hasSessionSearchQuery?(Qt=r.hasSessionSearchQuery&&We.some(Mt=>Me.get(Mt)?.hasMatch===!0),e[218]=Me,e[219]=We,e[220]=r.hasSessionSearchQuery,e[221]=Qt):Qt=e[221];const Zt=Qt,rs=!!_t;let es;e[222]!==X||e[223]!==Y||e[224]!==N?(es={editingId:X,openSidebarMenuKey:Y,setOpenSidebarMenuKey:te,visibleSessionCountByGroup:N},e[222]=X,e[223]=Y,e[224]=N,e[225]=es):es=e[225];let zs;e[226]!==Wt||e[227]!==Bt||e[228]!==fe||e[229]!==_t||e[230]!==Gt||e[231]!==R||e[232]!==it||e[233]!==rs||e[234]!==es||e[235]!==Zt||e[236]!==n.projectRepoStatus||e[237]!==r.activeProjectId||e[238]!==r.emptyState||e[239]!==r.searchEmptyState?(zs={topContent:_t,topContentHasSearchMatches:Zt,hasSharedSessions:rs,sectionsForRender:Bt,projectSections:fe,activeProjectId:r.activeProjectId,singleProjectMode:R,singleProjectId:Gt,emptyState:r.emptyState,searchEmptyState:r.searchEmptyState,projectRepoStatus:n.projectRepoStatus,stuckProjectHeaders:it,projectHeaderSentinelRefs:Ue,state:es,groupProps:Wt},e[226]=Wt,e[227]=Bt,e[228]=fe,e[229]=_t,e[230]=Gt,e[231]=R,e[232]=it,e[233]=rs,e[234]=es,e[235]=Zt,e[236]=n.projectRepoStatus,e[237]=r.activeProjectId,e[238]=r.emptyState,e[239]=r.searchEmptyState,e[240]=zs):zs=e[240];const ys=zs;let Rs;e[241]!==o||e[242]!==g.collapsedProjects||e[243]!==r.hasSessionSearchQuery||e[244]!==r.hideDirectoryControls||e[245]!==r.homeDirectory||e[246]!==r.isDesktopShellRuntime||e[247]!==r.mobileVariant||e[248]!==r.normalizedSessionSearchQuery||e[249]!==r.projectSortOrder||e[250]!==r.showOnlyMainWorkspace||e[251]!==r.stickyZoneHeaders?(Rs={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[241]=o,e[242]=g.collapsedProjects,e[243]=r.hasSessionSearchQuery,e[244]=r.hideDirectoryControls,e[245]=r.homeDirectory,e[246]=r.isDesktopShellRuntime,e[247]=r.mobileVariant,e[248]=r.normalizedSessionSearchQuery,e[249]=r.projectSortOrder,e[250]=r.showOnlyMainWorkspace,e[251]=r.stickyZoneHeaders,e[252]=Rs):Rs=e[252];const is=Rs;let Vs;e[253]!==Kt||e[254]!==d.openNewSessionDraft||e[255]!==d.openNewWorktreeDialog||e[256]!==d.openProjectEditDialog||e[257]!==d.openWorktreesPage||e[258]!==d.removeProject||e[259]!==d.renderProjectStatusIndicator||e[260]!==d.reorderProjects||e[261]!==d.setActiveProjectIdOnly||e[262]!==d.setSessionSwitcherOpen||e[263]!==S||e[264]!==U||e[265]!==f?(Vs={group:Kt,toggleProject:f,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[253]=Kt,e[254]=d.openNewSessionDraft,e[255]=d.openNewWorktreeDialog,e[256]=d.openProjectEditDialog,e[257]=d.openWorktreesPage,e[258]=d.removeProject,e[259]=d.renderProjectStatusIndicator,e[260]=d.reorderProjects,e[261]=d.setActiveProjectIdOnly,e[262]=d.setSessionSwitcherOpen,e[263]=S,e[264]=U,e[265]=f,e[266]=Vs):Vs=e[266];const Us=Vs;let As;e[267]===Symbol.for("react.memo_cache_sentinel")?(As=s.jsx(P0,{}),e[267]=As):As=e[267];let hs;e[268]!==i.initialActiveSessionByProject||e[269]!==i.openNewSessionDraft||e[270]!==i.persistActiveSessionByProject||e[271]!==i.setSessionSwitcherOpen||e[272]!==ae.bySessionId||e[273]!==fe||e[274]!==Se||e[275]!==r.activeProjectId||e[276]!==r.mobileVariant?(hs=s.jsx(B0,{projectSections:fe,activeProjectId:r.activeProjectId,initialActiveSessionByProject:i.initialActiveSessionByProject,persistActiveSessionByProject:i.persistActiveSessionByProject,mobileVariant:r.mobileVariant,openNewSessionDraft:i.openNewSessionDraft,setSessionSwitcherOpen:i.setSessionSwitcherOpen,sessionOwnerBySessionId:ae.bySessionId,handleSessionSelect:Se}),e[268]=i.initialActiveSessionByProject,e[269]=i.openNewSessionDraft,e[270]=i.persistActiveSessionByProject,e[271]=i.setSessionSwitcherOpen,e[272]=ae.bySessionId,e[273]=fe,e[274]=Se,e[275]=r.activeProjectId,e[276]=r.mobileVariant,e[277]=hs):hs=e[277];let Ds;e[278]!==y.orderedSessions||e[279]!==ge||e[280]!==B?(Ds=s.jsx(J0,{sortedSessions:y.orderedSessions,recentSessions:B,prefetchSession:ge}),e[278]=y.orderedSessions,e[279]=ge,e[280]=B,e[281]=Ds):Ds=e[281];let Ks;e[282]!==Us||e[283]!==ys||e[284]!==is?(Ks=s.jsx(Z2,{model:ys,view:is,actions:Us}),e[282]=Us,e[283]=ys,e[284]=is,e[285]=Ks):Ks=e[285];const Hs=X!==null;let ks;e[286]!==ke||e[287]!==Hs?(ks=s.jsx(ak,{getFolderScopesForProject:ke,isInlineEditing:Hs,startFolderRename:Q}),e[286]=ke,e[287]=Hs,e[288]=ks):ks=e[288];let tn;return e[289]!==hs||e[290]!==Ds||e[291]!==Ks||e[292]!==ks?(tn=s.jsxs(s.Fragment,{children:[As,hs,Ds,Ks,ks]}),e[289]=hs,e[290]=Ds,e[291]=Ks,e[292]=ks,e[293]=tn):tn=e[293],tn},Pk=t=>{const e=et.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(Dk,{...t}):null,e[0]=t,e[1]=n):n=e[1],n};function Ik(t){return t.foldersMap}function Tk(t){return t.createFolder}function Rk(t){return t.addSessionToFolder}function Ek(t){return t.showRecentSection}function Mk(t){return t.projectDisplayMode}function Ok(t){return t.singleProjectId}function Fk(t){return t.setSingleProjectId}function Bk(t){return t.setCurrentSession}function _k(t){return Hd(t.directory)}function Lk(t){return St(t.directory??null)}function $k(t){return!!t}function Wk(t){return{scopeKey:t,directory:t}}function zk(t){return!t.time?.archived&&Ak(t)}function Vk(t){return t.isArchivedBucket}function Uk(t){return!t.isArchivedBucket}function Kk(t){return t.groups.some(Vk)?{...t,groups:t.groups.filter(Uk)}:t}function Hk(t){return!t.isArchivedBucket}function Gk(t){return t.status}function qk(t){return t.hasChecked}function Qk(t){return t.ensureEntry}function Yk(t){return t.setParams}function Xk(t){return t.refreshTargets}function Jk(t,e){return[t.id,e]}const wm=(t,e,n)=>{const r=new Set;for(const i of t){const o=St(i.path);o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=St(o.path);l&&r.add(l)}return r},Tc="oc.sessions.activeSessionByProject",Zk=[],e4=wu(br(),br().min(1).catch("")),t4=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{wi("react.session_sidebar_render"),Ys("ui.session_sidebar.render"),Ys(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Ys(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=Nt(),[a,u]=c.useState(!1),[d,h]=c.useState(""),[m,p]=c.useState(0),g=c.useRef(null),w=c.useRef(null),[S,x]=c.useState(null),f=c.useMemo(()=>No(),[]),[b,y]=c.useState(new Map),v=Te(ye=>ye.isNewWorktreeDialogOpen),N=Te(ye=>ye.setNewWorktreeDialogOpen),[C,k]=c.useState(!1),D=c.useMemo(()=>{try{const ye=f.getItem(Tc);if(!ye)return new Map;const mt=e4.safeParse(JSON.parse(ye));if(!mt.success)return new Map;const bt=new Map;return Object.entries(mt.data).forEach(([It,Je])=>{Je&&bt.set(It,Je)}),bt}catch{return new Map}},[f]),P=c.useCallback(ye=>{try{f.setItem(Tc,JSON.stringify(Object.fromEntries(ye.entries())))}catch{}},[f]),[I,M]=c.useState(new Map),_=ss(ye=>ye.homeDirectory),O=Ht(ye=>ye.projects),U=Ht(ye=>ye.activeProjectId),L=Ht(ye=>ye.removeProject),F=Ht(ye=>ye.setActiveProjectIdOnly),R=Ht(ye=>ye.updateProjectMeta),j=Ht(ye=>ye.reorderProjects),A=Te(ye=>ye.setSettingsDialogOpen),B=Te(ye=>ye.toggleHelpDialog),X=Te(ye=>ye.setAboutDialogOpen),H=Te(ye=>ye.setSessionSwitcherOpen),Z=Te(ye=>ye.setScheduledTasksDialogOpen),ce=Te(ye=>ye.setArchivePageOpen),Y=Te(ye=>ye.setWorktreesPageProjectId),te=Te(ye=>ye.openMultiRunLauncher),se=Te(ye=>ye.notifyOnSubtasks),ve=c.useMemo(()=>d.trim().toLowerCase(),[d]),K=ve.length>0;Xv({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:w,sessionSearchContainerRef:g});const he=Md(t),be=c.useMemo(()=>Pn(),[]),ie=Ze(ye=>ye.setCurrentSession),T=Ze(ye=>ye.worktreeMetadata),Q=Ze(ye=>ye.availableWorktreesByProject),le=Ze(ye=>ye.openNewSessionDraft),me=c.useMemo(()=>wm(O,Q,{includeWorktrees:!be}),[Q,be,O]),ue=c.useCallback(ye=>{Te.getState().closeMainSurfaces(),le(ye),be&&window.dispatchEvent(new CustomEvent("aiworker:navigate",{detail:{view:"chat"}}))},[be,le]),Ce=Fr(Jn(ye=>({checkForUpdates:ye.checkForUpdates,available:ye.available,runtimeType:ye.runtimeType,info:ye.info,downloading:ye.downloading,downloaded:ye.downloaded,progress:ye.progress,error:ye.error,downloadUpdate:ye.downloadUpdate,restartToUpdate:ye.restartToUpdate}))),xe=fs(),Re=c.useMemo(()=>`${xe}|${O.map(ye=>`${ye.id}:${St(ye.path)??""}`).join("|")}`,[O,xe]),[we,G]=c.useState(be?Re:null),[Se,ge]=c.useReducer(ye=>ye+1,0),Ae=!be&&we!==Re,[oe,ne]=c.useState(new Set),z=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let ye=!1;return(async()=>{const bt=xe,It=Ht.getState().projects;if(It.length===0||be){ye||(z.current={runtimeKey:null,revision:0,worktreesByProject:new Map},ne(new Set),G(Re));return}const Je=Ze.getState().availableWorktreesByProject,lt=za({rawWorktreesByProjectRef:z,publishedWorktreesByProject:Je,runtimeKey:bt}),vt=lt.revision,yt=new Map(lt.worktreesByProject),Tt=new Set,Ct=3;let Rt=0;const Bt=Array.from({length:Ct},async()=>{for(;;){const Ut=Rt;if(Rt+=1,Ut>=It.length)return;const Wt=It[Ut],Ft=St(Wt.path);if(Ft)try{const Kt=await Di(async()=>Dn.getState().directories.get(Ft)?.isGitRepo??await Ko(Ft)?ul({id:Wt.id,path:Ft}):null);if(Kt===null){yt.delete(Ft);continue}if(ye)return;Kt.length===0?yt.delete(Ft):yt.set(Ft,Kt)}catch{Tt.add(Ft)}}});if(await Promise.all(Bt),ye||fs()!==bt)return;const Gt=new Set(It.map(Ut=>St(Ut.path)).filter(Boolean));for(const Ut of yt.keys())Gt.has(Ut)||yt.delete(Ut);u2({rawWorktreesByProjectRef:z,runtimeKey:bt,capturedRevision:vt,nextRawWorktreesByProject:yt,publishedWorktreesByProject:Je,partitionWorktreesByRegisteredProject:dl,projects:It,worktreeMapsEqual:cl,recordWorktreesSeen:Dc,publishTopology:Ut=>{Ze.setState(Ut)},requestRediscovery:()=>{ge()},now:()=>Date.now()})&&(ne(Tt),G(Re))})(),()=>{ye=!0}},[be,Re,xe,Se]);const $=c.useMemo(()=>bn(),[]),{isTablet:ae}=_n(),W=e||ae,je=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]),Ee=c.useMemo(()=>O.find(ye=>ye.id===S)??null,[O,S]),Ne=c.useCallback(ye=>{S&&R(S,{label:ye.label,icon:ye.icon,color:ye.color,iconBackground:ye.iconBackground,defaultModel:ye.defaultModel??null,defaultVariant:ye.defaultVariant??null})},[S,R]),Be=c.useCallback(()=>{N(!0)},[N]),ze=c.useCallback(()=>{const ye=Fr.getState();if(ye.available&&ye.info){k(!0);return}Ce.checkForUpdates().then(()=>{const{available:mt,error:bt}=Fr.getState();if(bt){_e.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:bt});return}if(!mt){_e.success(l("sessions.sidebar.updateCheck.latestVersion"));return}k(!0)})},[l,Ce]),We=c.useCallback(()=>{e&&H(!1),A(!0)},[e,H,A]),V=Ce.available&&(Ce.runtimeType==="desktop"||Ce.runtimeType==="web"),fe=c.useCallback(()=>{xn.requestDirectoryDialog()},[]),Me=c.useMemo(()=>O.flatMap(ye=>{const mt=St(ye.path);return mt?[{id:ye.id,path:ye.path,label:ye.label,normalizedPath:mt,icon:ye.icon??void 0,color:ye.color??void 0,iconImage:ye.iconImage??void 0,iconBackground:ye.iconBackground??void 0,addedAt:ye.addedAt,lastOpenedAt:ye.lastOpenedAt,sidebarCollapsed:ye.sidebarCollapsed}]:[]}),[O]),Pe=c.useMemo(()=>Me.map(ye=>ye.normalizedPath),[Me]),ot=Jh(t?Pe:Zk);o0({enabled:t,normalizedProjects:Me,gitRepoStatus:ot,setProjectRepoStatus:y,setProjectRootBranches:M});const Ke=Ze(ye=>ye.isLoading),ht=c.useRef(!1);U&&b.has(U)&&(ht.current=!!b.get(U));const ft=cs(ye=>ye.showArchivedSessions),kt=cs(ye=>ye.projectSortOrder),pe=cs(ye=>ye.stickyZoneHeaders),Ye=Ht(ye=>ye.manualProjectOrder),wt={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:ae,projects:O,activeProjectId:U,manualProjectOrder:Ye,worktreeMetadata:T,availableWorktreesByProject:Q,gitBranches:he,gitRepoStatus:ot,updateStore:Ce,showArchivedSessions:ft,projectSortOrder:kt,projectRepoStatus:b,projectRootBranches:I,resolvedWorktreeTopologyKey:we,unresolvedWorktreeProjectPaths:oe,isSessionSearchOpen:a,sessionSearchQuery:d,editingProjectDialogId:S,updateDialogOpen:C},jt=c.useRef(null),de=jt.current;if(de){let ye=!1;for(const mt of Object.keys(wt))Object.is(de[mt],wt[mt])||(Ys(`ui.session_sidebar.source.${mt}`),ye=!0);ye||Ys("ui.session_sidebar.source.parent_or_context")}jt.current=wt;const Ve=c.useMemo(()=>jg(Me,kt,Ye),[Me,kt,Ye]),ct=t0({isVSCode:be,projects:Ve}),Le=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]),J=be&&ft,ke=cs(ye=>ye.sessionGroupingMode)==="by-worktree"&&!be,st=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",it="h-4.5 w-4.5",rt=c.useCallback(()=>{e&&H(!1),te()},[e,te,H]),qe=c.useMemo(()=>({projects:O,getCurrentProjects:()=>Ht.getState().projects,rawWorktreesByProjectRef:z,getPublishedWorktreesByProject:()=>Ze.getState().availableWorktreesByProject,resolveProject:ye=>vi(ye),listProjectWorktrees:ul,partitionWorktreesByRegisteredProject:dl,worktreeMapsEqual:cl,recordWorktreesSeen:Dc,publishTopology:ye=>{Ze.setState(ye)},getRuntimeKey:fs,now:()=>Date.now()}),[O]),at=c.useCallback(ye=>{const mt=ye.projectId?O.find(bt=>bt.id===ye.projectId)??null:ye.sourceDirectory?vi(ye.sourceDirectory):null;return d2(ye,{...qe,projectRootBranch:mt?I.get(mt.id)??null:null})},[I,O,qe]);c.useEffect(()=>{if(!be)return Yr(ye=>{if(ye.type==="session-created"){ge();return}if(ye.type==="worktree-changed")for(const mt of Zh(ye.directories)){const bt=St(mt.path);xm(mt,null,qe).then(()=>{bt&&ne(It=>{if(!It.has(bt))return It;const Je=new Set(It);return Je.delete(bt),Je})}).catch(()=>{bt&&ne(It=>new Set(It).add(bt))})}})},[be,qe]);const Oe=c.useCallback(()=>{Te.getState().closeMainSurfaces(),e&&H(!1),le()},[e,le,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&&!be?s.jsx(N0,{onNewSession:Oe}):null,s.jsx(m0,{hideDirectoryControls:i,showProjectDisplayControls:!be,showRecentControls:!be,handleOpenDirectoryDialog:fe,onOpenScheduled:()=>{e&&H(!1),Z(!0)},onOpenMultiRun:rt,canOpenMultiRun:O.length>0,onOpenArchive:()=>{e&&H(!1),ce(!0)},headerActionIconClass:it,headerActionButtonClass:st,isSessionSearchOpen:a,setIsSessionSearchOpen:u,sessionSearchInputRef:w,sessionSearchQuery:d,setSessionSearchQuery:h,hasSessionSearchQuery:K,searchMatchCount:m,collapseAllProjects:ct.actions.collapseAllProjects,expandAllProjects:ct.actions.expandAllProjects}),s.jsx(Pk,{topology:{projects:Ve,availableWorktreesByProject:Q,knownDirectories:me,isVSCode:be,worktreeMetadata:T,gitBranches:he,projectRepoStatus:b,projectRootBranches:I,lastRepoStatus:ht.current},view:{isVisible:t,hasSessionSearchQuery:K,normalizedSessionSearchQuery:ve,activeProjectId:U,showInlineArchived:J,useGroupedSections:ke,homeDirectory:_,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:$,stickyZoneHeaders:pe,projectSortOrder:kt,emptyState:je,searchEmptyState:Le,isSessionsLoading:Ke,isWorktreeTopologyLoading:Ae,unresolvedWorktreeProjectPaths:oe,projectView:ct.state,onSearchMatchCountChange:p},actions:{rowActions:{allowReselect:r,onSessionSelected:n,isSessionSearchOpen:a,sessionSearchQuery:d,setSessionSearchQuery:h,setIsSessionSearchOpen:u},alwaysShowActions:W,notifyOnSubtasks:se,setActiveProjectIdOnly:F,setSessionSwitcherOpen:H,openNewSessionDraft:ue,openNewWorktreeDialog:Be,openWorktreesPage:ye=>{e&&H(!1),Y(ye)},openProjectEditDialog:x,removeProject:L,reorderProjects:j,startSessionWorktreeMenuLoad:at,initialActiveSessionByProject:D,persistActiveSessionByProject:P,projectViewActions:ct.actions}}),s.jsx(A0,{onOpenSettings:We,onOpenShortcuts:B,onOpenAbout:()=>X(!0),onOpenUpdate:ze,showRuntimeButtons:!be,showUpdateButton:V}),s.jsx(eu,{open:C,onOpenChange:k,info:Ce.info,downloading:Ce.downloading,downloaded:Ce.downloaded,progress:Ce.progress,error:Ce.error,onDownload:Ce.downloadUpdate,onRestart:Ce.restartToUpdate,runtimeType:Ce.runtimeType}),s.jsx(d0,{open:!!Ee,onOpenChange:ye=>{ye||x(null)},project:Ee,onSave:Ne}),s.jsx(kg,{open:v,onOpenChange:N,onWorktreeCreated:(ye,mt)=>{if(Te.getState().closeMainSurfaces(),e&&H(!1),mt?.sessionId){ie(mt.sessionId,ye);return}le({directoryOverride:ye,preserveDirectoryOverride:!0})}})]})})},s4=c.memo(t4),jn=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,mn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},n4=()=>{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),[m,p]=c.useState(!1),[g,w]=c.useState(!1),[S,x]=c.useState(!1),[f,b]=c.useState(new Set),y=Ze(G=>G.getWorktreeMetadata),v=Ze(G=>G.newSessionDraft),N=Ze(G=>G.setNewSessionDraftTarget),C=Ze(G=>G.setDraftBootstrapPendingDirectory),k=ep,D=Ze(G=>G.deleteSessions),P=Ze(G=>G.archiveSessions),I=Te(G=>G.showDeletionDialog),M=Te(G=>G.setShowDeletionDialog),_=ss(G=>G.currentDirectory),O=ss(G=>G.homeDirectory),U=ss(G=>G.isHomeReady),L=Ht(G=>G.projects),F=Ht(G=>G.activeProjectId),{isMobile:R,isTablet:j,hasTouchInput:A}=_n(),B=R||j||A,X=c.useMemo(()=>{const Se=(F?L.find(ge=>ge.id===F)??null:null)?.path??_;return mn(Se)},[F,_,L]),H=c.useCallback(G=>{const ge=mn(G.projectDirectory)||X;return{id:(L.find(oe=>mn(oe.path)===ge)??null)?.id??`path:${ge}`,path:ge}},[X,L]),Z=S&&f.size>0,ce=c.useMemo(()=>{const G=o?.worktree;return G&&typeof G.branch=="string"&&G.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:Se})=>typeof Se.branch=="string"&&Se.branch.trim().length>0)},[o?.worktree,a]),Y=o?.mode==="worktree",te=Y,se=g||!Y||!ce,ve=g||!Y;c.useEffect(()=>{r||!U||L.length>0||(i(!0),n(!0))},[r,U,L.length]);const K=c.useCallback(G=>{l({sessions:G.sessions,dateLabel:G.dateLabel,mode:G.mode??"session",worktree:G.worktree??null})},[]),he=c.useCallback(()=>{l(null),u([]),h(!1),p(!1),w(!1),x(!1),b(new Set)},[]),be=c.useCallback(async G=>{if(G.sessions.length===0)return;if(G.sessions.length===1){const oe=G.sessions[0];await k(oe.id)?_e.success(t("sessions.sidebar.session.delete.success")):_e.error(t("sessions.sidebar.session.delete.error"));return}const Se=G.sessions.map(oe=>oe.id),{deletedIds:ge,failedIds:Ae}=await D(Se);if(ge.length>0){const oe=Ae.length>0?Ae.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Ae.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Ae.length}):G.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:G.dateLabel}):void 0;_e.success(ge.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ge.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ge.length}),{description:jn(oe)})}Ae.length>0&&_e.error(Ae.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Ae.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Ae.length}),{description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[k,D,t]);c.useEffect(()=>xn.onDeleteRequest(G=>{if(!I&&(G.mode??"session")==="session"){be(G);return}K(G)}),[K,I,be]),c.useEffect(()=>xn.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){u([]),h(!1),p(!1),x(!1),b(new Set);return}const G=o.sessions.map(Ae=>{const oe=y(Ae.id);return oe?{session:Ae,metadata:oe}:null}).filter(Ae=>!!Ae);u(G),h(!1),x(!1),b(new Set);const Se=new Map;if(o.worktree?.path&&Se.set(mn(o.worktree.path),o.worktree),G.forEach(({metadata:Ae})=>{Ae.path&&Se.set(mn(Ae.path),Ae)}),Se.size===0){x(!0);return}let ge=!1;return(async()=>{const Ae=new Map,oe=new Set;await Promise.all(Array.from(Se.entries()).map(async([ne,z])=>{try{const $=await tp(z.path);Ae.set(ne,$),$?.isDirty&&oe.add(ne)}catch{z.status&&(Ae.set(ne,z.status),z.status.isDirty&&oe.add(ne))}})).catch(ne=>{console.warn("Failed to inspect worktree status before deletion:",ne)}),!ge&&(b(oe),x(!0),l(ne=>{if(!ne?.worktree?.path)return ne;const z=mn(ne.worktree.path),$=Ae.get(z);if(!$)return ne;const ae=ne.worktree.status;return ae?.isDirty===$.isDirty&&ae?.ahead===$.ahead&&ae?.behind===$.behind&&ae?.upstream===$.upstream?ne:{...ne,worktree:{...ne.worktree,status:$}}}),u(ne=>ne.map(z=>{const $=mn(z.metadata.path),ae=Ae.get($);return ae?{session:z.session,metadata:{...z.metadata,status:ae}}:z})))})(),()=>{ge=!0}},[o,y]),c.useEffect(()=>{ce||h(!1)},[ce]);const ie=c.useCallback(async(G,Se,ge)=>{const Ae=d&&ce,oe=H(G),ne=mn(G.path),z=mn(oe.path);try{await wd(oe,G,{deleteRemoteBranch:Ae,deleteLocalBranch:Se});const $=mn(v?.directoryOverride);return v?.open&&ne&&$===ne&&z&&(C(null),N({projectId:oe.id,directoryOverride:z},{force:!0})),mn(_)===ne&&z&&ss.getState().setDirectory(z,{showOverlay:!1}),!0}catch($){return _e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:ti(G)}),{id:ge,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((G,Se,ge)=>{const Ae=d&&ce,oe=_e.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:ti(G)}));(async()=>{try{if(Se.length>0){const{failedIds:$}=await P(Se);if($.length>0){_e.error($.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:$.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:$.length}),{id:oe,description:jn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await ie(G,ge,oe))return;const z=t(Ae?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");_e.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:ti(G)}),{id:oe,description:jn(z)})}catch(ne){_e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:oe,description:jn(ne instanceof Error?ne.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[P,ce,d,ie,t]),Q=c.useCallback(async()=>{if(o){w(!0);try{const G=te,Se=G&&d,ge=G&&m;if(Y&&o.worktree){T(o.worktree,o.sessions.map(Ae=>Ae.id),ge),he();return}if(o.sessions.length===1){const Ae=o.sessions[0];if(!await k(Ae.id)){_e.error(t("sessions.sidebar.session.delete.error")),w(!1);return}const ne=!Y&&G?t(Se?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;_e.success(t("sessions.sidebar.session.delete.success"),{description:jn(ne),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const Ae=o.sessions.map($=>$.id);let oe=[],ne=[];const z=await D(Ae);if(oe=z.deletedIds,ne=z.failedIds,oe.length>0){const $=!Y&&G?t(Se?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,W=[ne.length>0?ne.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ne.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ne.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,$].filter(Boolean).join(" ");_e.success(oe.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:oe.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:oe.length}),{description:jn(W||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(ne.length>0&&(_e.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"))}),oe.length===0)){w(!1);return}}he()}finally{w(!1)}}},[o,d,m,k,D,he,te,Y,T,t]),le=o?.worktree??a[0]?.metadata??null,me=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(G=>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:G.title||t("sessions.sidebar.session.untitled")})]},G.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,Ce=Y?ce?s.jsxs("button",{type:"button",onClick:()=>{se||h(G=>!G)},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:[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,xe=Y?s.jsxs("button",{type:"button",onClick:()=>{ve||p(G=>!G)},disabled:ve,className:Ie("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ve?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[m?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:[xe,Ce]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xt,{variant:"ghost",onClick:he,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(xt,{variant:"destructive",onClick:Q,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:he,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(xt,{variant:"destructive",onClick:Q,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")})]})]}),we=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||he()},title:we,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Re}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[me&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:me}),ue]})}):s.jsx(vs,{open:!!o,onOpenChange:G=>{if(!G){if(g)return;he()}},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(Ws,{children:[s.jsxs(Is,{className:Ie(Y&&"flex items-center gap-2"),children:[Y&&s.jsx(E,{name:"delete-bin",className:"h-5 w-5"}),we]}),me&&s.jsx(Ts,{children:me})]}),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(Cg,{open:e,onOpenChange:n})]})};function r4(t){const e=et.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(Is,{children:d}),e[4]=d,e[5]=h):h=e[5];const m=r?.dirtyFileCount??0;let p;e[6]!==n||e[7]!==m?(p=n("sessions.sidebar.session.moveToWorktree.confirm.changedFiles",{count:m}),e[6]=n,e[7]=m,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(Ts,{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(Ws,{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 f;e[19]!==x?(f=s.jsx("p",{children:x}),e[19]=x,e[20]=f):f=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]!==f||e[33]!==y||e[34]!==v||e[35]!==C?(k=s.jsxs("div",{className:"space-y-2 typography-ui-label text-muted-foreground",children:[f,y,v,C]}),e[32]=f,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 Sm(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return Su.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function o4(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=Su.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 i4=[{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"}],a4={"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=>a4[t]??t,vm=[0,1,2,3,4,5,6],Rc="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"],Ec=()=>{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},Mc=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},l4=(t,e,n)=>{const r=jo(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},Oc=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),c4=(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 m=h-l+1;if(m<=0){const p=u+m;d.push({date:new Date(n,r-1,p),inCurrentMonth:!1});continue}if(m>a){d.push({date:new Date(n,r+1,m-a),inCurrentMonth:!1});continue}d.push({date:new Date(n,r,m),inCurrentMonth:!0})}return d},d4=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"},Fc=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}),u4=(t,e)=>wr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),Bc=(t,e)=>wr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),m4=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}},h4=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return vm.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},p4=(t,e)=>[...t.slice(e),...t.slice(0,e)],Ms=t=>{const e=et.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},_c=t=>{const e=et.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=d4(n),e[0]=n,e[1]=h):h=e[1];const m=h,p=gt.useRef(null),g=gt.useRef(null),[w,S]=gt.useState(null),[x,f]=gt.useState(null),b=gt.useRef(null),y=gt.useRef(null);let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=G=>{b.current=G,S(G)},e[2]=v):v=e[2];const N=v;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=G=>{y.current=G,f(G)},e[3]=C):C=e[3];const k=C,D=v4,P=j4,I=k4;let M;e[4]!==r||e[5]!==m.meridiem||e[6]!==m.minute||e[7]!==i?(M=G=>{const Se=G.replace(/\D/g,"").slice(0,2);N(Se),Se.length===2&&(r(i?I(D(Se),m.minute):zn(Fc(Se),m.minute,m.meridiem)),N(null),g.current?.focus())},e[4]=r,e[5]=m.meridiem,e[6]=m.minute,e[7]=i,e[8]=M):M=e[8];const _=M;let O;e[9]!==r||e[10]!==m.meridiem||e[11]!==m.minute||e[12]!==i?(O=()=>{const G=b.current;if(G!==null&&(N(null),G.length!==0)){if(i){r(I(D(G.padStart(2,"0")),m.minute));return}r(zn(Fc(G.padStart(2,"0")),m.minute,m.meridiem))}},e[9]=r,e[10]=m.meridiem,e[11]=m.minute,e[12]=i,e[13]=O):O=e[13];const U=O;let L;e[14]!==r||e[15]!==m.hour12||e[16]!==m.hour24||e[17]!==m.meridiem||e[18]!==i?(L=G=>{const Se=G.replace(/\D/g,"").slice(0,2);k(Se),Se.length===2&&(r(i?I(m.hour24,uo(Se)):zn(m.hour12,uo(Se),m.meridiem)),k(null))},e[14]=r,e[15]=m.hour12,e[16]=m.hour24,e[17]=m.meridiem,e[18]=i,e[19]=L):L=e[19];const F=L;let R;e[20]!==r||e[21]!==m.hour12||e[22]!==m.hour24||e[23]!==m.meridiem||e[24]!==i?(R=()=>{const G=y.current;G!==null&&(k(null),G.length!==0&&r(i?I(m.hour24,uo(G.padStart(2,"0"))):zn(m.hour12,uo(G.padStart(2,"0")),m.meridiem)))},e[20]=r,e[21]=m.hour12,e[22]=m.hour24,e[23]=m.meridiem,e[24]=i,e[25]=R):R=e[25];const j=R;let A;e[26]!==r||e[27]!==m.hour12||e[28]!==m.hour24||e[29]!==m.meridiem||e[30]!==m.minute||e[31]!==i?(A=G=>r(i?I(P(m.hour24,G),m.minute):zn(u4(m.hour12,G),m.minute,m.meridiem)),e[26]=r,e[27]=m.hour12,e[28]=m.hour24,e[29]=m.meridiem,e[30]=m.minute,e[31]=i,e[32]=A):A=e[32];const B=A;let X;e[33]!==r||e[34]!==m.hour12||e[35]!==m.hour24||e[36]!==m.meridiem||e[37]!==m.minute||e[38]!==i?(X=G=>r(i?I(m.hour24,Bc(m.minute,G)):zn(m.hour12,Bc(m.minute,G),m.meridiem)),e[33]=r,e[34]=m.hour12,e[35]=m.hour24,e[36]=m.meridiem,e[37]=m.minute,e[38]=i,e[39]=X):X=e[39];const H=X;let Z;e[40]!==r||e[41]!==m.hour12||e[42]!==m.meridiem||e[43]!==m.minute?(Z=G=>{G!==m.meridiem&&r(zn(m.hour12,m.minute,G))},e[40]=r,e[41]=m.hour12,e[42]=m.meridiem,e[43]=m.minute,e[44]=Z):Z=e[44];const ce=Z;let Y;e[45]!==U||e[46]!==B?(Y=G=>{if(G.key==="ArrowRight"){G.preventDefault(),U(),g.current?.focus();return}(G.key==="ArrowUp"||G.key==="ArrowDown")&&(G.preventDefault(),N(null),B(G.key==="ArrowUp"?1:-1))},e[45]=U,e[46]=B,e[47]=Y):Y=e[47];const te=Y;let se;e[48]!==j||e[49]!==H?(se=G=>{if(G.key==="ArrowLeft"&&(G.currentTarget.selectionStart??0)===0){G.preventDefault(),j(),p.current?.focus();return}(G.key==="ArrowUp"||G.key==="ArrowDown")&&(G.preventDefault(),k(null),H(G.key==="ArrowUp"?1:-1))},e[48]=j,e[49]=H,e[50]=se):se=e[50];const ve=se,K=i?"px-2":"pl-2 pr-1";let he;e[51]!==K?(he=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]=he):he=e[52];const be=w??(i?m.hour24:m.hour12);let ie;e[53]!==_?(ie=G=>_(G.target.value),e[53]=_,e[54]=ie):ie=e[54];let T;e[55]===Symbol.for("react.memo_cache_sentinel")?(T=()=>N(""),e[55]=T):T=e[55];let Q;e[56]!==U||e[57]!==o||e[58]!==te||e[59]!==be||e[60]!==ie?(Q=s.jsx("input",{ref:p,inputMode:"numeric",value:be,onChange:ie,onKeyDown:te,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]=te,e[59]=be,e[60]=ie,e[61]=Q):Q=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 me=x??m.minute;let ue;e[63]!==F?(ue=G=>F(G.target.value),e[63]=F,e[64]=ue):ue=e[64];let Ce;e[65]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>k(""),e[65]=Ce):Ce=e[65];let xe;e[66]!==j||e[67]!==l||e[68]!==ve||e[69]!==me||e[70]!==ue?(xe=s.jsx("input",{ref:g,inputMode:"numeric",value:me,onChange:ue,onKeyDown:ve,onFocus:Ce,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]=ve,e[69]=me,e[70]=ue,e[71]=xe):xe=e[71];let Re;e[72]!==u||e[73]!==m.meridiem||e[74]!==a||e[75]!==d||e[76]!==ce||e[77]!==i?(Re=i?null:s.jsxs(Fs,{value:m.meridiem,onValueChange:G=>ce(G),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(Ns,{})}),s.jsxs(_s,{children:[s.jsx(ns,{value:"AM",children:u}),s.jsx(ns,{value:"PM",children:d})]})]}),e[72]=u,e[73]=m.meridiem,e[74]=a,e[75]=d,e[76]=ce,e[77]=i,e[78]=Re):Re=e[78];let we;return e[79]!==he||e[80]!==Q||e[81]!==xe||e[82]!==Re?(we=s.jsxs("div",{className:he,children:[Q,le,xe,Re]}),e[79]=he,e[80]=Q,e[81]=xe,e[82]=Re,e[83]=we):we=e[83],we},Lc=t=>new Date(t.getFullYear(),t.getMonth(),1),g4=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},$c=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),x4=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"]},Wc=(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:x4(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:Ec(),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:Ec(),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}}},b4=(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(!Sm(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")},y4=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))},w4=t=>{const e=et.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?Sm(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=o4(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=j):j=e[5],d=j}const h=d;let m;e[6]!==n.schedule.timezone||e[7]!==i?(m=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]=m):m=e[8];const p=m;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 f;e[17]!==l||e[18]!==S||e[19]!==x?(f=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]=f):f=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]!==f||e[27]!==b?(y=s.jsxs("div",{className:"flex flex-col gap-1",children:[w,f,b]}),e[25]=w,e[26]=f,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=i4.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(Ns,{})}),e[51]=O):O=e[51];let U;e[52]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(_s,{children:la.map(C4)}),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 S4(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=Nt(),a=Yt(V=>V.loadProviders),u=Yt(V=>V.loadAgents),d=Yt(V=>V.providers),h=Yt(V=>V.currentProviderId),m=Yt(V=>V.currentModelId),p=Yt(V=>V.currentVariant||""),g=Yt(V=>V.currentAgentName||""),w=Te(V=>V.timeFormatPreference),S=Te(V=>V.weekStartPreference),x=Te(V=>V.isMobile),[f,b]=gt.useState(()=>Wc(n,{providerID:h,modelID:m,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 V=jo(n?.schedule?.date||"")||new Date;return new Date(V.getFullYear(),V.getMonth(),1)}),X=gt.useRef(null),H=gt.useRef(null),Z=gt.useRef(null),ce=gt.useRef(null),Y=gt.useRef(null),te=gt.useMemo(()=>f4(l),[l]),se=gt.useMemo(()=>m4(l),[l]),ve=gt.useMemo(()=>w==="24h"?!0:w==="12h"?!1:te,[w,te]),K=gt.useMemo(()=>S==="sunday"?0:S==="monday"?1:se,[S,se]),he=gt.useMemo(()=>{const V=h4(l);return p4(vm.map(fe=>({value:fe,label:V[fe]||""})),K)},[l,K]);gt.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),u({source:"scheduledTaskEditor"}))},[e,a,u]),gt.useEffect(()=>{if(!e)return;b(Wc(n,{providerID:h,modelID:m,variant:p,agent:g}));const V=jo(n?.schedule?.date||"")||new Date;B(new Date(V.getFullYear(),V.getMonth(),1)),C(!1),_(!1),D(!1),U(""),I("")},[e,n,h,m,p,g]),gt.useEffect(()=>{if(!N)return;const V=fe=>{X.current&&!X.current.contains(fe.target)&&C(!1)};return document.addEventListener("mousedown",V),()=>{document.removeEventListener("mousedown",V)}},[N]);const be=gt.useMemo(()=>{const fe=d.find(Me=>Me.id===f.execution.providerID)?.models?.find(Me=>Me.id===f.execution.modelID);return fe?.variants?Object.keys(fe.variants):[]},[d,f.execution.providerID,f.execution.modelID]),ie=be.length>0,T=gt.useMemo(()=>!ie||!f.execution.variant?"__default":be.includes(f.execution.variant)?f.execution.variant:"__default",[f.execution.variant,ie,be]);gt.useEffect(()=>{ie||!f.execution.variant||b(V=>({...V,execution:{...V.execution,variant:""}}))},[ie,f.execution.variant]);const Q=gt.useCallback((V,fe)=>{b(Me=>{const Pe=new Set(Me.schedule.weekdays);return fe?Pe.add(V):Pe.delete(V),{...Me,schedule:{...Me.schedule,weekdays:Array.from(Pe).sort((ot,Ke)=>ot-Ke)}}})},[]),le=gt.useCallback((V,fe)=>{b(Me=>{const Pe=Me.schedule.times.slice();return Pe[V]=fe,{...Me,schedule:{...Me.schedule,times:Pe}}})},[]),me=gt.useCallback(V=>{b(fe=>{const Me=fe.schedule.times.filter((Pe,ot)=>ot!==V);return{...fe,schedule:{...fe.schedule,times:Me.length>0?Me:["09:00"]}}})},[]),ue=gt.useCallback(()=>{b(V=>({...V,schedule:{...V.schedule,times:[...V.schedule.times,"12:00"]}}))},[]),Ce=gt.useMemo(()=>g4(),[]),xe=gt.useMemo(()=>Lc(Ce),[Ce]),Re=gt.useMemo(()=>{const V=jo(f.schedule.onceDate);return V?$c(V,Ce)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(V):null},[f.schedule.onceDate,l,o,Ce]),we=gt.useMemo(()=>Lc(A).getTime()<=xe.getTime(),[A,xe]),G=gt.useMemo(()=>he.map(V=>V.label),[he]),Se=gt.useCallback(V=>{b(fe=>({...fe,schedule:{...fe.schedule,onceDate:V}}))},[]),ge=gt.useCallback((V,fe)=>{if(V.startsWith("/")){const Ke=V.indexOf(" "),ht=V.indexOf(`
|
|
924
|
+
`),ft=Math.min(Ke===-1?V.length:Ke,ht===-1?V.length:ht);if(fe<=ft&&Ke===-1){U(V.substring(1,ft)),_(!0),D(!1),F(!1);return}}_(!1);const Me=V.substring(0,fe),Pe=Me.lastIndexOf("#");if(Pe!==-1){const Ke=Pe>0?Me[Pe-1]:null,ht=Me.substring(Pe+1);if((!Ke||/\s/.test(Ke))&&!ht.includes(" ")&&!ht.includes(`
|
|
925
|
+
`)){j(ht),F(!0),D(!1);return}}F(!1);const ot=Me.lastIndexOf("@");if(ot!==-1){const Ke=ot>0?Me[ot-1]:null,ht=Me.substring(ot+1);(!Ke||/\s/.test(Ke))&&!ht.includes(" ")&&!ht.includes(`
|
|
926
|
+
`)?(I(ht),D(!0)):D(!1);return}D(!1)},[]),Ae=gt.useCallback(V=>{b(fe=>({...fe,execution:{...fe.execution,prompt:V}}))},[]),oe=gt.useCallback(V=>{const fe=f.execution.prompt,Pe=H.current?.selectionStart??fe.length,Ke=fe.substring(0,Pe).lastIndexOf("@"),ht=V.relativePath&&V.relativePath.trim().length>0?V.relativePath.trim():V.path||V.name,ft=Ke!==-1?Ke:Pe,kt=`${fe.substring(0,ft)}@${ht} ${fe.substring(Pe)}`,pe=ft+ht.length+2;Ae(kt),D(!1),I(""),requestAnimationFrame(()=>{const Ye=H.current;Ye&&(Ye.selectionStart=pe,Ye.selectionEnd=pe,Ye.focus()),ge(kt,pe)})},[f.execution.prompt,Ae,ge]),ne=gt.useCallback(V=>{const fe=f.execution.prompt,Pe=H.current?.selectionStart??fe.length,Ke=fe.substring(0,Pe).lastIndexOf("@"),ht=Ke!==-1?Ke:Pe,ft=`${fe.substring(0,ht)}@${V} ${fe.substring(Pe)}`,kt=ht+V.length+2;Ae(ft),D(!1),I(""),requestAnimationFrame(()=>{const pe=H.current;pe&&(pe.selectionStart=kt,pe.selectionEnd=kt,pe.focus()),ge(ft,kt)})},[f.execution.prompt,Ae,ge]),z=gt.useCallback(V=>{const fe=`/${V.name} `;Ae(fe),_(!1),U(""),F(!1),requestAnimationFrame(()=>{const Me=H.current;Me&&(Me.focus(),Me.selectionStart=Me.value.length,Me.selectionEnd=Me.value.length),ge(fe,fe.length)})},[Ae,ge]),$=gt.useCallback((V,fe)=>{const Me=f.execution.prompt,ot=H.current?.selectionStart??Me.length,ht=Me.substring(0,ot).lastIndexOf("#"),ft=ht!==-1?ht:ot,kt=`${Me.substring(0,ft)}#${fe} ${Me.substring(ot)}`,pe=ft+fe.length+2;Ae(kt),F(!1),j(""),requestAnimationFrame(()=>{const Ye=H.current;Ye&&(Ye.selectionStart=pe,Ye.selectionEnd=pe,Ye.focus()),ge(kt,pe)})},[f.execution.prompt,Ae,ge]),ae=gt.useCallback(V=>{if(M&&ce.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")){V.preventDefault(),ce.current.handleKeyDown(V.key);return}k&&Z.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),Z.current.handleKeyDown(V.key)),L&&Y.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),Y.current.handleKeyDown(V.key))},[M,k,L]),W=gt.useCallback(async()=>{const V=b4(f,o);if(V){_e.error(V);return}const fe={...f.id?{id:f.id}:{},name:f.name.trim(),enabled:f.enabled,schedule:{kind:f.schedule.kind,timezone:f.schedule.timezone.trim(),...f.schedule.kind==="cron"?{cron:f.schedule.cronExpression.trim()}:f.schedule.kind==="once"?{date:f.schedule.onceDate,time:f.schedule.onceTime}:{times:y4(f.schedule.times),...f.schedule.kind==="weekly"?{weekdays:f.schedule.weekdays}:{}}},execution:{prompt:f.execution.prompt,providerID:f.execution.providerID,modelID:f.execution.modelID,...f.execution.variant.trim()?{variant:f.execution.variant.trim()}:{},...f.execution.agent.trim()?{agent:f.execution.agent.trim()}:{},...f.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...f.execution.goalEnabled?{goalEnabled:!0}:{},...f.execution.goalEnabled&&f.execution.goalTokenBudget?{goalTokenBudget:f.execution.goalTokenBudget}:{}},...f.state?{state:f.state}:{}};v(!0);try{await i(fe),r(!1)}catch(Me){_e.error(Me instanceof Error?Me.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{v(!1)}},[f,r,i,o]),je=gt.useId(),Ee=gt.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),Ne=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),Be=o("sessions.scheduledTasks.editor.description"),ze=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:f.name,onChange:V=>b(fe=>({...fe,name:V.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:f.schedule.kind,onValueChange:V=>{b(fe=>({...fe,schedule:{...fe.schedule,kind:V,...V==="cron"&&!fe.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{children:V=>o(V==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":V==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":V==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(_s,{children:[s.jsx(ns,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(ns,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(ns,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(ns,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),f.schedule.kind==="cron"?s.jsx(w4,{draft:f,setDraft:b,locale:l,t:o}):f.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(V=>!V),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:l4(f.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(V=>Oc(V,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:we,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(V=>Oc(V,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:G.map((V,fe)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:V},`${V}-${fe}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:c4(A,K).map(({date:V,inCurrentMonth:fe})=>{const Me=Mc(V),Pe=Me===f.schedule.onceDate,ot=$c(V,Ce),Ke=V.getTime()<Ce.getTime(),ht=Pe?"bg-interactive-selection text-interactive-selection-foreground":Ke?"text-muted-foreground/40":fe?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{Ke||(Se(Me),C(!1))},disabled:Ke,className:["h-8 rounded-md typography-ui-label",ht,ot&&!Pe?"ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50":"",Ke?"cursor-not-allowed opacity-45":""].join(" "),children:V.getDate()},Me)})}),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:()=>{Se(Mc(Ce)),B(new Date(Ce.getFullYear(),Ce.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(_c,{value:f.schedule.onceTime,use24Hour:ve,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:V=>b(fe=>({...fe,schedule:{...fe.schedule,onceTime:V}}))}),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:f.schedule.timezone,onValueChange:V=>{b(fe=>({...fe,schedule:{...fe.schedule,timezone:V}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{})}),s.jsx(_s,{children:la.map(V=>s.jsx(ns,{value:V,children:V},V))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[f.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:he.map(V=>{const fe=f.schedule.weekdays.includes(V.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",fe?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(ur,{checked:fe,onChange:Me=>Q(V.value,Me),ariaLabel:V.label}),s.jsx("button",{type:"button",onClick:()=>Q(V.value,!fe),className:"group-hover:text-foreground",children:V.label})]},V.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:f.schedule.times.map((V,fe)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(_c,{value:V,use24Hour:ve,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:Me=>le(fe,Me)}),f.schedule.times.length>1?s.jsx(xt,{type:"button",size:"icon",variant:"ghost",onClick:()=>me(fe),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(E,{name:"close",className:"h-4 w-4"})}):null]},fe))}),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:f.schedule.timezone,onValueChange:V=>{b(fe=>({...fe,schedule:{...fe.schedule,timezone:V}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{})}),s.jsx(_s,{children:la.map(V=>s.jsx(ns,{value:V,children:V},V))})]})]})]}),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(sp,{providerId:f.execution.providerID,modelId:f.execution.modelID,onChange:(V,fe)=>{b(Me=>({...Me,execution:{...Me.execution,providerID:V,modelID:fe,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:!ie,onValueChange:V=>{b(fe=>({...fe,execution:{...fe.execution,variant:V==="__default"?"":V}}))},children:[s.jsx(Bs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ns,{children:V=>V==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):V})}),s.jsxs(_s,{children:[s.jsx(ns,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),be.map(V=>s.jsx(ns,{value:V,children:V},V))]})]})]})]}),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(np,{agentName:f.execution.agent,filter:V=>$d(V.mode),onChange:V=>b(fe=>({...fe,execution:{...fe.execution,agent:V}}))})]}),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:f.execution.prompt,onChange:V=>{const fe=V.target.value;Ae(fe);const Me=V.target.selectionStart??fe.length;ge(fe,Me)},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:z,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:oe,onAgentSelect:ne,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]})]}),f.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:f.execution.goalTokenBudget!==null,onChange:V=>b(fe=>({...fe,execution:{...fe.execution,goalTokenBudget:V?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),f.execution.goalTokenBudget!==null?s.jsx(rp,{value:f.execution.goalTokenBudget,onValueChange:V=>{typeof V=="number"&&Number.isFinite(V)&&V>0&&b(fe=>({...fe,execution:{...fe.execution,goalTokenBudget:Math.floor(V)}}))},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:f.enabled,onChange:V=>b(fe=>({...fe,enabled:V})),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(Rc),onClick:()=>b(V=>({...V,execution:{...V.execution,permissionAutoAccept:!V.execution.permissionAutoAccept}})),"aria-pressed":f.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:f.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(Rc,f.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>b(V=>({...V,execution:{...V.execution,goalEnabled:!V.execution.goalEnabled}})),"aria-pressed":f.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:f.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:Ne,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:V=>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:Ne}),V]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:Be})]}),footer:We,children:ze}):s.jsx(vs,{open:e,onOpenChange:V=>{!V&&Ee()||r(V)},children:s.jsxs(js,{"aria-describedby":je,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Ts,{id:je,className:"sr-only",children:Be}),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(Is,{className:"typography-ui-label font-medium text-foreground",children:Ne}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:Be})]})}),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:ze})}),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 v4(t){return wr(t,{min:0,max:23})}function j4(t,e){return wr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function k4(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 C4(t){return s.jsx(ns,{value:t,children:t},t)}const N4=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))},A4=(t,e)=>{const n=N4(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||""})},D4=(t,e)=>!t||!Number.isFinite(t)?"":op(t,e),zc=(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 m=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:m}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:m})}if(r<l){const m=Math.floor(r/o),p=Math.round(r%o/i),g=p>0?`${m}h ${p}m`:`${m}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})},P4={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"}},I4=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function T4(){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=ss(j=>j.homeDirectory),{currentTheme:u}=Zn(),[d,h]=gt.useState(""),[m,p]=gt.useState([]),[g,w]=gt.useState(!0),[S,x]=gt.useState(!1),[f,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?ja[j.icon]:null,X=j.color?ka[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(Ca,{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 Ug(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){_e.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 Cl(d,j),await k(d),_e.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 Kg(d,j.id,A):await Cl(d,{...j,enabled:A}),await k(d,{silent:!0})}catch(B){_e.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 Hg(d,j.id):await Gg(d,j.id),await k(d,{silent:!0}),_e.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(B){_e.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 qg(d,j.id);if(await Promise.all([k(d,{silent:!0}),Ia()]),B?_e.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):_e.success(t("sessions.scheduledTasks.dialog.toast.started")),A){const X=o.find(H=>H.id===d);Ze.getState().setCurrentSession(A,X?.path??null)}}catch(A){_e.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(Ns,{children:C(N)}):s.jsx(Ns,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(_s,{children:[o.length===0?s.jsx(ns,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(j=>s.jsx(ns,{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")]}):m.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:m.map(j=>{const A=y===j.id,B=j.state?.lastStatus||"idle",X=P4[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:A4(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:zc(Z,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:D4(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:zc(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:I4("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(S4,{open:S,task:f,onOpenChange:x,onSave:D})]})}const ko=100;function R4(){const t=et.c(108),{t:e}=Nt(),n=Te(W4),r=Te($4),i=Ze(L4),o=Ze(_4),l=ss(B4);let a;t[0]!==n?(a=Z=>n?Z.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const u=$s(Jn(a)),[d,h]=c.useState(""),[m,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 f;e:{if(!n){let ce;t[4]===Symbol.for("react.memo_cache_sentinel")?(ce=[],t[4]=ce):ce=t[4],f=ce;break e}let Z;t[5]!==u?(Z=[...u].sort(F4),t[5]=u,t[6]=Z):Z=t[6],f=Z}const b=f;let y;if(t[7]!==l||t[8]!==b||t[9]!==e){const Z=new Map;for(const ce of b){const Y=St(Ps(ce))??"",te=Z.get(Y);if(te){te.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(O4),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 te;t[14]!==x?(te=se=>se.id.toLowerCase()===x,t[14]=x,t[15]=te):te=t[15],Y=b.filter(te),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=ip(b,x,M4),t[16]=x,t[17]=b,t[18]=ce):ce=t[18],N=ce;break e}if(m===null){N=b;break e}let Z;t[19]!==v||t[20]!==m?(Z=v.find(ce=>ce.directory===m)?.sessions??[],t[19]=v,t[20]=m,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]!==m||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=we=>{p(we),w(ko)},t[45]=Y):Y=t[45];const te=Y;let se;t[46]!==i||t[47]!==r?(se=we=>{const G=St(Ps(we));i(we.id,G??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=se):se=t[48];const ve=se;let K;t[49]!==e||t[50]!==o?(K=we=>{o(we.id).then(G=>{G?_e.success(e("sessions.sidebar.session.restore.success")):_e.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=K):K=t[51];const he=K;if(!n){M=null;break e}let be;t[52]!==e?(be=(we,G,Se,ge,Ae,oe,ne)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:Ae,title:oe,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",ne?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",ge?"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:G}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:Se})]}),ne?s.jsxs(At,{children:[s.jsx(Dt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>xn.requestDelete({sessions:ne,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity 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:G}),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]},we),t[52]=e,t[53]=be):be=t[53];const ie=be;I="absolute inset-0 z-10 flex flex-col bg-background",D="flex min-h-0 flex-1";let T;if(t[54]!==ie||t[55]!==m||t[56]!==e||t[57]!==ce){let we;t[59]===Symbol.for("react.memo_cache_sentinel")?(we=()=>te(null),t[59]=we):we=t[59],T=ie("__all__",e("sessions.archivePage.allDirectories"),ce,m===null,we),t[54]=ie,t[55]=m,t[56]=e,t[57]=ce,t[58]=T}else T=t[58];let Q;if(t[60]!==v||t[61]!==ie||t[62]!==m){let we;t[64]!==ie||t[65]!==m?(we=G=>ie(G.directory||"__none__",G.label,G.sessions.length,m===G.directory,()=>te(G.directory),G.directory||void 0,G.sessions),t[64]=ie,t[65]=m,t[66]=we):we=t[66],Q=v.map(we),t[60]=v,t[61]=ie,t[62]=m,t[63]=Q}else Q=t[63];t[67]!==T||t[68]!==Q?(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,Q]})}),t[67]=T,t[68]=Q,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=we=>{h(we),w(ko)},t[70]=le):le=t[70];let me;t[71]!==e?(me=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=me):me=t[72];let ue;t[73]!==e?(ue=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=ue):ue=t[74];let Ce;t[75]!==d||t[76]!==me||t[77]!==ue?(Ce=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(ou,{value:d,onSearch:le,placeholder:me,clearLabel:ue})}),t[75]=d,t[76]=me,t[77]=ue,t[78]=Ce):Ce=t[78];let xe;t[79]!==C.length||t[80]!==e?(xe=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[79]=C.length,t[80]=e,t[81]=xe):xe=t[81];let Re;t[82]!==xe?(Re=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:xe}),t[82]=xe,t[83]=Re):Re=t[83],t[84]!==Ce||t[85]!==Re?(F=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Ce,Re]}),t[84]=Ce,t[85]=Re,t[86]=F):F=t[86],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(we=>{const G=St(Ps(we))??"",Se=G?Fn(G,l)||G: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:()=>ve(we),role:"button",tabIndex:0,onKeyDown:ge=>{(ge.key==="Enter"||ge.key===" ")&&(ge.preventDefault(),ve(we))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:we.title||e("sessions.sidebar.session.untitled")}),x&&Se?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:G,children:Se}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Kd(we.time?.archived??we.time?.updated??we.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:ge=>{ge.stopPropagation(),he(we)},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:we.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:ge=>{ge.stopPropagation(),xn.requestDelete({sessions:[we],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:we.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},we.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]=m,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[87]!==k||t[88]!==e?(R=k>0?s.jsx("button",{type:"button",onClick:()=>w(E4),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[87]=k,t[88]=e,t[89]=R):R=t[89];let j;t[90]!==R||t[91]!==_||t[92]!==O?(j=s.jsxs("div",{className:_,children:[O,R]}),t[90]=R,t[91]=_,t[92]=O,t[93]=j):j=t[93];let A;t[94]!==j||t[95]!==U?(A=s.jsx("div",{className:U,children:j}),t[94]=j,t[95]=U,t[96]=A):A=t[96];let B;t[97]!==A||t[98]!==L||t[99]!==F?(B=s.jsxs("div",{className:L,children:[F,A]}),t[97]=A,t[98]=L,t[99]=F,t[100]=B):B=t[100];let X;t[101]!==D||t[102]!==P||t[103]!==B?(X=s.jsxs("div",{className:D,children:[P,B]}),t[101]=D,t[102]=P,t[103]=B,t[104]=X):X=t[104];let H;return t[105]!==I||t[106]!==X?(H=s.jsx("div",{className:I,children:X}),t[105]=I,t[106]=X,t[107]=H):H=t[107],H}function E4(t){return t+ko}function M4(t){return[t.title]}function O4(t,e){return e.sessions.length-t.sessions.length}function F4(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function B4(t){return t.homeDirectory}function _4(t){return t.unarchiveSession}function L4(t){return t.setCurrentSession}function $4(t){return t.setArchivePageOpen}function W4(t){return t.isArchivePageOpen}function z4(){const t=et.c(18),{t:e}=Nt(),n=Te(K4),r=Te(U4),i=Ht(V4);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 m;t[12]!==l.id||t[13]!==l.path?(m=s.jsx(Ng,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=m):m=t[14];let p;return t[15]!==h||t[16]!==m?(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,m]})})}),t[15]=h,t[16]=m,t[17]=p):p=t[17],p}function V4(t){return t.setActiveProjectIdOnly}function U4(t){return t.setNewWorktreeDialogOpen}function K4(t){return t.worktreesPageProjectId}const ca=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),H4=(t,e)=>{const n=ca(t),r=ca(e);return`${n}-${r}`.substring(0,60)},Vc=(t,e)=>`${t}/${e}`,G4=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},Uc=(t,e)=>{const n=G4(e),r=t.directory,i=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};hp(t.id,n),Ze.getState().markSessionAsAiWorkerCreated(t.id),$s.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},q4=()=>{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=ss.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()(bu(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=q4();if(!a)return t({error:"Select a project",isLoading:!1}),null;const u=a.path,h=await Ko(u)&&e.isolateRuns!==!1,m=ca(n),p=h?await qo(u):void 0,g=h?await ap(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=H4(P.providerID,P.modelID),U=r.length>1?`g${v+1}`:void 0,L=M>1?Vc(m,`${O}/${_}`):Vc(m,O),F=U?`${U}/${L}`:L,R=zj({groupSlug:m,runGroup:U,providerID:P.providerID,modelID:P.modelID,index:M>1?_:void 0});try{if(!h){const X=await Xs.withDirectory(u,()=>Xs.createSession({title:R}));Uc(X,u),w.push({sessionId:X.id,worktreePath:u,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:C});continue}const j=await lp(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 cp(a)&&await dp(j.path);const B=await Xs.withDirectory(j.path,()=>Xs.createSession({title:R}));Uc(B,j.path),Ze.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&&up(a,x).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const f=w.map(v=>v.sessionId),b=w[0]?.sessionId??null;if(f.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=mp.getState().expandText;await Promise.allSettled(w.map(async N=>{try{const C=await v(N.prompt).catch(()=>N.prompt);await fp({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:m,sessionIds:f,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 jm(t){const e=et.c(30),{git:n}=Sn(),r=Ad(t),i=Dd(t),o=pp(t),l=gp(t),a=Dn(Z4),u=Dn(J4);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 m;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(m=()=>{!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]=m):m=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(m,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(X4).sort(),e[20]=r.all,e[21]=C):C=e[21],S=C}const x=S;let f;e:{if(!r?.all){let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[22]=k):k=e[22],f=k;break e}let C;e[23]!==r.all?(C=r.all.filter(Y4).map(Q4).sort(),e[23]=r.all,e[24]=C):C=e[24],f=C}const b=f;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 Y4(t){return t.startsWith("remotes/")}function X4(t){return!t.startsWith("remotes/")}function J4(t){return t.fetchStatus}function Z4(t){return t.fetchBranches}const e3=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=Nt(),{localBranches:a,remoteBranches:u,isLoading:d,isGitRepository:h}=jm(t),m=c.useMemo(()=>[...a,...u.map(g=>`remotes/${g}`)],[a,u]);c.useEffect(()=>{if(i||d||m.length===0||e&&m.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 f=localStorage.getItem(vl),{sourceBranch:b,shouldClearSavedSourceBranch:y}=Ag({branches:m,savedSourceBranch:f,rootBranch:x});if(y&&localStorage.removeItem(vl),w||g&&m.includes(g))return;b&&n(b)}catch{}})(),()=>{w=!0}},[m,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(Ns,{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(ns,{value:g,className:"whitespace-normal break-all",children:g},g))]}),a.length>0&&u.length>0&&s.jsx(xp,{}),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(ns,{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")})]})},t3=10*1024*1024,Co=t=>{const e=et.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=et.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},s3=({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(""),[m,p]=c.useState([]),[g,w]=c.useState(!1),[S,x]=c.useState([]),[f,b]=c.useState(!1),[y,v]=c.useState(!1),[N,C]=c.useState(!0),k=c.useRef(null),D=ss(z=>z.currentDirectory??null),P=ss(z=>z.homeDirectory??null),I=c.useMemo(()=>{if(typeof window>"u")return null;const z=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof z=="string"&&z.trim().length>0?z.trim():null},[]),M=Ht(z=>z.activeProjectId),_=Ht(z=>z.setActiveProjectIdOnly),O=Ht(z=>z.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(z=>z.id===U)??null:null,[O,U]),R=F?.path??D,j=c.useCallback(z=>{L(z),z!==M&&_(z)},[M,_]),{currentTheme:A}=Zn(),B=c.useCallback(z=>{const $=z.label?.trim()||Fn(z.path,P),ae=z.icon?ja[z.icon]:null,W=z.color?ka[z.color]:void 0,je=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:[z.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:z.iconBackground?{backgroundColor:z.iconBackground}:void 0,children:s.jsx(Ca,{project:{id:z.id,iconImage:z.iconImage??null},options:{themeVariant:A.metadata.variant,iconColor:A.colors.surface.foreground},className:"h-full w-full object-contain",fallback:je})}):je,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 z=D??I;return z?{id:`path:${z}`,path:z}: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=Sd(),Y=c.useMemo(()=>{if(typeof window>"u")return null;const z=window.__AIWORKER_MACOS_MAJOR__;if(typeof z=="number"&&Number.isFinite(z)&&z>0)return z;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},[]),te=c.useMemo(()=>H&&Z||ce?"pl-[88px]":"pl-3",[H,Z,ce]),se=c.useMemo(()=>!H||!Z||Y===null?"":Y>=26?"h-12":Y<=15?"h-14":"",[H,Z,Y]),ve=c.useCallback(async z=>{z.target.closest("button, a, input, select, textarea")||z.button===0&&H&&await bp()},[H]);c.useEffect(()=>{if(!n)return;const z=$=>{$.key==="Escape"&&($.preventDefault(),$.stopPropagation(),n())};return window.addEventListener("keydown",z,!0),()=>window.removeEventListener("keydown",z,!0)},[n]);const[K,he]=c.useState(""),{isLoading:be,isGitRepository:ie}=jm(R),T=c.useRef(!1),Q=ie===!0,le=Q&&N;c.useEffect(()=>{if(ie===!1){T.current=!0,C(!1);return}ie===!0&&T.current&&(T.current=!1,C(!0))},[ie]);const me=xi(z=>z.createMultiRun),ue=xi(z=>z.error),Ce=xi(z=>z.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&u(z=>{const $=[...z];return $.length>0&&!$[0].prompt.trim()&&($[0]={...$[0],prompt:t}),$})},[t]),c.useEffect(()=>{if(!X)return;let z=!1;return v(!0),(async()=>{try{const $=await yp(X);z||x($)}catch{}finally{z||v(!1)}})(),()=>{z=!0}},[X]);const xe=c.useCallback((z,$)=>{u(ae=>ae.map(W=>W.id===z?{...W,...$}:W))},[]),Re=c.useCallback(z=>{u($=>$.filter(ae=>ae.id!==z))},[]),we=c.useCallback(()=>{u(z=>[...z,{id:Lr(),prompt:"",models:[]}])},[]),G=async z=>{const $=z.target.files;if(!$)return;let ae=0;for(let W=0;W<$.length;W++){const je=$[W];if(je.size>t3){_e.error(i("multirun.launcher.toast.fileTooLarge",{fileName:je.name}));continue}try{const Ee=await new Promise((Ne,Be)=>{const ze=new FileReader;ze.onload=()=>Ne(ze.result),ze.onerror=Be,ze.readAsDataURL(je)});p(Ne=>[...Ne,{id:Lr(),filename:je.name,mimeType:je.type||"application/octet-stream",size:je.size,dataUrl:Ee}]),ae++}catch(Ee){console.error("File attach failed",Ee),_e.error(i("multirun.launcher.toast.attachFailed",{fileName:je.name}))}}ae>0&&_e.success(ae===1?i("multirun.launcher.toast.attachedSingle",{count:ae}):i("multirun.launcher.toast.attachedPlural",{count:ae})),k.current&&(k.current.value="")},Se=z=>{p($=>$.filter(ae=>ae.id!==z))},ge=c.useMemo(()=>a.reduce((z,$)=>z+$.models.length,0),[a]),Ae=async z=>{z.preventDefault();const $=a.filter(ae=>ae.prompt.trim()&&ae.models.length>=1);if($.length!==0&&!(ge<1)){w(!0),Ce();try{U&&U!==M&&_(U);const ae=m.map(Be=>({mime:Be.mimeType,filename:Be.filename,url:Be.dataUrl})),W=S.filter(Be=>Be.trim().length>0),je=$.map(Be=>({prompt:Be.prompt.trim(),models:Be.models.map(ze=>({providerID:ze.providerID,modelID:ze.modelID,displayName:ze.displayName,variant:ze.variant}))})),Ee={name:o.trim(),groups:je,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},Ne=await me(Ee);Ne&&(Ne.firstSessionId&&Ze.getState().setCurrentSession(Ne.firstSessionId),e?.())}finally{w(!1)}}},oe=!!(o.trim()&&a.some(z=>z.prompt.trim()&&z.models.length>=1)&&ge>=1&&R&&!be&&(ie===!1||!le||K)),ne=S.filter(z=>z.trim()).length;return s.jsxs("form",{onSubmit:Ae,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:ve,className:Ie("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",te,se),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(Ns,{children:B(F)}):s.jsx(Ns,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(_s,{fitContent:!0,children:O.map(z=>s.jsx(ns,{value:z.id,className:"max-w-[24rem]",children:B(z)},z.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(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:z=>l(z.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Kn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Co,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(e3,{directory:R,value:K,onChange:he,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:!Q,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(pm,{value:d,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(ki,{open:f,onOpenChange:b,children:[s.jsxs(Nd,{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")}),ne>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:ne}),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",f&&"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((z,$)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(Cn,{value:z,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"})})]},`${z}-${$}`)),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:G,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")})]}),m.map(z=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[z.mimeType.startsWith("image/")?s.jsx(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:z.filename,children:z.filename}),s.jsx("button",{type:"button",onClick:()=>Se(z.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(E,{name:"close",className:"h-3 w-3"})})]},z.id))]})]}),a.map((z,$)=>s.jsx(n3,{group:z,groupIndex:$,canRemove:a.length>1,onUpdate:xe,onRemove:Re},z.id)),s.jsxs("button",{type:"button",onClick:we,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&&ie!==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:!oe||g,children:g?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:ge})})})]})})]})},n3=t=>{const e=et.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=Nt(),[u,d]=c.useState(!1),[h,m]=c.useState(""),[p,g]=c.useState(!1),[w,S]=c.useState(""),[x,f]=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((je,Ee)=>Ee!==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,je)=>{o(n.id,{models:n.models.map((Ee,Ne)=>Ne===W?je:Ee)})},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,je)=>{if(W.startsWith("/")){const ze=W.indexOf(" "),We=W.indexOf(`
|
|
927
|
+
`),V=Math.min(ze===-1?W.length:ze,We===-1?W.length:We);if(je<=V&&ze===-1){S(W.substring(1,V)),g(!0),d(!1),f(!1);return}}g(!1);const Ee=W.substring(0,je),Ne=Ee.lastIndexOf("#");if(Ne!==-1){const ze=Ne>0?Ee[Ne-1]:null,We=Ee.substring(Ne+1);if((!ze||/\s/.test(ze))&&!We.includes(" ")&&!We.includes(`
|
|
928
|
+
`)){y(We),f(!0),d(!1);return}}f(!1);const Be=Ee.lastIndexOf("@");if(Be!==-1){const ze=Be>0?Ee[Be-1]:null,We=Ee.substring(Be+1);(!ze||/\s/.test(ze))&&!We.includes(" ")&&!We.includes(`
|
|
929
|
+
`)?(m(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 je=n.prompt,Ne=v.current?.selectionStart??je.length,ze=je.substring(0,Ne).lastIndexOf("@"),We=W.relativePath&&W.relativePath.trim().length>0?W.relativePath.trim():W.path||W.name,V=ze!==-1?ze:Ne,fe=`${je.substring(0,V)}@${We} ${je.substring(Ne)}`,Me=V+We.length+2;R(fe),d(!1),m(""),requestAnimationFrame(()=>{const Pe=v.current;Pe&&(Pe.selectionStart=Me,Pe.selectionEnd=Me,Pe.focus()),L(fe,Me)})},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 je=n.prompt,Ne=v.current?.selectionStart??je.length,ze=je.substring(0,Ne).lastIndexOf("@"),We=ze!==-1?ze:Ne,V=`${je.substring(0,We)}@${W} ${je.substring(Ne)}`,fe=We+W.length+2;R(V),d(!1),m(""),requestAnimationFrame(()=>{const Me=v.current;Me&&(Me.selectionStart=fe,Me.selectionEnd=fe,Me.focus()),L(V,fe)})},e[19]=n.prompt,e[20]=R,e[21]=B):B=e[21];const X=B;let H;e[22]!==R?(H=W=>{const je=`/${W.name} `;R(je),g(!1),S(""),f(!1),requestAnimationFrame(()=>{const Ee=v.current;Ee&&(Ee.focus(),Ee.selectionStart=Ee.value.length,Ee.selectionEnd=Ee.value.length),L(je,je.length)})},e[22]=R,e[23]=H):H=e[23];const Z=H;let ce;e[24]!==n.prompt||e[25]!==R?(ce=(W,je)=>{const Ee=n.prompt,Be=v.current?.selectionStart??Ee.length,We=Ee.substring(0,Be).lastIndexOf("#"),V=We!==-1?We:Be,fe=`${Ee.substring(0,V)}#${je} ${Ee.substring(Be)}`,Me=V+je.length+2;R(fe),f(!1),y(""),requestAnimationFrame(()=>{const Pe=v.current;Pe&&(Pe.selectionStart=Me,Pe.selectionEnd=Me,Pe.focus()),L(fe,Me)})},e[24]=n.prompt,e[25]=R,e[26]=ce):ce=e[26];const Y=ce;let te;e[27]!==p||e[28]!==u||e[29]!==x?(te=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]=te):te=e[30];const se=te,ve=r+1;let K;e[31]!==a||e[32]!==ve?(K=a("multirun.launcher.groups.groupLabel",{index:ve}),e[31]=a,e[32]=ve,e[33]=K):K=e[33];let he;e[34]!==K?(he=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:K}),e[34]=K,e[35]=he):he=e[35];let be;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(be=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]=be):be=e[40];let ie;e[41]!==he||e[42]!==be?(ie=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[he,be]}),e[41]=he,e[42]=be,e[43]=ie):ie=e[43];let T;e[44]!==a?(T=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=T):T=e[45];let Q;e[46]!==T?(Q=s.jsx(Kn,{required:!0,children:T}),e[46]=T,e[47]=Q):Q=e[47];const le=n.prompt;let me;e[48]!==R?(me=W=>{const je=W.target.value;R(je);const Ee=W.target.selectionStart??je.length;L(je,Ee)},e[48]=R,e[49]=me):me=e[49];let ue;e[50]!==a?(ue=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=ue):ue=e[51];let Ce;e[52]!==n.prompt||e[53]!==se||e[54]!==me||e[55]!==ue?(Ce=s.jsx(lr,{ref:v,value:le,onChange:me,onKeyDown:se,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]=se,e[54]=me,e[55]=ue,e[56]=Ce):Ce=e[56];let xe;e[57]!==w||e[58]!==Z||e[59]!==p?(xe=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]=xe):xe=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 we;e[66]!==Y||e[67]!==x||e[68]!==b?(we=x?s.jsx(Yd,{ref:k,searchQuery:b,onSnippetSelect:Y,onClose:()=>f(!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]=we):we=e[69];let G;e[70]!==Ce||e[71]!==xe||e[72]!==Re||e[73]!==we?(G=s.jsxs("div",{className:"relative",children:[Ce,xe,Re,we]}),e[70]=Ce,e[71]=xe,e[72]=Re,e[73]=we,e[74]=G):G=e[74];let Se;e[75]!==Q||e[76]!==G?(Se=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[Q,G]}),e[75]=Q,e[76]=G,e[77]=Se):Se=e[77];let ge;e[78]!==a?(ge=a("multirun.launcher.models.info"),e[78]=a,e[79]=ge):ge=e[79];let Ae;e[80]!==ge?(Ae=s.jsx(Co,{children:ge}),e[80]=ge,e[81]=Ae):Ae=e[81];let oe;e[82]!==a?(oe=a("multirun.launcher.models.label"),e[82]=a,e[83]=oe):oe=e[83];let ne;e[84]!==Ae||e[85]!==oe?(ne=s.jsx(Kn,{required:!0,info:Ae,children:oe}),e[84]=Ae,e[85]=oe,e[86]=ne):ne=e[86];let z;e[87]!==n.models||e[88]!==P||e[89]!==M||e[90]!==O?(z=s.jsx(gm,{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]=z):z=e[91];let $;e[92]!==ne||e[93]!==z?($=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ne,z]}),e[92]=ne,e[93]=z,e[94]=$):$=e[94];let ae;return e[95]!==ie||e[96]!==Se||e[97]!==$?(ae=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[ie,Se,$]}),e[95]=ie,e[96]=Se,e[97]=$,e[98]=ae):ae=e[98],ae},r3=t=>{const e=new Map;for(const n of t){const r=Ps(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},o3=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},i3=t=>{const e=et.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=fs(),h=r3(i),m=l.current?.runtimeKey===d?l.current.identities:null;for(const p of o3(m,h))wp({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)},a3=new Map,l3=t=>{const e=et.c(26),{isVSCode:n}=t,r=Pa(),i=Ht(c3),o=Ht(d3),l=ss(u3),a=Ze(m3);let u;e[0]!==n?(u=I=>n?a3:I.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const d=Ze(u),h=!n;let m;e[2]!==d||e[3]!==i||e[4]!==h?(m=wm(i,d,{includeWorktrees:h}),e[2]=d,e[3]=i,e[4]=h,e[5]=m):m=e[5];const p=m,g=$s(f3),w=$s(h3),S=$s(p3),x=`session-list-sync:${c.useId()}`;let f,b;e[6]!==o||e[7]!==x||e[8]!==r||e[9]!==l||e[10]!==a||e[11]!==p||e[12]!==i?(f=()=>(r.setBootstrapDemand(x,dm({knownDirectories:p,activeProjectDirectory:St(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]=f,e[14]=b):(f=e[13],b=e[14]),c.useEffect(f,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(g3,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],i3(P)};function c3(t){return t.projects}function d3(t){return t.activeProjectId}function u3(t){return t.currentDirectory}function m3(t){return t.currentSessionDirectory}function f3(t){return t.activeSessions}function h3(t){return t.archivedSessions}function p3(t){return t.status==="ready"}function g3(){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(),Ia(Po());return}const o=[...n];n.clear(),o.length&&xa(o,Po())},500)});return()=>{t&&clearTimeout(t),r()}}const x3=Ln(()=>Bn(()=>import("./SettingsWindow-DFMJqIkx.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}))),b3=()=>{const t=et.c(58);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],l3(e),Dg();const n=Te(y3),r=Te(w3),i=Te(S3),o=Te(v3),[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(j3),m=Te(k3),p=Te(C3),g=Te(N3),w=Te(A3),S=Te(D3),x=g||w||!!S||h;let f;t[4]===Symbol.for("react.memo_cache_sentinel")?(f=[],t[4]=f):f=t[4],c.useEffect(I3,f);const{isMobile:b}=_n();Pg();const y=cb();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(GS,{}),k=s.jsx(Vv,{}),D=s.jsx(Gv,{}),P=s.jsx(n4,{}),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(r4,{value:y,onMoveSessionOnly:T3,onMoveAllChanges:R3,onCancel:bb}),t[13]=y,t[14]=I):I=t[14];let M;t[15]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(Ab,{}),t[15]=M):M=t[15];let _;t[16]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(Nb,{}),t[16]=_):_=t[16];let O;t[17]!==n?(O=s.jsx(s4,{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(Cb,{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(jb,{}),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(Qs,{children:s.jsx(au,{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]!==m?(X=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qs,{children:s.jsx(s3,{isWindowed:!0,initialPrompt:p,onCreated:()=>m(!1),onCancel:()=>m(!1)})})}),t[31]=h,t[32]=p,t[33]=m,t[34]=X):X=t[34];let H;t[35]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Qs,{children:s.jsx(T4,{})}),t[35]=H):H=t[35];let Z;t[36]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Qs,{children:s.jsx(R4,{})}),t[36]=Z):Z=t[36];let ce;t[37]===Symbol.for("react.memo_cache_sentinel")?(ce=s.jsx(Qs,{children:s.jsx(z4,{})}),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 te;t[41]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(xS,{}),t[41]=te):te=t[41];let se;t[42]!==Y?(se=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,te]})})}),t[42]=Y,t[43]=se):se=t[43];let ve;t[44]===Symbol.for("react.memo_cache_sentinel")?(ve=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Qs,{children:s.jsx(AS,{})})}),t[44]=ve):ve=t[44];let K;t[45]!==se?(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:[se,ve]})]}),t[45]=se,t[46]=K):K=t[46];let he;t[47]!==U||t[48]!==K?(he=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]=he):he=t[49];let be;t[50]!==i||t[51]!==o||t[52]!==l?(be=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(x3,{open:i,onOpenChange:o})}):null,t[50]=i,t[51]=o,t[52]=l,t[53]=be):be=t[53];let ie;return t[54]!==I||t[55]!==he||t[56]!==be?(ie=s.jsx(Ig,{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,he,be]})}),t[54]=I,t[55]=he,t[56]=be,t[57]=ie):ie=t[57],ie};function y3(t){return t.isSidebarOpen}function w3(t){return t.setIsMobile}function S3(t){return t.isSettingsDialogOpen}function v3(t){return t.setSettingsDialogOpen}function j3(t){return t.isMultiRunLauncherOpen}function k3(t){return t.setMultiRunLauncherOpen}function C3(t){return t.multiRunLauncherPrefillPrompt}function N3(t){return t.isScheduledTasksDialogOpen}function A3(t){return t.isArchivePageOpen}function D3(t){return t.worktreesPageProjectId}function P3(){return Te.getState().closeMainSurfaces()}function I3(){const t=P3,e=Ze.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 T3(){return Ou(!1)}function R3(){return Ou(!0)}const km=12,E3=[{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"}],M3=t=>{const e=et.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?E3:l,m=gt.useRef(!1);let p,g;e[0]!==n||e[1]!==a?(p=()=>{!n&&m.current&&a?.(),n&&(m.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:km},O3),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 f;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],f=h.map(y),e[7]=u,e[8]=h,e[9]=d,e[10]=f}else f=e[10];let b;return e[14]!==u||e[15]!==x||e[16]!==f?(b=s.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":u,children:f}),e[14]=u,e[15]=x,e[16]=f,e[17]=b):b=e[17],b};function O3(t,e){const n=Math.PI*2*e/km;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const F3=t=>{const e=et.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 m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{h(),a(B3)},e[4]=m):m=e[4];const p=m;let g;e[5]!==i?(g=()=>{h(),a(_3),u.current=window.setTimeout(()=>{a(L3),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 f;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(f={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=f):f=e[12],f};function B3(t){return t.isActive?{...t,isActive:!1}:t}function _3(t){return{isActive:!0,cycle:t.cycle+1}}function L3(t){return t.isActive?{...t,isActive:!1}:t}const Cm=c.createContext(void 0),$3=t=>{const e=et.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=F3();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(M3,{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(Cm.Provider,{value:u,children:[n,d]}),e[6]=n,e[7]=d,e[8]=u,e[9]=h):h=e[9],h},j5=()=>{const t=c.useContext(Cm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},da="aiworker_requests_in_flight",Nm=1e3,W3=300*1e3,$o=Math.ceil(W3/Nm),z3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(da)==="1"}catch{return!1}},Am=()=>({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 V3=1;const U3=(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))},K3=t=>{const e=window.__aiworkerRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Dm=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)},H3=()=>{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=V3++;U3(o,Date.now());try{return await e(r,i)}finally{K3(o)}};window.fetch=n},Kc=()=>{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)},G3=()=>{const t=window.__aiworkerRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Dm(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()},q3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(G3,Nm))},Hc=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Gc=t=>{if(!(typeof window>"u"))try{if(t){Hc(),Kc(),window.localStorage.setItem(da,"1"),window.__aiworkerRequestsInFlight__=Am(),H3(),q3();return}window.localStorage.removeItem(da),Hc(),Kc(),delete window.__aiworkerRequestsInFlight__}catch{}},Q3=()=>{if(typeof window>"u")return;const t=window.__aiworkerRequestsInFlight__;if(!t)return;const e=Am();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(!z3()||!t)return qc();const e=Dm(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 Y3(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const Pm=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`},ma=t=>`${(t/1e3).toFixed(2)} s`,Ss=t=>{const e=et.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},Qc=t=>{const e=et.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(Z3,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 m;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(m=r.startedAt?Pm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=m):m=e[15];let p;e[16]!==m?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:m}),e[16]=m,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 f;e[28]!==x||e[29]!==d?(f=s.jsx(Ss,{label:x,value:d}),e[28]=x,e[29]=d,e[30]=f):f=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]!==f||e[40]!==v||e[41]!==S?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[S,f,v]}),e[39]=f,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(dn,{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},Yc=t=>{const e=et.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,u=n.reduce(eC,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 m=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 f;if(e[9]!==n||e[10]!==m||e[11]!==g){let v;e[13]!==m||e[14]!==g?(v=(N,C)=>{const k=N.samples.length;if(k===0)return null;const D=N.samples.map((I,M)=>`${m(M)},${g(I).toFixed(2)}`),P=`M ${D.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${m(0)},56 L ${D.join(" L ")} L ${m(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]=m,e[14]=g,e[15]=v):v=e[15],f=n.map(v),e[9]=n,e[10]=m,e[11]=g,e[12]=f}else f=e[12];let b;e[16]!==o||e[17]!==S||e[18]!==x||e[19]!==f?(b=s.jsxs("svg",{viewBox:S,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[x,f]}),e[16]=o,e[17]=S,e[18]=x,e[19]=f,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},X3=t=>{const e=et.c(100),{onClose:n}=t,{t:r}=Nt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),u=Ze(tC),d=Ud(sC),h=Id(),m=Sp(nC),p=qs(rC),[g,w]=c.useState(oC),[S,x]=c.useState(iC),[f,b]=c.useState(aC),y=[{label:"p50",current:f.ageP50,samples:f.p50Samples,color:"var(--status-success)"},{label:"p90",current:f.ageP90,samples:f.p90Samples,color:"var(--status-info)"},{label:"p99",current:f.ageP99,samples:f.p99Samples,color:"var(--status-warning)"},{label:"max",current:f.ageMax,samples:f.maxSamples,color:"var(--status-error)"}];let v;e[0]!==f.samples?(v=f.samples.reduce(lC,0),e[0]=f.samples,e[1]=v):v=e[1];const N=v,C=y.reduce(dC,0);let k;e[2]!==g.entries?(k=new Map,g.entries.forEach(Me=>{k.set(Me.metric,Me.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 Me=()=>{w(mo()),x(fo()),b(ua())};Me();const Pe=window.setInterval(Me,500);return()=>window.clearInterval(Pe)},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 Me=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Me)},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 Me of Object.keys(m)){const Pe=m[Me]??[];X=X+Pe.length;for(const ot of Pe)ot.role==="user"?H=H+1:ot.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]!==m||e[34]!==d||e[35]!==h||e[36]!==r){let Me;e[38]!==u||e[39]!==m||e[40]!==d||e[41]!==r?(Me=Pe=>{const ot=m[Pe.id]??[];let Ke=0,ht=0;for(const kt of ot)kt.role==="user"?ht=ht+1:kt.role==="assistant"&&(Ke=Ke+1);const ft=d.get(Pe.id);return{id:Pe.id,title:Pe.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:Ke,messageCount:ot.length,userMessageCount:ht,isStreaming:ft?.isStreaming||!1,isZombie:ft?.isZombie||!1,backgroundCount:ft?.backgroundMessageCount||0,lastAccessed:ft?.lastAccessedAt||0,isCurrent:Pe.id===u}},e[38]=u,e[39]=m,e[40]=d,e[41]=r,e[42]=Me):Me=e[42],Y=h.map(Me).sort(uC),e[32]=u,e[33]=m,e[34]=d,e[35]=h,e[36]=r,e[37]=Y}else Y=e[37];const te=Y;let se;e[43]!==m?(se=Object.keys(m),e[43]=m,e[44]=se):se=e[44];const ve=se.length;let K;e[45]===Symbol.for("react.memo_cache_sentinel")?(K=async()=>{try{const Me={generatedAt:new Date().toISOString(),ui:mo(),vscode:fo()};await navigator.clipboard.writeText(JSON.stringify(Me,null,2)),a("copied")}catch{a("error")}},e[45]=K):K=e[45];const he=K,be=jp,ie="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 Q;e[47]!==i?(Q=Y3(i),e[47]=i,e[48]=Q):Q=e[48];let le;e[49]!==Q?(le=s.jsx(E,{name:Q,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=Q,e[50]=le):le=e[50];let me;e[51]!==r?(me=r("memoryDebugPanel.title"),e[51]=r,e[52]=me):me=e[52];let ue;e[53]!==me?(ue=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:me}),e[53]=me,e[54]=ue):ue=e[54];let Ce;e[55]!==le||e[56]!==ue?(Ce=s.jsxs("div",{className:"flex items-center gap-2",children:[le,ue]}),e[55]=le,e[56]=ue,e[57]=Ce):Ce=e[57];let xe;e[58]!==i?(xe=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(xt,{size:"xs",variant:"ghost",onClick:he,children:s.jsx(E,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(xt,{size:"xs",variant:"ghost",onClick:()=>{gf(),w(mo()),x(fo())},children:s.jsx(E,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=xe):xe=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 we;e[62]!==n?(we=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]=we):we=e[63];let G;e[64]!==xe||e[65]!==Re||e[66]!==we?(G=s.jsxs("div",{className:"flex items-center gap-1",children:[xe,Re,we]}),e[64]=xe,e[65]=Re,e[66]=we,e[67]=G):G=e[67];let Se;e[68]!==Ce||e[69]!==G?(Se=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Ce,G]}),e[68]=Ce,e[69]=G,e[70]=Se):Se=e[70];let ge;e[71]===Symbol.for("react.memo_cache_sentinel")?(ge={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=ge):ge=e[71];const Ae=i==="memory"?"secondary":"ghost";let oe;e[72]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>o("memory"),e[72]=oe):oe=e[72];let ne;e[73]!==r?(ne=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=ne):ne=e[74];let z;e[75]!==Ae||e[76]!==ne?(z=s.jsx(xt,{size:"sm",variant:Ae,className:"flex-1",onClick:oe,children:ne}),e[75]=Ae,e[76]=ne,e[77]=z):z=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 je;e[81]!==$||e[82]!==W?(je=s.jsx(xt,{size:"sm",variant:$,className:"flex-1",onClick:ae,children:W}),e[81]=$,e[82]=W,e[83]=je):je=e[83];const Ee=i==="requests"?"secondary":"ghost";let Ne;e[84]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>o("requests"),e[84]=Ne):Ne=e[84];let Be;e[85]!==r?(Be=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Be):Be=e[86];let ze;e[87]!==Ee||e[88]!==Be?(ze=s.jsx(xt,{size:"sm",variant:Ee,className:"flex-1",onClick:Ne,children:Be}),e[87]=Ee,e[88]=Be,e[89]=ze):ze=e[89];let We;e[90]!==z||e[91]!==je||e[92]!==ze?(We=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ge,children:[z,je,ze]}),e[90]=z,e[91]=je,e[92]=ze,e[93]=We):We=e[93];const V=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:`${ve} / ${fl.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:vp()})})]}),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:fl.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(dn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:te.map(Me=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Me.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:Me.title}),Me.isStreaming?s.jsx(E,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Me.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:Me.assistantMessageCount,user:Me.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Me.messageCount})}),Me.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Me.backgroundCount]}):null]})]},Me.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(mC),currentSessionId:u,cachedSessions:Object.keys(m),messageRoleCounts:ce,sessionMessageRoleCounts:te.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:he,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(Qc,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:g,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),S.entries.length>0?s.jsx(Qc,{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:`${f.totalSettled} / ${f.totalStarted}`}),s.jsx(Ss,{label:r("memoryDebugPanel.requests.tracking"),value:f.startedAt?Pm(f.durationMs):r("memoryDebugPanel.common.idle")})]}),f.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:f.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:f.peak})]})]}),s.jsx(Yc,{series:[{samples:f.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:f.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:f.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:ma(f.peakAgeMs)})]}),s.jsx(Yc,{series:y.map(hC),peak:C,windowSeconds:f.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:ma(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:y.map(pC)}),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:f.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let fe;return e[94]!==be||e[95]!==T||e[96]!==Se||e[97]!==We||e[98]!==V?(fe=s.jsxs(be,{className:ie,style:T,children:[Se,We,V]}),e[94]=be,e[95]=T,e[96]=Se,e[97]=We,e[98]=V,e[99]=fe):fe=e[99],fe},J3=X3;function Z3(t,e){return t+e.count}function eC(t,e){return Math.max(t,e.samples.length)}function tC(t){return t.currentSessionId}function sC(t){return t.sessionMemoryState}function nC(t){return t.message}function rC(t){return t.totalRequestCount}function oC(){return mo()}function iC(){return fo()}function aC(){return ua()}function lC(t,e){return Math.max(t,e)}function cC(t,e){return Math.max(t,e)}function dC(t,e){return e.samples.reduce(cC,t)}function uC(t,e){return e.lastAccessed-t.lastAccessed}function mC(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 hC(t){return{samples:t.samples,color:t.color}}function pC(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:ma(t.current)})]},t.label)}const gC=()=>{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()??"":""},xC=async()=>{const t=gC()||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")},Xc="aiworker:menu-action",bi="aiworker:check-for-updates",bC=t=>{const e=Ze(f=>f.openNewSessionDraft),n=Te(f=>f.toggleCommandPalette),r=Te(f=>f.setCommandPaletteOpen),i=Te(f=>f.toggleHelpDialog),o=Te(f=>f.toggleSidebar),l=Te(f=>f.setSessionSwitcherOpen),a=Te(f=>f.setSettingsDialogOpen),u=Te(f=>f.setAboutDialogOpen),d=Fr(f=>f.checkForUpdates),{setThemeMode:h}=Zn(),m=c.useRef(!1),p=c.useCallback(()=>{m.current||(m.current=!0,d().then(()=>{const{available:f,error:b}=Fr.getState();if(b){_e.error("Failed to check for updates",{description:b});return}f||_e.success("You are on the latest version")}).finally(()=>{m.current=!1}))},[d]),g=c.useCallback(()=>{xn.requestDirectoryDialog()},[]),w=c.useCallback(f=>{const b=kp();if(b.length===0)return;const y=Ze.getState().currentSessionId,v=b.findIndex(k=>k.id===y);let N=f>0?0:b.length-1;v>=0&&(N=(v+f+b.length)%b.length);const C=b[N];C&&(l(!1),Ze.getState().setCurrentSession(C.id))},[l]),S=c.useCallback(f=>{const{activeProjectId:b,projects:y,setActiveProject:v}=Ht.getState();if(y.length===0)return;const N=y.findIndex(D=>D.id===b);let C=f>0?0:y.length-1;N>=0&&(C=(N+f+y.length)%y.length);const k=y[C];k&&v(k.id)},[]),x=c.useCallback(f=>{switch(f){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=Ze.getState(),y=ss.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=ss.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=ss.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"git");break}case"open-right-sidebar-files":{const b=ss.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"file");break}case"toggle-terminal":{const b=ss.getState().currentDirectory;if(!b)break;Te.getState().openContextSurface(or(b),"terminal");break}case"toggle-terminal-expanded":{const b=ss.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)||xC();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":Cp();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":ss.getState().goBack();break;case"go-forward":ss.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(()=>{_e.error("Failed to collect OpenCode status")});break}}},[g,S,w,t,e,u,l,r,a,h,n,i,o]);c.useEffect(()=>{const f=y=>{const v=y.detail;v&&x(v)},b=()=>{p()};return window.addEventListener(Xc,f),window.addEventListener(bi,b),()=>{window.removeEventListener(Xc,f),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])},yC="aiworker:tray-action",Jc=5e3,wC=500,Im=20,Zc=()=>{if(typeof window>"u")return!1;const t=window.__AIWORKER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},ed=()=>typeof window<"u"&&window.__AIWORKER_ELECTRON__?.trayEnabled!==!1,SC=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},vC=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Tm=(t,e)=>Gd(t,e,Wr.getState().ids,va.getState().rankById),jC=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},kC=(t,e,n,r,i)=>{if(!t)return"";const o=fd(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||jC(t),u=go(t);let d=u&&i.get(u)||"";if(!d){for(const[h,m]of Dn.getState().directories)if(go(h)===u){d=m.status?.current??"";break}}if(!d)for(const h of r.values()){const m=h.find(p=>go(p.path)===u);if(m?.branch){d=m.branch;break}}return d?`${a} · ${d}`:a},CC=()=>{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 Dp){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const u=[];for(const[h,m]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?m.remainingPercent:m.usedPercent;u.push({label:Ip(h),value:Pp(m.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}},NC=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 ad()).hosts.find(i=>e?qa(e,xf(i)):!1);return r?.label?.trim()?ld(r.label.trim()):"Instance"}catch{return""}},AC=()=>{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,m=h==="busy"?"busy":h==="retry"?"retry":"idle",p=t.get(u);(!p||p==="idle")&&t.set(u,m)}for(const[u,d]of Object.entries(a.permission??{}))for(const h of d??[]){if(!h?.id)continue;const m=h.sessionID||u;n.push({kind:"permission",id:h.id,sessionId:m,sessionTitle:"",label:SC(h),directory:o})}for(const[u,d]of Object.entries(a.question??{}))for(const h of d??[]){if(!h?.id)continue;const m=h.sessionID||u;n.push({kind:"question",id:h.id,sessionId:m,sessionTitle:"",label:vC(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},DC=()=>{const t=$s.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Tm).slice(0,Im).forEach(r=>{const i=Ps(r);i&&e.add(i)});const n=new Map;for(const r of t){if(!r?.id)continue;const i=Ps(r);if(!i||!e.has(i))continue;const o=n.get(i)??[];o.push(r.id),n.set(i,o)}return n},PC=t=>{const e=AC(),n=Aa.getState().index.session,r=$s.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 f=o.get(x.parentID)??[];f.push(x.id),o.set(x.parentID,f)}const l=x=>{const f=[],b=[...o.get(x)??[]],y=new Set;for(;b.length;){const v=b.pop();y.has(v)||(y.add(v),f.push(v),b.push(...o.get(v)??[]))}return f},a=Na.getState().statusById,u=x=>{const f=e.statusById.get(x);return f&&f!=="idle"?f:a.get(x)?.status.type??f??"idle"},d=x=>{const f=x.map(b=>u(b));return f.includes("busy")?"busy":f.includes("retry")?"retry":"idle"},h=Ht.getState().projects,m=Ze.getState().availableWorktreesByProject,p=r.filter(x=>x?.id&&!x.parentID).slice().sort(Tm).slice(0,Im).map(x=>{const f=[x.id,...l(x.id)],b=Ps(x)??"";return{id:x.id,title:x.title||"Untitled session",status:d(f),branch:b?e.branchByDirectory.get(b)??"":"",unseen:f.reduce((y,v)=>y+(n.unseenCount[v]??0),0),hasError:f.some(y=>n.unseenHasError[y]??!1),directory:b,subtitle:kC(b,x,h,m,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 f=n.unseenCount[x.id]??0;f===0&&w.notifyOnSubtasks&&(f=l(x.id).reduce((b,y)=>b+(n.unseenCount[y]??0),0)),f>0&&(S+=1)}return{sessions:p,approvals:g,instanceName:t,usage:CC(),dockBadgeCount:S}},IC=()=>{c.useEffect(()=>{if(!Zc()||!ed()||!Vo())return;let t=!1,e="",n=null,r="";const i=()=>{if(t)return;const C=PC(r),k=JSON.stringify(C);k!==e&&(e=k,Mn("desktop_tray_update",C))};NC().then(C=>{t||(r=C,i())});const o=async()=>{const C=DC();await Promise.all([...C.entries()].map(async([k,D])=>{const P=await Xs.getSessionStatusForDirectory(k).catch(()=>null);t||P===null||Np(k,P,D)}))},l=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,i()},wC))},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=Aa.subscribe(()=>l()),m=$s.subscribe(()=>l()),p=Ht.subscribe(()=>l()),g=Ze.subscribe(()=>l()),w=Dn.subscribe(()=>l()),S=Te.subscribe(()=>l()),x=Na.subscribe(()=>l()),f=va.subscribe(()=>l()),b=Wr.subscribe(()=>l());o();const y=window.setInterval(()=>{o()},Jc),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()},Jc);return i(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(N),window.clearInterval(y),h(),m(),p(),g(),w(),S(),x(),f(),b(),v(),d?.();for(const C of a.values())C();a.clear()}},[]),c.useEffect(()=>{if(!Zc()||!ed()||typeof window>"u")return;const e=window.__AIWORKER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&Ap(i.sessionId,i.id,i.response).catch(()=>{_e.error("Failed to respond to permission request")})};let r=null;return e(yC,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{}}},[])},TC=45e3,RC=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,TC);return()=>r(i)},EC=t=>{const e=et.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return RC(MC,OC)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function MC(){Tp(Po())}function OC(){Ia()}const FC="/api/notifications/stream",BC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),_C=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}},LC=t=>{const e=et.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(dd().sse(FC));return o.onmessage=$C,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function $C(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Te.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&BC())return;const r=_C(e);if(!r)return;zo()?.notifications?.notifyAgentCompletion(r)}const WC=6e4,zC=t=>{const e=et.c(10),n=Te(VC),r=Rp(UC),o=Tg(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:WC})},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 VC(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function UC(t){return t.load}const td="pwa-install-toast-shown",sd="pwa-install-toast-dismissed",KC=()=>{const t=et.c(6),{browserTab:e}=Rg(),{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&&(_e.dismiss(d),d=null)},m=async()=>{if(!u)return;const w=u;u=null,h(),await w.prompt();const{outcome:S}=await w.userChoice;S==="accepted"&&_e.success(r.current("pwa.installPrompt.started"))},p=w=>{const S=w;if(typeof S.prompt!="function")return;S.preventDefault(),u=S;const x=No(),f=bf();Eg({dismissed:x.getItem(sd),sessionShown:f.getItem(td),hasActiveToast:d!==null})&&(f.setItem(td,"true"),d=_e.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{m()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{No().setItem(sd,"true"),h()}}}))},g=()=>{u=null,h(),_e.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)},HC=({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,m]=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 us("/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 Ep())})()},[t]),c.useEffect(()=>{if(!t)return;let f=!1;return(async()=>{try{const y=await us("/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():"";!f&&N&&a(N)}catch{}})(),()=>{f=!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")})]})})})},nd=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},GC=(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},qC=()=>{const t=Mp(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=Op(a),h=Fp(a),m=yi(a,"error"),p=yi(a,"error_description");if(m){h&&us(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(p??m);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 us(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(S.ok){const x=await S.json().catch(()=>null);w=x?.origin===Bp,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 us(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),w&&nd(!0),l("Authorization completed. You can close this tab and return to AiWorker.")}catch(g){h&&await us(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(GC(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:_p,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:()=>nd(r),children:"Return to AiWorker"})})]})})},rd=Ln(()=>Bn(()=>import("./OnboardingScreen-Cy6xZ-IQ.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=et.c(3),e=Te(t5),n=Te(s5);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(HC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},YC=t=>{const e=et.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 m;e[14]!==r||e[15]!==n||e[16]!==h?(m=s.jsx(xt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=m):m=e[17];let p;return e[18]!==d||e[19]!==m?(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,m]})}),e[18]=d,e[19]=m,e[20]=p):p=e[20],p},od=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",XC=()=>{if(typeof window>"u"||!cx())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}},JC=()=>typeof window>"u"?!1:window.location.pathname===Vp,ZC=t=>{const e=et.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=ss(n5),l=Ze(r5),a=Ze(o5),u=kd(),d=c.useRef(null);let h;e[0]!==n.directory?(h=od(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const m=h;let p;e[2]!==o?(p=od(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]!==m||e[9]!==r||e[10]!==a||e[11]!==u?(w=()=>{if(r||m&&g!==m)return;const N=`${m}
|
|
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,m,r,a,u],e[4]=g,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=m,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),m&&g!==m)return null;let x;e[14]!==i?(x=s.jsx(Xd,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=x):x=e[15];let f;e[16]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(lu,{}),e[16]=f):f=e[16];let b;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(b=s.jsx(au,{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,f,b,y]}),e[22]=x,e[23]=b,e[24]=v):v=e[24],v};function e5({apis:t}){c.useEffect(()=>{yf("App:mounted"),wf()&&console.info("[startup-trace] enabled. Run console.table(window.__AIWORKER_STARTUP_TRACE__) after startup.")},[]);const e=Yt(T=>T.initializeApp),n=Yt(T=>T.isInitialized),r=Yt(T=>T.isConnected),i=Yt(T=>T.providers.length),o=Yt(T=>T.agents.length),l=Yt(T=>T.loadProviders),a=Yt(T=>T.loadAgents),u=Ze(T=>T.error),d=Ze(T=>T.clearError),h=ss(T=>T.currentDirectory),m=ss(T=>T.setDirectory),p=ss(T=>T.isSwitchingDirectory),[g,w]=c.useState(!1),S=An(T=>T.refreshStatus),x=Ni(T=>T.refreshStatus),[f,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(()=>Qa()),[A,B]=c.useState(()=>{const T=Ya();return T!==null?Xa({isDesktopShell:!0,bootOutcome:T}):null}),X=c.useRef(!1),H=c.useMemo(()=>XC(),[]),Z=!H||y,ce=c.useMemo(()=>JC(),[]);c.useEffect(()=>(Ja(g),()=>{Ja(!1)}),[g]),c.useEffect(()=>(Gc(g),()=>{Gc(!1)}),[g]),c.useEffect(()=>{Sf(U)},[U]),c.useEffect(()=>{b(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>fa(T=>{Mg(T),I(Q=>Q+1),C(!1),D(Q=>Q+1)}),[]);const Y=hl(T=>{const Q=fs();return Object.values(T.runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===Q).map(le=>`${le.originalSessionID}:${le.phase}:${le.lastForwardedMessageID??""}:${le.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(H)return;const T=fs(),Q=Object.values(hl.getState().runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===T);for(const le of Q)Lp(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(()=>(Za(t),()=>Za(null)),[t]),c.useEffect(()=>{H||(S(t.github,{force:!0}),x(t.linear,{force:!0}))},[t.github,t.linear,H,r,S,x,P]),$p();const te=R==="valid",se=A?.screen==="main";c.useEffect(()=>{if(!vf({isDesktopShell:L,isInitialized:n,bootOutcomeKnown:te,bootViewIsMain:se}))return;const T=setTimeout(()=>{const Q=document.getElementById("initial-loading");Q&&(Q.classList.add("fade-out"),setTimeout(()=>{Q.remove()},300))},150);return()=>clearTimeout(T)},[L,n,te,se]),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 Q=document.getElementById("initial-loading");Q&&!n&&(Q.classList.add("fade-out"),setTimeout(()=>{Q.remove()},300))},5e3);return()=>clearTimeout(T)},[L,n]),c.useEffect(()=>{let T=!1;return(async()=>{const le=await us("/health",{method:"GET"}).catch(()=>null);if(!le||!le.ok||T)return;const me=await le.json().catch(()=>null);if(!me||T)return;const ue=me.planModeExperimentalEnabled;F(ue===!0||ue===1||ue==="1"||ue==="true")})(),()=>{T=!0}},[F]),c.useEffect(()=>{f||e()},[e,f]),c.useEffect(()=>{if(f||n)return;let T=!0,Q,le=0;const me=10,ue=1e3,Ce=async()=>{if(!T)return;if(le>=me){C(!0);return}const xe=Yt.getState();if(xe.isInitialized){C(!1);return}le+=1,await xe.initializeApp();const Re=Yt.getState();if(!T)return;if(Re.isInitialized){C(!1);return}if(le>=me){C(!0);return}const we=Math.min(ue*Math.pow(2,le-1),16e3);Q=setTimeout(Ce,we)};return Q=setTimeout(Ce,ue),()=>{T=!1,Q&&clearTimeout(Q)}},[k,n,f]),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(f||!r||i>0&&o>0)return;let T=!0,Q=0;const le=15,me=async()=>{const Ce=Yt.getState();if(!(Ce.providers.length>0&&Ce.agents.length>0))try{Ce.providers.length===0&&await l({source:"startupRecovery"}),Yt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};me();const ue=setInterval(()=>{if(T){if(++Q>=le){clearInterval(ue);return}me()}},2e3);return()=>{T=!1,clearInterval(ue)}},[r,f,a,l,i,o]),c.useEffect(()=>{p||f||r&&Xs.setDirectory(h)},[h,p,r,f]),c.useEffect(()=>{if(!H||typeof window>"u")return;const T=me=>{v(me?.visible===!0)},Q=me=>{if(me.origin!==window.location.origin||me.source!==window.parent)return;const ue=me.data;ue?.type===yu&&T(ue.payload)},le=window;return le.__aiworkerSetEmbeddedVisibility=T,window.addEventListener("message",Q),lx(),()=>{window.removeEventListener("message",Q),le.__aiworkerSetEmbeddedVisibility===T&&delete le.__aiworkerSetEmbeddedVisibility}},[H]),c.useEffect(()=>{!H?.directory||f||h!==H.directory&&m(H.directory,{showOverlay:!1})},[h,H,f,m]),c.useEffect(()=>{if(!H||typeof window>"u")return;const T=Q=>{Q.storageArea===window.localStorage&&Q.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=Q=>{const le=Q.detail,me=typeof le?.sessionId=="string"?le.sessionId.trim():"";if(!me)return;const ue=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null;Ze.getState().setCurrentSession(me,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 Q=Ze.getState().currentSessionId;Q&&Rd(Q)};return window.addEventListener("focus",T),()=>window.removeEventListener("focus",T)},[]),c.useEffect(()=>{if(typeof window>"u")return;const T=Q=>{const le=Q.detail,me=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,Ce=!!(me||ue);Te.getState().setSessionSwitcherOpen(!1),Ze.getState().openNewSessionDraft({target:Ce?"project":"chat",selectedProjectId:Ce?ue:null,directoryOverride:Ce?me:null,preserveDirectoryOverride:!!me})};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]),Wp({enabled:Z}),LC({enabled:Z}),zC(h||null),KC(),zp(),Lg(),Og();const ve=c.useCallback(()=>{w(T=>!T)},[]);bC(ve),IC(),EC(!H),c.useEffect(()=>{if(H)return;const T=()=>w(Q=>!Q);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,Q=0;const le=200,me=2e3,ue=50,Ce=()=>{if(T)return;Q++;const xe=Qa();if(xe!=="not-injected"){if(T=!0,j(xe),xe==="valid"){const we=Ya();we&&B(Xa({isDesktopShell:!0,bootOutcome:we}))}return}const Re=Math.min(le*Math.pow(1.1,Q),me);if(Q>=ue){const we=document.getElementById("initial-loading");we&&!we.textContent?.includes("taking longer")&&(we.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Ce,Re)};return window.setTimeout(Ce,le),()=>{T=!0}},[L,R]);const K=c.useCallback(async()=>{if(jf({isDesktopShell:bn(),isDesktopLocalOriginActive:Wo()})){await kf();return}window.location.reload()},[]),he=c.useCallback(async()=>{if(!M){C(!1),_(!0);try{await Yt.getState().initializeApp()}finally{_(!1)}Yt.getState().isInitialized||D(T=>T+1)}},[M]),be=T=>{if(T.screen==="recovery")return T.variant};if(L&&A&&A.screen!=="main"){if(A.screen==="chooser")return s.jsx(Qs,{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(rd,{mode:"first-launch",localAvailable:A.localAvailable!==!1,onCliAvailable:K,onChooseRemote:()=>{}})})})});const T=be(A),Q=A.screen==="recovery"&&"url"in A?A.url:void 0;return s.jsx(Qs,{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(rd,{mode:"recovery",recoveryVariant:T,recoveryHostUrl:Q,recoveryHostLabel:void 0,localAvailable:A.localAvailable!==!1,onCliAvailable:K})})})})}if(H)return s.jsx(Qs,{children:s.jsx(pl,{sdk:Xs.getSdkClient(),directory:h||"",children:s.jsx(gl,{apis:t,children:s.jsx(Ri,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(ZC,{embeddedSessionChat:H,isVSCodeRuntime:f,embeddedBackgroundWorkEnabled:Z}),s.jsx(xl,{}),s.jsx(bl,{})]})})})},P)});if(ce)return s.jsx(Qs,{children:s.jsx(qC,{})});if(N&&!n&&!f&&!H)return s.jsx(Qs,{children:s.jsx(YC,{onRetry:()=>{he()},isRetrying:M})});const ie=!n&&!L;return s.jsx(Qs,{children:s.jsx(pl,{sdk:Xs.getSdkClient(),directory:h||"",children:s.jsx(gl,{apis:t,children:s.jsx($3,{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(lu,{}),s.jsx(b3,{}),s.jsx(Jd,{}),s.jsx(xl,{}),s.jsx(bl,{}),!ie&&s.jsxs(s.Fragment,{children:[s.jsx(Fg,{}),s.jsx(QC,{}),g&&s.jsx(J3,{onClose:()=>w(!1)})]})]})})})})},P)})}function t5(t){return t.isAboutDialogOpen}function s5(t){return t.setAboutDialogOpen}function n5(t){return t.currentDirectory}function r5(t){return t.currentSessionId}function o5(t){return t.setCurrentSession}const i5=typeof window<"u"&&window.__AIWORKER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Up();Cf().then(()=>{Promise.all([Nf(),Kp()]).catch(t=>{console.error("[main] settings init failed:",t)}),Hp(),Gp(),qp()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Rm=document.getElementById("root");if(!Rm)throw new Error("Root element not found");Qp();Hm.createRoot(Rm).render(s.jsx(gt.StrictMode,{children:s.jsx(Yp,{children:s.jsx(Xp,{children:s.jsx(Jp,{children:s.jsx(Zp,{children:s.jsx(e5,{apis:i5})})})})})}));const k5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Vb as W,Rb as a,j5 as b,zu as g,k5 as m,zb as u,Wu as v};
|