@vantran-se/openchamber-web 2.0.1 → 2.0.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.
Files changed (60) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-ntXIbhV2.js → CodeMirrorCommentWidgets-CWhdh0wf.js} +1 -1
  2. package/dist/assets/{DiffView-CjxUovbM.js → DiffView-CX3wAX2S.js} +1 -1
  3. package/dist/assets/{FilesView-DFWD0RQR.js → FilesView-OL3CON3r.js} +1 -1
  4. package/dist/assets/{GitView-BWa7e5vw.js → GitView-DKIjpnu4.js} +1 -1
  5. package/dist/assets/{GuestAttachDialog-DdOuyZzp.js → GuestAttachDialog-BIa9jCfL.js} +1 -1
  6. package/dist/assets/{GuestSurfacePane-DDfzid3U.js → GuestSurfacePane-B_cqX5I5.js} +1 -1
  7. package/dist/assets/{JsonTreeView-3sGwqexh.js → JsonTreeView-CtI1Mqwo.js} +1 -1
  8. package/dist/assets/{LinearIssuesView-C6dpIdjw.js → LinearIssuesView-BD2zLu-r.js} +1 -1
  9. package/dist/assets/{MarkdownImageGallery-Q7YR_tl4.js → MarkdownImageGallery-DFiTFZgj.js} +1 -1
  10. package/dist/assets/{MarkdownRendererImpl-DxDV56bL.js → MarkdownRendererImpl-DZm5sf1W.js} +1 -1
  11. package/dist/assets/{OnboardingScreen-rK4Stg__.js → OnboardingScreen-B8TxloXZ.js} +1 -1
  12. package/dist/assets/{PatchDiff-DS-IMU1j.js → PatchDiff--Civs1xY.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-DW23KWKZ.js → PierreDiffViewer-BlDmw3-A.js} +1 -1
  14. package/dist/assets/{PlanView-BCk_VobP.js → PlanView-DyH2SyCP.js} +1 -1
  15. package/dist/assets/{PluginPane-BPP1dbck.js → PluginPane-BibJit86.js} +1 -1
  16. package/dist/assets/{SettingsView-kMmrpn43.js → SettingsView-h-VpVO47.js} +1 -1
  17. package/dist/assets/{SettingsWindow-BpvD6IYQ.js → SettingsWindow-y9WpZqK6.js} +1 -1
  18. package/dist/assets/{SubmoduleDiffSummary-BLttSS1X.js → SubmoduleDiffSummary-DeFmhPFZ.js} +1 -1
  19. package/dist/assets/{ToolOutputDialog-CtqDqbyr.js → ToolOutputDialog-8DmF7_PZ.js} +1 -1
  20. package/dist/assets/{ToolPartDiffPreview-5FcKdyRy.js → ToolPartDiffPreview-Ca15DKE1.js} +1 -1
  21. package/dist/assets/{VirtualizedFileDiff-C763hNCR.js → VirtualizedFileDiff-BfEBad09.js} +1 -1
  22. package/dist/assets/{WalkthroughView-lap5btCF.js → WalkthroughView-Cj3K8Xz6.js} +1 -1
  23. package/dist/assets/{appThemeRegistry-u4zw1l0B.js → appThemeRegistry-DAdawJZn.js} +1 -1
  24. package/dist/assets/{commitAndPush-CwGJfJG-.js → commitAndPush-BIPfOMXY.js} +1 -1
  25. package/dist/assets/{computeVirtualFileMetrics-DW5jjX4n.js → computeVirtualFileMetrics-RF-KjfUH.js} +1 -1
  26. package/dist/assets/{de-CndEg67T.js → de-BqCNGROu.js} +1 -1
  27. package/dist/assets/{es-DglvPlaC.js → es-BTPpTRgN.js} +1 -1
  28. package/dist/assets/{fr-DejPCpbS.js → fr-hxbzMdAg.js} +1 -1
  29. package/dist/assets/{index-C2r64QfD.js → index-CL7ZQ94-.js} +1 -1
  30. package/dist/assets/{isDiffPlainText-D47a6hMP.js → isDiffPlainText-D2yJ9fO6.js} +1 -1
  31. package/dist/assets/{isFilePlainText-B-mGgeKl.js → isFilePlainText-BwMEq1Ey.js} +1 -1
  32. package/dist/assets/{ja-CVpQawCd.js → ja-_zLwwYiy.js} +1 -1
  33. package/dist/assets/{ko-Bw446h9j.js → ko-CFn3Dzhc.js} +1 -1
  34. package/dist/assets/{main-oreqDsOV.js → main-BLJaug9I.js} +4 -4
  35. package/dist/assets/{main-Bz4WWXbr.js → main-quLSA7jc.js} +2 -2
  36. package/dist/assets/{markdownCore-D2e5sp9y.js → markdownCore-DS9FdwrI.js} +1 -1
  37. package/dist/assets/{miniChat-D1v2gsBI.js → miniChat-D-lJJibr.js} +2 -2
  38. package/dist/assets/{mobile-DBj3lCf2.js → mobile-VTtphbW6.js} +2 -2
  39. package/dist/assets/{patchFileDiff-BpeUOV91.js → patchFileDiff-D9iBcTEi.js} +1 -1
  40. package/dist/assets/{pl-BYNlPdhm.js → pl-DFHE7xac.js} +1 -1
  41. package/dist/assets/{pt-BR-CL-Yfv9H.js → pt-BR-CUjZF179.js} +1 -1
  42. package/dist/assets/{renderElectronMiniChatApp-DVtfEB2z.js → renderElectronMiniChatApp-DF7ch5eM.js} +2 -2
  43. package/dist/assets/{renderMobileApp-DFp9-xbG.js → renderMobileApp-CNQhdXsi.js} +3 -3
  44. package/dist/assets/{runtimeEndpointReset-CsIpUep1.js → runtimeEndpointReset-DeaERc0M.js} +3 -3
  45. package/dist/assets/{scheduledTasksApi-B5OHVpPM.js → scheduledTasksApi-BD6Vx9pu.js} +1 -1
  46. package/dist/assets/{shikiHighlight-DNm2Z_Jc.js → shikiHighlight-_HeCCHx1.js} +1 -1
  47. package/dist/assets/{textMateThemeFromAppTheme-DGF2kG7g.js → textMateThemeFromAppTheme-C95XdFGj.js} +1 -1
  48. package/dist/assets/{tr-DzmbxLy-.js → tr-BB6sA_zH.js} +1 -1
  49. package/dist/assets/{uk-C7vQnwro.js → uk-CB4o8g-o.js} +1 -1
  50. package/dist/assets/{useAppFontEffects-Ci3FEaPf.js → useAppFontEffects-ZM9ij19-.js} +48 -48
  51. package/dist/assets/{useInlineCommentController-CuUuakrt.js → useInlineCommentController-CkfxMJPy.js} +1 -1
  52. package/dist/assets/{useRootScrollLock-CQIsyERq.js → useRootScrollLock-BtiAC1fj.js} +2 -2
  53. package/dist/assets/{vendor-codemirror-language-data-CQa7_1cr.js → vendor-codemirror-language-data-U-lXzXNK.js} +2 -2
  54. package/dist/assets/{web-components-B6tKQyJN.js → web-components-C583Pmfm.js} +1 -1
  55. package/dist/assets/{zh-CN-Cl0srS-z.js → zh-CN-BRyDuWhc.js} +1 -1
  56. package/dist/assets/{zh-TW-DtII5bDb.js → zh-TW-BDGbWA1Q.js} +1 -1
  57. package/dist/index.html +1 -1
  58. package/dist/mini-chat.html +1 -1
  59. package/dist/mobile.html +1 -1
  60. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-lap5btCF.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-Ci3FEaPf.js","assets/index-CvLgnuNI.js","assets/vendor-zod-Gea9uBlY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-_BAHQo4R.js","assets/index-CLcM8HKx.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.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-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/contextPanelEmbeddedChat-CirXEPJq.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-CQa7_1cr.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-BpeUOV91.js","assets/runtimeEndpointReset-CsIpUep1.js","assets/GuestAttachDialog-DdOuyZzp.js","assets/PluginPane-BPP1dbck.js","assets/VirtualizedFileDiff-C763hNCR.js","assets/web-components-B6tKQyJN.js","assets/computeVirtualFileMetrics-DW5jjX4n.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-D47a6hMP.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-DW23KWKZ.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-CuUuakrt.js","assets/appThemeRegistry-u4zw1l0B.js","assets/textMateThemeFromAppTheme-DGF2kG7g.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-CQIsyERq.js","assets/scheduledTasksApi-B5OHVpPM.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-CjxUovbM.js","assets/SubmoduleDiffSummary-BLttSS1X.js","assets/FilesView-DFWD0RQR.js","assets/shikiHighlight-DNm2Z_Jc.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-3sGwqexh.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-B-mGgeKl.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-ntXIbhV2.js","assets/GitView-BWa7e5vw.js","assets/commitAndPush-CwGJfJG-.js","assets/LinearIssuesView-C6dpIdjw.js","assets/PlanView-BCk_VobP.js","assets/GuestSurfacePane-DDfzid3U.js","assets/SettingsWindow-BpvD6IYQ.js","assets/SettingsView-kMmrpn43.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-rK4Stg__.js"])))=>i.map(i=>d[i]);
2
- import{f as tt,R as c,j as s,r as ut,c as Om,h as Bm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{E as xn,F as Zo,H as Fm,I as _m,h as bs,x as Od,u as Ne,J as Mt,K as pl,a as Qt,y as Cr,o as xt,L as Ts,N as qr,O as _n,P as Bd,Q as Lm,R as $m,S as zm,T as Wm,U as Fd,n as os,V as Fn,W as Yr,e as Dn,X as Km,Y as Vm,Z as Um,_ as Hm,$ as _d,v as pn,B as dn,a0 as Gm,a1 as gl,a2 as qm,a3 as Ld,a4 as Ym,a5 as $d,f as Qm,a6 as Qn,a7 as tr,a8 as Fo,a9 as Ui,aa as Xm,ab as Ma,d as _o,t as Fr,q as Ns,ac as zd,ad as Jm,ae as Hi,af as Wd,ag as Kd,i as Zm,ah as Po,ai as Do,aj as eh,ak as xl,al as th,am as sh,an as nh,ao as rh,ap as bl,aq as yl,ar as wl,as as vl,at as oh,A as Sl,au as ih,av as ah,aw as lh,C as ch,D as dh}from"./index-CvLgnuNI.js";import{_ as yn}from"./vendor-vite-runtime-DD1OZmLC.js";import{y as jl,z as ki,E as an,F as Gi,G as kl,H as uh,I as fh,J as mh,K as hh,L as ph,M as gh,Q as xh,R as bh,V as Oa,a as yh,e as Vd,W as Ud,h as qi,l as Hd,X as wh,k as vh,j as Sh,Y as Gd,Z as Yi,_ as Xn,$ as qd,a0 as Yd,P as jh,T as kh,a1 as Ch,a2 as Nh,a3 as Ah,b as Qd,a4 as Ph,a5 as Xd,a6 as Lo,a7 as Dh,a8 as Ih,a9 as Th,S as Ci,aa as Jd,ab as Zd,d as Eh,ac as Rh,c as Mh,ad as Oh,r as Cl,ae as Bh,af as Fh,ag as lo,u as Kr,s as _h,N as Lh,D as $h,ah as zh,ai as Nl,aj as Wh,ak as Ni,v as Kh,o as Vh,w as eu,U as Uh,x as Hh,al as Gh,am as qh,an as Yh,O as Qh,n as Xh,q as Jh,t as tu,A as Zh,C as ep}from"./runtimeEndpointReset-CsIpUep1.js";import{f as Nt,h as Ee,bh as Ht,I as _,g as cr,t as Ke,at as Fs,bi as Es,av as _s,as as Ls,T as Ln,_ as wn,ai as dr,bj as $n,o as eo,bk as Al,bl as tp,bm as sp,ae as vt,af as St,ag as jt,b as Ut,z as rt,H as np,bn as su,bo as co,u as vs,r as As,D as nu,C as ru,bp as Qi,bq as rp,br as ou,bs as iu,S as Ba,bt as op,bu as ip,bv as Pl,bw as Dl,bx as au,by as ap,bz as Il,bA as lp,bB as cp,bC as Fa,bD as Xi,bE as lu,bF as dp,bG as up,bH as fp,Q as cu,bI as mp,bJ as hp,bK as pp,n as hr,bL as du,bM as gp,bN as xp,p as bp,bO as uu,bP as yp,bQ as wp,bR as vp,bS as fu,bT as mu,bU as hu,bV as pu,bW as gu,bX as xu,bY as bu,bZ as to,b_ as _a,aJ as La,b$ as sr,c0 as so,c1 as Sp,c2 as Ps,c3 as Ds,c4 as sn,c5 as Us,c6 as Hs,c7 as zn,B as ct,c8 as En,aB as Cs,c9 as jp,ca as kp,aH as In,cb as _r,cc as Vs,cd as ei,ce as yu,cf as Ji,cg as Zi,ch as ea,ci as Cp,cj as Rs,ck as Ms,cl as js,cm as Os,cn as rs,X as An,co as pr,cp as Tl,cq as xr,cr as wu,R as ti,aj as Np,ak as $a,al as vu,J as Su,K as Tn,cs as za,a9 as Wa,ct as Ap,cu as Pp,az as Dp,cv as Ip,cw as ju,cx as Tp,cy as Ep,aA as Ka,cz as Rp,cA as ku,cB as br,cC as Cu,cD as Mp,l as Yt,s as Op,cE as Bp,cF as Fp,aO as Wn,cG as _p,cH as mr,O as Nu,cI as Lp,cJ as $p,cK as Kn,cL as zp,cM as Wp,aD as Kp,cN as Ai,cO as Vp,cP as Up,cQ as Hp,cR as Au,cS as Va,cT as Gp,cU as Pu,cV as qp,aI as ta,cW as sa,cX as El,cY as Yp,cZ as Rl,c_ as Lr,c as Qr,d as Ua,a4 as Qp,a1 as Du,c$ as Dr,d0 as $r,d1 as Xp,d2 as Jp,d3 as Zp,$ as Ha,aC as eg,d4 as tg,d5 as sg,d6 as ng,d7 as rg,d8 as Iu,d9 as un,da as og,db as Tu,dc as ig,a8 as na,dd as ag,de as Eu,df as ms,dg as lg,dh as cg,di as dg,dj as Ru,dk as ug,dl as Ga,dm as Mu,a6 as $o,dn as ra,dp as si,a as qa,dq as Ya,a5 as fg,dr as Ml,U as ni,V as ri,W as oi,ds as mg,dt as oa,du as Ou,dv as hg,au as Bu,dw as pg,dx as Qa,P as ia,L as gg,dy as Ol,dz as xg,dA as bg,dB as ss,dC as yg,dD as ir,dE as Fu,dF as _u,dG as Lu,dH as $u,dI as wg,E as vg,dJ as Sg,dK as jg,dL as kg,dM as Bl,dN as zu,dO as Cg,dP as Wu,F as Ng,dQ as Ag,dR as Pg,dS as Vr,dT as Dg,dU as Ig,dV as Tg,dW as Eg,e as Xa,dX as ii,dY as Rg,dZ as Xr,a3 as Mg,G as ai,d_ as Og,d$ as Bg,e0 as Fl,e1 as Fg,e2 as _g,a0 as Lg,e3 as $g,e4 as zg,a$ as _l,ab as Ll,aa as $l,e5 as Wg,aW as aa,e6 as Kg,M as Vg,N as Pi,e7 as Ug,e8 as Hg,e9 as Ku,ea as Vu,eb as Uu,ec as Gg,ed as qg,a7 as Yg,am as Qg,ee as Xg,ef as zl,eg as Jg,eh as Zg,ei as ex,ej as tx,ek as zo,el as sx,em as Wl,en as nx,eo as rx,ep as ox,eq as ix,er as la,es as ax,et as Io,eu as lx,i as cx,ev as dx,ew as ux,ex as fx,ey as mx,ez as hx,eA as px,eB as Kl,eC as gx,aP as xx,aQ as bx,aS as yx,aR as wx,aU as Vl,aV as Ul,aY as Hl,aZ as Gl,aX as Hu,a_ as Gu,eD as vx,bc as Sx,bd as jx,be as kx,bf as Cx,bg as Nx,b6 as Ax,b8 as Px,b9 as Dx,ba as Ix,bb as Tx}from"./useAppFontEffects-Ci3FEaPf.js";import{u as qu,S as ql,C as Ex,t as Rx,W as Yu,f as Mx,G as Ox,a as Bx}from"./useRootScrollLock-CQIsyERq.js";import{u as Un,O as Yl,D as Fx,a as _x,b as Lx,c as $x,f as zx,d as Ql,s as Wx,e as Kx,g as Vx,r as Ux}from"./scheduledTasksApi-B5OHVpPM.js";import{f as li,h as Pn,T as ci,M as di,D as ui,j as fi,d as Hx,b as Gx,k as qx,i as Yx}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as mi,S as Ja,h as Qx,a as Qu,v as Xu,s as Xx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as hi}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Ju,M as Zu,C as ef,a as ca,b as da,c as ua,d as tf,e as Jx,f as Zx}from"./vendor-base-ui-CsXYnR5c.js";import{c as no,u as ar,d as eb,p as tb}from"./vendor-zustand-BAGL70zf.js";import{g as sb,a as nb,E as sf,b as rb,c as ob,d as ib,e as ab,i as lb}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as cb}from"./PluginPane-BPP1dbck.js";import{a as Za,s as lr,r as nf,o as Xl,b as Jl}from"./vendor-zod-Gea9uBlY.js";import{u as db}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as ub}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as rf}from"./vendor-cron-parser-CjvYVigk.js";const fb="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",mb="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",Di=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?fb:t.id==="terminal"?mb:void 0}),Zl=t=>{const e=tt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let y;return e[3]!==u?(y=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=u,e[4]=y):y=e[4],y}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=Ee("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=m):m=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:m,children:d}),e[6]=d,e[7]=f):f=e[7],f},hb=t=>{const e=tt.c(75),{directory:n,className:r}=t,{t:i}=Nt(),o=Un(pb),l=Un(gb),a=Un(xb),d=Un(bb),u=Un(yb),m=Un(wb),f=Un(vb);let p,y;e[0]!==u?(p=()=>{u()},y=[u],e[0]=u,e[1]=p,e[2]=y):(p=e[1],y=e[2]),c.useEffect(p,y);const x=xn()&&Zo();let k;e:{let be;e[3]!==l||e[4]!==o?(be=l.find(H=>H.id===o)??l.find(Sb)??l[0]??Yl[0],e[3]=l,e[4]=o,e[5]=be):be=e[5];const fe=be;if(fe){let H;e[6]!==fe?(H=Di(fe),e[6]=fe,e[7]=H):H=e[7],k=H;break e}let ke;e[8]===Symbol.for("react.memo_cache_sentinel")?(ke=Di(Yl[0]),e[8]=ke):ke=e[8],k=ke}const w=k;if(!x||!n||l.length===0)return null;let h;e[9]!==n?(h=async be=>{await Fm(n,be.id,be.appName)||await _m(n,be.appName)},e[9]=n,e[10]=h):h=e[10];const g=h;let j;e[11]!==g||e[12]!==f?(j=async be=>{await f(be.id),await g(be)},e[11]=g,e[12]=f,e[13]=j):j=e[13];const b=j;let S;e[14]!==n||e[15]!==i?(S=async()=>{(await cr(n)).ok&&Ke.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=S):S=e[16];const C=S;let v;e[17]!==r?(v=Ee("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]=v):v=e[18];let E;e[19]!==g||e[20]!==w?(E=()=>{g(w)},e[19]=g,e[20]=w,e[21]=E):E=e[21];const R=d&&"animate-pulse";let A;e[22]!==R?(A=Ee("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",R),e[22]=R,e[23]=A):A=e[23];let O;e[24]!==w.label||e[25]!==i?(O=i("openInApp.actions.openInAria",{app:w.label}),e[24]=w.label,e[25]=i,e[26]=O):O=e[26];let B;e[27]!==w.fallbackIconDataUrl||e[28]!==w.iconDataUrl||e[29]!==w.label?(B=s.jsx(Zl,{label:w.label,iconDataUrl:w.iconDataUrl,fallbackIconDataUrl:w.fallbackIconDataUrl}),e[27]=w.fallbackIconDataUrl,e[28]=w.iconDataUrl,e[29]=w.label,e[30]=B):B=e[30];let T;e[31]!==A||e[32]!==O||e[33]!==B||e[34]!==E?(T=s.jsx("button",{type:"button",onClick:E,className:A,"aria-label":O,children:B}),e[31]=A,e[32]=O,e[33]=B,e[34]=E,e[35]=T):T=e[35];let M;e[36]===Symbol.for("react.memo_cache_sentinel")?(M=Ee("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]=M):M=e[36];let L;e[37]!==i?(L=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=L):L=e[38];let W;e[39]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=W):W=e[39];let $;e[40]!==L?($=s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:M,"aria-label":L,children:W})}),e[40]=L,e[41]=$):$=e[41];let P;e[42]!==C?(P=()=>{C()},e[42]=C,e[43]=P):P=e[43];let D;e[44]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(_,{name:"file-copy",className:"h-4 w-4"}),e[44]=D):D=e[44];let I;e[45]!==i?(I=i("openInApp.actions.copyPath"),e[45]=i,e[46]=I):I=e[46];let X;e[47]!==I?(X=s.jsx("span",{className:"typography-ui-label text-foreground",children:I}),e[47]=I,e[48]=X):X=e[48];let Z;e[49]!==P||e[50]!==X?(Z=s.jsxs(Ht,{className:"flex items-center gap-2",onClick:P,children:[D,X]}),e[49]=P,e[50]=X,e[51]=Z):Z=e[51];let ne;e[52]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(Es,{}),e[52]=ne):ne=e[52];let ue;if(e[53]!==l||e[54]!==b||e[55]!==w.id){let be;e[57]!==b||e[58]!==w.id?(be=fe=>{const ke=Di(fe);return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{b(fe)},children:[s.jsx(Zl,{label:fe.label,iconDataUrl:fe.iconDataUrl,fallbackIconDataUrl:ke.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:fe.label}),w.id===fe.id?s.jsx(_,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},fe.id)},e[57]=b,e[58]=w.id,e[59]=be):be=e[59],ue=l.map(be),e[53]=l,e[54]=b,e[55]=w.id,e[56]=ue}else ue=e[56];let se;e[60]!==a||e[61]!==m||e[62]!==i?(se=a?s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(_,{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]=m,e[62]=i,e[63]=se):se=e[63];let xe;e[64]!==Z||e[65]!==ue||e[66]!==se?(xe=s.jsxs(_s,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Z,ne,ue,se]}),e[64]=Z,e[65]=ue,e[66]=se,e[67]=xe):xe=e[67];let ie;e[68]!==$||e[69]!==xe?(ie=s.jsxs(Ls,{children:[$,xe]}),e[68]=$,e[69]=xe,e[70]=ie):ie=e[70];let Re;return e[71]!==T||e[72]!==ie||e[73]!==v?(Re=s.jsxs("div",{className:v,children:[T,ie]}),e[71]=T,e[72]=ie,e[73]=v,e[74]=Re):Re=e[74],Re};function pb(t){return t.selectedAppId}function gb(t){return t.availableApps}function xb(t){return t.isCacheStale}function bb(t){return t.isScanning}function yb(t){return t.initialize}function wb(t){return t.loadInstalledApps}function vb(t){return t.selectApp}function Sb(t){return t.id===Fx}const Wo=new Map,fa=new Set,of=()=>{for(const t of fa)t()},Ii=(t,e)=>{const n=t.trim();n&&(e.length===0?Wo.delete(n):Wo.set(n,[...e]),of())},jb=t=>{Wo.delete(t.trim())&&of()},af=[],kb=t=>Wo.get(t.trim())??af,Cb=t=>(fa.add(t),()=>{fa.delete(t)}),Nb=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=()=>kb(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(Cb,n,Ab)};function Ab(){return af}const Pb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Db=["dev","start","preview","serve"];async function Ib(t,e,n){if(!t)return null;const r=Rb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Mb(n);if(i){const o=await Ob(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 Tb(t)){const i=await Eb(),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 Tb(t){const e=`${t}/index.html`,n=await Ko(e,t);return typeof n=="string"&&n.trim().length>0}async function Eb(){try{const t=await bs("/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 Rb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Db.some(i=>n.includes(i)))return e}return null}function Mb(t){for(const{pattern:e}of Pb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ob(t){const e=await Ko(`${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 Ko(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ko(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await bs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Od()?.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 bs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Bb(t){try{const e=await Ko(`${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 cn="__openchamber_auto_discover_preview__",Fb=15e3,_b=3e3,Ti=t=>t.id===cn?"scan-2":bh.find(n=>n.key===t.icon)?.Icon??"play",Lb=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}},$b=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=Nt(),{currentTheme:l}=Ln(),{terminal:a,runtime:d}=wn(),u=dr(),{isMobile:m}=$n(),f=c.useMemo(()=>xn(),[]),p=jl(te=>te.instances),y=jl(te=>te.load),x=Ne(te=>te.terminalShell),k=Ne(te=>te.terminalLoginShells.includes(te.terminalShell)),w=Ne(te=>te.setSettingsPage),h=Ne(te=>te.setSettingsDialogOpen),g=Ne(te=>te.setSettingsProjectsSelectedId),j=Ne(te=>te.openContextPreview),b=Mt(te=>te.ensureDirectory),S=Mt(te=>te.reconcileServerSessions),C=Mt(te=>te.setTabLabel),v=Mt(te=>te.setTabIconKey),E=Mt(te=>te.setActiveTab),R=Mt(te=>te.setConnecting),A=Mt(te=>te.setTabSessionId),O=Mt(te=>te.setTabPurpose),B=Mt(te=>te.allocateActionExecution),T=Mt(te=>te.setTabLifecycle),M=Mt(te=>te.setTabPreviewUrl),L=Mt(te=>te.matchesActionExecution),W=Mt(te=>te.captureStartedActionMutationRevisions),[$,P]=c.useState([]),D=c.useRef(null),[I,X]=c.useState(null),[Z,ne]=c.useState(!1),ue=c.useRef({}),se=c.useRef({}),xe=c.useRef({}),ie=c.useRef(new Set),Re=c.useRef(0),[be,fe]=c.useState({}),ke=t?.id??null,H=t?.path??"",J=c.useMemo(()=>ke?{id:ke,path:H}:null,[ke,H]);c.useEffect(()=>{f&&y().catch(()=>{})},[f,y]);const ce=c.useCallback(async te=>{await eo(te)},[]),je=c.useCallback(async()=>{if(!J)return;const te=Re.current+1;Re.current=te,ne(!0);try{const me=await Al(J);if(Re.current!==te)return;D.current=me;const De=me.projectActions;P(De),X(K=>K===cn||K&&De.some(Se=>Se.id===K)?K:null)}catch{if(Re.current!==te)return}finally{Re.current===te&&ne(!1)}},[J]),G=c.useMemo(()=>ki(e||J?.path||""),[e,J?.path]),we=c.useMemo(()=>ki(J?.path||""),[J?.path]),Te=c.useMemo(()=>ki(u||"")||G,[u,G]),he=c.useRef(Te);c.useEffect(()=>{he.current=Te},[Te]);const re=Mt(te=>G?te.getDirectoryState(G):void 0),ge=Mt(te=>we&&we!==G?te.getDirectoryState(we):void 0),q=c.useMemo(()=>{const te=G?[{directory:G,state:re}]:[];return we&&we!==G&&te.push({directory:we,state:ge}),te},[re,G,we,ge]),z=c.useMemo(()=>{const te=G?[G]:[];return we&&we!==G&&te.push(we),te},[G,we]),ee=c.useCallback(te=>te.id!==cn&&te.runIn==="parent"&&we||G,[G,we]),de=c.useCallback((te,me,De)=>`${te}::${me}::${De}`,[]),Y=c.useCallback((te,me,De=Mt.getState())=>te?De.getDirectoryState(te)?.tabs.find(K=>K.purpose.type==="project-action"&&K.purpose.actionId===me)??null:null,[]),U=c.useMemo(()=>{const te={};for(const{directory:me,state:De}of q)for(const K of De?.tabs??[]){if(K.purpose.type!=="project-action"||!K.purpose.executionId||!K.terminalSessionId||K.lifecycle==="idle"||K.lifecycle==="exited")continue;const Se=an(me,K.purpose.actionId),Ve=de(me,K.purpose.actionId,K.purpose.executionId);te[Se]={directory:me,actionId:K.purpose.actionId,tabId:K.id,sessionId:K.terminalSessionId,executionId:K.purpose.executionId,status:K.lifecycle==="stopping"?"stopping":be[Ve]?"waiting-for-preview":"running"}}return te},[de,be,q]),F=c.useCallback((te,me,De)=>{const K=an(te,me),Se=de(te,me,De),Xe=ue.current[K]?.executionId===De,nt=globalThis.window,Ze=gt=>{nt?.clearTimeout(xe.current[gt]),delete xe.current[gt]};Xe&&(delete ue.current[K],Ze(K)),se.current[Se]?.(),delete se.current[Se],Ze(Se),fe(gt=>{if(!gt[Se])return gt;const We={...gt};return delete We[Se],We})},[de]),V=c.useCallback(te=>{se.current[te]?.(),delete se.current[te]},[]),oe=c.useCallback(te=>{window.clearTimeout(xe.current[te]),delete xe.current[te]},[]);c.useEffect(()=>{const te=se.current,me=xe.current;return()=>{for(const De of Object.keys(te))V(De);for(const De of Object.keys(me))oe(De)}},[oe,V]),c.useEffect(()=>{const te=new Set(z);for(const me of Object.values(ue.current))te.has(me.directory)||F(me.directory,me.actionId,me.executionId);for(const me of Object.keys(se.current)){const De=me.split("::",1)[0]??"";te.has(De)||V(me)}},[F,V,z]);const ae=c.useCallback((te,me)=>{Ne.getState().openContextPanelTab(te,{mode:"terminal",targetDirectory:me===te?null:me})},[]),pe=c.useMemo(()=>I?$.find(te=>te.id===I)??null:null,[$,I]),le=c.useMemo(()=>({id:cn,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),_e=!m,Fe=c.useMemo(()=>_e?[le,...$]:$,[$,le,_e]);c.useEffect(()=>{je()},[je]),c.useEffect(()=>{const te=z.map(me=>Gi(a,me,W,De=>S(me,De.sessions,{startedActionMutationRevisions:De.startedActionMutationRevisions})));return()=>{for(const me of te)me()}},[W,S,a,z]),c.useEffect(()=>{for(const{directory:te,state:me}of q)if(te)for(const De of me?.tabs??[]){if(De.purpose.type!=="project-action")continue;const K=De.purpose.actionId,Se=Fe.find(nt=>nt.id===K),Ve=Se?.name??K,Xe=Se?.icon||"play";De.label!==Ve&&C(te,De.id,Ve),De.iconKey!==Xe&&v(te,De.id,Xe)}},[Fe,v,C,q]),c.useEffect(()=>{const te=globalThis.window;if(!te)return;const me=De=>{const K=De.detail;ke&&(K?.projectId&&K.projectId!==ke||je())};return te.addEventListener(kl,me),()=>{te.removeEventListener(kl,me)}},[je,ke]),c.useEffect(()=>{I&&(I===cn&&_e||$.some(te=>te.id===I)||X(null))},[$,_e,I]),c.useEffect(()=>{const te=De=>{delete xe.current[De];const K=ue.current[De];if(!K||K.openedUrl)return;const Se=de(K.directory,K.actionId,K.executionId),Ve=K.announced;if(Ve.length!==0){if(window.clearTimeout(xe.current[Se]),delete xe.current[Se],K.openedUrl=!0,fe(Xe=>{if(!Xe[Se])return Xe;const nt={...Xe};return delete nt[Se],nt}),Ve.length===1){Ii(K.directory,[]),M(K.directory,K.tabId,Ve[0],{locked:!1,autoOpened:!0}),j(K.directory,Ve[0]);return}K.offering=!0,Ii(K.directory,Ve),Ne.getState().openContextSurface(K.directory,"browser"),Ke.info(o("projectActions.toast.multipleServers"))}},me=()=>{const De=Mt.getState(),K=De.sessions,Se=U;for(const[Ve,Xe]of Object.entries(Se)){const Ze=K.get(Xe.directory)?.tabs.find(ve=>ve.id===Xe.tabId);if(!Ze||Ze.terminalSessionId!==Xe.sessionId){F(Xe.directory,Xe.actionId,Xe.executionId);continue}const gt=ue.current[Ve],We=gt?.executionId===Xe.executionId?gt:{hostDirectory:he.current||Xe.directory,directory:Xe.directory,tabId:Xe.tabId,actionId:Xe.actionId,executionId:Xe.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ue.current[Ve]=We;const Et=Fe.find(ve=>ve.id===Xe.actionId),Ft=De.getBuffer(Xe.directory,Xe.tabId).chunks;if(!Et||Ft.length===0)continue;const Ie=Ft.filter(ve=>We.lastSeenChunkId===null||ve.id>We.lastSeenChunkId);if(Ie.length===0)continue;const yt=Ie.map(ve=>ve.data).join(""),At=`${We.tail}${yt}`;if(We.openInPreview&&(!We.openedUrl||We.offering)){const ve=gh(At),Qe=We.announced.length;for(const Ye of ve)We.announced.includes(Ye)||We.announced.push(Ye);const qe=We.announced.length-Qe;We.offering&&qe>0?Ii(Xe.directory,We.announced):!We.openedUrl&&Qe===0&&We.announced.length>0&&(window.clearTimeout(xe.current[Ve]),xe.current[Ve]=window.setTimeout(()=>te(Ve),_b))}const He=!We.openedUrl&&Et.autoOpenUrl===!0&&!We.openInPreview?xh(At):null,Ue=Ie[Ie.length-1]?.id??We.lastSeenChunkId;if(We.lastSeenChunkId=Ue,We.tail=At.slice(-512),He)if(We.openedUrl=!0,We.openInPreview){const ve=Se[Ve];ve&&(M(ve.directory,ve.tabId,He,{locked:!1,autoOpened:!1,expectedExecutionId:ve.executionId}),ve.status==="waiting-for-preview"&&fe(Qe=>{const qe=de(ve.directory,ve.actionId,ve.executionId);if(!Qe[qe])return Qe;const Ye={...Qe};return delete Ye[qe],Ye}),window.clearTimeout(xe.current[Ve]),delete xe.current[Ve],j(ve.directory,He))}else ce(He),Ke.success(o("projectActions.toast.openedUrlFromOutput"));ue.current[Ve]=We}for(const Ve of Object.keys(ue.current))if(!Se[Ve]){const Xe=ue.current[Ve],nt=Xe?K.get(Xe.directory)?.tabs.find(gt=>gt.id===Xe.tabId):void 0;if(nt?.purpose.type==="project-action"&&nt.purpose.executionId===Xe?.executionId&&!!nt.terminalSessionId&&nt.lifecycle!=="idle"&&nt.lifecycle!=="exited")continue;delete ue.current[Ve],window.clearTimeout(xe.current[Ve]),delete xe.current[Ve]}};return me(),Mt.subscribe((De,K)=>{(De.sessions!==K.sessions||De.buffers!==K.buffers)&&me()})},[F,he,Fe,de,j,ce,U,M,o]),c.useEffect(()=>{for(const{directory:te,state:me}of q)for(const De of me?.tabs??[]){if(De.purpose.type!=="project-action"||!De.purpose.executionId||!De.terminalSessionId||De.lifecycle!=="running")continue;const K=De.purpose.actionId,Se=De.purpose.executionId,Ve=de(te,K,Se);if(se.current[Ve])continue;const Xe=a.connect(De.terminalSessionId,{onEvent:nt=>{if(!L(te,De.id,Se))return;nt.type==="snapshot"&&(Mt.getState().replaceBuffer(te,De.id,nt.data??"",nt.sequence??0,pl(nt)),nt.status==="running"&&Mt.getState().setTabLifecycle(te,De.id,"running",{expectedExecutionId:Se}),nt.status==="exited"&&(Mt.getState().setTabLifecycle(te,De.id,"exited",{expectedExecutionId:Se}),Mt.getState().setTabPurpose(te,De.id,{type:"project-action",actionId:K,executionId:null}),F(te,K,Se)));const Ze=nt.type==="data"?nt.data??"":"";Ze&&Mt.getState().appendToBuffer(te,De.id,Ze,nt.sequence,nt.replayData),nt.type==="exit"&&(Mt.getState().setTabLifecycle(te,De.id,"exited",{expectedExecutionId:Se}),Mt.getState().setTabPurpose(te,De.id,{type:"project-action",actionId:K,executionId:null}),F(te,K,Se))},onError:(nt,Ze)=>{!Ze||!L(te,De.id,Se)||(Mt.getState().setTabLifecycle(te,De.id,"exited",{expectedExecutionId:Se}),Mt.getState().setTabSessionId(te,De.id,null,{expectedExecutionId:Se}),Mt.getState().setTabPurpose(te,De.id,{type:"project-action",actionId:K,executionId:null}),F(te,K,Se))}});se.current[Ve]=Xe.close}},[F,de,L,a,q]);const Me=c.useCallback(async te=>{const me=ee(te);if(!me)throw new Error(o("projectActions.error.noActiveDirectory"));const De=an(me,te.id);b(me);const K=Mt.getState(),Se=Y(me,te.id,K),Ve=Se?.id??K.createTab(me);C(me,Ve,te.name),v(me,Ve,te.icon||"play"),Se||O(me,Ve,{type:"project-action",actionId:te.id,executionId:null}),E(me,Ve);const nt=Mt.getState().getDirectoryState(me)?.tabs.find(Ze=>Ze.id===Ve);return{executionDirectory:me,key:De,tabId:Ve,sessionId:nt?.terminalSessionId??null,executionId:nt?.purpose.type==="project-action"?nt.purpose.executionId:null}},[b,ee,Y,E,v,C,O,o]),Ae=c.useCallback(async te=>{if(d.isVSCode||!i&&m)return;if(!G){Ke.error(o("projectActions.error.noActiveDirectoryForAction"));return}const me=an(ee(te),te.id),De=U[me];if(De&&De.status==="running"||ie.current.has(me))return;ie.current.add(me);let K=null;try{const Se=te.id===cn?await(async()=>{const[qe,Ye]=await Promise.all([tp({id:J?.id??"",path:G}),Bb(G)]),dt=await Ib(G,qe.actions,Ye);if(!dt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:cn,name:o("projectActions.actions.autoDiscover"),command:dt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:dt.previewUrlHint||""}})():te,Ve=Se.autoOpenUrl===!0&&(Se.openUrl||"").trim().length>0,Xe=!Ve&&te.id!==cn,nt=he.current||G,{executionDirectory:Ze,key:gt,tabId:We}=await Me(Se),Et=uh(Se.command);if(!Et)throw new Error(o("projectActions.error.failedToRunAction"));const Ft=Se.autoOpenUrl===!0&&f&&(Se.desktopOpenSshForward||"").trim().length>0,Ie=Se.autoOpenUrl?Lb(Se.openUrl):null,yt=Se.autoOpenUrl&&f?fh(Se.desktopOpenSshForward,p):null;if(a.listSessions){const qe=Y(Ze,Se.id);if(qe?.purpose.type==="project-action"&&qe.purpose.executionId===null){const Ye=await mh(a,Ze,{captureStartedActionMutationRevisions:W});Ye&&S(Ze,Ye.sessions,{startedActionMutationRevisions:Ye.startedActionMutationRevisions})}}const At=Y(Ze,Se.id);let He,Ue;if(At?.lifecycle==="running"&&At.terminalSessionId&&At.purpose.type==="project-action"&&At.purpose.executionId)He=At.terminalSessionId,Ue=At.purpose.executionId;else{const qe=At?.purpose.type==="project-action"?At.purpose.executionId:null;qe&&F(Ze,Se.id,qe);const Ye=B(Ze,We,Se.id);if(!Ye)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));K={directory:Ze,tabId:We,id:Ye},R(Ze,We,!0,{expectedExecutionId:Ye});const dt=await hh({terminal:a,createOptions:{cwd:Ze,shell:x,loginShell:k,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Et,isRunStillExpected:()=>L(Ze,We,Ye),purpose:{type:"project-action",actionId:Se.id,executionId:Ye}});if(!L(Ze,We,Ye)){dt.sessionId===Ye&&await a.close(dt.sessionId).catch(()=>{});return}Ue=dt.purpose?.type==="project-action"?dt.purpose.executionId:Ye,He=dt.sessionId,O(Ze,We,{type:"project-action",actionId:Se.id,executionId:Ue}),A(Ze,We,He,{expectedExecutionId:Ue}),R(Ze,We,!1,{expectedExecutionId:Ue})}Xe&&nt&&ae(nt,Ze),ue.current[gt]={hostDirectory:nt,directory:Ze,tabId:We,actionId:Se.id,executionId:Ue,lastSeenChunkId:null,openedUrl:!!yt||!!Ie||Ve,tail:"",openInPreview:Se.id===cn,announced:[],offering:!1};const ve=de(Ze,Se.id,Ue);R(Ze,We,!0,{expectedExecutionId:Ue});const Qe=a.connect(He,{onEvent:qe=>{if(!L(Ze,We,Ue)||qe.purpose?.type==="project-action"&&qe.purpose.executionId!==Ue)return;qe.type==="snapshot"&&(Mt.getState().replaceBuffer(Ze,We,qe.data??"",qe.sequence??0,pl(qe)),Mt.getState().setConnecting(Ze,We,!1,{expectedExecutionId:Ue}),qe.purpose?.type==="project-action"&&Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:qe.purpose.actionId,executionId:qe.purpose.executionId}),qe.status==="running"&&Mt.getState().setTabLifecycle(Ze,We,"running",{expectedExecutionId:Ue}),qe.status==="exited"&&(Mt.getState().setTabLifecycle(Ze,We,"exited",{expectedExecutionId:Ue}),Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:Se.id,executionId:null}),F(Ze,Se.id,Ue)));const Ye=qe.type==="data"?qe.data??"":"";Ye&&Mt.getState().appendToBuffer(Ze,We,Ye,qe.sequence,qe.replayData),qe.type==="exit"&&(Mt.getState().setTabLifecycle(Ze,We,"exited",{expectedExecutionId:Ue}),Mt.getState().setConnecting(Ze,We,!1,{expectedExecutionId:Ue}),Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:Se.id,executionId:null}),F(Ze,Se.id,Ue))},onError:(qe,Ye)=>{L(Ze,We,Ue)&&(Mt.getState().setConnecting(Ze,We,!1,{expectedExecutionId:Ue}),Ye&&(Mt.getState().setTabLifecycle(Ze,We,"exited",{expectedExecutionId:Ue}),Mt.getState().setTabSessionId(Ze,We,null,{expectedExecutionId:Ue}),Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:Se.id,executionId:null}),F(Ze,Se.id,Ue)))}});if(!L(Ze,We,Ue)){Qe.close();return}se.current[ve]?.(),se.current[ve]=Qe.close,window.clearTimeout(xe.current[ve]),delete xe.current[ve],Se.id===cn&&!Ie&&(fe(qe=>({...qe,[ve]:!0})),xe.current[ve]=window.setTimeout(()=>{delete xe.current[ve];const qe=ue.current[gt];!qe||qe.executionId!==Ue||qe.openedUrl||qe.offering||L(Ze,We,Ue)&&(fe(Ye=>{if(!Ye[ve])return Ye;const dt={...Ye};return delete dt[ve],dt}),Mt.getState().setActiveTab(Ze,We),ae(qe.hostDirectory,Ze))},Fb)),yt?(M(Ze,We,null,{locked:!0,expectedExecutionId:Ue}),ce(yt),Ke.success(o("projectActions.toast.openedForwardedUrl"))):Ie?(M(Ze,We,Ie,{locked:!0,autoOpened:!0,expectedExecutionId:Ue}),j(nt,Ie),Ke.success(o("projectActions.toast.openedActionUrl"))):Ve?(M(Ze,We,null,{locked:!0,expectedExecutionId:Ue}),Ke.error(o("projectActions.error.invalidCustomUrlFormat"))):Ft?(M(Ze,We,null,{locked:!0,expectedExecutionId:Ue}),Ke.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):M(Ze,We,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ue})}catch(Se){if(K&&L(K.directory,K.tabId,K.id)){const{directory:Ve,tabId:Xe,id:nt}=K;F(Ve,te.id,nt),T(Ve,Xe,"exited",{expectedExecutionId:nt}),O(Ve,Xe,{type:"project-action",actionId:te.id,executionId:null})}if(Se instanceof Error&&Se.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Se instanceof Error&&(Se.message==="COMMAND_MODE_UNSUPPORTED"||Se.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Ke.error(o("projectActions.error.failedToCreateTerminalSession"));return}Ke.error(Se instanceof Error?Se.message:o("projectActions.error.failedToRunAction"))}finally{ie.current.delete(me)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,he,p,Me,i,m,f,G,k,x,ce,j,U,ae,d.isVSCode,ee,L,F,de,Y,S,B,W,R,T,O,M,A,J?.id,o,a]),Q=c.useCallback(async te=>{const me=an(ee(te),te.id),De=U[me];De&&await ph({terminal:a,sessionId:De.sessionId,isExecutionStillCurrent:()=>L(De.directory,De.tabId,De.executionId),markStopping:()=>{T(De.directory,De.tabId,"stopping",{expectedExecutionId:De.executionId})},restoreRunning:()=>{T(De.directory,De.tabId,"running",{expectedExecutionId:De.executionId})},clearSession:()=>{A(De.directory,De.tabId,null,{expectedExecutionId:De.executionId})},finalizeExit:()=>{T(De.directory,De.tabId,"exited",{expectedExecutionId:De.executionId}),O(De.directory,De.tabId,{type:"project-action",actionId:De.actionId,executionId:null}),F(De.directory,De.actionId,De.executionId)}})},[F,ee,L,U,T,O,A,a]),Ce=c.useCallback(()=>{const te=pe??Fe[0];if(!te)return;const me=an(ee(te),te.id),De=U[me];if(De?.status!=="stopping"){if(De){Q(te);return}Ae(te)}},[Fe,ee,Ae,U,pe,Q]),Be=c.useCallback(async te=>{if(te.source==="shared"&&J){const me=D.current?.trust.trusted?D.current:await Al(J);if(D.current=me,!await sp(J,me))return;D.current={...me,trust:{...me.trust,trusted:!0}}}await Ae(te)},[Ae,J]),Le=c.useCallback((te,me=!1)=>{if(X(te.id),!me){Be(te);return}const De=an(ee(te),te.id),K=U[De];if(K?.status!=="stopping"){if(K){Q(te);return}Be(te)}},[ee,Be,U,Q]),Je=c.useCallback(()=>{J?.id&&(g(J.id),w("projects"),h(!0))},[h,w,g,J?.id]),ot=pe??Fe[0]??null,et=ot?U[an(ee(ot),ot.id)]:null,it=Mt(te=>et?te.getDirectoryState(et.directory)?.tabs.find(me=>me.id===et.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&m||!J||!G)return null;const ht=pe??Fe[0]??null;if(!ht)return null;const st=Ti(ht),mt=an(ee(ht),ht.id),kt=U[mt],Pe=kt?.status==="stopping",Ge=kt?.status==="waiting-for-preview",at=!!(kt&&it),ze=()=>{!kt||!it||j(kt.directory,it)},ft=ht.id===cn;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",disabled:Z||Pe,className:Ee("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-ring","disabled:cursor-not-allowed",n),onClick:Ce,"aria-label":kt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:Pe||Ge?s.jsx(_,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):kt?s.jsx(_,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(_,{name:st,className:"h-5 w-5"})})}),ft?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),at?s.jsxs(vt,{children:[s.jsx(St,{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-ring","aria-label":o("projectActions.actions.openPreview"),onClick:ze,children:s.jsx(_,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ls,{children:[s.jsx(Fs,{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-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(_,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(_s,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ht,{className:"flex items-center gap-2",onClick:Je,children:[s.jsx(_,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Es,{}),Fe.map(te=>{const me=Ti(te),De=an(ee(te),te.id),K=U[De],Se=!!K,Ve=K?.status==="stopping";return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{Le(te,!0)},children:[s.jsx(_,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:te.name}),te.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,Ve||K?.status==="waiting-for-preview"?s.jsx(_,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Se?s.jsx(_,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},te.id)})]})]})]}):s.jsxs("div",{className:Ee("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(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ce,disabled:Z||Pe,className:Ee("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-ring disabled:cursor-not-allowed"),"aria-label":kt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:Pe||Ge?s.jsx(_,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):kt?s.jsx(_,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(_,{name:st,className:"h-4 w-4"})})})}),ft?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),at?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ze,className:Ee(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-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(_,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee(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-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(_s,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ht,{className:"flex items-center gap-2",onClick:Je,children:[s.jsx(_,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Es,{}),Fe.map(te=>{const me=Ti(te),De=an(ee(te),te.id),K=U[De],Se=!!K,Ve=K?.status==="stopping";return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{Le(te,!0)},children:[s.jsx(_,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:te.name}),te.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,Ve||K?.status==="waiting-for-preview"?s.jsx(_,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Se?s.jsx(_,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},te.id)})]})]})]})},zr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},zb=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=zr(n??"");if(i){const o=su(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function Wb(){const t=Ut(x=>x.projects),e=Ut(x=>x.activeProjectId),n=rt(x=>x.availableWorktreesByProject),r=rt(x=>x.currentSessionId),i=np(r??null),o=rt(x=>r?x.worktreeMetadata.get(r)?.path??"":""),l=rt(x=>x.newSessionDraft?.open?zr(x.newSessionDraft.bootstrapPendingDirectory??x.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>zr(o||""),[o]),d=c.useMemo(()=>{const x=typeof i?.directory=="string"?i.directory:"";return zr(x||"")},[i?.directory]),u=a||d||l,m=c.useMemo(()=>zb({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>zr(u||m?.path||""),[u,m?.path]),p=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),y=c.useRef(null);return c.useEffect(()=>{p&&f&&(y.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:y.current,[p,f])}const Kb=({transform:t})=>({...t,y:0}),Vb={Item:Ht,Separator:Es},Ub={Item:({className:t,...e})=>s.jsx(Zu,{className:Ee(iu,t),...e}),Separator:({className:t,...e})=>s.jsx(Ju,{className:Ee(ou,t),...e})},Hb=t=>{const e=tt.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:m}=t,{t:f}=Nt(),[p,y]=c.useState(!1),[x,k]=c.useState(!1),[w,h]=c.useState(!1);let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:j,listeners:b,setNodeRef:S,transform:C,transition:v,isDragging:E}=mi(g);let R;e[2]!==f||e[3]!==n.session.title?(R=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=R):R=e[4];const A=R,O=!i&&(p||x),B=n.id;let T;e[5]!==n.session?(T=As(n.session),e[5]=n.session,e[6]=T):T=e[6];const M=Oa(B,T),L=nu(n.id),$=ru(n.id)>0&&!r&&!L,P=L||$;let D;e[7]!==L||e[8]!==f?(D=f(L?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=L,e[8]=f,e[9]=D):D=e[9];const I=D;let X;e[10]!==d||e[11]!==w||e[12]!==r||e[13]!==p||e[14]!==o||e[15]!==n?(X=we=>({session:n.session,open:p||w,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:we}),e[10]=d,e[11]=w,e[12]=r,e[13]=p,e[14]=o,e[15]=n,e[16]=X):X=e[16];const Z=X;let ne;e[17]!==C?(ne=hi.Translate.toString(C),e[17]=C,e[18]=ne):ne=e[18];let ue;e[19]!==ne||e[20]!==v?(ue={transform:ne,transition:v},e[19]=ne,e[20]=v,e[21]=ue):ue=e[21];const se=E&&"z-10 opacity-60";let xe;e[22]!==se?(xe=Ee("session-tab-slot flex h-7 w-44 shrink-0 touch-none",se),e[22]=se,e[23]=xe):xe=e[23];const ie=r?"true":"false";let Re;e[24]!==r?(Re=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=Re):Re=e[25];let be;e[26]!==u?(be=we=>u?.(we),e[26]=u,e[27]=be):be=e[27];let fe;e[28]!==m||e[29]!==I||e[30]!==r||e[31]!==M||e[32]!==L||e[33]!==Z||e[34]!==p||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==O||e[39]!==a||e[40]!==P||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==A?(fe=s.jsx(ef,{render:we=>s.jsxs("div",{...we,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),o(n))},onAuxClick:Te=>{Te.button===1&&(Te.preventDefault(),l(n.id))},"data-controls-open":O?"true":"false",className:Ee("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":Ee("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",O&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Ee("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",O&&"pr-10"),children:[s.jsx("div",{className:Ee("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?m: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:A})})}),M?s.jsx(_,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):P?s.jsx(Ba,{state:L?"running":"unread",label:I,className:Ee("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",O&&"opacity-0")}):null]}),i?null:s.jsxs("div",{onClick:qb,onPointerDown:Yb,className:Ee("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",O&&"flex opacity-100"),children:[s.jsxs(Ls,{open:p,onOpenChange:Te=>{y(Te),Te&&k(!0)},onOpenChangeComplete:Te=>{Te||k(!1),u?.(Te)},children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"more",className:"size-4"})})}),s.jsx(_s,{align:"start",className:"min-w-[190px]",children:a(Z(Vb))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"size-4"})})]})]})}),e[28]=m,e[29]=I,e[30]=r,e[31]=M,e[32]=L,e[33]=Z,e[34]=p,e[35]=l,e[36]=u,e[37]=o,e[38]=O,e[39]=a,e[40]=P,e[41]=i,e[42]=f,e[43]=n,e[44]=A,e[45]=fe):fe=e[45];let ke,H;e[46]===Symbol.for("react.memo_cache_sentinel")?(ke={color:"var(--surface-elevated-foreground)"},H=Ee(Qi,"min-w-[190px]"),e[46]=ke,e[47]=H):(ke=e[46],H=e[47]);let J;e[48]!==Z||e[49]!==a?(J=a(Z(Ub)),e[48]=Z,e[49]=a,e[50]=J):J=e[50];let ce;e[51]!==J?(ce=s.jsx(ca,{children:s.jsx(da,{className:"app-region-no-drag z-50",children:s.jsx(ua,{"data-slot":"dropdown-menu-content",style:ke,className:H,children:J})})}),e[51]=J,e[52]=ce):ce=e[52];let je;e[53]!==w||e[54]!==be||e[55]!==fe||e[56]!==ce?(je=s.jsxs(tf,{open:w,onOpenChange:h,onOpenChangeComplete:be,children:[fe,ce]}),e[53]=w,e[54]=be,e[55]=fe,e[56]=ce,e[57]=je):je=e[57];let G;return e[58]!==j||e[59]!==b||e[60]!==S||e[61]!==xe||e[62]!==ie||e[63]!==Re||e[64]!==je||e[65]!==ue?(G=s.jsx("div",{ref:S,style:ue,className:xe,"data-active":ie,...Re,...j,...b,children:je}),e[58]=j,e[59]=b,e[60]=S,e[61]=xe,e[62]=ie,e[63]=Re,e[64]=je,e[65]=ue,e[66]=G):G=e[66],G},Gb=t=>{const e=tt.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=Nt(),d=co(Qb),u=co(Xb),m=co(Jb),f=co(Zb),p=rt(ey),y=rt(ty),x=vs(sy);let k,w;e[0]!==p||e[1]!==u?(k=()=>{p&&u(p)},w=[p,u],e[0]=p,e[1]=u,e[2]=k,e[3]=w):(k=e[2],w=e[3]),c.useEffect(k,w);let h;if(e[4]!==x){h=new Map;for(const he of x)h.set(he.id,he);e[4]=x,e[5]=h}else h=e[5];const g=h;let j;if(e[6]!==g||e[7]!==d){j=[];for(const he of d){const re=g.get(he);re&&j.push({id:he,session:re})}e[6]=g,e[7]=d,e[8]=j}else j=e[8];const b=j;let S;e[9]!==y?(S=he=>{y(he.id,As(he.session))},e[9]=y,e[10]=S):S=e[10];const C=S,v=ny;let E;e[11]!==m||e[12]!==p||e[13]!==C||e[14]!==b?(E=he=>{if(m(he),p&&p!==he){const re=b.find(ge=>ge.id===he);re&&C(re)}},e[11]=m,e[12]=p,e[13]=C,e[14]=b,e[15]=E):E=e[15];const R=E;let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{distance:8}},e[16]=A):A=e[16];let O;e[17]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{delay:200,tolerance:6}},e[17]=O):O=e[17];const B=li(Pn(di,A),Pn(ci,O));let T;e[18]!==f?(T=he=>{const{active:re,over:ge}=he;ge&&re.id!==ge.id&&f(String(re.id),String(ge.id))},e[18]=f,e[19]=T):T=e[19];const M=T,L=c.useRef(null);let W;e[20]===Symbol.for("react.memo_cache_sentinel")?(W={left:!1,right:!1},e[20]=W):W=e[20];const[$,P]=c.useState(W);let D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{const he=L.current;if(!he)return;const re=he.scrollLeft>2,ge=he.scrollLeft+he.clientWidth<he.scrollWidth-2;P(q=>q.left===re&&q.right===ge?q:{left:re,right:ge})},e[21]=D):D=e[21];const I=D;let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{I();const he=L.current;if(!he||!globalThis.ResizeObserver)return;const re=new ResizeObserver(I);return re.observe(he),()=>re.disconnect()},e[22]=X):X=e[22];let Z;e[23]!==b.length?(Z=[I,b.length],e[23]=b.length,e[24]=Z):Z=e[24],c.useEffect(X,Z);let ne;e[25]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{L.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=ne):ne=e[25];let ue;e[26]!==p?(ue=[p],e[26]=p,e[27]=ue):ue=e[27],c.useEffect(ne,ue);const se=$.left&&$.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":$.left?"linear-gradient(to right, transparent, black 24px)":$.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let xe;e[28]!==b?(xe=b.map(ry),e[28]=b,e[29]=xe):xe=e[29];const ie=xe;let Re;e[30]!==p||e[31]!==b?(Re=!p||!b.some(he=>he.id===p),e[30]=p,e[31]=b,e[32]=Re):Re=e[32];const be=Re;let fe;e[33]!==a?(fe=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=fe):fe=e[34];let ke;e[35]!==se?(ke=se?{maskImage:se,WebkitMaskImage:se}:void 0,e[35]=se,e[36]=ke):ke=e[36];let H;e[37]===Symbol.for("react.memo_cache_sentinel")?(H=[Kb],e[37]=H):H=e[37];let J;e[38]!==o||e[39]!==p||e[40]!==R||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==b?(J=b.map(he=>s.jsx(Hb,{tab:he,isActive:he.id===p,suppressControls:he.id===p&&l,onSelect:C,onClose:v,renderMenu:n,closeOtherTabs:R,onMenuOpenChangeComplete:r,children:he.id===p?o:null},he.id)),e[38]=o,e[39]=p,e[40]=R,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=b,e[46]=J):J=e[46];let ce;e[47]!==J||e[48]!==ie?(ce=s.jsx(Ja,{items:ie,strategy:Qx,children:J}),e[47]=J,e[48]=ie,e[49]=ce):ce=e[49];let je;e[50]!==M||e[51]!==B||e[52]!==ce?(je=s.jsx(ui,{sensors:B,collisionDetection:fi,modifiers:H,onDragEnd:M,children:ce}),e[50]=M,e[51]=B,e[52]=ce,e[53]=je):je=e[53];let G;e[54]!==o||e[55]!==be?(G=be?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]=be,e[56]=G):G=e[56];let we;e[57]!==ke||e[58]!==je||e[59]!==G?(we=s.jsxs("div",{ref:L,onScroll:I,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:ke,children:[je,G]}),e[57]=ke,e[58]=je,e[59]=G,e[60]=we):we=e[60];let Te;return e[61]!==fe||e[62]!==we?(Te=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":fe,children:we}),e[61]=fe,e[62]=we,e[63]=Te):Te=e[63],Te};function qb(t){return t.stopPropagation()}function Yb(t){return t.stopPropagation()}function Qb(t){return t.tabIds}function Xb(t){return t.ensureTab}function Jb(t){return t.closeOtherTabs}function Zb(t){return t.reorderTabs}function ey(t){return t.currentSessionId}function ty(t){return t.setCurrentSession}function sy(t){return t.activeSessions}function ny(t){rp(t)}function ry(t){return t.id}const lf=async t=>{const{entry:e,session:n}=t,r=Qt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(op(e.action)&&ip(e.guest,"conversation"))){await Pl(e,Dl(e.action.id,i),t.t,r);return}let l=!1;const a=Cr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Pl(e,Dl(e.action.id,i,d),t.t,r)}};function ma(t){const e=tt.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=Nt(),{pending:a,disabled:d,hint:u,run:m}=yh(n,r,i),f=a?"loader-4":"ai-generate-2",p=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let y;e[0]!==f||e[1]!==p?(y=s.jsx(_,{name:f,className:p}),e[0]=f,e[1]=p,e[2]=y):y=e[2];let x;e[3]!==l?(x=l("sessions.aiRename.action"),e[3]=l,e[4]=x):x=e[4];let k;e[5]!==o||e[6]!==d||e[7]!==m||e[8]!==y||e[9]!==x?(k=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:m,className:"w-full",children:[y,x]})})}),e[5]=o,e[6]=d,e[7]=m,e[8]=y,e[9]=x,e[10]=k):k=e[10];let w;e[11]!==u?(w=s.jsx(jt,{side:"right",children:u}),e[11]=u,e[12]=w):w=e[12];let h;return e[13]!==k||e[14]!==w?(h=s.jsxs(vt,{children:[k,w]}),e[13]=k,e[14]=w,e[15]=h):h=e[15],h}const ha=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class cf extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const pi=no(()=>({pendingSessionIds:new Set})),df=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],pi(n)},ec=(t,e)=>{pi.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}})},oy=async(t,e)=>{try{const d=(await fp(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=xt(t),r=xt(e)??e,i=rt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>xt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},tc=t=>{for(const e of t){const n=lp(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class iy extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const ay=(t,e)=>{const n=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new iy(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},ly=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(cp(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await au(o,n,e),rt.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},sc=async(t,e,n)=>{try{await cu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},nc=async(t,e)=>{const n=e?[t,e]:[t];try{await Fa(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},uf=async(t,e)=>{if(pi.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");ec(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,rt.getState().getWorktreeMetadata(a.id)]));tc(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){tc(n.slice(a));try{await au(d,t.sourceDirectory,i.directory)}catch(u){throw ap(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&rt.getState().setWorktreeMetadata(d.id,Il(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await ly(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await nc(t.sourceDirectory,i?.directory),u.length>0)throw ay(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new cf(d):d}return rt.getState().setWorktreeMetadata(t.root.id,Il(i.metadata)),await nc(t.sourceDirectory,i.directory),i.directory}finally{ec(t.root.id,!1)}},cy=async t=>{const e=xt(t.sourceDirectory)??t.sourceDirectory,n=xt(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 uf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},dy=async t=>uf(t,async()=>{const e=Xi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await lu(t.sourceDirectory)?await oy(t.sourceDirectory,e.path):null,r=await dp(e,n?{startRef:n}:{});try{await up(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return sc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>sc(e,r,i)}}),uy=t=>{(t.kind==="existing"?cy({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):dy({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>Ke.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));Ke.error(t.messages.failure,{description:r instanceof cf?t.messages.outcomeUnknown:r.message})})},pa=t=>{pi.getState().pendingSessionIds.has(t.root.id)||uy(t)},Vo="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-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",fy=c.memo(function(e){const n=tt.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:m}=e,f=r===void 0?!0:r,p=m===void 0?!1:m;if(!f)return null;const y=a??Vo,x=p&&"bg-interactive-selection text-interactive-selection-foreground";let k;n[0]!==y||n[1]!==x?(k=Ee(y,x),n[0]=y,n[1]=x,n[2]=k):k=n[2];const w=u??"h-[18px] w-[18px]";let h;n[3]!==d||n[4]!==w?(h=s.jsx(_,{name:d,className:w}),n[3]=d,n[4]=w,n[5]=h):h=n[5];let g;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==k||n[10]!==h?(g=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:k,children:h})}),n[6]=o,n[7]=l,n[8]=p,n[9]=k,n[10]=h,n[11]=g):g=n[11];let j;n[12]!==i?(j=s.jsx(jt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=j):j=n[13];let b;return n[14]!==g||n[15]!==j?(b=s.jsxs(vt,{children:[g,j]}),n[14]=g,n[15]=j,n[16]=b):b=n[16],b}),my=c.memo(function(e){const n=tt.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:m,remoteUpdateChecking:f,remoteUpdateError:p,onOpenRemoteUpdate:y}=e,{t:x}=Nt();let k;n[0]!==d||n[1]!==a?(k=B=>{a(B),B&&d()},n[0]=d,n[1]=a,n[2]=k):k=n[2];let w;n[3]!==i||n[4]!==r||n[5]!==x?(w=r?x("header.services.openWithCurrent",{current:i}):x("header.services.open"),n[3]=i,n[4]=r,n[5]=x,n[6]=w):w=n[6];const h=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let g;n[7]!==h?(g=Ee(Vo,h),n[7]=h,n[8]=g):g=n[8];let j;n[9]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(_,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=j):j=n[9];let b;n[10]!==i||n[11]!==r?(b=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=b):b=n[12];let S;n[13]!==w||n[14]!==g||n[15]!==b?(S=s.jsx(St,{asChild:!0,children:s.jsx(Fs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":w,className:g,children:[j,b]})})}),n[13]=w,n[14]=g,n[15]=b,n[16]=S):S=n[16];let C;n[17]!==i||n[18]!==u||n[19]!==x?(C=x("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=x,n[20]=C):C=n[20];let v;n[21]!==C?(v=s.jsx(jt,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=v):v=n[22];let E;n[23]!==S||n[24]!==v?(E=s.jsxs(vt,{children:[S,v]}),n[23]=S,n[24]=v,n[25]=E):E=n[25];let R;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==y||n[30]!==f||n[31]!==p||n[32]!==m||n[33]!==a||n[34]!==x?(R=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:x("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:m?.available?x("header.services.remoteUpdate.available",{version:m.version||""}):f?x("header.services.remoteUpdate.checking"):p||x("header.services.remoteUpdate.upToDate")})]}),m?.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:y,children:x("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(mp,{embedded:!0,open:l,onOpenChange:py,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=y,n[30]=f,n[31]=p,n[32]=m,n[33]=a,n[34]=x,n[35]=R):R=n[35];let A;n[36]!==R?(A=s.jsx(_s,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:R}),n[36]=R,n[37]=A):A=n[37];let O;return n[38]!==l||n[39]!==k||n[40]!==E||n[41]!==A?(O=s.jsxs(Ls,{open:l,onOpenChange:k,children:[E,A]}),n[38]=l,n[39]=k,n[40]=E,n[41]=A,n[42]=O):O=n[42],O}),kn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},rc=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,hy=()=>{Ts("ui.header.render");const{t}=Nt(),e=Ne(N=>N.isSidebarOpen),n=Ne(N=>N.openContextOverview),r=Ne(N=>N.closeContextPanel),i=Ne(N=>N.shortcutOverrides),o=Ne(N=>N.sessionTabsEnabled),l=rt(N=>N.getContextUsage),a=rt(N=>!!N.newSessionDraft?.open),d=rt(N=>N.currentSessionId),u=hp(d??""),m=pp(d??""),f=df(d??""),p=vs(ar(c.useCallback(N=>{if(!d)return null;const ye=[...N.activeSessions,...N.archivedSessions].find(lt=>lt.id===d);if(!ye)return null;const $e=ye;return{title:ye.title??null,directory:$e.directory??null,created:ye.time?.created??null,slug:$e.slug??null,parentId:ye.parentID??null}},[d]))),y=Ut(ar(N=>{if(!N.activeProjectId)return null;const ye=N.projects.find($e=>$e.id===N.activeProjectId);return ye?{id:ye.id,path:ye.path,label:ye.label}:null})),x=c.useMemo(()=>{if(!y)return null;const N=y.label?.trim();if(N)return N;const ye=y.path.split(/[\\/]/).filter(Boolean);return ye[ye.length-1]??null},[y]),k=hr(N=>N.loadSettings),{isMobile:w}=$n(),h=c.useRef(null),[g,j]=c.useState(()=>typeof window>"u"?!1:xn()),b=c.useMemo(()=>qr(),[]),S=du(),[C,v]=c.useState(!1),E=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:R,side:A}=qu(),O=c.useMemo(()=>{if(typeof window>"u")return null;const N=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof N=="number"&&Number.isFinite(N)&&N>0)return N;if(typeof navigator>"u")return null;const ye=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ye)return null;const $e=Number.parseInt(ye[1],10),lt=Number.parseInt(ye[2],10);return Number.isNaN($e)?null:$e===10?lt:$e},[]);ut.useEffect(()=>{typeof window>"u"||j(xn())},[]);const{context:B,output:T}=gp(d),M=l(B,T),[L,W]=c.useState(null),$=!d||u;ut.useEffect(()=>{if(!d){W(N=>N===null?N:null);return}if(M){W(N=>xp(N,M)?N:M);return}$&&W(N=>N===null?N:null)},[M,d,$]);const[P,D]=c.useState(!1),[I,X]=c.useState("Local"),[Z,ne]=c.useState(!0),[ue,se]=c.useState(!1),[xe,ie]=c.useState(null),[Re,be]=c.useState(!1),[fe,ke]=c.useState(null),H=c.useMemo(()=>_n(),[]),J=Ne(N=>N.workStatusPanelVisible),ce=Ne(N=>N.workStatusPanelEnabled),je=Ne(N=>N.setWorkStatusPanelEnabled),G=Ne(N=>N.workStatusPanelFits),we=Ne(N=>N.workStatusOverlayOpen),Te=Ne(N=>N.setWorkStatusOverlayOpen),re=ce&&G||we,ge=c.useCallback(()=>{if(ce&&!G){Te(!we);return}je(!ce)},[Te,je,we,ce,G]),q=!H&&!J&&!!L,z=c.useCallback(async()=>{if(!(typeof window>"u"||!g))try{if(Zo()){X("Local"),ne(!0);return}ne(!1);const N=await Bd(),ye=Lm(),$e=$m([zm(ye),...N.hosts]);if($e.id===Wm){X("Local"),ne(!0);return}X(Fd($e.label.trim()||"Instance"))}catch{X("Local"),ne(!0)}},[g]);ut.useEffect(()=>(z(),Cr(()=>{z()})),[z]);const ee=c.useCallback(async()=>{if(Z){ie(null),ke(null);return}be(!0),ke(null);try{const N=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),ye=await bs(`/api/openchamber/update-check?${N.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!ye.ok)throw new Error(`Server responded with ${ye.status}`);const $e=await ye.json();ie({available:$e.available??!1,version:$e.version,currentVersion:$e.currentVersion??"unknown",body:$e.body,nextSuggestedCheckInSec:typeof $e.nextSuggestedCheckInSec=="number"?$e.nextSuggestedCheckInSec:void 0,packageManager:$e.packageManager,updateCommand:$e.updateCommand})}catch(N){ie(null),ke(N instanceof Error?N.message:t("header.services.remoteUpdate.error"))}finally{be(!1)}},[Z,t]);c.useEffect(()=>{ie(null),ke(null),se(!1)},[Z,I]),c.useEffect(()=>{if(!g||Z)return;const N=3e3,ye=3600*1e3;let $e=!1,lt=null;const Pt=Dt=>{lt=window.setTimeout(()=>{if($e||typeof document<"u"&&document.visibilityState!=="visible"){Pt(ye);return}ee().finally(()=>{$e||Pt(ye)})},Dt)};return Pt(N),()=>{$e=!0,lt!==null&&window.clearTimeout(lt)}},[ee,Z,I,g]);const de=c.useCallback(()=>{if(xe?.available){se(!0);return}ee()},[ee,xe?.available]);bp(),c.useEffect(()=>{k()},[k]);const Y=d?p??null:null,U=c.useRef(null),[F,V]=c.useState(0);c.useEffect(()=>{if(!d){U.current&&(U.current=null,V(lt=>lt+1));return}if(Y){U.current={sessionId:d,session:Y,expiresAt:Date.now()+2e3};return}const N=U.current;if(!N||N.sessionId!==d)return;const ye=N.expiresAt-Date.now();if(ye<=0){U.current=null,V(lt=>lt+1);return}const $e=window.setTimeout(()=>{U.current?.sessionId===d&&(U.current=null),V(lt=>lt+1)},ye);return()=>{window.clearTimeout($e)}},[d,Y]);const oe=(()=>{if(Y)return Y;if(!d)return null;const N=U.current;return N&&N.sessionId===d&&N.expiresAt>Date.now()?N.session:null})(),ae=rt(N=>d?N.worktreeMetadata.get(d)?.path??"":""),pe=rt(N=>d?N.worktreeMetadata.get(d)?.branch?.trim()??null:null),le=uu(N=>d?N.getAttachment(d):void 0),_e=c.useMemo(()=>le?yp(le,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,le]),Fe=c.useMemo(()=>le?le.legacy?"legacy":le.degraded?"degraded":le.worktreeStatus==="pending"?"pending":le.worktreeStatus==="missing"?"missing":le.worktreeStatus==="invalid"?"invalid":le.attentionReason?"attention":null:null,[le]),Me=c.useMemo(()=>kn(ae||""),[ae]),Ae=c.useMemo(()=>{const N=typeof oe?.directory=="string"?oe.directory:"";return kn(N||"")},[oe?.directory]),Q=Oa(d??"",Ae),Ce=rt(N=>N.newSessionDraft?.open?kn(N.newSessionDraft.bootstrapPendingDirectory??N.newSessionDraft.directoryOverride??""):""),Be=rt(N=>N.newSessionDraft.target),Le=rt(N=>N.newSessionDraft.selectedProjectId),Je=rt(N=>N.currentSessionDirectory),ot=os(N=>N.homeDirectory),et=c.useMemo(()=>Me||Ae||Ce,[Ce,Ae,Me]),it=Ne(c.useCallback(N=>{const ye=kn(et||"");return ye?rc(N.contextPanelByDirectory[ye]):null},[et])),ht=rt(N=>{const ye=kn(Me||Ae||"");if(!ye)return null;for(const $e of N.availableWorktreesByProject.values()){const Pt=$e.find(Dt=>kn(Dt.path)===ye)?.branch?.trim();if(Pt)return Pt}return null}),mt=wp(et||null)||pe||ht,kt=a?Be==="chat":vp(Ae||Je,ot),Pe=!kt&&!J&&!!(x||mt||!a&&Fe),Ge=c.useMemo(()=>{if(!d)return x??"OpenChamber";const N=oe?.title?.trim();return N&&N.length>0?N:"Untitled Session"},[x,oe?.title,d]),at=fu(),ze=rt(N=>N.updateSessionTitle),ft=rt(N=>N.archiveSessions),te=rt(N=>N.deleteSessions),[me,De]=c.useState(!1),[K,Se]=c.useState(!1),Ve=c.useRef(null),[Xe,nt]=c.useState(""),[Ze,gt]=c.useState(null),We=c.useRef(null),Et=c.useCallback(()=>{d&&(nt(oe?.title?.trim()||Ge),De(!0))},[oe?.title,d,Ge]),Ft=c.useRef(Et);Ft.current=Et;const Ie=c.useCallback(N=>{N&&(N.focus(),N.select())},[]);c.useEffect(()=>{if(Se(!1),gt(null),d&&Ve.current===d){Ve.current=null,Ft.current();return}De(!1),nt("")},[d]);const yt=c.useCallback(async()=>{if(!d)return;const N=Xe.trim();N&&N!==oe?.title?.trim()&&await ze(d,N),De(!1)},[oe?.title,d,Xe,ze]);c.useEffect(()=>{if(!me)return;const N=ye=>{const $e=ye.target;(!$e||!We.current?.contains($e))&&yt()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[me,yt]);const At=c.useCallback(N=>{N&&cr(N).then(ye=>{Ke[ye.ok?"success":"error"](t(ye.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Ke.error(t("sessions.sidebar.session.copyId.error")))},[t]),He=c.useCallback(async()=>{if(!d||!et){Ke.error(t("sessions.sidebar.session.export.nothingToExport"));return}const N=await at({sessionID:d,directory:et}).catch(()=>null);if(!N){Ke.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(N.length===0){Ke.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ye=mu(N,oe?.title??null),$e=hu(oe?.title??null);await pu(ye,$e)||gu(ye,$e),Ke.success(t("sessions.sidebar.session.export.success"))},[oe?.title,d,at,et,t]),Ue=xu(),ve=c.useMemo(()=>bu(Ue),[Ue]),Qe=c.useCallback(N=>{d&&lf({entry:N,t,session:{id:d,title:oe?.title,directory:Ae??et},loadRecords:async()=>{if(!et)return null;try{return await at({sessionID:d,directory:et})}catch{return null}},onLoadFailed:()=>Ke.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[oe?.title,d,at,et,Ae,t]),qe=c.useCallback(N=>ve.map(ye=>s.jsxs(N,{onClick:()=>Qe(ye),children:[s.jsx(to,{icon:ye.icon,iconSrc:ye.iconSrc,className:"mr-1 size-4"}),ye.action.label]},`${ye.guest.id}:${ye.action.id}`)),[ve,Qe]),Ye=m?.type==="busy"||m?.type==="retry",dt=c.useCallback(()=>{if(!d||!Ae||Ye||f)return;const N=vs.getState().activeSessions,ye=N.find(Pt=>Pt.id===d);if(!ye)return;const $e=[],lt=[d];for(let Pt=0;Pt<lt.length;Pt+=1){const Dt=lt[Pt];for(const pt of N)pt.parentID===Dt&&($e.push(pt),lt.push(pt.id))}pa({kind:"quick",root:ye,descendants:$e,sourceDirectory:Ae,messages:ha(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Ye,f,Ae,t]),Ot=c.useCallback(async()=>{if(!Ze)return;const N=Ze.action,ye=[Ze.sessionId,...Vd(Ze.sessionId,[],N==="delete")];if(gt(null),(N==="archive"?await ft(ye):await te(ye)).failedIds.length>0){Ke.error(t(N==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Ke.success(t(N==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[ft,te,Ze,t]),zt=Ne(N=>N.openGuestPageId),Kt=_a(N=>N.guests.find(ye=>ye.id===zt)),Gt=Ne(N=>N.isScheduledTasksDialogOpen),Bt=Ne(N=>N.isArchivePageOpen),Jt=Ne(N=>N.isUsageStatsPageOpen),Vt=Ne(N=>N.worktreesPageProjectId),Wt=Ne(N=>N.isMultiRunLauncherOpen),_t=Ut(N=>{if(!Vt)return null;const ye=N.projects.find($e=>$e.id===Vt);return ye?.label?.trim()||ye?.path?.split("/").pop()||null}),Xt=c.useMemo(()=>Kt?{title:Kt.pageTitle??Kt.name,subtitle:null}:Gt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Bt?{title:t("sessions.archivePage.title"),subtitle:null}:Jt?{title:t("usageStats.title"),subtitle:null}:Vt?{title:t("sessions.worktreesPage.title",{project:_t??""}),subtitle:null}:Wt?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[Kt,Bt,Wt,Gt,Jt,t,Vt,_t]),Ct=c.useMemo(()=>kn(et||y?.path||""),[y?.path,et]),Tt=Wb(),is=La(N=>N.planModeEnabled),$s=rt(N=>N.isSessionPlanAvailable),cs=is&&d?$s(d):!1,ps=c.useRef("");c.useEffect(()=>{if(!is||!d)return;const N=`${d||"none"}:${Ae||"none"}:${oe?.created||0}:${oe?.slug||"none"}`;ps.current!==N&&(ps.current=N)},[is,cs,oe?.slug,oe?.created,d,Ae]);const fn=c.useCallback(()=>{Fn("desktop_open_draft_mini_chat_window",{directory:kt?"":Ce,projectId:kt?null:Le,apiBaseUrl:Dn(),clientToken:Yr()}).catch(N=>{console.warn("[header] failed to open draft mini chat window",N)})},[Ce,Le,kt]),nn=c.useCallback(()=>{if(a){fn();return}d&&Fn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Ae||kn(Je||"")||Me,apiBaseUrl:Dn(),clientToken:Yr()}).catch(N=>{console.warn("[header] failed to open session mini chat window",N)})},[d,fn,a,Je,Ae,Me]),mn=c.useCallback(()=>{const N=kn(et||"");if(!N)return;const ye=Ne.getState().contextPanelByDirectory[N];if(rc(ye)==="context"){r(N);return}n(N)},[r,n,et]),vn=it==="context",ks=Vo,rn=c.useMemo(()=>g&&E&&!C?"88px":S?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!g||R)&&!H?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[g,C,E,S,H,R]);ut.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",rn)},[rn]);const zs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Ws=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ut.useEffect(()=>{if(!g||!E){v(!1);return}let N=!1;const ye=async()=>{try{const lt=await Fn("desktop_is_window_fullscreen");N||v(lt===!0)}catch{N||v(!1)}},$e=()=>{ye()};return ye(),window.addEventListener("openchamber:window-resized",$e),()=>{N=!0,window.removeEventListener("openchamber:window-resized",$e)}},[g,E]);const as=c.useMemo(()=>!g||!E||O===null?"":O>=26?"h-12":O<=15?"h-14":"",[g,E,O]),Gs=c.useMemo(()=>{if(!(g&&!R||H)&&!(R&&A==="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))"}},[g,H,R,A]),gs=c.useCallback(()=>{if(typeof document>"u")return;const N=h.current?.getBoundingClientRect().height;N&&document.documentElement.style.setProperty("--oc-header-height",`${N}px`)},[]);ut.useEffect(()=>{if(typeof window>"u")return;gs();const N=h.current;if(!N||typeof ResizeObserver>"u")return()=>{};let ye=0;const $e=()=>{ye||(ye=requestAnimationFrame(()=>{ye=0,gs()}))},lt=new ResizeObserver($e);return lt.observe(N),window.addEventListener("resize",$e),window.addEventListener("orientationchange",$e),()=>{ye&&cancelAnimationFrame(ye),lt.disconnect(),window.removeEventListener("resize",$e),window.removeEventListener("orientationchange",$e)}},[gs]),ut.useEffect(()=>{gs()},[gs,w,as]);const us=c.useCallback(async N=>{const ye=N.target;ye.closest(".app-region-no-drag")||ye.closest("button, a, input, select, textarea")||N.button===0&&g&&await Km()},[g]),qs=c.useCallback(N=>sr(so(N,i)),[i]);Sp({rename_current_session:()=>{if(!d||w)return!1;Et()},toggle_services_menu:()=>{if(P){D(!1);return}D(!0),z()}});const Sn=s.jsxs(s.Fragment,{children:[Tt?s.jsx($b,{projectRef:Tt.projectRef,directory:Tt.directory,className:"mr-2"}):null,s.jsx(hb,{directory:Ct,className:"mr-1"}),g?s.jsx(my,{isDesktopApp:g,currentInstanceLabel:I,currentInstanceIsLocal:Z,isDesktopServicesOpen:P,setIsDesktopServicesOpen:D,refreshCurrentInstanceLabel:z,shortcutLabel:qs,remoteUpdateInfo:xe,remoteUpdateChecking:Re,remoteUpdateError:fe,onOpenRemoteUpdate:de}):null]}),Ys=b&&(a||!!d),hn=c.useCallback(({session:N,open:ye,isActive:$e,select:lt,closeOtherTabs:Pt,components:Dt})=>{const{Item:pt,Separator:qt}=Dt,wt=$e&&!H&&!kt&&oe&&!oe.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(pt,{onClick:()=>{$e||lt(),Ve.current=N.id},children:[s.jsx(_,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ma,{sessionID:N.id,directory:N.directory,open:ye,Item:pt}),s.jsxs(pt,{onClick:()=>At(N.id),children:[s.jsx(_,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(qt,{}),$e?s.jsxs(pt,{onClick:()=>{He()},children:[s.jsx(_,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,$e?qe(pt):null,wt?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(pt,{disabled:!Ae||Ye||f,onClick:dt,className:"w-full",children:[s.jsx(_,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ye?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(qt,{}),s.jsxs(pt,{onClick:Pt,children:[s.jsx(_,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(qt,{}),s.jsxs(pt,{onClick:()=>gt({action:"archive",sessionId:N.id}),children:[s.jsx(_,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(pt,{className:"text-destructive focus:text-destructive",onClick:()=>gt({action:"delete",sessionId:N.id}),children:[s.jsx(_,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[At,oe,He,kt,Ye,f,H,dt,qe,Ae,t]),on=()=>s.jsxs("div",{onMouseDown:us,className:Ee("app-region-drag relative flex h-12 select-none items-center",R&&A==="right"?"pr-0":"pr-3",as),style:Gs,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:zs}}),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:Ws}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Xt?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Ne.getState().closeMainSurfaces(),children:s.jsx(_,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Xt.title}),Xt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Xt.subtitle}):null]})]}):H||!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:[Q?s.jsx(_,{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(ql,{align:"start",children:s.jsx("button",{type:"button",className:ks,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(_,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[me?s.jsxs("form",{ref:We,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),yt()},children:[s.jsx("input",{ref:Ie,value:Xe,onChange:N=>nt(N.target.value),onKeyDown:N=>qi(N,()=>De(!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(_,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>De(!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(_,{name:"close",className:"size-4"})})]}):a?null:s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ge}),Pe?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:[x?s.jsx("span",{className:"truncate",children:x}):null,mt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(_,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:mt})]}):null,!a&&Fe?s.jsxs("span",{className:Ee("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(_,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:_e})]}):null]}):null]}),s.jsx("div",{className:Ee("flex h-[18px] shrink-0 items-center justify-center",Pe?"self-start":"self-center"),children:d&&!a&&!me?s.jsxs(Ls,{open:K,onOpenChange:Se,onOpenChangeComplete:N=>{!N&&Ve.current&&Ve.current===d&&(Ve.current=null,Et())},children:[s.jsx(Fs,{asChild:!0,children:s.jsx(ct,{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(_,{name:"more",className:"size-4"})})}),s.jsxs(_s,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Ht,{onClick:()=>{Ve.current=d},children:[s.jsx(_,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ma,{sessionID:d,directory:Ae,open:K,Item:Ht}),s.jsxs(Ht,{onClick:()=>d&&At(d),children:[s.jsx(_,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Es,{}),s.jsxs(Ht,{onClick:()=>{He()},children:[s.jsx(_,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),qe(Ht),!H&&!kt&&oe&&!oe.parentId?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Ht,{disabled:!Ae||Ye||f,onClick:dt,className:"w-full",children:[s.jsx(_,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ye?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Es,{}),s.jsxs(Ht,{onClick:()=>{d&&gt({action:"archive",sessionId:d})},children:[s.jsx(_,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Ht,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&gt({action:"delete",sessionId:d})},children:[s.jsx(_,{name:"delete-bin",className:"mr-1 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(ql,{align:"start",children:s.jsx("button",{type:"button",className:ks,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(_,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Gb,{renderMenu:hn,suppressActiveTabControls:me,onMenuOpenChangeComplete:N=>{!N&&Ve.current&&Ve.current===d&&(Ve.current=null,Et())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:me?s.jsxs("form",{ref:We,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),yt()},children:[s.jsx("input",{ref:Ie,value:Xe,onChange:N=>nt(N.target.value),onKeyDown:N=>qi(N,()=>De(!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(_,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>De(!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(_,{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:a?t("sessions.switcher.draftTitle"):Ge})})})]}),Xt||H||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[q&&L?s.jsx(Ex,{reading:Rx(L),contextLimit:L.contextLimit,outputLimit:L.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:mn,pressed:vn,className:Ys?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(fy,{visible:Ys,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:nn,className:Ee(ks,"mr-1"),Icon:"picture-in-picture-2"}),H?null:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":re,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:ge,className:Ee(Vo,"mr-1",re?"text-foreground":"text-muted-foreground/50"),children:s.jsx(_,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t(ce&&!G?we?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":ce?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),Sn,s.jsx(Yu,{visible:R&&A==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:on()}),s.jsx(Ps,{open:Ze!==null,onOpenChange:N=>{N||gt(null)},children:s.jsxs(Ds,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(sn,{children:[s.jsx(Us,{children:Ze?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Hs,{children:Ze?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Ge}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Ge})})]}),s.jsxs(zn,{children:[s.jsx(ct,{variant:"outline",size:"sm",onClick:()=>gt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ct,{variant:"destructive",size:"sm",onClick:()=>{Ot()},children:Ze?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Ud,{open:ue,onOpenChange:se,info:xe,downloading:!1,downloaded:!1,progress:null,error:fe,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function py(){}const oc=280,ic=264,ac=500,gy=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=Nt(),l=Ne(v=>v.sidebarWidth),a=Ne(v=>v.setSidebarWidth),[d,u]=c.useState(!1),m=c.useRef(0),f=c.useRef(l||oc),p=c.useRef(null),y=c.useRef(null),x=c.useRef(null),k=c.useCallback(v=>Math.min(ac,Math.max(ic,v)),[]),w=c.useCallback(v=>{const E=x.current;E&&(E.style.width=`${v}px`,E.style.minWidth=`${v}px`,E.style.maxWidth=`${v}px`,E.style.setProperty("--oc-left-sidebar-width",`${v}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(p.current=null,y.current=null)},[d]),e)return null;const h=Math.min(ac,Math.max(ic,l||oc)),g=t?h:0,j=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}y.current=v.pointerId,u(!0),m.current=v.clientX,f.current=g,p.current=g,w(g),v.preventDefault()}},b=v=>{if(e||!d||y.current!==v.pointerId)return;const E=v.clientX-m.current,R=k(f.current+E);p.current!==R&&(p.current=R,w(R))},S=v=>{if(y.current!==v.pointerId||e)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const E=k(p.current??g);y.current=null,p.current=null,u(!1),a(E)},C=d?p.current??g:g;return s.jsxs("aside",{ref:x,className:Ee("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${d?C:h}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||g===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:Ee("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:j,onPointerMove:b,onPointerUp:S,onPointerCancel:S,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Ee("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(En,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Cs,{children:n})})]})]})},xy=()=>{const t=tt.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},uo="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-ring hover:bg-interactive-hover transition-colors",by=()=>{const t=tt.c(37),{t:e}=Nt(),n=Ne(yy),r=Ne(wy),i=Ne(vy),o=c.useRef(null),l=sr(so("toggle_sidebar",i)),a=Sy,{usesFramelessChrome:d,side:u}=qu(),m=ky;let f,p;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const L=o.current;if(!L)return;const W=()=>{const P=Math.max(L.getBoundingClientRect().width,L.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(P)}px`)};if(W(),typeof ResizeObserver>"u")return;const $=new ResizeObserver(W);return $.observe(L),()=>{$.disconnect()}},p=[],t[0]=f,t[1]=p):(f=t[0],p=t[1]),c.useEffect(f,p);const y="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let x;t[2]===Symbol.for("react.memo_cache_sentinel")?(x={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=x):x=t[2];const k="flex items-center gap-2";let w;t[3]!==d||t[4]!==u?(w=d&&u==="left"?s.jsx(Yu,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=w):w=t[5];let h;t[6]!==e||t[7]!==d?(h=d?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,"aria-label":e("header.actions.openAppMenuAria"),className:Ee(uo,"shrink-0"),children:s.jsx(_,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=h):h=t[8];const g=vt;let j;t[9]!==e?(j=e("header.actions.openSessionsAria"),t[9]=e,t[10]=j):j=t[10];let b,S;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=Ee(uo,"shrink-0"),S=s.jsx(_,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=b,t[12]=S):(b=t[11],S=t[12]);let C;t[13]!==j||t[14]!==n?(C=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":j,className:b,children:S})}),t[13]=j,t[14]=n,t[15]=C):C=t[15];const v=jt,E=e("header.actions.openSessionsWithShortcut",{shortcut:l});let R;t[16]!==E?(R=s.jsx("p",{children:E}),t[16]=E,t[17]=R):R=t[17];let A;t[18]!==v||t[19]!==R?(A=s.jsx(v,{children:R}),t[18]=v,t[19]=R,t[20]=A):A=t[20];let O;t[21]!==g||t[22]!==C||t[23]!==A?(O=s.jsxs(g,{children:[C,A]}),t[21]=g,t[22]=C,t[23]=A,t[24]=O):O=t[24];let B;t[25]!==a||t[26]!==r||t[27]!==e?(B=r?s.jsxs("button",{type:"button",onClick:a,className:Ee(uo,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(_,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Ee(uo,"-ml-1 shrink-0"),children:s.jsx(_,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=B):B=t[28];let T;t[29]!==O||t[30]!==B||t[31]!==w||t[32]!==h?(T=s.jsxs("div",{ref:o,className:k,children:[w,h,O,B]}),t[29]=O,t[30]=B,t[31]=w,t[32]=h,t[33]=T):T=t[33];let M;return t[34]!==T||t[35]!==x?(M=s.jsx("div",{className:y,style:x,children:T}),t[34]=T,t[35]=x,t[36]=M):M=t[36],M};function yy(t){return t.toggleSidebar}function wy(t){return t.isSidebarOpen}function vy(t){return t.shortcutOverrides}function Sy(){Ne.getState().closeMainSurfaces(),rt.getState().openNewSessionDraft()}function jy(t){console.warn("[titlebar] failed to open app menu",t)}function ky(t){const e=t.currentTarget.getBoundingClientRect();Fn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(jy)}function ff(t){const e=tt.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(_,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const lc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Cy(t,e,n){const r=tt.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,m]=await Promise.all([jp(t),kp(t)]).catch(Ny);if(d)return;const f=lc(u),p=lc(m);if(!f||!p||p===f)return;const y=n||"",x=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:f,branch:y,label:y||x,name:x,worktreeRoot:p,worktreeStatus:"ready",headState:y?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function Ny(){return["",""]}const cc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Ay=async(t,e)=>{if(t)return t.authActivate(e);const n=await bs("/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},dc=({className:t})=>{const{t:e}=Nt(),{github:n}=wn(),r=In(y=>y.status),i=In(y=>y.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async y=>{if(!(!y||o)){l(!0);try{i(await Ay(n,y))}catch(x){console.error("Failed to switch GitHub account:",x)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,m=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),p=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(_,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return m.length<=1?s.jsx("div",{className:Ee(cc,t),title:f,children:p}):s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee(cc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:p})}),s.jsxs(_s,{align:"end",className:"w-64",children:[s.jsx(_r,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Es,{}),m.map(y=>{const x=y.user,k=!!y.current,w=y.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Ht,{className:"gap-2",disabled:o,onSelect:()=>{k||a(y.id)},children:[x?.avatarUrl?s.jsx("img",{src:x.avatarUrl,alt:x.login?e("header.github.avatarWithLogin",{login:x.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(_,{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:x?.name?.trim()||x?.login||"GitHub"}),x?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:x.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:w})]}):null]}),k?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},y.id)})]})]})};class gi 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 xi="/api/walkthrough",mf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),hf=()=>new gi("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Py=t=>!mf(t)&&(t.ok||t.status===404),el=async(t,e)=>{if(Py(t))throw hf();const n=await t.json().catch(()=>null);throw new gi(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})},pf=async t=>{if(!mf(t))throw hf();try{return await t.json()}catch{throw new gi("The server returned a malformed walkthrough response")}};async function Dy(t,e,n={}){const r=await bs(xi,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?pf(r):el(r,"Failed to load walkthrough")}async function Iy(t,e,n={}){const r=await bs(`${xi}/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?pf(r):el(r,"Failed to generate walkthrough")}async function Ty(t,e){const n=await bs(`${xi}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await el(n,"Failed to cancel walkthrough generation")}async function Ey(t,e,n){const r=await bs(`${xi}/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 Ir={status:"idle",stage:null,result:null,readiness:null,error:null},Ry=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}`,Rn=(t,e)=>`${Qt()}\0${t}\0${Ry(e)}`,uc=t=>t instanceof gi?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Js=new Map,Tr=new Map,My=1e3,Oy=no()(eb((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Rn(n,r)],selectModel:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Rn(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[Rn(n,r)]??Ir,load:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);if(e().entries[o]?.status==="generating")return;Js.get(o)?.abort();const a=new AbortController;Js.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Ir,status:"loading",error:null}}}));try{const d=await Dy(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Ir,status:"error",stage:null,error:uc(d)}}}))}finally{Js.get(o)===a&&Js.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);Js.get(o)?.abort();const l=new AbortController;Js.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Ir,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Tr.get(o);d!==void 0&&(clearInterval(d),Tr.delete(o))};a(),Tr.set(o,setInterval(()=>{Ey(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const m=u.entries[o];return!m||m.status!=="generating"||m.stage===d?u:{entries:{...u.entries,[o]:{...m,stage:d}}}})}).catch(()=>{})},My));try{const d=await Iy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Ir,status:"error",stage:null,error:uc(d)}}}))}finally{a(),Js.get(o)===l&&Js.delete(o)}},cancel:(n,r)=>{const i=Rn(n,r);Ty(n,r).catch(()=>{}),Js.get(i)?.abort(),Js.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 Js.values())n.abort();Js.clear();for(const n of Tr.values())clearInterval(n);Tr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),By="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)]",Fy=3e4,fc=20,gf=(t,e)=>JSON.stringify([Qt(),t,e]),_y=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}},mc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),fo=new Map,Ly=t=>{const e=Object.entries(t);return e.length<=fc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,fc))},hc=no()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=gf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<Fy&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const m=`${l}::${a?"details":"plain"}`,p=fo.get(`${l}::details`)??(a?null:fo.get(m));if(p&&!o?.force)return p;const y=(async()=>{t(x=>({entries:{...x.entries,[l]:{...x.entries[l]??mc(),isLoading:!0,error:null}}}));try{const x=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(k=>({entries:Ly({...k.entries,[l]:{result:x,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),x}catch(x){const k=x instanceof Error?x.message:"Failed to load pull request context";return t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??mc(),isLoading:!1,error:k}}})),null}finally{fo.delete(m)}})();return fo.set(m,y),y},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=_y(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),$y=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}:{}}},zy=35e3,Ei=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},Ri=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},pc=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"}},Wy=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"},Ky=[2e3,5e3],Vy=600,gc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),On=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):""},Uy=(t,e)=>{const n=On(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},Hy=(t,e)=>`${t}::${e}`,tl=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},Mi=(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=tl(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)},Gy=t=>t.startsWith("pr-"),qy=(t,e)=>{const n=tl(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=>!Gy(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Er=new Map,mo=eo;function Yy(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const Qy=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=Nt(),d=Ne(N=>N.timeFormatPreference),{github:u}=wn(),m=In(N=>N.status),f=In(N=>N.hasChecked),p=Ne(N=>N.setSettingsDialogOpen),y=Ne(N=>N.setSettingsPage),x=rt(N=>N.currentSessionId),k=rt(N=>!!N.newSessionDraft?.open),{isMobile:w,hasTouchInput:h,screenWidth:g}=$n(),j=Ne(N=>N.openContextSurface),b=Oy(N=>N.requestSource),S=!w&&g>=768&&!_n(),C=c.useCallback(()=>{y("integrations"),p(!0)},[p,y]),v=c.useMemo(()=>Hy(t,e),[t,e]),E=c.useMemo(()=>Er.get(v)??null,[v]),R=Vs(N=>N.ensureEntry),A=Vs(N=>N.setParams),O=Vs(N=>N.startWatching),B=Vs(N=>N.stopWatching),T=Vs(N=>N.refresh),M=Vs(N=>N.updateStatus),[L,W]=c.useState(()=>E?.title??gc(e)),[$,P]=c.useState(()=>E?.body??""),[D,I]=c.useState(()=>E?.draft??!1),[X,Z]=c.useState(()=>E?.additionalContext??""),[ne,ue]=c.useState(()=>{const N=typeof E?.targetBaseBranch=="string"?On(E.targetBaseBranch):"";return N||On(n)}),[se,xe]=c.useState("squash"),[ie,Re]=c.useState(!1),[be,fe]=c.useState(!1),[ke,H]=c.useState(!1),[J,ce]=c.useState(!1),[je,G]=c.useState(!1),[we,Te]=c.useState(!1),[he,re]=c.useState(null),[ge,q]=c.useState(""),[z,ee]=c.useState(""),[de,Y]=c.useState(!1),[U,F]=c.useState(!1),[V,oe]=c.useState(()=>Mi(i,{selectedRemoteName:E?.selectedRemoteName,trackingBranch:r})),[ae,pe]=c.useState(!1),{detectedUpstream:le,upstreamBranches:_e}=Yy(t,u);c.useEffect(()=>{pe(!1)},[t]);const Fe=i.some(N=>N.name==="upstream"),Ae=!!(t&&e&&n&&(e!==n||(Fe||le!==null))),Q=c.useMemo(()=>ei(t,e,V?.name??null),[t,e,V?.name]),Ce=Vs(N=>N.entries[Q]),Be=Ce?.isLoading??!1,Le=Ce?.status??null,Je=Ce?.error??null,ot=Ce?.isInitialStatusResolved??!1,et=c.useMemo(()=>{const N=ae?null:V?.name?.trim()||null,ye=new Set;for(const Pt of o){const Dt=Uy(Pt,N);!Dt||Dt==="HEAD"||ye.add(Dt)}if(ae)for(const Pt of _e)Pt&&Pt!=="HEAD"&&ye.add(Pt);const $e=On(n);$e&&$e!=="HEAD"&&ye.add($e);const lt=On(ne);return lt&&lt!=="HEAD"&&ye.add(lt),Array.from(ye).sort((Pt,Dt)=>Pt.localeCompare(Dt))},[n,o,V?.name,ne,_e,ae]);c.useEffect(()=>{if(i.length===0){V&&oe(null);return}(!V||!i.some(N=>N.name===V.name))&&oe(Mi(i,{selectedRemoteName:E?.selectedRemoteName,trackingBranch:r}))},[E?.selectedRemoteName,i,V,r]),c.useEffect(()=>{const N=On(n);if(!ne&&N){ue(N);return}if(et.length!==0&&!et.includes(ne)){const ye=et.includes(N)?N:et[0];ye&&ue(ye)}},[et,n,ne]);const[it,ht]=c.useState(()=>E?.activeSegment??"overview"),[st,mt]=c.useState(new Set),[kt,Pe]=c.useState(new Set),Ge=c.useRef(new Set),at=c.useRef(null),ze=c.useRef(!1),ft=c.useRef(new Set),te=c.useRef([]);c.useEffect(()=>{le&&!Fe&&pe(!0)},[le,Fe]),c.useEffect(()=>{ae&&le?.defaultBranch&&ue(le.defaultBranch)},[ae,le?.defaultBranch]);const me=Le?.pr??null,De=me?.state==="merged"||me?.state==="closed",K=De?null:me,Se=K?gf(t,K.number):null,Ve=hc(N=>Se?N.entries[Se]:void 0),Xe=hc(N=>N.ensure),nt=Ve?.result??null,Ze=Ve?.isLoading??!1,gt=c.useCallback(N=>{ht(N);const ye=Er.get(v);ye&&Er.set(v,{...ye,activeSegment:N})},[v]);c.useEffect(()=>{!K||!u?.prContext||it==="overview"||Xe(u,t,K.number,{includeCheckDetails:it==="checks",sourceRepo:Le?.repo??null})},[it,t,Xe,u,K,Le?.repo]);const We=Le?.checks??null,Et=(We?.pending??0)>0,Ft=nt?.checkRuns??null,Ie=nt?.fetchedAt;c.useEffect(()=>{if(!Ft||Ft.length===0)return;const N=$y(Ft);M(Q,ye=>{if(!ye?.pr||typeof Ie=="number"&&typeof ye.fetchedAt=="number"&&Ie<ye.fetchedAt)return ye;const $e=ye.checks;return $e&&$e.state===N.state&&$e.total===N.total&&$e.success===N.success&&$e.failure===N.failure&&$e.pending===N.pending&&$e.inProgress===N.inProgress&&$e.queued===N.queued&&$e.startedAt===N.startedAt?ye:{...ye,checks:N,...typeof Ie=="number"?{fetchedAt:Ie}:{}}})},[Ft,Ie,Q,M]),c.useEffect(()=>{if(it!=="checks"||!Et||!me||!u?.prContext)return;const N=window.setInterval(()=>{Xe(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Le?.repo??null,force:!0})},zy);return()=>window.clearInterval(N)},[it,Et,t,Xe,u,me,Le?.repo]);const[yt,At]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Et)return;At(Date.now());const N=window.setInterval(()=>At(Date.now()),3e4);return()=>window.clearInterval(N)},[Et]);const He=me?`${t}#${me.number}`:null,Ue=!!(He&&he===He);c.useEffect(()=>{if(!u?.prContext||!me||typeof me.body=="string"&&me.body.length>0)return;const N=`${t}#${me.number}`;if(Ge.current.has(N))return;Ge.current.add(N),re(N);let ye=!1;return Xe(u,t,me.number,{sourceRepo:Le?.repo??null}).then($e=>{if(ye)return;const lt=$e?.pr;lt&&M(Q,Pt=>!Pt?.pr||Pt.pr.number!==me.number?Pt:{...Pt,pr:{...Pt.pr,body:lt.body||""}})}).catch(()=>{}).finally(()=>{ye||re($e=>$e===N?null:$e)}),()=>{ye=!0}},[t,Xe,u,me,Q,Le?.repo,M]),c.useEffect(()=>{if(!me){Te(!1),q(""),ee(""),at.current=null;return}const N=at.current!==null&&at.current!==me.number;N&&Te(!1),(!we||N)&&(q(me.title||""),ee(me.body||"")),at.current=me.number},[we,me]);const ve=c.useCallback(N=>{if(!N)return"";const ye=Date.parse(N);return Number.isFinite(ye)?yu(ye,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):N},[d]),Qe=c.useMemo(()=>{const N=m?.user?.login;return typeof N=="string"?N.trim():""},[m]),qe=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)]",[]),Ye=c.useCallback(N=>{const ye=Qe.toLowerCase(),$e=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return N.replace($e,(lt,Pt,Dt)=>{const pt=`@${Dt}`,qt=Dt.toLowerCase();return`${Pt}[${pt}](https://github.com/${qt}${ye&&qt===ye?"?oc-self-mention=1":""})`})},[Qe]),dt=c.useMemo(()=>{const N=(nt?.issueComments??[]).map(lt=>({id:`issue-${lt.id}`,body:lt.body||"",authorName:lt.author?.name||lt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:lt.author?.login||null,avatarUrl:lt.author?.avatarUrl||null,createdAt:lt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),ye=(nt?.reviewComments??[]).map(lt=>({id:`review-${lt.id}`,body:lt.body||"",authorName:lt.author?.name||lt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:lt.author?.login||null,avatarUrl:lt.author?.avatarUrl||null,createdAt:lt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:lt.path||null,line:lt.line??null})),$e=[...N,...ye];return $e.sort((lt,Pt)=>{const Dt=lt.createdAt?Date.parse(lt.createdAt):0,pt=Pt.createdAt?Date.parse(Pt.createdAt):0,qt=Number.isFinite(Dt)?Dt:0,wt=Number.isFinite(pt)?pt:0;return qt-wt}),$e},[nt,a]),Ot=c.useCallback(()=>{const N=x??(k?"draft":null);return N?{directory:t,sessionKey:N}:(Ke.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[x,t,k,a]),zt=c.useCallback((N,ye)=>{const $e=ye.authorLogin?`@${ye.authorLogin}`:ye.authorName,lt=ye.path?` · ${ye.path}${ye.line?`:${ye.line}`:""}`:"";Ji.getState().addDraft(N,{source:"pr-comment",fileLabel:`PR #${me?.number??""} ${$e}${lt}`,startLine:ye.line??0,endLine:ye.line??0,code:ye.body,language:"markdown",text:""})},[me?.number]),Kt=c.useCallback((N,ye)=>{const $e=N.status||"unknown",lt=N.conclusion??void 0,Pt=lt?`${$e} / ${lt}`:$e,Dt=N.app?.name||N.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:ye?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[ye?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:N.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Dt?`${Dt} · ${Pt}`:Pt})]}),N.detailsUrl?s.jsx(ct,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:N.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(_,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),N.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:N.output.title}):null,N.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:N.output.summary}):null,N.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:N.output.text}):null,Array.isArray(N.annotations)&&N.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",N.annotations.length>20?` (showing 20/${N.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:N.annotations.slice(0,20).map((pt,qt)=>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||qt}:${qt}`))})]}):null,N.job?.steps&&N.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:N.job.steps.map((pt,qt)=>{const wt=(pt.conclusion||"").toLowerCase(),bt=wt&&!["success","neutral","skipped"].includes(wt),It=`${N.id??"run"}:${N.job?.jobId??"job"}:${pt.number??qt}:${pt.name}`,Lt=st.has(It);return bt?s.jsxs(Zi,{open:Lt,children:[s.jsxs("button",{type:"button",onClick:()=>{mt(Zt=>{const $t=new Set(Zt);return $t.has(It)?$t.delete(It):$t.add(It),$t})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(bt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Lt?s.jsx(_,{name:"arrow-down-s",className:"size-4"}):s.jsx(_,{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(ea,{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"),": ",ve(pt.startedAt)]}):null,pt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",ve(pt.completedAt)]}):null]})})]},It):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]},It)})})]}):null]})},[st,ve,a]),[Gt,Bt]=c.useState(!1),[Jt,Vt]=c.useState(!1),Wt=c.useCallback(async()=>{if(!u?.prContext){Ke.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!me)return;const N=Ot();if(N){Bt(!0);try{const ye=await Xe(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Le?.repo??null});if(!ye){Ke.error(a("gitView.pr.toast.loadChecksFailed"));return}const lt=(ye.checkRuns??[]).filter(Dt=>Ri(Dt.conclusion));if(lt.length===0){Ke.message(a("gitView.pr.toast.noFailedChecks"));return}const Pt=Ji.getState();for(const Dt of lt){const pt=(Dt.annotations??[]).map(bt=>[[bt.level,bt.title].filter(Boolean).join(" "),bt.path?`${bt.path}${typeof bt.startLine=="number"?`:${bt.startLine}`:""}`:null,bt.message,bt.rawDetails].filter(Boolean).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-Cj3K8Xz6.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-ZM9ij19-.js","assets/index-CvLgnuNI.js","assets/vendor-zod-Gea9uBlY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-_BAHQo4R.js","assets/index-CLcM8HKx.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.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-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/contextPanelEmbeddedChat-CirXEPJq.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-U-lXzXNK.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-D9iBcTEi.js","assets/runtimeEndpointReset-DeaERc0M.js","assets/GuestAttachDialog-BIa9jCfL.js","assets/PluginPane-BibJit86.js","assets/VirtualizedFileDiff-BfEBad09.js","assets/web-components-C583Pmfm.js","assets/computeVirtualFileMetrics-RF-KjfUH.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-D2yJ9fO6.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-BlDmw3-A.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-CkfxMJPy.js","assets/appThemeRegistry-DAdawJZn.js","assets/textMateThemeFromAppTheme-C95XdFGj.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-BtiAC1fj.js","assets/scheduledTasksApi-BD6Vx9pu.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-CX3wAX2S.js","assets/SubmoduleDiffSummary-DeFmhPFZ.js","assets/FilesView-OL3CON3r.js","assets/shikiHighlight-_HeCCHx1.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-CtI1Mqwo.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-BwMEq1Ey.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-CWhdh0wf.js","assets/GitView-DKIjpnu4.js","assets/commitAndPush-BIPfOMXY.js","assets/LinearIssuesView-BD2zLu-r.js","assets/PlanView-DyH2SyCP.js","assets/GuestSurfacePane-B_cqX5I5.js","assets/SettingsWindow-y9WpZqK6.js","assets/SettingsView-h-VpVO47.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-B8TxloXZ.js"])))=>i.map(i=>d[i]);
2
+ import{f as tt,R as c,j as s,r as ut,c as Om,h as Bm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{E as xn,F as Zo,H as Fm,I as _m,h as bs,x as Od,u as Ne,J as Mt,K as pl,a as Qt,y as Cr,o as xt,L as Ts,N as qr,O as _n,P as Bd,Q as Lm,R as $m,S as zm,T as Wm,U as Fd,n as os,V as Fn,W as Yr,e as Dn,X as Km,Y as Vm,Z as Um,_ as Hm,$ as _d,v as pn,B as dn,a0 as Gm,a1 as gl,a2 as qm,a3 as Ld,a4 as Ym,a5 as $d,f as Qm,a6 as Qn,a7 as tr,a8 as Fo,a9 as Ui,aa as Xm,ab as Ma,d as _o,t as Fr,q as Ns,ac as zd,ad as Jm,ae as Hi,af as Wd,ag as Kd,i as Zm,ah as Po,ai as Do,aj as eh,ak as xl,al as th,am as sh,an as nh,ao as rh,ap as bl,aq as yl,ar as wl,as as vl,at as oh,A as Sl,au as ih,av as ah,aw as lh,C as ch,D as dh}from"./index-CvLgnuNI.js";import{_ as yn}from"./vendor-vite-runtime-DD1OZmLC.js";import{y as jl,z as ki,E as an,F as Gi,G as kl,H as uh,I as fh,J as mh,K as hh,L as ph,M as gh,Q as xh,R as bh,V as Oa,a as yh,e as Vd,W as Ud,h as qi,l as Hd,X as wh,k as vh,j as Sh,Y as Gd,Z as Yi,_ as Xn,$ as qd,a0 as Yd,P as jh,T as kh,a1 as Ch,a2 as Nh,a3 as Ah,b as Qd,a4 as Ph,a5 as Xd,a6 as Lo,a7 as Dh,a8 as Ih,a9 as Th,S as Ci,aa as Jd,ab as Zd,d as Eh,ac as Rh,c as Mh,ad as Oh,r as Cl,ae as Bh,af as Fh,ag as lo,u as Kr,s as _h,N as Lh,D as $h,ah as zh,ai as Nl,aj as Wh,ak as Ni,v as Kh,o as Vh,w as eu,U as Uh,x as Hh,al as Gh,am as qh,an as Yh,O as Qh,n as Xh,q as Jh,t as tu,A as Zh,C as ep}from"./runtimeEndpointReset-DeaERc0M.js";import{f as Nt,h as Ee,bh as Ht,I as _,g as cr,t as Ke,at as Fs,bi as Es,av as _s,as as Ls,T as Ln,_ as wn,ai as dr,bj as $n,o as eo,bk as Al,bl as tp,bm as sp,ae as vt,af as St,ag as jt,b as Ut,z as rt,H as np,bn as su,bo as co,u as vs,r as As,D as nu,C as ru,bp as Qi,bq as rp,br as ou,bs as iu,S as Ba,bt as op,bu as ip,bv as Pl,bw as Dl,bx as au,by as ap,bz as Il,bA as lp,bB as cp,bC as Fa,bD as Xi,bE as lu,bF as dp,bG as up,bH as fp,Q as cu,bI as mp,bJ as hp,bK as pp,n as hr,bL as du,bM as gp,bN as xp,p as bp,bO as uu,bP as yp,bQ as wp,bR as vp,bS as fu,bT as mu,bU as hu,bV as pu,bW as gu,bX as xu,bY as bu,bZ as to,b_ as _a,aJ as La,b$ as sr,c0 as so,c1 as Sp,c2 as Ps,c3 as Ds,c4 as sn,c5 as Us,c6 as Hs,c7 as zn,B as ct,c8 as En,aB as Cs,c9 as jp,ca as kp,aH as In,cb as _r,cc as Vs,cd as ei,ce as yu,cf as Ji,cg as Zi,ch as ea,ci as Cp,cj as Rs,ck as Ms,cl as js,cm as Os,cn as rs,X as An,co as pr,cp as Tl,cq as xr,cr as wu,R as ti,aj as Np,ak as $a,al as vu,J as Su,K as Tn,cs as za,a9 as Wa,ct as Ap,cu as Pp,az as Dp,cv as Ip,cw as ju,cx as Tp,cy as Ep,aA as Ka,cz as Rp,cA as ku,cB as br,cC as Cu,cD as Mp,l as Yt,s as Op,cE as Bp,cF as Fp,aO as Wn,cG as _p,cH as mr,O as Nu,cI as Lp,cJ as $p,cK as Kn,cL as zp,cM as Wp,aD as Kp,cN as Ai,cO as Vp,cP as Up,cQ as Hp,cR as Au,cS as Va,cT as Gp,cU as Pu,cV as qp,aI as ta,cW as sa,cX as El,cY as Yp,cZ as Rl,c_ as Lr,c as Qr,d as Ua,a4 as Qp,a1 as Du,c$ as Dr,d0 as $r,d1 as Xp,d2 as Jp,d3 as Zp,$ as Ha,aC as eg,d4 as tg,d5 as sg,d6 as ng,d7 as rg,d8 as Iu,d9 as un,da as og,db as Tu,dc as ig,a8 as na,dd as ag,de as Eu,df as ms,dg as lg,dh as cg,di as dg,dj as Ru,dk as ug,dl as Ga,dm as Mu,a6 as $o,dn as ra,dp as si,a as qa,dq as Ya,a5 as fg,dr as Ml,U as ni,V as ri,W as oi,ds as mg,dt as oa,du as Ou,dv as hg,au as Bu,dw as pg,dx as Qa,P as ia,L as gg,dy as Ol,dz as xg,dA as bg,dB as ss,dC as yg,dD as ir,dE as Fu,dF as _u,dG as Lu,dH as $u,dI as wg,E as vg,dJ as Sg,dK as jg,dL as kg,dM as Bl,dN as zu,dO as Cg,dP as Wu,F as Ng,dQ as Ag,dR as Pg,dS as Vr,dT as Dg,dU as Ig,dV as Tg,dW as Eg,e as Xa,dX as ii,dY as Rg,dZ as Xr,a3 as Mg,G as ai,d_ as Og,d$ as Bg,e0 as Fl,e1 as Fg,e2 as _g,a0 as Lg,e3 as $g,e4 as zg,a$ as _l,ab as Ll,aa as $l,e5 as Wg,aW as aa,e6 as Kg,M as Vg,N as Pi,e7 as Ug,e8 as Hg,e9 as Ku,ea as Vu,eb as Uu,ec as Gg,ed as qg,a7 as Yg,am as Qg,ee as Xg,ef as zl,eg as Jg,eh as Zg,ei as ex,ej as tx,ek as zo,el as sx,em as Wl,en as nx,eo as rx,ep as ox,eq as ix,er as la,es as ax,et as Io,eu as lx,i as cx,ev as dx,ew as ux,ex as fx,ey as mx,ez as hx,eA as px,eB as Kl,eC as gx,aP as xx,aQ as bx,aS as yx,aR as wx,aU as Vl,aV as Ul,aY as Hl,aZ as Gl,aX as Hu,a_ as Gu,eD as vx,bc as Sx,bd as jx,be as kx,bf as Cx,bg as Nx,b6 as Ax,b8 as Px,b9 as Dx,ba as Ix,bb as Tx}from"./useAppFontEffects-ZM9ij19-.js";import{u as qu,S as ql,C as Ex,t as Rx,W as Yu,f as Mx,G as Ox,a as Bx}from"./useRootScrollLock-BtiAC1fj.js";import{u as Un,O as Yl,D as Fx,a as _x,b as Lx,c as $x,f as zx,d as Ql,s as Wx,e as Kx,g as Vx,r as Ux}from"./scheduledTasksApi-BD6Vx9pu.js";import{f as li,h as Pn,T as ci,M as di,D as ui,j as fi,d as Hx,b as Gx,k as qx,i as Yx}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as mi,S as Ja,h as Qx,a as Qu,v as Xu,s as Xx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as hi}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Ju,M as Zu,C as ef,a as ca,b as da,c as ua,d as tf,e as Jx,f as Zx}from"./vendor-base-ui-CsXYnR5c.js";import{c as no,u as ar,d as eb,p as tb}from"./vendor-zustand-BAGL70zf.js";import{g as sb,a as nb,E as sf,b as rb,c as ob,d as ib,e as ab,i as lb}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as cb}from"./PluginPane-BibJit86.js";import{a as Za,s as lr,r as nf,o as Xl,b as Jl}from"./vendor-zod-Gea9uBlY.js";import{u as db}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as ub}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as rf}from"./vendor-cron-parser-CjvYVigk.js";const fb="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",mb="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",Di=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?fb:t.id==="terminal"?mb:void 0}),Zl=t=>{const e=tt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let y;return e[3]!==u?(y=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=u,e[4]=y):y=e[4],y}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=Ee("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=m):m=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:m,children:d}),e[6]=d,e[7]=f):f=e[7],f},hb=t=>{const e=tt.c(75),{directory:n,className:r}=t,{t:i}=Nt(),o=Un(pb),l=Un(gb),a=Un(xb),d=Un(bb),u=Un(yb),m=Un(wb),f=Un(vb);let p,y;e[0]!==u?(p=()=>{u()},y=[u],e[0]=u,e[1]=p,e[2]=y):(p=e[1],y=e[2]),c.useEffect(p,y);const x=xn()&&Zo();let k;e:{let be;e[3]!==l||e[4]!==o?(be=l.find(H=>H.id===o)??l.find(Sb)??l[0]??Yl[0],e[3]=l,e[4]=o,e[5]=be):be=e[5];const fe=be;if(fe){let H;e[6]!==fe?(H=Di(fe),e[6]=fe,e[7]=H):H=e[7],k=H;break e}let ke;e[8]===Symbol.for("react.memo_cache_sentinel")?(ke=Di(Yl[0]),e[8]=ke):ke=e[8],k=ke}const w=k;if(!x||!n||l.length===0)return null;let h;e[9]!==n?(h=async be=>{await Fm(n,be.id,be.appName)||await _m(n,be.appName)},e[9]=n,e[10]=h):h=e[10];const g=h;let j;e[11]!==g||e[12]!==f?(j=async be=>{await f(be.id),await g(be)},e[11]=g,e[12]=f,e[13]=j):j=e[13];const b=j;let S;e[14]!==n||e[15]!==i?(S=async()=>{(await cr(n)).ok&&Ke.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=S):S=e[16];const C=S;let v;e[17]!==r?(v=Ee("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]=v):v=e[18];let E;e[19]!==g||e[20]!==w?(E=()=>{g(w)},e[19]=g,e[20]=w,e[21]=E):E=e[21];const R=d&&"animate-pulse";let A;e[22]!==R?(A=Ee("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",R),e[22]=R,e[23]=A):A=e[23];let O;e[24]!==w.label||e[25]!==i?(O=i("openInApp.actions.openInAria",{app:w.label}),e[24]=w.label,e[25]=i,e[26]=O):O=e[26];let B;e[27]!==w.fallbackIconDataUrl||e[28]!==w.iconDataUrl||e[29]!==w.label?(B=s.jsx(Zl,{label:w.label,iconDataUrl:w.iconDataUrl,fallbackIconDataUrl:w.fallbackIconDataUrl}),e[27]=w.fallbackIconDataUrl,e[28]=w.iconDataUrl,e[29]=w.label,e[30]=B):B=e[30];let T;e[31]!==A||e[32]!==O||e[33]!==B||e[34]!==E?(T=s.jsx("button",{type:"button",onClick:E,className:A,"aria-label":O,children:B}),e[31]=A,e[32]=O,e[33]=B,e[34]=E,e[35]=T):T=e[35];let M;e[36]===Symbol.for("react.memo_cache_sentinel")?(M=Ee("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]=M):M=e[36];let L;e[37]!==i?(L=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=L):L=e[38];let W;e[39]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=W):W=e[39];let $;e[40]!==L?($=s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:M,"aria-label":L,children:W})}),e[40]=L,e[41]=$):$=e[41];let P;e[42]!==C?(P=()=>{C()},e[42]=C,e[43]=P):P=e[43];let D;e[44]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(_,{name:"file-copy",className:"h-4 w-4"}),e[44]=D):D=e[44];let I;e[45]!==i?(I=i("openInApp.actions.copyPath"),e[45]=i,e[46]=I):I=e[46];let X;e[47]!==I?(X=s.jsx("span",{className:"typography-ui-label text-foreground",children:I}),e[47]=I,e[48]=X):X=e[48];let Z;e[49]!==P||e[50]!==X?(Z=s.jsxs(Ht,{className:"flex items-center gap-2",onClick:P,children:[D,X]}),e[49]=P,e[50]=X,e[51]=Z):Z=e[51];let ne;e[52]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(Es,{}),e[52]=ne):ne=e[52];let ue;if(e[53]!==l||e[54]!==b||e[55]!==w.id){let be;e[57]!==b||e[58]!==w.id?(be=fe=>{const ke=Di(fe);return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{b(fe)},children:[s.jsx(Zl,{label:fe.label,iconDataUrl:fe.iconDataUrl,fallbackIconDataUrl:ke.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:fe.label}),w.id===fe.id?s.jsx(_,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},fe.id)},e[57]=b,e[58]=w.id,e[59]=be):be=e[59],ue=l.map(be),e[53]=l,e[54]=b,e[55]=w.id,e[56]=ue}else ue=e[56];let se;e[60]!==a||e[61]!==m||e[62]!==i?(se=a?s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(_,{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]=m,e[62]=i,e[63]=se):se=e[63];let xe;e[64]!==Z||e[65]!==ue||e[66]!==se?(xe=s.jsxs(_s,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Z,ne,ue,se]}),e[64]=Z,e[65]=ue,e[66]=se,e[67]=xe):xe=e[67];let ie;e[68]!==$||e[69]!==xe?(ie=s.jsxs(Ls,{children:[$,xe]}),e[68]=$,e[69]=xe,e[70]=ie):ie=e[70];let Re;return e[71]!==T||e[72]!==ie||e[73]!==v?(Re=s.jsxs("div",{className:v,children:[T,ie]}),e[71]=T,e[72]=ie,e[73]=v,e[74]=Re):Re=e[74],Re};function pb(t){return t.selectedAppId}function gb(t){return t.availableApps}function xb(t){return t.isCacheStale}function bb(t){return t.isScanning}function yb(t){return t.initialize}function wb(t){return t.loadInstalledApps}function vb(t){return t.selectApp}function Sb(t){return t.id===Fx}const Wo=new Map,fa=new Set,of=()=>{for(const t of fa)t()},Ii=(t,e)=>{const n=t.trim();n&&(e.length===0?Wo.delete(n):Wo.set(n,[...e]),of())},jb=t=>{Wo.delete(t.trim())&&of()},af=[],kb=t=>Wo.get(t.trim())??af,Cb=t=>(fa.add(t),()=>{fa.delete(t)}),Nb=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=()=>kb(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(Cb,n,Ab)};function Ab(){return af}const Pb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Db=["dev","start","preview","serve"];async function Ib(t,e,n){if(!t)return null;const r=Rb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Mb(n);if(i){const o=await Ob(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 Tb(t)){const i=await Eb(),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 Tb(t){const e=`${t}/index.html`,n=await Ko(e,t);return typeof n=="string"&&n.trim().length>0}async function Eb(){try{const t=await bs("/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 Rb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Db.some(i=>n.includes(i)))return e}return null}function Mb(t){for(const{pattern:e}of Pb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ob(t){const e=await Ko(`${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 Ko(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ko(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await bs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Od()?.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 bs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Bb(t){try{const e=await Ko(`${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 cn="__openchamber_auto_discover_preview__",Fb=15e3,_b=3e3,Ti=t=>t.id===cn?"scan-2":bh.find(n=>n.key===t.icon)?.Icon??"play",Lb=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}},$b=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=Nt(),{currentTheme:l}=Ln(),{terminal:a,runtime:d}=wn(),u=dr(),{isMobile:m}=$n(),f=c.useMemo(()=>xn(),[]),p=jl(te=>te.instances),y=jl(te=>te.load),x=Ne(te=>te.terminalShell),k=Ne(te=>te.terminalLoginShells.includes(te.terminalShell)),w=Ne(te=>te.setSettingsPage),h=Ne(te=>te.setSettingsDialogOpen),g=Ne(te=>te.setSettingsProjectsSelectedId),j=Ne(te=>te.openContextPreview),b=Mt(te=>te.ensureDirectory),S=Mt(te=>te.reconcileServerSessions),C=Mt(te=>te.setTabLabel),v=Mt(te=>te.setTabIconKey),E=Mt(te=>te.setActiveTab),R=Mt(te=>te.setConnecting),A=Mt(te=>te.setTabSessionId),O=Mt(te=>te.setTabPurpose),B=Mt(te=>te.allocateActionExecution),T=Mt(te=>te.setTabLifecycle),M=Mt(te=>te.setTabPreviewUrl),L=Mt(te=>te.matchesActionExecution),W=Mt(te=>te.captureStartedActionMutationRevisions),[$,P]=c.useState([]),D=c.useRef(null),[I,X]=c.useState(null),[Z,ne]=c.useState(!1),ue=c.useRef({}),se=c.useRef({}),xe=c.useRef({}),ie=c.useRef(new Set),Re=c.useRef(0),[be,fe]=c.useState({}),ke=t?.id??null,H=t?.path??"",J=c.useMemo(()=>ke?{id:ke,path:H}:null,[ke,H]);c.useEffect(()=>{f&&y().catch(()=>{})},[f,y]);const ce=c.useCallback(async te=>{await eo(te)},[]),je=c.useCallback(async()=>{if(!J)return;const te=Re.current+1;Re.current=te,ne(!0);try{const me=await Al(J);if(Re.current!==te)return;D.current=me;const De=me.projectActions;P(De),X(K=>K===cn||K&&De.some(Se=>Se.id===K)?K:null)}catch{if(Re.current!==te)return}finally{Re.current===te&&ne(!1)}},[J]),G=c.useMemo(()=>ki(e||J?.path||""),[e,J?.path]),we=c.useMemo(()=>ki(J?.path||""),[J?.path]),Te=c.useMemo(()=>ki(u||"")||G,[u,G]),he=c.useRef(Te);c.useEffect(()=>{he.current=Te},[Te]);const re=Mt(te=>G?te.getDirectoryState(G):void 0),ge=Mt(te=>we&&we!==G?te.getDirectoryState(we):void 0),q=c.useMemo(()=>{const te=G?[{directory:G,state:re}]:[];return we&&we!==G&&te.push({directory:we,state:ge}),te},[re,G,we,ge]),z=c.useMemo(()=>{const te=G?[G]:[];return we&&we!==G&&te.push(we),te},[G,we]),ee=c.useCallback(te=>te.id!==cn&&te.runIn==="parent"&&we||G,[G,we]),de=c.useCallback((te,me,De)=>`${te}::${me}::${De}`,[]),Y=c.useCallback((te,me,De=Mt.getState())=>te?De.getDirectoryState(te)?.tabs.find(K=>K.purpose.type==="project-action"&&K.purpose.actionId===me)??null:null,[]),U=c.useMemo(()=>{const te={};for(const{directory:me,state:De}of q)for(const K of De?.tabs??[]){if(K.purpose.type!=="project-action"||!K.purpose.executionId||!K.terminalSessionId||K.lifecycle==="idle"||K.lifecycle==="exited")continue;const Se=an(me,K.purpose.actionId),Ve=de(me,K.purpose.actionId,K.purpose.executionId);te[Se]={directory:me,actionId:K.purpose.actionId,tabId:K.id,sessionId:K.terminalSessionId,executionId:K.purpose.executionId,status:K.lifecycle==="stopping"?"stopping":be[Ve]?"waiting-for-preview":"running"}}return te},[de,be,q]),F=c.useCallback((te,me,De)=>{const K=an(te,me),Se=de(te,me,De),Xe=ue.current[K]?.executionId===De,nt=globalThis.window,Ze=gt=>{nt?.clearTimeout(xe.current[gt]),delete xe.current[gt]};Xe&&(delete ue.current[K],Ze(K)),se.current[Se]?.(),delete se.current[Se],Ze(Se),fe(gt=>{if(!gt[Se])return gt;const We={...gt};return delete We[Se],We})},[de]),V=c.useCallback(te=>{se.current[te]?.(),delete se.current[te]},[]),oe=c.useCallback(te=>{window.clearTimeout(xe.current[te]),delete xe.current[te]},[]);c.useEffect(()=>{const te=se.current,me=xe.current;return()=>{for(const De of Object.keys(te))V(De);for(const De of Object.keys(me))oe(De)}},[oe,V]),c.useEffect(()=>{const te=new Set(z);for(const me of Object.values(ue.current))te.has(me.directory)||F(me.directory,me.actionId,me.executionId);for(const me of Object.keys(se.current)){const De=me.split("::",1)[0]??"";te.has(De)||V(me)}},[F,V,z]);const ae=c.useCallback((te,me)=>{Ne.getState().openContextPanelTab(te,{mode:"terminal",targetDirectory:me===te?null:me})},[]),pe=c.useMemo(()=>I?$.find(te=>te.id===I)??null:null,[$,I]),le=c.useMemo(()=>({id:cn,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),_e=!m,Fe=c.useMemo(()=>_e?[le,...$]:$,[$,le,_e]);c.useEffect(()=>{je()},[je]),c.useEffect(()=>{const te=z.map(me=>Gi(a,me,W,De=>S(me,De.sessions,{startedActionMutationRevisions:De.startedActionMutationRevisions})));return()=>{for(const me of te)me()}},[W,S,a,z]),c.useEffect(()=>{for(const{directory:te,state:me}of q)if(te)for(const De of me?.tabs??[]){if(De.purpose.type!=="project-action")continue;const K=De.purpose.actionId,Se=Fe.find(nt=>nt.id===K),Ve=Se?.name??K,Xe=Se?.icon||"play";De.label!==Ve&&C(te,De.id,Ve),De.iconKey!==Xe&&v(te,De.id,Xe)}},[Fe,v,C,q]),c.useEffect(()=>{const te=globalThis.window;if(!te)return;const me=De=>{const K=De.detail;ke&&(K?.projectId&&K.projectId!==ke||je())};return te.addEventListener(kl,me),()=>{te.removeEventListener(kl,me)}},[je,ke]),c.useEffect(()=>{I&&(I===cn&&_e||$.some(te=>te.id===I)||X(null))},[$,_e,I]),c.useEffect(()=>{const te=De=>{delete xe.current[De];const K=ue.current[De];if(!K||K.openedUrl)return;const Se=de(K.directory,K.actionId,K.executionId),Ve=K.announced;if(Ve.length!==0){if(window.clearTimeout(xe.current[Se]),delete xe.current[Se],K.openedUrl=!0,fe(Xe=>{if(!Xe[Se])return Xe;const nt={...Xe};return delete nt[Se],nt}),Ve.length===1){Ii(K.directory,[]),M(K.directory,K.tabId,Ve[0],{locked:!1,autoOpened:!0}),j(K.directory,Ve[0]);return}K.offering=!0,Ii(K.directory,Ve),Ne.getState().openContextSurface(K.directory,"browser"),Ke.info(o("projectActions.toast.multipleServers"))}},me=()=>{const De=Mt.getState(),K=De.sessions,Se=U;for(const[Ve,Xe]of Object.entries(Se)){const Ze=K.get(Xe.directory)?.tabs.find(ve=>ve.id===Xe.tabId);if(!Ze||Ze.terminalSessionId!==Xe.sessionId){F(Xe.directory,Xe.actionId,Xe.executionId);continue}const gt=ue.current[Ve],We=gt?.executionId===Xe.executionId?gt:{hostDirectory:he.current||Xe.directory,directory:Xe.directory,tabId:Xe.tabId,actionId:Xe.actionId,executionId:Xe.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ue.current[Ve]=We;const Et=Fe.find(ve=>ve.id===Xe.actionId),Ft=De.getBuffer(Xe.directory,Xe.tabId).chunks;if(!Et||Ft.length===0)continue;const Ie=Ft.filter(ve=>We.lastSeenChunkId===null||ve.id>We.lastSeenChunkId);if(Ie.length===0)continue;const yt=Ie.map(ve=>ve.data).join(""),At=`${We.tail}${yt}`;if(We.openInPreview&&(!We.openedUrl||We.offering)){const ve=gh(At),Qe=We.announced.length;for(const Ye of ve)We.announced.includes(Ye)||We.announced.push(Ye);const qe=We.announced.length-Qe;We.offering&&qe>0?Ii(Xe.directory,We.announced):!We.openedUrl&&Qe===0&&We.announced.length>0&&(window.clearTimeout(xe.current[Ve]),xe.current[Ve]=window.setTimeout(()=>te(Ve),_b))}const He=!We.openedUrl&&Et.autoOpenUrl===!0&&!We.openInPreview?xh(At):null,Ue=Ie[Ie.length-1]?.id??We.lastSeenChunkId;if(We.lastSeenChunkId=Ue,We.tail=At.slice(-512),He)if(We.openedUrl=!0,We.openInPreview){const ve=Se[Ve];ve&&(M(ve.directory,ve.tabId,He,{locked:!1,autoOpened:!1,expectedExecutionId:ve.executionId}),ve.status==="waiting-for-preview"&&fe(Qe=>{const qe=de(ve.directory,ve.actionId,ve.executionId);if(!Qe[qe])return Qe;const Ye={...Qe};return delete Ye[qe],Ye}),window.clearTimeout(xe.current[Ve]),delete xe.current[Ve],j(ve.directory,He))}else ce(He),Ke.success(o("projectActions.toast.openedUrlFromOutput"));ue.current[Ve]=We}for(const Ve of Object.keys(ue.current))if(!Se[Ve]){const Xe=ue.current[Ve],nt=Xe?K.get(Xe.directory)?.tabs.find(gt=>gt.id===Xe.tabId):void 0;if(nt?.purpose.type==="project-action"&&nt.purpose.executionId===Xe?.executionId&&!!nt.terminalSessionId&&nt.lifecycle!=="idle"&&nt.lifecycle!=="exited")continue;delete ue.current[Ve],window.clearTimeout(xe.current[Ve]),delete xe.current[Ve]}};return me(),Mt.subscribe((De,K)=>{(De.sessions!==K.sessions||De.buffers!==K.buffers)&&me()})},[F,he,Fe,de,j,ce,U,M,o]),c.useEffect(()=>{for(const{directory:te,state:me}of q)for(const De of me?.tabs??[]){if(De.purpose.type!=="project-action"||!De.purpose.executionId||!De.terminalSessionId||De.lifecycle!=="running")continue;const K=De.purpose.actionId,Se=De.purpose.executionId,Ve=de(te,K,Se);if(se.current[Ve])continue;const Xe=a.connect(De.terminalSessionId,{onEvent:nt=>{if(!L(te,De.id,Se))return;nt.type==="snapshot"&&(Mt.getState().replaceBuffer(te,De.id,nt.data??"",nt.sequence??0,pl(nt)),nt.status==="running"&&Mt.getState().setTabLifecycle(te,De.id,"running",{expectedExecutionId:Se}),nt.status==="exited"&&(Mt.getState().setTabLifecycle(te,De.id,"exited",{expectedExecutionId:Se}),Mt.getState().setTabPurpose(te,De.id,{type:"project-action",actionId:K,executionId:null}),F(te,K,Se)));const Ze=nt.type==="data"?nt.data??"":"";Ze&&Mt.getState().appendToBuffer(te,De.id,Ze,nt.sequence,nt.replayData),nt.type==="exit"&&(Mt.getState().setTabLifecycle(te,De.id,"exited",{expectedExecutionId:Se}),Mt.getState().setTabPurpose(te,De.id,{type:"project-action",actionId:K,executionId:null}),F(te,K,Se))},onError:(nt,Ze)=>{!Ze||!L(te,De.id,Se)||(Mt.getState().setTabLifecycle(te,De.id,"exited",{expectedExecutionId:Se}),Mt.getState().setTabSessionId(te,De.id,null,{expectedExecutionId:Se}),Mt.getState().setTabPurpose(te,De.id,{type:"project-action",actionId:K,executionId:null}),F(te,K,Se))}});se.current[Ve]=Xe.close}},[F,de,L,a,q]);const Me=c.useCallback(async te=>{const me=ee(te);if(!me)throw new Error(o("projectActions.error.noActiveDirectory"));const De=an(me,te.id);b(me);const K=Mt.getState(),Se=Y(me,te.id,K),Ve=Se?.id??K.createTab(me);C(me,Ve,te.name),v(me,Ve,te.icon||"play"),Se||O(me,Ve,{type:"project-action",actionId:te.id,executionId:null}),E(me,Ve);const nt=Mt.getState().getDirectoryState(me)?.tabs.find(Ze=>Ze.id===Ve);return{executionDirectory:me,key:De,tabId:Ve,sessionId:nt?.terminalSessionId??null,executionId:nt?.purpose.type==="project-action"?nt.purpose.executionId:null}},[b,ee,Y,E,v,C,O,o]),Ae=c.useCallback(async te=>{if(d.isVSCode||!i&&m)return;if(!G){Ke.error(o("projectActions.error.noActiveDirectoryForAction"));return}const me=an(ee(te),te.id),De=U[me];if(De&&De.status==="running"||ie.current.has(me))return;ie.current.add(me);let K=null;try{const Se=te.id===cn?await(async()=>{const[qe,Ye]=await Promise.all([tp({id:J?.id??"",path:G}),Bb(G)]),dt=await Ib(G,qe.actions,Ye);if(!dt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:cn,name:o("projectActions.actions.autoDiscover"),command:dt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:dt.previewUrlHint||""}})():te,Ve=Se.autoOpenUrl===!0&&(Se.openUrl||"").trim().length>0,Xe=!Ve&&te.id!==cn,nt=he.current||G,{executionDirectory:Ze,key:gt,tabId:We}=await Me(Se),Et=uh(Se.command);if(!Et)throw new Error(o("projectActions.error.failedToRunAction"));const Ft=Se.autoOpenUrl===!0&&f&&(Se.desktopOpenSshForward||"").trim().length>0,Ie=Se.autoOpenUrl?Lb(Se.openUrl):null,yt=Se.autoOpenUrl&&f?fh(Se.desktopOpenSshForward,p):null;if(a.listSessions){const qe=Y(Ze,Se.id);if(qe?.purpose.type==="project-action"&&qe.purpose.executionId===null){const Ye=await mh(a,Ze,{captureStartedActionMutationRevisions:W});Ye&&S(Ze,Ye.sessions,{startedActionMutationRevisions:Ye.startedActionMutationRevisions})}}const At=Y(Ze,Se.id);let He,Ue;if(At?.lifecycle==="running"&&At.terminalSessionId&&At.purpose.type==="project-action"&&At.purpose.executionId)He=At.terminalSessionId,Ue=At.purpose.executionId;else{const qe=At?.purpose.type==="project-action"?At.purpose.executionId:null;qe&&F(Ze,Se.id,qe);const Ye=B(Ze,We,Se.id);if(!Ye)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));K={directory:Ze,tabId:We,id:Ye},R(Ze,We,!0,{expectedExecutionId:Ye});const dt=await hh({terminal:a,createOptions:{cwd:Ze,shell:x,loginShell:k,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Et,isRunStillExpected:()=>L(Ze,We,Ye),purpose:{type:"project-action",actionId:Se.id,executionId:Ye}});if(!L(Ze,We,Ye)){dt.sessionId===Ye&&await a.close(dt.sessionId).catch(()=>{});return}Ue=dt.purpose?.type==="project-action"?dt.purpose.executionId:Ye,He=dt.sessionId,O(Ze,We,{type:"project-action",actionId:Se.id,executionId:Ue}),A(Ze,We,He,{expectedExecutionId:Ue}),R(Ze,We,!1,{expectedExecutionId:Ue})}Xe&&nt&&ae(nt,Ze),ue.current[gt]={hostDirectory:nt,directory:Ze,tabId:We,actionId:Se.id,executionId:Ue,lastSeenChunkId:null,openedUrl:!!yt||!!Ie||Ve,tail:"",openInPreview:Se.id===cn,announced:[],offering:!1};const ve=de(Ze,Se.id,Ue);R(Ze,We,!0,{expectedExecutionId:Ue});const Qe=a.connect(He,{onEvent:qe=>{if(!L(Ze,We,Ue)||qe.purpose?.type==="project-action"&&qe.purpose.executionId!==Ue)return;qe.type==="snapshot"&&(Mt.getState().replaceBuffer(Ze,We,qe.data??"",qe.sequence??0,pl(qe)),Mt.getState().setConnecting(Ze,We,!1,{expectedExecutionId:Ue}),qe.purpose?.type==="project-action"&&Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:qe.purpose.actionId,executionId:qe.purpose.executionId}),qe.status==="running"&&Mt.getState().setTabLifecycle(Ze,We,"running",{expectedExecutionId:Ue}),qe.status==="exited"&&(Mt.getState().setTabLifecycle(Ze,We,"exited",{expectedExecutionId:Ue}),Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:Se.id,executionId:null}),F(Ze,Se.id,Ue)));const Ye=qe.type==="data"?qe.data??"":"";Ye&&Mt.getState().appendToBuffer(Ze,We,Ye,qe.sequence,qe.replayData),qe.type==="exit"&&(Mt.getState().setTabLifecycle(Ze,We,"exited",{expectedExecutionId:Ue}),Mt.getState().setConnecting(Ze,We,!1,{expectedExecutionId:Ue}),Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:Se.id,executionId:null}),F(Ze,Se.id,Ue))},onError:(qe,Ye)=>{L(Ze,We,Ue)&&(Mt.getState().setConnecting(Ze,We,!1,{expectedExecutionId:Ue}),Ye&&(Mt.getState().setTabLifecycle(Ze,We,"exited",{expectedExecutionId:Ue}),Mt.getState().setTabSessionId(Ze,We,null,{expectedExecutionId:Ue}),Mt.getState().setTabPurpose(Ze,We,{type:"project-action",actionId:Se.id,executionId:null}),F(Ze,Se.id,Ue)))}});if(!L(Ze,We,Ue)){Qe.close();return}se.current[ve]?.(),se.current[ve]=Qe.close,window.clearTimeout(xe.current[ve]),delete xe.current[ve],Se.id===cn&&!Ie&&(fe(qe=>({...qe,[ve]:!0})),xe.current[ve]=window.setTimeout(()=>{delete xe.current[ve];const qe=ue.current[gt];!qe||qe.executionId!==Ue||qe.openedUrl||qe.offering||L(Ze,We,Ue)&&(fe(Ye=>{if(!Ye[ve])return Ye;const dt={...Ye};return delete dt[ve],dt}),Mt.getState().setActiveTab(Ze,We),ae(qe.hostDirectory,Ze))},Fb)),yt?(M(Ze,We,null,{locked:!0,expectedExecutionId:Ue}),ce(yt),Ke.success(o("projectActions.toast.openedForwardedUrl"))):Ie?(M(Ze,We,Ie,{locked:!0,autoOpened:!0,expectedExecutionId:Ue}),j(nt,Ie),Ke.success(o("projectActions.toast.openedActionUrl"))):Ve?(M(Ze,We,null,{locked:!0,expectedExecutionId:Ue}),Ke.error(o("projectActions.error.invalidCustomUrlFormat"))):Ft?(M(Ze,We,null,{locked:!0,expectedExecutionId:Ue}),Ke.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):M(Ze,We,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ue})}catch(Se){if(K&&L(K.directory,K.tabId,K.id)){const{directory:Ve,tabId:Xe,id:nt}=K;F(Ve,te.id,nt),T(Ve,Xe,"exited",{expectedExecutionId:nt}),O(Ve,Xe,{type:"project-action",actionId:te.id,executionId:null})}if(Se instanceof Error&&Se.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Se instanceof Error&&(Se.message==="COMMAND_MODE_UNSUPPORTED"||Se.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Ke.error(o("projectActions.error.failedToCreateTerminalSession"));return}Ke.error(Se instanceof Error?Se.message:o("projectActions.error.failedToRunAction"))}finally{ie.current.delete(me)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,he,p,Me,i,m,f,G,k,x,ce,j,U,ae,d.isVSCode,ee,L,F,de,Y,S,B,W,R,T,O,M,A,J?.id,o,a]),Q=c.useCallback(async te=>{const me=an(ee(te),te.id),De=U[me];De&&await ph({terminal:a,sessionId:De.sessionId,isExecutionStillCurrent:()=>L(De.directory,De.tabId,De.executionId),markStopping:()=>{T(De.directory,De.tabId,"stopping",{expectedExecutionId:De.executionId})},restoreRunning:()=>{T(De.directory,De.tabId,"running",{expectedExecutionId:De.executionId})},clearSession:()=>{A(De.directory,De.tabId,null,{expectedExecutionId:De.executionId})},finalizeExit:()=>{T(De.directory,De.tabId,"exited",{expectedExecutionId:De.executionId}),O(De.directory,De.tabId,{type:"project-action",actionId:De.actionId,executionId:null}),F(De.directory,De.actionId,De.executionId)}})},[F,ee,L,U,T,O,A,a]),Ce=c.useCallback(()=>{const te=pe??Fe[0];if(!te)return;const me=an(ee(te),te.id),De=U[me];if(De?.status!=="stopping"){if(De){Q(te);return}Ae(te)}},[Fe,ee,Ae,U,pe,Q]),Be=c.useCallback(async te=>{if(te.source==="shared"&&J){const me=D.current?.trust.trusted?D.current:await Al(J);if(D.current=me,!await sp(J,me))return;D.current={...me,trust:{...me.trust,trusted:!0}}}await Ae(te)},[Ae,J]),Le=c.useCallback((te,me=!1)=>{if(X(te.id),!me){Be(te);return}const De=an(ee(te),te.id),K=U[De];if(K?.status!=="stopping"){if(K){Q(te);return}Be(te)}},[ee,Be,U,Q]),Je=c.useCallback(()=>{J?.id&&(g(J.id),w("projects"),h(!0))},[h,w,g,J?.id]),ot=pe??Fe[0]??null,et=ot?U[an(ee(ot),ot.id)]:null,it=Mt(te=>et?te.getDirectoryState(et.directory)?.tabs.find(me=>me.id===et.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&m||!J||!G)return null;const ht=pe??Fe[0]??null;if(!ht)return null;const st=Ti(ht),mt=an(ee(ht),ht.id),kt=U[mt],Pe=kt?.status==="stopping",Ge=kt?.status==="waiting-for-preview",at=!!(kt&&it),ze=()=>{!kt||!it||j(kt.directory,it)},ft=ht.id===cn;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",disabled:Z||Pe,className:Ee("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-ring","disabled:cursor-not-allowed",n),onClick:Ce,"aria-label":kt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:Pe||Ge?s.jsx(_,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):kt?s.jsx(_,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(_,{name:st,className:"h-5 w-5"})})}),ft?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),at?s.jsxs(vt,{children:[s.jsx(St,{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-ring","aria-label":o("projectActions.actions.openPreview"),onClick:ze,children:s.jsx(_,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ls,{children:[s.jsx(Fs,{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-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(_,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(_s,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ht,{className:"flex items-center gap-2",onClick:Je,children:[s.jsx(_,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Es,{}),Fe.map(te=>{const me=Ti(te),De=an(ee(te),te.id),K=U[De],Se=!!K,Ve=K?.status==="stopping";return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{Le(te,!0)},children:[s.jsx(_,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:te.name}),te.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,Ve||K?.status==="waiting-for-preview"?s.jsx(_,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Se?s.jsx(_,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},te.id)})]})]})]}):s.jsxs("div",{className:Ee("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(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ce,disabled:Z||Pe,className:Ee("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-ring disabled:cursor-not-allowed"),"aria-label":kt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:Pe||Ge?s.jsx(_,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):kt?s.jsx(_,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(_,{name:st,className:"h-4 w-4"})})})}),ft?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),at?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ze,className:Ee(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-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(_,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee(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-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(_s,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Ht,{className:"flex items-center gap-2",onClick:Je,children:[s.jsx(_,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Es,{}),Fe.map(te=>{const me=Ti(te),De=an(ee(te),te.id),K=U[De],Se=!!K,Ve=K?.status==="stopping";return s.jsxs(Ht,{className:"flex items-center gap-2",onClick:()=>{Le(te,!0)},children:[s.jsx(_,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:te.name}),te.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,Ve||K?.status==="waiting-for-preview"?s.jsx(_,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Se?s.jsx(_,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},te.id)})]})]})]})},zr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},zb=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=zr(n??"");if(i){const o=su(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function Wb(){const t=Ut(x=>x.projects),e=Ut(x=>x.activeProjectId),n=rt(x=>x.availableWorktreesByProject),r=rt(x=>x.currentSessionId),i=np(r??null),o=rt(x=>r?x.worktreeMetadata.get(r)?.path??"":""),l=rt(x=>x.newSessionDraft?.open?zr(x.newSessionDraft.bootstrapPendingDirectory??x.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>zr(o||""),[o]),d=c.useMemo(()=>{const x=typeof i?.directory=="string"?i.directory:"";return zr(x||"")},[i?.directory]),u=a||d||l,m=c.useMemo(()=>zb({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>zr(u||m?.path||""),[u,m?.path]),p=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),y=c.useRef(null);return c.useEffect(()=>{p&&f&&(y.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:y.current,[p,f])}const Kb=({transform:t})=>({...t,y:0}),Vb={Item:Ht,Separator:Es},Ub={Item:({className:t,...e})=>s.jsx(Zu,{className:Ee(iu,t),...e}),Separator:({className:t,...e})=>s.jsx(Ju,{className:Ee(ou,t),...e})},Hb=t=>{const e=tt.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:m}=t,{t:f}=Nt(),[p,y]=c.useState(!1),[x,k]=c.useState(!1),[w,h]=c.useState(!1);let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:j,listeners:b,setNodeRef:S,transform:C,transition:v,isDragging:E}=mi(g);let R;e[2]!==f||e[3]!==n.session.title?(R=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=R):R=e[4];const A=R,O=!i&&(p||x),B=n.id;let T;e[5]!==n.session?(T=As(n.session),e[5]=n.session,e[6]=T):T=e[6];const M=Oa(B,T),L=nu(n.id),$=ru(n.id)>0&&!r&&!L,P=L||$;let D;e[7]!==L||e[8]!==f?(D=f(L?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=L,e[8]=f,e[9]=D):D=e[9];const I=D;let X;e[10]!==d||e[11]!==w||e[12]!==r||e[13]!==p||e[14]!==o||e[15]!==n?(X=we=>({session:n.session,open:p||w,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:we}),e[10]=d,e[11]=w,e[12]=r,e[13]=p,e[14]=o,e[15]=n,e[16]=X):X=e[16];const Z=X;let ne;e[17]!==C?(ne=hi.Translate.toString(C),e[17]=C,e[18]=ne):ne=e[18];let ue;e[19]!==ne||e[20]!==v?(ue={transform:ne,transition:v},e[19]=ne,e[20]=v,e[21]=ue):ue=e[21];const se=E&&"z-10 opacity-60";let xe;e[22]!==se?(xe=Ee("session-tab-slot flex h-7 w-44 shrink-0 touch-none",se),e[22]=se,e[23]=xe):xe=e[23];const ie=r?"true":"false";let Re;e[24]!==r?(Re=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=Re):Re=e[25];let be;e[26]!==u?(be=we=>u?.(we),e[26]=u,e[27]=be):be=e[27];let fe;e[28]!==m||e[29]!==I||e[30]!==r||e[31]!==M||e[32]!==L||e[33]!==Z||e[34]!==p||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==O||e[39]!==a||e[40]!==P||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==A?(fe=s.jsx(ef,{render:we=>s.jsxs("div",{...we,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),o(n))},onAuxClick:Te=>{Te.button===1&&(Te.preventDefault(),l(n.id))},"data-controls-open":O?"true":"false",className:Ee("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":Ee("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",O&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Ee("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",O&&"pr-10"),children:[s.jsx("div",{className:Ee("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?m: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:A})})}),M?s.jsx(_,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):P?s.jsx(Ba,{state:L?"running":"unread",label:I,className:Ee("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",O&&"opacity-0")}):null]}),i?null:s.jsxs("div",{onClick:qb,onPointerDown:Yb,className:Ee("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",O&&"flex opacity-100"),children:[s.jsxs(Ls,{open:p,onOpenChange:Te=>{y(Te),Te&&k(!0)},onOpenChangeComplete:Te=>{Te||k(!1),u?.(Te)},children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"more",className:"size-4"})})}),s.jsx(_s,{align:"start",className:"min-w-[190px]",children:a(Z(Vb))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"size-4"})})]})]})}),e[28]=m,e[29]=I,e[30]=r,e[31]=M,e[32]=L,e[33]=Z,e[34]=p,e[35]=l,e[36]=u,e[37]=o,e[38]=O,e[39]=a,e[40]=P,e[41]=i,e[42]=f,e[43]=n,e[44]=A,e[45]=fe):fe=e[45];let ke,H;e[46]===Symbol.for("react.memo_cache_sentinel")?(ke={color:"var(--surface-elevated-foreground)"},H=Ee(Qi,"min-w-[190px]"),e[46]=ke,e[47]=H):(ke=e[46],H=e[47]);let J;e[48]!==Z||e[49]!==a?(J=a(Z(Ub)),e[48]=Z,e[49]=a,e[50]=J):J=e[50];let ce;e[51]!==J?(ce=s.jsx(ca,{children:s.jsx(da,{className:"app-region-no-drag z-50",children:s.jsx(ua,{"data-slot":"dropdown-menu-content",style:ke,className:H,children:J})})}),e[51]=J,e[52]=ce):ce=e[52];let je;e[53]!==w||e[54]!==be||e[55]!==fe||e[56]!==ce?(je=s.jsxs(tf,{open:w,onOpenChange:h,onOpenChangeComplete:be,children:[fe,ce]}),e[53]=w,e[54]=be,e[55]=fe,e[56]=ce,e[57]=je):je=e[57];let G;return e[58]!==j||e[59]!==b||e[60]!==S||e[61]!==xe||e[62]!==ie||e[63]!==Re||e[64]!==je||e[65]!==ue?(G=s.jsx("div",{ref:S,style:ue,className:xe,"data-active":ie,...Re,...j,...b,children:je}),e[58]=j,e[59]=b,e[60]=S,e[61]=xe,e[62]=ie,e[63]=Re,e[64]=je,e[65]=ue,e[66]=G):G=e[66],G},Gb=t=>{const e=tt.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=Nt(),d=co(Qb),u=co(Xb),m=co(Jb),f=co(Zb),p=rt(ey),y=rt(ty),x=vs(sy);let k,w;e[0]!==p||e[1]!==u?(k=()=>{p&&u(p)},w=[p,u],e[0]=p,e[1]=u,e[2]=k,e[3]=w):(k=e[2],w=e[3]),c.useEffect(k,w);let h;if(e[4]!==x){h=new Map;for(const he of x)h.set(he.id,he);e[4]=x,e[5]=h}else h=e[5];const g=h;let j;if(e[6]!==g||e[7]!==d){j=[];for(const he of d){const re=g.get(he);re&&j.push({id:he,session:re})}e[6]=g,e[7]=d,e[8]=j}else j=e[8];const b=j;let S;e[9]!==y?(S=he=>{y(he.id,As(he.session))},e[9]=y,e[10]=S):S=e[10];const C=S,v=ny;let E;e[11]!==m||e[12]!==p||e[13]!==C||e[14]!==b?(E=he=>{if(m(he),p&&p!==he){const re=b.find(ge=>ge.id===he);re&&C(re)}},e[11]=m,e[12]=p,e[13]=C,e[14]=b,e[15]=E):E=e[15];const R=E;let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{distance:8}},e[16]=A):A=e[16];let O;e[17]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{delay:200,tolerance:6}},e[17]=O):O=e[17];const B=li(Pn(di,A),Pn(ci,O));let T;e[18]!==f?(T=he=>{const{active:re,over:ge}=he;ge&&re.id!==ge.id&&f(String(re.id),String(ge.id))},e[18]=f,e[19]=T):T=e[19];const M=T,L=c.useRef(null);let W;e[20]===Symbol.for("react.memo_cache_sentinel")?(W={left:!1,right:!1},e[20]=W):W=e[20];const[$,P]=c.useState(W);let D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{const he=L.current;if(!he)return;const re=he.scrollLeft>2,ge=he.scrollLeft+he.clientWidth<he.scrollWidth-2;P(q=>q.left===re&&q.right===ge?q:{left:re,right:ge})},e[21]=D):D=e[21];const I=D;let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{I();const he=L.current;if(!he||!globalThis.ResizeObserver)return;const re=new ResizeObserver(I);return re.observe(he),()=>re.disconnect()},e[22]=X):X=e[22];let Z;e[23]!==b.length?(Z=[I,b.length],e[23]=b.length,e[24]=Z):Z=e[24],c.useEffect(X,Z);let ne;e[25]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{L.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=ne):ne=e[25];let ue;e[26]!==p?(ue=[p],e[26]=p,e[27]=ue):ue=e[27],c.useEffect(ne,ue);const se=$.left&&$.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":$.left?"linear-gradient(to right, transparent, black 24px)":$.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let xe;e[28]!==b?(xe=b.map(ry),e[28]=b,e[29]=xe):xe=e[29];const ie=xe;let Re;e[30]!==p||e[31]!==b?(Re=!p||!b.some(he=>he.id===p),e[30]=p,e[31]=b,e[32]=Re):Re=e[32];const be=Re;let fe;e[33]!==a?(fe=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=fe):fe=e[34];let ke;e[35]!==se?(ke=se?{maskImage:se,WebkitMaskImage:se}:void 0,e[35]=se,e[36]=ke):ke=e[36];let H;e[37]===Symbol.for("react.memo_cache_sentinel")?(H=[Kb],e[37]=H):H=e[37];let J;e[38]!==o||e[39]!==p||e[40]!==R||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==b?(J=b.map(he=>s.jsx(Hb,{tab:he,isActive:he.id===p,suppressControls:he.id===p&&l,onSelect:C,onClose:v,renderMenu:n,closeOtherTabs:R,onMenuOpenChangeComplete:r,children:he.id===p?o:null},he.id)),e[38]=o,e[39]=p,e[40]=R,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=b,e[46]=J):J=e[46];let ce;e[47]!==J||e[48]!==ie?(ce=s.jsx(Ja,{items:ie,strategy:Qx,children:J}),e[47]=J,e[48]=ie,e[49]=ce):ce=e[49];let je;e[50]!==M||e[51]!==B||e[52]!==ce?(je=s.jsx(ui,{sensors:B,collisionDetection:fi,modifiers:H,onDragEnd:M,children:ce}),e[50]=M,e[51]=B,e[52]=ce,e[53]=je):je=e[53];let G;e[54]!==o||e[55]!==be?(G=be?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]=be,e[56]=G):G=e[56];let we;e[57]!==ke||e[58]!==je||e[59]!==G?(we=s.jsxs("div",{ref:L,onScroll:I,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:ke,children:[je,G]}),e[57]=ke,e[58]=je,e[59]=G,e[60]=we):we=e[60];let Te;return e[61]!==fe||e[62]!==we?(Te=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":fe,children:we}),e[61]=fe,e[62]=we,e[63]=Te):Te=e[63],Te};function qb(t){return t.stopPropagation()}function Yb(t){return t.stopPropagation()}function Qb(t){return t.tabIds}function Xb(t){return t.ensureTab}function Jb(t){return t.closeOtherTabs}function Zb(t){return t.reorderTabs}function ey(t){return t.currentSessionId}function ty(t){return t.setCurrentSession}function sy(t){return t.activeSessions}function ny(t){rp(t)}function ry(t){return t.id}const lf=async t=>{const{entry:e,session:n}=t,r=Qt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(op(e.action)&&ip(e.guest,"conversation"))){await Pl(e,Dl(e.action.id,i),t.t,r);return}let l=!1;const a=Cr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Pl(e,Dl(e.action.id,i,d),t.t,r)}};function ma(t){const e=tt.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=Nt(),{pending:a,disabled:d,hint:u,run:m}=yh(n,r,i),f=a?"loader-4":"ai-generate-2",p=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let y;e[0]!==f||e[1]!==p?(y=s.jsx(_,{name:f,className:p}),e[0]=f,e[1]=p,e[2]=y):y=e[2];let x;e[3]!==l?(x=l("sessions.aiRename.action"),e[3]=l,e[4]=x):x=e[4];let k;e[5]!==o||e[6]!==d||e[7]!==m||e[8]!==y||e[9]!==x?(k=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:m,className:"w-full",children:[y,x]})})}),e[5]=o,e[6]=d,e[7]=m,e[8]=y,e[9]=x,e[10]=k):k=e[10];let w;e[11]!==u?(w=s.jsx(jt,{side:"right",children:u}),e[11]=u,e[12]=w):w=e[12];let h;return e[13]!==k||e[14]!==w?(h=s.jsxs(vt,{children:[k,w]}),e[13]=k,e[14]=w,e[15]=h):h=e[15],h}const ha=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class cf extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const pi=no(()=>({pendingSessionIds:new Set})),df=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],pi(n)},ec=(t,e)=>{pi.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}})},oy=async(t,e)=>{try{const d=(await fp(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=xt(t),r=xt(e)??e,i=rt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>xt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},tc=t=>{for(const e of t){const n=lp(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class iy extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const ay=(t,e)=>{const n=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new iy(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},ly=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(cp(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await au(o,n,e),rt.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},sc=async(t,e,n)=>{try{await cu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},nc=async(t,e)=>{const n=e?[t,e]:[t];try{await Fa(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},uf=async(t,e)=>{if(pi.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");ec(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,rt.getState().getWorktreeMetadata(a.id)]));tc(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){tc(n.slice(a));try{await au(d,t.sourceDirectory,i.directory)}catch(u){throw ap(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&rt.getState().setWorktreeMetadata(d.id,Il(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await ly(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await nc(t.sourceDirectory,i?.directory),u.length>0)throw ay(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new cf(d):d}return rt.getState().setWorktreeMetadata(t.root.id,Il(i.metadata)),await nc(t.sourceDirectory,i.directory),i.directory}finally{ec(t.root.id,!1)}},cy=async t=>{const e=xt(t.sourceDirectory)??t.sourceDirectory,n=xt(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 uf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},dy=async t=>uf(t,async()=>{const e=Xi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await lu(t.sourceDirectory)?await oy(t.sourceDirectory,e.path):null,r=await dp(e,n?{startRef:n}:{});try{await up(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return sc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>sc(e,r,i)}}),uy=t=>{(t.kind==="existing"?cy({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):dy({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>Ke.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));Ke.error(t.messages.failure,{description:r instanceof cf?t.messages.outcomeUnknown:r.message})})},pa=t=>{pi.getState().pendingSessionIds.has(t.root.id)||uy(t)},Vo="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-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",fy=c.memo(function(e){const n=tt.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:m}=e,f=r===void 0?!0:r,p=m===void 0?!1:m;if(!f)return null;const y=a??Vo,x=p&&"bg-interactive-selection text-interactive-selection-foreground";let k;n[0]!==y||n[1]!==x?(k=Ee(y,x),n[0]=y,n[1]=x,n[2]=k):k=n[2];const w=u??"h-[18px] w-[18px]";let h;n[3]!==d||n[4]!==w?(h=s.jsx(_,{name:d,className:w}),n[3]=d,n[4]=w,n[5]=h):h=n[5];let g;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==k||n[10]!==h?(g=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:k,children:h})}),n[6]=o,n[7]=l,n[8]=p,n[9]=k,n[10]=h,n[11]=g):g=n[11];let j;n[12]!==i?(j=s.jsx(jt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=j):j=n[13];let b;return n[14]!==g||n[15]!==j?(b=s.jsxs(vt,{children:[g,j]}),n[14]=g,n[15]=j,n[16]=b):b=n[16],b}),my=c.memo(function(e){const n=tt.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:m,remoteUpdateChecking:f,remoteUpdateError:p,onOpenRemoteUpdate:y}=e,{t:x}=Nt();let k;n[0]!==d||n[1]!==a?(k=B=>{a(B),B&&d()},n[0]=d,n[1]=a,n[2]=k):k=n[2];let w;n[3]!==i||n[4]!==r||n[5]!==x?(w=r?x("header.services.openWithCurrent",{current:i}):x("header.services.open"),n[3]=i,n[4]=r,n[5]=x,n[6]=w):w=n[6];const h=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let g;n[7]!==h?(g=Ee(Vo,h),n[7]=h,n[8]=g):g=n[8];let j;n[9]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(_,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=j):j=n[9];let b;n[10]!==i||n[11]!==r?(b=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=b):b=n[12];let S;n[13]!==w||n[14]!==g||n[15]!==b?(S=s.jsx(St,{asChild:!0,children:s.jsx(Fs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":w,className:g,children:[j,b]})})}),n[13]=w,n[14]=g,n[15]=b,n[16]=S):S=n[16];let C;n[17]!==i||n[18]!==u||n[19]!==x?(C=x("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=x,n[20]=C):C=n[20];let v;n[21]!==C?(v=s.jsx(jt,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=v):v=n[22];let E;n[23]!==S||n[24]!==v?(E=s.jsxs(vt,{children:[S,v]}),n[23]=S,n[24]=v,n[25]=E):E=n[25];let R;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==y||n[30]!==f||n[31]!==p||n[32]!==m||n[33]!==a||n[34]!==x?(R=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:x("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:m?.available?x("header.services.remoteUpdate.available",{version:m.version||""}):f?x("header.services.remoteUpdate.checking"):p||x("header.services.remoteUpdate.upToDate")})]}),m?.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:y,children:x("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(mp,{embedded:!0,open:l,onOpenChange:py,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=y,n[30]=f,n[31]=p,n[32]=m,n[33]=a,n[34]=x,n[35]=R):R=n[35];let A;n[36]!==R?(A=s.jsx(_s,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:R}),n[36]=R,n[37]=A):A=n[37];let O;return n[38]!==l||n[39]!==k||n[40]!==E||n[41]!==A?(O=s.jsxs(Ls,{open:l,onOpenChange:k,children:[E,A]}),n[38]=l,n[39]=k,n[40]=E,n[41]=A,n[42]=O):O=n[42],O}),kn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},rc=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,hy=()=>{Ts("ui.header.render");const{t}=Nt(),e=Ne(N=>N.isSidebarOpen),n=Ne(N=>N.openContextOverview),r=Ne(N=>N.closeContextPanel),i=Ne(N=>N.shortcutOverrides),o=Ne(N=>N.sessionTabsEnabled),l=rt(N=>N.getContextUsage),a=rt(N=>!!N.newSessionDraft?.open),d=rt(N=>N.currentSessionId),u=hp(d??""),m=pp(d??""),f=df(d??""),p=vs(ar(c.useCallback(N=>{if(!d)return null;const ye=[...N.activeSessions,...N.archivedSessions].find(lt=>lt.id===d);if(!ye)return null;const $e=ye;return{title:ye.title??null,directory:$e.directory??null,created:ye.time?.created??null,slug:$e.slug??null,parentId:ye.parentID??null}},[d]))),y=Ut(ar(N=>{if(!N.activeProjectId)return null;const ye=N.projects.find($e=>$e.id===N.activeProjectId);return ye?{id:ye.id,path:ye.path,label:ye.label}:null})),x=c.useMemo(()=>{if(!y)return null;const N=y.label?.trim();if(N)return N;const ye=y.path.split(/[\\/]/).filter(Boolean);return ye[ye.length-1]??null},[y]),k=hr(N=>N.loadSettings),{isMobile:w}=$n(),h=c.useRef(null),[g,j]=c.useState(()=>typeof window>"u"?!1:xn()),b=c.useMemo(()=>qr(),[]),S=du(),[C,v]=c.useState(!1),E=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:R,side:A}=qu(),O=c.useMemo(()=>{if(typeof window>"u")return null;const N=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof N=="number"&&Number.isFinite(N)&&N>0)return N;if(typeof navigator>"u")return null;const ye=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ye)return null;const $e=Number.parseInt(ye[1],10),lt=Number.parseInt(ye[2],10);return Number.isNaN($e)?null:$e===10?lt:$e},[]);ut.useEffect(()=>{typeof window>"u"||j(xn())},[]);const{context:B,output:T}=gp(d),M=l(B,T),[L,W]=c.useState(null),$=!d||u;ut.useEffect(()=>{if(!d){W(N=>N===null?N:null);return}if(M){W(N=>xp(N,M)?N:M);return}$&&W(N=>N===null?N:null)},[M,d,$]);const[P,D]=c.useState(!1),[I,X]=c.useState("Local"),[Z,ne]=c.useState(!0),[ue,se]=c.useState(!1),[xe,ie]=c.useState(null),[Re,be]=c.useState(!1),[fe,ke]=c.useState(null),H=c.useMemo(()=>_n(),[]),J=Ne(N=>N.workStatusPanelVisible),ce=Ne(N=>N.workStatusPanelEnabled),je=Ne(N=>N.setWorkStatusPanelEnabled),G=Ne(N=>N.workStatusPanelFits),we=Ne(N=>N.workStatusOverlayOpen),Te=Ne(N=>N.setWorkStatusOverlayOpen),re=ce&&G||we,ge=c.useCallback(()=>{if(ce&&!G){Te(!we);return}je(!ce)},[Te,je,we,ce,G]),q=!H&&!J&&!!L,z=c.useCallback(async()=>{if(!(typeof window>"u"||!g))try{if(Zo()){X("Local"),ne(!0);return}ne(!1);const N=await Bd(),ye=Lm(),$e=$m([zm(ye),...N.hosts]);if($e.id===Wm){X("Local"),ne(!0);return}X(Fd($e.label.trim()||"Instance"))}catch{X("Local"),ne(!0)}},[g]);ut.useEffect(()=>(z(),Cr(()=>{z()})),[z]);const ee=c.useCallback(async()=>{if(Z){ie(null),ke(null);return}be(!0),ke(null);try{const N=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),ye=await bs(`/api/openchamber/update-check?${N.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!ye.ok)throw new Error(`Server responded with ${ye.status}`);const $e=await ye.json();ie({available:$e.available??!1,version:$e.version,currentVersion:$e.currentVersion??"unknown",body:$e.body,nextSuggestedCheckInSec:typeof $e.nextSuggestedCheckInSec=="number"?$e.nextSuggestedCheckInSec:void 0,packageManager:$e.packageManager,updateCommand:$e.updateCommand})}catch(N){ie(null),ke(N instanceof Error?N.message:t("header.services.remoteUpdate.error"))}finally{be(!1)}},[Z,t]);c.useEffect(()=>{ie(null),ke(null),se(!1)},[Z,I]),c.useEffect(()=>{if(!g||Z)return;const N=3e3,ye=3600*1e3;let $e=!1,lt=null;const Pt=Dt=>{lt=window.setTimeout(()=>{if($e||typeof document<"u"&&document.visibilityState!=="visible"){Pt(ye);return}ee().finally(()=>{$e||Pt(ye)})},Dt)};return Pt(N),()=>{$e=!0,lt!==null&&window.clearTimeout(lt)}},[ee,Z,I,g]);const de=c.useCallback(()=>{if(xe?.available){se(!0);return}ee()},[ee,xe?.available]);bp(),c.useEffect(()=>{k()},[k]);const Y=d?p??null:null,U=c.useRef(null),[F,V]=c.useState(0);c.useEffect(()=>{if(!d){U.current&&(U.current=null,V(lt=>lt+1));return}if(Y){U.current={sessionId:d,session:Y,expiresAt:Date.now()+2e3};return}const N=U.current;if(!N||N.sessionId!==d)return;const ye=N.expiresAt-Date.now();if(ye<=0){U.current=null,V(lt=>lt+1);return}const $e=window.setTimeout(()=>{U.current?.sessionId===d&&(U.current=null),V(lt=>lt+1)},ye);return()=>{window.clearTimeout($e)}},[d,Y]);const oe=(()=>{if(Y)return Y;if(!d)return null;const N=U.current;return N&&N.sessionId===d&&N.expiresAt>Date.now()?N.session:null})(),ae=rt(N=>d?N.worktreeMetadata.get(d)?.path??"":""),pe=rt(N=>d?N.worktreeMetadata.get(d)?.branch?.trim()??null:null),le=uu(N=>d?N.getAttachment(d):void 0),_e=c.useMemo(()=>le?yp(le,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,le]),Fe=c.useMemo(()=>le?le.legacy?"legacy":le.degraded?"degraded":le.worktreeStatus==="pending"?"pending":le.worktreeStatus==="missing"?"missing":le.worktreeStatus==="invalid"?"invalid":le.attentionReason?"attention":null:null,[le]),Me=c.useMemo(()=>kn(ae||""),[ae]),Ae=c.useMemo(()=>{const N=typeof oe?.directory=="string"?oe.directory:"";return kn(N||"")},[oe?.directory]),Q=Oa(d??"",Ae),Ce=rt(N=>N.newSessionDraft?.open?kn(N.newSessionDraft.bootstrapPendingDirectory??N.newSessionDraft.directoryOverride??""):""),Be=rt(N=>N.newSessionDraft.target),Le=rt(N=>N.newSessionDraft.selectedProjectId),Je=rt(N=>N.currentSessionDirectory),ot=os(N=>N.homeDirectory),et=c.useMemo(()=>Me||Ae||Ce,[Ce,Ae,Me]),it=Ne(c.useCallback(N=>{const ye=kn(et||"");return ye?rc(N.contextPanelByDirectory[ye]):null},[et])),ht=rt(N=>{const ye=kn(Me||Ae||"");if(!ye)return null;for(const $e of N.availableWorktreesByProject.values()){const Pt=$e.find(Dt=>kn(Dt.path)===ye)?.branch?.trim();if(Pt)return Pt}return null}),mt=wp(et||null)||pe||ht,kt=a?Be==="chat":vp(Ae||Je,ot),Pe=!kt&&!J&&!!(x||mt||!a&&Fe),Ge=c.useMemo(()=>{if(!d)return x??"OpenChamber";const N=oe?.title?.trim();return N&&N.length>0?N:"Untitled Session"},[x,oe?.title,d]),at=fu(),ze=rt(N=>N.updateSessionTitle),ft=rt(N=>N.archiveSessions),te=rt(N=>N.deleteSessions),[me,De]=c.useState(!1),[K,Se]=c.useState(!1),Ve=c.useRef(null),[Xe,nt]=c.useState(""),[Ze,gt]=c.useState(null),We=c.useRef(null),Et=c.useCallback(()=>{d&&(nt(oe?.title?.trim()||Ge),De(!0))},[oe?.title,d,Ge]),Ft=c.useRef(Et);Ft.current=Et;const Ie=c.useCallback(N=>{N&&(N.focus(),N.select())},[]);c.useEffect(()=>{if(Se(!1),gt(null),d&&Ve.current===d){Ve.current=null,Ft.current();return}De(!1),nt("")},[d]);const yt=c.useCallback(async()=>{if(!d)return;const N=Xe.trim();N&&N!==oe?.title?.trim()&&await ze(d,N),De(!1)},[oe?.title,d,Xe,ze]);c.useEffect(()=>{if(!me)return;const N=ye=>{const $e=ye.target;(!$e||!We.current?.contains($e))&&yt()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[me,yt]);const At=c.useCallback(N=>{N&&cr(N).then(ye=>{Ke[ye.ok?"success":"error"](t(ye.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Ke.error(t("sessions.sidebar.session.copyId.error")))},[t]),He=c.useCallback(async()=>{if(!d||!et){Ke.error(t("sessions.sidebar.session.export.nothingToExport"));return}const N=await at({sessionID:d,directory:et}).catch(()=>null);if(!N){Ke.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(N.length===0){Ke.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ye=mu(N,oe?.title??null),$e=hu(oe?.title??null);await pu(ye,$e)||gu(ye,$e),Ke.success(t("sessions.sidebar.session.export.success"))},[oe?.title,d,at,et,t]),Ue=xu(),ve=c.useMemo(()=>bu(Ue),[Ue]),Qe=c.useCallback(N=>{d&&lf({entry:N,t,session:{id:d,title:oe?.title,directory:Ae??et},loadRecords:async()=>{if(!et)return null;try{return await at({sessionID:d,directory:et})}catch{return null}},onLoadFailed:()=>Ke.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[oe?.title,d,at,et,Ae,t]),qe=c.useCallback(N=>ve.map(ye=>s.jsxs(N,{onClick:()=>Qe(ye),children:[s.jsx(to,{icon:ye.icon,iconSrc:ye.iconSrc,className:"mr-1 size-4"}),ye.action.label]},`${ye.guest.id}:${ye.action.id}`)),[ve,Qe]),Ye=m?.type==="busy"||m?.type==="retry",dt=c.useCallback(()=>{if(!d||!Ae||Ye||f)return;const N=vs.getState().activeSessions,ye=N.find(Pt=>Pt.id===d);if(!ye)return;const $e=[],lt=[d];for(let Pt=0;Pt<lt.length;Pt+=1){const Dt=lt[Pt];for(const pt of N)pt.parentID===Dt&&($e.push(pt),lt.push(pt.id))}pa({kind:"quick",root:ye,descendants:$e,sourceDirectory:Ae,messages:ha(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Ye,f,Ae,t]),Ot=c.useCallback(async()=>{if(!Ze)return;const N=Ze.action,ye=[Ze.sessionId,...Vd(Ze.sessionId,[],N==="delete")];if(gt(null),(N==="archive"?await ft(ye):await te(ye)).failedIds.length>0){Ke.error(t(N==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Ke.success(t(N==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[ft,te,Ze,t]),zt=Ne(N=>N.openGuestPageId),Kt=_a(N=>N.guests.find(ye=>ye.id===zt)),Gt=Ne(N=>N.isScheduledTasksDialogOpen),Bt=Ne(N=>N.isArchivePageOpen),Jt=Ne(N=>N.isUsageStatsPageOpen),Vt=Ne(N=>N.worktreesPageProjectId),Wt=Ne(N=>N.isMultiRunLauncherOpen),_t=Ut(N=>{if(!Vt)return null;const ye=N.projects.find($e=>$e.id===Vt);return ye?.label?.trim()||ye?.path?.split("/").pop()||null}),Xt=c.useMemo(()=>Kt?{title:Kt.pageTitle??Kt.name,subtitle:null}:Gt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Bt?{title:t("sessions.archivePage.title"),subtitle:null}:Jt?{title:t("usageStats.title"),subtitle:null}:Vt?{title:t("sessions.worktreesPage.title",{project:_t??""}),subtitle:null}:Wt?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[Kt,Bt,Wt,Gt,Jt,t,Vt,_t]),Ct=c.useMemo(()=>kn(et||y?.path||""),[y?.path,et]),Tt=Wb(),is=La(N=>N.planModeEnabled),$s=rt(N=>N.isSessionPlanAvailable),cs=is&&d?$s(d):!1,ps=c.useRef("");c.useEffect(()=>{if(!is||!d)return;const N=`${d||"none"}:${Ae||"none"}:${oe?.created||0}:${oe?.slug||"none"}`;ps.current!==N&&(ps.current=N)},[is,cs,oe?.slug,oe?.created,d,Ae]);const fn=c.useCallback(()=>{Fn("desktop_open_draft_mini_chat_window",{directory:kt?"":Ce,projectId:kt?null:Le,apiBaseUrl:Dn(),clientToken:Yr()}).catch(N=>{console.warn("[header] failed to open draft mini chat window",N)})},[Ce,Le,kt]),nn=c.useCallback(()=>{if(a){fn();return}d&&Fn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Ae||kn(Je||"")||Me,apiBaseUrl:Dn(),clientToken:Yr()}).catch(N=>{console.warn("[header] failed to open session mini chat window",N)})},[d,fn,a,Je,Ae,Me]),mn=c.useCallback(()=>{const N=kn(et||"");if(!N)return;const ye=Ne.getState().contextPanelByDirectory[N];if(rc(ye)==="context"){r(N);return}n(N)},[r,n,et]),vn=it==="context",ks=Vo,rn=c.useMemo(()=>g&&E&&!C?"88px":S?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!g||R)&&!H?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[g,C,E,S,H,R]);ut.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",rn)},[rn]);const zs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Ws=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ut.useEffect(()=>{if(!g||!E){v(!1);return}let N=!1;const ye=async()=>{try{const lt=await Fn("desktop_is_window_fullscreen");N||v(lt===!0)}catch{N||v(!1)}},$e=()=>{ye()};return ye(),window.addEventListener("openchamber:window-resized",$e),()=>{N=!0,window.removeEventListener("openchamber:window-resized",$e)}},[g,E]);const as=c.useMemo(()=>!g||!E||O===null?"":O>=26?"h-12":O<=15?"h-14":"",[g,E,O]),Gs=c.useMemo(()=>{if(!(g&&!R||H)&&!(R&&A==="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))"}},[g,H,R,A]),gs=c.useCallback(()=>{if(typeof document>"u")return;const N=h.current?.getBoundingClientRect().height;N&&document.documentElement.style.setProperty("--oc-header-height",`${N}px`)},[]);ut.useEffect(()=>{if(typeof window>"u")return;gs();const N=h.current;if(!N||typeof ResizeObserver>"u")return()=>{};let ye=0;const $e=()=>{ye||(ye=requestAnimationFrame(()=>{ye=0,gs()}))},lt=new ResizeObserver($e);return lt.observe(N),window.addEventListener("resize",$e),window.addEventListener("orientationchange",$e),()=>{ye&&cancelAnimationFrame(ye),lt.disconnect(),window.removeEventListener("resize",$e),window.removeEventListener("orientationchange",$e)}},[gs]),ut.useEffect(()=>{gs()},[gs,w,as]);const us=c.useCallback(async N=>{const ye=N.target;ye.closest(".app-region-no-drag")||ye.closest("button, a, input, select, textarea")||N.button===0&&g&&await Km()},[g]),qs=c.useCallback(N=>sr(so(N,i)),[i]);Sp({rename_current_session:()=>{if(!d||w)return!1;Et()},toggle_services_menu:()=>{if(P){D(!1);return}D(!0),z()}});const Sn=s.jsxs(s.Fragment,{children:[Tt?s.jsx($b,{projectRef:Tt.projectRef,directory:Tt.directory,className:"mr-2"}):null,s.jsx(hb,{directory:Ct,className:"mr-1"}),g?s.jsx(my,{isDesktopApp:g,currentInstanceLabel:I,currentInstanceIsLocal:Z,isDesktopServicesOpen:P,setIsDesktopServicesOpen:D,refreshCurrentInstanceLabel:z,shortcutLabel:qs,remoteUpdateInfo:xe,remoteUpdateChecking:Re,remoteUpdateError:fe,onOpenRemoteUpdate:de}):null]}),Ys=b&&(a||!!d),hn=c.useCallback(({session:N,open:ye,isActive:$e,select:lt,closeOtherTabs:Pt,components:Dt})=>{const{Item:pt,Separator:qt}=Dt,wt=$e&&!H&&!kt&&oe&&!oe.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(pt,{onClick:()=>{$e||lt(),Ve.current=N.id},children:[s.jsx(_,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ma,{sessionID:N.id,directory:N.directory,open:ye,Item:pt}),s.jsxs(pt,{onClick:()=>At(N.id),children:[s.jsx(_,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(qt,{}),$e?s.jsxs(pt,{onClick:()=>{He()},children:[s.jsx(_,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,$e?qe(pt):null,wt?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(pt,{disabled:!Ae||Ye||f,onClick:dt,className:"w-full",children:[s.jsx(_,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ye?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(qt,{}),s.jsxs(pt,{onClick:Pt,children:[s.jsx(_,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(qt,{}),s.jsxs(pt,{onClick:()=>gt({action:"archive",sessionId:N.id}),children:[s.jsx(_,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(pt,{className:"text-destructive focus:text-destructive",onClick:()=>gt({action:"delete",sessionId:N.id}),children:[s.jsx(_,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[At,oe,He,kt,Ye,f,H,dt,qe,Ae,t]),on=()=>s.jsxs("div",{onMouseDown:us,className:Ee("app-region-drag relative flex h-12 select-none items-center",R&&A==="right"?"pr-0":"pr-3",as),style:Gs,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:zs}}),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:Ws}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Xt?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Ne.getState().closeMainSurfaces(),children:s.jsx(_,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Xt.title}),Xt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Xt.subtitle}):null]})]}):H||!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:[Q?s.jsx(_,{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(ql,{align:"start",children:s.jsx("button",{type:"button",className:ks,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(_,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[me?s.jsxs("form",{ref:We,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),yt()},children:[s.jsx("input",{ref:Ie,value:Xe,onChange:N=>nt(N.target.value),onKeyDown:N=>qi(N,()=>De(!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(_,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>De(!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(_,{name:"close",className:"size-4"})})]}):a?null:s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ge}),Pe?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:[x?s.jsx("span",{className:"truncate",children:x}):null,mt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(_,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:mt})]}):null,!a&&Fe?s.jsxs("span",{className:Ee("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(_,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:_e})]}):null]}):null]}),s.jsx("div",{className:Ee("flex h-[18px] shrink-0 items-center justify-center",Pe?"self-start":"self-center"),children:d&&!a&&!me?s.jsxs(Ls,{open:K,onOpenChange:Se,onOpenChangeComplete:N=>{!N&&Ve.current&&Ve.current===d&&(Ve.current=null,Et())},children:[s.jsx(Fs,{asChild:!0,children:s.jsx(ct,{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(_,{name:"more",className:"size-4"})})}),s.jsxs(_s,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Ht,{onClick:()=>{Ve.current=d},children:[s.jsx(_,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ma,{sessionID:d,directory:Ae,open:K,Item:Ht}),s.jsxs(Ht,{onClick:()=>d&&At(d),children:[s.jsx(_,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Es,{}),s.jsxs(Ht,{onClick:()=>{He()},children:[s.jsx(_,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),qe(Ht),!H&&!kt&&oe&&!oe.parentId?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Ht,{disabled:!Ae||Ye||f,onClick:dt,className:"w-full",children:[s.jsx(_,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Ye?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Es,{}),s.jsxs(Ht,{onClick:()=>{d&&gt({action:"archive",sessionId:d})},children:[s.jsx(_,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Ht,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&gt({action:"delete",sessionId:d})},children:[s.jsx(_,{name:"delete-bin",className:"mr-1 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(ql,{align:"start",children:s.jsx("button",{type:"button",className:ks,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(_,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Gb,{renderMenu:hn,suppressActiveTabControls:me,onMenuOpenChangeComplete:N=>{!N&&Ve.current&&Ve.current===d&&(Ve.current=null,Et())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:me?s.jsxs("form",{ref:We,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),yt()},children:[s.jsx("input",{ref:Ie,value:Xe,onChange:N=>nt(N.target.value),onKeyDown:N=>qi(N,()=>De(!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(_,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>De(!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(_,{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:a?t("sessions.switcher.draftTitle"):Ge})})})]}),Xt||H||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[q&&L?s.jsx(Ex,{reading:Rx(L),contextLimit:L.contextLimit,outputLimit:L.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:mn,pressed:vn,className:Ys?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(fy,{visible:Ys,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:nn,className:Ee(ks,"mr-1"),Icon:"picture-in-picture-2"}),H?null:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":re,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:ge,className:Ee(Vo,"mr-1",re?"text-foreground":"text-muted-foreground/50"),children:s.jsx(_,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t(ce&&!G?we?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":ce?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),Sn,s.jsx(Yu,{visible:R&&A==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:on()}),s.jsx(Ps,{open:Ze!==null,onOpenChange:N=>{N||gt(null)},children:s.jsxs(Ds,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(sn,{children:[s.jsx(Us,{children:Ze?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Hs,{children:Ze?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Ge}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Ge})})]}),s.jsxs(zn,{children:[s.jsx(ct,{variant:"outline",size:"sm",onClick:()=>gt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ct,{variant:"destructive",size:"sm",onClick:()=>{Ot()},children:Ze?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Ud,{open:ue,onOpenChange:se,info:xe,downloading:!1,downloaded:!1,progress:null,error:fe,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function py(){}const oc=280,ic=264,ac=500,gy=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=Nt(),l=Ne(v=>v.sidebarWidth),a=Ne(v=>v.setSidebarWidth),[d,u]=c.useState(!1),m=c.useRef(0),f=c.useRef(l||oc),p=c.useRef(null),y=c.useRef(null),x=c.useRef(null),k=c.useCallback(v=>Math.min(ac,Math.max(ic,v)),[]),w=c.useCallback(v=>{const E=x.current;E&&(E.style.width=`${v}px`,E.style.minWidth=`${v}px`,E.style.maxWidth=`${v}px`,E.style.setProperty("--oc-left-sidebar-width",`${v}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(p.current=null,y.current=null)},[d]),e)return null;const h=Math.min(ac,Math.max(ic,l||oc)),g=t?h:0,j=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}y.current=v.pointerId,u(!0),m.current=v.clientX,f.current=g,p.current=g,w(g),v.preventDefault()}},b=v=>{if(e||!d||y.current!==v.pointerId)return;const E=v.clientX-m.current,R=k(f.current+E);p.current!==R&&(p.current=R,w(R))},S=v=>{if(y.current!==v.pointerId||e)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const E=k(p.current??g);y.current=null,p.current=null,u(!1),a(E)},C=d?p.current??g:g;return s.jsxs("aside",{ref:x,className:Ee("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${d?C:h}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||g===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:Ee("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:j,onPointerMove:b,onPointerUp:S,onPointerCancel:S,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Ee("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(En,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Cs,{children:n})})]})]})},xy=()=>{const t=tt.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},uo="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-ring hover:bg-interactive-hover transition-colors",by=()=>{const t=tt.c(37),{t:e}=Nt(),n=Ne(yy),r=Ne(wy),i=Ne(vy),o=c.useRef(null),l=sr(so("toggle_sidebar",i)),a=Sy,{usesFramelessChrome:d,side:u}=qu(),m=ky;let f,p;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const L=o.current;if(!L)return;const W=()=>{const P=Math.max(L.getBoundingClientRect().width,L.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(P)}px`)};if(W(),typeof ResizeObserver>"u")return;const $=new ResizeObserver(W);return $.observe(L),()=>{$.disconnect()}},p=[],t[0]=f,t[1]=p):(f=t[0],p=t[1]),c.useEffect(f,p);const y="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let x;t[2]===Symbol.for("react.memo_cache_sentinel")?(x={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=x):x=t[2];const k="flex items-center gap-2";let w;t[3]!==d||t[4]!==u?(w=d&&u==="left"?s.jsx(Yu,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=w):w=t[5];let h;t[6]!==e||t[7]!==d?(h=d?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,"aria-label":e("header.actions.openAppMenuAria"),className:Ee(uo,"shrink-0"),children:s.jsx(_,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=h):h=t[8];const g=vt;let j;t[9]!==e?(j=e("header.actions.openSessionsAria"),t[9]=e,t[10]=j):j=t[10];let b,S;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=Ee(uo,"shrink-0"),S=s.jsx(_,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=b,t[12]=S):(b=t[11],S=t[12]);let C;t[13]!==j||t[14]!==n?(C=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":j,className:b,children:S})}),t[13]=j,t[14]=n,t[15]=C):C=t[15];const v=jt,E=e("header.actions.openSessionsWithShortcut",{shortcut:l});let R;t[16]!==E?(R=s.jsx("p",{children:E}),t[16]=E,t[17]=R):R=t[17];let A;t[18]!==v||t[19]!==R?(A=s.jsx(v,{children:R}),t[18]=v,t[19]=R,t[20]=A):A=t[20];let O;t[21]!==g||t[22]!==C||t[23]!==A?(O=s.jsxs(g,{children:[C,A]}),t[21]=g,t[22]=C,t[23]=A,t[24]=O):O=t[24];let B;t[25]!==a||t[26]!==r||t[27]!==e?(B=r?s.jsxs("button",{type:"button",onClick:a,className:Ee(uo,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(_,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Ee(uo,"-ml-1 shrink-0"),children:s.jsx(_,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=B):B=t[28];let T;t[29]!==O||t[30]!==B||t[31]!==w||t[32]!==h?(T=s.jsxs("div",{ref:o,className:k,children:[w,h,O,B]}),t[29]=O,t[30]=B,t[31]=w,t[32]=h,t[33]=T):T=t[33];let M;return t[34]!==T||t[35]!==x?(M=s.jsx("div",{className:y,style:x,children:T}),t[34]=T,t[35]=x,t[36]=M):M=t[36],M};function yy(t){return t.toggleSidebar}function wy(t){return t.isSidebarOpen}function vy(t){return t.shortcutOverrides}function Sy(){Ne.getState().closeMainSurfaces(),rt.getState().openNewSessionDraft()}function jy(t){console.warn("[titlebar] failed to open app menu",t)}function ky(t){const e=t.currentTarget.getBoundingClientRect();Fn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(jy)}function ff(t){const e=tt.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(_,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const lc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Cy(t,e,n){const r=tt.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,m]=await Promise.all([jp(t),kp(t)]).catch(Ny);if(d)return;const f=lc(u),p=lc(m);if(!f||!p||p===f)return;const y=n||"",x=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:f,branch:y,label:y||x,name:x,worktreeRoot:p,worktreeStatus:"ready",headState:y?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function Ny(){return["",""]}const cc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Ay=async(t,e)=>{if(t)return t.authActivate(e);const n=await bs("/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},dc=({className:t})=>{const{t:e}=Nt(),{github:n}=wn(),r=In(y=>y.status),i=In(y=>y.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async y=>{if(!(!y||o)){l(!0);try{i(await Ay(n,y))}catch(x){console.error("Failed to switch GitHub account:",x)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,m=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),p=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(_,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return m.length<=1?s.jsx("div",{className:Ee(cc,t),title:f,children:p}):s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee(cc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:p})}),s.jsxs(_s,{align:"end",className:"w-64",children:[s.jsx(_r,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Es,{}),m.map(y=>{const x=y.user,k=!!y.current,w=y.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Ht,{className:"gap-2",disabled:o,onSelect:()=>{k||a(y.id)},children:[x?.avatarUrl?s.jsx("img",{src:x.avatarUrl,alt:x.login?e("header.github.avatarWithLogin",{login:x.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(_,{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:x?.name?.trim()||x?.login||"GitHub"}),x?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:x.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:w})]}):null]}),k?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},y.id)})]})]})};class gi 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 xi="/api/walkthrough",mf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),hf=()=>new gi("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Py=t=>!mf(t)&&(t.ok||t.status===404),el=async(t,e)=>{if(Py(t))throw hf();const n=await t.json().catch(()=>null);throw new gi(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})},pf=async t=>{if(!mf(t))throw hf();try{return await t.json()}catch{throw new gi("The server returned a malformed walkthrough response")}};async function Dy(t,e,n={}){const r=await bs(xi,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?pf(r):el(r,"Failed to load walkthrough")}async function Iy(t,e,n={}){const r=await bs(`${xi}/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?pf(r):el(r,"Failed to generate walkthrough")}async function Ty(t,e){const n=await bs(`${xi}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await el(n,"Failed to cancel walkthrough generation")}async function Ey(t,e,n){const r=await bs(`${xi}/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 Ir={status:"idle",stage:null,result:null,readiness:null,error:null},Ry=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}`,Rn=(t,e)=>`${Qt()}\0${t}\0${Ry(e)}`,uc=t=>t instanceof gi?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Js=new Map,Tr=new Map,My=1e3,Oy=no()(eb((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Rn(n,r)],selectModel:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Rn(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[Rn(n,r)]??Ir,load:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);if(e().entries[o]?.status==="generating")return;Js.get(o)?.abort();const a=new AbortController;Js.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Ir,status:"loading",error:null}}}));try{const d=await Dy(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Ir,status:"error",stage:null,error:uc(d)}}}))}finally{Js.get(o)===a&&Js.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);Js.get(o)?.abort();const l=new AbortController;Js.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Ir,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Tr.get(o);d!==void 0&&(clearInterval(d),Tr.delete(o))};a(),Tr.set(o,setInterval(()=>{Ey(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const m=u.entries[o];return!m||m.status!=="generating"||m.stage===d?u:{entries:{...u.entries,[o]:{...m,stage:d}}}})}).catch(()=>{})},My));try{const d=await Iy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Ir,status:"error",stage:null,error:uc(d)}}}))}finally{a(),Js.get(o)===l&&Js.delete(o)}},cancel:(n,r)=>{const i=Rn(n,r);Ty(n,r).catch(()=>{}),Js.get(i)?.abort(),Js.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 Js.values())n.abort();Js.clear();for(const n of Tr.values())clearInterval(n);Tr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),By="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)]",Fy=3e4,fc=20,gf=(t,e)=>JSON.stringify([Qt(),t,e]),_y=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}},mc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),fo=new Map,Ly=t=>{const e=Object.entries(t);return e.length<=fc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,fc))},hc=no()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=gf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<Fy&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const m=`${l}::${a?"details":"plain"}`,p=fo.get(`${l}::details`)??(a?null:fo.get(m));if(p&&!o?.force)return p;const y=(async()=>{t(x=>({entries:{...x.entries,[l]:{...x.entries[l]??mc(),isLoading:!0,error:null}}}));try{const x=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(k=>({entries:Ly({...k.entries,[l]:{result:x,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),x}catch(x){const k=x instanceof Error?x.message:"Failed to load pull request context";return t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??mc(),isLoading:!1,error:k}}})),null}finally{fo.delete(m)}})();return fo.set(m,y),y},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=_y(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),$y=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}:{}}},zy=35e3,Ei=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},Ri=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},pc=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"}},Wy=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"},Ky=[2e3,5e3],Vy=600,gc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),On=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):""},Uy=(t,e)=>{const n=On(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},Hy=(t,e)=>`${t}::${e}`,tl=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},Mi=(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=tl(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)},Gy=t=>t.startsWith("pr-"),qy=(t,e)=>{const n=tl(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=>!Gy(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Er=new Map,mo=eo;function Yy(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const Qy=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=Nt(),d=Ne(N=>N.timeFormatPreference),{github:u}=wn(),m=In(N=>N.status),f=In(N=>N.hasChecked),p=Ne(N=>N.setSettingsDialogOpen),y=Ne(N=>N.setSettingsPage),x=rt(N=>N.currentSessionId),k=rt(N=>!!N.newSessionDraft?.open),{isMobile:w,hasTouchInput:h,screenWidth:g}=$n(),j=Ne(N=>N.openContextSurface),b=Oy(N=>N.requestSource),S=!w&&g>=768&&!_n(),C=c.useCallback(()=>{y("integrations"),p(!0)},[p,y]),v=c.useMemo(()=>Hy(t,e),[t,e]),E=c.useMemo(()=>Er.get(v)??null,[v]),R=Vs(N=>N.ensureEntry),A=Vs(N=>N.setParams),O=Vs(N=>N.startWatching),B=Vs(N=>N.stopWatching),T=Vs(N=>N.refresh),M=Vs(N=>N.updateStatus),[L,W]=c.useState(()=>E?.title??gc(e)),[$,P]=c.useState(()=>E?.body??""),[D,I]=c.useState(()=>E?.draft??!1),[X,Z]=c.useState(()=>E?.additionalContext??""),[ne,ue]=c.useState(()=>{const N=typeof E?.targetBaseBranch=="string"?On(E.targetBaseBranch):"";return N||On(n)}),[se,xe]=c.useState("squash"),[ie,Re]=c.useState(!1),[be,fe]=c.useState(!1),[ke,H]=c.useState(!1),[J,ce]=c.useState(!1),[je,G]=c.useState(!1),[we,Te]=c.useState(!1),[he,re]=c.useState(null),[ge,q]=c.useState(""),[z,ee]=c.useState(""),[de,Y]=c.useState(!1),[U,F]=c.useState(!1),[V,oe]=c.useState(()=>Mi(i,{selectedRemoteName:E?.selectedRemoteName,trackingBranch:r})),[ae,pe]=c.useState(!1),{detectedUpstream:le,upstreamBranches:_e}=Yy(t,u);c.useEffect(()=>{pe(!1)},[t]);const Fe=i.some(N=>N.name==="upstream"),Ae=!!(t&&e&&n&&(e!==n||(Fe||le!==null))),Q=c.useMemo(()=>ei(t,e,V?.name??null),[t,e,V?.name]),Ce=Vs(N=>N.entries[Q]),Be=Ce?.isLoading??!1,Le=Ce?.status??null,Je=Ce?.error??null,ot=Ce?.isInitialStatusResolved??!1,et=c.useMemo(()=>{const N=ae?null:V?.name?.trim()||null,ye=new Set;for(const Pt of o){const Dt=Uy(Pt,N);!Dt||Dt==="HEAD"||ye.add(Dt)}if(ae)for(const Pt of _e)Pt&&Pt!=="HEAD"&&ye.add(Pt);const $e=On(n);$e&&$e!=="HEAD"&&ye.add($e);const lt=On(ne);return lt&&lt!=="HEAD"&&ye.add(lt),Array.from(ye).sort((Pt,Dt)=>Pt.localeCompare(Dt))},[n,o,V?.name,ne,_e,ae]);c.useEffect(()=>{if(i.length===0){V&&oe(null);return}(!V||!i.some(N=>N.name===V.name))&&oe(Mi(i,{selectedRemoteName:E?.selectedRemoteName,trackingBranch:r}))},[E?.selectedRemoteName,i,V,r]),c.useEffect(()=>{const N=On(n);if(!ne&&N){ue(N);return}if(et.length!==0&&!et.includes(ne)){const ye=et.includes(N)?N:et[0];ye&&ue(ye)}},[et,n,ne]);const[it,ht]=c.useState(()=>E?.activeSegment??"overview"),[st,mt]=c.useState(new Set),[kt,Pe]=c.useState(new Set),Ge=c.useRef(new Set),at=c.useRef(null),ze=c.useRef(!1),ft=c.useRef(new Set),te=c.useRef([]);c.useEffect(()=>{le&&!Fe&&pe(!0)},[le,Fe]),c.useEffect(()=>{ae&&le?.defaultBranch&&ue(le.defaultBranch)},[ae,le?.defaultBranch]);const me=Le?.pr??null,De=me?.state==="merged"||me?.state==="closed",K=De?null:me,Se=K?gf(t,K.number):null,Ve=hc(N=>Se?N.entries[Se]:void 0),Xe=hc(N=>N.ensure),nt=Ve?.result??null,Ze=Ve?.isLoading??!1,gt=c.useCallback(N=>{ht(N);const ye=Er.get(v);ye&&Er.set(v,{...ye,activeSegment:N})},[v]);c.useEffect(()=>{!K||!u?.prContext||it==="overview"||Xe(u,t,K.number,{includeCheckDetails:it==="checks",sourceRepo:Le?.repo??null})},[it,t,Xe,u,K,Le?.repo]);const We=Le?.checks??null,Et=(We?.pending??0)>0,Ft=nt?.checkRuns??null,Ie=nt?.fetchedAt;c.useEffect(()=>{if(!Ft||Ft.length===0)return;const N=$y(Ft);M(Q,ye=>{if(!ye?.pr||typeof Ie=="number"&&typeof ye.fetchedAt=="number"&&Ie<ye.fetchedAt)return ye;const $e=ye.checks;return $e&&$e.state===N.state&&$e.total===N.total&&$e.success===N.success&&$e.failure===N.failure&&$e.pending===N.pending&&$e.inProgress===N.inProgress&&$e.queued===N.queued&&$e.startedAt===N.startedAt?ye:{...ye,checks:N,...typeof Ie=="number"?{fetchedAt:Ie}:{}}})},[Ft,Ie,Q,M]),c.useEffect(()=>{if(it!=="checks"||!Et||!me||!u?.prContext)return;const N=window.setInterval(()=>{Xe(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Le?.repo??null,force:!0})},zy);return()=>window.clearInterval(N)},[it,Et,t,Xe,u,me,Le?.repo]);const[yt,At]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Et)return;At(Date.now());const N=window.setInterval(()=>At(Date.now()),3e4);return()=>window.clearInterval(N)},[Et]);const He=me?`${t}#${me.number}`:null,Ue=!!(He&&he===He);c.useEffect(()=>{if(!u?.prContext||!me||typeof me.body=="string"&&me.body.length>0)return;const N=`${t}#${me.number}`;if(Ge.current.has(N))return;Ge.current.add(N),re(N);let ye=!1;return Xe(u,t,me.number,{sourceRepo:Le?.repo??null}).then($e=>{if(ye)return;const lt=$e?.pr;lt&&M(Q,Pt=>!Pt?.pr||Pt.pr.number!==me.number?Pt:{...Pt,pr:{...Pt.pr,body:lt.body||""}})}).catch(()=>{}).finally(()=>{ye||re($e=>$e===N?null:$e)}),()=>{ye=!0}},[t,Xe,u,me,Q,Le?.repo,M]),c.useEffect(()=>{if(!me){Te(!1),q(""),ee(""),at.current=null;return}const N=at.current!==null&&at.current!==me.number;N&&Te(!1),(!we||N)&&(q(me.title||""),ee(me.body||"")),at.current=me.number},[we,me]);const ve=c.useCallback(N=>{if(!N)return"";const ye=Date.parse(N);return Number.isFinite(ye)?yu(ye,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):N},[d]),Qe=c.useMemo(()=>{const N=m?.user?.login;return typeof N=="string"?N.trim():""},[m]),qe=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)]",[]),Ye=c.useCallback(N=>{const ye=Qe.toLowerCase(),$e=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return N.replace($e,(lt,Pt,Dt)=>{const pt=`@${Dt}`,qt=Dt.toLowerCase();return`${Pt}[${pt}](https://github.com/${qt}${ye&&qt===ye?"?oc-self-mention=1":""})`})},[Qe]),dt=c.useMemo(()=>{const N=(nt?.issueComments??[]).map(lt=>({id:`issue-${lt.id}`,body:lt.body||"",authorName:lt.author?.name||lt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:lt.author?.login||null,avatarUrl:lt.author?.avatarUrl||null,createdAt:lt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),ye=(nt?.reviewComments??[]).map(lt=>({id:`review-${lt.id}`,body:lt.body||"",authorName:lt.author?.name||lt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:lt.author?.login||null,avatarUrl:lt.author?.avatarUrl||null,createdAt:lt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:lt.path||null,line:lt.line??null})),$e=[...N,...ye];return $e.sort((lt,Pt)=>{const Dt=lt.createdAt?Date.parse(lt.createdAt):0,pt=Pt.createdAt?Date.parse(Pt.createdAt):0,qt=Number.isFinite(Dt)?Dt:0,wt=Number.isFinite(pt)?pt:0;return qt-wt}),$e},[nt,a]),Ot=c.useCallback(()=>{const N=x??(k?"draft":null);return N?{directory:t,sessionKey:N}:(Ke.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[x,t,k,a]),zt=c.useCallback((N,ye)=>{const $e=ye.authorLogin?`@${ye.authorLogin}`:ye.authorName,lt=ye.path?` · ${ye.path}${ye.line?`:${ye.line}`:""}`:"";Ji.getState().addDraft(N,{source:"pr-comment",fileLabel:`PR #${me?.number??""} ${$e}${lt}`,startLine:ye.line??0,endLine:ye.line??0,code:ye.body,language:"markdown",text:""})},[me?.number]),Kt=c.useCallback((N,ye)=>{const $e=N.status||"unknown",lt=N.conclusion??void 0,Pt=lt?`${$e} / ${lt}`:$e,Dt=N.app?.name||N.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:ye?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[ye?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:N.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Dt?`${Dt} · ${Pt}`:Pt})]}),N.detailsUrl?s.jsx(ct,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:N.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(_,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),N.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:N.output.title}):null,N.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:N.output.summary}):null,N.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:N.output.text}):null,Array.isArray(N.annotations)&&N.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",N.annotations.length>20?` (showing 20/${N.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:N.annotations.slice(0,20).map((pt,qt)=>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||qt}:${qt}`))})]}):null,N.job?.steps&&N.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:N.job.steps.map((pt,qt)=>{const wt=(pt.conclusion||"").toLowerCase(),bt=wt&&!["success","neutral","skipped"].includes(wt),It=`${N.id??"run"}:${N.job?.jobId??"job"}:${pt.number??qt}:${pt.name}`,Lt=st.has(It);return bt?s.jsxs(Zi,{open:Lt,children:[s.jsxs("button",{type:"button",onClick:()=>{mt(Zt=>{const $t=new Set(Zt);return $t.has(It)?$t.delete(It):$t.add(It),$t})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(bt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Lt?s.jsx(_,{name:"arrow-down-s",className:"size-4"}):s.jsx(_,{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(ea,{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"),": ",ve(pt.startedAt)]}):null,pt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",ve(pt.completedAt)]}):null]})})]},It):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]},It)})})]}):null]})},[st,ve,a]),[Gt,Bt]=c.useState(!1),[Jt,Vt]=c.useState(!1),Wt=c.useCallback(async()=>{if(!u?.prContext){Ke.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!me)return;const N=Ot();if(N){Bt(!0);try{const ye=await Xe(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Le?.repo??null});if(!ye){Ke.error(a("gitView.pr.toast.loadChecksFailed"));return}const lt=(ye.checkRuns??[]).filter(Dt=>Ri(Dt.conclusion));if(lt.length===0){Ke.message(a("gitView.pr.toast.noFailedChecks"));return}const Pt=Ji.getState();for(const Dt of lt){const pt=(Dt.annotations??[]).map(bt=>[[bt.level,bt.title].filter(Boolean).join(" "),bt.path?`${bt.path}${typeof bt.startLine=="number"?`:${bt.startLine}`:""}`:null,bt.message,bt.rawDetails].filter(Boolean).join(`
3
3
  `)),qt=(Dt.job?.steps??[]).filter(bt=>Ri(bt.conclusion)).map(bt=>`step ${bt.number??"?"}: ${bt.name} → ${bt.conclusion}`),wt=[`check: ${Dt.job?.workflowName?`${Dt.job.workflowName} / ${Dt.name}`:Dt.name}`,`status: ${Dt.status??"unknown"} / ${Dt.conclusion??"unknown"}`,Dt.detailsUrl?`url: ${Dt.detailsUrl}`:null,Dt.output?.title?`title: ${Dt.output.title}`:null,Dt.output?.summary?`summary:
4
4
  ${Dt.output.summary}`:null,qt.length>0?`failed steps:
5
5
  ${qt.join(`
@@ -875,7 +875,7 @@ ${t}
875
875
  styles: styles
876
876
  };
877
877
  `),ev=t=>{const e=tt.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=Nt();if(n.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let f;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(f=(p,y)=>s.jsxs("div",{role:"option","aria-selected":y===r,className:Ee("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",y===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:x=>{x.preventDefault(),i(p.url)},onPointerEnter:()=>l(y),children:[s.jsx(_,{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||ol(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsx("button",{type:"button",className:Ee("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:x=>{x.preventDefault(),x.stopPropagation(),o(p.url)},children:s.jsx(_,{name:"close",className:"size-3","aria-hidden":"true"})})]},p.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let m;return e[15]!==d||e[16]!==u?(m=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=m):m=e[17],m},en=t=>{const e=tt.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=Ee("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let m;e[2]!==n?(m=s.jsx(_,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=m):m=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==m?(f=s.jsx(St,{asChild:!0,children:s.jsx(ct,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:m})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=m,e[11]=f):f=e[11];let p;e[12]!==r?(p=s.jsx(jt,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let y;return e[14]!==f||e[15]!==p?(y=s.jsxs(vt,{children:[f,p]}),e[14]=f,e[15]=p,e[16]=y):y=e[16],y},Rf=t=>{const e=tt.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:m,canGoBack:f,canGoForward:p,isLoading:y,onAnnotate:x,onOpenDevTools:k,isAnnotating:w,onHardReload:h,onZoomIn:g,onZoomOut:j,onZoomReset:b,zoomPercent:S,onClearCookies:C,onClearCache:v,onToggleDeviceBar:E,isDeviceBarOpen:R}=t;let A;e[0]!==r?(A=r===void 0?[]:r,e[0]=r,e[1]=A):A=e[1];const O=A,B=S===void 0?100:S,{t:T}=Nt(),[M,L]=c.useState(!1),[W,$]=c.useState(-1);let P;e[2]!==M||e[3]!==O?(P=M?O:[],e[2]=M,e[3]=O,e[4]=P):P=e[4];const D=P;let I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{$(-1)},e[5]=I):I=e[5];let X;e[6]!==n||e[7]!==M?(X=[n,M],e[6]=n,e[7]=M,e[8]=X):X=e[8],c.useEffect(I,X);let Z;e[9]!==l?(Z=Fe=>{L(!1),$(-1),l(Fe)},e[9]=l,e[10]=Z):Z=e[10];const ne=Z;let ue;e[11]!==W||e[12]!==ne||e[13]!==D?(ue=Fe=>{if(D.length!==0){if(Fe.key==="ArrowDown"||Fe.key==="ArrowUp"){Fe.preventDefault();const Me=Fe.key==="ArrowDown"?1:-1,Ae=D.length;$(Q=>{const Ce=Q+Me;return Ce<-1?Ae-1:Ce>=Ae?-1:Ce});return}if(Fe.key==="Escape"&&W>=0){Fe.preventDefault(),$(-1);return}if(Fe.key==="Enter"&&W>=0){Fe.preventDefault();const Me=D[W];Me&&ne(Me.url)}}},e[11]=W,e[12]=ne,e[13]=D,e[14]=ue):ue=e[14];const se=ue;let xe;e[15]!==T?(xe=T("contextPanel.browser.back"),e[15]=T,e[16]=xe):xe=e[16];const ie=!f;let Re;e[17]!==a||e[18]!==ie||e[19]!==xe?(Re=s.jsx(en,{icon:"arrow-left",label:xe,onClick:a,disabled:ie}),e[17]=a,e[18]=ie,e[19]=xe,e[20]=Re):Re=e[20];let be;e[21]!==T?(be=T("contextPanel.browser.forward"),e[21]=T,e[22]=be):be=e[22];const fe=!p;let ke;e[23]!==d||e[24]!==be||e[25]!==fe?(ke=s.jsx(en,{icon:"arrow-right",label:be,onClick:d,disabled:fe}),e[23]=d,e[24]=be,e[25]=fe,e[26]=ke):ke=e[26];let H;e[27]!==y||e[28]!==T?(H=T(y?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=y,e[28]=T,e[29]=H):H=e[29];let J;e[30]!==u||e[31]!==H?(J=s.jsx(en,{icon:"refresh",label:H,onClick:u}),e[30]=u,e[31]=H,e[32]=J):J=e[32];let ce;e[33]!==h||e[34]!==T?(ce=h?s.jsx(en,{icon:"restart",label:T("contextPanel.browser.hardReload"),onClick:h}):null,e[33]=h,e[34]=T,e[35]=ce):ce=e[35];let je;e[36]!==n||e[37]!==ne?(je=Fe=>{Fe.preventDefault(),ne(n)},e[36]=n,e[37]=ne,e[38]=je):je=e[38];let G;e[39]!==o?(G=Fe=>o(Fe.target.value),e[39]=o,e[40]=G):G=e[40];let we,Te;e[41]===Symbol.for("react.memo_cache_sentinel")?(we=()=>L(!0),Te=()=>L(!1),e[41]=we,e[42]=Te):(we=e[41],Te=e[42]);const he=D.length>0;let re;e[43]===Symbol.for("react.memo_cache_sentinel")?(re=Ee("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 ge;e[44]!==T?(ge=T("contextPanel.browser.addressAria"),e[44]=T,e[45]=ge):ge=e[45];let q;e[46]!==n||e[47]!==se||e[48]!==G||e[49]!==he||e[50]!==ge?(q=s.jsx("input",{value:n,onChange:G,onFocus:we,onBlur:Te,onKeyDown:se,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":he,"aria-controls":"openchamber-browser-address-suggestions",className:re,"aria-label":ge}),e[46]=n,e[47]=se,e[48]=G,e[49]=he,e[50]=ge,e[51]=q):q=e[51];let z;e[52]!==i?(z=Fe=>i?.(Fe),e[52]=i,e[53]=z):z=e[53];let ee;e[54]!==W||e[55]!==ne||e[56]!==z||e[57]!==D?(ee=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(ev,{entries:D,activeIndex:W,onSelect:ne,onForget:z,onHighlight:$})}),e[54]=W,e[55]=ne,e[56]=z,e[57]=D,e[58]=ee):ee=e[58];let de;e[59]!==je||e[60]!==q||e[61]!==ee?(de=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:je,children:[q,ee]}),e[59]=je,e[60]=q,e[61]=ee,e[62]=de):de=e[62];let Y;e[63]!==g||e[64]!==j||e[65]!==b||e[66]!==T||e[67]!==B?(Y=j&&g?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(en,{icon:"subtract",label:T("contextPanel.browser.zoomOut"),onClick:j}),B!==100&&b?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ct,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:b,"aria-label":T("contextPanel.browser.zoomReset"),children:[B,"%"]})}),s.jsx(jt,{sideOffset:6,children:T("contextPanel.browser.zoomReset")})]}):null,s.jsx(en,{icon:"add",label:T("contextPanel.browser.zoomIn"),onClick:g})]}):null,e[63]=g,e[64]=j,e[65]=b,e[66]=T,e[67]=B,e[68]=Y):Y=e[68];let U;e[69]!==C||e[70]!==T?(U=C?s.jsx(en,{icon:"delete-bin",label:T("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=T,e[71]=U):U=e[71];let F;e[72]!==v||e[73]!==T?(F=v?s.jsx(en,{icon:"database-2",label:T("contextPanel.browser.clearCache"),onClick:v}):null,e[72]=v,e[73]=T,e[74]=F):F=e[74];let V;e[75]!==R||e[76]!==E||e[77]!==T?(V=E?s.jsx(en,{icon:"smartphone",label:T("contextPanel.browser.deviceToolbar"),onClick:E,pressed:R}):null,e[75]=R,e[76]=E,e[77]=T,e[78]=V):V=e[78];let oe;e[79]!==w||e[80]!==x||e[81]!==T?(oe=x?s.jsx(en,{icon:"markup",label:T("contextPanel.browser.annotate.toggle"),onClick:x,pressed:w}):null,e[79]=w,e[80]=x,e[81]=T,e[82]=oe):oe=e[82];let ae;e[83]!==k||e[84]!==T?(ae=k?s.jsx(en,{icon:"terminal-box",label:T("contextPanel.browser.devTools"),onClick:k}):null,e[83]=k,e[84]=T,e[85]=ae):ae=e[85];let pe;e[86]!==T?(pe=T("contextPanel.browser.openExternal"),e[86]=T,e[87]=pe):pe=e[87];let le;e[88]!==m||e[89]!==pe?(le=s.jsx(en,{icon:"external-link",label:pe,onClick:m}),e[88]=m,e[89]=pe,e[90]=le):le=e[90];let _e;return e[91]!==Re||e[92]!==ke||e[93]!==J||e[94]!==ce||e[95]!==de||e[96]!==Y||e[97]!==U||e[98]!==F||e[99]!==V||e[100]!==oe||e[101]!==ae||e[102]!==le?(_e=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Re,ke,J,ce,de,Y,U,F,V,oe,ae,le]}),e[91]=Re,e[92]=ke,e[93]=J,e[94]=ce,e[95]=de,e[96]=Y,e[97]=U,e[98]=F,e[99]=V,e[100]=oe,e[101]=ae,e[102]=le,e[103]=_e):_e=e[103],_e},Uo={kind:"fill"},Pc=240,tv=3840,Mf=[{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}],Dc=t=>Number.isFinite(t)?Math.round(Math.min(tv,Math.max(Pc,t))):Pc,Ho=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Of=t=>{const e=Mf.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},sv=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},nv=(t,e)=>{const n=Ho(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}},rv=["mobile","tablet","desktop","fill"],ov={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Ic=t=>typeof t=="string"&&rv.includes(t),Sa=t=>t==="fill"?Uo:Of(ov[t])??Uo,xo=t=>{const e=Ho(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=Sa(n),i=Ho(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}},iv=t=>{const e=tt.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=Nt();let d;e[0]!==n?(d=Ho(n),e[0]=n,e[1]=d):d=e[1];const u=d,m=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==u?(f=(ie,Re)=>{const be=Number.parseInt(Re,10);if(!Number.isFinite(be))return;const fe=u??{width:1280,height:800};r({kind:"custom",width:Dc(ie==="width"?be:fe.width),height:Dc(ie==="height"?be:fe.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const p=f;let y;e[5]===Symbol.for("react.memo_cache_sentinel")?(y=Ee("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]=y):y=e[5];const x=y;let k;e[6]!==r?(k=ie=>{const Re=Of(ie.target.value);r(Re??Uo)},e[6]=r,e[7]=k):k=e[7];let w;e[8]!==a?(w=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=w):w=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=Ee("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]=h):h=e[10];let g;e[11]!==a?(g=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=g):g=e[12];let j;e[13]!==g?(j=s.jsx("option",{value:"",children:g}),e[13]=g,e[14]=j):j=e[14];let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=Mf.map(av),e[15]=b):b=e[15];let S;e[16]!==m||e[17]!==k||e[18]!==w||e[19]!==j?(S=s.jsxs("select",{value:m,onChange:k,"aria-label":w,className:h,children:[j,b]}),e[16]=m,e[17]=k,e[18]=w,e[19]=j,e[20]=S):S=e[20];const C=u?String(u.width):"";let v;e[21]!==p?(v=ie=>p("width",ie.target.value),e[21]=p,e[22]=v):v=e[22];let E;e[23]!==a?(E=a("contextPanel.browser.device.width"),e[23]=a,e[24]=E):E=e[24];let R;e[25]!==C||e[26]!==v||e[27]!==E?(R=s.jsx("input",{value:C,onChange:v,placeholder:"—",inputMode:"numeric","aria-label":E,className:x}),e[25]=C,e[26]=v,e[27]=E,e[28]=R):R=e[28];let A;e[29]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=A):A=e[29];const O=u?String(u.height):"";let B;e[30]!==p?(B=ie=>p("height",ie.target.value),e[30]=p,e[31]=B):B=e[31];let T;e[32]!==a?(T=a("contextPanel.browser.device.height"),e[32]=a,e[33]=T):T=e[33];let M;e[34]!==O||e[35]!==B||e[36]!==T?(M=s.jsx("input",{value:O,onChange:B,placeholder:"—",inputMode:"numeric","aria-label":T,className:x}),e[34]=O,e[35]=B,e[36]=T,e[37]=M):M=e[37];let L;e[38]!==r||e[39]!==n?(L=()=>r(sv(n)),e[38]=r,e[39]=n,e[40]=L):L=e[40];const W=!u;let $;e[41]!==a?($=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=$):$=e[42];let P;e[43]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(_,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=P):P=e[43];let D;e[44]!==L||e[45]!==W||e[46]!==$?(D=s.jsx(St,{asChild:!0,children:s.jsx(ct,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:L,disabled:W,"aria-label":$,children:P})}),e[44]=L,e[45]=W,e[46]=$,e[47]=D):D=e[47];let I;e[48]!==a?(I=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=I):I=e[49];let X;e[50]!==I?(X=s.jsx(jt,{sideOffset:6,children:I}),e[50]=I,e[51]=X):X=e[51];let Z;e[52]!==D||e[53]!==X?(Z=s.jsxs(vt,{children:[D,X]}),e[52]=D,e[53]=X,e[54]=Z):Z=e[54];let ne;e[55]!==l||e[56]!==u?(ne=u&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=ne):ne=e[57];let ue;e[58]===Symbol.for("react.memo_cache_sentinel")?(ue=["system","light","dark"],e[58]=ue):ue=e[58];let se;e[59]!==i||e[60]!==o||e[61]!==a?(se=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ue.map(ie=>s.jsx(ct,{type:"button",variant:i===ie?"secondary":"ghost",size:"xs",className:Ee("shrink-0 rounded-full px-2.5 typography-micro",i===ie?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(ie),"aria-pressed":i===ie,children:a(ie==="system"?"contextPanel.browser.device.schemeSystem":ie==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},ie))}),e[59]=i,e[60]=o,e[61]=a,e[62]=se):se=e[62];let xe;return e[63]!==S||e[64]!==R||e[65]!==M||e[66]!==Z||e[67]!==ne||e[68]!==se?(xe=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[S,R,A,M,Z,ne,se]}),e[63]=S,e[64]=R,e[65]=M,e[66]=Z,e[67]=ne,e[68]=se,e[69]=xe):xe=e[69],xe};function av(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const lv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},cv=2e3,dv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=Dn();if(!t)return!1;try{return!Nr(new URL(t,window.location.href).toString())}catch{return!1}},Bf=t=>{const e=tt.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,d]=c.useState(l),u=Nb(i),[m]=c.useState(dv);let f,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let R=!0,A=null;const O=new AbortController,B=()=>{iw(O.signal).then(T=>{R&&(d(T),A=setTimeout(B,cv))})};return B(),()=>{R=!1,A&&clearTimeout(A),O.abort()}},p=[],e[1]=f,e[2]=p):(f=e[1],p=e[2]),c.useEffect(f,p);const y=a.kind==="ready"?a.servers:null;let x;e[3]!==u||e[4]!==y?(x=cw({announced:u,discovered:y}),e[3]=u,e[4]=y,e[5]=x):x=e[5];const k=x;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Nu,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=w):w=e[6];let h;e[7]!==o?(h=o("contextPanel.browser.empty"),e[7]=o,e[8]=h):h=e[8];let g;e[9]!==h?(g=s.jsx("span",{className:"typography-ui-header text-foreground",children:h}),e[9]=h,e[10]=g):g=e[10];let j;e[11]!==o?(j=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=j):j=e[12];let b;e[13]!==j?(b=s.jsx("span",{className:"typography-micro text-muted-foreground",children:j}),e[13]=j,e[14]=b):b=e[14];let S;e[15]!==b||e[16]!==g?(S=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[g,b]}),e[15]=b,e[16]=g,e[17]=S):S=e[17];let C;e[18]!==u||e[19]!==k||e[20]!==i||e[21]!==n||e[22]!==m||e[23]!==o?(C=k.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),m?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:k.map(R=>s.jsxs(ct,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{jb(i),n(R.url)},children:[s.jsx(_,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:ol(R.url)||R.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:lv(R.url)})]},R.port))})]}):null,e[18]=u,e[19]=k,e[20]=i,e[21]=n,e[22]=m,e[23]=o,e[24]=C):C=e[24];let v;e[25]!==k.length||e[26]!==a.kind||e[27]!==o?(v=k.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=k.length,e[26]=a.kind,e[27]=o,e[28]=v):v=e[28];let E;return e[29]!==S||e[30]!==C||e[31]!==v?(E=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:[w,S,C,v]}),e[29]=S,e[30]=C,e[31]=v,e[32]=E):E=e[32],E},Bs=t=>Math.round(t),uv=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Bs(l.x)}, y=${Bs(l.y)}, width=${Bs(l.width)}, height=${Bs(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")},fv=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Bs(n.x)}, y=${Bs(n.y)}, width=${Bs(n.width)}, height=${Bs(n.height)}`},mv=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Bs(n.x)}, y=${Bs(n.y)}, width=${Bs(n.width)}, height=${Bs(n.height)}`},hv=({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: ${Bs(t.viewport.width)}x${Bs(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("",...uv(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(fv(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(mv(l,a)))),o.filter(l=>typeof l=="string").join(`
878
- `)},pv=t=>{const e=tt.c(7),{t:n}=Nt(),r=rt(xv),i=rt(bv),o=Ji(yv),l=Lp(wv);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){Ke.error(n("contextPanel.browser.annotate.noSession"));return}let m=!1;if(d.screenshot)try{await l(d.screenshot),m=!0}catch{m=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:hv({payload:d.payload,screenshotAttached:m,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Ke.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},gv=()=>{const t=tt.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 xv(t){return t.currentSessionId}function bv(t){return t.newSessionDraft?.open}function yv(t){return t.addDraft}function wv(t){return t.addAttachedFile}const vv=3e4,Sv=3,jv=250,kv={attempts:0,windowStartedAt:null},Cv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=vv,r=n?0:t.attempts;return r>=Sv?null:{delayMs:jv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Nv=-3,bo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",gr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Av=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:fw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,m]=c.useState(!1),[f,p]=c.useState(!1),y=c.useRef(n);y.current=n;const x=c.useRef(kv);return c.useEffect(()=>{if(!t)return;const k=()=>{try{const A=t.getURL();return bo(A)?A:""}catch{return""}},w=()=>{try{m(t.canGoBack()),p(t.canGoForward())}catch{}},h=A=>{bo(A)&&(l(A),y.current(A))},g=()=>{const A=k();i({kind:"loading",url:A})},j=()=>{const A=k();let O="";try{O=t.getTitle()||""}catch{O=""}d(O),h(A),w(),i(B=>B.kind==="failed"&&B.url===A?B:{kind:"ready",url:A,title:O})},b=A=>{const O=gr(A);bo(O.url)&&(h(O.url),w())},S=A=>{const O=gr(A),B=Array.isArray(O.favicons)?O.favicons.find(Boolean):"",T=k();B&&T&&Sf.getState().resolve(T,B)},C=A=>{const O=gr(A);typeof O.title=="string"&&d(O.title)},v=A=>{const O=gr(A);if(O.isMainFrame===!1)return;const B=typeof O.errorCode=="number"?O.errorCode:0;B!==Nv&&i({kind:"failed",url:bo(O.validatedURL)?O.validatedURL:k(),code:B,description:typeof O.errorDescription=="string"?O.errorDescription:""})};let E=null;const R=()=>{const A=k(),O=Cv(x.current,Date.now());if(!O){i({kind:"failed",url:A,code:0,description:"",crashed:!0});return}x.current=O.state,i({kind:"loading",url:A}),E=setTimeout(()=>{E=null;try{t.reload()}catch{i({kind:"failed",url:A,code:0,description:"",crashed:!0})}},O.delayMs)};t.addEventListener("did-start-loading",g),t.addEventListener("did-stop-loading",j),t.addEventListener("did-navigate",b),t.addEventListener("did-navigate-in-page",b),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",S),t.addEventListener("did-fail-load",v),t.addEventListener("render-process-gone",R),t.addEventListener("crashed",R);try{!t.isLoading()&&k()&&j()}catch{}return()=>{E!==null&&clearTimeout(E),t.removeEventListener("render-process-gone",R),t.removeEventListener("crashed",R),t.removeEventListener("did-start-loading",g),t.removeEventListener("did-stop-loading",j),t.removeEventListener("did-navigate",b),t.removeEventListener("did-navigate-in-page",b),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",S),t.removeEventListener("did-fail-load",v)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},Pv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Dv=4e4,yo=.5,Iv=-3,Tv=4,Ev="persist:openchamber-browser",Tc=20,Rv=600,Mv=2e4,Ov=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=Nt(),{currentTheme:i}=Ln(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(Y=>{o.current=Y,a(Y)},[]),u=Ne(Y=>Y.setContextPanelTabTargetPath),m=c.useRef(wr(t)),f=m.current!==tn?m.current:"",[p,y]=c.useState(f?null:tn),[x,k]=c.useState(f),[w,h]=c.useState(!1),[g,j]=c.useState(!1),[b,S]=c.useState(0),C=c.useRef(0),[v,E]=c.useState(!1),[R,A]=c.useState(Uo),O=c.useRef(R);O.current=R;const B=c.useRef([]),[T,M]=c.useState("system"),[L,W]=c.useState({width:0,height:0}),$=c.useRef(null),P=c.useRef(null),D=c.useRef(!1),I=c.useRef(Date.now()),X=c.useCallback(Y=>{!Y||Y===tn||!e||!n||u(e,n,Y)},[e,n,u]),Z=Av(l,{initialUrl:f,onUrlChange:c.useCallback(Y=>{const U=Rr(Y);k(U),X(U)},[X])}),[ne,ue]=c.useState(null),se=pv(e),xe=gv(),ie=Z.status.kind==="loading",Re=Sr(Df(e)),be=Sr(Y=>Y.recordVisit),fe=Sr(Y=>Y.forget);c.useEffect(()=>{Z.status.kind==="ready"&&be(e,{url:Rr(Z.status.url),title:Z.status.title})},[e,Z.status,be]);const ke=c.useMemo(()=>Pf(Re,x),[Re,x]),H=c.useCallback(Y=>{const U=wr(Y);U!==tn&&(k(U),ue(null),Cc(U).then(F=>{const V=o.current;if(!V){y(F);return}try{V.loadURL(F)}catch{y(F)}}).catch(F=>{F instanceof Hr&&ue(U)}))},[]);c.useEffect(()=>{if(!f)return;let Y=!0;return Cc(f).then(U=>{Y&&y(U)}).catch(U=>{if(Y){if(U instanceof Hr){ue(f),y(tn);return}y(f)}}),()=>{Y=!1}},[]);const J=c.useMemo(()=>({executeJavaScript:async(Y,U)=>{const F=o.current;if(!F)throw new Error("Browser view is not available");return F.executeJavaScript(Y,U)},capturePage:async()=>{const Y=o.current;if(!Y)return null;const U=Y.getWebContentsId();return Number.isFinite(U)?await br("desktop_browser_capture_page",{webContentsId:U}):null}}),[]),ce=c.useCallback(()=>{if(w){h(!1),Eo(J);return}if(!Z.url){Ke.error(r("contextPanel.browser.annotate.noPage"));return}const Y=Nw(i.metadata.variant==="light"?"light":"dark");h(!0),kw({host:J,theme:Y,labels:xe}).then(async U=>{h(!1),U&&await se(U)}).catch(()=>{h(!1),Ke.error(r("contextPanel.browser.annotate.failed"))})},[J,se,i,w,Z.url,xe,r]);c.useEffect(()=>{if(!w)return;const Y=U=>{$p(U)||U.key!=="Escape"||(U.preventDefault(),U.stopImmediatePropagation(),h(!1),Eo(J))};return window.addEventListener("keydown",Y,!0),()=>window.removeEventListener("keydown",Y,!0)},[J,w]);const je=c.useCallback(async(Y=8e3)=>{const U=Date.now();for(;;){const F=o.current;if(!F)return!1;let V=!1;try{V=F.isLoading()}catch{return!1}if(!V)return!0;if(Date.now()-U>Y)return!1;await new Promise(oe=>setTimeout(oe,120))}},[]),G=c.useCallback(async(Y,U)=>{const F=o.current;if(!F)throw new Error("The browser panel is not ready");const V=()=>{Ic(U.viewport)&&(A(Sa(U.viewport)),E(!0))};if(Y==="browser.back"||Y==="browser.forward"){const Fe=Y==="browser.back";if(!(Fe?F.canGoBack():F.canGoForward()))throw new Error(Fe?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Fe?F.goBack():F.goForward(),await new Promise(Q=>setTimeout(Q,150)),await je();let Ae="";try{Ae=F.getTitle()||""}catch{Ae=""}return{url:Rr(F.getURL()),title:Ae}}if(Y==="browser.capture"){const Fe=Ne.getState(),Me=Qn(e),Ae=Fe.contextPanelByDirectory[Me],Q=!!(Ae?.isOpen&&Ae.activeTabId===n);Q||Fe.setActiveContextPanelTab(e,n);const Ce=()=>{if(Q||!Ae)return;const Be=Ne.getState(),Le=Be.contextPanelByDirectory[Me];!Le?.isOpen||Le.activeTabId!==n||(Ae.activeTabId&&Ae.activeTabId!==n&&Be.setActiveContextPanelTab(e,Ae.activeTabId),Ae.isOpen||Be.closeContextPanel(e))};try{const Be=Date.now()+1200;let Le=0,Je=0;for(;Je<2&&Date.now()<Be;){const it=F.getBoundingClientRect().width;Je=it>=2&&Math.abs(it-Le)<.5?Je+1:0,Le=it,await new Promise(ht=>setTimeout(ht,50))}await new Promise(it=>{requestAnimationFrame(()=>requestAnimationFrame(()=>it()))}),await je();const ot=await J.capturePage();if(!ot)throw new Error("The page could not be captured");let et="";try{et=F.getTitle()||""}catch{et=""}return{...ot,url:Rr(F.getURL()),title:et,viewport:xo(O.current)}}finally{Ce()}}if(Y==="browser.resize"){if(!Ic(U.viewport))throw new Error("viewport is required");return V(),await new Promise(Fe=>setTimeout(Fe,200)),await je(),{viewport:xo(Sa(U.viewport))}}if(Y==="browser.open"){const Fe=typeof U.url=="string"?U.url:"";if(!Fe)throw new Error("url is required");V(),H(Fe),await new Promise(Q=>setTimeout(Q,150));const Me=await je(25e3);let Ae="";try{Ae=F.getTitle()||""}catch{Ae=""}return{url:wr(Fe),title:Ae,opened:!0,settled:Me,viewport:xo(O.current)}}await je();const oe=Fe=>typeof Fe=="string"&&Fe?Fe:void 0,pe=(()=>{switch(Y){case"browser.snapshot":return qw({selector:oe(U.selector)});case"browser.click":return Yw({selector:oe(U.selector),text:oe(U.text)});case"browser.type":return Qw({selector:String(U.selector??""),value:String(U.value??""),submit:U.submit===!0});case"browser.inspect":return Zw({selector:String(U.selector??"")});case"browser.scroll":return Xw({selector:oe(U.selector),direction:oe(U.direction)});default:return null}})();if(!pe)throw new Error(`Unsupported browser action: ${Y}`);const le=await F.executeJavaScript(pe,!0);if(!le||typeof le!="object")throw new Error("The page returned no result");const _e=le;if(_e.ok!==!0)throw new Error(typeof _e.error=="string"&&_e.error?_e.error:"Browser action failed");if(Y==="browser.snapshot"){const Fe=B.current;return{..._e,viewport:xo(O.current),...Fe.length>0?{consoleProblems:[...Fe]}:{}}}return(Y==="browser.click"||Y==="browser.type"&&U.submit===!0)&&(await new Promise(Fe=>setTimeout(Fe,150)),await je()),le},[J,e,H,n,je]);c.useEffect(()=>Ew({run:G}),[G]),c.useEffect(()=>{const Y=J;return()=>{Eo(Y)}},[J]),c.useEffect(()=>{if(!l)return;const Y=F=>{const V=F;if(typeof V.level!="number"||V.level<2)return;const oe=V.sourceId?`${V.sourceId}${V.line?`:${V.line}`:""}`:"";B.current.push({level:V.level>=3?"error":"warning",message:String(V.message??"").slice(0,400),source:oe}),B.current.length>Tc&&B.current.splice(0,B.current.length-Tc)},U=()=>{B.current=[]};return l.addEventListener("console-message",Y),l.addEventListener("did-start-loading",U),()=>{l.removeEventListener("console-message",Y),l.removeEventListener("did-start-loading",U)}},[l]);const we=c.useRef(new Set),Te=c.useCallback(Y=>{we.current.clear(),H(Y)},[H]);c.useEffect(()=>{if(!l)return;const Y=F=>{const V=gr(F),oe=typeof V.url=="string"?V.url:"";!oe||!Nc(oe)||(F.preventDefault(),H(oe))},U=F=>{const V=gr(F);if(V.isMainFrame===!1||V.errorCode===-3)return;const oe=typeof V.validatedURL=="string"?V.validatedURL:"";!oe||!Nc(oe)||we.current.has(oe)||(we.current.add(oe),H(oe))};return l.addEventListener("will-navigate",Y),l.addEventListener("did-fail-load",U),()=>{l.removeEventListener("will-navigate",Y),l.removeEventListener("did-fail-load",U)}},[H,l]),c.useEffect(()=>{if(!l)return;const Y=U=>{const F=U.detail;U.preventDefault(),F?.url&&H(F.url)};return l.addEventListener("new-window",Y),()=>l.removeEventListener("new-window",Y)},[H,l]);const he=c.useCallback(Y=>{const U=Math.min(Tv,Math.max(Iv,Y));C.current=U,S(U);try{o.current?.setZoomLevel(U)}catch{}},[]);c.useEffect(()=>{const Y=U=>{if(!(U instanceof CustomEvent))return;const F=U.detail,V=o.current;!V||document.activeElement!==V||(F==="zoom-in"?he(C.current+yo):F==="zoom-out"?he(C.current-yo):F==="zoom-reset"&&he(0))};return window.addEventListener("openchamber:zoom",Y),()=>window.removeEventListener("openchamber:zoom",Y)},[he]);const re=c.useCallback(Y=>{br("desktop_browser_clear_data",{partition:Ev,cookies:Y==="cookies",cache:Y==="cache"}).then(()=>{Ke.success(r(Y==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Ke.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const Y=$.current;if(!Y||typeof ResizeObserver>"u")return;const U=new ResizeObserver(F=>{const V=F[0]?.contentRect;V&&W({width:V.width,height:V.height})});return U.observe(Y),()=>U.disconnect()},[]);const ge=c.useCallback(Y=>{M(Y);const U=o.current;if(!U)return;let F=-1;try{F=U.getWebContentsId()}catch{return}br("desktop_browser_set_color_scheme",{webContentsId:F,scheme:Y}).catch(V=>{M("system"),Ke.error(V instanceof Error?V.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),q=c.useCallback(()=>{try{ie?o.current?.stop():o.current?.reload()}catch{}},[ie]),z=Z.status;c.useEffect(()=>{const Y=()=>{j(!0);const V=setTimeout(()=>{try{o.current?.reload()}catch{}},Rv);return()=>clearTimeout(V)};if(z.kind==="failed"){if(!rw(z.code,z.url)){j(!1);return}const V=Date.now(),oe=P.current?.url===z.url?P.current:{url:z.url,startedAt:V};if(P.current=oe,V-oe.startedAt>Dv){j(!1);return}return Y()}if(z.kind==="loading")return;if(P.current=null,z.kind!=="ready"||!z.url||!Nr(z.url)){D.current=!0,j(!1);return}if(D.current||Date.now()-I.current>Mv){D.current=!0,j(!1);return}let U=!1,F=null;return aw(Rr(z.url)).then(V=>{if(!U){if(V===null||V<500){D.current=!0,j(!1);return}F=Y()}}),()=>{U=!0,F?.()}},[z]);const ee=Z.status.kind==="failed"&&!g?Z.status:null,de=nv(R,L);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Rf,{address:x,onAddressChange:k,onSubmit:Te,suggestions:ke,onForgetSuggestion:Y=>fe(e,Y),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:q,onOpenExternal:()=>{eo(Z.url||x)},canGoBack:Z.canGoBack,canGoForward:Z.canGoForward,isLoading:ie,onAnnotate:ce,isAnnotating:w,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>he(b+yo),onZoomOut:()=>he(b-yo),onZoomReset:()=>he(0),zoomPercent:Math.round(Math.pow(1.2,b)*100),onClearCookies:()=>re("cookies"),onClearCache:()=>re("cache"),onToggleDeviceBar:()=>E(Y=>!Y),isDeviceBarOpen:v}),v?s.jsx(iv,{viewport:R,onViewportChange:A,colorScheme:T,onColorSchemeChange:ge,scale:de?.scale??1}):null,s.jsxs("div",{ref:$,className:Ee("relative min-h-0 flex-1 bg-background",de&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:d,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:de?{width:`${de.width}px`,height:`${de.height}px`,transform:`scale(${de.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!f&&!Z.url&&!ie?s.jsx(Bf,{onOpen:Te,directory:e}):null,g?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,ne?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:ne})})]}):null,ee&&!ne?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:ee.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ee.crashed?r("contextPanel.browser.crashedHint"):ee.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ie?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]})]})},Bv=t=>{const e=tt.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=Nt(),l=Ne(_v);let a;e[0]!==n?(a=wr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==tn?d:"",[m,f]=c.useState(u),[p,y]=c.useState(u);let x;e[2]!==u?(x=u?[u]:[],e[2]=u,e[3]=x):x=e[3];const[k,w]=c.useState(x),[h,g]=c.useState(u?0:-1),[j,b]=c.useReducer(Lv,0);let S;e[4]!==r||e[5]!==l||e[6]!==i?(S=xe=>{!xe||xe===tn||!r||!i||l(r,i,xe)},e[4]=r,e[5]=l,e[6]=i,e[7]=S):S=e[7];const C=S;let v;e[8]!==r?(v=Df(r),e[8]=r,e[9]=v):v=e[9];const E=Sr(v),R=Sr($v),A=Sr(zv);let O;e[10]!==m||e[11]!==E?(O=Pf(E,m),e[10]=m,e[11]=E,e[12]=O):O=e[12];const B=O;let T;e[13]!==r||e[14]!==h||e[15]!==C||e[16]!==R?(T=xe=>{const ie=wr(xe);ie!==tn&&(f(ie),y(ie),C(ie),R(r,{url:ie}),w(Re=>{const be=h>=0?Re.slice(0,h+1):[];return be[be.length-1]===ie?(g(be.length-1),be):(g(be.length),[...be,ie])}))},e[13]=r,e[14]=h,e[15]=C,e[16]=R,e[17]=T):T=e[17];const M=T;let L;e[18]!==k||e[19]!==C?(L=xe=>{const ie=k[xe];ie&&(g(xe),f(ie),y(ie),C(ie))},e[18]=k,e[19]=C,e[20]=L):L=e[20];const W=L;let $;e[21]!==r||e[22]!==A?($=xe=>A(r,xe),e[21]=r,e[22]=A,e[23]=$):$=e[23];let P,D;e[24]!==W||e[25]!==h?(D=()=>W(h-1),P=()=>W(h+1),e[24]=W,e[25]=h,e[26]=P,e[27]=D):(P=e[26],D=e[27]);let I;e[28]!==m||e[29]!==p?(I=()=>{eo(p||m)},e[28]=m,e[29]=p,e[30]=I):I=e[30];const X=h>0,Z=h>=0&&h<k.length-1;let ne;e[31]!==m||e[32]!==M||e[33]!==B||e[34]!==P||e[35]!==I||e[36]!==X||e[37]!==Z||e[38]!==$||e[39]!==D?(ne=s.jsx(Rf,{address:m,onAddressChange:f,onSubmit:M,suggestions:B,onForgetSuggestion:$,onBack:D,onForward:P,onReload:b,onOpenExternal:I,canGoBack:X,canGoForward:Z,isLoading:!1}),e[31]=m,e[32]=M,e[33]=B,e[34]=P,e[35]=I,e[36]=X,e[37]=Z,e[38]=$,e[39]=D,e[40]=ne):ne=e[40];let ue;e[41]!==p||e[42]!==M||e[43]!==j||e[44]!==o?(ue=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}|${j}`):s.jsx(Bf,{onOpen:M})}),e[41]=p,e[42]=M,e[43]=j,e[44]=o,e[45]=ue):ue=e[45];let se;return e[46]!==ne||e[47]!==ue?(se=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[ne,ue]}),e[46]=ne,e[47]=ue,e[48]=se):se=e[48],se},Fv=t=>{const e=tt.c(3),[n]=c.useState(Pv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Ov,{...t}):s.jsx(Bv,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function _v(t){return t.setContextPanelTabTargetPath}function Lv(t){return t+1}function $v(t){return t.recordVisit}function zv(t){return t.forget}const Wv=Kn(()=>yn(()=>import("./WalkthroughView-lap5btCF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.WalkthroughView}))),Kv=Kn(()=>yn(()=>import("./DiffView-CjxUovbM.js"),__vite__mapDeps([128,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,115,116,129,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.DiffView}))),Vv=Kn(()=>yn(()=>import("./FilesView-DFWD0RQR.js"),__vite__mapDeps([130,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,131,132,133,134,135,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,136,137,120,121,118,125,138,119,139])).then(t=>({default:t.FilesView}))),Uv=Kn(()=>yn(()=>import("./GitView-BWa7e5vw.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,84,85,86,141,117,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,87,115,116,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),Hv=Kn(()=>yn(()=>import("./LinearIssuesView-C6dpIdjw.js"),__vite__mapDeps([142,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}))),Gv=Kn(()=>yn(()=>import("./PlanView-BCk_VobP.js"),__vite__mapDeps([143,1,2,4,5,6,7,8,9,131,57,58,59,60,61,62,79,55,56,63,132,133,134,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,119,139,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Ec=c.lazy(()=>yn(()=>import("./PluginPane-BPP1dbck.js").then(t=>t.l),__vite__mapDeps([86,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.PluginPane}))),_i={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-r border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-l border-border",vertical:!1}},Rc=c.lazy(()=>yn(()=>import("./GuestSurfacePane-DDfzid3U.js"),__vite__mapDeps([144,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,86])).then(t=>({default:t.GuestSurfacePane}))),Ff=320,al=600,qv=400,Yv=100,Qv=24,Go=new Map,Xv=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},Mc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Ff,Math.round(t))):al,Oc=t=>{const e=t??(typeof window<"u"?window.innerWidth:al*2);return Math.max(Ff,e-qv)},Jv=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Zv=(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},_f=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):tr(t)?_a.getState().guests.find(r=>r.id===Fo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),eS=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},tS=(t,e,n)=>{if(t.mode==="chat"){const r=ja(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"?ol(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?eS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):_f(t.mode,n)},sS=t=>{const e=tt.c(8),{mode:n}=t,r=Va();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=m=>m.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??Gp,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(to,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Bc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Ka,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(ff,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(_,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(_,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(_,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(_,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(_,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(_,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(_,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(_,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(_,{name:"chat-4",className:"h-3.5 w-3.5"});if(tr(t.mode))return s.jsx(sS,{mode:t.mode});if(t.mode==="browser"){const n=nS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(_,{name:"global",className:"h-3.5 w-3.5"})}},nS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},rS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=Nt(),i=Ne(g=>g.contextEditorTreeWidth),o=Ne(g=>g.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),y=c.useCallback(g=>{const j=p.current;j&&(j.style.width=`${g}px`,j.style.setProperty("--oc-editor-tree-width",`${g}px`))},[]),x=g=>{if(t){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{}f.current=g.pointerId,a(!0),d.current=g.clientX,u.current=i,m.current=i,g.preventDefault()}},k=g=>{if(!l||f.current!==g.pointerId)return;const j=d.current-g.clientX,b=Ui(u.current+j);m.current!==b&&(m.current=b,y(b))},w=g=>{if(f.current!==g.pointerId)return;try{g.currentTarget.releasePointerCapture(g.pointerId)}catch{}const j=Ui(m.current??i);f.current=null,m.current=null,a(!1),o(j)},h=t?i:0;return s.jsxs("div",{ref:p,className:Ee("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?m.current??h:h}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?m.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Ee("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:x,onPointerMove:k,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Ee("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(k1,{visible:t&&e})})]})},ja=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,oS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},iS=(t,e)=>{if(e.length===0)return Go;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?Go:r},aS=(t,e)=>{const n=Hp(t),r=c.useRef(Go),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=iS(n.getState().session,i.current);return oS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Go)},lS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,cS=()=>{const{t}=Nt(),e=dr()??"",n=c.useMemo(()=>Xv(e),[e]),r=Ne(K=>n?K.contextPanelByDirectory[n]:void 0),i=Ne(K=>K.closeContextPanel),o=Ne(K=>K.closeContextPanelTab),l=Ne(K=>K.openContextPanelTab),a=Ne(K=>K.toggleContextPanelExpanded),d=Ne(K=>K.setContextPanelWidth),u=Ne(K=>K.setActiveContextPanelTab),m=Ne(K=>K.openContextBrowser);c.useEffect(()=>{if(e)return Rw(K=>m(e,K,{reveal:!1}))},[e,m]);const f=Ne(K=>K.openContextFile);c.useEffect(()=>Wn(K=>{if(K.type!=="file-open-request")return;const Se=K.directory??e;Se&&f(Se,K.path)}),[e,f]);const p=Ne(K=>K.reorderContextPanelTabs),y=pn(K=>K.setSelectedPath),x=Ne(K=>K.contextEditorTreeVisible),k=Ne(K=>K.contextEditorTreeWidth),w=Ne(K=>K.setContextEditorTreeWidth),h=Ne(K=>K.toggleContextEditorTree),g=Ne(K=>K.contextEditorVisible),j=Ne(K=>K.toggleContextEditor),b=Ne(K=>K.openNewContextBrowserTab),S=Sf(K=>K.byOrigin),C=Ne(K=>K.allowPromptingSubagentSessions),{themeMode:v,setThemeMode:E,lightThemeId:R,darkThemeId:A,currentTheme:O}=Ln(),B=c.useMemo(()=>r?.tabs??[],[r?.tabs]),T=B.find(K=>K.id===r?.activeTabId)??B[B.length-1]??null,M=!!(r?.isOpen&&T),[L,W]=c.useState(null),$=c.useMemo(()=>B.some(K=>K.mode==="file"&&K.targetPath),[B]),P=$&&(g||!x),D=T?.mode??null,I=D==="file"&&!P,X=!!(M&&r?.expanded&&!I),Z=D?r?.widthByMode?.[D]:void 0,ne=D?r?.widthFractionByMode?.[D]:void 0,ue=D?zp(D):.5,se=L??(typeof window<"u"?window.innerWidth:al*2),xe=ne!=null&&L!=null?Math.round(ne*L):Z,ie=I?k:Mc(xe??Math.round(ue*se),Oc(L??se));c.useEffect(()=>{!n||!D||I||ne!=null||Z==null||L==null||d(n,D,Z,L)},[D,L,n,I,Z,ne,d]);const Re=c.useMemo(()=>{const K=[];for(const Se of B){if(Se.mode!=="chat")continue;const Ve=ja(Se.dedupeKey);Ve&&!K.includes(Ve)&&K.push(Ve)}return K},[B]),be=aS(n||void 0,Re),[fe,ke]=c.useState(!1),H=c.useRef(0),J=c.useRef(ie),ce=c.useRef(null),je=c.useRef(null),G=c.useRef(null),we=c.useRef(new Map),Te=c.useRef(new Map),he=c.useRef(!1);c.useLayoutEffect(()=>{const K=G.current?.parentElement;if(!K||typeof ResizeObserver>"u")return;const Se=new ResizeObserver(()=>{W(K.clientWidth||null)});return Se.observe(K),W(K.clientWidth||null),()=>Se.disconnect()},[]),c.useEffect(()=>{if(!M||he.current){he.current=M;return}const K=window.requestAnimationFrame(()=>{G.current?.focus({preventScroll:!0})});return he.current=!0,()=>window.cancelAnimationFrame(K)},[M]);const re=c.useRef(null),ge=c.useRef(null),q=c.useCallback(()=>{ge.current=null;const K=G.current,Se=ce.current;!K||Se===null||K.style.setProperty("--oc-context-panel-width",`${Se}px`)},[]);c.useEffect(()=>()=>{ge.current!==null&&clearTimeout(ge.current)},[]);const z=c.useCallback(K=>{const Se=re.current,Ve=I?Ui(K):Mc(K,Oc(Se));return Se===null?Ve:Math.min(Ve,Math.max(1,Se))},[I]),ee=c.useCallback(K=>{!M||X||!n||(je.current=K.pointerId,ke(!0),H.current=K.clientX,J.current=ie,ce.current=ie,re.current=Jv(G.current),document.documentElement.style.cursor="col-resize",K.preventDefault())},[n,X,M,ie]),de=c.useCallback(()=>{const K=z(ce.current??ie),Se=re.current;ce.current=null,re.current=null,ge.current!==null&&(clearTimeout(ge.current),ge.current=null),document.documentElement.style.cursor="",I?w(K):n&&D&&d(n,D,K,Se??void 0),ke(!1),je.current=null},[D,z,n,I,w,d,ie]);c.useEffect(()=>{if(!fe)return;const K=Xe=>{if(je.current!==Xe.pointerId)return;const nt=H.current-Xe.clientX,Ze=z(J.current+nt);ce.current!==Ze&&(ce.current=Ze,ge.current===null&&(ge.current=setTimeout(q,Yv)))},Se=Xe=>{je.current===Xe.pointerId&&de()},Ve=()=>{de()};return window.addEventListener("pointermove",K),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se),window.addEventListener("blur",Ve),()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se),window.removeEventListener("blur",Ve)}},[q,z,de,fe]),c.useEffect(()=>{fe||(ce.current=null,document.documentElement.style.cursor="")},[fe]);const Y=c.useCallback(()=>{n&&i(n)},[i,n]),U=c.useCallback(()=>{n&&a(n)},[n,a]),F=c.useCallback(K=>{K.key==="Escape"&&(K.target instanceof Node&&!K.currentTarget.contains(K.target)||Wp(K.target)||Kp(K.target)||(K.preventDefault(),K.stopPropagation(),Y()))},[Y]);c.useEffect(()=>{if(!(!n||!T)&&T.mode==="file"&&T.targetPath){y(n,T.targetPath,{allowOutsideRoot:!0});return}},[T,n,y]);const V=c.useMemo(()=>B.filter(K=>K.mode==="chat"),[B]),oe=M&&T?.mode==="chat"?T.id:null,ae=M&&T?.mode==="chat"?ja(T.dedupeKey):null,pe=sb(V,oe);c.useEffect(()=>{if(!M||!n||!ae||typeof window>"u")return;const K=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Ai(n,ae,!1);return}Au(ae),Ai(n,ae,!0)};K();const Se=window.setInterval(K,1e4);return window.addEventListener("focus",K),window.addEventListener("blur",K),document.addEventListener("visibilitychange",K),()=>{window.clearInterval(Se),window.removeEventListener("focus",K),window.removeEventListener("blur",K),document.removeEventListener("visibilitychange",K),Ai(n,ae,!1)}},[ae,n,M]);const le=c.useCallback((K,Se,Ve)=>nb(Te.current,K,Se,n||null,Ve,{mode:v,lightThemeId:R,darkThemeId:A,currentTheme:O},{allowPromptingSubagentSessions:C}),[C,O,A,n,R,v]),_e=pe&&ae?le(pe.id,ae,pe.readOnly):null;c.useEffect(()=>{const K=new Set(B.map(Se=>Se.id));for(const Se of Te.current.keys())K.has(Se)||Te.current.delete(Se)},[B]);const Fe=c.useCallback(K=>{!n||T?.mode!=="diff"||l(n,{mode:"diff",targetPath:T.targetPath,stagedDiff:K==="staged",diffScope:K})},[T,n,l]),Me=c.useCallback(()=>{if(typeof window>"u")return;const K={themeMode:v,lightThemeId:R,darkThemeId:A,currentTheme:O};for(const Se of we.current.values()){const Ve=Se.contentWindow;Ve&&Ve.postMessage({type:"openchamber:theme-sync",payload:K},window.location.origin)}},[O,A,R,v]),Ae=c.useCallback(()=>{if(typeof window>"u")return;const K={allowPromptingSubagentSessions:C};for(const Se of we.current.values()){const Ve=Se.contentWindow;Ve&&Ve.postMessage({type:"openchamber:chat-settings-sync",payload:K},window.location.origin)}},[C]),Q=c.useCallback((K,Se,Ve)=>{const Xe=Se.contentWindow;Xe&&Xe.postMessage({type:sf,payload:{visible:oe===K}},Ve)},[oe]),Ce=c.useCallback(()=>{if(!(typeof window>"u"))for(const[K,Se]of we.current.entries())Q(K,Se,window.location.origin)},[Q]);c.useEffect(()=>{if(typeof window>"u")return;const K=Se=>{if(Se.origin!==window.location.origin)return;const Ve=Array.from(we.current.entries()).find(([,We])=>We.contentWindow===Se.source);if(!Ve)return;const Xe=Se.data;if(Xe?.type===rb){const[We,Et]=Ve;Q(We,Et,Se.origin);return}if(Xe?.type===ob){if(typeof Xe.requestId!="string"||!Xe.requestId)return;const We=Qt(),Et={apiBaseUrl:Dn(),clientToken:Yr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:$d(),relayHostId:We.startsWith("host:")?We.slice(5):"",relay:Xm()??void 0};Se.source?.postMessage({type:ib,requestId:Xe.requestId,payload:Et},Se.origin);return}if(Xe?.type==="openchamber:theme-sync-request"){Me();return}if(Xe?.type==="openchamber:chat-settings-request"){Ae();return}if(Xe?.type!=="openchamber:cycle-theme-request")return;const nt=["light","dark","system"],gt=(nt.indexOf(v)+1)%nt.length;E(nt[gt])};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[Ae,Q,Me,E,v]),c.useLayoutEffect(()=>{B.some(Se=>Se.mode==="chat")&&(Me(),Ae(),Ce())},[A,R,Ae,Ce,Me,B,v]);const Be=T?.mode==="file"||T?.mode==="chat"||T?.mode==="browser",Le=c.useMemo(()=>T?B.filter(K=>K.mode===T.mode):[],[T,B]),Je=c.useMemo(()=>Le.map(K=>{const Se=tS(K,be,t),Ve=lS(Se,Qv),Xe=Zv(K.targetPath,e);return{id:K.id,label:Ve,icon:Bc(K,S),title:Xe?`${Se}: ${Xe}`:Se,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ve})}}),[Le,e,S,be,t]),ot=T?.mode==="context"?s.jsx(K1,{}):T?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Uv,{isActive:M})}):T?.mode==="pr"?s.jsx(Xy,{}):T?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Hv,{})}):T?.mode==="notes"?s.jsx(jh,{}):T?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Gv,{targetPath:T.targetPath,savedProjectPlan:T.projectPlanId&&T.projectPlanRef?{projectRef:T.projectPlanRef,planId:T.projectPlanId}:null})}):null,et=c.useMemo(()=>B.filter(K=>K.mode==="browser"),[B]),it=c.useMemo(()=>B.filter(K=>K.mode==="diff"),[B]),ht=c.useMemo(()=>B.find(K=>K.mode==="terminal")??null,[B]),st=c.useMemo(()=>B.some(K=>K.mode==="walkthrough"),[B]),mt=c.useMemo(()=>B.filter(K=>tr(K.mode)),[B]),kt=_a(K=>K.guests),Pe=c.useMemo(()=>new Set(kt.filter(Vp).map(K=>K.id)),[kt]),Ge=c.useMemo(()=>{const K=new Map;for(const Se of kt){const Ve=Up(Se);Ve&&K.set(Se.id,Ve)}return K},[kt]),at=c.useMemo(()=>B.some(K=>K.mode==="file"),[B]),ze=T?.mode==="file",ft=Ne(K=>K.closeContextPanelTabs),te=c.useCallback(K=>{if(!n)return null;const{id:Se,index:Ve,allIds:Xe,close:nt}=K,Ze=()=>ft(n,Xe.filter(At=>At!==Se)),gt=()=>ft(n,Xe.slice(0,Ve)),We=()=>ft(n,Xe.slice(Ve+1)),Et=()=>ft(n,Xe),Ft=Xe.length>1,Ie=Ve===0,yt=Ve===Xe.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Xn,{onClick:nt,children:[s.jsx(_,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Yi,{}),s.jsxs(Xn,{onClick:Ze,disabled:!Ft,children:[s.jsx(_,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Xn,{onClick:gt,disabled:Ie,children:[s.jsx(_,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Xn,{onClick:We,disabled:yt,children:[s.jsx(_,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Yi,{}),s.jsxs(Xn,{onClick:Et,disabled:!Ft,children:[s.jsx(_,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[ft,n,t]),me=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Be?s.jsx(Hd,{items:Je,activeId:T?.id??null,onSelect:K=>{n&&u(n,K)},onClose:K=>{n&&o(n,K)},onReorder:(K,Se)=>{n&&p(n,K,Se)},layoutMode:"scrollable",variant:"default",tabContextMenu:te}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[T?Bc(T,S):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:T?_f(T.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[T?.mode==="browser"?s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&b(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(_,{name:"add",className:"h-3.5 w-3.5"})}):null,ze&&$?s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:j,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":P,children:s.jsx(_,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,ze?s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":x,children:s.jsx(_,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,I?null:s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:U,className:"h-7 w-7 p-0",title:t(X?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(X?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:X?s.jsx(_,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:Y,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]})]}),De=M?X?{"--oc-context-panel-width":L!==null?`${L}px`:"100%",width:L!==null?`${L}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${ie}px`}:{"--oc-context-panel-width":`${ie}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:G,"data-context-panel":"true",tabIndex:-1,inert:!M||void 0,className:Ee("flex min-h-0 flex-col overflow-hidden bg-background",X?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!M&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:F,style:De,children:[M&&!X&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),M&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!X&&s.jsx("div",{className:Ee("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",fe&&"bg-[var(--interactive-border)]"),onPointerDown:ee,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Ee("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]",!M&&"pointer-events-none select-none opacity-0"),style:{width:X?L!==null?`${L}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!M,children:[me,s.jsxs("div",{className:Ee("relative min-h-0 flex-1 overflow-hidden",fe&&"pointer-events-none"),children:[at?s.jsxs("div",{className:Ee("absolute inset-0 flex",ze?"flex":"hidden"),children:[$||!x?s.jsx("div",{className:Ee("h-full min-w-0 flex-1",$&&!P&&"hidden"),children:$?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Vv,{mode:"editor-only",visible:M&&ze&&P})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(_,{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")})]})}):null,s.jsx(rS,{visible:x,active:M&&ze,fill:!P})]}):null,pe&&ae&&_e?s.jsx("iframe",{ref:K=>{if(!K){we.current.delete(pe.id);return}we.current.set(pe.id,K)},src:_e,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ae}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Me(),Ae(),Ce()}},pe.id):null,et.map(K=>s.jsx("div",{className:Ee("absolute inset-0",T?.id!==K.id&&"invisible pointer-events-none"),"aria-hidden":T?.id!==K.id||void 0,children:s.jsx(Fv,{initialUrl:K.targetPath??"",directory:n,tabID:K.id})},K.id)),it.map(K=>s.jsx("div",{className:Ee("absolute inset-0",T?.id!==K.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Kv,{visible:M&&T?.id===K.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:K.diffScope??(K.stagedDiff?"staged":"working"),onDiffScopeChange:Fe,targetFilePath:K.targetPath,flushContent:!0})})},K.id)),ht?s.jsx("div",{className:Ee("absolute inset-0",T?.mode==="terminal"?"block":"hidden"),children:s.jsx(kh,{visible:M&&T?.mode==="terminal",directory:ht.targetDirectory})}):null,st?s.jsx("div",{className:Ee("absolute inset-0",T?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Wv,{directory:e,visible:M&&T?.mode==="walkthrough"})})}):null,mt.map(K=>{if(!tr(K.mode))return null;const Se=Fo(K.mode),Ve=Pe.has(Se),Xe=Ge.get(Se),nt=T?.id===K.id,Ze=nt&&M;return Ve&&!Xe&&!Ze?null:s.jsx("div",{className:Ee("absolute inset-0",nt?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ve?Xe?s.jsxs("div",{className:Ee("flex h-full",_i[Xe.dock].container),children:[s.jsx("div",{className:Ee("shrink-0",_i[Xe.dock].page),style:_i[Xe.dock].vertical?{height:Xe.size}:{width:Xe.size},children:s.jsx(Ec,{mode:K.mode})}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ze?s.jsx(Rc,{mode:K.mode}):null})]}):s.jsx(Rc,{mode:K.mode}):s.jsx(Ec,{mode:K.mode})})},K.id)}),T?.mode!=="chat"&&!ze&&T?.mode!=="browser"&&T?.mode!=="diff"&&T?.mode!=="terminal"&&T?.mode!=="walkthrough"&&!(T&&tr(T.mode))?ot:null]})]})]})},dS=t=>{const e=tt.c(43),{open:n,onOpenChange:r}=t,{t:i}=Nt(),o=Ne(uS),l=Ne(fS),a=Ne(mS),d=Ne(hS),u=Va();let m;e[0]!==o||e[1]!==u?(m=Pu(o,u),e[0]=o,e[1]=u,e[2]=m):m=e[2];const f=m,p=l.length===0;let y;if(e[3]!==l||e[4]!==f){let R;e[6]!==l?(R=A=>l.includes(A.id),e[6]=l,e[7]=R):R=e[7],y=f.every(R),e[3]=l,e[4]=f,e[5]=y}else y=e[5];const x=y;let k;e[8]!==i?(k=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=k):k=e[9];let w;e[10]!==k?(w=s.jsx(Us,{children:k}),e[10]=k,e[11]=w):w=e[11];let h;e[12]!==i?(h=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=h):h=e[13];let g;e[14]!==h?(g=s.jsx(Hs,{children:h}),e[14]=h,e[15]=g):g=e[15];let j;e[16]!==w||e[17]!==g?(j=s.jsxs(sn,{children:[w,g]}),e[16]=w,e[17]=g,e[18]=j):j=e[18];let b;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let R;e[24]!==l||e[25]!==a||e[26]!==i?(R=A=>s.jsx(qp,{settingsItem:`layout.context-rail.surface.${A.id}`,checked:!l.includes(A.id),onChange:O=>a(A.id,O),label:A.label??i(A.labelKey),ariaLabel:A.label??i(A.labelKey)},A.id),e[24]=l,e[25]=a,e[26]=i,e[27]=R):R=e[27],b=f.map(R),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=b}else b=e[23];let S;e[28]!==b?(S=s.jsx("div",{className:"flex flex-col",children:b}),e[28]=b,e[29]=S):S=e[29];let C;e[30]!==p||e[31]!==x||e[32]!==d||e[33]!==i?(C=p?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[x?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ct,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=p,e[31]=x,e[32]=d,e[33]=i,e[34]=C):C=e[34];let v;e[35]!==C||e[36]!==j||e[37]!==S?(v=s.jsxs(Ds,{className:"max-w-md",children:[j,S,C]}),e[35]=C,e[36]=j,e[37]=S,e[38]=v):v=e[38];let E;return e[39]!==r||e[40]!==n||e[41]!==v?(E=s.jsx(Ps,{open:n,onOpenChange:r,children:v}),e[39]=r,e[40]=n,e[41]=v,e[42]=E):E=e[42],E};function uS(t){return t.contextRailOrder}function fS(t){return t.contextRailHiddenSurfaces}function mS(t){return t.setContextRailSurfaceVisible}function hS(t){return t.setContextRailHiddenSurfaces}const Lf=150,pS=500,gS=[],xS=t=>t>99?"99+":String(t),bS=t=>{const e=tt.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:m,showOrderNumber:f,onSelect:p}=t;let y;e[0]!==n.id?(y={id:n.id},e[0]=n.id,e[1]=y):y=e[1];const{attributes:x,listeners:k,setNodeRef:w,transform:h,transition:g,isDragging:j}=mi(y);let b;e[2]!==a?(b=a!=null&&a>0?xS(a):null,e[2]=a,e[3]=b):b=e[3];const S=b;let C;e[4]!==h?(C=hi.Translate.toString(h),e[4]=h,e[5]=C):C=e[5];let v;e[6]!==C||e[7]!==g?(v={transform:C,transition:g},e[6]=C,e[7]=g,e[8]=v):v=e[8];const E=j&&"z-10 opacity-70";let R;e[9]!==E?(R=Ee("relative",E),e[9]=E,e[10]=R):R=e[10];let A;e[11]!==p||e[12]!==n?(A=()=>p(n),e[11]=p,e[12]=n,e[13]=A):A=e[13];const O=d??o,B=r?"text-primary":"text-muted-foreground hover:text-foreground";let T;e[14]!==B?(T=Ee("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",B),e[14]=B,e[15]=T):T=e[15];let M;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?(M=n.id==="diff"?s.jsx(ff,{className:"h-[18px] w-[18px]"}):s.jsx(to,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=M):M=e[19];let L;e[20]!==S||e[21]!==m||e[22]!==i||e[23]!==f?(L=f&&m!=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:m===10?"0":m}):S?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:S}):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[20]=S,e[21]=m,e[22]=i,e[23]=f,e[24]=L):L=e[24];let W;e[25]!==x||e[26]!==r||e[27]!==k||e[28]!==T||e[29]!==M||e[30]!==L||e[31]!==A||e[32]!==O?(W=s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",...x,...k,onClick:A,"aria-label":O,"aria-pressed":r,className:T,children:[M,L]})}),e[25]=x,e[26]=r,e[27]=k,e[28]=T,e[29]=M,e[30]=L,e[31]=A,e[32]=O,e[33]=W):W=e[33];let $;e[34]!==o?($=s.jsx("span",{children:o}),e[34]=o,e[35]=$):$=e[35];let P;e[36]!==l?(P=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=P):P=e[37];let D;e[38]!==u?(D=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=D):D=e[39];let I;e[40]!==$||e[41]!==P||e[42]!==D?(I=s.jsx(jt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[$,P,D]})}),e[40]=$,e[41]=P,e[42]=D,e[43]=I):I=e[43];let X;e[44]!==W||e[45]!==I?(X=s.jsxs(vt,{delayDuration:Lf,children:[W,I]}),e[44]=W,e[45]=I,e[46]=X):X=e[46];let Z;return e[47]!==w||e[48]!==X||e[49]!==v||e[50]!==R?(Z=s.jsx("div",{ref:w,style:v,className:R,children:X}),e[47]=w,e[48]=X,e[49]=v,e[50]=R,e[51]=Z):Z=e[51],Z},yS=()=>{const t=tt.c(92),{t:e}=Nt(),n=dr();let r;t[0]!==n?(r=n?Qn(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=Y=>i?Y.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Ne(o),a=Ne(wS),d=Ne(vS),u=Ne(SS),m=Ne(jS),f=Ne(kS),p=Ne(CS),y=Ne(NS),x=La(AS),k=ta(PS),w=ta(DS),h=In(IS),g=In(TS),{screenWidth:j}=$n(),b=$a(i||null);let S;t[4]!==y?(S=sa("switch_context_surface",y),t[4]=y,t[5]=S):S=t[5];const C=S,[v,E]=c.useState(!1);let R,A;t[6]!==C?(R=()=>{const Y=new Set;let U=null,F=!1;const V=ES,oe=()=>{Rl(C,Y)?!F&&U===null&&(U=setTimeout(()=>E(!0),pS)):(F=!1,U!==null&&(clearTimeout(U),U=null),E(!1))},ae=_e=>{if(Y.add(_e.key.toLowerCase()),V(_e.key)&&Rl(C,Y)){F=!0,U!==null&&(clearTimeout(U),U=null),E(!1);return}oe()},pe=_e=>{Y.delete(_e.key.toLowerCase()),oe()},le=()=>{Y.clear(),F=!1,U!==null&&(clearTimeout(U),U=null),E(!1)};return window.addEventListener("keydown",ae,!0),window.addEventListener("keyup",pe,!0),window.addEventListener("blur",le),()=>{window.removeEventListener("keydown",ae,!0),window.removeEventListener("keyup",pe,!0),window.removeEventListener("blur",le),U!==null&&clearTimeout(U)}},A=[C],t[6]=C,t[7]=R,t[8]=A):(R=t[7],A=t[8]),c.useEffect(R,A);let O;t[9]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{distance:8}},t[9]=O):O=t[9];let B;t[10]===Symbol.for("react.memo_cache_sentinel")?(B={activationConstraint:{delay:200,tolerance:6}},t[10]=B):B=t[10];const T=li(Pn(di,O),Pn(ci,B)),M=Va(),L=El(RS),W=El(MS),$=l?.tabs??gS;let P;t[11]!==l?.activeTabId||t[12]!==$?(P=$.find(Y=>Y.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=$,t[13]=P):P=t[13];const D=P,I=l?.isOpen?D?.mode??null:null,X=b?.files.length??0;let Z;t[14]!==u||t[15]!==d||t[16]!==g||t[17]!==M||t[18]!==w||t[19]!==x||t[20]!==j||t[21]!==$?(Z=Yp({railOrder:d,hiddenSurfaces:u,planModeEnabled:x,isVSCode:_n(),screenWidth:j,tabs:$,linearConnected:w,githubConnected:g,extras:M}),t[14]=u,t[15]=d,t[16]=g,t[17]=M,t[18]=w,t[19]=x,t[20]=j,t[21]=$,t[22]=Z):Z=t[22];const ne=Z;let ue,se;t[23]!==I||t[24]!==p||t[25]!==i||t[26]!==k||t[27]!==w?(se=()=>{!i||!k||w||I!=="linear"||p(i)},ue=[I,p,i,k,w],t[23]=I,t[24]=p,t[25]=i,t[26]=k,t[27]=w,t[28]=ue,t[29]=se):(ue=t[28],se=t[29]),c.useEffect(se,ue);let xe,ie;t[30]!==I||t[31]!==p||t[32]!==i||t[33]!==h||t[34]!==g?(xe=()=>{!i||!h||g||I!=="pr"||p(i)},ie=[I,p,i,h,g],t[30]=I,t[31]=p,t[32]=i,t[33]=h,t[34]=g,t[35]=xe,t[36]=ie):(xe=t[35],ie=t[36]),c.useEffect(xe,ie);const[Re,be]=c.useState(!1);let fe;t[37]!==M||t[38]!==m?(fe=Y=>{const{active:U,over:F}=Y;if(!F||U.id===F.id)return;const V=Pu(Ne.getState().contextRailOrder,M).map(OS),oe=V.indexOf(U.id),ae=V.indexOf(F.id);oe===-1||ae===-1||m(Qu(V,oe,ae))},t[37]=M,t[38]=m,t[39]=fe):fe=t[39];const ke=fe;if(!i)return null;let H;t[40]!==e?(H=e("contextRail.aria.rail"),t[40]=e,t[41]=H):H=t[41];let J;t[42]!==ne?(J=ne.map(BS),t[42]=ne,t[43]=J):J=t[43];let ce;if(t[44]!==I||t[45]!==X||t[46]!==W||t[47]!==i||t[48]!==L||t[49]!==f||t[50]!==v||t[51]!==ne||t[52]!==e||t[53]!==a){let Y;t[55]!==I||t[56]!==X||t[57]!==W||t[58]!==i||t[59]!==L||t[60]!==f||t[61]!==v||t[62]!==e||t[63]!==a?(Y=(U,F)=>{const V=U.label??e(U.labelKey),oe=U.id==="git"&&!a?X:0,ae=tr(U.mode)&&I!==U.mode?L[Fo(U.mode)]??0:0,pe=oe>0?oe:ae>0?ae:null,le=pe!==null&&oe===0;return s.jsx(bS,{surface:U,isActive:I===U.mode,showActivityDot:!1,label:V,description:e(U.descriptionKey),badgeCount:pe,badgeAriaLabel:pe!==null?e(le?pe===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":pe===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:V,count:pe}):null,badgeDescription:pe!==null?e(le?pe===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":pe===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:pe}):null,orderNumber:F+1,showOrderNumber:v,onSelect:_e=>{tr(_e.mode)&&W(Fo(_e.mode)),f(i,_e.mode)}},U.id)},t[55]=I,t[56]=X,t[57]=W,t[58]=i,t[59]=L,t[60]=f,t[61]=v,t[62]=e,t[63]=a,t[64]=Y):Y=t[64],ce=ne.map(Y),t[44]=I,t[45]=X,t[46]=W,t[47]=i,t[48]=L,t[49]=f,t[50]=v,t[51]=ne,t[52]=e,t[53]=a,t[54]=ce}else ce=t[54];let je;t[65]!==J||t[66]!==ce?(je=s.jsx(Ja,{items:J,strategy:Xu,children:ce}),t[65]=J,t[66]=ce,t[67]=je):je=t[67];let G;t[68]!==ke||t[69]!==T||t[70]!==je?(G=s.jsx(ui,{sensors:T,collisionDetection:fi,onDragEnd:ke,children:je}),t[68]=ke,t[69]=T,t[70]=je,t[71]=G):G=t[71];let we;t[72]!==e?(we=e("contextRail.configure.open"),t[72]=e,t[73]=we):we=t[73];let Te;t[74]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>be(!0),t[74]=Te):Te=t[74];let he;t[75]===Symbol.for("react.memo_cache_sentinel")?(he=s.jsx(_,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=he):he=t[75];let re;t[76]!==we?(re=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":we,onClick:Te,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:he})}),t[76]=we,t[77]=re):re=t[77];let ge;t[78]!==e?(ge=e("contextRail.configure.open"),t[78]=e,t[79]=ge):ge=t[79];let q;t[80]!==ge?(q=s.jsx(jt,{side:"left",sideOffset:8,children:ge}),t[80]=ge,t[81]=q):q=t[81];let z;t[82]!==re||t[83]!==q?(z=s.jsxs(vt,{delayDuration:Lf,children:[re,q]}),t[82]=re,t[83]=q,t[84]=z):z=t[84];let ee;t[85]!==Re?(ee=s.jsx(dS,{open:Re,onOpenChange:be}),t[85]=Re,t[86]=ee):ee=t[86];let de;return t[87]!==H||t[88]!==G||t[89]!==z||t[90]!==ee?(de=s.jsxs("nav",{"aria-label":H,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[G,z,ee]}),t[87]=H,t[88]=G,t[89]=z,t[90]=ee,t[91]=de):de=t[91],de};function wS(t){return t.workStatusPanelVisible}function vS(t){return t.contextRailOrder}function SS(t){return t.contextRailHiddenSurfaces}function jS(t){return t.setContextRailOrder}function kS(t){return t.openContextSurface}function CS(t){return t.closeContextPanel}function NS(t){return t.shortcutOverrides}function AS(t){return t.planModeEnabled}function PS(t){return t.hasChecked}function DS(t){return t.status?.connected===!0}function IS(t){return t.hasChecked}function TS(t){return t.status?.connected===!0}function ES(t){return t.length===1&&t>="0"&&t<="9"}function RS(t){return t.countByGuest}function MS(t){return t.clearBadge}function OS(t){return t.id}function BS(t){return t.id}const FS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),_S=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Lr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),LS=new Set,$S=[],ka=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},zS=()=>{const t=tt.c(183),{t:e}=Nt(),n=Ne(WS),r=Ne(KS),i=Ne(VS),o=Ne(US),l=Ne(HS),a=Ne(GS),d=Ne(qS),u=Ne(YS),m=Ne(QS),f=Ne(XS),p=Ne(JS),y=Ne(ZS),x=Ne(e0),k=rt(t0),w=rt(s0),h=rt(n0),g=Qr(r0);let j;t[0]!==n?(j=He=>n?He.activeSessions:$S,t[0]=n,t[1]=j):j=t[1];const b=vs(j);let S;t[2]!==n?(S=He=>n?He.ids:LS,t[2]=n,t[3]=S):S=t[3];const C=Qr(S);let v;t[4]!==n?(v=He=>n?He.rankById:Ha,t[4]=n,t[5]=v):v=t[5];const E=Ua(v),R=os(o0),A=Ut(i0),O=Ut(a0),B=dr(),T=_d(l0),{files:M,git:L}=wn(),W=Tn(c0),{isMobile:$}=$n();let P;t[6]!==B?(P=B?ka(B):null,t[6]=B,t[7]=P):P=t[7];const D=P,[I,X]=c.useState(""),ne=ku(I,200).trim();let ue;t[8]!==I?(ue=I.trim(),t[8]=I,t[9]=ue):ue=t[9];const se=ue;let xe,ie;t[10]!==n?(xe=()=>{n&&X("")},ie=[n],t[10]=n,t[11]=xe,t[12]=ie):(xe=t[11],ie=t[12]),c.useEffect(xe,ie);let Re,be;t[13]!==b||t[14]!==W||t[15]!==L||t[16]!==n?(Re=()=>{if(!n||!L)return;const He=setTimeout(()=>{const Ue=new Set;for(const ve of b){const Qe=As(ve);!Qe||Ue.has(Qe)||(Ue.add(Qe),W(Qe,L))}},0);return()=>clearTimeout(He)},be=[n,b,L,W],t[13]=b,t[14]=W,t[15]=L,t[16]=n,t[17]=Re,t[18]=be):(Re=t[17],be=t[18]),c.useEffect(Re,be);let fe;t[19]!==r?(fe=()=>r(!1),t[19]=r,t[20]=fe):fe=t[20];const ke=fe;let H;t[21]!==ke?(H=He=>()=>{ke(),He()},t[21]=ke,t[22]=H):H=t[22];const J=H;let ce;t[23]!==A?.id||t[24]!==A?.path||t[25]!==R||t[26]!==h||t[27]!==$||t[28]!==d||t[29]!==u||t[30]!==p||t[31]!==k||t[32]!==J||t[33]!==y||t[34]!==x||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==g||t[39]!==a?(ce=()=>{const He=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(_,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:J(()=>{l(!1),k()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(_,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:J(d0)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(_,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:J(u0)},{id:"toggle-sidebar",title:e($?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(_,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e($?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:J(()=>{if($){const{isSessionSwitcherOpen:Ue}=Ne.getState();l(!Ue)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(_,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:J(()=>{R&&u(R,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(_,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:J(()=>{R&&d(R)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(_,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:J(f0)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(_,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:J(m0)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(_,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:J(()=>i(!0))}];return He.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(_,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:J(()=>{h&&R&&g({directory:R,sessionId:h})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(_,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:J(()=>{h&&cr(h).then(Ue=>{if(Ue.ok){Ke.success(e("sessions.sidebar.session.copyId.success"));return}Ke.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Ke.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(_,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:J(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(_,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:J(()=>{l(!1),y(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(_,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:J(()=>{R&&(x("notes"),u(R,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(_,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:J(()=>{R&&(x("todos"),u(R,"notes"))})}),He.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(_,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:J(h0)}),qr()&&He.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(_,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:J(()=>{Fn("desktop_open_draft_mini_chat_window",{directory:ka(R||A?.path||""),projectId:A?.id??null}).catch(p0)})}),He},t[23]=A?.id,t[24]=A?.path,t[25]=R,t[26]=h,t[27]=$,t[28]=d,t[29]=u,t[30]=p,t[31]=k,t[32]=J,t[33]=y,t[34]=x,t[35]=l,t[36]=i,t[37]=e,t[38]=g,t[39]=a,t[40]=ce):ce=t[40],A?.id,A?.path;let je;t[41]!==ce?(je=ce(),t[41]=ce,t[42]=je):je=t[42];const G=je,we=Ne(g0);let Te;t[43]===Symbol.for("react.memo_cache_sentinel")?(Te=xn(),t[43]=Te):Te=t[43];const he=Te;let re,ge;t[44]===Symbol.for("react.memo_cache_sentinel")?(re=_n(),ge=!he&&Ma(),t[44]=re,t[45]=ge):(re=t[44],ge=t[45]);let q;t[46]!==$||t[47]!==we?(q={isVSCode:re,isWeb:ge,isDesktop:he,isMobile:$,routingAvailable:we},t[46]=$,t[47]=we,t[48]=q):q=t[48];const z=q;let ee;if(t[49]!==J||t[50]!==i||t[51]!==o||t[52]!==z){let He;t[54]!==z?(He=ve=>ve.isAvailable?ve.isAvailable(z):!0,t[54]=z,t[55]=He):He=t[55];let Ue;t[56]!==J||t[57]!==i||t[58]!==o?(Ue=ve=>{const Qe=Nh(ve.slug)??"settings-3",qe=(ve.keywords??[]).join(" ");return{id:`settings:${ve.slug}`,title:ve.title,icon:ve.slug==="mcp"?s.jsx(eg,{className:"mr-2 h-4 w-4"}):s.jsx(_,{name:Qe,className:"mr-2 h-4 w-4"}),searchText:`${ve.title} ${ve.group} ${qe}`,onSelect:J(()=>{o(ve.slug),i(!0)})}},t[56]=J,t[57]=i,t[58]=o,t[59]=Ue):Ue=t[59],ee=Ch.filter(x0).filter(He).map(Ue),t[49]=J,t[50]=i,t[51]=o,t[52]=z,t[53]=ee}else ee=t[53];const de=ee;let Y;if(t[60]!==b||t[61]!==C||t[62]!==E){const He=b.filter(b0);Y=Qp(He,C,E),t[60]=b,t[61]=C,t[62]=E,t[63]=Y}else Y=t[63];const U=Y,F=Du(),V=rt(y0);let oe;t[64]!==F||t[65]!==V?(oe=(He,Ue)=>{const ve=V.get(He);return ve?.branch?ve.branch.trim()||null:Ue&&F.get(Ue)?.trim()||null},t[64]=F,t[65]=V,t[66]=oe):oe=t[66];const ae=oe;let pe;t[67]===Symbol.for("react.memo_cache_sentinel")?(pe=[],t[67]=pe):pe=t[67];const[le,_e]=c.useState(pe),[Fe,Me]=c.useState(""),Ae=FS(D,ne);let Q;t[68]!==D||t[69]!==Ae||t[70]!==n||t[71]!==T||t[72]!==_e||t[73]!==Me||t[74]!==ne?(Q=()=>{if(!n){_e([]),Me("");return}if(!Ae){_e([]),Me("");return}if(!D){_e([]),Me("");return}let He=!1;return T(D,ne,40,{type:"file"}).then(Ue=>{He||(_e(Ue.map(w0)),Me(Ae))}).catch(()=>{He||(_e([]),Me(Ae))}),()=>{He=!0}},t[68]=D,t[69]=Ae,t[70]=n,t[71]=T,t[72]=_e,t[73]=Me,t[74]=ne,t[75]=Q):Q=t[75];let Ce;t[76]!==D||t[77]!==Ae||t[78]!==n||t[79]!==T||t[80]!==ne?(Ce=[n,D,ne,Ae,T],t[76]=D,t[77]=Ae,t[78]=n,t[79]=T,t[80]=ne,t[81]=Ce):Ce=t[81],c.useEffect(Q,Ce);const Be=se.length>0;let Le;e:{if(!Be){let Ue;t[82]!==G?(Ue=G.filter(v0).map(S0),t[82]=G,t[83]=Ue):Ue=t[83],Le=Ue;break e}let He;t[84]!==G||t[85]!==se?(He=Lr(G,se,j0,{limit:7,noFuzzy:!0}),t[84]=G,t[85]=se,t[86]=He):He=t[86],Le=He}const Je=Le;let ot;e:{if(!Be){let Ue;t[87]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[87]=Ue):Ue=t[87],ot=Ue;break e}let He;t[88]!==se||t[89]!==de?(He=Lr(de,se,k0,{limit:7,noFuzzy:!0}),t[88]=se,t[89]=de,t[90]=He):He=t[90],ot=He}const et=ot;let it;e:{if(!Be){let Ue;t[91]!==U?(Ue=U.slice(0,5).map(C0),t[91]=U,t[92]=Ue):Ue=t[92],it=Ue;break e}let He;t[93]!==se||t[94]!==U?(He=Lr(U,se,N0,{limit:7,threshold:.2}),t[93]=se,t[94]=U,t[95]=He):He=t[95],it=He}const ht=it;let st;e:{if(!n){let Ue;t[96]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[96]=Ue):Ue=t[96],st=Ue;break e}let He;t[97]!==le||t[98]!==Fe||t[99]!==Ae||t[100]!==ne?(He=_S(le,ne,Ae,Fe),t[97]=le,t[98]=Fe,t[99]=Ae,t[100]=ne,t[101]=He):He=t[101],st=He}const mt=st,kt=n&&Ae.length>0&&Fe!==Ae;let Pe;e:{if(!Be){let Ue;t[102]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[102]=Ue):Ue=t[102],Pe=Ue;break e}let He;if(t[103]!==se||t[104]!==O){const Ue=O.map(A0);He=Lr(Ue,se,P0,{limit:7,threshold:.4}),t[103]=se,t[104]=O,t[105]=He}else He=t[105];Pe=He}const Ge=Pe;let at,ze,ft,te,me,De,K,Se,Ve,Xe,nt,Ze,gt,We;if(t[106]!==ae||t[107]!==ke||t[108]!==D||t[109]!==M||t[110]!==Be||t[111]!==n||t[112]!==m||t[113]!==k||t[114]!==I||t[115]!==Je||t[116]!==mt||t[117]!==Ge||t[118]!==ht||t[119]!==et||t[120]!==r||t[121]!==w||t[122]!==f||t[123]!==e){const He=Je.map(D0),Ue=et.map(I0),ve=ht.map(T0),Qe=Be?mt.map(E0):[],qe=Be?Ge.map(R0):[];let Ye;e:{if(!Be){Ye=["commands","sessions"];break e}const Ct=M0,Tt=[{key:"commands",score:Ct(Je)},{key:"settings",score:Ct(et)},{key:"sessions",score:Ct(ht)},{key:"files",score:Ct(mt)},{key:"projects",score:Ct(Ge)}];Tt.sort(O0),Ye=Tt.map(B0)}const dt=Ye,Ot=Ct=>{ke(),w(Ct.id,As(Ct))},zt=async Ct=>{if(!D)return;const Tt=await xf(M,Ct,{directory:D});if(!Tt.ok){Ke.error(bf(Tt.reason));return}m(D,Ct),ke()},Kt=(Ct,Tt)=>{ke(),k({selectedProjectId:Ct,directoryOverride:Tt})},Gt=Ct=>sr(so(Ct,f));te=Ps,Ze=n,gt=r;let Bt;t[138]!==e?(Bt=e("commandPalette.title"),t[138]=e,t[139]=Bt):Bt=t[139];let Jt;t[140]!==Bt?(Jt=s.jsx(Us,{children:Bt}),t[140]=Bt,t[141]=Jt):Jt=t[141];let Vt;t[142]!==e?(Vt=e("commandPalette.description"),t[142]=e,t[143]=Vt):Vt=t[143];let Wt;t[144]!==Vt?(Wt=s.jsx(Hs,{children:Vt}),t[144]=Vt,t[145]=Wt):Wt=t[145],t[146]!==Jt||t[147]!==Wt?(We=s.jsxs(sn,{className:"sr-only",children:[Jt,Wt]}),t[146]=Jt,t[147]=Wt,t[148]=We):We=t[148],ft=Ds,Xe="overflow-hidden p-0",nt=!0,ze=tg,K=!1,Se="[&_[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 _t;t[149]!==e?(_t=e("commandPalette.input.placeholder"),t[149]=e,t[150]=_t):_t=t[150],t[151]!==I||t[152]!==_t?(Ve=s.jsx(sg,{value:I,onValueChange:X,placeholder:_t}),t[151]=I,t[152]=_t,t[153]=Ve):Ve=t[153],at=ng;let Xt;t[154]!==e?(Xt=e("commandPalette.empty.noResults"),t[154]=e,t[155]=Xt):Xt=t[155],t[156]!==Xt?(me=s.jsx(rg,{children:Xt}),t[156]=Xt,t[157]=me):me=t[157],De=dt.map(Ct=>Ct==="commands"&&He.length>0?s.jsx(Dr,{children:He.map(Tt=>s.jsxs($r,{value:Tt.id,onSelect:Tt.onSelect,children:[Tt.icon,s.jsx("span",{children:Tt.title}),Tt.shortcutId?s.jsx(Xp,{children:Gt(Tt.shortcutId)}):null]},Tt.id))},"commands"):Ct==="settings"&&Ue.length>0?s.jsx(Dr,{children:Ue.map(F0)},"settings"):Ct==="sessions"&&ve.length>0?s.jsx(Dr,{children:ve.map(Tt=>{const is=Tt.title||e("commandPalette.session.untitled"),$s=As(Tt),cs=ae(Tt.id,$s);return s.jsxs($r,{value:`session:${Tt.id}`,onSelect:()=>Ot(Tt),children:[s.jsx(_,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:is}),cs?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(_,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:cs})]}):null]},Tt.id)})},"sessions"):Ct==="files"&&Qe.length>0?s.jsx(Dr,{children:Qe.map(Tt=>{const is=Jp(Tt.relativePath||Tt.name,{maxLength:80});return s.jsxs($r,{value:`file:${Tt.path}`,onSelect:()=>{zt(Tt.path)},children:[s.jsx(Ka,{filePath:Tt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":Tt.relativePath,children:is})]},`file:${Tt.path}`)})},"files"):Ct==="projects"&&qe.length>0?s.jsx(Dr,{children:qe.map(Tt=>{const is=Tt.displayName;return s.jsxs($r,{value:`project:${Tt.id}`,onSelect:()=>Kt(Tt.id,Tt.path),children:[s.jsx(_,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:is}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:Tt.path})]},`project:${Tt.id}`)})},"projects"):null),t[106]=ae,t[107]=ke,t[108]=D,t[109]=M,t[110]=Be,t[111]=n,t[112]=m,t[113]=k,t[114]=I,t[115]=Je,t[116]=mt,t[117]=Ge,t[118]=ht,t[119]=et,t[120]=r,t[121]=w,t[122]=f,t[123]=e,t[124]=at,t[125]=ze,t[126]=ft,t[127]=te,t[128]=me,t[129]=De,t[130]=K,t[131]=Se,t[132]=Ve,t[133]=Xe,t[134]=nt,t[135]=Ze,t[136]=gt,t[137]=We}else at=t[124],ze=t[125],ft=t[126],te=t[127],me=t[128],De=t[129],K=t[130],Se=t[131],Ve=t[132],Xe=t[133],nt=t[134],Ze=t[135],gt=t[136],We=t[137];let Et;t[158]!==kt||t[159]!==e?(Et=kt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=kt,t[159]=e,t[160]=Et):Et=t[160];let Ft;t[161]!==at||t[162]!==me||t[163]!==De||t[164]!==Et?(Ft=s.jsxs(at,{children:[me,De,Et]}),t[161]=at,t[162]=me,t[163]=De,t[164]=Et,t[165]=Ft):Ft=t[165];let Ie;t[166]!==ze||t[167]!==K||t[168]!==Se||t[169]!==Ve||t[170]!==Ft?(Ie=s.jsxs(ze,{shouldFilter:K,className:Se,children:[Ve,Ft]}),t[166]=ze,t[167]=K,t[168]=Se,t[169]=Ve,t[170]=Ft,t[171]=Ie):Ie=t[171];let yt;t[172]!==ft||t[173]!==Xe||t[174]!==nt||t[175]!==Ie?(yt=s.jsx(ft,{className:Xe,showCloseButton:nt,children:Ie}),t[172]=ft,t[173]=Xe,t[174]=nt,t[175]=Ie,t[176]=yt):yt=t[176];let At;return t[177]!==te||t[178]!==Ze||t[179]!==gt||t[180]!==We||t[181]!==yt?(At=s.jsxs(te,{open:Ze,onOpenChange:gt,children:[We,yt]}),t[177]=te,t[178]=Ze,t[179]=gt,t[180]=We,t[181]=yt,t[182]=At):At=t[182],At};function WS(t){return t.isCommandPaletteOpen}function KS(t){return t.setCommandPaletteOpen}function VS(t){return t.setSettingsDialogOpen}function US(t){return t.setSettingsPage}function HS(t){return t.setSessionSwitcherOpen}function GS(t){return t.toggleSidebar}function qS(t){return t.openContextOverview}function YS(t){return t.openContextSurface}function QS(t){return t.openContextFile}function XS(t){return t.shortcutOverrides}function JS(t){return t.openMultiRunLauncher}function ZS(t){return t.setArchivePageOpen}function e0(t){return t.setProjectContextTab}function t0(t){return t.openNewSessionDraft}function s0(t){return t.setCurrentSession}function n0(t){return t.currentSessionId}function r0(t){return t.toggle}function o0(t){return t.currentDirectory}function i0(t){return t.getActiveProject()}function a0(t){return t.projects}function l0(t){return t.searchFiles}function c0(t){return t.ensureStatus}function d0(){Iu()}function u0(){un.requestDirectoryDialog()}function f0(){og.invoke("cycle_theme")}function m0(){Tu()}function h0(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function p0(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function g0(t){return t.routingFeatureAvailable}function x0(t){return t.slug!=="home"}function b0(t){return!Zp(t)}function y0(t){return t.worktreeMetadata}function w0(t){return{path:ka(t.path),name:t.name,relativePath:t.relativePath}}function v0(t){return!t.secondary}function S0(t){return{item:t,score:0}}function j0(t){return t.searchText}function k0(t){return t.searchText}function C0(t){return{item:t,score:0}}function N0(t){return t.title||""}function A0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function P0(t){return t.searchText}function D0(t){return t.item}function I0(t){return t.item}function T0(t){return t.item}function E0(t){return t.item}function R0(t){return t.item}function M0(t){return t.length?t[0].score:1/0}function O0(t,e){return t.score-e.score}function B0(t){return t.key}function F0(t){return s.jsxs($r,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Fc=(t,e,n)=>sr(so(t,e),n),_0=()=>{const t=tt.c(74),{t:e}=Nt(),n=Ne(L0),r=Ne($0),i=Ne(z0);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=_n(),t[0]=o):o=t[0];const l=o;let a,d,u,m,f,p,y,x,k,w,h,g;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const P=[{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:[sr("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:[`${sr(sa("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${sr(sa("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:""}]}];u=Ps,h=n,g=r,d=Ds,k="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let D;t[17]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(_,{name:"command",className:"h-5 w-5"}),t[17]=D):D=t[17];let I;t[18]!==e?(I=e("helpDialog.title"),t[18]=e,t[19]=I):I=t[19];let X;t[20]!==I?(X=s.jsxs(Us,{className:"flex items-center gap-2",children:[D,I]}),t[20]=I,t[21]=X):X=t[21];let Z;t[22]!==e?(Z=e("helpDialog.description"),t[22]=e,t[23]=Z):Z=t[23];let ne;t[24]!==Z?(ne=s.jsx(Hs,{children:Z}),t[24]=Z,t[25]=ne):ne=t[25],t[26]!==X||t[27]!==ne?(w=s.jsxs(sn,{children:[X,ne]}),t[26]=X,t[27]=ne,t[28]=w):w=t[28],a=En,p="flex-1 min-h-0 mt-3",y="pr-1",x=!0,m="space-y-4",f=P.map(ue=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(ue.categoryKey)}),s.jsx("div",{className:"space-y-1",children:ue.items.filter(se=>!(l&&se.id==="toggle_prompt_navigator")).map(se=>{const xe=se.id?ig(se.id):void 0,ie=se.descriptionKey??(xe?.customizable?xe.settingsLabelKey:void 0);if(!ie||se.id&&!so(se.id,i))return null;const Re=se.id?Fc(se.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(se.keys)?se.keys:se.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:[se.icon&&s.jsx(_,{name:se.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(ie)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(Re)?Re:[Re]).map((be,fe)=>s.jsxs(c.Fragment,{children:[fe>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:be})]},`${be}-${fe}`))})]},se.id||ie)})})]},ue.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=d,t[7]=u,t[8]=m,t[9]=f,t[10]=p,t[11]=y,t[12]=x,t[13]=k,t[14]=w,t[15]=h,t[16]=g}else a=t[5],d=t[6],u=t[7],m=t[8],f=t[9],p=t[10],y=t[11],x=t[12],k=t[13],w=t[14],h=t[15],g=t[16];let j;t[29]!==m||t[30]!==f?(j=s.jsx("div",{className:m,children:f}),t[29]=m,t[30]=f,t[31]=j):j=t[31];let b;t[32]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(_,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=b):b=t[32];let S;t[33]!==e?(S=e("helpDialog.proTips.title"),t[33]=e,t[34]=S):S=t[34];let C;t[35]!==S?(C=s.jsx("p",{className:"font-medium mb-1",children:S}),t[35]=S,t[36]=C):C=t[36];let v;t[37]!==i||t[38]!==e?(v=e("helpDialog.proTips.commandPalette",{shortcut:Fc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=v):v=t[39];let E;t[40]!==v?(E=s.jsxs("li",{children:["• ",v]}),t[40]=v,t[41]=E):E=t[41];let R;t[42]!==e?(R=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=R):R=t[43];let A;t[44]!==R?(A=s.jsxs("li",{children:["• ",R]}),t[44]=R,t[45]=A):A=t[45];let O;t[46]!==e?(O=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=O):O=t[47];let B;t[48]!==O?(B=s.jsxs("li",{children:["• ",O]}),t[48]=O,t[49]=B):B=t[49];let T;t[50]!==E||t[51]!==A||t[52]!==B?(T=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[E,A,B]}),t[50]=E,t[51]=A,t[52]=B,t[53]=T):T=t[53];let M;t[54]!==C||t[55]!==T?(M=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[b,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[C,T]})]})}),t[54]=C,t[55]=T,t[56]=M):M=t[56];let L;t[57]!==a||t[58]!==j||t[59]!==M||t[60]!==p||t[61]!==y||t[62]!==x?(L=s.jsxs(a,{outerClassName:p,className:y,disableHorizontal:x,children:[j,M]}),t[57]=a,t[58]=j,t[59]=M,t[60]=p,t[61]=y,t[62]=x,t[63]=L):L=t[63];let W;t[64]!==d||t[65]!==L||t[66]!==k||t[67]!==w?(W=s.jsxs(d,{className:k,children:[w,L]}),t[64]=d,t[65]=L,t[66]=k,t[67]=w,t[68]=W):W=t[68];let $;return t[69]!==u||t[70]!==W||t[71]!==h||t[72]!==g?($=s.jsx(u,{open:h,onOpenChange:g,children:W}),t[69]=u,t[70]=W,t[71]=h,t[72]=g,t[73]=$):$=t[73],$};function L0(t){return t.isHelpDialogOpen}function $0(t){return t.setHelpDialogOpen}function z0(t){return t.shortcutOverrides}const W0=()=>{const t=tt.c(32),{t:e}=Nt(),n=Ne(K0),r=Ne(V0),i=Ne(U0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await cr(i)).ok){Ke.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Ke.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Us,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==u?(m=s.jsx(Hs,{children:u}),t[9]=u,t[10]=m):m=t[10];let f;t[11]!==d||t[12]!==m?(f=s.jsxs(sn,{children:[d,m]}),t[11]=d,t[12]=m,t[13]=f):f=t[13];let p;t[14]!==e?(p=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=p):p=t[15];let y;t[16]!==l||t[17]!==p?(y=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-ring",children:p})}),t[16]=l,t[17]=p,t[18]=y):y=t[18];let x;t[19]!==i||t[20]!==e?(x=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=x):x=t[21];let k;t[22]!==x?(k=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:x}),t[22]=x,t[23]=k):k=t[23];let w;t[24]!==f||t[25]!==y||t[26]!==k?(w=s.jsxs(Ds,{className:"max-w-2xl",children:[f,y,k]}),t[24]=f,t[25]=y,t[26]=k,t[27]=w):w=t[27];let h;return t[28]!==n||t[29]!==r||t[30]!==w?(h=s.jsx(Ps,{open:n,onOpenChange:r,children:w}),t[28]=n,t[29]=r,t[30]=w,t[31]=h):h=t[31],h};function K0(t){return t.isOpenCodeStatusDialogOpen}function V0(t){return t.setOpenCodeStatusDialogOpen}function U0(t){return t.openCodeStatusText}const H0=t=>{const e=tt.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const x=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(x)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let m,f;e[5]!==a||e[6]!==o||e[7]!==i?(m=()=>{if(!a||typeof window>"u")return;const x=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",x),()=>window.removeEventListener("openchamber:sidebar-session-search",x)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=m,e[9]=f):(m=e[8],f=e[9]),c.useEffect(m,f);let p,y;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const x=k=>{l.current&&(l.current.contains(k.target)||i(!1))};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},y=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=y):(p=e[14],y=e[15]),c.useEffect(p,y)},G0=t=>{const e=tt.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(q0)),u=[];a.forEach(p=>{const y=d.get(p);y&&(u.push(y),d.delete(p))});const m=[],f=[];return l.forEach(p=>{d.has(p.id)&&(p.isArchivedBucket?f.push(p):m.push(p))}),[...m,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function q0(t){return[t.id,t]}const wo="oc.sessions.projectCollapse",_c="oc.sessions.groupOrder",Lc="oc.sessions.groupCollapse",$c=t=>{if(!t)return new Set;try{const e=Za(lr()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},Y0=t=>{if(!t)return new Map;try{const e=nf(lr(),Za(lr())).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}},Q0=t=>{const e=tt.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=_o(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>$c(o.getItem(wo)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>$c(o.getItem(Lc)),e[2]=u):u=e[2];const[m,f]=c.useState(u);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>Y0(o.getItem(_c)),e[3]=p):p=e[3];const[y,x]=c.useState(p),k=c.useRef(0),w=c.useRef(!1),h=c.useRef(!1),g=c.useRef(null),j=c.useRef(null);let b;e[4]!==n?(b=()=>{if(n)return;const fe=j.current;if(j.current=null,g.current=null,!fe)return;const{projects:ke}=Ut.getState(),H=ke.map(J=>({...J,sidebarCollapsed:fe.has(J.id)}));Fr({projects:H}).catch(X0)},e[4]=n,e[5]=b):b=e[5];const S=b;let C;e[6]!==S||e[7]!==n?(C=fe=>{!globalThis.window||n||(j.current=fe,g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{S()},700))},e[6]=S,e[7]=n,e[8]=C):C=e[8];const v=C;let E,R;e[9]===Symbol.for("react.memo_cache_sentinel")?(E=()=>()=>{globalThis.window&&g.current!==null&&window.clearTimeout(g.current),g.current=null,j.current=null},R=[],e[9]=E,e[10]=R):(E=e[9],R=e[10]),c.useEffect(E,R);let A,O;e[11]!==y?(O=()=>{if(h.current)try{o.setItem(_c,JSON.stringify(Object.fromEntries(y.entries())))}catch{}},A=[y,o],e[11]=y,e[12]=A,e[13]=O):(A=e[12],O=e[13]),c.useEffect(O,A);let B,T;e[14]!==m?(B=()=>{if(w.current)try{o.setItem(Lc,JSON.stringify(Array.from(m)))}catch{}},T=[m,o],e[14]=m,e[15]=B,e[16]=T):(B=e[15],T=e[16]),c.useEffect(B,T);let M;e[17]!==r||e[18]!==v?(M=()=>{k.current=Date.now()+150,w.current=!0,f(new Set),d(()=>{const fe=new Set(r.map(J0));try{o.setItem(wo,JSON.stringify(Array.from(fe)))}catch{}return v(fe),fe})},e[17]=r,e[18]=v,e[19]=M):M=e[19];const L=M;let W;e[20]!==v?(W=()=>{k.current=Date.now()+150,w.current=!0,f(new Set),d(()=>{const fe=new Set;try{o.setItem(wo,JSON.stringify([]))}catch{}return v(fe),fe})},e[20]=v,e[21]=W):W=e[21];const $=W;let P;e[22]!==v?(P=fe=>{k.current=Date.now()+150,d(ke=>{const H=new Set(ke);H.has(fe)?H.delete(fe):H.add(fe);try{o.setItem(wo,JSON.stringify(Array.from(H)))}catch{}return v(H),H})},e[22]=v,e[23]=P):P=e[23];const D=P;let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=fe=>{w.current=!0,f(ke=>{const H=new Set(ke);return H.has(fe)?H.delete(fe):H.add(fe),H})},e[24]=I):I=e[24];const X=I;let Z;e[25]===Symbol.for("react.memo_cache_sentinel")?(Z=fe=>{h.current=!0,x(fe)},e[25]=Z):Z=e[25];const ne=Z,{getOrderedGroups:ue}=G0(y);let se;e[26]!==m||e[27]!==a||e[28]!==y?(se={collapsedProjects:a,collapsedGroups:m,groupOrderByProject:y},e[26]=m,e[27]=a,e[28]=y,e[29]=se):se=e[29];const xe=se;let ie;e[30]!==L||e[31]!==$||e[32]!==ue||e[33]!==v||e[34]!==D?(ie={setCollapsedProjects:d,toggleProject:D,collapseAllProjects:L,expandAllProjects:$,scheduleCollapsedProjectsPersist:v,setCollapsedGroups:f,toggleGroup:X,setGroupOrderByProject:ne,getOrderedGroups:ue},e[30]=L,e[31]=$,e[32]=ue,e[33]=v,e[34]=D,e[35]=ie):ie=e[35];const Re=ie;let be;return e[36]!==Re||e[37]!==xe?(be={state:xe,actions:Re},e[36]=Re,e[37]=xe,e[38]=be):be=e[38],be};function X0(){}function J0(t){return t.id}const Z0=5*6e4,ej=t=>{const e=tt.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=wn(),u=Tn(tj);let m,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(m=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(C=>{na(()=>u(C.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=m,e[6]=f):(m=e[5],f=e[6]),c.useEffect(m,f);let p,y;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(v=>{C.set(v.id,i.get(v.normalizedPath)?.isGitRepo??null)}),o(C)},y=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=y):(p=e[11],y=e[12]),c.useEffect(p,y);let x;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=v=>{const E=i.get(v.normalizedPath)?.branch??"";return`${v.id}:${E}`},e[16]=i,e[17]=C):C=e[17],x=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=x}else x=e[15];const k=x;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w=new Map,e[18]=w):w=e[18];const h=c.useRef(w);let g;e[19]===Symbol.for("react.memo_cache_sentinel")?(g=new Map,e[19]=g):g=e[19];const j=c.useRef(g);let b;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(b=()=>{if(!a)return;let C=!1;const v=setTimeout(()=>{(async()=>{const R=new Set(n.map(sj));for(const L of h.current.keys())R.has(L)||(h.current.delete(L),j.current.delete(L));const A=Date.now(),O=n.filter(L=>{const W=i.get(L.normalizedPath);if(W?.isGitRepo===!1)return h.current.delete(L.id),j.current.delete(L.id),!1;if(W?.isGitRepo!==!0||W.branch===null)return!1;const $=W.branch.trim(),P=`${L.normalizedPath}\0${$}`,D=h.current.get(L.id);if(D===P){const I=j.current.get(L.id);return I&&(I.at=A),!1}return!(D!==void 0&&A-(j.current.get(L.id)?.at??0)<Z0)});if(O.length===0)return;const B=await ag(O,2,async L=>{const W=i.get(L.normalizedPath)?.branch?.trim()??"",$=`${L.normalizedPath}\0${W}`,P=await na(()=>za(L.normalizedPath,W?{knownBranch:W}:void 0)).catch(nj);return{id:L.id,inputKey:$,branch:P}});if(C)return;const T=B.filter(rj);if(T.length===0)return;const M=Date.now();l(L=>{const W=new Map(L);return T.forEach($=>{const{id:P,branch:D}=$;D&&W.set(P,D)}),W}),T.forEach(L=>{const{id:W,inputKey:$,branch:P}=L;h.current.set(W,$),P&&j.current.set(W,{branch:P,at:M})})})()},150);return()=>{C=!0,clearTimeout(v)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=b):b=e[24];let S;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==k||e[29]!==l?(S=[a,n,k,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=k,e[29]=l,e[30]=S):S=e[30],c.useEffect(b,S)};function tj(t){return t.ensureStatus}function sj(t){return t.id}function nj(){return null}function rj(t){return t.branch}const oj=t=>{const e=tt.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(Ah,{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(Ds,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(En,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(Ps,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function ij(t){const e=tt.c(197),{t:n}=Nt(),r=Eu(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenMultiRun:u,canOpenMultiRun:m,onOpenArchive:f,headerActionIconClass:p,headerActionButtonClass:y,isSessionSearchOpen:x,setIsSessionSearchOpen:k,sessionSearchInputRef:w,sessionSearchQuery:h,setSessionSearchQuery:g,hasSessionSearchQuery:j,searchMatchCount:b,collapseAllProjects:S,expandAllProjects:C}=t,v=ms(bj),E=ms(xj),R=Ns(gj),A=Ns(pj),O=Ns(hj),B=Ns(mj),T=Ns(fj),M=Ns(uj),L=Ns(dj),W=Ns(cj),$=o&&L==="single",P=o&&T==="timeline";if(i)return null;let D;e[0]!==y?(D=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=y,e[1]=D):D=e[1];let I;e[2]!==n?(I=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=I):I=e[3];let X;e[4]!==p?(X=s.jsx(_,{name:"folder-add",className:p}),e[4]=p,e[5]=X):X=e[5];let Z;e[6]!==a||e[7]!==D||e[8]!==I||e[9]!==X?(Z=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:D,"aria-label":I,children:X})}),e[6]=a,e[7]=D,e[8]=I,e[9]=X,e[10]=Z):Z=e[10];let ne;e[11]!==n?(ne=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=ne):ne=e[12];let ue;e[13]!==ne?(ue=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ne})}),e[13]=ne,e[14]=ue):ue=e[14];let se;e[15]!==Z||e[16]!==ue?(se=s.jsxs(vt,{children:[Z,ue]}),e[15]=Z,e[16]=ue,e[17]=se):se=e[17];let xe;e[18]!==y?(xe=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=y,e[19]=xe):xe=e[19];let ie;e[20]!==n?(ie=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=ie):ie=e[21];let Re;e[22]!==p?(Re=s.jsx(_,{name:"calendar-schedule",className:p}),e[22]=p,e[23]=Re):Re=e[23];let be;e[24]!==d||e[25]!==xe||e[26]!==ie||e[27]!==Re?(be=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:xe,"aria-label":ie,children:Re})}),e[24]=d,e[25]=xe,e[26]=ie,e[27]=Re,e[28]=be):be=e[28];let fe;e[29]!==n?(fe=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=fe):fe=e[30];let ke;e[31]!==fe?(ke=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:fe})}),e[31]=fe,e[32]=ke):ke=e[32];let H;e[33]!==be||e[34]!==ke?(H=s.jsxs(vt,{children:[be,ke]}),e[33]=be,e[34]=ke,e[35]=H):H=e[35];let J;e[36]!==y?(J=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=y,e[37]=J):J=e[37];let ce;e[38]!==n?(ce=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=ce):ce=e[39];const je=!m;let G;e[40]!==p?(G=s.jsx(dg,{className:p}),e[40]=p,e[41]=G):G=e[41];let we;e[42]!==u||e[43]!==J||e[44]!==ce||e[45]!==je||e[46]!==G?(we=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:J,"aria-label":ce,disabled:je,children:G})}),e[42]=u,e[43]=J,e[44]=ce,e[45]=je,e[46]=G,e[47]=we):we=e[47];let Te;e[48]!==n?(Te=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=Te):Te=e[49];let he;e[50]!==Te?(he=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Te})}),e[50]=Te,e[51]=he):he=e[51];let re;e[52]!==we||e[53]!==he?(re=s.jsxs(vt,{children:[we,he]}),e[52]=we,e[53]=he,e[54]=re):re=e[54];let ge;e[55]!==y?(ge=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=y,e[56]=ge):ge=e[56];let q;e[57]!==n?(q=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=q):q=e[58];let z;e[59]!==p?(z=s.jsx(_,{name:"archive",className:p}),e[59]=p,e[60]=z):z=e[60];let ee;e[61]!==f||e[62]!==ge||e[63]!==q||e[64]!==z?(ee=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:ge,"aria-label":q,children:z})}),e[61]=f,e[62]=ge,e[63]=q,e[64]=z,e[65]=ee):ee=e[65];let de;e[66]!==n?(de=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=de):de=e[67];let Y;e[68]!==de?(Y=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:de})}),e[68]=de,e[69]=Y):Y=e[69];let U;e[70]!==ee||e[71]!==Y?(U=s.jsxs(vt,{children:[ee,Y]}),e[70]=ee,e[71]=Y,e[72]=U):U=e[72];let F;e[73]!==r||e[74]!==p||e[75]!==n?(F=r.length>0&&s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsx(ct,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(_,{name:"apps",className:p})})}),s.jsxs(_s,{align:"start",children:[s.jsx(_r,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(lj)]})]}),e[73]=r,e[74]=p,e[75]=n,e[76]=F):F=e[76];let V;e[77]!==H||e[78]!==re||e[79]!==U||e[80]!==F||e[81]!==se?(V=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[se,H,re,U,F]}),e[77]=H,e[78]=re,e[79]=U,e[80]=F,e[81]=se,e[82]=V):V=e[82];let oe;e[83]!==k?(oe=()=>k(aj),e[83]=k,e[84]=oe):oe=e[84];let ae;e[85]!==y?(ae=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=y,e[86]=ae):ae=e[86];let pe;e[87]!==n?(pe=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=pe):pe=e[88];let le;e[89]!==p?(le=s.jsx(_,{name:"search",className:p}),e[89]=p,e[90]=le):le=e[90];let _e;e[91]!==x||e[92]!==oe||e[93]!==ae||e[94]!==pe||e[95]!==le?(_e=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:oe,className:ae,"aria-label":pe,"aria-expanded":x,children:le})}),e[91]=x,e[92]=oe,e[93]=ae,e[94]=pe,e[95]=le,e[96]=_e):_e=e[96];let Fe;e[97]!==n?(Fe=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=Fe):Fe=e[98];let Me;e[99]!==Fe?(Me=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Fe})}),e[99]=Fe,e[100]=Me):Me=e[100];let Ae;e[101]!==_e||e[102]!==Me?(Ae=s.jsxs(vt,{children:[_e,Me]}),e[101]=_e,e[102]=Me,e[103]=Ae):Ae=e[103];const Q=v&&"bg-interactive-hover text-primary";let Ce;e[104]!==y||e[105]!==Q?(Ce=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent",Q),e[104]=y,e[105]=Q,e[106]=Ce):Ce=e[106];let Be;e[107]!==v||e[108]!==n?(Be=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=v,e[108]=n,e[109]=Be):Be=e[109];let Le;e[110]!==p?(Le=s.jsx(_,{name:"checkbox-multiple",className:p}),e[110]=p,e[111]=Le):Le=e[111];let Je;e[112]!==v||e[113]!==Ce||e[114]!==Be||e[115]!==Le||e[116]!==E?(Je=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:E,className:Ce,"aria-label":Be,"aria-pressed":v,children:Le})}),e[112]=v,e[113]=Ce,e[114]=Be,e[115]=Le,e[116]=E,e[117]=Je):Je=e[117];let ot;e[118]!==v||e[119]!==n?(ot=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=v,e[119]=n,e[120]=ot):ot=e[120];let et;e[121]!==ot?(et=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ot})}),e[121]=ot,e[122]=et):et=e[122];let it;e[123]!==Je||e[124]!==et?(it=s.jsxs(vt,{children:[Je,et]}),e[123]=Je,e[124]=et,e[125]=it):it=e[125];let ht;e[126]!==y?(ht=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=y,e[127]=ht):ht=e[127];let st;e[128]!==n?(st=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=st):st=e[129];let mt;e[130]!==p?(mt=s.jsx(_,{name:"equalizer-2",className:p}),e[130]=p,e[131]=mt):mt=e[131];let kt;e[132]!==ht||e[133]!==st||e[134]!==mt?(kt=s.jsx(St,{asChild:!0,children:s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:ht,"aria-label":st,children:mt})})}),e[132]=ht,e[133]=st,e[134]=mt,e[135]=kt):kt=e[135];let Pe;e[136]!==n?(Pe=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=Pe):Pe=e[137];let Ge;e[138]!==Pe?(Ge=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Pe})}),e[138]=Pe,e[139]=Ge):Ge=e[139];let at;e[140]!==kt||e[141]!==Ge?(at=s.jsxs(vt,{children:[kt,Ge]}),e[140]=kt,e[141]=Ge,e[142]=at):at=e[142];let ze;e[143]!==M||e[144]!==o||e[145]!==T||e[146]!==n||e[147]!==P?(ze=o?s.jsxs(s.Fragment,{children:[s.jsx(_r,{children:n("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(Ze=>{const[gt,We]=Ze;return s.jsxs(Ht,{onClick:()=>{M(gt),Fr({sidebarViewMode:gt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(We)}),T===gt?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},gt)}),P?null:s.jsx(Es,{})]}):null,e[143]=M,e[144]=o,e[145]=T,e[146]=n,e[147]=P,e[148]=ze):ze=e[148];let ft;e[149]!==L||e[150]!==O||e[151]!==W||e[152]!==B||e[153]!==o||e[154]!==n||e[155]!==P?(ft=P?null:s.jsxs(s.Fragment,{children:[s.jsx(_r,{children:n("sessions.sidebar.header.actions.sortProjects")}),[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(Ze=>{const[gt,We]=Ze;return s.jsxs(Ht,{onClick:()=>{B(gt),Fr({sidebarProjectSortOrder:gt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(We)}),O===gt?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},gt)}),s.jsx(Es,{}),o?s.jsxs(s.Fragment,{children:[s.jsx(_r,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Ze=>{const[gt,We]=Ze;return s.jsxs(Ht,{onClick:()=>{W(gt),Fr({sidebarProjectDisplayMode:gt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(We)}),L===gt?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},gt)}),s.jsx(Es,{})]}):null]}),e[149]=L,e[150]=O,e[151]=W,e[152]=B,e[153]=o,e[154]=n,e[155]=P,e[156]=ft):ft=e[156];let te;e[157]!==$||e[158]!==l||e[159]!==R||e[160]!==n||e[161]!==P||e[162]!==A?(te=!P&&l&&!$?s.jsxs(Ht,{onClick:()=>{A(),Fr({sidebarShowRecentSection:!R})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),R?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[157]=$,e[158]=l,e[159]=R,e[160]=n,e[161]=P,e[162]=A,e[163]=te):te=e[163];let me;e[164]!==S||e[165]!==C||e[166]!==$||e[167]!==n||e[168]!==P?(me=!P&&!$?s.jsxs(s.Fragment,{children:[s.jsx(Es,{}),s.jsxs(Ht,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(_,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Ht,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(_,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[164]=S,e[165]=C,e[166]=$,e[167]=n,e[168]=P,e[169]=me):me=e[169];let De;e[170]!==ze||e[171]!==ft||e[172]!==te||e[173]!==me?(De=s.jsxs(_s,{align:"end",className:"min-w-[180px]",children:[ze,ft,te,me]}),e[170]=ze,e[171]=ft,e[172]=te,e[173]=me,e[174]=De):De=e[174];let K;e[175]!==at||e[176]!==De?(K=s.jsxs(Ls,{children:[at,De]}),e[175]=at,e[176]=De,e[177]=K):K=e[177];let Se;e[178]!==Ae||e[179]!==it||e[180]!==K?(Se=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Ae,it,K]}),e[178]=Ae,e[179]=it,e[180]=K,e[181]=Se):Se=e[181];let Ve;e[182]!==V||e[183]!==Se?(Ve=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[V,Se]}),e[182]=V,e[183]=Se,e[184]=Ve):Ve=e[184];let Xe;e[185]!==j||e[186]!==x||e[187]!==b||e[188]!==w||e[189]!==h||e[190]!==k||e[191]!==g||e[192]!==n?(Xe=x?s.jsx("div",{className:"pb-1",children:s.jsx(Qd,{inputRef:w,value:h,onSearch:g,onClose:()=>k(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:j?b===1?n("sessions.sidebar.header.search.matchCountSingle",{count:b}):n("sessions.sidebar.header.search.matchCountPlural",{count:b}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[185]=j,e[186]=x,e[187]=b,e[188]=w,e[189]=h,e[190]=k,e[191]=g,e[192]=n,e[193]=Xe):Xe=e[193];let nt;return e[194]!==Ve||e[195]!==Xe?(nt=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:[Ve,Xe]})}),e[194]=Ve,e[195]=Xe,e[196]=nt):nt=e[196],nt}function aj(t){return!t}function lj(t){return s.jsxs(Ht,{onSelect:()=>Ne.getState().setOpenGuestPage(t.id),children:[s.jsx(to,{icon:cg(t.icon),iconSrc:lg(t.id,t.icon,Ld().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function cj(t){return t.setProjectDisplayMode}function dj(t){return t.projectDisplayMode}function uj(t){return t.setSidebarViewMode}function fj(t){return t.sidebarViewMode}function mj(t){return t.setProjectSortOrder}function hj(t){return t.projectSortOrder}function pj(t){return t.toggleRecentSection}function gj(t){return t.showRecentSection}function xj(t){return t.toggleMode}function bj(t){return t.enabled}const vo="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-ring";function yj(t){const e=tt.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,m=d===void 0?!0:d,{t:f}=Nt();if(!u&&!m)return null;let p;e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==f?(p=u?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:vo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(_,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:vo,"aria-label":f("usageStats.openAction"),children:s.jsx(_,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("usageStats.openAction")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:vo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(_,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:vo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(_,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=r,e[4]=u,e[5]=f,e[6]=p):p=e[6];let y;e[7]!==l||e[8]!==m||e[9]!==f?(y=m?s.jsx(ct,{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:l,children:f("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=m,e[9]=f,e[10]=y):y=e[10];let x;return e[11]!==p||e[12]!==y?(x=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[p,y]}),e[11]=p,e[12]=y,e[13]=x):x=e[13],x}const wj=t=>{for(const e of t.sessions.values())if(e.tabs.some(zd))return!0;return!1},vj=()=>{const t=tt.c(4),{terminal:e}=wn(),n=Mt(wj);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=Sj,l=jj;if(n)return Gi(e,"",l,o);let a=kj;return a=Gi(e,"",l,d=>{o(d),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 Sj(t){const e=Mt.getState(),n=Ph(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 jj(){return new Map(Mt.getState().actionMutationRevisions)}function kj(){}const Cj=t=>{const e=tt.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:m,addSessionToFolder:f}=t,p=r===void 0?!0:r;let y,x;e[0]!==f||e[1]!==m||e[2]!==p||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(y=()=>{!p||o||!l||a||n.forEach(k=>{if(d.has(k.normalizedPath))return;const w=Ru(k.normalizedPath),h=i.archivedSessionsByProject.get(k.id)??[],g=u[w]??[],j=new Map(g.map(Nj));h.forEach(b=>{const S=ug(b,k.normalizedPath),C=S.toLowerCase();let v=j.get(C);v||(v=m(w,S),j.set(C,v)),v.sessionIds.includes(b.id)||f(w,v.id,b.id)})})},x=[n,p,i,o,l,a,d,u,m,f],e[0]=f,e[1]=m,e[2]=p,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=y,e[11]=x):(y=e[10],x=e[11]),c.useEffect(y,x)};function Nj(t){return[t.name.toLowerCase(),t]}function Aj({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([m,f])=>m!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const Pj=t=>{const e=tt.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:m,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let y,x;if(e[0]!==n){x=new Map,y=new Map;const C=(v,E,R,A)=>{x.has(v)||x.set(v,new Map);const O=x.get(v);A.forEach(B=>{const T=xt(B.worktree?.path??B.session.directory??R??E);O.set(B.session.id,{directory:T}),y.has(v)||y.set(v,{id:B.session.id,directory:T}),B.children.length>0&&C(v,E,T,B.children)})};n.forEach(v=>{v.groups.forEach(E=>{C(v.project.id,v.project.normalizedPath,E.directory,E.sessions)})}),e[0]=n,e[1]=y,e[2]=x}else y=e[1],x=e[2];let k;e[3]!==y||e[4]!==x?(k={metaByProject:x,firstSessionByProject:y},e[3]=y,e[4]=x,e[5]=k):k=e[5];const w=k,h=c.useRef(null);let g,j;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==m||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==w||e[16]!==o||e[17]!==p?(g=()=>{if(!r||u||Ne.getState().isNewWorktreeDialogOpen||h.current===r)return;const C=n.find(A=>A.project.id===r);if(!C)return;const v=w.metaByProject.get(r);if(l&&v&&v.has(l)){h.current=r,o(A=>{if(A.get(r)===l)return A;const O=new Map(A);return O.set(r,l),O});return}const E=Aj({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:v,metaByProject:w.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:w.firstSessionByProject.get(r)?.id??null});if(E.kind==="preserve-current"){a===r&&(h.current=r);return}if(h.current=r,E.kind==="open-draft"){m&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(E.kind!=="select-session")return;const R=v?.get(E.sessionId)?.directory??null;d(E.sessionId,R)},j=[r,i,l,a,d,u,m,f,n,w,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=m,e[12]=u,e[13]=f,e[14]=n,e[15]=w,e[16]=o,e[17]=p,e[18]=g,e[19]=j):(g=e[18],j=e[19]),c.useLayoutEffect(g,j);let b,S;e[20]!==r||e[21]!==l||e[22]!==w||e[23]!==o?(b=()=>{if(!r||!l)return;const C=w.metaByProject.get(r);!C||!C.has(l)||o(v=>{if(v.get(r)===l)return v;const E=new Map(v);return E.set(r,l),E})},S=[r,l,w,o],e[20]=r,e[21]=l,e[22]=w,e[23]=o,e[24]=b,e[25]=S):(b=e[24],S=e[25]),c.useEffect(b,S)},Dj=t=>{const e=tt.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=rt(Ij),a=rt(Tj);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let m;e[8]!==r?(m=()=>new Map(r),e[8]=r,e[9]=m):m=e[9];const[f,p]=c.useState(m);let y;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(y={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=y):y=e[15],Pj(y);let x,k;return e[16]!==f||e[17]!==i?(x=()=>{i(f)},k=[f,i],e[16]=f,e[17]=i,e[18]=x,e[19]=k):(x=e[18],k=e[19]),c.useEffect(x,k),null};function Ij(t){return t.currentSessionId}function Tj(t){return!!t.newSessionDraft?.open}const Ej=t=>{const e=tt.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},Yn=(t,e)=>`${t}\0${e}`,Zn=(t,e)=>t??Ga(e)??xt(e??null),Jr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??xt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},ll=t=>t.startsWith("__archived__:"),Rj=(t,e)=>t.map(n=>{const r=xt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
878
+ `)},pv=t=>{const e=tt.c(7),{t:n}=Nt(),r=rt(xv),i=rt(bv),o=Ji(yv),l=Lp(wv);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){Ke.error(n("contextPanel.browser.annotate.noSession"));return}let m=!1;if(d.screenshot)try{await l(d.screenshot),m=!0}catch{m=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:hv({payload:d.payload,screenshotAttached:m,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Ke.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},gv=()=>{const t=tt.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 xv(t){return t.currentSessionId}function bv(t){return t.newSessionDraft?.open}function yv(t){return t.addDraft}function wv(t){return t.addAttachedFile}const vv=3e4,Sv=3,jv=250,kv={attempts:0,windowStartedAt:null},Cv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=vv,r=n?0:t.attempts;return r>=Sv?null:{delayMs:jv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Nv=-3,bo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",gr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Av=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:fw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,m]=c.useState(!1),[f,p]=c.useState(!1),y=c.useRef(n);y.current=n;const x=c.useRef(kv);return c.useEffect(()=>{if(!t)return;const k=()=>{try{const A=t.getURL();return bo(A)?A:""}catch{return""}},w=()=>{try{m(t.canGoBack()),p(t.canGoForward())}catch{}},h=A=>{bo(A)&&(l(A),y.current(A))},g=()=>{const A=k();i({kind:"loading",url:A})},j=()=>{const A=k();let O="";try{O=t.getTitle()||""}catch{O=""}d(O),h(A),w(),i(B=>B.kind==="failed"&&B.url===A?B:{kind:"ready",url:A,title:O})},b=A=>{const O=gr(A);bo(O.url)&&(h(O.url),w())},S=A=>{const O=gr(A),B=Array.isArray(O.favicons)?O.favicons.find(Boolean):"",T=k();B&&T&&Sf.getState().resolve(T,B)},C=A=>{const O=gr(A);typeof O.title=="string"&&d(O.title)},v=A=>{const O=gr(A);if(O.isMainFrame===!1)return;const B=typeof O.errorCode=="number"?O.errorCode:0;B!==Nv&&i({kind:"failed",url:bo(O.validatedURL)?O.validatedURL:k(),code:B,description:typeof O.errorDescription=="string"?O.errorDescription:""})};let E=null;const R=()=>{const A=k(),O=Cv(x.current,Date.now());if(!O){i({kind:"failed",url:A,code:0,description:"",crashed:!0});return}x.current=O.state,i({kind:"loading",url:A}),E=setTimeout(()=>{E=null;try{t.reload()}catch{i({kind:"failed",url:A,code:0,description:"",crashed:!0})}},O.delayMs)};t.addEventListener("did-start-loading",g),t.addEventListener("did-stop-loading",j),t.addEventListener("did-navigate",b),t.addEventListener("did-navigate-in-page",b),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",S),t.addEventListener("did-fail-load",v),t.addEventListener("render-process-gone",R),t.addEventListener("crashed",R);try{!t.isLoading()&&k()&&j()}catch{}return()=>{E!==null&&clearTimeout(E),t.removeEventListener("render-process-gone",R),t.removeEventListener("crashed",R),t.removeEventListener("did-start-loading",g),t.removeEventListener("did-stop-loading",j),t.removeEventListener("did-navigate",b),t.removeEventListener("did-navigate-in-page",b),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",S),t.removeEventListener("did-fail-load",v)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},Pv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Dv=4e4,yo=.5,Iv=-3,Tv=4,Ev="persist:openchamber-browser",Tc=20,Rv=600,Mv=2e4,Ov=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=Nt(),{currentTheme:i}=Ln(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(Y=>{o.current=Y,a(Y)},[]),u=Ne(Y=>Y.setContextPanelTabTargetPath),m=c.useRef(wr(t)),f=m.current!==tn?m.current:"",[p,y]=c.useState(f?null:tn),[x,k]=c.useState(f),[w,h]=c.useState(!1),[g,j]=c.useState(!1),[b,S]=c.useState(0),C=c.useRef(0),[v,E]=c.useState(!1),[R,A]=c.useState(Uo),O=c.useRef(R);O.current=R;const B=c.useRef([]),[T,M]=c.useState("system"),[L,W]=c.useState({width:0,height:0}),$=c.useRef(null),P=c.useRef(null),D=c.useRef(!1),I=c.useRef(Date.now()),X=c.useCallback(Y=>{!Y||Y===tn||!e||!n||u(e,n,Y)},[e,n,u]),Z=Av(l,{initialUrl:f,onUrlChange:c.useCallback(Y=>{const U=Rr(Y);k(U),X(U)},[X])}),[ne,ue]=c.useState(null),se=pv(e),xe=gv(),ie=Z.status.kind==="loading",Re=Sr(Df(e)),be=Sr(Y=>Y.recordVisit),fe=Sr(Y=>Y.forget);c.useEffect(()=>{Z.status.kind==="ready"&&be(e,{url:Rr(Z.status.url),title:Z.status.title})},[e,Z.status,be]);const ke=c.useMemo(()=>Pf(Re,x),[Re,x]),H=c.useCallback(Y=>{const U=wr(Y);U!==tn&&(k(U),ue(null),Cc(U).then(F=>{const V=o.current;if(!V){y(F);return}try{V.loadURL(F)}catch{y(F)}}).catch(F=>{F instanceof Hr&&ue(U)}))},[]);c.useEffect(()=>{if(!f)return;let Y=!0;return Cc(f).then(U=>{Y&&y(U)}).catch(U=>{if(Y){if(U instanceof Hr){ue(f),y(tn);return}y(f)}}),()=>{Y=!1}},[]);const J=c.useMemo(()=>({executeJavaScript:async(Y,U)=>{const F=o.current;if(!F)throw new Error("Browser view is not available");return F.executeJavaScript(Y,U)},capturePage:async()=>{const Y=o.current;if(!Y)return null;const U=Y.getWebContentsId();return Number.isFinite(U)?await br("desktop_browser_capture_page",{webContentsId:U}):null}}),[]),ce=c.useCallback(()=>{if(w){h(!1),Eo(J);return}if(!Z.url){Ke.error(r("contextPanel.browser.annotate.noPage"));return}const Y=Nw(i.metadata.variant==="light"?"light":"dark");h(!0),kw({host:J,theme:Y,labels:xe}).then(async U=>{h(!1),U&&await se(U)}).catch(()=>{h(!1),Ke.error(r("contextPanel.browser.annotate.failed"))})},[J,se,i,w,Z.url,xe,r]);c.useEffect(()=>{if(!w)return;const Y=U=>{$p(U)||U.key!=="Escape"||(U.preventDefault(),U.stopImmediatePropagation(),h(!1),Eo(J))};return window.addEventListener("keydown",Y,!0),()=>window.removeEventListener("keydown",Y,!0)},[J,w]);const je=c.useCallback(async(Y=8e3)=>{const U=Date.now();for(;;){const F=o.current;if(!F)return!1;let V=!1;try{V=F.isLoading()}catch{return!1}if(!V)return!0;if(Date.now()-U>Y)return!1;await new Promise(oe=>setTimeout(oe,120))}},[]),G=c.useCallback(async(Y,U)=>{const F=o.current;if(!F)throw new Error("The browser panel is not ready");const V=()=>{Ic(U.viewport)&&(A(Sa(U.viewport)),E(!0))};if(Y==="browser.back"||Y==="browser.forward"){const Fe=Y==="browser.back";if(!(Fe?F.canGoBack():F.canGoForward()))throw new Error(Fe?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Fe?F.goBack():F.goForward(),await new Promise(Q=>setTimeout(Q,150)),await je();let Ae="";try{Ae=F.getTitle()||""}catch{Ae=""}return{url:Rr(F.getURL()),title:Ae}}if(Y==="browser.capture"){const Fe=Ne.getState(),Me=Qn(e),Ae=Fe.contextPanelByDirectory[Me],Q=!!(Ae?.isOpen&&Ae.activeTabId===n);Q||Fe.setActiveContextPanelTab(e,n);const Ce=()=>{if(Q||!Ae)return;const Be=Ne.getState(),Le=Be.contextPanelByDirectory[Me];!Le?.isOpen||Le.activeTabId!==n||(Ae.activeTabId&&Ae.activeTabId!==n&&Be.setActiveContextPanelTab(e,Ae.activeTabId),Ae.isOpen||Be.closeContextPanel(e))};try{const Be=Date.now()+1200;let Le=0,Je=0;for(;Je<2&&Date.now()<Be;){const it=F.getBoundingClientRect().width;Je=it>=2&&Math.abs(it-Le)<.5?Je+1:0,Le=it,await new Promise(ht=>setTimeout(ht,50))}await new Promise(it=>{requestAnimationFrame(()=>requestAnimationFrame(()=>it()))}),await je();const ot=await J.capturePage();if(!ot)throw new Error("The page could not be captured");let et="";try{et=F.getTitle()||""}catch{et=""}return{...ot,url:Rr(F.getURL()),title:et,viewport:xo(O.current)}}finally{Ce()}}if(Y==="browser.resize"){if(!Ic(U.viewport))throw new Error("viewport is required");return V(),await new Promise(Fe=>setTimeout(Fe,200)),await je(),{viewport:xo(Sa(U.viewport))}}if(Y==="browser.open"){const Fe=typeof U.url=="string"?U.url:"";if(!Fe)throw new Error("url is required");V(),H(Fe),await new Promise(Q=>setTimeout(Q,150));const Me=await je(25e3);let Ae="";try{Ae=F.getTitle()||""}catch{Ae=""}return{url:wr(Fe),title:Ae,opened:!0,settled:Me,viewport:xo(O.current)}}await je();const oe=Fe=>typeof Fe=="string"&&Fe?Fe:void 0,pe=(()=>{switch(Y){case"browser.snapshot":return qw({selector:oe(U.selector)});case"browser.click":return Yw({selector:oe(U.selector),text:oe(U.text)});case"browser.type":return Qw({selector:String(U.selector??""),value:String(U.value??""),submit:U.submit===!0});case"browser.inspect":return Zw({selector:String(U.selector??"")});case"browser.scroll":return Xw({selector:oe(U.selector),direction:oe(U.direction)});default:return null}})();if(!pe)throw new Error(`Unsupported browser action: ${Y}`);const le=await F.executeJavaScript(pe,!0);if(!le||typeof le!="object")throw new Error("The page returned no result");const _e=le;if(_e.ok!==!0)throw new Error(typeof _e.error=="string"&&_e.error?_e.error:"Browser action failed");if(Y==="browser.snapshot"){const Fe=B.current;return{..._e,viewport:xo(O.current),...Fe.length>0?{consoleProblems:[...Fe]}:{}}}return(Y==="browser.click"||Y==="browser.type"&&U.submit===!0)&&(await new Promise(Fe=>setTimeout(Fe,150)),await je()),le},[J,e,H,n,je]);c.useEffect(()=>Ew({run:G}),[G]),c.useEffect(()=>{const Y=J;return()=>{Eo(Y)}},[J]),c.useEffect(()=>{if(!l)return;const Y=F=>{const V=F;if(typeof V.level!="number"||V.level<2)return;const oe=V.sourceId?`${V.sourceId}${V.line?`:${V.line}`:""}`:"";B.current.push({level:V.level>=3?"error":"warning",message:String(V.message??"").slice(0,400),source:oe}),B.current.length>Tc&&B.current.splice(0,B.current.length-Tc)},U=()=>{B.current=[]};return l.addEventListener("console-message",Y),l.addEventListener("did-start-loading",U),()=>{l.removeEventListener("console-message",Y),l.removeEventListener("did-start-loading",U)}},[l]);const we=c.useRef(new Set),Te=c.useCallback(Y=>{we.current.clear(),H(Y)},[H]);c.useEffect(()=>{if(!l)return;const Y=F=>{const V=gr(F),oe=typeof V.url=="string"?V.url:"";!oe||!Nc(oe)||(F.preventDefault(),H(oe))},U=F=>{const V=gr(F);if(V.isMainFrame===!1||V.errorCode===-3)return;const oe=typeof V.validatedURL=="string"?V.validatedURL:"";!oe||!Nc(oe)||we.current.has(oe)||(we.current.add(oe),H(oe))};return l.addEventListener("will-navigate",Y),l.addEventListener("did-fail-load",U),()=>{l.removeEventListener("will-navigate",Y),l.removeEventListener("did-fail-load",U)}},[H,l]),c.useEffect(()=>{if(!l)return;const Y=U=>{const F=U.detail;U.preventDefault(),F?.url&&H(F.url)};return l.addEventListener("new-window",Y),()=>l.removeEventListener("new-window",Y)},[H,l]);const he=c.useCallback(Y=>{const U=Math.min(Tv,Math.max(Iv,Y));C.current=U,S(U);try{o.current?.setZoomLevel(U)}catch{}},[]);c.useEffect(()=>{const Y=U=>{if(!(U instanceof CustomEvent))return;const F=U.detail,V=o.current;!V||document.activeElement!==V||(F==="zoom-in"?he(C.current+yo):F==="zoom-out"?he(C.current-yo):F==="zoom-reset"&&he(0))};return window.addEventListener("openchamber:zoom",Y),()=>window.removeEventListener("openchamber:zoom",Y)},[he]);const re=c.useCallback(Y=>{br("desktop_browser_clear_data",{partition:Ev,cookies:Y==="cookies",cache:Y==="cache"}).then(()=>{Ke.success(r(Y==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Ke.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const Y=$.current;if(!Y||typeof ResizeObserver>"u")return;const U=new ResizeObserver(F=>{const V=F[0]?.contentRect;V&&W({width:V.width,height:V.height})});return U.observe(Y),()=>U.disconnect()},[]);const ge=c.useCallback(Y=>{M(Y);const U=o.current;if(!U)return;let F=-1;try{F=U.getWebContentsId()}catch{return}br("desktop_browser_set_color_scheme",{webContentsId:F,scheme:Y}).catch(V=>{M("system"),Ke.error(V instanceof Error?V.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),q=c.useCallback(()=>{try{ie?o.current?.stop():o.current?.reload()}catch{}},[ie]),z=Z.status;c.useEffect(()=>{const Y=()=>{j(!0);const V=setTimeout(()=>{try{o.current?.reload()}catch{}},Rv);return()=>clearTimeout(V)};if(z.kind==="failed"){if(!rw(z.code,z.url)){j(!1);return}const V=Date.now(),oe=P.current?.url===z.url?P.current:{url:z.url,startedAt:V};if(P.current=oe,V-oe.startedAt>Dv){j(!1);return}return Y()}if(z.kind==="loading")return;if(P.current=null,z.kind!=="ready"||!z.url||!Nr(z.url)){D.current=!0,j(!1);return}if(D.current||Date.now()-I.current>Mv){D.current=!0,j(!1);return}let U=!1,F=null;return aw(Rr(z.url)).then(V=>{if(!U){if(V===null||V<500){D.current=!0,j(!1);return}F=Y()}}),()=>{U=!0,F?.()}},[z]);const ee=Z.status.kind==="failed"&&!g?Z.status:null,de=nv(R,L);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Rf,{address:x,onAddressChange:k,onSubmit:Te,suggestions:ke,onForgetSuggestion:Y=>fe(e,Y),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:q,onOpenExternal:()=>{eo(Z.url||x)},canGoBack:Z.canGoBack,canGoForward:Z.canGoForward,isLoading:ie,onAnnotate:ce,isAnnotating:w,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>he(b+yo),onZoomOut:()=>he(b-yo),onZoomReset:()=>he(0),zoomPercent:Math.round(Math.pow(1.2,b)*100),onClearCookies:()=>re("cookies"),onClearCache:()=>re("cache"),onToggleDeviceBar:()=>E(Y=>!Y),isDeviceBarOpen:v}),v?s.jsx(iv,{viewport:R,onViewportChange:A,colorScheme:T,onColorSchemeChange:ge,scale:de?.scale??1}):null,s.jsxs("div",{ref:$,className:Ee("relative min-h-0 flex-1 bg-background",de&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:d,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:de?{width:`${de.width}px`,height:`${de.height}px`,transform:`scale(${de.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!f&&!Z.url&&!ie?s.jsx(Bf,{onOpen:Te,directory:e}):null,g?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,ne?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:ne})})]}):null,ee&&!ne?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:ee.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ee.crashed?r("contextPanel.browser.crashedHint"):ee.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ie?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]})]})},Bv=t=>{const e=tt.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=Nt(),l=Ne(_v);let a;e[0]!==n?(a=wr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==tn?d:"",[m,f]=c.useState(u),[p,y]=c.useState(u);let x;e[2]!==u?(x=u?[u]:[],e[2]=u,e[3]=x):x=e[3];const[k,w]=c.useState(x),[h,g]=c.useState(u?0:-1),[j,b]=c.useReducer(Lv,0);let S;e[4]!==r||e[5]!==l||e[6]!==i?(S=xe=>{!xe||xe===tn||!r||!i||l(r,i,xe)},e[4]=r,e[5]=l,e[6]=i,e[7]=S):S=e[7];const C=S;let v;e[8]!==r?(v=Df(r),e[8]=r,e[9]=v):v=e[9];const E=Sr(v),R=Sr($v),A=Sr(zv);let O;e[10]!==m||e[11]!==E?(O=Pf(E,m),e[10]=m,e[11]=E,e[12]=O):O=e[12];const B=O;let T;e[13]!==r||e[14]!==h||e[15]!==C||e[16]!==R?(T=xe=>{const ie=wr(xe);ie!==tn&&(f(ie),y(ie),C(ie),R(r,{url:ie}),w(Re=>{const be=h>=0?Re.slice(0,h+1):[];return be[be.length-1]===ie?(g(be.length-1),be):(g(be.length),[...be,ie])}))},e[13]=r,e[14]=h,e[15]=C,e[16]=R,e[17]=T):T=e[17];const M=T;let L;e[18]!==k||e[19]!==C?(L=xe=>{const ie=k[xe];ie&&(g(xe),f(ie),y(ie),C(ie))},e[18]=k,e[19]=C,e[20]=L):L=e[20];const W=L;let $;e[21]!==r||e[22]!==A?($=xe=>A(r,xe),e[21]=r,e[22]=A,e[23]=$):$=e[23];let P,D;e[24]!==W||e[25]!==h?(D=()=>W(h-1),P=()=>W(h+1),e[24]=W,e[25]=h,e[26]=P,e[27]=D):(P=e[26],D=e[27]);let I;e[28]!==m||e[29]!==p?(I=()=>{eo(p||m)},e[28]=m,e[29]=p,e[30]=I):I=e[30];const X=h>0,Z=h>=0&&h<k.length-1;let ne;e[31]!==m||e[32]!==M||e[33]!==B||e[34]!==P||e[35]!==I||e[36]!==X||e[37]!==Z||e[38]!==$||e[39]!==D?(ne=s.jsx(Rf,{address:m,onAddressChange:f,onSubmit:M,suggestions:B,onForgetSuggestion:$,onBack:D,onForward:P,onReload:b,onOpenExternal:I,canGoBack:X,canGoForward:Z,isLoading:!1}),e[31]=m,e[32]=M,e[33]=B,e[34]=P,e[35]=I,e[36]=X,e[37]=Z,e[38]=$,e[39]=D,e[40]=ne):ne=e[40];let ue;e[41]!==p||e[42]!==M||e[43]!==j||e[44]!==o?(ue=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}|${j}`):s.jsx(Bf,{onOpen:M})}),e[41]=p,e[42]=M,e[43]=j,e[44]=o,e[45]=ue):ue=e[45];let se;return e[46]!==ne||e[47]!==ue?(se=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[ne,ue]}),e[46]=ne,e[47]=ue,e[48]=se):se=e[48],se},Fv=t=>{const e=tt.c(3),[n]=c.useState(Pv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Ov,{...t}):s.jsx(Bv,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function _v(t){return t.setContextPanelTabTargetPath}function Lv(t){return t+1}function $v(t){return t.recordVisit}function zv(t){return t.forget}const Wv=Kn(()=>yn(()=>import("./WalkthroughView-Cj3K8Xz6.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.WalkthroughView}))),Kv=Kn(()=>yn(()=>import("./DiffView-CX3wAX2S.js"),__vite__mapDeps([128,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,115,116,129,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.DiffView}))),Vv=Kn(()=>yn(()=>import("./FilesView-OL3CON3r.js"),__vite__mapDeps([130,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,131,132,133,134,135,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,136,137,120,121,118,125,138,119,139])).then(t=>({default:t.FilesView}))),Uv=Kn(()=>yn(()=>import("./GitView-DKIjpnu4.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,84,85,86,141,117,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,87,115,116,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),Hv=Kn(()=>yn(()=>import("./LinearIssuesView-BD2zLu-r.js"),__vite__mapDeps([142,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}))),Gv=Kn(()=>yn(()=>import("./PlanView-DyH2SyCP.js"),__vite__mapDeps([143,1,2,4,5,6,7,8,9,131,57,58,59,60,61,62,79,55,56,63,132,133,134,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,119,139,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Ec=c.lazy(()=>yn(()=>import("./PluginPane-BibJit86.js").then(t=>t.l),__vite__mapDeps([86,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.PluginPane}))),_i={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-r border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-l border-border",vertical:!1}},Rc=c.lazy(()=>yn(()=>import("./GuestSurfacePane-B_cqX5I5.js"),__vite__mapDeps([144,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,86])).then(t=>({default:t.GuestSurfacePane}))),Ff=320,al=600,qv=400,Yv=100,Qv=24,Go=new Map,Xv=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},Mc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Ff,Math.round(t))):al,Oc=t=>{const e=t??(typeof window<"u"?window.innerWidth:al*2);return Math.max(Ff,e-qv)},Jv=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Zv=(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},_f=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):tr(t)?_a.getState().guests.find(r=>r.id===Fo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),eS=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},tS=(t,e,n)=>{if(t.mode==="chat"){const r=ja(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"?ol(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?eS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):_f(t.mode,n)},sS=t=>{const e=tt.c(8),{mode:n}=t,r=Va();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=m=>m.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??Gp,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(to,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Bc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Ka,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(ff,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(_,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(_,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(_,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(_,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(_,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(_,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(_,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(_,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(_,{name:"chat-4",className:"h-3.5 w-3.5"});if(tr(t.mode))return s.jsx(sS,{mode:t.mode});if(t.mode==="browser"){const n=nS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(_,{name:"global",className:"h-3.5 w-3.5"})}},nS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},rS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=Nt(),i=Ne(g=>g.contextEditorTreeWidth),o=Ne(g=>g.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),y=c.useCallback(g=>{const j=p.current;j&&(j.style.width=`${g}px`,j.style.setProperty("--oc-editor-tree-width",`${g}px`))},[]),x=g=>{if(t){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{}f.current=g.pointerId,a(!0),d.current=g.clientX,u.current=i,m.current=i,g.preventDefault()}},k=g=>{if(!l||f.current!==g.pointerId)return;const j=d.current-g.clientX,b=Ui(u.current+j);m.current!==b&&(m.current=b,y(b))},w=g=>{if(f.current!==g.pointerId)return;try{g.currentTarget.releasePointerCapture(g.pointerId)}catch{}const j=Ui(m.current??i);f.current=null,m.current=null,a(!1),o(j)},h=t?i:0;return s.jsxs("div",{ref:p,className:Ee("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?m.current??h:h}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?m.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Ee("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:x,onPointerMove:k,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Ee("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(k1,{visible:t&&e})})]})},ja=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,oS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},iS=(t,e)=>{if(e.length===0)return Go;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?Go:r},aS=(t,e)=>{const n=Hp(t),r=c.useRef(Go),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=iS(n.getState().session,i.current);return oS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Go)},lS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,cS=()=>{const{t}=Nt(),e=dr()??"",n=c.useMemo(()=>Xv(e),[e]),r=Ne(K=>n?K.contextPanelByDirectory[n]:void 0),i=Ne(K=>K.closeContextPanel),o=Ne(K=>K.closeContextPanelTab),l=Ne(K=>K.openContextPanelTab),a=Ne(K=>K.toggleContextPanelExpanded),d=Ne(K=>K.setContextPanelWidth),u=Ne(K=>K.setActiveContextPanelTab),m=Ne(K=>K.openContextBrowser);c.useEffect(()=>{if(e)return Rw(K=>m(e,K,{reveal:!1}))},[e,m]);const f=Ne(K=>K.openContextFile);c.useEffect(()=>Wn(K=>{if(K.type!=="file-open-request")return;const Se=K.directory??e;Se&&f(Se,K.path)}),[e,f]);const p=Ne(K=>K.reorderContextPanelTabs),y=pn(K=>K.setSelectedPath),x=Ne(K=>K.contextEditorTreeVisible),k=Ne(K=>K.contextEditorTreeWidth),w=Ne(K=>K.setContextEditorTreeWidth),h=Ne(K=>K.toggleContextEditorTree),g=Ne(K=>K.contextEditorVisible),j=Ne(K=>K.toggleContextEditor),b=Ne(K=>K.openNewContextBrowserTab),S=Sf(K=>K.byOrigin),C=Ne(K=>K.allowPromptingSubagentSessions),{themeMode:v,setThemeMode:E,lightThemeId:R,darkThemeId:A,currentTheme:O}=Ln(),B=c.useMemo(()=>r?.tabs??[],[r?.tabs]),T=B.find(K=>K.id===r?.activeTabId)??B[B.length-1]??null,M=!!(r?.isOpen&&T),[L,W]=c.useState(null),$=c.useMemo(()=>B.some(K=>K.mode==="file"&&K.targetPath),[B]),P=$&&(g||!x),D=T?.mode??null,I=D==="file"&&!P,X=!!(M&&r?.expanded&&!I),Z=D?r?.widthByMode?.[D]:void 0,ne=D?r?.widthFractionByMode?.[D]:void 0,ue=D?zp(D):.5,se=L??(typeof window<"u"?window.innerWidth:al*2),xe=ne!=null&&L!=null?Math.round(ne*L):Z,ie=I?k:Mc(xe??Math.round(ue*se),Oc(L??se));c.useEffect(()=>{!n||!D||I||ne!=null||Z==null||L==null||d(n,D,Z,L)},[D,L,n,I,Z,ne,d]);const Re=c.useMemo(()=>{const K=[];for(const Se of B){if(Se.mode!=="chat")continue;const Ve=ja(Se.dedupeKey);Ve&&!K.includes(Ve)&&K.push(Ve)}return K},[B]),be=aS(n||void 0,Re),[fe,ke]=c.useState(!1),H=c.useRef(0),J=c.useRef(ie),ce=c.useRef(null),je=c.useRef(null),G=c.useRef(null),we=c.useRef(new Map),Te=c.useRef(new Map),he=c.useRef(!1);c.useLayoutEffect(()=>{const K=G.current?.parentElement;if(!K||typeof ResizeObserver>"u")return;const Se=new ResizeObserver(()=>{W(K.clientWidth||null)});return Se.observe(K),W(K.clientWidth||null),()=>Se.disconnect()},[]),c.useEffect(()=>{if(!M||he.current){he.current=M;return}const K=window.requestAnimationFrame(()=>{G.current?.focus({preventScroll:!0})});return he.current=!0,()=>window.cancelAnimationFrame(K)},[M]);const re=c.useRef(null),ge=c.useRef(null),q=c.useCallback(()=>{ge.current=null;const K=G.current,Se=ce.current;!K||Se===null||K.style.setProperty("--oc-context-panel-width",`${Se}px`)},[]);c.useEffect(()=>()=>{ge.current!==null&&clearTimeout(ge.current)},[]);const z=c.useCallback(K=>{const Se=re.current,Ve=I?Ui(K):Mc(K,Oc(Se));return Se===null?Ve:Math.min(Ve,Math.max(1,Se))},[I]),ee=c.useCallback(K=>{!M||X||!n||(je.current=K.pointerId,ke(!0),H.current=K.clientX,J.current=ie,ce.current=ie,re.current=Jv(G.current),document.documentElement.style.cursor="col-resize",K.preventDefault())},[n,X,M,ie]),de=c.useCallback(()=>{const K=z(ce.current??ie),Se=re.current;ce.current=null,re.current=null,ge.current!==null&&(clearTimeout(ge.current),ge.current=null),document.documentElement.style.cursor="",I?w(K):n&&D&&d(n,D,K,Se??void 0),ke(!1),je.current=null},[D,z,n,I,w,d,ie]);c.useEffect(()=>{if(!fe)return;const K=Xe=>{if(je.current!==Xe.pointerId)return;const nt=H.current-Xe.clientX,Ze=z(J.current+nt);ce.current!==Ze&&(ce.current=Ze,ge.current===null&&(ge.current=setTimeout(q,Yv)))},Se=Xe=>{je.current===Xe.pointerId&&de()},Ve=()=>{de()};return window.addEventListener("pointermove",K),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se),window.addEventListener("blur",Ve),()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se),window.removeEventListener("blur",Ve)}},[q,z,de,fe]),c.useEffect(()=>{fe||(ce.current=null,document.documentElement.style.cursor="")},[fe]);const Y=c.useCallback(()=>{n&&i(n)},[i,n]),U=c.useCallback(()=>{n&&a(n)},[n,a]),F=c.useCallback(K=>{K.key==="Escape"&&(K.target instanceof Node&&!K.currentTarget.contains(K.target)||Wp(K.target)||Kp(K.target)||(K.preventDefault(),K.stopPropagation(),Y()))},[Y]);c.useEffect(()=>{if(!(!n||!T)&&T.mode==="file"&&T.targetPath){y(n,T.targetPath,{allowOutsideRoot:!0});return}},[T,n,y]);const V=c.useMemo(()=>B.filter(K=>K.mode==="chat"),[B]),oe=M&&T?.mode==="chat"?T.id:null,ae=M&&T?.mode==="chat"?ja(T.dedupeKey):null,pe=sb(V,oe);c.useEffect(()=>{if(!M||!n||!ae||typeof window>"u")return;const K=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Ai(n,ae,!1);return}Au(ae),Ai(n,ae,!0)};K();const Se=window.setInterval(K,1e4);return window.addEventListener("focus",K),window.addEventListener("blur",K),document.addEventListener("visibilitychange",K),()=>{window.clearInterval(Se),window.removeEventListener("focus",K),window.removeEventListener("blur",K),document.removeEventListener("visibilitychange",K),Ai(n,ae,!1)}},[ae,n,M]);const le=c.useCallback((K,Se,Ve)=>nb(Te.current,K,Se,n||null,Ve,{mode:v,lightThemeId:R,darkThemeId:A,currentTheme:O},{allowPromptingSubagentSessions:C}),[C,O,A,n,R,v]),_e=pe&&ae?le(pe.id,ae,pe.readOnly):null;c.useEffect(()=>{const K=new Set(B.map(Se=>Se.id));for(const Se of Te.current.keys())K.has(Se)||Te.current.delete(Se)},[B]);const Fe=c.useCallback(K=>{!n||T?.mode!=="diff"||l(n,{mode:"diff",targetPath:T.targetPath,stagedDiff:K==="staged",diffScope:K})},[T,n,l]),Me=c.useCallback(()=>{if(typeof window>"u")return;const K={themeMode:v,lightThemeId:R,darkThemeId:A,currentTheme:O};for(const Se of we.current.values()){const Ve=Se.contentWindow;Ve&&Ve.postMessage({type:"openchamber:theme-sync",payload:K},window.location.origin)}},[O,A,R,v]),Ae=c.useCallback(()=>{if(typeof window>"u")return;const K={allowPromptingSubagentSessions:C};for(const Se of we.current.values()){const Ve=Se.contentWindow;Ve&&Ve.postMessage({type:"openchamber:chat-settings-sync",payload:K},window.location.origin)}},[C]),Q=c.useCallback((K,Se,Ve)=>{const Xe=Se.contentWindow;Xe&&Xe.postMessage({type:sf,payload:{visible:oe===K}},Ve)},[oe]),Ce=c.useCallback(()=>{if(!(typeof window>"u"))for(const[K,Se]of we.current.entries())Q(K,Se,window.location.origin)},[Q]);c.useEffect(()=>{if(typeof window>"u")return;const K=Se=>{if(Se.origin!==window.location.origin)return;const Ve=Array.from(we.current.entries()).find(([,We])=>We.contentWindow===Se.source);if(!Ve)return;const Xe=Se.data;if(Xe?.type===rb){const[We,Et]=Ve;Q(We,Et,Se.origin);return}if(Xe?.type===ob){if(typeof Xe.requestId!="string"||!Xe.requestId)return;const We=Qt(),Et={apiBaseUrl:Dn(),clientToken:Yr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:$d(),relayHostId:We.startsWith("host:")?We.slice(5):"",relay:Xm()??void 0};Se.source?.postMessage({type:ib,requestId:Xe.requestId,payload:Et},Se.origin);return}if(Xe?.type==="openchamber:theme-sync-request"){Me();return}if(Xe?.type==="openchamber:chat-settings-request"){Ae();return}if(Xe?.type!=="openchamber:cycle-theme-request")return;const nt=["light","dark","system"],gt=(nt.indexOf(v)+1)%nt.length;E(nt[gt])};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[Ae,Q,Me,E,v]),c.useLayoutEffect(()=>{B.some(Se=>Se.mode==="chat")&&(Me(),Ae(),Ce())},[A,R,Ae,Ce,Me,B,v]);const Be=T?.mode==="file"||T?.mode==="chat"||T?.mode==="browser",Le=c.useMemo(()=>T?B.filter(K=>K.mode===T.mode):[],[T,B]),Je=c.useMemo(()=>Le.map(K=>{const Se=tS(K,be,t),Ve=lS(Se,Qv),Xe=Zv(K.targetPath,e);return{id:K.id,label:Ve,icon:Bc(K,S),title:Xe?`${Se}: ${Xe}`:Se,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ve})}}),[Le,e,S,be,t]),ot=T?.mode==="context"?s.jsx(K1,{}):T?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Uv,{isActive:M})}):T?.mode==="pr"?s.jsx(Xy,{}):T?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Hv,{})}):T?.mode==="notes"?s.jsx(jh,{}):T?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Gv,{targetPath:T.targetPath,savedProjectPlan:T.projectPlanId&&T.projectPlanRef?{projectRef:T.projectPlanRef,planId:T.projectPlanId}:null})}):null,et=c.useMemo(()=>B.filter(K=>K.mode==="browser"),[B]),it=c.useMemo(()=>B.filter(K=>K.mode==="diff"),[B]),ht=c.useMemo(()=>B.find(K=>K.mode==="terminal")??null,[B]),st=c.useMemo(()=>B.some(K=>K.mode==="walkthrough"),[B]),mt=c.useMemo(()=>B.filter(K=>tr(K.mode)),[B]),kt=_a(K=>K.guests),Pe=c.useMemo(()=>new Set(kt.filter(Vp).map(K=>K.id)),[kt]),Ge=c.useMemo(()=>{const K=new Map;for(const Se of kt){const Ve=Up(Se);Ve&&K.set(Se.id,Ve)}return K},[kt]),at=c.useMemo(()=>B.some(K=>K.mode==="file"),[B]),ze=T?.mode==="file",ft=Ne(K=>K.closeContextPanelTabs),te=c.useCallback(K=>{if(!n)return null;const{id:Se,index:Ve,allIds:Xe,close:nt}=K,Ze=()=>ft(n,Xe.filter(At=>At!==Se)),gt=()=>ft(n,Xe.slice(0,Ve)),We=()=>ft(n,Xe.slice(Ve+1)),Et=()=>ft(n,Xe),Ft=Xe.length>1,Ie=Ve===0,yt=Ve===Xe.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Xn,{onClick:nt,children:[s.jsx(_,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Yi,{}),s.jsxs(Xn,{onClick:Ze,disabled:!Ft,children:[s.jsx(_,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Xn,{onClick:gt,disabled:Ie,children:[s.jsx(_,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Xn,{onClick:We,disabled:yt,children:[s.jsx(_,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Yi,{}),s.jsxs(Xn,{onClick:Et,disabled:!Ft,children:[s.jsx(_,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[ft,n,t]),me=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Be?s.jsx(Hd,{items:Je,activeId:T?.id??null,onSelect:K=>{n&&u(n,K)},onClose:K=>{n&&o(n,K)},onReorder:(K,Se)=>{n&&p(n,K,Se)},layoutMode:"scrollable",variant:"default",tabContextMenu:te}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[T?Bc(T,S):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:T?_f(T.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[T?.mode==="browser"?s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&b(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(_,{name:"add",className:"h-3.5 w-3.5"})}):null,ze&&$?s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:j,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":P,children:s.jsx(_,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,ze?s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":x,children:s.jsx(_,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,I?null:s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:U,className:"h-7 w-7 p-0",title:t(X?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(X?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:X?s.jsx(_,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(_,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:Y,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]})]}),De=M?X?{"--oc-context-panel-width":L!==null?`${L}px`:"100%",width:L!==null?`${L}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${ie}px`}:{"--oc-context-panel-width":`${ie}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:G,"data-context-panel":"true",tabIndex:-1,inert:!M||void 0,className:Ee("flex min-h-0 flex-col overflow-hidden bg-background",X?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!M&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:F,style:De,children:[M&&!X&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),M&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!X&&s.jsx("div",{className:Ee("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",fe&&"bg-[var(--interactive-border)]"),onPointerDown:ee,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Ee("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]",!M&&"pointer-events-none select-none opacity-0"),style:{width:X?L!==null?`${L}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!M,children:[me,s.jsxs("div",{className:Ee("relative min-h-0 flex-1 overflow-hidden",fe&&"pointer-events-none"),children:[at?s.jsxs("div",{className:Ee("absolute inset-0 flex",ze?"flex":"hidden"),children:[$||!x?s.jsx("div",{className:Ee("h-full min-w-0 flex-1",$&&!P&&"hidden"),children:$?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Vv,{mode:"editor-only",visible:M&&ze&&P})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(_,{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")})]})}):null,s.jsx(rS,{visible:x,active:M&&ze,fill:!P})]}):null,pe&&ae&&_e?s.jsx("iframe",{ref:K=>{if(!K){we.current.delete(pe.id);return}we.current.set(pe.id,K)},src:_e,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ae}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Me(),Ae(),Ce()}},pe.id):null,et.map(K=>s.jsx("div",{className:Ee("absolute inset-0",T?.id!==K.id&&"invisible pointer-events-none"),"aria-hidden":T?.id!==K.id||void 0,children:s.jsx(Fv,{initialUrl:K.targetPath??"",directory:n,tabID:K.id})},K.id)),it.map(K=>s.jsx("div",{className:Ee("absolute inset-0",T?.id!==K.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Kv,{visible:M&&T?.id===K.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:K.diffScope??(K.stagedDiff?"staged":"working"),onDiffScopeChange:Fe,targetFilePath:K.targetPath,flushContent:!0})})},K.id)),ht?s.jsx("div",{className:Ee("absolute inset-0",T?.mode==="terminal"?"block":"hidden"),children:s.jsx(kh,{visible:M&&T?.mode==="terminal",directory:ht.targetDirectory})}):null,st?s.jsx("div",{className:Ee("absolute inset-0",T?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Wv,{directory:e,visible:M&&T?.mode==="walkthrough"})})}):null,mt.map(K=>{if(!tr(K.mode))return null;const Se=Fo(K.mode),Ve=Pe.has(Se),Xe=Ge.get(Se),nt=T?.id===K.id,Ze=nt&&M;return Ve&&!Xe&&!Ze?null:s.jsx("div",{className:Ee("absolute inset-0",nt?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ve?Xe?s.jsxs("div",{className:Ee("flex h-full",_i[Xe.dock].container),children:[s.jsx("div",{className:Ee("shrink-0",_i[Xe.dock].page),style:_i[Xe.dock].vertical?{height:Xe.size}:{width:Xe.size},children:s.jsx(Ec,{mode:K.mode})}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ze?s.jsx(Rc,{mode:K.mode}):null})]}):s.jsx(Rc,{mode:K.mode}):s.jsx(Ec,{mode:K.mode})})},K.id)}),T?.mode!=="chat"&&!ze&&T?.mode!=="browser"&&T?.mode!=="diff"&&T?.mode!=="terminal"&&T?.mode!=="walkthrough"&&!(T&&tr(T.mode))?ot:null]})]})]})},dS=t=>{const e=tt.c(43),{open:n,onOpenChange:r}=t,{t:i}=Nt(),o=Ne(uS),l=Ne(fS),a=Ne(mS),d=Ne(hS),u=Va();let m;e[0]!==o||e[1]!==u?(m=Pu(o,u),e[0]=o,e[1]=u,e[2]=m):m=e[2];const f=m,p=l.length===0;let y;if(e[3]!==l||e[4]!==f){let R;e[6]!==l?(R=A=>l.includes(A.id),e[6]=l,e[7]=R):R=e[7],y=f.every(R),e[3]=l,e[4]=f,e[5]=y}else y=e[5];const x=y;let k;e[8]!==i?(k=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=k):k=e[9];let w;e[10]!==k?(w=s.jsx(Us,{children:k}),e[10]=k,e[11]=w):w=e[11];let h;e[12]!==i?(h=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=h):h=e[13];let g;e[14]!==h?(g=s.jsx(Hs,{children:h}),e[14]=h,e[15]=g):g=e[15];let j;e[16]!==w||e[17]!==g?(j=s.jsxs(sn,{children:[w,g]}),e[16]=w,e[17]=g,e[18]=j):j=e[18];let b;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let R;e[24]!==l||e[25]!==a||e[26]!==i?(R=A=>s.jsx(qp,{settingsItem:`layout.context-rail.surface.${A.id}`,checked:!l.includes(A.id),onChange:O=>a(A.id,O),label:A.label??i(A.labelKey),ariaLabel:A.label??i(A.labelKey)},A.id),e[24]=l,e[25]=a,e[26]=i,e[27]=R):R=e[27],b=f.map(R),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=b}else b=e[23];let S;e[28]!==b?(S=s.jsx("div",{className:"flex flex-col",children:b}),e[28]=b,e[29]=S):S=e[29];let C;e[30]!==p||e[31]!==x||e[32]!==d||e[33]!==i?(C=p?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[x?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ct,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=p,e[31]=x,e[32]=d,e[33]=i,e[34]=C):C=e[34];let v;e[35]!==C||e[36]!==j||e[37]!==S?(v=s.jsxs(Ds,{className:"max-w-md",children:[j,S,C]}),e[35]=C,e[36]=j,e[37]=S,e[38]=v):v=e[38];let E;return e[39]!==r||e[40]!==n||e[41]!==v?(E=s.jsx(Ps,{open:n,onOpenChange:r,children:v}),e[39]=r,e[40]=n,e[41]=v,e[42]=E):E=e[42],E};function uS(t){return t.contextRailOrder}function fS(t){return t.contextRailHiddenSurfaces}function mS(t){return t.setContextRailSurfaceVisible}function hS(t){return t.setContextRailHiddenSurfaces}const Lf=150,pS=500,gS=[],xS=t=>t>99?"99+":String(t),bS=t=>{const e=tt.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:m,showOrderNumber:f,onSelect:p}=t;let y;e[0]!==n.id?(y={id:n.id},e[0]=n.id,e[1]=y):y=e[1];const{attributes:x,listeners:k,setNodeRef:w,transform:h,transition:g,isDragging:j}=mi(y);let b;e[2]!==a?(b=a!=null&&a>0?xS(a):null,e[2]=a,e[3]=b):b=e[3];const S=b;let C;e[4]!==h?(C=hi.Translate.toString(h),e[4]=h,e[5]=C):C=e[5];let v;e[6]!==C||e[7]!==g?(v={transform:C,transition:g},e[6]=C,e[7]=g,e[8]=v):v=e[8];const E=j&&"z-10 opacity-70";let R;e[9]!==E?(R=Ee("relative",E),e[9]=E,e[10]=R):R=e[10];let A;e[11]!==p||e[12]!==n?(A=()=>p(n),e[11]=p,e[12]=n,e[13]=A):A=e[13];const O=d??o,B=r?"text-primary":"text-muted-foreground hover:text-foreground";let T;e[14]!==B?(T=Ee("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",B),e[14]=B,e[15]=T):T=e[15];let M;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?(M=n.id==="diff"?s.jsx(ff,{className:"h-[18px] w-[18px]"}):s.jsx(to,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=M):M=e[19];let L;e[20]!==S||e[21]!==m||e[22]!==i||e[23]!==f?(L=f&&m!=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:m===10?"0":m}):S?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:S}):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[20]=S,e[21]=m,e[22]=i,e[23]=f,e[24]=L):L=e[24];let W;e[25]!==x||e[26]!==r||e[27]!==k||e[28]!==T||e[29]!==M||e[30]!==L||e[31]!==A||e[32]!==O?(W=s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",...x,...k,onClick:A,"aria-label":O,"aria-pressed":r,className:T,children:[M,L]})}),e[25]=x,e[26]=r,e[27]=k,e[28]=T,e[29]=M,e[30]=L,e[31]=A,e[32]=O,e[33]=W):W=e[33];let $;e[34]!==o?($=s.jsx("span",{children:o}),e[34]=o,e[35]=$):$=e[35];let P;e[36]!==l?(P=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=P):P=e[37];let D;e[38]!==u?(D=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=D):D=e[39];let I;e[40]!==$||e[41]!==P||e[42]!==D?(I=s.jsx(jt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[$,P,D]})}),e[40]=$,e[41]=P,e[42]=D,e[43]=I):I=e[43];let X;e[44]!==W||e[45]!==I?(X=s.jsxs(vt,{delayDuration:Lf,children:[W,I]}),e[44]=W,e[45]=I,e[46]=X):X=e[46];let Z;return e[47]!==w||e[48]!==X||e[49]!==v||e[50]!==R?(Z=s.jsx("div",{ref:w,style:v,className:R,children:X}),e[47]=w,e[48]=X,e[49]=v,e[50]=R,e[51]=Z):Z=e[51],Z},yS=()=>{const t=tt.c(92),{t:e}=Nt(),n=dr();let r;t[0]!==n?(r=n?Qn(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=Y=>i?Y.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Ne(o),a=Ne(wS),d=Ne(vS),u=Ne(SS),m=Ne(jS),f=Ne(kS),p=Ne(CS),y=Ne(NS),x=La(AS),k=ta(PS),w=ta(DS),h=In(IS),g=In(TS),{screenWidth:j}=$n(),b=$a(i||null);let S;t[4]!==y?(S=sa("switch_context_surface",y),t[4]=y,t[5]=S):S=t[5];const C=S,[v,E]=c.useState(!1);let R,A;t[6]!==C?(R=()=>{const Y=new Set;let U=null,F=!1;const V=ES,oe=()=>{Rl(C,Y)?!F&&U===null&&(U=setTimeout(()=>E(!0),pS)):(F=!1,U!==null&&(clearTimeout(U),U=null),E(!1))},ae=_e=>{if(Y.add(_e.key.toLowerCase()),V(_e.key)&&Rl(C,Y)){F=!0,U!==null&&(clearTimeout(U),U=null),E(!1);return}oe()},pe=_e=>{Y.delete(_e.key.toLowerCase()),oe()},le=()=>{Y.clear(),F=!1,U!==null&&(clearTimeout(U),U=null),E(!1)};return window.addEventListener("keydown",ae,!0),window.addEventListener("keyup",pe,!0),window.addEventListener("blur",le),()=>{window.removeEventListener("keydown",ae,!0),window.removeEventListener("keyup",pe,!0),window.removeEventListener("blur",le),U!==null&&clearTimeout(U)}},A=[C],t[6]=C,t[7]=R,t[8]=A):(R=t[7],A=t[8]),c.useEffect(R,A);let O;t[9]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{distance:8}},t[9]=O):O=t[9];let B;t[10]===Symbol.for("react.memo_cache_sentinel")?(B={activationConstraint:{delay:200,tolerance:6}},t[10]=B):B=t[10];const T=li(Pn(di,O),Pn(ci,B)),M=Va(),L=El(RS),W=El(MS),$=l?.tabs??gS;let P;t[11]!==l?.activeTabId||t[12]!==$?(P=$.find(Y=>Y.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=$,t[13]=P):P=t[13];const D=P,I=l?.isOpen?D?.mode??null:null,X=b?.files.length??0;let Z;t[14]!==u||t[15]!==d||t[16]!==g||t[17]!==M||t[18]!==w||t[19]!==x||t[20]!==j||t[21]!==$?(Z=Yp({railOrder:d,hiddenSurfaces:u,planModeEnabled:x,isVSCode:_n(),screenWidth:j,tabs:$,linearConnected:w,githubConnected:g,extras:M}),t[14]=u,t[15]=d,t[16]=g,t[17]=M,t[18]=w,t[19]=x,t[20]=j,t[21]=$,t[22]=Z):Z=t[22];const ne=Z;let ue,se;t[23]!==I||t[24]!==p||t[25]!==i||t[26]!==k||t[27]!==w?(se=()=>{!i||!k||w||I!=="linear"||p(i)},ue=[I,p,i,k,w],t[23]=I,t[24]=p,t[25]=i,t[26]=k,t[27]=w,t[28]=ue,t[29]=se):(ue=t[28],se=t[29]),c.useEffect(se,ue);let xe,ie;t[30]!==I||t[31]!==p||t[32]!==i||t[33]!==h||t[34]!==g?(xe=()=>{!i||!h||g||I!=="pr"||p(i)},ie=[I,p,i,h,g],t[30]=I,t[31]=p,t[32]=i,t[33]=h,t[34]=g,t[35]=xe,t[36]=ie):(xe=t[35],ie=t[36]),c.useEffect(xe,ie);const[Re,be]=c.useState(!1);let fe;t[37]!==M||t[38]!==m?(fe=Y=>{const{active:U,over:F}=Y;if(!F||U.id===F.id)return;const V=Pu(Ne.getState().contextRailOrder,M).map(OS),oe=V.indexOf(U.id),ae=V.indexOf(F.id);oe===-1||ae===-1||m(Qu(V,oe,ae))},t[37]=M,t[38]=m,t[39]=fe):fe=t[39];const ke=fe;if(!i)return null;let H;t[40]!==e?(H=e("contextRail.aria.rail"),t[40]=e,t[41]=H):H=t[41];let J;t[42]!==ne?(J=ne.map(BS),t[42]=ne,t[43]=J):J=t[43];let ce;if(t[44]!==I||t[45]!==X||t[46]!==W||t[47]!==i||t[48]!==L||t[49]!==f||t[50]!==v||t[51]!==ne||t[52]!==e||t[53]!==a){let Y;t[55]!==I||t[56]!==X||t[57]!==W||t[58]!==i||t[59]!==L||t[60]!==f||t[61]!==v||t[62]!==e||t[63]!==a?(Y=(U,F)=>{const V=U.label??e(U.labelKey),oe=U.id==="git"&&!a?X:0,ae=tr(U.mode)&&I!==U.mode?L[Fo(U.mode)]??0:0,pe=oe>0?oe:ae>0?ae:null,le=pe!==null&&oe===0;return s.jsx(bS,{surface:U,isActive:I===U.mode,showActivityDot:!1,label:V,description:e(U.descriptionKey),badgeCount:pe,badgeAriaLabel:pe!==null?e(le?pe===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":pe===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:V,count:pe}):null,badgeDescription:pe!==null?e(le?pe===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":pe===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:pe}):null,orderNumber:F+1,showOrderNumber:v,onSelect:_e=>{tr(_e.mode)&&W(Fo(_e.mode)),f(i,_e.mode)}},U.id)},t[55]=I,t[56]=X,t[57]=W,t[58]=i,t[59]=L,t[60]=f,t[61]=v,t[62]=e,t[63]=a,t[64]=Y):Y=t[64],ce=ne.map(Y),t[44]=I,t[45]=X,t[46]=W,t[47]=i,t[48]=L,t[49]=f,t[50]=v,t[51]=ne,t[52]=e,t[53]=a,t[54]=ce}else ce=t[54];let je;t[65]!==J||t[66]!==ce?(je=s.jsx(Ja,{items:J,strategy:Xu,children:ce}),t[65]=J,t[66]=ce,t[67]=je):je=t[67];let G;t[68]!==ke||t[69]!==T||t[70]!==je?(G=s.jsx(ui,{sensors:T,collisionDetection:fi,onDragEnd:ke,children:je}),t[68]=ke,t[69]=T,t[70]=je,t[71]=G):G=t[71];let we;t[72]!==e?(we=e("contextRail.configure.open"),t[72]=e,t[73]=we):we=t[73];let Te;t[74]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>be(!0),t[74]=Te):Te=t[74];let he;t[75]===Symbol.for("react.memo_cache_sentinel")?(he=s.jsx(_,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=he):he=t[75];let re;t[76]!==we?(re=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":we,onClick:Te,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:he})}),t[76]=we,t[77]=re):re=t[77];let ge;t[78]!==e?(ge=e("contextRail.configure.open"),t[78]=e,t[79]=ge):ge=t[79];let q;t[80]!==ge?(q=s.jsx(jt,{side:"left",sideOffset:8,children:ge}),t[80]=ge,t[81]=q):q=t[81];let z;t[82]!==re||t[83]!==q?(z=s.jsxs(vt,{delayDuration:Lf,children:[re,q]}),t[82]=re,t[83]=q,t[84]=z):z=t[84];let ee;t[85]!==Re?(ee=s.jsx(dS,{open:Re,onOpenChange:be}),t[85]=Re,t[86]=ee):ee=t[86];let de;return t[87]!==H||t[88]!==G||t[89]!==z||t[90]!==ee?(de=s.jsxs("nav",{"aria-label":H,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[G,z,ee]}),t[87]=H,t[88]=G,t[89]=z,t[90]=ee,t[91]=de):de=t[91],de};function wS(t){return t.workStatusPanelVisible}function vS(t){return t.contextRailOrder}function SS(t){return t.contextRailHiddenSurfaces}function jS(t){return t.setContextRailOrder}function kS(t){return t.openContextSurface}function CS(t){return t.closeContextPanel}function NS(t){return t.shortcutOverrides}function AS(t){return t.planModeEnabled}function PS(t){return t.hasChecked}function DS(t){return t.status?.connected===!0}function IS(t){return t.hasChecked}function TS(t){return t.status?.connected===!0}function ES(t){return t.length===1&&t>="0"&&t<="9"}function RS(t){return t.countByGuest}function MS(t){return t.clearBadge}function OS(t){return t.id}function BS(t){return t.id}const FS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),_S=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Lr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),LS=new Set,$S=[],ka=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},zS=()=>{const t=tt.c(183),{t:e}=Nt(),n=Ne(WS),r=Ne(KS),i=Ne(VS),o=Ne(US),l=Ne(HS),a=Ne(GS),d=Ne(qS),u=Ne(YS),m=Ne(QS),f=Ne(XS),p=Ne(JS),y=Ne(ZS),x=Ne(e0),k=rt(t0),w=rt(s0),h=rt(n0),g=Qr(r0);let j;t[0]!==n?(j=He=>n?He.activeSessions:$S,t[0]=n,t[1]=j):j=t[1];const b=vs(j);let S;t[2]!==n?(S=He=>n?He.ids:LS,t[2]=n,t[3]=S):S=t[3];const C=Qr(S);let v;t[4]!==n?(v=He=>n?He.rankById:Ha,t[4]=n,t[5]=v):v=t[5];const E=Ua(v),R=os(o0),A=Ut(i0),O=Ut(a0),B=dr(),T=_d(l0),{files:M,git:L}=wn(),W=Tn(c0),{isMobile:$}=$n();let P;t[6]!==B?(P=B?ka(B):null,t[6]=B,t[7]=P):P=t[7];const D=P,[I,X]=c.useState(""),ne=ku(I,200).trim();let ue;t[8]!==I?(ue=I.trim(),t[8]=I,t[9]=ue):ue=t[9];const se=ue;let xe,ie;t[10]!==n?(xe=()=>{n&&X("")},ie=[n],t[10]=n,t[11]=xe,t[12]=ie):(xe=t[11],ie=t[12]),c.useEffect(xe,ie);let Re,be;t[13]!==b||t[14]!==W||t[15]!==L||t[16]!==n?(Re=()=>{if(!n||!L)return;const He=setTimeout(()=>{const Ue=new Set;for(const ve of b){const Qe=As(ve);!Qe||Ue.has(Qe)||(Ue.add(Qe),W(Qe,L))}},0);return()=>clearTimeout(He)},be=[n,b,L,W],t[13]=b,t[14]=W,t[15]=L,t[16]=n,t[17]=Re,t[18]=be):(Re=t[17],be=t[18]),c.useEffect(Re,be);let fe;t[19]!==r?(fe=()=>r(!1),t[19]=r,t[20]=fe):fe=t[20];const ke=fe;let H;t[21]!==ke?(H=He=>()=>{ke(),He()},t[21]=ke,t[22]=H):H=t[22];const J=H;let ce;t[23]!==A?.id||t[24]!==A?.path||t[25]!==R||t[26]!==h||t[27]!==$||t[28]!==d||t[29]!==u||t[30]!==p||t[31]!==k||t[32]!==J||t[33]!==y||t[34]!==x||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==g||t[39]!==a?(ce=()=>{const He=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(_,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:J(()=>{l(!1),k()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(_,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:J(d0)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(_,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:J(u0)},{id:"toggle-sidebar",title:e($?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(_,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e($?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:J(()=>{if($){const{isSessionSwitcherOpen:Ue}=Ne.getState();l(!Ue)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(_,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:J(()=>{R&&u(R,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(_,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:J(()=>{R&&d(R)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(_,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:J(f0)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(_,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:J(m0)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(_,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:J(()=>i(!0))}];return He.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(_,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:J(()=>{h&&R&&g({directory:R,sessionId:h})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(_,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:J(()=>{h&&cr(h).then(Ue=>{if(Ue.ok){Ke.success(e("sessions.sidebar.session.copyId.success"));return}Ke.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Ke.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(_,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:J(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(_,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:J(()=>{l(!1),y(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(_,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:J(()=>{R&&(x("notes"),u(R,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(_,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:J(()=>{R&&(x("todos"),u(R,"notes"))})}),He.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(_,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:J(h0)}),qr()&&He.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(_,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:J(()=>{Fn("desktop_open_draft_mini_chat_window",{directory:ka(R||A?.path||""),projectId:A?.id??null}).catch(p0)})}),He},t[23]=A?.id,t[24]=A?.path,t[25]=R,t[26]=h,t[27]=$,t[28]=d,t[29]=u,t[30]=p,t[31]=k,t[32]=J,t[33]=y,t[34]=x,t[35]=l,t[36]=i,t[37]=e,t[38]=g,t[39]=a,t[40]=ce):ce=t[40],A?.id,A?.path;let je;t[41]!==ce?(je=ce(),t[41]=ce,t[42]=je):je=t[42];const G=je,we=Ne(g0);let Te;t[43]===Symbol.for("react.memo_cache_sentinel")?(Te=xn(),t[43]=Te):Te=t[43];const he=Te;let re,ge;t[44]===Symbol.for("react.memo_cache_sentinel")?(re=_n(),ge=!he&&Ma(),t[44]=re,t[45]=ge):(re=t[44],ge=t[45]);let q;t[46]!==$||t[47]!==we?(q={isVSCode:re,isWeb:ge,isDesktop:he,isMobile:$,routingAvailable:we},t[46]=$,t[47]=we,t[48]=q):q=t[48];const z=q;let ee;if(t[49]!==J||t[50]!==i||t[51]!==o||t[52]!==z){let He;t[54]!==z?(He=ve=>ve.isAvailable?ve.isAvailable(z):!0,t[54]=z,t[55]=He):He=t[55];let Ue;t[56]!==J||t[57]!==i||t[58]!==o?(Ue=ve=>{const Qe=Nh(ve.slug)??"settings-3",qe=(ve.keywords??[]).join(" ");return{id:`settings:${ve.slug}`,title:ve.title,icon:ve.slug==="mcp"?s.jsx(eg,{className:"mr-2 h-4 w-4"}):s.jsx(_,{name:Qe,className:"mr-2 h-4 w-4"}),searchText:`${ve.title} ${ve.group} ${qe}`,onSelect:J(()=>{o(ve.slug),i(!0)})}},t[56]=J,t[57]=i,t[58]=o,t[59]=Ue):Ue=t[59],ee=Ch.filter(x0).filter(He).map(Ue),t[49]=J,t[50]=i,t[51]=o,t[52]=z,t[53]=ee}else ee=t[53];const de=ee;let Y;if(t[60]!==b||t[61]!==C||t[62]!==E){const He=b.filter(b0);Y=Qp(He,C,E),t[60]=b,t[61]=C,t[62]=E,t[63]=Y}else Y=t[63];const U=Y,F=Du(),V=rt(y0);let oe;t[64]!==F||t[65]!==V?(oe=(He,Ue)=>{const ve=V.get(He);return ve?.branch?ve.branch.trim()||null:Ue&&F.get(Ue)?.trim()||null},t[64]=F,t[65]=V,t[66]=oe):oe=t[66];const ae=oe;let pe;t[67]===Symbol.for("react.memo_cache_sentinel")?(pe=[],t[67]=pe):pe=t[67];const[le,_e]=c.useState(pe),[Fe,Me]=c.useState(""),Ae=FS(D,ne);let Q;t[68]!==D||t[69]!==Ae||t[70]!==n||t[71]!==T||t[72]!==_e||t[73]!==Me||t[74]!==ne?(Q=()=>{if(!n){_e([]),Me("");return}if(!Ae){_e([]),Me("");return}if(!D){_e([]),Me("");return}let He=!1;return T(D,ne,40,{type:"file"}).then(Ue=>{He||(_e(Ue.map(w0)),Me(Ae))}).catch(()=>{He||(_e([]),Me(Ae))}),()=>{He=!0}},t[68]=D,t[69]=Ae,t[70]=n,t[71]=T,t[72]=_e,t[73]=Me,t[74]=ne,t[75]=Q):Q=t[75];let Ce;t[76]!==D||t[77]!==Ae||t[78]!==n||t[79]!==T||t[80]!==ne?(Ce=[n,D,ne,Ae,T],t[76]=D,t[77]=Ae,t[78]=n,t[79]=T,t[80]=ne,t[81]=Ce):Ce=t[81],c.useEffect(Q,Ce);const Be=se.length>0;let Le;e:{if(!Be){let Ue;t[82]!==G?(Ue=G.filter(v0).map(S0),t[82]=G,t[83]=Ue):Ue=t[83],Le=Ue;break e}let He;t[84]!==G||t[85]!==se?(He=Lr(G,se,j0,{limit:7,noFuzzy:!0}),t[84]=G,t[85]=se,t[86]=He):He=t[86],Le=He}const Je=Le;let ot;e:{if(!Be){let Ue;t[87]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[87]=Ue):Ue=t[87],ot=Ue;break e}let He;t[88]!==se||t[89]!==de?(He=Lr(de,se,k0,{limit:7,noFuzzy:!0}),t[88]=se,t[89]=de,t[90]=He):He=t[90],ot=He}const et=ot;let it;e:{if(!Be){let Ue;t[91]!==U?(Ue=U.slice(0,5).map(C0),t[91]=U,t[92]=Ue):Ue=t[92],it=Ue;break e}let He;t[93]!==se||t[94]!==U?(He=Lr(U,se,N0,{limit:7,threshold:.2}),t[93]=se,t[94]=U,t[95]=He):He=t[95],it=He}const ht=it;let st;e:{if(!n){let Ue;t[96]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[96]=Ue):Ue=t[96],st=Ue;break e}let He;t[97]!==le||t[98]!==Fe||t[99]!==Ae||t[100]!==ne?(He=_S(le,ne,Ae,Fe),t[97]=le,t[98]=Fe,t[99]=Ae,t[100]=ne,t[101]=He):He=t[101],st=He}const mt=st,kt=n&&Ae.length>0&&Fe!==Ae;let Pe;e:{if(!Be){let Ue;t[102]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[102]=Ue):Ue=t[102],Pe=Ue;break e}let He;if(t[103]!==se||t[104]!==O){const Ue=O.map(A0);He=Lr(Ue,se,P0,{limit:7,threshold:.4}),t[103]=se,t[104]=O,t[105]=He}else He=t[105];Pe=He}const Ge=Pe;let at,ze,ft,te,me,De,K,Se,Ve,Xe,nt,Ze,gt,We;if(t[106]!==ae||t[107]!==ke||t[108]!==D||t[109]!==M||t[110]!==Be||t[111]!==n||t[112]!==m||t[113]!==k||t[114]!==I||t[115]!==Je||t[116]!==mt||t[117]!==Ge||t[118]!==ht||t[119]!==et||t[120]!==r||t[121]!==w||t[122]!==f||t[123]!==e){const He=Je.map(D0),Ue=et.map(I0),ve=ht.map(T0),Qe=Be?mt.map(E0):[],qe=Be?Ge.map(R0):[];let Ye;e:{if(!Be){Ye=["commands","sessions"];break e}const Ct=M0,Tt=[{key:"commands",score:Ct(Je)},{key:"settings",score:Ct(et)},{key:"sessions",score:Ct(ht)},{key:"files",score:Ct(mt)},{key:"projects",score:Ct(Ge)}];Tt.sort(O0),Ye=Tt.map(B0)}const dt=Ye,Ot=Ct=>{ke(),w(Ct.id,As(Ct))},zt=async Ct=>{if(!D)return;const Tt=await xf(M,Ct,{directory:D});if(!Tt.ok){Ke.error(bf(Tt.reason));return}m(D,Ct),ke()},Kt=(Ct,Tt)=>{ke(),k({selectedProjectId:Ct,directoryOverride:Tt})},Gt=Ct=>sr(so(Ct,f));te=Ps,Ze=n,gt=r;let Bt;t[138]!==e?(Bt=e("commandPalette.title"),t[138]=e,t[139]=Bt):Bt=t[139];let Jt;t[140]!==Bt?(Jt=s.jsx(Us,{children:Bt}),t[140]=Bt,t[141]=Jt):Jt=t[141];let Vt;t[142]!==e?(Vt=e("commandPalette.description"),t[142]=e,t[143]=Vt):Vt=t[143];let Wt;t[144]!==Vt?(Wt=s.jsx(Hs,{children:Vt}),t[144]=Vt,t[145]=Wt):Wt=t[145],t[146]!==Jt||t[147]!==Wt?(We=s.jsxs(sn,{className:"sr-only",children:[Jt,Wt]}),t[146]=Jt,t[147]=Wt,t[148]=We):We=t[148],ft=Ds,Xe="overflow-hidden p-0",nt=!0,ze=tg,K=!1,Se="[&_[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 _t;t[149]!==e?(_t=e("commandPalette.input.placeholder"),t[149]=e,t[150]=_t):_t=t[150],t[151]!==I||t[152]!==_t?(Ve=s.jsx(sg,{value:I,onValueChange:X,placeholder:_t}),t[151]=I,t[152]=_t,t[153]=Ve):Ve=t[153],at=ng;let Xt;t[154]!==e?(Xt=e("commandPalette.empty.noResults"),t[154]=e,t[155]=Xt):Xt=t[155],t[156]!==Xt?(me=s.jsx(rg,{children:Xt}),t[156]=Xt,t[157]=me):me=t[157],De=dt.map(Ct=>Ct==="commands"&&He.length>0?s.jsx(Dr,{children:He.map(Tt=>s.jsxs($r,{value:Tt.id,onSelect:Tt.onSelect,children:[Tt.icon,s.jsx("span",{children:Tt.title}),Tt.shortcutId?s.jsx(Xp,{children:Gt(Tt.shortcutId)}):null]},Tt.id))},"commands"):Ct==="settings"&&Ue.length>0?s.jsx(Dr,{children:Ue.map(F0)},"settings"):Ct==="sessions"&&ve.length>0?s.jsx(Dr,{children:ve.map(Tt=>{const is=Tt.title||e("commandPalette.session.untitled"),$s=As(Tt),cs=ae(Tt.id,$s);return s.jsxs($r,{value:`session:${Tt.id}`,onSelect:()=>Ot(Tt),children:[s.jsx(_,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:is}),cs?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(_,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:cs})]}):null]},Tt.id)})},"sessions"):Ct==="files"&&Qe.length>0?s.jsx(Dr,{children:Qe.map(Tt=>{const is=Jp(Tt.relativePath||Tt.name,{maxLength:80});return s.jsxs($r,{value:`file:${Tt.path}`,onSelect:()=>{zt(Tt.path)},children:[s.jsx(Ka,{filePath:Tt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":Tt.relativePath,children:is})]},`file:${Tt.path}`)})},"files"):Ct==="projects"&&qe.length>0?s.jsx(Dr,{children:qe.map(Tt=>{const is=Tt.displayName;return s.jsxs($r,{value:`project:${Tt.id}`,onSelect:()=>Kt(Tt.id,Tt.path),children:[s.jsx(_,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:is}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:Tt.path})]},`project:${Tt.id}`)})},"projects"):null),t[106]=ae,t[107]=ke,t[108]=D,t[109]=M,t[110]=Be,t[111]=n,t[112]=m,t[113]=k,t[114]=I,t[115]=Je,t[116]=mt,t[117]=Ge,t[118]=ht,t[119]=et,t[120]=r,t[121]=w,t[122]=f,t[123]=e,t[124]=at,t[125]=ze,t[126]=ft,t[127]=te,t[128]=me,t[129]=De,t[130]=K,t[131]=Se,t[132]=Ve,t[133]=Xe,t[134]=nt,t[135]=Ze,t[136]=gt,t[137]=We}else at=t[124],ze=t[125],ft=t[126],te=t[127],me=t[128],De=t[129],K=t[130],Se=t[131],Ve=t[132],Xe=t[133],nt=t[134],Ze=t[135],gt=t[136],We=t[137];let Et;t[158]!==kt||t[159]!==e?(Et=kt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=kt,t[159]=e,t[160]=Et):Et=t[160];let Ft;t[161]!==at||t[162]!==me||t[163]!==De||t[164]!==Et?(Ft=s.jsxs(at,{children:[me,De,Et]}),t[161]=at,t[162]=me,t[163]=De,t[164]=Et,t[165]=Ft):Ft=t[165];let Ie;t[166]!==ze||t[167]!==K||t[168]!==Se||t[169]!==Ve||t[170]!==Ft?(Ie=s.jsxs(ze,{shouldFilter:K,className:Se,children:[Ve,Ft]}),t[166]=ze,t[167]=K,t[168]=Se,t[169]=Ve,t[170]=Ft,t[171]=Ie):Ie=t[171];let yt;t[172]!==ft||t[173]!==Xe||t[174]!==nt||t[175]!==Ie?(yt=s.jsx(ft,{className:Xe,showCloseButton:nt,children:Ie}),t[172]=ft,t[173]=Xe,t[174]=nt,t[175]=Ie,t[176]=yt):yt=t[176];let At;return t[177]!==te||t[178]!==Ze||t[179]!==gt||t[180]!==We||t[181]!==yt?(At=s.jsxs(te,{open:Ze,onOpenChange:gt,children:[We,yt]}),t[177]=te,t[178]=Ze,t[179]=gt,t[180]=We,t[181]=yt,t[182]=At):At=t[182],At};function WS(t){return t.isCommandPaletteOpen}function KS(t){return t.setCommandPaletteOpen}function VS(t){return t.setSettingsDialogOpen}function US(t){return t.setSettingsPage}function HS(t){return t.setSessionSwitcherOpen}function GS(t){return t.toggleSidebar}function qS(t){return t.openContextOverview}function YS(t){return t.openContextSurface}function QS(t){return t.openContextFile}function XS(t){return t.shortcutOverrides}function JS(t){return t.openMultiRunLauncher}function ZS(t){return t.setArchivePageOpen}function e0(t){return t.setProjectContextTab}function t0(t){return t.openNewSessionDraft}function s0(t){return t.setCurrentSession}function n0(t){return t.currentSessionId}function r0(t){return t.toggle}function o0(t){return t.currentDirectory}function i0(t){return t.getActiveProject()}function a0(t){return t.projects}function l0(t){return t.searchFiles}function c0(t){return t.ensureStatus}function d0(){Iu()}function u0(){un.requestDirectoryDialog()}function f0(){og.invoke("cycle_theme")}function m0(){Tu()}function h0(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function p0(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function g0(t){return t.routingFeatureAvailable}function x0(t){return t.slug!=="home"}function b0(t){return!Zp(t)}function y0(t){return t.worktreeMetadata}function w0(t){return{path:ka(t.path),name:t.name,relativePath:t.relativePath}}function v0(t){return!t.secondary}function S0(t){return{item:t,score:0}}function j0(t){return t.searchText}function k0(t){return t.searchText}function C0(t){return{item:t,score:0}}function N0(t){return t.title||""}function A0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function P0(t){return t.searchText}function D0(t){return t.item}function I0(t){return t.item}function T0(t){return t.item}function E0(t){return t.item}function R0(t){return t.item}function M0(t){return t.length?t[0].score:1/0}function O0(t,e){return t.score-e.score}function B0(t){return t.key}function F0(t){return s.jsxs($r,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Fc=(t,e,n)=>sr(so(t,e),n),_0=()=>{const t=tt.c(74),{t:e}=Nt(),n=Ne(L0),r=Ne($0),i=Ne(z0);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=_n(),t[0]=o):o=t[0];const l=o;let a,d,u,m,f,p,y,x,k,w,h,g;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const P=[{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:[sr("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:[`${sr(sa("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${sr(sa("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:""}]}];u=Ps,h=n,g=r,d=Ds,k="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let D;t[17]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(_,{name:"command",className:"h-5 w-5"}),t[17]=D):D=t[17];let I;t[18]!==e?(I=e("helpDialog.title"),t[18]=e,t[19]=I):I=t[19];let X;t[20]!==I?(X=s.jsxs(Us,{className:"flex items-center gap-2",children:[D,I]}),t[20]=I,t[21]=X):X=t[21];let Z;t[22]!==e?(Z=e("helpDialog.description"),t[22]=e,t[23]=Z):Z=t[23];let ne;t[24]!==Z?(ne=s.jsx(Hs,{children:Z}),t[24]=Z,t[25]=ne):ne=t[25],t[26]!==X||t[27]!==ne?(w=s.jsxs(sn,{children:[X,ne]}),t[26]=X,t[27]=ne,t[28]=w):w=t[28],a=En,p="flex-1 min-h-0 mt-3",y="pr-1",x=!0,m="space-y-4",f=P.map(ue=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(ue.categoryKey)}),s.jsx("div",{className:"space-y-1",children:ue.items.filter(se=>!(l&&se.id==="toggle_prompt_navigator")).map(se=>{const xe=se.id?ig(se.id):void 0,ie=se.descriptionKey??(xe?.customizable?xe.settingsLabelKey:void 0);if(!ie||se.id&&!so(se.id,i))return null;const Re=se.id?Fc(se.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(se.keys)?se.keys:se.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:[se.icon&&s.jsx(_,{name:se.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(ie)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(Re)?Re:[Re]).map((be,fe)=>s.jsxs(c.Fragment,{children:[fe>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:be})]},`${be}-${fe}`))})]},se.id||ie)})})]},ue.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=d,t[7]=u,t[8]=m,t[9]=f,t[10]=p,t[11]=y,t[12]=x,t[13]=k,t[14]=w,t[15]=h,t[16]=g}else a=t[5],d=t[6],u=t[7],m=t[8],f=t[9],p=t[10],y=t[11],x=t[12],k=t[13],w=t[14],h=t[15],g=t[16];let j;t[29]!==m||t[30]!==f?(j=s.jsx("div",{className:m,children:f}),t[29]=m,t[30]=f,t[31]=j):j=t[31];let b;t[32]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(_,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=b):b=t[32];let S;t[33]!==e?(S=e("helpDialog.proTips.title"),t[33]=e,t[34]=S):S=t[34];let C;t[35]!==S?(C=s.jsx("p",{className:"font-medium mb-1",children:S}),t[35]=S,t[36]=C):C=t[36];let v;t[37]!==i||t[38]!==e?(v=e("helpDialog.proTips.commandPalette",{shortcut:Fc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=v):v=t[39];let E;t[40]!==v?(E=s.jsxs("li",{children:["• ",v]}),t[40]=v,t[41]=E):E=t[41];let R;t[42]!==e?(R=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=R):R=t[43];let A;t[44]!==R?(A=s.jsxs("li",{children:["• ",R]}),t[44]=R,t[45]=A):A=t[45];let O;t[46]!==e?(O=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=O):O=t[47];let B;t[48]!==O?(B=s.jsxs("li",{children:["• ",O]}),t[48]=O,t[49]=B):B=t[49];let T;t[50]!==E||t[51]!==A||t[52]!==B?(T=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[E,A,B]}),t[50]=E,t[51]=A,t[52]=B,t[53]=T):T=t[53];let M;t[54]!==C||t[55]!==T?(M=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[b,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[C,T]})]})}),t[54]=C,t[55]=T,t[56]=M):M=t[56];let L;t[57]!==a||t[58]!==j||t[59]!==M||t[60]!==p||t[61]!==y||t[62]!==x?(L=s.jsxs(a,{outerClassName:p,className:y,disableHorizontal:x,children:[j,M]}),t[57]=a,t[58]=j,t[59]=M,t[60]=p,t[61]=y,t[62]=x,t[63]=L):L=t[63];let W;t[64]!==d||t[65]!==L||t[66]!==k||t[67]!==w?(W=s.jsxs(d,{className:k,children:[w,L]}),t[64]=d,t[65]=L,t[66]=k,t[67]=w,t[68]=W):W=t[68];let $;return t[69]!==u||t[70]!==W||t[71]!==h||t[72]!==g?($=s.jsx(u,{open:h,onOpenChange:g,children:W}),t[69]=u,t[70]=W,t[71]=h,t[72]=g,t[73]=$):$=t[73],$};function L0(t){return t.isHelpDialogOpen}function $0(t){return t.setHelpDialogOpen}function z0(t){return t.shortcutOverrides}const W0=()=>{const t=tt.c(32),{t:e}=Nt(),n=Ne(K0),r=Ne(V0),i=Ne(U0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await cr(i)).ok){Ke.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Ke.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Us,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==u?(m=s.jsx(Hs,{children:u}),t[9]=u,t[10]=m):m=t[10];let f;t[11]!==d||t[12]!==m?(f=s.jsxs(sn,{children:[d,m]}),t[11]=d,t[12]=m,t[13]=f):f=t[13];let p;t[14]!==e?(p=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=p):p=t[15];let y;t[16]!==l||t[17]!==p?(y=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-ring",children:p})}),t[16]=l,t[17]=p,t[18]=y):y=t[18];let x;t[19]!==i||t[20]!==e?(x=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=x):x=t[21];let k;t[22]!==x?(k=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:x}),t[22]=x,t[23]=k):k=t[23];let w;t[24]!==f||t[25]!==y||t[26]!==k?(w=s.jsxs(Ds,{className:"max-w-2xl",children:[f,y,k]}),t[24]=f,t[25]=y,t[26]=k,t[27]=w):w=t[27];let h;return t[28]!==n||t[29]!==r||t[30]!==w?(h=s.jsx(Ps,{open:n,onOpenChange:r,children:w}),t[28]=n,t[29]=r,t[30]=w,t[31]=h):h=t[31],h};function K0(t){return t.isOpenCodeStatusDialogOpen}function V0(t){return t.setOpenCodeStatusDialogOpen}function U0(t){return t.openCodeStatusText}const H0=t=>{const e=tt.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const x=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(x)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let m,f;e[5]!==a||e[6]!==o||e[7]!==i?(m=()=>{if(!a||typeof window>"u")return;const x=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",x),()=>window.removeEventListener("openchamber:sidebar-session-search",x)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=m,e[9]=f):(m=e[8],f=e[9]),c.useEffect(m,f);let p,y;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const x=k=>{l.current&&(l.current.contains(k.target)||i(!1))};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},y=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=y):(p=e[14],y=e[15]),c.useEffect(p,y)},G0=t=>{const e=tt.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(q0)),u=[];a.forEach(p=>{const y=d.get(p);y&&(u.push(y),d.delete(p))});const m=[],f=[];return l.forEach(p=>{d.has(p.id)&&(p.isArchivedBucket?f.push(p):m.push(p))}),[...m,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function q0(t){return[t.id,t]}const wo="oc.sessions.projectCollapse",_c="oc.sessions.groupOrder",Lc="oc.sessions.groupCollapse",$c=t=>{if(!t)return new Set;try{const e=Za(lr()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},Y0=t=>{if(!t)return new Map;try{const e=nf(lr(),Za(lr())).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}},Q0=t=>{const e=tt.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=_o(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>$c(o.getItem(wo)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>$c(o.getItem(Lc)),e[2]=u):u=e[2];const[m,f]=c.useState(u);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>Y0(o.getItem(_c)),e[3]=p):p=e[3];const[y,x]=c.useState(p),k=c.useRef(0),w=c.useRef(!1),h=c.useRef(!1),g=c.useRef(null),j=c.useRef(null);let b;e[4]!==n?(b=()=>{if(n)return;const fe=j.current;if(j.current=null,g.current=null,!fe)return;const{projects:ke}=Ut.getState(),H=ke.map(J=>({...J,sidebarCollapsed:fe.has(J.id)}));Fr({projects:H}).catch(X0)},e[4]=n,e[5]=b):b=e[5];const S=b;let C;e[6]!==S||e[7]!==n?(C=fe=>{!globalThis.window||n||(j.current=fe,g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{S()},700))},e[6]=S,e[7]=n,e[8]=C):C=e[8];const v=C;let E,R;e[9]===Symbol.for("react.memo_cache_sentinel")?(E=()=>()=>{globalThis.window&&g.current!==null&&window.clearTimeout(g.current),g.current=null,j.current=null},R=[],e[9]=E,e[10]=R):(E=e[9],R=e[10]),c.useEffect(E,R);let A,O;e[11]!==y?(O=()=>{if(h.current)try{o.setItem(_c,JSON.stringify(Object.fromEntries(y.entries())))}catch{}},A=[y,o],e[11]=y,e[12]=A,e[13]=O):(A=e[12],O=e[13]),c.useEffect(O,A);let B,T;e[14]!==m?(B=()=>{if(w.current)try{o.setItem(Lc,JSON.stringify(Array.from(m)))}catch{}},T=[m,o],e[14]=m,e[15]=B,e[16]=T):(B=e[15],T=e[16]),c.useEffect(B,T);let M;e[17]!==r||e[18]!==v?(M=()=>{k.current=Date.now()+150,w.current=!0,f(new Set),d(()=>{const fe=new Set(r.map(J0));try{o.setItem(wo,JSON.stringify(Array.from(fe)))}catch{}return v(fe),fe})},e[17]=r,e[18]=v,e[19]=M):M=e[19];const L=M;let W;e[20]!==v?(W=()=>{k.current=Date.now()+150,w.current=!0,f(new Set),d(()=>{const fe=new Set;try{o.setItem(wo,JSON.stringify([]))}catch{}return v(fe),fe})},e[20]=v,e[21]=W):W=e[21];const $=W;let P;e[22]!==v?(P=fe=>{k.current=Date.now()+150,d(ke=>{const H=new Set(ke);H.has(fe)?H.delete(fe):H.add(fe);try{o.setItem(wo,JSON.stringify(Array.from(H)))}catch{}return v(H),H})},e[22]=v,e[23]=P):P=e[23];const D=P;let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=fe=>{w.current=!0,f(ke=>{const H=new Set(ke);return H.has(fe)?H.delete(fe):H.add(fe),H})},e[24]=I):I=e[24];const X=I;let Z;e[25]===Symbol.for("react.memo_cache_sentinel")?(Z=fe=>{h.current=!0,x(fe)},e[25]=Z):Z=e[25];const ne=Z,{getOrderedGroups:ue}=G0(y);let se;e[26]!==m||e[27]!==a||e[28]!==y?(se={collapsedProjects:a,collapsedGroups:m,groupOrderByProject:y},e[26]=m,e[27]=a,e[28]=y,e[29]=se):se=e[29];const xe=se;let ie;e[30]!==L||e[31]!==$||e[32]!==ue||e[33]!==v||e[34]!==D?(ie={setCollapsedProjects:d,toggleProject:D,collapseAllProjects:L,expandAllProjects:$,scheduleCollapsedProjectsPersist:v,setCollapsedGroups:f,toggleGroup:X,setGroupOrderByProject:ne,getOrderedGroups:ue},e[30]=L,e[31]=$,e[32]=ue,e[33]=v,e[34]=D,e[35]=ie):ie=e[35];const Re=ie;let be;return e[36]!==Re||e[37]!==xe?(be={state:xe,actions:Re},e[36]=Re,e[37]=xe,e[38]=be):be=e[38],be};function X0(){}function J0(t){return t.id}const Z0=5*6e4,ej=t=>{const e=tt.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=wn(),u=Tn(tj);let m,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(m=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(C=>{na(()=>u(C.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=m,e[6]=f):(m=e[5],f=e[6]),c.useEffect(m,f);let p,y;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(v=>{C.set(v.id,i.get(v.normalizedPath)?.isGitRepo??null)}),o(C)},y=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=y):(p=e[11],y=e[12]),c.useEffect(p,y);let x;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=v=>{const E=i.get(v.normalizedPath)?.branch??"";return`${v.id}:${E}`},e[16]=i,e[17]=C):C=e[17],x=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=x}else x=e[15];const k=x;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w=new Map,e[18]=w):w=e[18];const h=c.useRef(w);let g;e[19]===Symbol.for("react.memo_cache_sentinel")?(g=new Map,e[19]=g):g=e[19];const j=c.useRef(g);let b;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(b=()=>{if(!a)return;let C=!1;const v=setTimeout(()=>{(async()=>{const R=new Set(n.map(sj));for(const L of h.current.keys())R.has(L)||(h.current.delete(L),j.current.delete(L));const A=Date.now(),O=n.filter(L=>{const W=i.get(L.normalizedPath);if(W?.isGitRepo===!1)return h.current.delete(L.id),j.current.delete(L.id),!1;if(W?.isGitRepo!==!0||W.branch===null)return!1;const $=W.branch.trim(),P=`${L.normalizedPath}\0${$}`,D=h.current.get(L.id);if(D===P){const I=j.current.get(L.id);return I&&(I.at=A),!1}return!(D!==void 0&&A-(j.current.get(L.id)?.at??0)<Z0)});if(O.length===0)return;const B=await ag(O,2,async L=>{const W=i.get(L.normalizedPath)?.branch?.trim()??"",$=`${L.normalizedPath}\0${W}`,P=await na(()=>za(L.normalizedPath,W?{knownBranch:W}:void 0)).catch(nj);return{id:L.id,inputKey:$,branch:P}});if(C)return;const T=B.filter(rj);if(T.length===0)return;const M=Date.now();l(L=>{const W=new Map(L);return T.forEach($=>{const{id:P,branch:D}=$;D&&W.set(P,D)}),W}),T.forEach(L=>{const{id:W,inputKey:$,branch:P}=L;h.current.set(W,$),P&&j.current.set(W,{branch:P,at:M})})})()},150);return()=>{C=!0,clearTimeout(v)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=b):b=e[24];let S;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==k||e[29]!==l?(S=[a,n,k,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=k,e[29]=l,e[30]=S):S=e[30],c.useEffect(b,S)};function tj(t){return t.ensureStatus}function sj(t){return t.id}function nj(){return null}function rj(t){return t.branch}const oj=t=>{const e=tt.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(Ah,{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(Ds,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(En,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(Ps,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function ij(t){const e=tt.c(197),{t:n}=Nt(),r=Eu(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenMultiRun:u,canOpenMultiRun:m,onOpenArchive:f,headerActionIconClass:p,headerActionButtonClass:y,isSessionSearchOpen:x,setIsSessionSearchOpen:k,sessionSearchInputRef:w,sessionSearchQuery:h,setSessionSearchQuery:g,hasSessionSearchQuery:j,searchMatchCount:b,collapseAllProjects:S,expandAllProjects:C}=t,v=ms(bj),E=ms(xj),R=Ns(gj),A=Ns(pj),O=Ns(hj),B=Ns(mj),T=Ns(fj),M=Ns(uj),L=Ns(dj),W=Ns(cj),$=o&&L==="single",P=o&&T==="timeline";if(i)return null;let D;e[0]!==y?(D=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=y,e[1]=D):D=e[1];let I;e[2]!==n?(I=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=I):I=e[3];let X;e[4]!==p?(X=s.jsx(_,{name:"folder-add",className:p}),e[4]=p,e[5]=X):X=e[5];let Z;e[6]!==a||e[7]!==D||e[8]!==I||e[9]!==X?(Z=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:D,"aria-label":I,children:X})}),e[6]=a,e[7]=D,e[8]=I,e[9]=X,e[10]=Z):Z=e[10];let ne;e[11]!==n?(ne=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=ne):ne=e[12];let ue;e[13]!==ne?(ue=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ne})}),e[13]=ne,e[14]=ue):ue=e[14];let se;e[15]!==Z||e[16]!==ue?(se=s.jsxs(vt,{children:[Z,ue]}),e[15]=Z,e[16]=ue,e[17]=se):se=e[17];let xe;e[18]!==y?(xe=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=y,e[19]=xe):xe=e[19];let ie;e[20]!==n?(ie=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=ie):ie=e[21];let Re;e[22]!==p?(Re=s.jsx(_,{name:"calendar-schedule",className:p}),e[22]=p,e[23]=Re):Re=e[23];let be;e[24]!==d||e[25]!==xe||e[26]!==ie||e[27]!==Re?(be=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:xe,"aria-label":ie,children:Re})}),e[24]=d,e[25]=xe,e[26]=ie,e[27]=Re,e[28]=be):be=e[28];let fe;e[29]!==n?(fe=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=fe):fe=e[30];let ke;e[31]!==fe?(ke=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:fe})}),e[31]=fe,e[32]=ke):ke=e[32];let H;e[33]!==be||e[34]!==ke?(H=s.jsxs(vt,{children:[be,ke]}),e[33]=be,e[34]=ke,e[35]=H):H=e[35];let J;e[36]!==y?(J=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=y,e[37]=J):J=e[37];let ce;e[38]!==n?(ce=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=ce):ce=e[39];const je=!m;let G;e[40]!==p?(G=s.jsx(dg,{className:p}),e[40]=p,e[41]=G):G=e[41];let we;e[42]!==u||e[43]!==J||e[44]!==ce||e[45]!==je||e[46]!==G?(we=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:J,"aria-label":ce,disabled:je,children:G})}),e[42]=u,e[43]=J,e[44]=ce,e[45]=je,e[46]=G,e[47]=we):we=e[47];let Te;e[48]!==n?(Te=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=Te):Te=e[49];let he;e[50]!==Te?(he=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Te})}),e[50]=Te,e[51]=he):he=e[51];let re;e[52]!==we||e[53]!==he?(re=s.jsxs(vt,{children:[we,he]}),e[52]=we,e[53]=he,e[54]=re):re=e[54];let ge;e[55]!==y?(ge=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=y,e[56]=ge):ge=e[56];let q;e[57]!==n?(q=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=q):q=e[58];let z;e[59]!==p?(z=s.jsx(_,{name:"archive",className:p}),e[59]=p,e[60]=z):z=e[60];let ee;e[61]!==f||e[62]!==ge||e[63]!==q||e[64]!==z?(ee=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:ge,"aria-label":q,children:z})}),e[61]=f,e[62]=ge,e[63]=q,e[64]=z,e[65]=ee):ee=e[65];let de;e[66]!==n?(de=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=de):de=e[67];let Y;e[68]!==de?(Y=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:de})}),e[68]=de,e[69]=Y):Y=e[69];let U;e[70]!==ee||e[71]!==Y?(U=s.jsxs(vt,{children:[ee,Y]}),e[70]=ee,e[71]=Y,e[72]=U):U=e[72];let F;e[73]!==r||e[74]!==p||e[75]!==n?(F=r.length>0&&s.jsxs(Ls,{children:[s.jsx(Fs,{asChild:!0,children:s.jsx(ct,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(_,{name:"apps",className:p})})}),s.jsxs(_s,{align:"start",children:[s.jsx(_r,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(lj)]})]}),e[73]=r,e[74]=p,e[75]=n,e[76]=F):F=e[76];let V;e[77]!==H||e[78]!==re||e[79]!==U||e[80]!==F||e[81]!==se?(V=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[se,H,re,U,F]}),e[77]=H,e[78]=re,e[79]=U,e[80]=F,e[81]=se,e[82]=V):V=e[82];let oe;e[83]!==k?(oe=()=>k(aj),e[83]=k,e[84]=oe):oe=e[84];let ae;e[85]!==y?(ae=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=y,e[86]=ae):ae=e[86];let pe;e[87]!==n?(pe=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=pe):pe=e[88];let le;e[89]!==p?(le=s.jsx(_,{name:"search",className:p}),e[89]=p,e[90]=le):le=e[90];let _e;e[91]!==x||e[92]!==oe||e[93]!==ae||e[94]!==pe||e[95]!==le?(_e=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:oe,className:ae,"aria-label":pe,"aria-expanded":x,children:le})}),e[91]=x,e[92]=oe,e[93]=ae,e[94]=pe,e[95]=le,e[96]=_e):_e=e[96];let Fe;e[97]!==n?(Fe=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=Fe):Fe=e[98];let Me;e[99]!==Fe?(Me=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Fe})}),e[99]=Fe,e[100]=Me):Me=e[100];let Ae;e[101]!==_e||e[102]!==Me?(Ae=s.jsxs(vt,{children:[_e,Me]}),e[101]=_e,e[102]=Me,e[103]=Ae):Ae=e[103];const Q=v&&"bg-interactive-hover text-primary";let Ce;e[104]!==y||e[105]!==Q?(Ce=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent",Q),e[104]=y,e[105]=Q,e[106]=Ce):Ce=e[106];let Be;e[107]!==v||e[108]!==n?(Be=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=v,e[108]=n,e[109]=Be):Be=e[109];let Le;e[110]!==p?(Le=s.jsx(_,{name:"checkbox-multiple",className:p}),e[110]=p,e[111]=Le):Le=e[111];let Je;e[112]!==v||e[113]!==Ce||e[114]!==Be||e[115]!==Le||e[116]!==E?(Je=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:E,className:Ce,"aria-label":Be,"aria-pressed":v,children:Le})}),e[112]=v,e[113]=Ce,e[114]=Be,e[115]=Le,e[116]=E,e[117]=Je):Je=e[117];let ot;e[118]!==v||e[119]!==n?(ot=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=v,e[119]=n,e[120]=ot):ot=e[120];let et;e[121]!==ot?(et=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ot})}),e[121]=ot,e[122]=et):et=e[122];let it;e[123]!==Je||e[124]!==et?(it=s.jsxs(vt,{children:[Je,et]}),e[123]=Je,e[124]=et,e[125]=it):it=e[125];let ht;e[126]!==y?(ht=Ee(y,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=y,e[127]=ht):ht=e[127];let st;e[128]!==n?(st=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=st):st=e[129];let mt;e[130]!==p?(mt=s.jsx(_,{name:"equalizer-2",className:p}),e[130]=p,e[131]=mt):mt=e[131];let kt;e[132]!==ht||e[133]!==st||e[134]!==mt?(kt=s.jsx(St,{asChild:!0,children:s.jsx(Fs,{asChild:!0,children:s.jsx("button",{type:"button",className:ht,"aria-label":st,children:mt})})}),e[132]=ht,e[133]=st,e[134]=mt,e[135]=kt):kt=e[135];let Pe;e[136]!==n?(Pe=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=Pe):Pe=e[137];let Ge;e[138]!==Pe?(Ge=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Pe})}),e[138]=Pe,e[139]=Ge):Ge=e[139];let at;e[140]!==kt||e[141]!==Ge?(at=s.jsxs(vt,{children:[kt,Ge]}),e[140]=kt,e[141]=Ge,e[142]=at):at=e[142];let ze;e[143]!==M||e[144]!==o||e[145]!==T||e[146]!==n||e[147]!==P?(ze=o?s.jsxs(s.Fragment,{children:[s.jsx(_r,{children:n("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(Ze=>{const[gt,We]=Ze;return s.jsxs(Ht,{onClick:()=>{M(gt),Fr({sidebarViewMode:gt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(We)}),T===gt?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},gt)}),P?null:s.jsx(Es,{})]}):null,e[143]=M,e[144]=o,e[145]=T,e[146]=n,e[147]=P,e[148]=ze):ze=e[148];let ft;e[149]!==L||e[150]!==O||e[151]!==W||e[152]!==B||e[153]!==o||e[154]!==n||e[155]!==P?(ft=P?null:s.jsxs(s.Fragment,{children:[s.jsx(_r,{children:n("sessions.sidebar.header.actions.sortProjects")}),[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(Ze=>{const[gt,We]=Ze;return s.jsxs(Ht,{onClick:()=>{B(gt),Fr({sidebarProjectSortOrder:gt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(We)}),O===gt?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},gt)}),s.jsx(Es,{}),o?s.jsxs(s.Fragment,{children:[s.jsx(_r,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Ze=>{const[gt,We]=Ze;return s.jsxs(Ht,{onClick:()=>{W(gt),Fr({sidebarProjectDisplayMode:gt})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(We)}),L===gt?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]},gt)}),s.jsx(Es,{})]}):null]}),e[149]=L,e[150]=O,e[151]=W,e[152]=B,e[153]=o,e[154]=n,e[155]=P,e[156]=ft):ft=e[156];let te;e[157]!==$||e[158]!==l||e[159]!==R||e[160]!==n||e[161]!==P||e[162]!==A?(te=!P&&l&&!$?s.jsxs(Ht,{onClick:()=>{A(),Fr({sidebarShowRecentSection:!R})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),R?s.jsx(_,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[157]=$,e[158]=l,e[159]=R,e[160]=n,e[161]=P,e[162]=A,e[163]=te):te=e[163];let me;e[164]!==S||e[165]!==C||e[166]!==$||e[167]!==n||e[168]!==P?(me=!P&&!$?s.jsxs(s.Fragment,{children:[s.jsx(Es,{}),s.jsxs(Ht,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(_,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Ht,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(_,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[164]=S,e[165]=C,e[166]=$,e[167]=n,e[168]=P,e[169]=me):me=e[169];let De;e[170]!==ze||e[171]!==ft||e[172]!==te||e[173]!==me?(De=s.jsxs(_s,{align:"end",className:"min-w-[180px]",children:[ze,ft,te,me]}),e[170]=ze,e[171]=ft,e[172]=te,e[173]=me,e[174]=De):De=e[174];let K;e[175]!==at||e[176]!==De?(K=s.jsxs(Ls,{children:[at,De]}),e[175]=at,e[176]=De,e[177]=K):K=e[177];let Se;e[178]!==Ae||e[179]!==it||e[180]!==K?(Se=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Ae,it,K]}),e[178]=Ae,e[179]=it,e[180]=K,e[181]=Se):Se=e[181];let Ve;e[182]!==V||e[183]!==Se?(Ve=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[V,Se]}),e[182]=V,e[183]=Se,e[184]=Ve):Ve=e[184];let Xe;e[185]!==j||e[186]!==x||e[187]!==b||e[188]!==w||e[189]!==h||e[190]!==k||e[191]!==g||e[192]!==n?(Xe=x?s.jsx("div",{className:"pb-1",children:s.jsx(Qd,{inputRef:w,value:h,onSearch:g,onClose:()=>k(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:j?b===1?n("sessions.sidebar.header.search.matchCountSingle",{count:b}):n("sessions.sidebar.header.search.matchCountPlural",{count:b}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[185]=j,e[186]=x,e[187]=b,e[188]=w,e[189]=h,e[190]=k,e[191]=g,e[192]=n,e[193]=Xe):Xe=e[193];let nt;return e[194]!==Ve||e[195]!==Xe?(nt=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:[Ve,Xe]})}),e[194]=Ve,e[195]=Xe,e[196]=nt):nt=e[196],nt}function aj(t){return!t}function lj(t){return s.jsxs(Ht,{onSelect:()=>Ne.getState().setOpenGuestPage(t.id),children:[s.jsx(to,{icon:cg(t.icon),iconSrc:lg(t.id,t.icon,Ld().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function cj(t){return t.setProjectDisplayMode}function dj(t){return t.projectDisplayMode}function uj(t){return t.setSidebarViewMode}function fj(t){return t.sidebarViewMode}function mj(t){return t.setProjectSortOrder}function hj(t){return t.projectSortOrder}function pj(t){return t.toggleRecentSection}function gj(t){return t.showRecentSection}function xj(t){return t.toggleMode}function bj(t){return t.enabled}const vo="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-ring";function yj(t){const e=tt.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,m=d===void 0?!0:d,{t:f}=Nt();if(!u&&!m)return null;let p;e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==f?(p=u?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:vo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(_,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:vo,"aria-label":f("usageStats.openAction"),children:s.jsx(_,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("usageStats.openAction")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:vo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(_,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:vo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(_,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=r,e[4]=u,e[5]=f,e[6]=p):p=e[6];let y;e[7]!==l||e[8]!==m||e[9]!==f?(y=m?s.jsx(ct,{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:l,children:f("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=m,e[9]=f,e[10]=y):y=e[10];let x;return e[11]!==p||e[12]!==y?(x=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[p,y]}),e[11]=p,e[12]=y,e[13]=x):x=e[13],x}const wj=t=>{for(const e of t.sessions.values())if(e.tabs.some(zd))return!0;return!1},vj=()=>{const t=tt.c(4),{terminal:e}=wn(),n=Mt(wj);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=Sj,l=jj;if(n)return Gi(e,"",l,o);let a=kj;return a=Gi(e,"",l,d=>{o(d),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 Sj(t){const e=Mt.getState(),n=Ph(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 jj(){return new Map(Mt.getState().actionMutationRevisions)}function kj(){}const Cj=t=>{const e=tt.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:m,addSessionToFolder:f}=t,p=r===void 0?!0:r;let y,x;e[0]!==f||e[1]!==m||e[2]!==p||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(y=()=>{!p||o||!l||a||n.forEach(k=>{if(d.has(k.normalizedPath))return;const w=Ru(k.normalizedPath),h=i.archivedSessionsByProject.get(k.id)??[],g=u[w]??[],j=new Map(g.map(Nj));h.forEach(b=>{const S=ug(b,k.normalizedPath),C=S.toLowerCase();let v=j.get(C);v||(v=m(w,S),j.set(C,v)),v.sessionIds.includes(b.id)||f(w,v.id,b.id)})})},x=[n,p,i,o,l,a,d,u,m,f],e[0]=f,e[1]=m,e[2]=p,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=y,e[11]=x):(y=e[10],x=e[11]),c.useEffect(y,x)};function Nj(t){return[t.name.toLowerCase(),t]}function Aj({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([m,f])=>m!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const Pj=t=>{const e=tt.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:m,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let y,x;if(e[0]!==n){x=new Map,y=new Map;const C=(v,E,R,A)=>{x.has(v)||x.set(v,new Map);const O=x.get(v);A.forEach(B=>{const T=xt(B.worktree?.path??B.session.directory??R??E);O.set(B.session.id,{directory:T}),y.has(v)||y.set(v,{id:B.session.id,directory:T}),B.children.length>0&&C(v,E,T,B.children)})};n.forEach(v=>{v.groups.forEach(E=>{C(v.project.id,v.project.normalizedPath,E.directory,E.sessions)})}),e[0]=n,e[1]=y,e[2]=x}else y=e[1],x=e[2];let k;e[3]!==y||e[4]!==x?(k={metaByProject:x,firstSessionByProject:y},e[3]=y,e[4]=x,e[5]=k):k=e[5];const w=k,h=c.useRef(null);let g,j;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==m||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==w||e[16]!==o||e[17]!==p?(g=()=>{if(!r||u||Ne.getState().isNewWorktreeDialogOpen||h.current===r)return;const C=n.find(A=>A.project.id===r);if(!C)return;const v=w.metaByProject.get(r);if(l&&v&&v.has(l)){h.current=r,o(A=>{if(A.get(r)===l)return A;const O=new Map(A);return O.set(r,l),O});return}const E=Aj({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:v,metaByProject:w.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:w.firstSessionByProject.get(r)?.id??null});if(E.kind==="preserve-current"){a===r&&(h.current=r);return}if(h.current=r,E.kind==="open-draft"){m&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(E.kind!=="select-session")return;const R=v?.get(E.sessionId)?.directory??null;d(E.sessionId,R)},j=[r,i,l,a,d,u,m,f,n,w,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=m,e[12]=u,e[13]=f,e[14]=n,e[15]=w,e[16]=o,e[17]=p,e[18]=g,e[19]=j):(g=e[18],j=e[19]),c.useLayoutEffect(g,j);let b,S;e[20]!==r||e[21]!==l||e[22]!==w||e[23]!==o?(b=()=>{if(!r||!l)return;const C=w.metaByProject.get(r);!C||!C.has(l)||o(v=>{if(v.get(r)===l)return v;const E=new Map(v);return E.set(r,l),E})},S=[r,l,w,o],e[20]=r,e[21]=l,e[22]=w,e[23]=o,e[24]=b,e[25]=S):(b=e[24],S=e[25]),c.useEffect(b,S)},Dj=t=>{const e=tt.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=rt(Ij),a=rt(Tj);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let m;e[8]!==r?(m=()=>new Map(r),e[8]=r,e[9]=m):m=e[9];const[f,p]=c.useState(m);let y;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(y={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=y):y=e[15],Pj(y);let x,k;return e[16]!==f||e[17]!==i?(x=()=>{i(f)},k=[f,i],e[16]=f,e[17]=i,e[18]=x,e[19]=k):(x=e[18],k=e[19]),c.useEffect(x,k),null};function Ij(t){return t.currentSessionId}function Tj(t){return!!t.newSessionDraft?.open}const Ej=t=>{const e=tt.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},Yn=(t,e)=>`${t}\0${e}`,Zn=(t,e)=>t??Ga(e)??xt(e??null),Jr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??xt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},ll=t=>t.startsWith("__archived__:"),Rj=(t,e)=>t.map(n=>{const r=xt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
879
879
  `),Mj=[],Oj=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:m,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:p,buildGroupSearchText:y,foldersMap:x,standaloneGroups:k}=t,w=c.useRef(new Map),h=c.useMemo(()=>{const R=w.current,A=new Map;let O=0,B=0;const T=(L,W)=>L.length===W.length&&L.every(($,P)=>$===W[P]),M=e.map(L=>{const W=n(L.id),$=r(L.id),P=i.get(L.normalizedPath)??Mj,D=o.has(L.id)?!!o.get(L.id):d,I=l.get(L.id)??null,X=Rj(P,a),Z=R.get(L.id);if(Z&&Z.project===L&&T(Z.activeSessions,W)&&T(Z.archivedSessions,$)&&Z.availableWorktrees===P&&Z.rootBranch===I&&Z.worktreeBranchesKey===X&&Z.isRepo===D&&Z.buildGroupedSessions===u)return O+=1,A.set(L.id,Z),Z.section;if(B+=1,Z){const xe=Z.project!==L?"project":T(Z.activeSessions,W)?T(Z.archivedSessions,$)?Z.availableWorktrees!==P?"worktrees":Z.rootBranch!==I?"branch":Z.worktreeBranchesKey!==X?"worktreeBranches":Z.isRepo!==D?"repo":"builder":"archived":"sessions";Ts(`ui.sidebar.project_section.rebuilt_reason.${xe}`)}const ne=Mu([...W,...$]),ue=u(ne,L.normalizedPath,P,I,D),se={project:L,groups:ue};return A.set(L.id,{project:L,activeSessions:W,archivedSessions:$,availableWorktrees:P,rootBranch:I,worktreeBranchesKey:X,isRepo:D,buildGroupedSessions:u,section:se}),se});return w.current=A,O>0&&Ts("ui.sidebar.project_section.reused",O),B>0&&Ts("ui.sidebar.project_section.rebuilt",B),M},[e,n,r,i,o,d,u,l,a]),g=c.useMemo(()=>h,[h]),j=c.useMemo(()=>{const R=new WeakMap;if(!m)return R;const A=f.trim().toLowerCase(),O=A.startsWith("ses_"),B=M=>M.reduce((L,W)=>L+(!O||W.session.id.toLowerCase()===A?1:0)+B(W.children),0),T=M=>{const L=p(M.sessions,f),W=B(L),$=!O&&$o([y(M)],f),P=Jr(M).flatMap(({scopeKey:I})=>x[I]??[]),D=O?0:P.filter(I=>$o([I.name],f)).length;R.set(M,{filteredNodes:L,matchedSessionCount:W,folderNameMatchCount:D,groupMatches:$,hasMatch:$||W>0||D>0})};return g.forEach(M=>{M.groups.forEach(T)}),k.forEach(T),R},[m,g,k,p,f,y,x]),b=c.useMemo(()=>m?g.map(R=>({...R,groups:R.groups.filter(A=>j.get(A)?.hasMatch===!0)})).filter(R=>R.groups.length>0):g,[m,g,j]),S=m?b:g,C=c.useRef(new WeakMap),v=c.useMemo(()=>{const R=C.current;return S.map(A=>{const O=R.get(A);if(O&&O.query===f)return O.section;const B=A.groups.filter(D=>!D.isArchivedBucket),T=A.groups.filter(D=>D.isArchivedBucket),M=B.flatMap(D=>m?j.get(D)?.filteredNodes??[]:D.sessions),L=B.map(D=>({scopeKey:D.folderScopeKey??xt(D.directory??null),directory:D.directory??null})).filter(D=>!!D.scopeKey),W=B.find(D=>D.isMain)??null,$={id:"flat",label:W?.label??"",branch:W?.branch??null,description:W?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:W?.directory??A.project.normalizedPath,folderScopeKey:W?.folderScopeKey??A.project.normalizedPath,folderScopes:L,sessions:M};if(m){const D=B.map(I=>j.get(I)).filter(I=>!!I);j.set($,{filteredNodes:M,matchedSessionCount:D.reduce((I,X)=>I+X.matchedSessionCount,0),folderNameMatchCount:D.reduce((I,X)=>I+X.folderNameMatchCount,0),groupMatches:D.some(I=>I.groupMatches),hasMatch:D.some(I=>I.hasMatch)})}const P={project:A.project,groups:[$,...T]};return R.set(A,{query:f,section:P}),P})},[j,m,f,S]),E=c.useMemo(()=>{if(!m)return 0;const R=(O,B)=>{const T=j.get(B);if(!T)return O;const M=T.folderNameMatchCount+(T.groupMatches?1:0);return O+T.matchedSessionCount+M},A=S.reduce((O,B)=>B.groups.reduce(R,O),0);return k.reduce(R,A)},[m,S,k,j]);return{projectSections:h,visibleProjectSections:g,groupSearchDataByGroup:j,searchableProjectSections:b,sectionsForRender:S,flatSectionsForRender:v,searchMatchCount:E}},Bj=180,zc=150,Fj=2,_j=8,Wc=[-1,1],Li=t=>`${t.directory}
880
880
  ${t.sessionId}`,Lj=t=>t?.directory?.trim()||null,$j=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>_n(),[]),m=c.useCallback(()=>{d.current+=1,l.current=[],o.current.forEach(y=>window.clearTimeout(y)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<Fj&&l.current.length>0;){const y=l.current.shift();if(!y)break;if(y.generation!==d.current||rt.getState().currentSessionId===y.sessionId||ra(y.sessionId,y.directory).renderable)continue;const k=Li(y);a.current.add(k),i({directory:y.directory,sessionID:y.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(k),f()})}},[t,u,i]),p=c.useCallback(y=>{const x=y?.id,k=Lj(y);if(!t||u||!x||!k||x===e)return;const w={sessionId:x,directory:k,generation:d.current},h=Li(w);if(ra(x,k).renderable||a.current.has(h)||l.current.some(b=>Li(b)===h))return;const g=o.current.get(h);g!==void 0&&window.clearTimeout(g);const j=window.setTimeout(()=>{if(o.current.delete(h),w.generation!==d.current)return;const b=l.current;b.length>=_j&&b.shift(),b.push(w),f()},Bj);o.current.set(h,j)},[e,t,u,f]);c.useEffect(()=>{m()},[m,e,t,u]),c.useEffect(()=>{if(!t||u||!e||n.length===0)return;const y=window.setTimeout(()=>{const x=n.findIndex(k=>k.id===e);if(!(x<0))for(const k of Wc)p(n[x+k])},zc);return()=>window.clearTimeout(y)},[e,t,u,p,n]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const y=window.setTimeout(()=>{const x=r.findIndex(k=>k.id===e);if(!(x<0))for(const k of Wc)p(r[x+k])},zc);return()=>window.clearTimeout(y)},[e,t,u,r,p]),c.useEffect(()=>m,[m])},zj=t=>{const e=tt.c(3),n=rt(Wj);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],$j(r),null};function Wj(t){return t.currentSessionId}const Kj=(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}},cl=t=>{const e=tt.c(15),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==o||e[1]!==n?(l=o?n:[],e[0]=o,e[1]=n,e[2]=l):l=e[2];let a;e[3]!==r||e[4]!==l?(a=Kj(l,r),e[3]=r,e[4]=l,e[5]=a):a=e[5];const d=a;let u;e[6]!==o||e[7]!==d.active?(u=k=>{if(!o)return null;for(const w of d.active){const h=k.statusById.get(w)?.status.type;if(h==="busy"||h==="retry")return"active"}return null},e[6]=o,e[7]=d.active,e[8]=u):u=e[8];const m=si(u);let f;e[9]!==o||e[10]!==d.unread?(f=k=>{if(!o)return null;for(const w of d.unread)if((k.index.session.unseenCount[w]??0)>0)return"unread";return null},e[9]=o,e[10]=d.unread,e[11]=f):f=e[11];const p=qa(f);let y;return e[12]!==o||e[13]!==d.active?(y=k=>{if(!o)return null;let w=null;for(const h of d.active){const g=k.bySession.get(h);if(g){if(g.permissions.length>0)return"permission";g.forms.length>0&&(w="form")}}return w},e[12]=o,e[13]=d.active,e[14]=y):y=e[14],Ya(y)??m??p};function $f(t){const e=tt.c(19),{state:n,className:r}=t,{t:i}=Nt();if(n==="permission"||n==="form"){let u;e[0]!==n||e[1]!==i?(u=i(n==="permission"?"sessions.sidebar.session.status.permissionRequired":"sessions.sidebar.session.status.questionPending"),e[0]=n,e[1]=i,e[2]=u):u=e[2];const m=u,f=n==="permission"?"text-destructive":"text-status-info";let p;e[3]!==r||e[4]!==f?(p=Ee("inline-flex shrink-0 items-center",f,r),e[3]=r,e[4]=f,e[5]=p):p=e[5];const y=n==="permission"?"shield":"question";let x;e[6]!==y?(x=s.jsx(_,{name:y,className:"h-3 w-3"}),e[6]=y,e[7]=x):x=e[7];let k;return e[8]!==m||e[9]!==p||e[10]!==x?(k=s.jsx("span",{className:p,"aria-label":m,title:m,children:x}),e[8]=m,e[9]=p,e[10]=x,e[11]=k):k=e[11],k}let o;e[12]!==n||e[13]!==i?(o=i(n==="active"?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[12]=n,e[13]=i,e[14]=o):o=e[14];const l=o,a=n==="active"?"running":"unread";let d;return e[15]!==r||e[16]!==l||e[17]!==a?(d=s.jsx(Ba,{state:a,label:l,className:r}),e[15]=r,e[16]=l,e[17]=a,e[18]=d):d=e[18],d}const Vj=t=>{const e=tt.c(5),{nodes:n,includeUnreadSubtasks:r}=t;let i;e[0]!==r||e[1]!==n?(i={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=i):i=e[2];const o=cl(i);if(!o)return null;let l;return e[3]!==o?(l=s.jsx($f,{state:o}),e[3]=o,e[4]=l):l=e[4],l},Uj=t=>{const e=tt.c(83),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:m,children:f,renderBody:p,mobileVariant:y,alwaysShowActions:x,isRenaming:k,renameDraft:w,onRenameDraftChange:h,onRenameSave:g,onRenameCancel:j,droppableRef:b,isDropTarget:S,onNewSession:C,depth:v,hideActions:E,archivedBucket:R}=t,A=a===void 0?null:a,O=p===void 0?!0:p,T=x===void 0?y===void 0?!1:y:x,M=k===void 0?!1:k,L=w===void 0?"":w,W=S===void 0?!1:S,$=E===void 0?!1:E,P=R===void 0?!1:R,{t:D}=Nt(),[I,X]=c.useState(!1),[Z,ne]=c.useState(""),ue=c.useRef(null),se=M||I,xe=M?L:Z;let ie;e[0]!==n.name?(ie=()=>{ne(n.name),X(!0)},e[0]=n.name,e[1]=ie):ie=e[1];const Re=ie;let be;e[2]!==xe||e[3]!==n.name||e[4]!==M||e[5]!==u||e[6]!==g?(be=()=>{const Me=xe.trim();Me&&Me!==n.name&&u(Me),M&&g&&g(),X(!1),ne("")},e[2]=xe,e[3]=n.name,e[4]=M,e[5]=u,e[6]=g,e[7]=be):be=e[7];const fe=be;let ke;e[8]!==M||e[9]!==j?(ke=()=>{M&&j&&j(),X(!1),ne("")},e[8]=M,e[9]=j,e[10]=ke):ke=e[10];const H=ke;let J;e[11]!==M||e[12]!==h?(J=Me=>{M&&h?h(Me):ne(Me)},e[11]=M,e[12]=h,e[13]=J):J=e[13];const ce=J;let je,G;e[14]!==M?(je=()=>{if(!M)return;const Me=()=>{const Ce=ue.current;Ce&&(Ce.focus(),Ce.select())},Ae=requestAnimationFrame(Me),Q=window.setTimeout(Me,0);return()=>{cancelAnimationFrame(Ae),window.clearTimeout(Q)}},G=[M],e[14]=M,e[15]=je,e[16]=G):(je=e[15],G=e[16]),c.useEffect(je,G);const we=l?"folder":"folder-open",Te=W&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let he;e[17]!==Te?(he=Ee("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",Te),e[17]=Te,e[18]=he):he=e[18];let re;e[19]!==d||e[20]!==se?(re=se?void 0:Me=>{Me.currentTarget.blur(),d()},e[19]=d,e[20]=se,e[21]=re):re=e[21];const ge=se?void 0:"button",q=se?void 0:0;let z;e[22]!==d||e[23]!==se?(z=se?void 0:Me=>{(Me.key==="Enter"||Me.key===" ")&&(Me.preventDefault(),d())},e[22]=d,e[23]=se,e[24]=z):z=e[24];let ee;e[25]!==n.name||e[26]!==l||e[27]!==D?(ee=l?D("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):D("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=D,e[28]=ee):ee=e[28];const de=P?T?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":T?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let Y;e[29]!==de?(Y=Ee("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",de),e[29]=de,e[30]=Y):Y=e[30];const U=W?"text-primary":"text-muted-foreground";let F;e[31]!==U?(F=Ee("h-3.5 w-3.5 flex-shrink-0",U),e[31]=U,e[32]=F):F=e[32];let V;e[33]!==we||e[34]!==F?(V=s.jsx(_,{name:we,className:F}),e[33]=we,e[34]=F,e[35]=V):V=e[35];let oe;e[36]!==A||e[37]!==r||e[38]!==xe||e[39]!==n.name||e[40]!==H||e[41]!==ce||e[42]!==fe||e[43]!==l||e[44]!==W||e[45]!==se||e[46]!==i||e[47]!==D?(oe=se?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:Hj,onMouseDown:Gj,onSubmit:Me=>{Me.preventDefault(),fe()},children:[s.jsx("input",{ref:ue,value:xe,onChange:Me=>ce(Me.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:D("sessions.sidebar.folderItem.namePlaceholder"),onClick:qj,onPointerDown:Yj,onMouseDown:Qj,onKeyDown:Me=>{if(Me.key==="Escape"){Me.stopPropagation(),H();return}(Me.key===" "||Me.key==="Enter")&&Me.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:Xj,onPointerDown:Jj,onMouseDown:Zj,children:s.jsx(_,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),H()},onPointerDown:e2,onMouseDown:t2,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(_,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:Ee("typography-ui-label font-semibold truncate",W?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(jt,{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]}),A?s.jsx($f,{state:A}):null,l?s.jsx(_,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(_,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=A,e[37]=r,e[38]=xe,e[39]=n.name,e[40]=H,e[41]=ce,e[42]=fe,e[43]=l,e[44]=W,e[45]=se,e[46]=i,e[47]=D,e[48]=oe):oe=e[48];let ae;e[49]!==Y||e[50]!==V||e[51]!==oe?(ae=s.jsxs("div",{className:Y,children:[V,oe]}),e[49]=Y,e[50]=V,e[51]=oe,e[52]=ae):ae=e[52];let pe;e[53]!==T||e[54]!==P||e[55]!==n.name||e[56]!==Re||e[57]!==$||e[58]!==m||e[59]!==C||e[60]!==se||e[61]!==D?(pe=!se&&(!$||P)?s.jsx("div",{className:Ee("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",T?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!P&&C?s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),C()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":D("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:D("sessions.sidebar.project.actions.newSession"),children:s.jsx(_,{name:"add",className:"h-3.5 w-3.5"})}):null,P?null:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),Re()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":D("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(_,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),m()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":P?D("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):D("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=T,e[54]=P,e[55]=n.name,e[56]=Re,e[57]=$,e[58]=m,e[59]=C,e[60]=se,e[61]=D,e[62]=pe):pe=e[62];let le;e[63]!==b||e[64]!==he||e[65]!==re||e[66]!==ge||e[67]!==q||e[68]!==z||e[69]!==ee||e[70]!==ae||e[71]!==pe?(le=s.jsxs("div",{ref:b,className:he,onClick:re,role:ge,tabIndex:q,onKeyDown:z,"aria-label":ee,children:[ae,pe]}),e[63]=b,e[64]=he,e[65]=re,e[66]=ge,e[67]=q,e[68]=z,e[69]=ee,e[70]=ae,e[71]=pe,e[72]=le):le=e[72];let _e;e[73]!==f||e[74]!==l||e[75]!==O||e[76]!==i||e[77]!==o||e[78]!==D?(_e=!l&&O?s.jsxs("div",{className:"pb-1",children:[o,i.length>0?f:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:D("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=f,e[74]=l,e[75]=O,e[76]=i,e[77]=o,e[78]=D,e[79]=_e):_e=e[79];let Fe;return e[80]!==le||e[81]!==_e?(Fe=s.jsxs("div",{className:"oc-folder",children:[le,_e]}),e[80]=le,e[81]=_e,e[82]=Fe):Fe=e[82],Fe},zf=c.memo(Uj);function Hj(t){return t.stopPropagation()}function Gj(t){return t.stopPropagation()}function qj(t){return t.stopPropagation()}function Yj(t){return t.stopPropagation()}function Qj(t){return t.stopPropagation()}function Xj(t){return t.stopPropagation()}function Jj(t){return t.stopPropagation()}function Zj(t){return t.stopPropagation()}function e2(t){return t.stopPropagation()}function t2(t){return t.stopPropagation()}function s2(t){const e=tt.c(11);let n,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:n,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let l;e[4]!==n||e[5]!==r||e[6]!==o?(l={nodes:n,includeUnreadSubtasks:r,enabled:o},e[4]=n,e[5]=r,e[6]=o,e[7]=l):l=e[7];const a=cl(l);let d;return e[8]!==a||e[9]!==i?(d=s.jsx(zf,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=d):d=e[10],d}const Zr=t=>{const e=tt.c(13),{directory:n,className:r}=t,{t:i}=Nt();let o;e[0]!==n?(o=Jm(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=k=>k.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Mt(a)?.tabs.some(zd))return null;let m;e[4]!==i?(m=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=m):m=e[5];const f=m;let p;e[6]!==r?(p=Ee("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=p):p=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(_,{name:"pulse",className:"size-3.5"}),e[8]=y):y=e[8];let x;return e[9]!==l||e[10]!==f||e[11]!==p?(x=s.jsx("span",{className:p,role:"img","aria-label":f,title:f,"data-action-directory":l,children:y}),e[9]=l,e[10]=f,e[11]=p,e[12]=x):x=e[12],x},n2=t=>{const e=tt.c(19),{sessionId:n,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:d}=t,u=i===void 0?null:i,m=a===void 0?!1:a,f=`session-drag:${r??n}`;let p;e[0]!==m||e[1]!==u||e[2]!==o||e[3]!==n||e[4]!==l?(p={type:"session",sessionId:n,ownerKey:u,sessionDirectory:o,sessionTitle:l,archivedBucket:m},e[0]=m,e[1]=u,e[2]=o,e[3]=n,e[4]=l,e[5]=p):p=e[5];let y;e[6]!==m||e[7]!==f||e[8]!==p?(y={id:f,disabled:m,data:p},e[6]=m,e[7]=f,e[8]=p,e[9]=y):y=e[9];const{attributes:x,listeners:k,setNodeRef:w,isDragging:h}=Hx(y);let g;e[10]!==k?(g=C=>{C.stopPropagation(),k?.onPointerDown&&k.onPointerDown(C)},e[10]=k,e[11]=g):g=e[11];const j=g,b=`touch-pan-y select-none${h?" opacity-30":""}`;let S;return e[12]!==x||e[13]!==d||e[14]!==j||e[15]!==k||e[16]!==w||e[17]!==b?(S=s.jsx("div",{ref:w,...x,...k,onPointerDown:j,className:b,children:d}),e[12]=x,e[13]=d,e[14]=j,e[15]=k,e[16]=w,e[17]=b,e[18]=S):S=e[18],S},Wf=t=>{const e=tt.c(20),{folderId:n,scopeKey:r,ownerKey:i,disabled:o,children:l}=t,a=o===void 0?!1:o;let d;e[0]!==n||e[1]!==r?(d=Yn(r,n),e[0]=n,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let m;e[3]!==a||e[4]!==r?(m=a||ll(r),e[3]=a,e[4]=r,e[5]=m):m=e[5];let f;e[6]!==n||e[7]!==i||e[8]!==r?(f={type:"folder",folderId:n,scopeKey:r,ownerKey:i},e[6]=n,e[7]=i,e[8]=r,e[9]=f):f=e[9];let p;e[10]!==u||e[11]!==m||e[12]!==f?(p={id:u,disabled:m,data:f},e[10]=u,e[11]=m,e[12]=f,e[13]=p):p=e[13];const{setNodeRef:y,isOver:x}=Gx(p);let k;e[14]!==l||e[15]!==x||e[16]!==y?(k=l(y,x),e[14]=l,e[15]=x,e[16]=y,e[17]=k):k=e[17];let w;return e[18]!==k?(w=s.jsx(s.Fragment,{children:k}),e[18]=k,e[19]=w):w=e[19],w},r2=t=>{const e=tt.c(22),{scopeKey:n,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const m=li(Pn(di,d),Pn(ci,u)),[f,p]=c.useState(null),[y,x]=c.useState("Session"),[k,w]=c.useState(null),[h,g]=c.useState(null);if(!n){let A;return e[2]!==l?(A=s.jsx(s.Fragment,{children:l}),e[2]=l,e[3]=A):A=e[3],A}let j;e[4]!==o||e[5]!==a?(j=A=>{p(null),w(null),g(null);const{active:O,over:B}=A;if(!B)return;const T=O.data.current,M=B.data.current;T?.type!=="session"||!T.sessionId||!T.ownerKey||T.archivedBucket===!0||a&&T.ownerKey!==a||M?.type!=="folder"||!M.folderId||!M.scopeKey||!M.ownerKey||ll(M.scopeKey)||M.ownerKey!==T.ownerKey||o(T.sessionId,{folderId:M.folderId,scopeKey:M.scopeKey,ownerKey:M.ownerKey},T.ownerKey)},e[4]=o,e[5]=a,e[6]=j):j=e[6];const b=j;let S,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=A=>{const O=A.active.data.current;if(O?.type==="session"&&O.sessionId){p(O.sessionId),x(O.sessionTitle??"Session");const B=A.active.rect.current.initial?.width,T=A.active.rect.current.initial?.height;w(B??null),g(T??null)}},C=()=>{p(null),w(null),g(null)},e[7]=S,e[8]=C):(S=e[7],C=e[8]);let v;e[9]!==h||e[10]!==f||e[11]!==y||e[12]!==k||e[13]!==i?(v=f&&i?s.jsxs("div",{style:{width:k?`${k}px`:"auto",height:h?`${h}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(_,{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:y})]}):null,e[9]=h,e[10]=f,e[11]=y,e[12]=k,e[13]=i,e[14]=v):v=e[14];let E;e[15]!==v?(E=s.jsx(qx,{children:v}),e[15]=v,e[16]=E):E=e[16];let R;return e[17]!==l||e[18]!==b||e[19]!==m||e[20]!==E?(R=s.jsxs(ui,{sensors:m,collisionDetection:fi,onDragStart:S,onDragCancel:C,onDragEnd:b,children:[l,E]}),e[17]=l,e[18]=b,e[19]=m,e[20]=E,e[21]=R):R=e[21],R},Kf=c.createContext(null),o2=({entries:t,descendantIds:e,sessionsById:n,children:r})=>{const i=c.useRef(t),o=c.useRef(e),l=c.useRef(n);i.current=t,o.current=e,l.current=n;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>l.current}),s.jsx(Kf.Provider,{value:a.current,children:r})},Vf=()=>c.useContext(Kf),i2=(t,e,n)=>{const r=t[0];if(!r)return null;const i=n??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const m of u)l.has(m)||(l.add(m),o.push(m))}return o.length>0?{ids:o,scopeKey:i}:null},Uf=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},Kc=(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)},kr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(kr(n,e))return!0;return!1},a2=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!fg(r),l2=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,c2=(t,e,n)=>{const r=new Map,i=o=>{const l=As(o.session)??xt(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}))},Ca=(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})},Hf=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of n.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},Gf=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const p=i.get(u.parentId)??[];p.push(u.id),i.set(u.parentId,p)}const m=new Set;let f=u.id;for(;f;){if(m.has(f)){o.add(u.id);break}m.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const m=r.get(u);if(!m)return!1;a.add(u);let f=o.has(u);return!f&&e.archivedBucket&&m.nodeCount===0?f=(i.get(u)??[]).some(d):(!f&&!e.searchQuery&&(f=!0),!f&&(m.nodeCount>0||!n&&$o([m.name],e.searchQuery))&&(f=!0),f||(f=(i.get(u)??[]).some(d))),a.delete(u),f&&l.add(u),f};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},Vc=new WeakMap;let Uc=1;const d2=t=>{const e=Vc.get(t);if(e!==void 0)return e;const n=Uc;return Uc+=1,Vc.set(t,n),n},qo=t=>t.children.length===0?"":t.children.map(n=>{const r=d2(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${qo(n)}`}).join("|"),qf=(t,e,n,r,i,o)=>{const l=Qt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const m=d.session.directory??i,f=u.session.directory??o,p=Ml(l,m??"",d.session.id),y=Ml(l,f??"",u.session.id);return(p?n.has(p):!1)!==(y?r.has(y):!1)?!0:d.children.some((x,k)=>a(x,u.children[k]))};return a(t,e)},u2=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,f2=(t,e)=>t?t.branchLabel??null:e??null,m2=(t,e)=>{if(e)return null;const n=t?.branch?.trim(),r=xt(t?.path??null);return n&&r?ei(r,n):null},Yo=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o},h2=t=>{const e=tt.c(29),{menuInstanceKey:n,contextMenuInstanceKey:r,openSidebarMenuKey:i,setOpenSidebarMenuKey:o,hasDeferredCloseWork:l,onCloseComplete:a}=t,[d,u]=c.useState(!1),[m,f]=c.useState(!1),p=i===n&&!m,y=r?i===r&&!m:d;let x;e[0]!==l||e[1]!==i||e[2]!==o?(x=R=>{if(i===R){if(l()){f(!0);return}o(null)}},e[0]=l,e[1]=i,e[2]=o,e[3]=x):x=e[3];const k=x;let w;e[4]!==n||e[5]!==k||e[6]!==o?(w=R=>{if(R){u(!1),f(!1),o(n);return}k(n)},e[4]=n,e[5]=k,e[6]=o,e[7]=w):w=e[7];const h=w;let g;e[8]!==r||e[9]!==k||e[10]!==o?(g=R=>{if(!r){u(R);return}if(R){f(!1),o(r);return}k(r)},e[8]=r,e[9]=k,e[10]=o,e[11]=g):g=e[11];const j=g;let b;e[12]!==r||e[13]!==n||e[14]!==a||e[15]!==i||e[16]!==o?(b=R=>{R||(a(),f(!1),(i===n||i===r)&&o(null))},e[12]=r,e[13]=n,e[14]=a,e[15]=i,e[16]=o,e[17]=b):b=e[17];const S=b;let C;e[18]!==p||e[19]!==n||e[20]!==o?(C=()=>{f(!1),o(p?null:n)},e[18]=p,e[19]=n,e[20]=o,e[21]=C):C=e[21];const v=C;let E;return e[22]!==j||e[23]!==h||e[24]!==S||e[25]!==y||e[26]!==p||e[27]!==v?(E={isMenuOpen:p,isContextMenuOpen:y,handleMenuOpenChange:h,handleContextMenuOpenChange:j,handleMenuOpenChangeComplete:S,toggleMenu:v},e[22]=j,e[23]=h,e[24]=S,e[25]=y,e[26]=p,e[27]=v,e[28]=E):E=e[28],E},p2=t=>{const e=tt.c(10),{project:n,fallback:r}=t,{currentTheme:i}=Ln(),o=n.iconImage??null;let l;e[0]!==n.id||e[1]!==o?(l={id:n.id,iconImage:o},e[0]=n.id,e[1]=o,e[2]=l):l=e[2];let a;e[3]!==i.colors.surface.foreground||e[4]!==i.metadata.variant?(a={themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},e[3]=i.colors.surface.foreground,e[4]=i.metadata.variant,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==l||e[8]!==a?(d=s.jsx(oi,{project:l,options:a,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=l,e[8]=a,e[9]=d):d=e[9],d},g2=t=>{const e=tt.c(13),{project:n}=t,r=n?.icon?ni[n.icon]:null,i=n?.color?ri[n.color]??null:null;let o;e[0]!==i||e[1]!==r?(o=r?s.jsx(_,{name:r,className:Ee("h-3.5 w-3.5",!i&&"text-muted-foreground/75"),style:i?{color:i}:void 0}):s.jsx(_,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/75",style:i?{color:i}:void 0}),e[0]=i,e[1]=r,e[2]=o):o=e[2];const l=o;if(!n?.iconImage){let m;return e[3]!==l?(m=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:l}),e[3]=l,e[4]=m):m=e[4],m}let a;e[5]!==n.iconBackground?(a=n.iconBackground?{backgroundColor:n.iconBackground}:void 0,e[5]=n.iconBackground,e[6]=a):a=e[6];let d;e[7]!==l||e[8]!==n?(d=s.jsx(p2,{project:n,fallback:l}),e[7]=l,e[8]=n,e[9]=d):d=e[9];let u;return e[10]!==a||e[11]!==d?(u=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:a,children:d}),e[10]=a,e[11]=d,e[12]=u):u=e[12],u},Hc=t=>{const e=tt.c(45),{compact:n,project:r,projectLabel:i,title:o,titleClassName:l,branchLabel:a,statusDot:d,pinnedMarker:u,timeSlot:m,directoryIndicator:f,prBadge:p,zombieIndicator:y,badges:x,metaPaddingClass:k,hideMetaOnHoverClass:w}=t,h=n===void 0?!1:n,g=!h&&(!!a||!!p||!!y||!!x);let j;e[0]!==w||e[1]!==k?(j=Ee("ml-auto flex flex-shrink-0 items-center gap-1 transition-opacity",k,w),e[0]=w,e[1]=k,e[2]=j):j=e[2];let b;e[3]!==m?(b=s.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:m}),e[3]=m,e[4]=b):b=e[4];let S;e[5]!==f||e[6]!==u||e[7]!==d||e[8]!==j||e[9]!==b?(S=s.jsxs("span",{className:j,children:[f,u,d,b]}),e[5]=f,e[6]=u,e[7]=d,e[8]=j,e[9]=b,e[10]=S):S=e[10];const C=S;if(h){let M;e[11]!==l?(M=Ee("min-w-0 flex-1 truncate typography-ui-label font-normal",l),e[11]=l,e[12]=M):M=e[12];let L;e[13]!==M||e[14]!==o?(L=s.jsx("div",{className:M,children:o}),e[13]=M,e[14]=o,e[15]=L):L=e[15];let W;e[16]!==x?(W=x?s.jsx("span",{className:"flex flex-shrink-0 items-center gap-1",children:x}):null,e[16]=x,e[17]=W):W=e[17];let $;return e[18]!==C||e[19]!==L||e[20]!==W?($=s.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[L,C,W]}),e[18]=C,e[19]=L,e[20]=W,e[21]=$):$=e[21],$}let v;e[22]!==r?(v=s.jsx(g2,{project:r}),e[22]=r,e[23]=v):v=e[23];let E;e[24]!==i?(E=i?s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/85",children:i}):null,e[24]=i,e[25]=E):E=e[25];let R;e[26]!==C||e[27]!==v||e[28]!==E?(R=s.jsxs("div",{className:"relative flex h-5 w-full min-w-0 items-center gap-1",children:[v,E,C]}),e[26]=C,e[27]=v,e[28]=E,e[29]=R):R=e[29];let A;e[30]!==l?(A=Ee("w-full min-w-0 truncate typography-ui-label font-normal",l),e[30]=l,e[31]=A):A=e[31];let O;e[32]!==A||e[33]!==o?(O=s.jsx("div",{className:A,children:o}),e[32]=A,e[33]=o,e[34]=O):O=e[34];let B;e[35]!==x||e[36]!==a||e[37]!==g||e[38]!==p||e[39]!==y?(B=g?s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[a?s.jsxs(s.Fragment,{children:[s.jsx(_,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:a})]}):null,s.jsxs("span",{className:"ml-auto flex flex-shrink-0 items-center gap-1",children:[y??p,x]})]}):null,e[35]=x,e[36]=a,e[37]=g,e[38]=p,e[39]=y,e[40]=B):B=e[40];let T;return e[41]!==B||e[42]!==R||e[43]!==O?(T=s.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[R,O,B]}),e[41]=B,e[42]=R,e[43]=O,e[44]=T):T=e[44],T};let Na=!1;const Aa=new Set;let Gc=!1;function x2(){for(const t of Aa)t()}function dl(t){Na!==t&&(Na=t,x2())}function b2(t){t.key==="Shift"&&dl(!0)}function y2(t){t.key==="Shift"&&dl(!1)}function w2(){dl(!1)}function v2(){Gc||typeof window>"u"||(Gc=!0,window.addEventListener("keydown",b2),window.addEventListener("keyup",y2),window.addEventListener("blur",w2))}function S2(t){return v2(),Aa.add(t),()=>{Aa.delete(t)}}function j2(){return Na}function k2(){return!1}function C2(){return ut.useSyncExternalStore(S2,j2,k2)}async function N2(t,e,n){const r=await Promise.all(t.map(async i=>{n();const o=i.directory??i.session.directory,l=await dn.getSession(i.session.id,o);if(n(),!Xd(e,Lo(l,i.projectDirectory??l.directory)))throw new Error("Fusion source membership changed");const a=await dn.getSessionMessages(i.session.id,{limit:50},o);n();let d="";for(const u of a.items)if(u.info.role==="assistant"){d=mg(u.parts).trim();break}return{source:{...i,session:l},text:d}}));return n(),r.filter(i=>i.text.length>0)}const Yf=t=>{const e=tt.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:d}=Nt(),u=Yt(A2),m=Yt(P2),f=Yt(D2);let p;e[0]!==u?(p=u(),e[0]=u,e[1]=p):p=e[1];const y=p;let x;e[2]!==y?(x=y.filter(I2),e[2]=y,e[3]=x):x=e[3];const k=x;let w,h;e[4]!==y.length||e[5]!==m?(w=()=>{y.length===0&&m()},h=[y.length,m],e[4]=y.length,e[5]=m,e[6]=w,e[7]=h):(w=e[6],h=e[7]),c.useEffect(w,h);let g,j;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==k||e[12]!==n?(g=()=>{if(o)return;const B=n.trim();if(B.length>0&&k.some(L=>L.name===B))return;const T=typeof f=="string"&&f.trim().length>0?f.trim():null;if(T&&k.some(L=>L.name===T)){r(T);return}const M=k[0]?.name;M&&r(M)},j=[f,o,r,k,n],e[8]=f,e[9]=o,e[10]=r,e[11]=k,e[12]=n,e[13]=g,e[14]=j):(g=e[13],j=e[14]),c.useEffect(g,j);const b=n.trim().length>0?n:void 0;let S;e[15]!==i?(S=Ee("max-w-full",i),e[15]=i,e[16]=S):S=e[16];let C;e[17]!==d?(C=d("multirun.agentSelector.placeholder"),e[17]=d,e[18]=C):C=e[18];let v;e[19]!==C?(v=s.jsx(js,{placeholder:C}),e[19]=C,e[20]=v):v=e[20];let E;e[21]!==l||e[22]!==S||e[23]!==v?(E=s.jsx(Ms,{id:l,size:"lg",className:S,children:v}),e[21]=l,e[22]=S,e[23]=v,e[24]=E):E=e[24];let R;e[25]!==k?(R=k.length>0&&s.jsx(oa,{children:k.map(T2)}),e[25]=k,e[26]=R):R=e[26];let A;e[27]!==a||e[28]!==R?(A=s.jsx(Os,{fitContent:!0,portalToBody:a,children:R}),e[27]=a,e[28]=R,e[29]=A):A=e[29];let O;return e[30]!==o||e[31]!==r||e[32]!==b||e[33]!==E||e[34]!==A?(O=s.jsxs(Rs,{value:b,onValueChange:r,disabled:o,children:[E,A]}),e[30]=o,e[31]=r,e[32]=b,e[33]=E,e[34]=A,e[35]=O):O=e[35],O};function A2(t){return t.getVisibleAgents}function P2(t){return t.loadAgents}function D2(t){return t.currentAgentName}function I2(t){return Ou(t.mode)}function T2(t){return s.jsx(rs,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const E2="h-7",Gr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,R2=t=>{const e=tt.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=Ee("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",E2),e[0]=d):d=e[0];let u;e[1]!==n.providerID?(u=s.jsx(ia,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=u):u=e[2];let m;e[3]!==a?(m=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=m):m=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(_,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let p;e[6]!==o?(p=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=o,e[7]=p):p=e[7];let y;return e[8]!==u||e[9]!==m||e[10]!==p?(y=s.jsxs("div",{className:d,children:[u,m,p]}),e[8]=u,e[9]=m,e[10]=p,e[11]=y):y=e[11],y},Qf=t=>{const e=tt.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:d,maxModels:u,addButtonClassName:m,dropdownSide:f,dropdownClassName:p,containerClassName:y,triggerIcon:x}=t,k=d===void 0?!0:d,w=f===void 0?"top":f,{t:h}=Nt(),g=Yt(M2),j=Yt(O2),b=Ne(B2),S=Ne(F2),{favoriteModelsList:C,recentModelsList:v}=hg(),E=Ne(_2),R=Ne(L2),[A,O]=c.useState(!1),[B,T]=c.useState(""),[M,L]=c.useState(null),W=c.useRef(null),$=c.useRef(null),P=u===1,D=u===void 0||n.length<u||P;let I;if(e[0]!==n){I=new Map;for(const Le of n){const Je=`${Le.providerID}:${Le.modelID}`;I.set(Je,(I.get(Je)||0)+1)}e[0]=n,e[1]=I}else I=e[1];const X=I;let Z;e[2]!==n?(Z=Le=>n.filter(ot=>ot.providerID===Le.providerID&&ot.modelID===Le.modelID).findIndex(ot=>ot.instanceId===Le.instanceId)+1,e[2]=n,e[3]=Z):Z=e[3];const ne=Z;let ue,se;e[4]!==w||e[5]!==A?(ue=()=>{if(!A||!$.current)return;const Le=$.current.getBoundingClientRect();if(w==="bottom"){const st=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Le.bottom-16-112;L(Math.max(160,Math.min(320,st)));return}let Je=$.current.parentElement;for(;Je&&!Je.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const it=getComputedStyle(Je);if(it.overflow==="auto"||it.overflow==="hidden"||it.overflowY==="auto"||it.overflowY==="hidden")break;Je=Je.parentElement}const ot=Je?Je.getBoundingClientRect().top:0,et=Le.top-ot-16;L(Math.max(150,Math.min(300,et)))},se=[w,A],e[4]=w,e[5]=A,e[6]=ue,e[7]=se):(ue=e[6],se=e[7]),c.useEffect(ue,se);let xe,ie;e[8]!==D||e[9]!==A?(xe=()=>{!D&&A&&(O(!1),T(""))},ie=[D,A],e[8]=D,e[9]=A,e[10]=xe,e[11]=ie):(xe=e[10],ie=e[11]),c.useEffect(xe,ie);let Re,be;e[12]!==A?(Re=()=>{if(!A)return;const Le=Je=>{W.current&&!W.current.contains(Je.target)&&(O(!1),T(""))};return document.addEventListener("mousedown",Le),()=>document.removeEventListener("mousedown",Le)},be=[A],e[12]=A,e[13]=Re,e[14]=be):(Re=e[13],be=e[14]),c.useEffect(Re,be);let fe;e[15]!==P||e[16]!==r||e[17]!==o||e[18]!==n.length?(fe=Le=>{const Je={providerID:Le.providerID,modelID:Le.modelID,displayName:Le.model.name||Le.modelID,instanceId:Gr()};P&&n.length>0&&o?o(0,Je):r(Je),P&&(O(!1),T(""))},e[15]=P,e[16]=r,e[17]=o,e[18]=n.length,e[19]=fe):fe=e[19];const ke=fe;let H;e[20]!==h?(H=h("multirun.modelMultiSelect.search.placeholder"),e[20]=h,e[21]=H):H=e[21];let J;e[22]!==h?(J=h("multirun.modelMultiSelect.search.noResults"),e[22]=h,e[23]=J):J=e[23];let ce;e[24]!==h?(ce=h("multirun.modelMultiSelect.sections.favorites"),e[24]=h,e[25]=ce):ce=e[25];let je;e[26]!==h?(je=h("multirun.modelMultiSelect.sections.recent"),e[26]=h,e[27]=je):je=e[27];let G;e[28]!==h?(G=h("multirun.modelMultiSelect.keyboard.hint"),e[28]=h,e[29]=G):G=e[29];let we;e[30]!==h?(we=h("settings.agents.modelSelector.actions.favorite"),e[30]=h,e[31]=we):we=e[31];let Te;e[32]!==h?(Te=h("settings.agents.modelSelector.actions.unfavorite"),e[32]=h,e[33]=Te):Te=e[33];let he;e[34]!==h?(he=h("chat.modelControls.capabilities"),e[34]=h,e[35]=he):he=e[35];let re;e[36]!==h?(re=h("chat.modelControls.capability.toolCalling"),e[36]=h,e[37]=re):re=e[37];let ge;e[38]!==h?(ge=h("chat.modelControls.capability.reasoning"),e[38]=h,e[39]=ge):ge=e[39];let q;e[40]!==h?(q=h("chat.modelControls.input"),e[40]=h,e[41]=q):q=e[41];let z;e[42]!==h?(z=h("chat.modelControls.output"),e[42]=h,e[43]=z):z=e[43];let ee;e[44]!==h?(ee=h("chat.modelControls.costPerMillion"),e[44]=h,e[45]=ee):ee=e[45];let de;e[46]!==H||e[47]!==J||e[48]!==ce||e[49]!==je||e[50]!==G||e[51]!==we||e[52]!==Te||e[53]!==he||e[54]!==re||e[55]!==ge||e[56]!==q||e[57]!==z||e[58]!==ee?(de={searchPlaceholder:H,noResults:J,favorites:ce,recent:je,keyboardHint:G,favorite:we,unfavorite:Te,capabilities:he,capabilityToolCalling:re,capabilityReasoning:ge,input:q,output:z,costPerMillion:ee},e[46]=H,e[47]=J,e[48]=ce,e[49]=je,e[50]=G,e[51]=we,e[52]=Te,e[53]=he,e[54]=re,e[55]=ge,e[56]=q,e[57]=z,e[58]=ee,e[59]=de):de=e[59];const Y=de;let U;e[60]!==y?(U=Ee("relative",y),e[60]=y,e[61]=U):U=e[61];const F=A?"":void 0;let V;e[62]!==m?(V=Ee(Bu({size:"default"}),"w-fit",m),e[62]=m,e[63]=V):V=e[63];const oe=!D;let ae;e[64]!==A?(ae=()=>{O(!A)},e[64]=A,e[65]=ae):ae=e[65];let pe;e[66]!==x?(pe=x??s.jsx(_,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=x,e[67]=pe):pe=e[67];let le;e[68]!==a||e[69]!==h?(le=a??h("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=h,e[70]=le):le=e[70];let _e;e[71]!==F||e[72]!==V||e[73]!==oe||e[74]!==ae||e[75]!==pe||e[76]!==le?(_e=s.jsxs("button",{ref:$,type:"button","data-popup-open":F,className:V,disabled:oe,onClick:ae,children:[pe,le]}),e[71]=F,e[72]=V,e[73]=oe,e[74]=ae,e[75]=pe,e[76]=le,e[77]=_e):_e=e[77];let Fe;e[78]!==M||e[79]!==D||e[80]!==p||e[81]!==w||e[82]!==C||e[83]!==ke||e[84]!==E||e[85]!==S||e[86]!==A||e[87]!==Y||e[88]!==X||e[89]!==j||e[90]!==R||e[91]!==g||e[92]!==v||e[93]!==B||e[94]!==b?(Fe=A?s.jsx("div",{className:Ee("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",w==="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(pg,{providers:g,providerOrder:R,favoriteModels:C,recentModels:v,modelsMetadata:j,hiddenModels:E,searchQuery:B,onSearchQueryChange:T,onSelect:ke,labels:Y,selectionCount:Le=>X.get(`${Le.providerID}:${Le.modelID}`)||0,disabled:!D,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:M?`${M}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:A,isFavorite:Le=>S(Le.providerID,Le.modelID),onToggleFavorite:Le=>b(Le.providerID,Le.modelID),onEscape:()=>{O(!1),T("")}})}):null,e[78]=M,e[79]=D,e[80]=p,e[81]=w,e[82]=C,e[83]=ke,e[84]=E,e[85]=S,e[86]=A,e[87]=Y,e[88]=X,e[89]=j,e[90]=R,e[91]=g,e[92]=v,e[93]=B,e[94]=b,e[95]=Fe):Fe=e[95];let Me;e[96]!==U||e[97]!==_e||e[98]!==Fe?(Me=s.jsxs("div",{className:U,ref:W,children:[_e,Fe]}),e[96]=U,e[97]=_e,e[98]=Fe,e[99]=Me):Me=e[99];let Ae;e[100]!==ne||e[101]!==X||e[102]!==i||e[103]!==o||e[104]!==g||e[105]!==n||e[106]!==k||e[107]!==h?(Ae=k&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Le,Je)=>{const ot=`${Le.providerID}:${Le.modelID}`,et=X.get(ot)||1,it=ne(Le),st=g.find(Ge=>Ge.id===Le.providerID)?.models?.find(Ge=>Ge.id===Le.modelID),mt=Qa(st?.variants),kt=mt.length>0,Pe=Le.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(R2,{model:Le,instanceIndex:it,totalSameModel:et,onRemove:()=>i(Je)}),kt&&s.jsxs(Rs,{value:Pe,onValueChange:Ge=>{if(!o)return;o(Je,{...Le,variant:Ge==="__default__"?void 0:Ge})},children:[s.jsxs(Ms,{size:"sm",className:"gap-1.5",children:[s.jsx(_,{name:"brain-ai-3",className:Ee("h-3.5 w-3.5 flex-shrink-0",Pe==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(js,{placeholder:h("multirun.modelMultiSelect.variant.placeholder"),children:Ge=>Ge==="__default__"?h("multirun.modelMultiSelect.variant.default"):Ge})]}),s.jsxs(Os,{fitContent:!0,children:[s.jsx(rs,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:h("multirun.modelMultiSelect.variant.default")}),mt.map($2)]})]})]},Le.instanceId)})}),e[100]=ne,e[101]=X,e[102]=i,e[103]=o,e[104]=g,e[105]=n,e[106]=k,e[107]=h,e[108]=Ae):Ae=e[108];let Q;e[109]!==Me||e[110]!==Ae?(Q=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[Me,Ae]}),e[109]=Me,e[110]=Ae,e[111]=Q):Q=e[111];let Ce;e[112]!==u||e[113]!==l||e[114]!==n.length||e[115]!==h?(Ce=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:u!==void 0?h("multirun.modelMultiSelect.validation.minToMax",{min:l,max:u}):h("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=u,e[113]=l,e[114]=n.length,e[115]=h,e[116]=Ce):Ce=e[116];let Be;return e[117]!==Q||e[118]!==Ce?(Be=s.jsxs("div",{className:"space-y-2",children:[Q,Ce]}),e[117]=Q,e[118]=Ce,e[119]=Be):Be=e[119],Be};function M2(t){return t.providers}function O2(t){return t.modelsMetadata}function B2(t){return t.toggleFavoriteModel}function F2(t){return t.isFavoriteModel}function _2(t){return t.hiddenModels}function L2(t){return t.providerOrder}function $2(t){return s.jsx(rs,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const z2=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
881
881
 
@@ -892,5 +892,5 @@ Now write the final fused answer.`}],directory:ue})}catch(ne){if(Qt()!==I||dn.ge
892
892
  `)?(A(et),E(!0)):E(!1);return}E(!1)},[]),de=ut.useCallback(Q=>{g(Ce=>({...Ce,execution:{...Ce.execution,prompt:Q}}))},[]),Y=ut.useCallback(Q=>{const Ce=h.execution.prompt,Le=Z.current?.selectionStart??Ce.length,ot=Ce.substring(0,Le).lastIndexOf("@"),et=Q.relativePath&&Q.relativePath.trim().length>0?Q.relativePath.trim():Q.path||Q.name,it=ot!==-1?ot:Le,ht=`${Ce.substring(0,it)}@${et} ${Ce.substring(Le)}`,st=it+et.length+2;de(ht),E(!1),A(""),requestAnimationFrame(()=>{const mt=Z.current;mt&&(mt.selectionStart=st,mt.selectionEnd=st,mt.focus()),ee(ht,st)})},[h.execution.prompt,de,ee]),U=ut.useCallback(Q=>{const Ce=h.execution.prompt,Le=Z.current?.selectionStart??Ce.length,ot=Ce.substring(0,Le).lastIndexOf("@"),et=ot!==-1?ot:Le,it=`${Ce.substring(0,et)}@${Q} ${Ce.substring(Le)}`,ht=et+Q.length+2;de(it),E(!1),A(""),requestAnimationFrame(()=>{const st=Z.current;st&&(st.selectionStart=ht,st.selectionEnd=ht,st.focus()),ee(it,ht)})},[h.execution.prompt,de,ee]),F=ut.useCallback(Q=>{const Ce=`/${Q.name} `;de(Ce),B(!1),M(""),W(!1),requestAnimationFrame(()=>{const Be=Z.current;Be&&(Be.focus(),Be.selectionStart=Be.value.length,Be.selectionEnd=Be.value.length),ee(Ce,Ce.length)})},[de,ee]),V=ut.useCallback((Q,Ce)=>{const Be=h.execution.prompt,Je=Z.current?.selectionStart??Be.length,et=Be.substring(0,Je).lastIndexOf("#"),it=et!==-1?et:Je,ht=`${Be.substring(0,it)}#${Ce} ${Be.substring(Je)}`,st=it+Ce.length+2;de(ht),W(!1),P(""),requestAnimationFrame(()=>{const mt=Z.current;mt&&(mt.selectionStart=st,mt.selectionEnd=st,mt.focus()),ee(ht,st)})},[h.execution.prompt,de,ee]),oe=ut.useCallback(Q=>{if(O&&ue.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")){Q.preventDefault(),ue.current.handleKeyDown(Q.key);return}v&&ne.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")&&(Q.preventDefault(),ne.current.handleKeyDown(Q.key)),L&&se.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")&&(Q.preventDefault(),se.current.handleKeyDown(Q.key))},[O,v,L]),ae=ut.useCallback(async()=>{const Q=K4(h,o);if(Q){Ke.error(Q);return}const Ce={...h.id?{id:h.id}:{},name:h.name.trim(),enabled:h.enabled,schedule:{kind:h.schedule.kind,timezone:h.schedule.timezone.trim(),...h.schedule.kind==="cron"?{cron:h.schedule.cronExpression.trim()}:h.schedule.kind==="once"?{date:h.schedule.onceDate,time:h.schedule.onceTime}:{times:V4(h.schedule.times),...h.schedule.kind==="weekly"?{weekdays:h.schedule.weekdays}:{}}},execution:{prompt:h.execution.prompt,providerID:h.execution.providerID,modelID:h.execution.modelID,...h.execution.variant.trim()?{variant:h.execution.variant.trim()}:{},...h.execution.agent.trim()?{agent:h.execution.agent.trim()}:{},...h.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...h.execution.goalEnabled?{goalEnabled:!0}:{},...h.execution.goalEnabled&&h.execution.goalTokenBudget?{goalTokenBudget:h.execution.goalTokenBudget}:{}},...h.state?{state:h.state}:{}};b(!0);try{await i(Ce),r(!1)}catch(Be){Ke.error(Be instanceof Error?Be.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{b(!1)}},[h,r,i,o]),pe=ut.useId(),le=ut.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),_e=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),Fe=o("sessions.scheduledTasks.editor.description"),Me=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(Is,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(An,{id:"sched-name",value:h.name,onChange:Q=>g(Ce=>({...Ce,name:Q.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(Is,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Rs,{value:h.schedule.kind,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,kind:Q,...Q==="cron"&&!Ce.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Ms,{size:"lg",className:"w-fit max-w-full",children:s.jsx(js,{children:Q=>o(Q==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":Q==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":Q==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(Os,{children:[s.jsx(rs,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(rs,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(rs,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(rs,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),h.schedule.kind==="cron"?s.jsx(U4,{draft:h,setDraft:g,locale:l,t:o}):h.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(Is,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Ee(Bu({size:"default"}),"w-fit max-w-full"),onClick:()=>C(Q=>!Q),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(_,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:R4(h.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(_,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),S?s.jsxs("div",{className:"oc-surface-elevated absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-surface-elevated 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:()=>I(Q=>hd(Q,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:ge,children:s.jsx(_,{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(D)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>I(Q=>hd(Q,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(_,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:q.map((Q,Ce)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:Q},`${Q}-${Ce}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:M4(D,be).map(({date:Q,inCurrentMonth:Ce})=>{const Be=md(Q),Le=Be===h.schedule.onceDate,Je=yd(Q,Te),ot=Q.getTime()<Te.getTime(),et=Le?"bg-interactive-selection text-interactive-selection-foreground":ot?"text-muted-foreground/40":Ce?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{ot||(z(Be),C(!1))},disabled:ot,className:["h-8 rounded-md typography-ui-label",et,Je&&!Le?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",ot?"cursor-not-allowed opacity-45":""].join(" "),children:Q.getDate()},Be)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:re||""}),s.jsx(ct,{type:"button",size:"xs",variant:"ghost",onClick:()=>{z(md(Te)),I(new Date(Te.getFullYear(),Te.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(Is,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(xd,{value:h.schedule.onceTime,use24Hour:Re,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:Q=>g(Ce=>({...Ce,schedule:{...Ce.schedule,onceTime:Q}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Rs,{value:h.schedule.timezone,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,timezone:Q}}))},children:[s.jsx(Ms,{size:"lg",className:"w-fit max-w-full",children:s.jsx(js,{})}),s.jsx(Os,{children:Ia.map(Q=>s.jsx(rs,{value:Q,children:Q},Q))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[h.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:fe.map(Q=>{const Ce=h.schedule.weekdays.includes(Q.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",Ce?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(xr,{checked:Ce,onChange:Be=>ce(Q.value,Be),ariaLabel:Q.label}),s.jsx("button",{type:"button",onClick:()=>ce(Q.value,!Ce),className:"group-hover:text-foreground",children:Q.label})]},Q.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:h.schedule.times.map((Q,Ce)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xd,{value:Q,use24Hour:Re,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Be=>je(Ce,Be)}),h.schedule.times.length>1?s.jsx(ct,{type:"button",size:"icon",variant:"ghost",onClick:()=>G(Ce),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(_,{name:"close",className:"h-4 w-4"})}):null]},Ce))}),s.jsx("div",{children:s.jsxs(ct,{type:"button",size:"sm",variant:"outline",onClick:we,children:[s.jsx(_,{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(Is,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Rs,{value:h.schedule.timezone,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,timezone:Q}}))},children:[s.jsx(Ms,{size:"lg",className:"w-fit max-w-full",children:s.jsx(js,{})}),s.jsx(Os,{children:Ia.map(Q=>s.jsx(rs,{value:Q,children:Q},Q))})]})]})]}),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(Is,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Ug,{providerId:h.execution.providerID,modelId:h.execution.modelID,onChange:(Q,Ce)=>{g(Be=>({...Be,execution:{...Be.execution,providerID:Q,modelID:Ce,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Rs,{value:J,disabled:!H,onValueChange:Q=>{g(Ce=>({...Ce,execution:{...Ce.execution,variant:Q==="__default"?"":Q}}))},children:[s.jsx(Ms,{size:"lg",className:"w-fit max-w-full",children:s.jsx(js,{children:Q=>Q==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):Q})}),s.jsxs(Os,{children:[s.jsx(rs,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),ke.map(Q=>s.jsx(rs,{value:Q,children:Q},Q))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Is,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Hg,{agentName:h.execution.agent,filter:Q=>Ou(Q.mode),onChange:Q=>g(Ce=>({...Ce,execution:{...Ce.execution,agent:Q}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Is,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(pr,{id:"sched-prompt",ref:Z,value:h.execution.prompt,onChange:Q=>{const Ce=Q.target.value;de(Ce);const Be=Q.target.selectionStart??Ce.length;ee(Ce,Be)},onKeyDown:oe,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),O?s.jsx(Ku,{ref:ue,searchQuery:T,onCommandSelect:F,onClose:()=>B(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,v?s.jsx(Vu,{ref:ne,searchQuery:R,onFileSelect:Y,onAgentSelect:U,onClose:()=>E(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,L?s.jsx(Uu,{ref:se,searchQuery:$,onSnippetSelect:V,onClose:()=>W(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),h.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(xr,{checked:h.execution.goalTokenBudget!==null,onChange:Q=>g(Ce=>({...Ce,execution:{...Ce.execution,goalTokenBudget:Q?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),h.execution.goalTokenBudget!==null?s.jsx(Gg,{value:h.execution.goalTokenBudget,onValueChange:Q=>{typeof Q=="number"&&Number.isFinite(Q)&&Q>0&&g(Ce=>({...Ce,execution:{...Ce.execution,goalTokenBudget:Math.floor(Q)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),Ae=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(xr,{checked:h.enabled,onChange:Q=>g(Ce=>({...Ce,enabled:Q})),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(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee(ud),onClick:()=>g(Q=>({...Q,execution:{...Q.execution,permissionAutoAccept:!Q.execution.permissionAutoAccept}})),"aria-pressed":h.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:h.execution.permissionAutoAccept?s.jsx(_,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(_,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(jt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Ee(ud,h.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>g(Q=>({...Q,execution:{...Q.execution,goalEnabled:!Q.execution.goalEnabled}})),"aria-pressed":h.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:h.execution.goalEnabled?s.jsx(_,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(_,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(jt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(ct,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:j,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(ct,{type:"button",size:"sm",onClick:ae,disabled:j,children:o(j?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return w?s.jsx(ti,{open:e,title:_e,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:Q=>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:_e}),Q]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:Fe})]}),footer:Ae,children:Me}):s.jsx(Ps,{open:e,onOpenChange:Q=>{!Q&&le()||r(Q)},children:s.jsxs(Ds,{"aria-describedby":pe,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Hs,{id:pe,className:"sr-only",children:Fe}),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(Us,{className:"typography-ui-label font-medium text-foreground",children:_e}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:Fe})]})}),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:Me})}),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:Ae})})]})})}function G4(t){return Ar(t,{min:0,max:23})}function q4(t,e){return Ar(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function Y4(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 Q4(t){return s.jsx(rs,{value:t,children:t},t)}const X4=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))},J4=(t,e)=>{const n=X4(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:er(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:er(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:er(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:er(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},Z4=(t,e)=>!t||!Number.isFinite(t)?"":qg(t,e),vd=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),p=Math.round(r%o/i),y=p>0?`${f}h ${p}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:y}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:y})}const d=Math.floor(r/l),u=Math.round(r%l/o),m=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:m}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:m})},e5={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"}},t5=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function s5(){const{t}=Nt(),e=Ne(P=>P.isScheduledTasksDialogOpen),n=Ne(P=>P.setScheduledTasksDialogOpen),r=Ne(P=>P.isMobile),i=Ne(P=>P.timeFormatPreference),o=Ut(P=>P.projects),l=Ut(P=>P.getActiveProject()),a=os(P=>P.homeDirectory),{currentTheme:d}=Ln(),[u,m]=ut.useState(""),[f,p]=ut.useState([]),[y,x]=ut.useState(!0),[k,w]=ut.useState(!1),[h,g]=ut.useState(null),[j,b]=ut.useState(null),S=ut.useMemo(()=>o.find(P=>P.id===u)||null,[o,u]),C=ut.useCallback(P=>{const D=P.label?.trim()||ir(P.path,a||void 0),I=P.icon?ni[P.icon]:null,X=P.color?ri[P.color]:void 0,Z=I?s.jsx(_,{name:I,className:"h-3.5 w-3.5 shrink-0",style:X?{color:X}:void 0}):s.jsx(_,{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:[P.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:P.iconBackground?{backgroundColor:P.iconBackground}:void 0,children:s.jsx(oi,{project:{id:P.id,iconImage:P.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:Z})}):Z,s.jsx("span",{className:"truncate",children:D})]})},[a,d.metadata.variant,d.colors.surface.foreground]),v=ut.useCallback(async(P,D)=>{if(!P){p([]);return}D?.silent||x(!0);try{const I=await zx(P);I.sort((X,Z)=>{if(X.enabled!==Z.enabled)return X.enabled?-1:1;const ne=X.name.localeCompare(Z.name);return ne!==0?ne:(X.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(Z.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),p(I)}catch(I){Ke.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),D?.silent||p([])}finally{D?.silent||x(!1)}},[t]);ut.useEffect(()=>{if(!e)return;const P=l?.id||o[0]?.id||"";m(P),P?v(P):(p([]),x(!1))},[e,l,o,v]),ut.useEffect(()=>{if(!e)return;let P=null;const D=Wn(I=>{I.type==="scheduled-task-ran"&&I.projectId===u&&(P&&clearTimeout(P),P=setTimeout(()=>{v(u,{silent:!0})},400))});return()=>{P&&clearTimeout(P),D()}},[e,u,v]);const E=ut.useCallback(async P=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Ql(u,P),await v(u),Ke.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,v,t]),R=ut.useCallback(async(P,D)=>{if(u){b(P.id),p(I=>I.map(X=>X.id===P.id?{...X,enabled:D}:X));try{P.loopFile?await Wx(u,P.id,D):await Ql(u,{...P,enabled:D}),await v(u,{silent:!0})}catch(I){Ke.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await v(u,{silent:!0})}finally{b(null)}}},[u,v,t]),A=ut.useCallback(async P=>{if(!(!u||!window.confirm(P.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:P.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:P.name})))){b(P.id);try{P.loopFile?await Kx(u,P.id):await Vx(u,P.id),await v(u,{silent:!0}),Ke.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(I){Ke.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{b(null)}}},[u,v,t]),O=ut.useCallback(P=>{if(!P.loopFile){g(P),w(!0);return}S?.path&&(n(!1),pn.getState().setSelectedPath(S.path,P.loopFile,{allowOutsideRoot:!0}),Ne.getState().openContextFile(S.path,P.loopFile))},[S?.path,n]),B=ut.useCallback(async P=>{if(u){b(P.id);try{const{sessionId:D,persistError:I}=await Ux(u,P.id);if(await Promise.all([v(u,{silent:!0}),ai()]),I?Ke.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Ke.success(t("sessions.scheduledTasks.dialog.toast.started")),D){const X=o.find(Z=>Z.id===u);rt.getState().setCurrentSession(D,X?.path??null)}}catch(D){Ke.error(D instanceof Error?D.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{b(null)}}},[u,o,v,t]),T=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(Rs,{value:u||"__none",onValueChange:P=>{const D=P==="__none"?"":P;m(D),D?v(D):p([])},children:[s.jsx(Ms,{size:"lg",className:r?"w-full":void 0,children:S?s.jsx(js,{children:C(S)}):s.jsx(js,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(Os,{children:[o.length===0?s.jsx(rs,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(P=>s.jsx(rs,{value:P.id,children:C(P)},P.id))]})]})]}),M=()=>{g(null),w(!0)},L=P=>{m(P),P?v(P):p([])},W=s.jsx("div",{className:"min-h-[280px]",children:y?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(_,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(u?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(P=>{const D=j===P.id,I=P.state?.lastStatus||"idle",X=e5[I],Z=t(I==="success"?"sessions.scheduledTasks.dialog.status.success":I==="error"?"sessions.scheduledTasks.dialog.status.error":I==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),ne=P.state?.nextRunAt,ue=P.state?.lastRunAt;return s.jsxs("div",{className:Ee("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Ee("min-w-0",!P.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:P.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:J4(P,t)}),P.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:P.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:P.loopFile})}):null]}),s.jsxs("div",{className:Ee("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!P.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(_,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),ne?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:vd(ne,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:Z4(ne,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(_,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),I==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(_,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):ue?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(_,{name:X.Icon,className:"h-3.5 w-3.5"}),Z]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:vd(ue,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),P.state?.lastError?s.jsxs("div",{className:Ee("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!P.enabled&&"opacity-60"),style:t5("error"),children:[s.jsx(_,{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:P.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Ee("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",P.enabled?"text-foreground":"text-muted-foreground",D&&"cursor-not-allowed opacity-50"),children:[s.jsx(xr,{checked:P.enabled,onChange:se=>{R(P,se)},ariaLabel:P.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:P.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:P.name}),disabled:D}),P.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(ct,{variant:"outline",size:"sm",onClick:()=>{B(P)},disabled:D,children:[s.jsx(_,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(ct,{variant:"outline",size:"sm",onClick:()=>O(P),disabled:D,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:P.name}),children:[s.jsx(_,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(ct,{variant:"destructive",size:"sm",onClick:()=>{A(P)},disabled:D,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:P.name}),children:s.jsx(_,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},P.id)})})}),$=s.jsxs("div",{className:"space-y-4",children:[T,W]});return s.jsxs(s.Fragment,{children:[r?s.jsx(ti,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:P=>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")}),P]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(ct,{className:"w-full",onClick:M,disabled:!u,children:[s.jsx(_,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:$}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface-elevated",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(P=>s.jsx("button",{type:"button",onClick:()=>L(P.id),className:Ee("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-ring",u===P.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(P)},P.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(ct,{size:"sm",onClick:M,disabled:!u,children:[s.jsx(_,{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:W})})]})]})}):null,s.jsx(H4,{open:k,task:h,onOpenChange:w,onSave:E})]})}const Oo=100;function n5(){const t=tt.c(108),{t:e}=Nt(),n=Ne(f5),r=Ne(u5),i=rt(d5),o=rt(c5),l=os(l5);let a;t[0]!==n?(a=ne=>n?ne.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=vs(ar(a)),[u,m]=c.useState(""),[f,p]=c.useState(null),[y,x]=c.useState(Oo);let k;t[2]!==u?(k=u.trim().toLowerCase(),t[2]=u,t[3]=k):k=t[3];const w=k;let h;e:{if(!n){let ue;t[4]===Symbol.for("react.memo_cache_sentinel")?(ue=[],t[4]=ue):ue=t[4],h=ue;break e}let ne;t[5]!==d?(ne=[...d].sort(a5),t[5]=d,t[6]=ne):ne=t[6],h=ne}const g=h;let j;if(t[7]!==l||t[8]!==g||t[9]!==e){const ne=new Map;for(const ue of g){const se=xt(As(ue))??"",xe=ne.get(se);if(xe){xe.sessions.push(ue);continue}ne.set(se,{directory:se,label:se?ir(se,l)||se:e("sessions.archivePage.otherProjects"),sessions:[ue]})}j=[...ne.values()].sort(i5),t[7]=l,t[8]=g,t[9]=e,t[10]=j}else j=t[10];const b=j;let S;e:{if(w){if(w.startsWith("ses_")){let se;if(t[11]!==w||t[12]!==g){let xe;t[14]!==w?(xe=ie=>ie.id.toLowerCase()===w,t[14]=w,t[15]=xe):xe=t[15],se=g.filter(xe),t[11]=w,t[12]=g,t[13]=se}else se=t[13];S=se;break e}let ue;t[16]!==w||t[17]!==g?(ue=Yg(g,w,o5),t[16]=w,t[17]=g,t[18]=ue):ue=t[18],S=ue;break e}if(f===null){S=g;break e}let ne;t[19]!==b||t[20]!==f?(ne=b.find(ue=>ue.directory===f)?.sessions??[],t[19]=b,t[20]=f,t[21]=ne):ne=t[21],S=ne}const C=S;let v,E,R,A,O,B,T,M,L,W;if(t[22]!==d.length||t[23]!==b||t[24]!==C||t[25]!==l||t[26]!==w||t[27]!==n||t[28]!==u||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==y){O=Symbol.for("react.early_return_sentinel");e:{const ne=C.slice(0,y);v=C.length-ne.length;const ue=d.length;let se;t[45]===Symbol.for("react.memo_cache_sentinel")?(se=ge=>{p(ge),x(Oo)},t[45]=se):se=t[45];const xe=se;let ie;t[46]!==i||t[47]!==r?(ie=ge=>{const q=xt(As(ge));i(ge.id,q??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=ie):ie=t[48];const Re=ie;let be;t[49]!==e||t[50]!==o?(be=ge=>{o(ge.id).then(q=>{q?Ke.success(e("sessions.sidebar.session.restore.success")):Ke.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=be):be=t[51];const fe=be;if(!n){O=null;break e}let ke;t[52]!==e?(ke=(ge,q,z,ee,de,Y,U)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:de,title:Y,className:Ee("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-ring",U?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",ee?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:q}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:z})]}),U?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>un.requestDelete({sessions:U,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-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:q}),children:s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},ge),t[52]=e,t[53]=ke):ke=t[53];const H=ke;A="absolute inset-0 z-10 flex flex-col bg-background",E="flex min-h-0 flex-1";let J;if(t[54]!==H||t[55]!==f||t[56]!==e||t[57]!==ue){let ge;t[59]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>xe(null),t[59]=ge):ge=t[59],J=H("__all__",e("sessions.archivePage.allDirectories"),ue,f===null,ge),t[54]=H,t[55]=f,t[56]=e,t[57]=ue,t[58]=J}else J=t[58];let ce;if(t[60]!==b||t[61]!==H||t[62]!==f){let ge;t[64]!==H||t[65]!==f?(ge=q=>H(q.directory||"__none__",q.label,q.sessions.length,f===q.directory,()=>xe(q.directory),q.directory||void 0,q.sessions),t[64]=H,t[65]=f,t[66]=ge):ge=t[66],ce=b.map(ge),t[60]=b,t[61]=H,t[62]=f,t[63]=ce}else ce=t[63];t[67]!==J||t[68]!==ce?(R=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:[J,ce]})}),t[67]=J,t[68]=ce,t[69]=R):R=t[69],L="flex min-w-0 flex-1 flex-col";let je;t[70]===Symbol.for("react.memo_cache_sentinel")?(je=ge=>{m(ge),x(Oo)},t[70]=je):je=t[70];let G;t[71]!==e?(G=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=G):G=t[72];let we;t[73]!==e?(we=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=we):we=t[74];let Te;t[75]!==u||t[76]!==G||t[77]!==we?(Te=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Qd,{value:u,onSearch:je,placeholder:G,clearLabel:we})}),t[75]=u,t[76]=G,t[77]=we,t[78]=Te):Te=t[78];let he;t[79]!==C.length||t[80]!==e?(he=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]=he):he=t[81];let re;t[82]!==he?(re=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:he}),t[82]=he,t[83]=re):re=t[83],t[84]!==Te||t[85]!==re?(W=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Te,re]}),t[84]=Te,t[85]=re,t[86]=W):W=t[86],M="min-h-0 flex-1 overflow-y-auto px-6 py-3",B="mx-auto w-full max-w-3xl space-y-0.5",T=ne.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(w?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):ne.map(ge=>{const q=xt(As(ge))??"",z=q?ir(q,l)||q:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>Re(ge),role:"button",tabIndex:0,onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&(ee.preventDefault(),Re(ge))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:ge.title||e("sessions.sidebar.session.untitled")}),w&&z?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:q,children:z}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Wu(ge.time?.archived??ge.time?.updated??ge.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),fe(ge)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:ge.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(_,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),un.requestDelete({sessions:[ge],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:ge.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(_,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},ge.id)})}t[22]=d.length,t[23]=b,t[24]=C,t[25]=l,t[26]=w,t[27]=n,t[28]=u,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=y,t[35]=v,t[36]=E,t[37]=R,t[38]=A,t[39]=O,t[40]=B,t[41]=T,t[42]=M,t[43]=L,t[44]=W}else v=t[35],E=t[36],R=t[37],A=t[38],O=t[39],B=t[40],T=t[41],M=t[42],L=t[43],W=t[44];if(O!==Symbol.for("react.early_return_sentinel"))return O;let $;t[87]!==v||t[88]!==e?($=v>0?s.jsx("button",{type:"button",onClick:()=>x(r5),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]=v,t[88]=e,t[89]=$):$=t[89];let P;t[90]!==$||t[91]!==B||t[92]!==T?(P=s.jsxs("div",{className:B,children:[T,$]}),t[90]=$,t[91]=B,t[92]=T,t[93]=P):P=t[93];let D;t[94]!==P||t[95]!==M?(D=s.jsx("div",{className:M,children:P}),t[94]=P,t[95]=M,t[96]=D):D=t[96];let I;t[97]!==D||t[98]!==L||t[99]!==W?(I=s.jsxs("div",{className:L,children:[W,D]}),t[97]=D,t[98]=L,t[99]=W,t[100]=I):I=t[100];let X;t[101]!==E||t[102]!==R||t[103]!==I?(X=s.jsxs("div",{className:E,children:[R,I]}),t[101]=E,t[102]=R,t[103]=I,t[104]=X):X=t[104];let Z;return t[105]!==A||t[106]!==X?(Z=s.jsx("div",{className:A,children:X}),t[105]=A,t[106]=X,t[107]=Z):Z=t[107],Z}function r5(t){return t+Oo}function o5(t){return[t.title]}function i5(t,e){return e.sessions.length-t.sessions.length}function a5(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function l5(t){return t.homeDirectory}function c5(t){return t.unarchiveSession}function d5(t){return t.setCurrentSession}function u5(t){return t.setArchivePageOpen}function f5(t){return t.isArchivePageOpen}function m5(){const t=tt.c(18),{t:e}=Nt(),n=Ne(g5),r=Ne(p5),i=Ut(h5);let o;t[0]!==n?(o=y=>y.projects.find(x=>x.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Ut(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(_,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==a||t[10]!==u?(m=s.jsx("div",{className:"flex items-center",children:s.jsxs(ct,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=m):m=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(zh,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let p;return t[15]!==m||t[16]!==f?(p=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[m,f]})})}),t[15]=m,t[16]=f,t[17]=p):p=t[17],p}function h5(t){return t.setActiveProjectIdOnly}function p5(t){return t.setNewWorktreeDialogOpen}function g5(t){return t.worktreesPageProjectId}function am(t){const e=tt.c(30),{git:n}=wn(),r=vu(t),i=Su(t),o=Qg(t),l=Xg(t),a=Tn(v5),d=Tn(w5);let u,m;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==i||e[4]!==o?(u=()=>{!t||!n||i!==null||o||d(t,n,{silent:!0})},m=[t,n,d,i,o],e[0]=t,e[1]=d,e[2]=n,e[3]=i,e[4]=o,e[5]=u,e[6]=m):(u=e[5],m=e[6]),c.useEffect(u,m);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(f=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=f):f=e[12];const p=r?.all;let y;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==p?(y=[t,n,i,p,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=p,e[18]=y):y=e[18],c.useEffect(f,y);const x=o||i===!0&&l;let k;e:{if(!r?.all){let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[19]=v):v=e[19],k=v;break e}let C;e[20]!==r.all?(C=r.all.filter(y5).sort(),e[20]=r.all,e[21]=C):C=e[21],k=C}const w=k;let h;e:{if(!r?.all){let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[22]=v):v=e[22],h=v;break e}let C;e[23]!==r.all?(C=r.all.filter(b5).map(x5).sort(),e[23]=r.all,e[24]=C):C=e[24],h=C}const g=h;let j;e:{if(!t){j=null;break e}if(i!==null){j=i;break e}if(x){j=null;break e}j=r?.all?!0:null}const b=j;let S;return e[25]!==b||e[26]!==x||e[27]!==w||e[28]!==g?(S={localBranches:w,remoteBranches:g,isLoading:x,isGitRepository:b},e[25]=b,e[26]=x,e[27]=w,e[28]=g,e[29]=S):S=e[29],S}function x5(t){return t.replace(/^remotes\//,"")}function b5(t){return t.startsWith("remotes/")}function y5(t){return!t.startsWith("remotes/")}function w5(t){return t.fetchStatus}function v5(t){return t.fetchBranches}const S5=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=Nt(),{localBranches:a,remoteBranches:d,isLoading:u,isGitRepository:m}=am(t),f=c.useMemo(()=>[...a,...d.map(y=>`remotes/${y}`)],[a,d]);c.useEffect(()=>{if(i||u||f.length===0||e&&f.includes(e))return;const y=e;let x=!1;return(async()=>{try{const w=t?await za(t).catch(()=>null):null;if(x)return;const h=localStorage.getItem(Nl),{sourceBranch:g,shouldClearSavedSourceBranch:j}=Wh({branches:f,savedSourceBranch:h,rootBranch:w});if(j&&localStorage.removeItem(Nl),x||y&&f.includes(y))return;g&&n(g)}catch{}})(),()=>{x=!0}},[f,t,i,u,n,e]);const p=i||!m||u;return s.jsxs("div",{children:[s.jsxs(Rs,{value:e,onValueChange:n,disabled:p,children:[s.jsx(Ms,{id:o,size:"lg",className:Ee("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(js,{placeholder:l(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Os,{className:"max-h-[280px] max-w-[320px]",children:u?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&d.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(oa,{children:[s.jsx(zl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(y=>s.jsx(rs,{value:y,className:"whitespace-normal break-all",children:y},y))]}),a.length>0&&d.length>0&&s.jsx(Jg,{}),d.length>0&&s.jsxs(oa,{children:[s.jsx(zl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),d.map(y=>s.jsx(rs,{value:`remotes/${y}`,className:"whitespace-normal break-all",children:y},`remotes/${y}`))]})]})})]}),m===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},j5=10*1024*1024,Bo=t=>{const e=tt.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(St,{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(_,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(vt,{children:[r,s.jsx(jt,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Jn=t=>{const e=tt.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const d=o&&o;let u;return e[6]!==a||e[7]!==d?(u=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,d]}),e[6]=a,e[7]=d,e[8]=u):u=e[8],u},k5=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=Nt(),[o,l]=c.useState(""),[a,d]=c.useState(()=>[{id:Gr(),prompt:"",models:[]}]),[u,m]=c.useState(""),[f,p]=c.useState([]),[y,x]=c.useState(!1),[k,w]=c.useState([]),[h,g]=c.useState(!1),[j,b]=c.useState(!1),[S,C]=c.useState(!0),v=c.useRef(null),E=os(F=>F.currentDirectory??null),R=os(F=>F.homeDirectory??null),A=c.useMemo(()=>{if(typeof window>"u")return null;const F=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof F=="string"&&F.trim().length>0?F.trim():null},[]),O=Ut(F=>F.activeProjectId),B=Ut(F=>F.setActiveProjectIdOnly),T=Ut(F=>F.projects),[M,L]=c.useState(()=>O??null);c.useEffect(()=>{if(O){L(O);return}!M&&T.length>0&&L(T[0].id)},[O,T,M]);const W=c.useMemo(()=>M?T.find(F=>F.id===M)??null:null,[T,M]),$=W?.path??E,P=c.useCallback(F=>{L(F),F!==O&&B(F)},[O,B]),{currentTheme:D}=Ln(),I=c.useCallback(F=>{const V=F.label?.trim()||ir(F.path,R),oe=F.icon?ni[F.icon]:null,ae=F.color?ri[F.color]:void 0,pe=oe?s.jsx(_,{name:oe,className:"h-3.5 w-3.5 shrink-0",style:ae?{color:ae}:void 0}):s.jsx(_,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:ae?{color:ae}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[F.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:F.iconBackground?{backgroundColor:F.iconBackground}:void 0,children:s.jsx(oi,{project:{id:F.id,iconImage:F.iconImage??null},options:{themeVariant:D.metadata.variant,iconColor:D.colors.surface.foreground},className:"h-full w-full object-contain",fallback:pe})}):pe,s.jsx("span",{className:"truncate",children:V})]})},[R,D.metadata.variant,D.colors.surface.foreground]),X=c.useMemo(()=>{if(W?.path)return{id:W.id,path:W.path};const F=E??A;return F?{id:`path:${F}`,path:F}:null},[W,E,A]),[Z]=c.useState(()=>typeof window<"u"?xn():!1),ne=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),ue=du(),se=c.useMemo(()=>{if(typeof window>"u")return null;const F=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof F=="number"&&Number.isFinite(F)&&F>0)return F;if(typeof navigator>"u")return null;const V=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!V)return null;const oe=Number.parseInt(V[1],10),ae=Number.parseInt(V[2],10);return Number.isNaN(oe)?null:oe===10?ae:oe},[]),xe=c.useMemo(()=>Z&&ne||ue?"pl-[88px]":"pl-3",[Z,ne,ue]),ie=c.useMemo(()=>!Z||!ne||se===null?"":se>=26?"h-12":se<=15?"h-14":"",[Z,ne,se]),Re=c.useCallback(async F=>{F.target.closest("button, a, input, select, textarea")||F.button===0&&Z&&await Zg()},[Z]);c.useEffect(()=>{if(!n)return;const F=V=>{V.key==="Escape"&&(V.preventDefault(),V.stopPropagation(),n())};return window.addEventListener("keydown",F,!0),()=>window.removeEventListener("keydown",F,!0)},[n]);const[be,fe]=c.useState(""),{isLoading:ke,isGitRepository:H}=am($),J=c.useRef(!1),ce=H===!0,je=ce&&S;c.useEffect(()=>{if(H===!1){J.current=!0,C(!1);return}H===!0&&J.current&&(J.current=!1,C(!0))},[H]);const G=Ni(F=>F.createMultiRun),we=Ni(F=>F.error),Te=Ni(F=>F.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(F=>{const V=[...F];return V.length>0&&!V[0].prompt.trim()&&(V[0]={...V[0],prompt:t}),V})},[t]),c.useEffect(()=>{if(!X)return;let F=!1;return b(!0),(async()=>{try{const V=await ex(X);F||w(V)}catch{}finally{F||b(!1)}})(),()=>{F=!0}},[X]);const he=c.useCallback((F,V)=>{d(oe=>oe.map(ae=>ae.id===F?{...ae,...V}:ae))},[]),re=c.useCallback(F=>{d(V=>V.filter(oe=>oe.id!==F))},[]),ge=c.useCallback(()=>{d(F=>[...F,{id:Gr(),prompt:"",models:[]}])},[]),q=async F=>{const V=F.target.files;if(!V)return;let oe=0;for(let ae=0;ae<V.length;ae++){const pe=V[ae];if(pe.size>j5){Ke.error(i("multirun.launcher.toast.fileTooLarge",{fileName:pe.name}));continue}try{const le=await new Promise((_e,Fe)=>{const Me=new FileReader;Me.onload=()=>_e(Me.result),Me.onerror=Fe,Me.readAsDataURL(pe)});p(_e=>[..._e,{id:Gr(),filename:pe.name,mimeType:pe.type||"application/octet-stream",size:pe.size,dataUrl:le}]),oe++}catch(le){console.error("File attach failed",le),Ke.error(i("multirun.launcher.toast.attachFailed",{fileName:pe.name}))}}oe>0&&Ke.success(oe===1?i("multirun.launcher.toast.attachedSingle",{count:oe}):i("multirun.launcher.toast.attachedPlural",{count:oe})),v.current&&(v.current.value="")},z=F=>{p(V=>V.filter(oe=>oe.id!==F))},ee=c.useMemo(()=>a.reduce((F,V)=>F+V.models.length,0),[a]),de=async F=>{F.preventDefault();const V=a.filter(oe=>oe.prompt.trim()&&oe.models.length>=1);if(V.length!==0&&!(ee<1)){x(!0),Te();try{M&&M!==O&&B(M);const oe=f.map(Fe=>({mime:Fe.mimeType,filename:Fe.filename,url:Fe.dataUrl})),ae=k.filter(Fe=>Fe.trim().length>0),pe=V.map(Fe=>({prompt:Fe.prompt.trim(),models:Fe.models.map(Me=>({providerID:Me.providerID,modelID:Me.modelID,displayName:Me.displayName,variant:Me.variant}))})),le={name:o.trim(),groups:pe,agent:u||void 0,worktreeBaseBranch:je?be:void 0,isolateRuns:je,files:oe.length>0?oe:void 0,setupCommands:ae.length>0?ae:void 0},_e=await G(le);_e&&(_e.failedCount>0&&Ke.error(i("multirun.launcher.toast.partialFailure",{failed:_e.failedCount})),_e.firstSessionId&&rt.getState().setCurrentSession(_e.firstSessionId),e?.())}finally{x(!1)}}},Y=!!(o.trim()&&a.some(F=>F.prompt.trim()&&F.models.length>=1)&&ee>=1&&$&&!ke&&(H===!1||!je||be)),U=k.filter(F=>F.trim()).length;return s.jsxs("form",{onSubmit:de,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:Re,className:Ee("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",xe,ie),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(vt,{children:[s.jsx(St,{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-ring app-region-no-drag",children:s.jsx(_,{name:"close",className:"h-5 w-5"})})}),s.jsx(jt,{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(Jn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),T.length>0?s.jsxs(Rs,{value:M??void 0,onValueChange:P,children:[s.jsx(Ms,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:W?s.jsx(js,{children:I(W)}):s.jsx(js,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(Os,{fitContent:!0,children:T.map(F=>s.jsx(rs,{value:F.id,className:"max-w-[24rem]",children:I(F)},F.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(Jn,{htmlFor:"group-name",required:!0,info:s.jsx(Bo,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(An,{id:"group-name",value:o,onChange:F=>l(F.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(Jn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Bo,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(S5,{directory:$,value:be,onChange:fe,disabled:!je,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(xr,{checked:S,onChange:C,disabled:!ce,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(Jn,{htmlFor:"multirun-agent",info:s.jsx(Bo,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(Yf,{value:u,onChange:m,id:"multirun-agent"})]})]}),s.jsxs(Zi,{open:h,onOpenChange:g,children:[s.jsxs(wu,{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(_,{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")}),U>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:U}),s.jsx(_,{name:"arrow-down-s",className:Ee("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",h&&"rotate-180")})]}),s.jsx(ea,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:j?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[k.map((F,V)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(An,{value:F,onChange:oe=>{const ae=[...k];ae[V]=oe.target.value,w(ae)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>w(k.filter((oe,ae)=>ae!==V)),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-ring","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(_,{name:"close",className:"h-3.5 w-3.5"})})]},`${F}-${V}`)),s.jsxs("button",{type:"button",onClick:()=>w([...k,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(_,{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(Jn,{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:v,type:"file",multiple:!0,className:"hidden",onChange:q,accept:"*/*"}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>v.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(_,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(jt,{children:i("multirun.launcher.attachments.tooltip")})]}),f.map(F=>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:[F.mimeType.startsWith("image/")?s.jsx(_,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(_,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:F.filename,children:F.filename}),s.jsx("button",{type:"button",onClick:()=>z(F.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(_,{name:"close",className:"h-3 w-3"})})]},F.id))]})]}),a.map((F,V)=>s.jsx(C5,{group:F,groupIndex:V,canRemove:a.length>1,onUpdate:he,onRemove:re},F.id)),s.jsxs("button",{type:"button",onClick:ge,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(_,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),we&&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:we})]})})}),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:[!je&&H!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(_,{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(ct,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(ct,{type:"submit",size:"sm",disabled:!Y||y,children:y?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:ee})})})]})})]})},C5=t=>{const e=tt.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=Nt(),[d,u]=c.useState(!1),[m,f]=c.useState(""),[p,y]=c.useState(!1),[x,k]=c.useState(""),[w,h]=c.useState(!1),[g,j]=c.useState(""),b=c.useRef(null),S=c.useRef(null),C=c.useRef(null),v=c.useRef(null);let E;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(E=ae=>{o(n.id,{models:[...n.models,ae]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=E):E=e[3];const R=E;let A;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(A=ae=>{o(n.id,{models:n.models.filter((pe,le)=>le!==ae)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=A):A=e[7];const O=A;let B;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(B=(ae,pe)=>{o(n.id,{models:n.models.map((le,_e)=>_e===ae?pe:le)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=B):B=e[11];const T=B;let M;e[12]===Symbol.for("react.memo_cache_sentinel")?(M=(ae,pe)=>{if(ae.startsWith("/")){const Me=ae.indexOf(" "),Ae=ae.indexOf(`
893
893
  `),Q=Math.min(Me===-1?ae.length:Me,Ae===-1?ae.length:Ae);if(pe<=Q&&Me===-1){k(ae.substring(1,Q)),y(!0),u(!1),h(!1);return}}y(!1);const le=ae.substring(0,pe),_e=le.lastIndexOf("#");if(_e!==-1){const Me=_e>0?le[_e-1]:null,Ae=le.substring(_e+1);if((!Me||/\s/.test(Me))&&!Ae.includes(" ")&&!Ae.includes(`
894
894
  `)){j(Ae),h(!0),u(!1);return}}h(!1);const Fe=le.lastIndexOf("@");if(Fe!==-1){const Me=Fe>0?le[Fe-1]:null,Ae=le.substring(Fe+1);(!Me||/\s/.test(Me))&&!Ae.includes(" ")&&!Ae.includes(`
895
- `)?(f(Ae),u(!0)):u(!1);return}u(!1)},e[12]=M):M=e[12];const L=M;let W;e[13]!==n.id||e[14]!==o?(W=ae=>{o(n.id,{prompt:ae})},e[13]=n.id,e[14]=o,e[15]=W):W=e[15];const $=W;let P;e[16]!==n.prompt||e[17]!==$?(P=ae=>{const pe=n.prompt,_e=b.current?.selectionStart??pe.length,Me=pe.substring(0,_e).lastIndexOf("@"),Ae=ae.relativePath&&ae.relativePath.trim().length>0?ae.relativePath.trim():ae.path||ae.name,Q=Me!==-1?Me:_e,Ce=`${pe.substring(0,Q)}@${Ae} ${pe.substring(_e)}`,Be=Q+Ae.length+2;$(Ce),u(!1),f(""),requestAnimationFrame(()=>{const Le=b.current;Le&&(Le.selectionStart=Be,Le.selectionEnd=Be,Le.focus()),L(Ce,Be)})},e[16]=n.prompt,e[17]=$,e[18]=P):P=e[18];const D=P;let I;e[19]!==n.prompt||e[20]!==$?(I=ae=>{const pe=n.prompt,_e=b.current?.selectionStart??pe.length,Me=pe.substring(0,_e).lastIndexOf("@"),Ae=Me!==-1?Me:_e,Q=`${pe.substring(0,Ae)}@${ae} ${pe.substring(_e)}`,Ce=Ae+ae.length+2;$(Q),u(!1),f(""),requestAnimationFrame(()=>{const Be=b.current;Be&&(Be.selectionStart=Ce,Be.selectionEnd=Ce,Be.focus()),L(Q,Ce)})},e[19]=n.prompt,e[20]=$,e[21]=I):I=e[21];const X=I;let Z;e[22]!==$?(Z=ae=>{const pe=`/${ae.name} `;$(pe),y(!1),k(""),h(!1),requestAnimationFrame(()=>{const le=b.current;le&&(le.focus(),le.selectionStart=le.value.length,le.selectionEnd=le.value.length),L(pe,pe.length)})},e[22]=$,e[23]=Z):Z=e[23];const ne=Z;let ue;e[24]!==n.prompt||e[25]!==$?(ue=(ae,pe)=>{const le=n.prompt,Fe=b.current?.selectionStart??le.length,Ae=le.substring(0,Fe).lastIndexOf("#"),Q=Ae!==-1?Ae:Fe,Ce=`${le.substring(0,Q)}#${pe} ${le.substring(Fe)}`,Be=Q+pe.length+2;$(Ce),h(!1),j(""),requestAnimationFrame(()=>{const Le=b.current;Le&&(Le.selectionStart=Be,Le.selectionEnd=Be,Le.focus()),L(Ce,Be)})},e[24]=n.prompt,e[25]=$,e[26]=ue):ue=e[26];const se=ue;let xe;e[27]!==p||e[28]!==d||e[29]!==w?(xe=ae=>{if(p&&C.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")){ae.preventDefault(),C.current.handleKeyDown(ae.key);return}d&&S.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),S.current.handleKeyDown(ae.key)),w&&v.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),v.current.handleKeyDown(ae.key))},e[27]=p,e[28]=d,e[29]=w,e[30]=xe):xe=e[30];const ie=xe,Re=r+1;let be;e[31]!==a||e[32]!==Re?(be=a("multirun.launcher.groups.groupLabel",{index:Re}),e[31]=a,e[32]=Re,e[33]=be):be=e[33];let fe;e[34]!==be?(fe=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:be}),e[34]=be,e[35]=fe):fe=e[35];let ke;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(ke=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(_,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=ke):ke=e[40];let H;e[41]!==fe||e[42]!==ke?(H=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[fe,ke]}),e[41]=fe,e[42]=ke,e[43]=H):H=e[43];let J;e[44]!==a?(J=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=J):J=e[45];let ce;e[46]!==J?(ce=s.jsx(Jn,{required:!0,children:J}),e[46]=J,e[47]=ce):ce=e[47];const je=n.prompt;let G;e[48]!==$?(G=ae=>{const pe=ae.target.value;$(pe);const le=ae.target.selectionStart??pe.length;L(pe,le)},e[48]=$,e[49]=G):G=e[49];let we;e[50]!==a?(we=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=we):we=e[51];let Te;e[52]!==n.prompt||e[53]!==ie||e[54]!==G||e[55]!==we?(Te=s.jsx(pr,{ref:b,value:je,onChange:G,onKeyDown:ie,placeholder:we,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]=ie,e[54]=G,e[55]=we,e[56]=Te):Te=e[56];let he;e[57]!==x||e[58]!==ne||e[59]!==p?(he=p?s.jsx(Ku,{ref:C,searchQuery:x,onCommandSelect:ne,onClose:()=>y(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=x,e[58]=ne,e[59]=p,e[60]=he):he=e[60];let re;e[61]!==X||e[62]!==D||e[63]!==m||e[64]!==d?(re=d?s.jsx(Vu,{ref:S,searchQuery:m,onFileSelect:D,onAgentSelect:X,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=X,e[62]=D,e[63]=m,e[64]=d,e[65]=re):re=e[65];let ge;e[66]!==se||e[67]!==w||e[68]!==g?(ge=w?s.jsx(Uu,{ref:v,searchQuery:g,onSnippetSelect:se,onClose:()=>h(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=se,e[67]=w,e[68]=g,e[69]=ge):ge=e[69];let q;e[70]!==Te||e[71]!==he||e[72]!==re||e[73]!==ge?(q=s.jsxs("div",{className:"relative",children:[Te,he,re,ge]}),e[70]=Te,e[71]=he,e[72]=re,e[73]=ge,e[74]=q):q=e[74];let z;e[75]!==ce||e[76]!==q?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ce,q]}),e[75]=ce,e[76]=q,e[77]=z):z=e[77];let ee;e[78]!==a?(ee=a("multirun.launcher.models.info"),e[78]=a,e[79]=ee):ee=e[79];let de;e[80]!==ee?(de=s.jsx(Bo,{children:ee}),e[80]=ee,e[81]=de):de=e[81];let Y;e[82]!==a?(Y=a("multirun.launcher.models.label"),e[82]=a,e[83]=Y):Y=e[83];let U;e[84]!==de||e[85]!==Y?(U=s.jsx(Jn,{required:!0,info:de,children:Y}),e[84]=de,e[85]=Y,e[86]=U):U=e[86];let F;e[87]!==n.models||e[88]!==R||e[89]!==O||e[90]!==T?(F=s.jsx(Qf,{selectedModels:n.models,onAdd:R,onRemove:O,onUpdate:T,minModels:1}),e[87]=n.models,e[88]=R,e[89]=O,e[90]=T,e[91]=F):F=e[91];let V;e[92]!==U||e[93]!==F?(V=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[U,F]}),e[92]=U,e[93]=F,e[94]=V):V=e[94];let oe;return e[95]!==H||e[96]!==z||e[97]!==V?(oe=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[H,z,V]}),e[95]=H,e[96]=z,e[97]=V,e[98]=oe):oe=e[98],oe};function N5(t){const e=[],n=(r,i)=>{const o=xt(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const A5=t=>{const e=new Map;for(const n of t){const r=As(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},P5=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},D5=t=>{const e=tt.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=Qt(),m=A5(i),f=l.current?.runtimeKey===u?l.current.identities:null;for(const p of P5(f,m))tx({runtimeKey:u,...p});l.current={runtimeKey:u,identities:m}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},I5=new Map,T5=t=>{const e=tt.c(23),{isVSCode:n}=t,r=ii(),i=Ut(E5),o=os(R5),l=rt(M5);let a;e[0]!==n?(a=R=>n?I5:R.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=rt(a),u=!n;let m;e[2]!==d||e[3]!==i||e[4]!==u?(m=rm(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=m):m=e[5];const f=m,p=vs(O5),y=vs(B5),x=vs(F5),k=`session-list-sync:${c.useId()}`;let w,h;e[6]!==k||e[7]!==r||e[8]!==o||e[9]!==l?(w=()=>(r.setBootstrapDemand(k,N5({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(k)),h=[k,r,o,l],e[6]=k,e[7]=r,e[8]=o,e[9]=l,e[10]=w,e[11]=h):(w=e[10],h=e[11]),c.useEffect(w,h);const g=c.useRef(null);let j,b;e[12]!==n||e[13]!==f?(j=()=>{const R=new Set(f),A=g.current;g.current=R;const O=A?[...R].filter(B=>!A.has(B)):n?[...R]:[];O.length&&Fa(O,zo())},b=[n,f],e[12]=n,e[13]=f,e[14]=j,e[15]=b):(j=e[14],b=e[15]),c.useEffect(j,b);let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[16]=S):S=e[16],c.useEffect(_5,S);let C;e[17]!==y||e[18]!==p?(C=[...p,...y],e[17]=y,e[18]=p,e[19]=C):C=e[19];const v=C;let E;e[20]!==v||e[21]!==x?(E={enabled:!0,hasAuthoritativeGlobalSessions:x,sessions:v},e[20]=v,e[21]=x,e[22]=E):E=e[22],D5(E)};function E5(t){return t.projects}function R5(t){return t.currentDirectory}function M5(t){return t.currentSessionDirectory}function O5(t){return t.activeSessions}function B5(t){return t.archivedSessions}function F5(t){return t.status==="ready"}function _5(){let t=null,e=!1;const n=new Set,r=Wn(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(),ai(zo());return}const o=[...n];n.clear(),o.length&&Fa(o,zo())},500)});return()=>{t&&clearTimeout(t),r()}}const L5=Kn(()=>yn(()=>import("./SettingsWindow-BpvD6IYQ.js"),__vite__mapDeps([145,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,146,84,85,86,147,131,132,133,134,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,148,149,150])).then(t=>({default:t.SettingsWindow}))),$5=()=>{const t=tt.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],T5(e),Kh();const n=Ne(z5),r=Ne(W5),i=Ne(K5),o=Ne(V5),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const m=Ne(U5),f=Ne(H5),p=Ne(G5),y=Ne(q5),x=Ne(Y5),k=Ne(Q5),w=Ne(X5),h=Ne(J5),g=Eu();let j;if(t[4]!==g||t[5]!==h){let q;t[7]!==h?(q=z=>z.id===h,t[7]=h,t[8]=q):q=t[8],j=g.find(q),t[4]=g,t[5]=h,t[6]=j}else j=t[6];const b=j;let S,C;t[9]!==b||t[10]!==h?(S=()=>{h&&!b&&Ne.getState().setOpenGuestPage(null)},C=[h,b],t[9]=b,t[10]=h,t[11]=S,t[12]=C):(S=t[11],C=t[12]),c.useEffect(S,C);let v;t[13]===Symbol.for("react.memo_cache_sentinel")?(v=[],t[13]=v):v=t[13],c.useEffect(eC,v);const E=y||x||k||!!w||m||!!b;let R;t[14]===Symbol.for("react.memo_cache_sentinel")?(R=[],t[14]=R):R=t[14],c.useEffect(sC,R);const{isMobile:A}=$n();Vh();let O,B;t[15]!==A||t[16]!==r?(O=()=>{Ne.getState().isMobile!==A&&r(A)},B=[A,r],t[15]=A,t[16]=r,t[17]=O,t[18]=B):(O=t[17],B=t[18]),c.useEffect(O,B);let T,M,L,W,$;t[19]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(zS,{}),M=s.jsx(_0,{}),L=s.jsx(W0,{}),W=s.jsx(D4,{}),$=s.jsx(by,{}),t[19]=T,t[20]=M,t[21]=L,t[22]=W,t[23]=$):(T=t[19],M=t[20],L=t[21],W=t[22],$=t[23]);let P;t[24]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(xy,{}),t[24]=P):P=t[24];let D;t[25]!==n?(D=s.jsx(P4,{isVisible:n}),t[25]=n,t[26]=D):D=t[26];let I;t[27]!==A||t[28]!==n||t[29]!==D?(I=s.jsx(gy,{isOpen:n,isMobile:A,className:"border-border",topBar:P,children:D}),t[27]=A,t[28]=n,t[29]=D,t[30]=I):I=t[30];let X;t[31]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(hy,{}),t[31]=X):X=t[31];const Z=E&&"invisible";let ne;t[32]!==Z?(ne=Ee("absolute inset-0",Z),t[32]=Z,t[33]=ne):ne=t[33];const ue=!i&&!E;let se;t[34]!==ue?(se=s.jsx(Cs,{children:s.jsx(eu,{active:ue})}),t[34]=ue,t[35]=se):se=t[35];let xe;t[36]!==ne||t[37]!==se?(xe=s.jsx("div",{className:ne,children:se}),t[36]=ne,t[37]=se,t[38]=xe):xe=t[38];let ie;t[39]!==m||t[40]!==p||t[41]!==f?(ie=m&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Cs,{children:s.jsx(k5,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[39]=m,t[40]=p,t[41]=f,t[42]=ie):ie=t[42];let Re;t[43]===Symbol.for("react.memo_cache_sentinel")?(Re=s.jsx(Cs,{children:s.jsx(s5,{})}),t[43]=Re):Re=t[43];let be;t[44]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(Cs,{children:s.jsx(n5,{})}),t[44]=be):be=t[44];let fe;t[45]!==k?(fe=k&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Cs,{children:s.jsx(Uh,{})})}),t[45]=k,t[46]=fe):fe=t[46];let ke;t[47]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx(Cs,{children:s.jsx(m5,{})}),t[47]=ke):ke=t[47];let H;t[48]!==b?(H=b&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Cs,{children:s.jsx(cb,{mode:`plugin:${b.id}`,surface:"page",item:null,onDismiss:nC})})}),t[48]=b,t[49]=H):H=t[49];let J;t[50]!==xe||t[51]!==ie||t[52]!==fe||t[53]!==H?(J=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[xe,ie,Re,be,fe,ke,H]}),t[50]=xe,t[51]=ie,t[52]=fe,t[53]=H,t[54]=J):J=t[54];let ce;t[55]===Symbol.for("react.memo_cache_sentinel")?(ce=s.jsx(cS,{}),t[55]=ce):ce=t[55];let je;t[56]!==J?(je=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:[J,ce]})})}),t[56]=J,t[57]=je):je=t[57];let G;t[58]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Cs,{children:s.jsx(yS,{})})}),t[58]=G):G=t[58];let we;t[59]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(Cs,{children:s.jsx(Ox,{})}),t[59]=we):we=t[59];let Te;t[60]!==je?(Te=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[X,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[je,G,we]})]}),t[60]=je,t[61]=Te):Te=t[61];let he;t[62]!==I||t[63]!==Te?(he=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[I,Te]}),t[62]=I,t[63]=Te,t[64]=he):he=t[64];let re;t[65]!==i||t[66]!==o||t[67]!==l?(re=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(L5,{open:i,onOpenChange:o})}):null,t[65]=i,t[66]=o,t[67]=l,t[68]=re):re=t[68];let ge;return t[69]!==he||t[70]!==re?(ge=s.jsx(Hh,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[T,M,L,W,$,he,re]})}),t[69]=he,t[70]=re,t[71]=ge):ge=t[71],ge};function z5(t){return t.isSidebarOpen}function W5(t){return t.setIsMobile}function K5(t){return t.isSettingsDialogOpen}function V5(t){return t.setSettingsDialogOpen}function U5(t){return t.isMultiRunLauncherOpen}function H5(t){return t.setMultiRunLauncherOpen}function G5(t){return t.multiRunLauncherPrefillPrompt}function q5(t){return t.isScheduledTasksDialogOpen}function Y5(t){return t.isArchivePageOpen}function Q5(t){return t.isUsageStatsPageOpen}function X5(t){return t.worktreesPageProjectId}function J5(t){return t.openGuestPageId}function Z5(){return Ne.getState().setOpenGuestPage(null)}function eC(){return Cr(Z5)}function tC(){return Ne.getState().closeMainSurfaces()}function sC(){const t=tC,e=rt.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 nC(){return Ne.getState().setOpenGuestPage(null)}const lm=12,rC=[{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"}],oC=t=>{const e=tt.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,m=l===void 0?rC:l,f=ut.useRef(!1);let p,y;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},y=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=y):(p=e[2],y=e[3]),ut.useEffect(p,y);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=Array.from({length:lm},iC),e[4]=x):x=e[4];const k=x;if(!n)return null;let w;e[5]!==i?(w=Ee("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=w):w=e[6];let h;if(e[7]!==d||e[8]!==m||e[9]!==u){let j;e[11]!==d||e[12]!==u?(j=b=>{const S={"--burst-delay":`${b.delay}ms`,"--burst-x":`${b.x}%`,"--burst-y":`${b.y}%`,"--firework-color":`var(${b.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:S,children:k.map((C,v)=>{const E=C.x*b.radius,R=C.y*b.radius,A={"--translate-x":`${E}px`,"--translate-y":`${R}px`,"--particle-delay":`${C.delay}ms`,color:`var(${b.colorVar})`};return s.jsx("span",{className:"firework-particle",style:A},`${b.id}-${v}-${d}`)})},`${b.id}-${d}`)},e[11]=d,e[12]=u,e[13]=j):j=e[13],h=m.map(j),e[7]=d,e[8]=m,e[9]=u,e[10]=h}else h=e[10];let g;return e[14]!==d||e[15]!==w||e[16]!==h?(g=s.jsx("div",{className:w,"aria-hidden":"true","data-burst-key":d,children:h}),e[14]=d,e[15]=w,e[16]=h,e[17]=g):g=e[17],g};function iC(t,e){const n=Math.PI*2*e/lm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const aC=t=>{const e=tt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,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]=ut.useState(o),d=ut.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const m=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{m(),a(lC)},e[4]=f):f=e[4];const p=f;let y;e[5]!==i?(y=()=>{m(),a(cC),d.current=window.setTimeout(()=>{a(dC),d.current=null},i)},e[5]=i,e[6]=y):y=e[6];const x=y;let k,w;e[7]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>m(),w=[m],e[7]=k,e[8]=w):(k=e[7],w=e[8]),ut.useEffect(k,w);let h;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==x?(h={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:x,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=x,e[12]=h):h=e[12],h};function lC(t){return t.isActive?{...t,isActive:!1}:t}function cC(t){return{isActive:!0,cycle:t.cycle+1}}function dC(t){return t.isActive?{...t,isActive:!1}:t}const cm=c.createContext(void 0),uC=t=>{const e=tt.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=aC();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(oC,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let m;return e[6]!==n||e[7]!==u||e[8]!==d?(m=s.jsxs(cm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=m):m=e[9],m},nA=()=>{const t=c.useContext(cm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Ta="openchamber_requests_in_flight",dm=1e3,fC=300*1e3,Jo=Math.ceil(fC/dm),mC=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ta)==="1"}catch{return!1}},um=()=>({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 hC=1;const pC=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},gC=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},fm=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},jr=(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)},xC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=hC++;pC(o,Date.now());try{return await e(r,i)}finally{gC(o)}};window.fetch=n},Sd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Or=t=>{t.length>Jo&&t.splice(0,t.length-Jo)},bC=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=fm(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(jr(e,50)),t.p90Samples.push(jr(e,90)),t.p99Samples.push(jr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Or(t.samples),Or(t.p50Samples),Or(t.p90Samples),Or(t.p99Samples),Or(t.maxSamples),t.lastSampleAt=Date.now()},yC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(bC,dm))},jd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},kd=t=>{if(!(typeof window>"u"))try{if(t){jd(),Sd(),window.localStorage.setItem(Ta,"1"),window.__openchamberRequestsInFlight__=um(),xC(),yC();return}window.localStorage.removeItem(Ta),jd(),Sd(),delete window.__openchamberRequestsInFlight__}catch{}},wC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=um();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},Ea=()=>{if(typeof window>"u")return Cd();const t=window.__openchamberRequestsInFlight__;if(!mC()||!t)return Cd();const e=fm(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:jr(e,50),ageP90:jr(e,90),ageP99:jr(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:Jo}},Cd=()=>({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:Jo});function vC(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const mm=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`},Ra=t=>`${(t/1e3).toFixed(2)} s`,ws=t=>{const e=tt.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},Nd=t=>{const e=tt.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 d;e[8]!==r.entries?(d=r.entries.reduce(kC,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let m;e[10]!==n?(m=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?mm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let y;e[18]!==m||e[19]!==p?(y=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,p]}),e[18]=m,e[19]=p,e[20]=y):y=e[20];let x;e[21]!==o?(x=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=x):x=e[22];let k;e[23]!==r.entries.length||e[24]!==x?(k=s.jsx(ws,{label:x,value:r.entries.length}),e[23]=r.entries.length,e[24]=x,e[25]=k):k=e[25];let w;e[26]!==o?(w=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=w):w=e[27];let h;e[28]!==w||e[29]!==u?(h=s.jsx(ws,{label:w,value:u}),e[28]=w,e[29]=u,e[30]=h):h=e[30];let g;e[31]!==o?(g=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=g):g=e[32];let j;e[33]!==r.lastUpdatedAt||e[34]!==o?(j=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=j):j=e[35];let b;e[36]!==g||e[37]!==j?(b=s.jsx(ws,{label:g,value:j}),e[36]=g,e[37]=j,e[38]=b):b=e[38];let S;e[39]!==h||e[40]!==b||e[41]!==k?(S=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[k,h,b]}),e[39]=h,e[40]=b,e[41]=k,e[42]=S):S=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:[y,S,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(En,{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},Ad=t=>{const e=tt.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(CC,0),u=r>0?52/r:0;let m;e[0]!==d||e[1]!==a?(m=b=>a-d+b,e[0]=d,e[1]=a,e[2]=m):m=e[2];const f=m;let p;e[3]!==u?(p=b=>56-b*u,e[3]=u,e[4]=p):p=e[4];const y=p;let x;e[5]!==l?(x=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]=x):x=e[6];const k=`0 0 ${a} 56`;let w;e[7]!==a?(w=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]=w):w=e[8];let h;if(e[9]!==n||e[10]!==f||e[11]!==y){let b;e[13]!==f||e[14]!==y?(b=(S,C)=>{const v=S.samples.length;if(v===0)return null;const E=S.samples.map((A,O)=>`${f(O)},${y(A).toFixed(2)}`),R=`M ${E.join(" L ")}`;return s.jsxs(c.Fragment,{children:[S.filled?s.jsx("path",{d:`M ${f(0)},56 L ${E.join(" L ")} L ${f(v-1)},56 Z`,fill:`color-mix(in srgb, ${S.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:R,fill:"none",stroke:S.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=y,e[15]=b):b=e[15],h=n.map(b),e[9]=n,e[10]=f,e[11]=y,e[12]=h}else h=e[12];let g;e[16]!==o||e[17]!==k||e[18]!==w||e[19]!==h?(g=s.jsxs("svg",{viewBox:k,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[w,h]}),e[16]=o,e[17]=k,e[18]=w,e[19]=h,e[20]=g):g=e[20];let j;return e[21]!==x||e[22]!==g?(j=s.jsxs("div",{className:"relative w-full",children:[x,g]}),e[21]=x,e[22]=g,e[23]=j):j=e[23],j},SC=t=>{const e=tt.c(100),{onClose:n}=t,{t:r}=Nt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=rt(NC),u=$u(AC),m=Cu(),f=sx(PC),p=Vs(DC),[y,x]=c.useState(IC),[k,w]=c.useState(TC),[h,g]=c.useState(EC),j=[{label:"p50",current:h.ageP50,samples:h.p50Samples,color:"var(--status-success)"},{label:"p90",current:h.ageP90,samples:h.p90Samples,color:"var(--status-info)"},{label:"p99",current:h.ageP99,samples:h.p99Samples,color:"var(--status-warning)"},{label:"max",current:h.ageMax,samples:h.maxSamples,color:"var(--status-error)"}];let b;e[0]!==h.samples?(b=h.samples.reduce(RC,0),e[0]=h.samples,e[1]=b):b=e[1];const S=b,C=j.reduce(OC,0);let v;e[2]!==y.entries?(v=new Map,y.entries.forEach(Be=>{v.set(Be.metric,Be.count)}),e[2]=y.entries,e[3]=v):v=e[3];let E;e[4]!==v?(E=v.get("ui.message_list.render")??0,e[4]=v,e[5]=E):E=e[5];let R;e[6]!==v?(R=v.get("ui.message_list.render.streaming")??0,e[6]=v,e[7]=R):R=e[7];let A;e[8]!==v?(A=v.get("ui.chat_message.render")??0,e[8]=v,e[9]=A):A=e[9];let O;e[10]!==v?(O=v.get("ui.chat_message.render.streaming")??0,e[10]=v,e[11]=O):O=e[11];let B;e[12]!==v?(B=v.get("ui.chat_message.render.static_during_stream")??0,e[12]=v,e[13]=B):B=e[13];let T;e[14]!==v?(T=v.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=v,e[15]=T):T=e[15];let M;e[16]!==E||e[17]!==R||e[18]!==A||e[19]!==O||e[20]!==B||e[21]!==T?(M={messageListRender:E,messageListRenderStreaming:R,chatMessageRender:A,chatMessageRenderStreaming:O,chatMessageRenderStaticDuringStream:B,chatMessageRenderStaticOutsideActiveTurnDuringStream:T},e[16]=E,e[17]=R,e[18]=A,e[19]=O,e[20]=B,e[21]=T,e[22]=M):M=e[22];const L=M;let W,$;e[23]===Symbol.for("react.memo_cache_sentinel")?($=()=>{const Be=()=>{x(Po()),w(Do()),g(Ea())};Be();const Le=window.setInterval(Be,500);return()=>window.clearInterval(Le)},W=[],e[23]=W,e[24]=$):(W=e[23],$=e[24]),c.useEffect($,W);let P,D;e[25]!==l?(P=()=>{if(l==="idle")return;const Be=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Be)},D=[l],e[25]=l,e[26]=P,e[27]=D):(P=e[26],D=e[27]),c.useEffect(P,D);let I=0,X=0,Z=0;for(const Be of Object.keys(f)){const Le=f[Be]??[];X=X+Le.length;for(const Je of Le)Je.role==="user"?Z=Z+1:Je.role==="assistant"&&(I=I+1)}let ne;e[28]!==I||e[29]!==X||e[30]!==Z?(ne={assistant:I,total:X,user:Z},e[28]=I,e[29]=X,e[30]=Z,e[31]=ne):ne=e[31];const ue=ne;let se;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==m||e[36]!==r){let Be;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(Be=Le=>{const Je=f[Le.id]??[];let ot=0,et=0;for(const ht of Je)ht.role==="user"?et=et+1:ht.role==="assistant"&&(ot=ot+1);const it=u.get(Le.id);return{id:Le.id,title:Le.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ot,messageCount:Je.length,userMessageCount:et,isStreaming:it?.isStreaming||!1,isZombie:it?.isZombie||!1,backgroundCount:it?.backgroundMessageCount||0,lastAccessed:it?.lastAccessedAt||0,isCurrent:Le.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=Be):Be=e[42],se=m.map(Be).sort(BC),e[32]=d,e[33]=f,e[34]=u,e[35]=m,e[36]=r,e[37]=se}else se=e[37];const xe=se;let ie;e[43]!==f?(ie=Object.keys(f),e[43]=f,e[44]=ie):ie=e[44];const Re=ie.length;let be;e[45]===Symbol.for("react.memo_cache_sentinel")?(be=async()=>{try{const Be={generatedAt:new Date().toISOString(),ui:Po(),vscode:Do()};await navigator.clipboard.writeText(JSON.stringify(Be,null,2)),a("copied")}catch{a("error")}},e[45]=be):be=e[45];const fe=be,ke=rx,H="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let J;e[46]===Symbol.for("react.memo_cache_sentinel")?(J={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=J):J=e[46];let ce;e[47]!==i?(ce=vC(i),e[47]=i,e[48]=ce):ce=e[48];let je;e[49]!==ce?(je=s.jsx(_,{name:ce,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=ce,e[50]=je):je=e[50];let G;e[51]!==r?(G=r("memoryDebugPanel.title"),e[51]=r,e[52]=G):G=e[52];let we;e[53]!==G?(we=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:G}),e[53]=G,e[54]=we):we=e[54];let Te;e[55]!==je||e[56]!==we?(Te=s.jsxs("div",{className:"flex items-center gap-2",children:[je,we]}),e[55]=je,e[56]=we,e[57]=Te):Te=e[57];let he;e[58]!==i?(he=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(ct,{size:"xs",variant:"ghost",onClick:fe,children:s.jsx(_,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(ct,{size:"xs",variant:"ghost",onClick:()=>{eh(),x(Po()),w(Do())},children:s.jsx(_,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=he):he=e[59];let re;e[60]!==i?(re=i==="requests"?s.jsx(ct,{size:"xs",variant:"ghost",onClick:()=>{wC(),g(Ea())},children:s.jsx(_,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=re):re=e[61];let ge;e[62]!==n?(ge=n?s.jsx(ct,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(_,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=ge):ge=e[63];let q;e[64]!==he||e[65]!==re||e[66]!==ge?(q=s.jsxs("div",{className:"flex items-center gap-1",children:[he,re,ge]}),e[64]=he,e[65]=re,e[66]=ge,e[67]=q):q=e[67];let z;e[68]!==Te||e[69]!==q?(z=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Te,q]}),e[68]=Te,e[69]=q,e[70]=z):z=e[70];let ee;e[71]===Symbol.for("react.memo_cache_sentinel")?(ee={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=ee):ee=e[71];const de=i==="memory"?"secondary":"ghost";let Y;e[72]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>o("memory"),e[72]=Y):Y=e[72];let U;e[73]!==r?(U=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=U):U=e[74];let F;e[75]!==de||e[76]!==U?(F=s.jsx(ct,{size:"sm",variant:de,className:"flex-1",onClick:Y,children:U}),e[75]=de,e[76]=U,e[77]=F):F=e[77];const V=i==="streaming"?"secondary":"ghost";let oe;e[78]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>o("streaming"),e[78]=oe):oe=e[78];let ae;e[79]!==r?(ae=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=ae):ae=e[80];let pe;e[81]!==V||e[82]!==ae?(pe=s.jsx(ct,{size:"sm",variant:V,className:"flex-1",onClick:oe,children:ae}),e[81]=V,e[82]=ae,e[83]=pe):pe=e[83];const le=i==="requests"?"secondary":"ghost";let _e;e[84]===Symbol.for("react.memo_cache_sentinel")?(_e=()=>o("requests"),e[84]=_e):_e=e[84];let Fe;e[85]!==r?(Fe=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Fe):Fe=e[86];let Me;e[87]!==le||e[88]!==Fe?(Me=s.jsx(ct,{size:"sm",variant:le,className:"flex-1",onClick:_e,children:Fe}),e[87]=le,e[88]=Fe,e[89]=Me):Me=e[89];let Ae;e[90]!==F||e[91]!==pe||e[92]!==Me?(Ae=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ee,children:[F,pe,Me]}),e[90]=F,e[91]=pe,e[92]=Me,e[93]=Ae):Ae=e[93];const Q=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(ws,{label:r("memoryDebugPanel.metric.totalMessages"),value:ue.total}),s.jsx(ws,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Re} / ${Wl.MAX_SESSIONS}`}),s.jsx(ws,{label:r("memoryDebugPanel.metric.userMessages"),value:ue.user}),s.jsx(ws,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ue.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:nx()})})]}),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:Wl.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(En,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:xe.map(Be=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Be.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Be.title}),Be.isStreaming?s.jsx(_,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Be.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Be.assistantMessageCount,user:Be.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Be.messageCount})}),Be.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Be.backgroundCount]}):null]})]},Be.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(FC),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:ue,sessionMessageRoleCounts:xe.map(_C),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(jt,{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(ct,{size:"xs",variant:"outline",onClick:fe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(ws,{label:r("memoryDebugPanel.metric.uiMetrics"),value:y.entries.length}),s.jsx(ws,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:k.entries.length}),s.jsx(ws,{label:r("memoryDebugPanel.metric.messageListRenders"),value:L.messageListRender}),s.jsx(ws,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:L.messageListRenderStreaming}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:L.chatMessageRender}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:L.chatMessageRenderStreaming}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:L.chatMessageRenderStaticDuringStream}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:L.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Nd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:y,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),k.entries.length>0?s.jsx(Nd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:k,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(ws,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${h.totalSettled} / ${h.totalStarted}`}),s.jsx(ws,{label:r("memoryDebugPanel.requests.tracking"),value:h.startedAt?mm(h.durationMs):r("memoryDebugPanel.common.idle")})]}),h.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:h.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:h.peak})]})]}),s.jsx(Ad,{series:[{samples:h.samples,color:"var(--status-info)",filled:!0}],peak:S,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:h.peak}),maxLabel:`${S}`}),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:Ra(h.peakAgeMs)})]}),s.jsx(Ad,{series:j.map(LC),peak:C,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Ra(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:j.map($C)}),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:h.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let Ce;return e[94]!==ke||e[95]!==J||e[96]!==z||e[97]!==Ae||e[98]!==Q?(Ce=s.jsxs(ke,{className:H,style:J,children:[z,Ae,Q]}),e[94]=ke,e[95]=J,e[96]=z,e[97]=Ae,e[98]=Q,e[99]=Ce):Ce=e[99],Ce},jC=SC;function kC(t,e){return t+e.count}function CC(t,e){return Math.max(t,e.samples.length)}function NC(t){return t.currentSessionId}function AC(t){return t.sessionMemoryState}function PC(t){return t.message}function DC(t){return t.totalRequestCount}function IC(){return Po()}function TC(){return Do()}function EC(){return Ea()}function RC(t,e){return Math.max(t,e)}function MC(t,e){return Math.max(t,e)}function OC(t,e){return e.samples.reduce(MC,t)}function BC(t,e){return e.lastAccessed-t.lastAccessed}function FC(t){return{id:t.id,title:t.title}}function _C(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function LC(t){return{samples:t.samples,color:t.color}}function $C(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:Ra(t.current)})]},t.label)}const zC=()=>{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()??"":""},WC=async()=>{const t=zC()||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")},Pd="openchamber:menu-action",Vi="openchamber:check-for-updates",KC=t=>{const e=rt(h=>h.openNewSessionDraft),n=Ne(h=>h.toggleCommandPalette),r=Ne(h=>h.setCommandPaletteOpen),i=Ne(h=>h.toggleHelpDialog),o=Ne(h=>h.toggleSidebar),l=Ne(h=>h.setSessionSwitcherOpen),a=Ne(h=>h.setSettingsDialogOpen),d=Ne(h=>h.setAboutDialogOpen),u=Kr(h=>h.checkForUpdates),{setThemeMode:m}=Ln(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:h,error:g}=Kr.getState();if(g){Ke.error("Failed to check for updates",{description:g});return}h||Ke.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),y=c.useCallback(()=>{un.requestDirectoryDialog()},[]),x=c.useCallback(h=>{const g=ox();if(g.length===0)return;const j=rt.getState().currentSessionId,b=g.findIndex(v=>v.id===j);let S=h>0?0:g.length-1;b>=0&&(S=(b+h+g.length)%g.length);const C=g[S];C&&(l(!1),rt.getState().setCurrentSession(C.id))},[l]),k=c.useCallback(h=>{const{activeProjectId:g,projects:j,setActiveProject:b}=Ut.getState();if(j.length===0)return;const S=j.findIndex(E=>E.id===g);let C=h>0?0:j.length-1;S>=0&&(C=(S+h+j.length)%j.length);const v=j[C];v&&b(v.id)},[]),w=c.useCallback(h=>{switch(h){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const g=rt.getState(),j=os.getState().currentDirectory;e(g.currentSessionId&&j?{directoryOverride:j}:void 0)}break;case"new-worktree-session":l(!1),Iu();break;case"change-workspace":y();break;case"toggle-right-sidebar":{const g=os.getState().currentDirectory;if(!g)break;const j=Ne.getState(),b=Qn(g),S=j.contextPanelByDirectory[b];S?.isOpen?j.closeContextPanel(b):S?.activeTabId?j.setActiveContextPanelTab(b,S.activeTabId):j.openContextSurface(b,"git");break}case"open-right-sidebar-git":{const g=os.getState().currentDirectory;if(!g)break;Ne.getState().openContextSurface(Qn(g),"git");break}case"open-right-sidebar-files":{const g=os.getState().currentDirectory;if(!g)break;Ne.getState().openContextSurface(Qn(g),"file");break}case"toggle-terminal":{const g=os.getState().currentDirectory;if(!g)break;Ne.getState().openContextSurface(Qn(g),"terminal");break}case"toggle-terminal-expanded":{const g=os.getState().currentDirectory;if(!g)break;const j=Qn(g),b=Ne.getState(),S=b.contextPanelByDirectory[j];(S?.isOpen?S.tabs.find(v=>v.id===S.activeTabId)?.mode:null)!=="terminal"&&b.openContextSurface(j,"terminal"),b.toggleContextPanelExpanded(j);break}case"copy":{const g=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(g)||WC();break}case"theme-light":m("light");break;case"theme-dark":m("dark");break;case"theme-system":m("system");break;case"add-selection-to-chat":ix();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":os.getState().goBack();break;case"go-forward":os.getState().goForward();break;case"previous-session":x(-1);break;case"next-session":x(1);break;case"previous-project":k(-1);break;case"next-project":k(1);break;case"help-dialog":i();break;case"download-logs":{Tu().catch(()=>{Ke.error("Failed to collect OpenCode status")});break}}},[y,k,x,t,e,d,l,r,a,m,n,i,o]);c.useEffect(()=>{const h=j=>{const b=j.detail;b&&w(b)},g=()=>{p()};return window.addEventListener(Pd,h),window.addEventListener(Vi,g),()=>{window.removeEventListener(Pd,h),window.removeEventListener(Vi,g)}},[w,p]),c.useEffect(()=>{if(typeof window>"u")return;const g=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof g!="function")return;let j=null,b=null;return g("openchamber:menu-action",S=>{const C=S?.payload;typeof C=="string"&&w(C)}).then(S=>{j=S}).catch(()=>{}),g("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Vi))}).then(S=>{b=S}).catch(()=>{}),()=>{(async()=>{try{const C=j?.();C instanceof Promise&&await C}catch{}try{const C=b?.();C instanceof Promise&&await C}catch{}})()}},[w])},VC="openchamber:tray-action",UC=5e3,HC=500,GC=20,Dd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Id=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,hm=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},pm=t=>t.title.trim()||"Question",qC=(t,e)=>Xa(t,e,Qr.getState().ids,Ua.getState().rankById),YC=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},QC=(t,e,n,r,i)=>{if(!t)return"";const o=su(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||YC(t),d=Io(t);let u=d&&i.get(d)||"";if(!u){for(const[m,f]of Tn.getState().directories)if(Io(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(p=>Io(p.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},XC=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=hr.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 lx){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:dx(m),value:cx(f.valueLabel,p)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},JC=async()=>{try{if(Zo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Dn();if(e&&xl(e,t))return"Local OpenChamber";const r=(await Bd()).hosts.find(i=>e?xl(e,th(i)):!1);return r?.label?.trim()?Fd(r.label.trim()):"Instance"}catch{return""}},ZC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=la()}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(Io(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"permission",id:m.id,sessionId:f,sessionTitle:"",label:hm(m),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"form",id:m.id,sessionId:f,sessionTitle:"",label:pm(m),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},eN=(t,e)=>{const n=qa.getState().index.session,r=vs.getState().activeSessions,i=new Map;for(const g of r)if(g?.id&&g.parentID){const j=i.get(g.parentID)??[];j.push(g.id),i.set(g.parentID,j)}const o=g=>{const j=[],b=[...i.get(g)??[]],S=new Set;for(;b.length;){const C=b.pop();S.has(C)||(S.add(C),j.push(C),b.push(...i.get(C)??[]))}return j},l=Ne.getState();let a=0;if(l.dockBadgeEnabled)for(const g of r){if(!g?.id||g.parentID)continue;let j=n.unseenCount[g.id]??0;j===0&&l.notifyOnSubtasks&&(j=o(g.id).reduce((b,S)=>b+(n.unseenCount[S]??0),0)),j>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=ZC(),u=new Map(d.titleById);for(const g of r)g?.id&&g.title&&u.set(g.id,g.title);const m=si.getState().statusById,f=g=>{const j=d.statusById.get(g);return j&&j!=="idle"?j:m.get(g)?.status.type??j??"idle"},p=g=>{const j=g.map(b=>f(b));return j.includes("busy")?"busy":j.includes("retry")?"retry":"idle"},y=Ut.getState().projects,x=rt.getState().availableWorktreesByProject,k=r.filter(g=>g?.id&&!g.parentID).slice().sort(qC).slice(0,GC).map(g=>{const j=[g.id,...o(g.id)],b=As(g)??"";return{id:g.id,title:g.title||"Untitled session",status:p(j),branch:b?d.branchByDirectory.get(b)??"":"",unseen:j.reduce((S,C)=>S+(n.unseenCount[C]??0),0),hasError:j.some(S=>n.unseenHasError[S]??!1),directory:b,subtitle:QC(b,g,y,x,d.branchByDirectory)}}),w=d.approvals.map(g=>({...g,sessionTitle:u.get(g.sessionId)||""})),h=new Set(w.map(g=>g.id));for(const[g,j]of Ya.getState().bySession){const b=u.get(g)||"";for(const S of j.permissions)h.has(S.id)||(h.add(S.id),w.push({kind:"permission",id:S.id,sessionId:g,sessionTitle:b,label:hm(S),directory:j.directory}));for(const S of j.forms)h.has(S.id)||(h.add(S.id),w.push({kind:"form",id:S.id,sessionId:g,sessionTitle:b,label:pm(S),directory:j.directory}))}return{sessions:k,approvals:w,instanceName:t,usage:XC(),dockBadgeCount:a}},tN=()=>{c.useEffect(()=>{if(!Dd()||!qr())return;const t=Id();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const v=eN(i,t),E=JSON.stringify(v);E!==n&&(n=E,Fn("desktop_tray_update",v))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},HC))},a=qa.subscribe(()=>l()),d=vs.subscribe(()=>l()),u=Ne.subscribe((v,E)=>{(v.dockBadgeEnabled!==E.dockBadgeEnabled||v.notifyOnSubtasks!==E.notifyOnSubtasks)&&l()}),m=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),m;JC().then(v=>{e||(i=v,o())});const f=new Map,p=()=>{if(e)return;let v;try{v=la()}catch{return}const E=new Set;for(const[R,A]of v.children.entries())E.add(R),f.has(R)||f.set(R,A.subscribe(()=>l()));for(const[R,A]of f)E.has(R)||(A(),f.delete(R))};let y=null;try{y=la().subscribeRegistry(()=>{p(),l()})}catch{}p();const x=Ut.subscribe(()=>l()),k=rt.subscribe(()=>l()),w=Tn.subscribe(()=>l()),h=si.subscribe(()=>l()),g=Ya.subscribe(()=>l()),j=Ua.subscribe(()=>l()),b=Qr.subscribe(()=>l()),S=hr.subscribe(()=>l());hr.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:v,results:E}=hr.getState();v.length>0&&v.some(A=>!E.some(O=>O.providerId===A))&&hr.getState().fetchQuotas(v)});const C=window.setInterval(()=>{p(),o()},UC);return o(),()=>{m(),window.clearInterval(C),x(),k(),w(),h(),g(),j(),b(),S(),y?.();for(const v of f.values())v();f.clear()}},[]),c.useEffect(()=>{if(!Dd()||!Id()||!qr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&ax(i.sessionId,i.id,i.response).catch(()=>{Ke.error("Failed to respond to permission request")})};let r=null;return e(VC,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{}}},[])},sN=30*6e4,nN=(t,e,n=sN)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Br=null;const rN=()=>{if(Br)return Br;const t=Qt();return Br=(async()=>{const e=await dn.getHostSessionStatusSnapshot();if(!e||Qt()!==t)return;const n=si.getState(),r=vs.getState().entityById,i=nN(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?As(a):null}});for(const[l,a]of i)ux(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?As(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}fx(o)})().finally(()=>{Br=null}),Br},oN=45e3,iN=[1e3,2e3,4e3],aN=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const m=await u().catch(()=>!1);if(i)return;a||=m;const f=a?void 0:iN[l];f!==void 0&&(l+=1),o=n(()=>{o=void 0,d(e)},f??oN)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},lN=t=>{const e=tt.c(3);let n,r;e[0]!==t?(n=()=>{if(!t)return;const i=cN;let o=i();const l=Cr(()=>{o(),o=i()});return()=>{l(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function cN(){const t=Qt();let e=!0;const n=async i=>(i?await mx(zo()):await ai(),!e||Qt()!==t?!1:(rN(),vs.getState().status==="ready")),r=aN(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const dN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,uN=t=>{const e=tt.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!(!n||xn()||!Ma()||!globalThis.window))return Wn(fN)},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function fN(t){if(t.type!=="notification")return;const e=Ne.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&dN())return;Od()?.notifications?.notifyAgentCompletion(t.payload)}const mN=6e4,hN=t=>{const e=tt.c(10),n=Ne(pN),r=hx(gN),o=Gh(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:mN})},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 d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return Wn(m=>{m.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function pN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function gN(t){return t.load}const xN=()=>{const t=tt.c(4),{t:e}=Nt(),n=Ne(bN);let r,i;t[0]!==n||t[1]!==e?(r=()=>Wn(o=>{o.type==="browser-provider-reset"&&(n("builtin"),Ke.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i)};function bN(t){return t.setBrowserProvider}const Td="pwa-install-toast-shown",Ed="pwa-install-toast-dismissed",yN=()=>{const t=tt.c(6),{browserTab:e}=qh(),{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"||!Ma()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(Ke.dismiss(u),u=null)},f=async()=>{if(!d)return;const x=d;d=null,m(),await x.prompt();const{outcome:k}=await x.userChoice;k==="accepted"&&Ke.success(r.current("pwa.installPrompt.started"))},p=x=>{const k=x;if(typeof k.prompt!="function")return;k.preventDefault(),d=k;const w=_o(),h=sh();Yh({dismissed:w.getItem(Ed),sessionShown:h.getItem(Td),hasActiveToast:u!==null})&&(h.setItem(Td,"true"),u=Ke.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{_o().setItem(Ed,"true"),m()}}}))},y=()=>{d=null,m(),Ke.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",y),()=>{m(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",y)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},wN=({open:t,onOpenChange:e})=>{const{t:n}=Nt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[m,f]=c.useState(!1),[p,y]=c.useState(null),[x,k]=c.useState(!1);c.useCallback(async()=>{},[p,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const g=await bs("/api/system/info");if(g.ok){const j=await g.json();if(typeof j.openchamberVersion=="string"&&j.openchamberVersion.trim()){o(j.openchamberVersion);return}}}catch{}o(await px())})()},[t]),c.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const j=await bs("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!j.ok)return;const b=await j.json().catch(()=>null),S=typeof b?.currentVersion=="string"?b.currentVersion.trim():"";!h&&S&&a(S)}catch{}})(),()=>{h=!0}},[t]),c.useEffect(()=>{{y(null),k(!1);return}},[t,r]);const w=i;return s.jsx(Ps,{open:t,onOpenChange:e,children:s.jsx(Ds,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Nu,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[w&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:w})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(_,{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(_,{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(_,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},vN="\x1B",SN=new RegExp(`${vN}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Ao=lr().transform(t=>t.replace(SN,"").trim()).nullish(),jN=Xl({isOpenCodeReady:Jl().optional(),openCodeRunning:Jl().optional(),lastOpenCodeError:Ao,opencodeBinaryResolved:Ao,lastOpenCodeLaunchDiagnostics:Xl({sourceBinary:Ao,binary:Ao}).nullish()}),kN=async(t,e=bs)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=jN.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},Rd=Kn(()=>yn(()=>import("./OnboardingScreen-rK4Stg__.js"),__vite__mapDeps([151,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.OnboardingScreen}))),CN=()=>{const t=tt.c(3),e=Ne(TN),n=Ne(EN);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(wN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},NN=t=>{const e=tt.c(28),{onRetry:n,isRetrying:r}=t,{t:i}=Nt(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const j=new AbortController,b=Qt(),S=setTimeout(()=>j.abort(),5e3);return kN(j.signal).then(C=>{!j.signal.aborted&&Qt()===b&&l(C)}).catch(RN).finally(()=>clearTimeout(S)),()=>{j.abort(),clearTimeout(S)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);let u;e[2]!==i?(u=i("startup.initRecovery.title"),e[2]=i,e[3]=u):u=e[3];let m;e[4]!==u?(m=s.jsx("h1",{className:"typography-title text-foreground",children:u}),e[4]=u,e[5]=m):m=e[5];const f=o?"startup.initRecovery.openCodeUnavailable":"startup.initRecovery.description";let p;e[6]!==i||e[7]!==f?(p=i(f),e[6]=i,e[7]=f,e[8]=p):p=e[8];let y;e[9]!==p?(y=s.jsx("p",{className:"typography-body text-muted-foreground",children:p}),e[9]=p,e[10]=y):y=e[10];let x;e[11]!==m||e[12]!==y?(x=s.jsxs("div",{className:"flex flex-col gap-2",children:[m,y]}),e[11]=m,e[12]=y,e[13]=x):x=e[13];let k;e[14]!==o||e[15]!==i?(k=o&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[14]=o,e[15]=i,e[16]=k):k=e[16];let w;e[17]!==r||e[18]!==i?(w=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[17]=r,e[18]=i,e[19]=w):w=e[19];let h;e[20]!==r||e[21]!==n||e[22]!==w?(h=s.jsx(ct,{type:"button",onClick:n,disabled:r,children:w}),e[20]=r,e[21]=n,e[22]=w,e[23]=h):h=e[23];let g;return e[24]!==h||e[25]!==x||e[26]!==k?(g=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[x,k,h]})}),e[24]=h,e[25]=x,e[26]=k,e[27]=g):g=e[27],g},Md=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",AN=()=>{if(typeof window>"u"||!lb())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}},PN=t=>{const e=tt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=os(MN),l=rt(ON),a=rt(BN),d=vx(),u=c.useRef(null);let m;e[0]!==n.directory?(m=Md(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let p;e[2]!==o?(p=Md(o),e[2]=o,e[3]=p):p=e[3];const y=p;let x,k;if(e[4]!==y||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(x=()=>{if(r||f&&y!==f)return;const S=`${f}
895
+ `)?(f(Ae),u(!0)):u(!1);return}u(!1)},e[12]=M):M=e[12];const L=M;let W;e[13]!==n.id||e[14]!==o?(W=ae=>{o(n.id,{prompt:ae})},e[13]=n.id,e[14]=o,e[15]=W):W=e[15];const $=W;let P;e[16]!==n.prompt||e[17]!==$?(P=ae=>{const pe=n.prompt,_e=b.current?.selectionStart??pe.length,Me=pe.substring(0,_e).lastIndexOf("@"),Ae=ae.relativePath&&ae.relativePath.trim().length>0?ae.relativePath.trim():ae.path||ae.name,Q=Me!==-1?Me:_e,Ce=`${pe.substring(0,Q)}@${Ae} ${pe.substring(_e)}`,Be=Q+Ae.length+2;$(Ce),u(!1),f(""),requestAnimationFrame(()=>{const Le=b.current;Le&&(Le.selectionStart=Be,Le.selectionEnd=Be,Le.focus()),L(Ce,Be)})},e[16]=n.prompt,e[17]=$,e[18]=P):P=e[18];const D=P;let I;e[19]!==n.prompt||e[20]!==$?(I=ae=>{const pe=n.prompt,_e=b.current?.selectionStart??pe.length,Me=pe.substring(0,_e).lastIndexOf("@"),Ae=Me!==-1?Me:_e,Q=`${pe.substring(0,Ae)}@${ae} ${pe.substring(_e)}`,Ce=Ae+ae.length+2;$(Q),u(!1),f(""),requestAnimationFrame(()=>{const Be=b.current;Be&&(Be.selectionStart=Ce,Be.selectionEnd=Ce,Be.focus()),L(Q,Ce)})},e[19]=n.prompt,e[20]=$,e[21]=I):I=e[21];const X=I;let Z;e[22]!==$?(Z=ae=>{const pe=`/${ae.name} `;$(pe),y(!1),k(""),h(!1),requestAnimationFrame(()=>{const le=b.current;le&&(le.focus(),le.selectionStart=le.value.length,le.selectionEnd=le.value.length),L(pe,pe.length)})},e[22]=$,e[23]=Z):Z=e[23];const ne=Z;let ue;e[24]!==n.prompt||e[25]!==$?(ue=(ae,pe)=>{const le=n.prompt,Fe=b.current?.selectionStart??le.length,Ae=le.substring(0,Fe).lastIndexOf("#"),Q=Ae!==-1?Ae:Fe,Ce=`${le.substring(0,Q)}#${pe} ${le.substring(Fe)}`,Be=Q+pe.length+2;$(Ce),h(!1),j(""),requestAnimationFrame(()=>{const Le=b.current;Le&&(Le.selectionStart=Be,Le.selectionEnd=Be,Le.focus()),L(Ce,Be)})},e[24]=n.prompt,e[25]=$,e[26]=ue):ue=e[26];const se=ue;let xe;e[27]!==p||e[28]!==d||e[29]!==w?(xe=ae=>{if(p&&C.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")){ae.preventDefault(),C.current.handleKeyDown(ae.key);return}d&&S.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),S.current.handleKeyDown(ae.key)),w&&v.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),v.current.handleKeyDown(ae.key))},e[27]=p,e[28]=d,e[29]=w,e[30]=xe):xe=e[30];const ie=xe,Re=r+1;let be;e[31]!==a||e[32]!==Re?(be=a("multirun.launcher.groups.groupLabel",{index:Re}),e[31]=a,e[32]=Re,e[33]=be):be=e[33];let fe;e[34]!==be?(fe=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:be}),e[34]=be,e[35]=fe):fe=e[35];let ke;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(ke=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(_,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=ke):ke=e[40];let H;e[41]!==fe||e[42]!==ke?(H=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[fe,ke]}),e[41]=fe,e[42]=ke,e[43]=H):H=e[43];let J;e[44]!==a?(J=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=J):J=e[45];let ce;e[46]!==J?(ce=s.jsx(Jn,{required:!0,children:J}),e[46]=J,e[47]=ce):ce=e[47];const je=n.prompt;let G;e[48]!==$?(G=ae=>{const pe=ae.target.value;$(pe);const le=ae.target.selectionStart??pe.length;L(pe,le)},e[48]=$,e[49]=G):G=e[49];let we;e[50]!==a?(we=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=we):we=e[51];let Te;e[52]!==n.prompt||e[53]!==ie||e[54]!==G||e[55]!==we?(Te=s.jsx(pr,{ref:b,value:je,onChange:G,onKeyDown:ie,placeholder:we,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]=ie,e[54]=G,e[55]=we,e[56]=Te):Te=e[56];let he;e[57]!==x||e[58]!==ne||e[59]!==p?(he=p?s.jsx(Ku,{ref:C,searchQuery:x,onCommandSelect:ne,onClose:()=>y(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=x,e[58]=ne,e[59]=p,e[60]=he):he=e[60];let re;e[61]!==X||e[62]!==D||e[63]!==m||e[64]!==d?(re=d?s.jsx(Vu,{ref:S,searchQuery:m,onFileSelect:D,onAgentSelect:X,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=X,e[62]=D,e[63]=m,e[64]=d,e[65]=re):re=e[65];let ge;e[66]!==se||e[67]!==w||e[68]!==g?(ge=w?s.jsx(Uu,{ref:v,searchQuery:g,onSnippetSelect:se,onClose:()=>h(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=se,e[67]=w,e[68]=g,e[69]=ge):ge=e[69];let q;e[70]!==Te||e[71]!==he||e[72]!==re||e[73]!==ge?(q=s.jsxs("div",{className:"relative",children:[Te,he,re,ge]}),e[70]=Te,e[71]=he,e[72]=re,e[73]=ge,e[74]=q):q=e[74];let z;e[75]!==ce||e[76]!==q?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ce,q]}),e[75]=ce,e[76]=q,e[77]=z):z=e[77];let ee;e[78]!==a?(ee=a("multirun.launcher.models.info"),e[78]=a,e[79]=ee):ee=e[79];let de;e[80]!==ee?(de=s.jsx(Bo,{children:ee}),e[80]=ee,e[81]=de):de=e[81];let Y;e[82]!==a?(Y=a("multirun.launcher.models.label"),e[82]=a,e[83]=Y):Y=e[83];let U;e[84]!==de||e[85]!==Y?(U=s.jsx(Jn,{required:!0,info:de,children:Y}),e[84]=de,e[85]=Y,e[86]=U):U=e[86];let F;e[87]!==n.models||e[88]!==R||e[89]!==O||e[90]!==T?(F=s.jsx(Qf,{selectedModels:n.models,onAdd:R,onRemove:O,onUpdate:T,minModels:1}),e[87]=n.models,e[88]=R,e[89]=O,e[90]=T,e[91]=F):F=e[91];let V;e[92]!==U||e[93]!==F?(V=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[U,F]}),e[92]=U,e[93]=F,e[94]=V):V=e[94];let oe;return e[95]!==H||e[96]!==z||e[97]!==V?(oe=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[H,z,V]}),e[95]=H,e[96]=z,e[97]=V,e[98]=oe):oe=e[98],oe};function N5(t){const e=[],n=(r,i)=>{const o=xt(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const A5=t=>{const e=new Map;for(const n of t){const r=As(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},P5=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},D5=t=>{const e=tt.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=Qt(),m=A5(i),f=l.current?.runtimeKey===u?l.current.identities:null;for(const p of P5(f,m))tx({runtimeKey:u,...p});l.current={runtimeKey:u,identities:m}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},I5=new Map,T5=t=>{const e=tt.c(23),{isVSCode:n}=t,r=ii(),i=Ut(E5),o=os(R5),l=rt(M5);let a;e[0]!==n?(a=R=>n?I5:R.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=rt(a),u=!n;let m;e[2]!==d||e[3]!==i||e[4]!==u?(m=rm(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=m):m=e[5];const f=m,p=vs(O5),y=vs(B5),x=vs(F5),k=`session-list-sync:${c.useId()}`;let w,h;e[6]!==k||e[7]!==r||e[8]!==o||e[9]!==l?(w=()=>(r.setBootstrapDemand(k,N5({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(k)),h=[k,r,o,l],e[6]=k,e[7]=r,e[8]=o,e[9]=l,e[10]=w,e[11]=h):(w=e[10],h=e[11]),c.useEffect(w,h);const g=c.useRef(null);let j,b;e[12]!==n||e[13]!==f?(j=()=>{const R=new Set(f),A=g.current;g.current=R;const O=A?[...R].filter(B=>!A.has(B)):n?[...R]:[];O.length&&Fa(O,zo())},b=[n,f],e[12]=n,e[13]=f,e[14]=j,e[15]=b):(j=e[14],b=e[15]),c.useEffect(j,b);let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[16]=S):S=e[16],c.useEffect(_5,S);let C;e[17]!==y||e[18]!==p?(C=[...p,...y],e[17]=y,e[18]=p,e[19]=C):C=e[19];const v=C;let E;e[20]!==v||e[21]!==x?(E={enabled:!0,hasAuthoritativeGlobalSessions:x,sessions:v},e[20]=v,e[21]=x,e[22]=E):E=e[22],D5(E)};function E5(t){return t.projects}function R5(t){return t.currentDirectory}function M5(t){return t.currentSessionDirectory}function O5(t){return t.activeSessions}function B5(t){return t.archivedSessions}function F5(t){return t.status==="ready"}function _5(){let t=null,e=!1;const n=new Set,r=Wn(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(),ai(zo());return}const o=[...n];n.clear(),o.length&&Fa(o,zo())},500)});return()=>{t&&clearTimeout(t),r()}}const L5=Kn(()=>yn(()=>import("./SettingsWindow-y9WpZqK6.js"),__vite__mapDeps([145,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,146,84,85,86,147,131,132,133,134,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,148,149,150])).then(t=>({default:t.SettingsWindow}))),$5=()=>{const t=tt.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],T5(e),Kh();const n=Ne(z5),r=Ne(W5),i=Ne(K5),o=Ne(V5),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const m=Ne(U5),f=Ne(H5),p=Ne(G5),y=Ne(q5),x=Ne(Y5),k=Ne(Q5),w=Ne(X5),h=Ne(J5),g=Eu();let j;if(t[4]!==g||t[5]!==h){let q;t[7]!==h?(q=z=>z.id===h,t[7]=h,t[8]=q):q=t[8],j=g.find(q),t[4]=g,t[5]=h,t[6]=j}else j=t[6];const b=j;let S,C;t[9]!==b||t[10]!==h?(S=()=>{h&&!b&&Ne.getState().setOpenGuestPage(null)},C=[h,b],t[9]=b,t[10]=h,t[11]=S,t[12]=C):(S=t[11],C=t[12]),c.useEffect(S,C);let v;t[13]===Symbol.for("react.memo_cache_sentinel")?(v=[],t[13]=v):v=t[13],c.useEffect(eC,v);const E=y||x||k||!!w||m||!!b;let R;t[14]===Symbol.for("react.memo_cache_sentinel")?(R=[],t[14]=R):R=t[14],c.useEffect(sC,R);const{isMobile:A}=$n();Vh();let O,B;t[15]!==A||t[16]!==r?(O=()=>{Ne.getState().isMobile!==A&&r(A)},B=[A,r],t[15]=A,t[16]=r,t[17]=O,t[18]=B):(O=t[17],B=t[18]),c.useEffect(O,B);let T,M,L,W,$;t[19]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(zS,{}),M=s.jsx(_0,{}),L=s.jsx(W0,{}),W=s.jsx(D4,{}),$=s.jsx(by,{}),t[19]=T,t[20]=M,t[21]=L,t[22]=W,t[23]=$):(T=t[19],M=t[20],L=t[21],W=t[22],$=t[23]);let P;t[24]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(xy,{}),t[24]=P):P=t[24];let D;t[25]!==n?(D=s.jsx(P4,{isVisible:n}),t[25]=n,t[26]=D):D=t[26];let I;t[27]!==A||t[28]!==n||t[29]!==D?(I=s.jsx(gy,{isOpen:n,isMobile:A,className:"border-border",topBar:P,children:D}),t[27]=A,t[28]=n,t[29]=D,t[30]=I):I=t[30];let X;t[31]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(hy,{}),t[31]=X):X=t[31];const Z=E&&"invisible";let ne;t[32]!==Z?(ne=Ee("absolute inset-0",Z),t[32]=Z,t[33]=ne):ne=t[33];const ue=!i&&!E;let se;t[34]!==ue?(se=s.jsx(Cs,{children:s.jsx(eu,{active:ue})}),t[34]=ue,t[35]=se):se=t[35];let xe;t[36]!==ne||t[37]!==se?(xe=s.jsx("div",{className:ne,children:se}),t[36]=ne,t[37]=se,t[38]=xe):xe=t[38];let ie;t[39]!==m||t[40]!==p||t[41]!==f?(ie=m&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Cs,{children:s.jsx(k5,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[39]=m,t[40]=p,t[41]=f,t[42]=ie):ie=t[42];let Re;t[43]===Symbol.for("react.memo_cache_sentinel")?(Re=s.jsx(Cs,{children:s.jsx(s5,{})}),t[43]=Re):Re=t[43];let be;t[44]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(Cs,{children:s.jsx(n5,{})}),t[44]=be):be=t[44];let fe;t[45]!==k?(fe=k&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Cs,{children:s.jsx(Uh,{})})}),t[45]=k,t[46]=fe):fe=t[46];let ke;t[47]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx(Cs,{children:s.jsx(m5,{})}),t[47]=ke):ke=t[47];let H;t[48]!==b?(H=b&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Cs,{children:s.jsx(cb,{mode:`plugin:${b.id}`,surface:"page",item:null,onDismiss:nC})})}),t[48]=b,t[49]=H):H=t[49];let J;t[50]!==xe||t[51]!==ie||t[52]!==fe||t[53]!==H?(J=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[xe,ie,Re,be,fe,ke,H]}),t[50]=xe,t[51]=ie,t[52]=fe,t[53]=H,t[54]=J):J=t[54];let ce;t[55]===Symbol.for("react.memo_cache_sentinel")?(ce=s.jsx(cS,{}),t[55]=ce):ce=t[55];let je;t[56]!==J?(je=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:[J,ce]})})}),t[56]=J,t[57]=je):je=t[57];let G;t[58]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(Cs,{children:s.jsx(yS,{})})}),t[58]=G):G=t[58];let we;t[59]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(Cs,{children:s.jsx(Ox,{})}),t[59]=we):we=t[59];let Te;t[60]!==je?(Te=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[X,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[je,G,we]})]}),t[60]=je,t[61]=Te):Te=t[61];let he;t[62]!==I||t[63]!==Te?(he=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[I,Te]}),t[62]=I,t[63]=Te,t[64]=he):he=t[64];let re;t[65]!==i||t[66]!==o||t[67]!==l?(re=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(L5,{open:i,onOpenChange:o})}):null,t[65]=i,t[66]=o,t[67]=l,t[68]=re):re=t[68];let ge;return t[69]!==he||t[70]!==re?(ge=s.jsx(Hh,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[T,M,L,W,$,he,re]})}),t[69]=he,t[70]=re,t[71]=ge):ge=t[71],ge};function z5(t){return t.isSidebarOpen}function W5(t){return t.setIsMobile}function K5(t){return t.isSettingsDialogOpen}function V5(t){return t.setSettingsDialogOpen}function U5(t){return t.isMultiRunLauncherOpen}function H5(t){return t.setMultiRunLauncherOpen}function G5(t){return t.multiRunLauncherPrefillPrompt}function q5(t){return t.isScheduledTasksDialogOpen}function Y5(t){return t.isArchivePageOpen}function Q5(t){return t.isUsageStatsPageOpen}function X5(t){return t.worktreesPageProjectId}function J5(t){return t.openGuestPageId}function Z5(){return Ne.getState().setOpenGuestPage(null)}function eC(){return Cr(Z5)}function tC(){return Ne.getState().closeMainSurfaces()}function sC(){const t=tC,e=rt.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 nC(){return Ne.getState().setOpenGuestPage(null)}const lm=12,rC=[{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"}],oC=t=>{const e=tt.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,m=l===void 0?rC:l,f=ut.useRef(!1);let p,y;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},y=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=y):(p=e[2],y=e[3]),ut.useEffect(p,y);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=Array.from({length:lm},iC),e[4]=x):x=e[4];const k=x;if(!n)return null;let w;e[5]!==i?(w=Ee("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=w):w=e[6];let h;if(e[7]!==d||e[8]!==m||e[9]!==u){let j;e[11]!==d||e[12]!==u?(j=b=>{const S={"--burst-delay":`${b.delay}ms`,"--burst-x":`${b.x}%`,"--burst-y":`${b.y}%`,"--firework-color":`var(${b.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:S,children:k.map((C,v)=>{const E=C.x*b.radius,R=C.y*b.radius,A={"--translate-x":`${E}px`,"--translate-y":`${R}px`,"--particle-delay":`${C.delay}ms`,color:`var(${b.colorVar})`};return s.jsx("span",{className:"firework-particle",style:A},`${b.id}-${v}-${d}`)})},`${b.id}-${d}`)},e[11]=d,e[12]=u,e[13]=j):j=e[13],h=m.map(j),e[7]=d,e[8]=m,e[9]=u,e[10]=h}else h=e[10];let g;return e[14]!==d||e[15]!==w||e[16]!==h?(g=s.jsx("div",{className:w,"aria-hidden":"true","data-burst-key":d,children:h}),e[14]=d,e[15]=w,e[16]=h,e[17]=g):g=e[17],g};function iC(t,e){const n=Math.PI*2*e/lm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const aC=t=>{const e=tt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,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]=ut.useState(o),d=ut.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const m=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{m(),a(lC)},e[4]=f):f=e[4];const p=f;let y;e[5]!==i?(y=()=>{m(),a(cC),d.current=window.setTimeout(()=>{a(dC),d.current=null},i)},e[5]=i,e[6]=y):y=e[6];const x=y;let k,w;e[7]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>m(),w=[m],e[7]=k,e[8]=w):(k=e[7],w=e[8]),ut.useEffect(k,w);let h;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==x?(h={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:x,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=x,e[12]=h):h=e[12],h};function lC(t){return t.isActive?{...t,isActive:!1}:t}function cC(t){return{isActive:!0,cycle:t.cycle+1}}function dC(t){return t.isActive?{...t,isActive:!1}:t}const cm=c.createContext(void 0),uC=t=>{const e=tt.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=aC();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(oC,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let m;return e[6]!==n||e[7]!==u||e[8]!==d?(m=s.jsxs(cm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=m):m=e[9],m},nA=()=>{const t=c.useContext(cm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Ta="openchamber_requests_in_flight",dm=1e3,fC=300*1e3,Jo=Math.ceil(fC/dm),mC=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ta)==="1"}catch{return!1}},um=()=>({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 hC=1;const pC=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},gC=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},fm=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},jr=(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)},xC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=hC++;pC(o,Date.now());try{return await e(r,i)}finally{gC(o)}};window.fetch=n},Sd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Or=t=>{t.length>Jo&&t.splice(0,t.length-Jo)},bC=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=fm(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(jr(e,50)),t.p90Samples.push(jr(e,90)),t.p99Samples.push(jr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Or(t.samples),Or(t.p50Samples),Or(t.p90Samples),Or(t.p99Samples),Or(t.maxSamples),t.lastSampleAt=Date.now()},yC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(bC,dm))},jd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},kd=t=>{if(!(typeof window>"u"))try{if(t){jd(),Sd(),window.localStorage.setItem(Ta,"1"),window.__openchamberRequestsInFlight__=um(),xC(),yC();return}window.localStorage.removeItem(Ta),jd(),Sd(),delete window.__openchamberRequestsInFlight__}catch{}},wC=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=um();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},Ea=()=>{if(typeof window>"u")return Cd();const t=window.__openchamberRequestsInFlight__;if(!mC()||!t)return Cd();const e=fm(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:jr(e,50),ageP90:jr(e,90),ageP99:jr(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:Jo}},Cd=()=>({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:Jo});function vC(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const mm=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`},Ra=t=>`${(t/1e3).toFixed(2)} s`,ws=t=>{const e=tt.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},Nd=t=>{const e=tt.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 d;e[8]!==r.entries?(d=r.entries.reduce(kC,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let m;e[10]!==n?(m=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?mm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let y;e[18]!==m||e[19]!==p?(y=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,p]}),e[18]=m,e[19]=p,e[20]=y):y=e[20];let x;e[21]!==o?(x=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=x):x=e[22];let k;e[23]!==r.entries.length||e[24]!==x?(k=s.jsx(ws,{label:x,value:r.entries.length}),e[23]=r.entries.length,e[24]=x,e[25]=k):k=e[25];let w;e[26]!==o?(w=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=w):w=e[27];let h;e[28]!==w||e[29]!==u?(h=s.jsx(ws,{label:w,value:u}),e[28]=w,e[29]=u,e[30]=h):h=e[30];let g;e[31]!==o?(g=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=g):g=e[32];let j;e[33]!==r.lastUpdatedAt||e[34]!==o?(j=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=j):j=e[35];let b;e[36]!==g||e[37]!==j?(b=s.jsx(ws,{label:g,value:j}),e[36]=g,e[37]=j,e[38]=b):b=e[38];let S;e[39]!==h||e[40]!==b||e[41]!==k?(S=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[k,h,b]}),e[39]=h,e[40]=b,e[41]=k,e[42]=S):S=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:[y,S,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(En,{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},Ad=t=>{const e=tt.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(CC,0),u=r>0?52/r:0;let m;e[0]!==d||e[1]!==a?(m=b=>a-d+b,e[0]=d,e[1]=a,e[2]=m):m=e[2];const f=m;let p;e[3]!==u?(p=b=>56-b*u,e[3]=u,e[4]=p):p=e[4];const y=p;let x;e[5]!==l?(x=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]=x):x=e[6];const k=`0 0 ${a} 56`;let w;e[7]!==a?(w=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]=w):w=e[8];let h;if(e[9]!==n||e[10]!==f||e[11]!==y){let b;e[13]!==f||e[14]!==y?(b=(S,C)=>{const v=S.samples.length;if(v===0)return null;const E=S.samples.map((A,O)=>`${f(O)},${y(A).toFixed(2)}`),R=`M ${E.join(" L ")}`;return s.jsxs(c.Fragment,{children:[S.filled?s.jsx("path",{d:`M ${f(0)},56 L ${E.join(" L ")} L ${f(v-1)},56 Z`,fill:`color-mix(in srgb, ${S.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:R,fill:"none",stroke:S.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=y,e[15]=b):b=e[15],h=n.map(b),e[9]=n,e[10]=f,e[11]=y,e[12]=h}else h=e[12];let g;e[16]!==o||e[17]!==k||e[18]!==w||e[19]!==h?(g=s.jsxs("svg",{viewBox:k,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[w,h]}),e[16]=o,e[17]=k,e[18]=w,e[19]=h,e[20]=g):g=e[20];let j;return e[21]!==x||e[22]!==g?(j=s.jsxs("div",{className:"relative w-full",children:[x,g]}),e[21]=x,e[22]=g,e[23]=j):j=e[23],j},SC=t=>{const e=tt.c(100),{onClose:n}=t,{t:r}=Nt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=rt(NC),u=$u(AC),m=Cu(),f=sx(PC),p=Vs(DC),[y,x]=c.useState(IC),[k,w]=c.useState(TC),[h,g]=c.useState(EC),j=[{label:"p50",current:h.ageP50,samples:h.p50Samples,color:"var(--status-success)"},{label:"p90",current:h.ageP90,samples:h.p90Samples,color:"var(--status-info)"},{label:"p99",current:h.ageP99,samples:h.p99Samples,color:"var(--status-warning)"},{label:"max",current:h.ageMax,samples:h.maxSamples,color:"var(--status-error)"}];let b;e[0]!==h.samples?(b=h.samples.reduce(RC,0),e[0]=h.samples,e[1]=b):b=e[1];const S=b,C=j.reduce(OC,0);let v;e[2]!==y.entries?(v=new Map,y.entries.forEach(Be=>{v.set(Be.metric,Be.count)}),e[2]=y.entries,e[3]=v):v=e[3];let E;e[4]!==v?(E=v.get("ui.message_list.render")??0,e[4]=v,e[5]=E):E=e[5];let R;e[6]!==v?(R=v.get("ui.message_list.render.streaming")??0,e[6]=v,e[7]=R):R=e[7];let A;e[8]!==v?(A=v.get("ui.chat_message.render")??0,e[8]=v,e[9]=A):A=e[9];let O;e[10]!==v?(O=v.get("ui.chat_message.render.streaming")??0,e[10]=v,e[11]=O):O=e[11];let B;e[12]!==v?(B=v.get("ui.chat_message.render.static_during_stream")??0,e[12]=v,e[13]=B):B=e[13];let T;e[14]!==v?(T=v.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=v,e[15]=T):T=e[15];let M;e[16]!==E||e[17]!==R||e[18]!==A||e[19]!==O||e[20]!==B||e[21]!==T?(M={messageListRender:E,messageListRenderStreaming:R,chatMessageRender:A,chatMessageRenderStreaming:O,chatMessageRenderStaticDuringStream:B,chatMessageRenderStaticOutsideActiveTurnDuringStream:T},e[16]=E,e[17]=R,e[18]=A,e[19]=O,e[20]=B,e[21]=T,e[22]=M):M=e[22];const L=M;let W,$;e[23]===Symbol.for("react.memo_cache_sentinel")?($=()=>{const Be=()=>{x(Po()),w(Do()),g(Ea())};Be();const Le=window.setInterval(Be,500);return()=>window.clearInterval(Le)},W=[],e[23]=W,e[24]=$):(W=e[23],$=e[24]),c.useEffect($,W);let P,D;e[25]!==l?(P=()=>{if(l==="idle")return;const Be=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Be)},D=[l],e[25]=l,e[26]=P,e[27]=D):(P=e[26],D=e[27]),c.useEffect(P,D);let I=0,X=0,Z=0;for(const Be of Object.keys(f)){const Le=f[Be]??[];X=X+Le.length;for(const Je of Le)Je.role==="user"?Z=Z+1:Je.role==="assistant"&&(I=I+1)}let ne;e[28]!==I||e[29]!==X||e[30]!==Z?(ne={assistant:I,total:X,user:Z},e[28]=I,e[29]=X,e[30]=Z,e[31]=ne):ne=e[31];const ue=ne;let se;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==m||e[36]!==r){let Be;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(Be=Le=>{const Je=f[Le.id]??[];let ot=0,et=0;for(const ht of Je)ht.role==="user"?et=et+1:ht.role==="assistant"&&(ot=ot+1);const it=u.get(Le.id);return{id:Le.id,title:Le.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ot,messageCount:Je.length,userMessageCount:et,isStreaming:it?.isStreaming||!1,isZombie:it?.isZombie||!1,backgroundCount:it?.backgroundMessageCount||0,lastAccessed:it?.lastAccessedAt||0,isCurrent:Le.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=Be):Be=e[42],se=m.map(Be).sort(BC),e[32]=d,e[33]=f,e[34]=u,e[35]=m,e[36]=r,e[37]=se}else se=e[37];const xe=se;let ie;e[43]!==f?(ie=Object.keys(f),e[43]=f,e[44]=ie):ie=e[44];const Re=ie.length;let be;e[45]===Symbol.for("react.memo_cache_sentinel")?(be=async()=>{try{const Be={generatedAt:new Date().toISOString(),ui:Po(),vscode:Do()};await navigator.clipboard.writeText(JSON.stringify(Be,null,2)),a("copied")}catch{a("error")}},e[45]=be):be=e[45];const fe=be,ke=rx,H="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let J;e[46]===Symbol.for("react.memo_cache_sentinel")?(J={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=J):J=e[46];let ce;e[47]!==i?(ce=vC(i),e[47]=i,e[48]=ce):ce=e[48];let je;e[49]!==ce?(je=s.jsx(_,{name:ce,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=ce,e[50]=je):je=e[50];let G;e[51]!==r?(G=r("memoryDebugPanel.title"),e[51]=r,e[52]=G):G=e[52];let we;e[53]!==G?(we=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:G}),e[53]=G,e[54]=we):we=e[54];let Te;e[55]!==je||e[56]!==we?(Te=s.jsxs("div",{className:"flex items-center gap-2",children:[je,we]}),e[55]=je,e[56]=we,e[57]=Te):Te=e[57];let he;e[58]!==i?(he=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(ct,{size:"xs",variant:"ghost",onClick:fe,children:s.jsx(_,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(ct,{size:"xs",variant:"ghost",onClick:()=>{eh(),x(Po()),w(Do())},children:s.jsx(_,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=he):he=e[59];let re;e[60]!==i?(re=i==="requests"?s.jsx(ct,{size:"xs",variant:"ghost",onClick:()=>{wC(),g(Ea())},children:s.jsx(_,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=re):re=e[61];let ge;e[62]!==n?(ge=n?s.jsx(ct,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(_,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=ge):ge=e[63];let q;e[64]!==he||e[65]!==re||e[66]!==ge?(q=s.jsxs("div",{className:"flex items-center gap-1",children:[he,re,ge]}),e[64]=he,e[65]=re,e[66]=ge,e[67]=q):q=e[67];let z;e[68]!==Te||e[69]!==q?(z=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Te,q]}),e[68]=Te,e[69]=q,e[70]=z):z=e[70];let ee;e[71]===Symbol.for("react.memo_cache_sentinel")?(ee={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=ee):ee=e[71];const de=i==="memory"?"secondary":"ghost";let Y;e[72]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>o("memory"),e[72]=Y):Y=e[72];let U;e[73]!==r?(U=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=U):U=e[74];let F;e[75]!==de||e[76]!==U?(F=s.jsx(ct,{size:"sm",variant:de,className:"flex-1",onClick:Y,children:U}),e[75]=de,e[76]=U,e[77]=F):F=e[77];const V=i==="streaming"?"secondary":"ghost";let oe;e[78]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>o("streaming"),e[78]=oe):oe=e[78];let ae;e[79]!==r?(ae=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=ae):ae=e[80];let pe;e[81]!==V||e[82]!==ae?(pe=s.jsx(ct,{size:"sm",variant:V,className:"flex-1",onClick:oe,children:ae}),e[81]=V,e[82]=ae,e[83]=pe):pe=e[83];const le=i==="requests"?"secondary":"ghost";let _e;e[84]===Symbol.for("react.memo_cache_sentinel")?(_e=()=>o("requests"),e[84]=_e):_e=e[84];let Fe;e[85]!==r?(Fe=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Fe):Fe=e[86];let Me;e[87]!==le||e[88]!==Fe?(Me=s.jsx(ct,{size:"sm",variant:le,className:"flex-1",onClick:_e,children:Fe}),e[87]=le,e[88]=Fe,e[89]=Me):Me=e[89];let Ae;e[90]!==F||e[91]!==pe||e[92]!==Me?(Ae=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ee,children:[F,pe,Me]}),e[90]=F,e[91]=pe,e[92]=Me,e[93]=Ae):Ae=e[93];const Q=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(ws,{label:r("memoryDebugPanel.metric.totalMessages"),value:ue.total}),s.jsx(ws,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Re} / ${Wl.MAX_SESSIONS}`}),s.jsx(ws,{label:r("memoryDebugPanel.metric.userMessages"),value:ue.user}),s.jsx(ws,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ue.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:nx()})})]}),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:Wl.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(En,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:xe.map(Be=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Be.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Be.title}),Be.isStreaming?s.jsx(_,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Be.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Be.assistantMessageCount,user:Be.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Be.messageCount})}),Be.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Be.backgroundCount]}):null]})]},Be.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ct,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(FC),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:ue,sessionMessageRoleCounts:xe.map(_C),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(jt,{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(ct,{size:"xs",variant:"outline",onClick:fe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(ws,{label:r("memoryDebugPanel.metric.uiMetrics"),value:y.entries.length}),s.jsx(ws,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:k.entries.length}),s.jsx(ws,{label:r("memoryDebugPanel.metric.messageListRenders"),value:L.messageListRender}),s.jsx(ws,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:L.messageListRenderStreaming}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:L.chatMessageRender}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:L.chatMessageRenderStreaming}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:L.chatMessageRenderStaticDuringStream}),s.jsx(ws,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:L.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Nd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:y,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),k.entries.length>0?s.jsx(Nd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:k,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(ws,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${h.totalSettled} / ${h.totalStarted}`}),s.jsx(ws,{label:r("memoryDebugPanel.requests.tracking"),value:h.startedAt?mm(h.durationMs):r("memoryDebugPanel.common.idle")})]}),h.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:h.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:h.peak})]})]}),s.jsx(Ad,{series:[{samples:h.samples,color:"var(--status-info)",filled:!0}],peak:S,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:h.peak}),maxLabel:`${S}`}),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:Ra(h.peakAgeMs)})]}),s.jsx(Ad,{series:j.map(LC),peak:C,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Ra(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:j.map($C)}),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:h.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let Ce;return e[94]!==ke||e[95]!==J||e[96]!==z||e[97]!==Ae||e[98]!==Q?(Ce=s.jsxs(ke,{className:H,style:J,children:[z,Ae,Q]}),e[94]=ke,e[95]=J,e[96]=z,e[97]=Ae,e[98]=Q,e[99]=Ce):Ce=e[99],Ce},jC=SC;function kC(t,e){return t+e.count}function CC(t,e){return Math.max(t,e.samples.length)}function NC(t){return t.currentSessionId}function AC(t){return t.sessionMemoryState}function PC(t){return t.message}function DC(t){return t.totalRequestCount}function IC(){return Po()}function TC(){return Do()}function EC(){return Ea()}function RC(t,e){return Math.max(t,e)}function MC(t,e){return Math.max(t,e)}function OC(t,e){return e.samples.reduce(MC,t)}function BC(t,e){return e.lastAccessed-t.lastAccessed}function FC(t){return{id:t.id,title:t.title}}function _C(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function LC(t){return{samples:t.samples,color:t.color}}function $C(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:Ra(t.current)})]},t.label)}const zC=()=>{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()??"":""},WC=async()=>{const t=zC()||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")},Pd="openchamber:menu-action",Vi="openchamber:check-for-updates",KC=t=>{const e=rt(h=>h.openNewSessionDraft),n=Ne(h=>h.toggleCommandPalette),r=Ne(h=>h.setCommandPaletteOpen),i=Ne(h=>h.toggleHelpDialog),o=Ne(h=>h.toggleSidebar),l=Ne(h=>h.setSessionSwitcherOpen),a=Ne(h=>h.setSettingsDialogOpen),d=Ne(h=>h.setAboutDialogOpen),u=Kr(h=>h.checkForUpdates),{setThemeMode:m}=Ln(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:h,error:g}=Kr.getState();if(g){Ke.error("Failed to check for updates",{description:g});return}h||Ke.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),y=c.useCallback(()=>{un.requestDirectoryDialog()},[]),x=c.useCallback(h=>{const g=ox();if(g.length===0)return;const j=rt.getState().currentSessionId,b=g.findIndex(v=>v.id===j);let S=h>0?0:g.length-1;b>=0&&(S=(b+h+g.length)%g.length);const C=g[S];C&&(l(!1),rt.getState().setCurrentSession(C.id))},[l]),k=c.useCallback(h=>{const{activeProjectId:g,projects:j,setActiveProject:b}=Ut.getState();if(j.length===0)return;const S=j.findIndex(E=>E.id===g);let C=h>0?0:j.length-1;S>=0&&(C=(S+h+j.length)%j.length);const v=j[C];v&&b(v.id)},[]),w=c.useCallback(h=>{switch(h){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const g=rt.getState(),j=os.getState().currentDirectory;e(g.currentSessionId&&j?{directoryOverride:j}:void 0)}break;case"new-worktree-session":l(!1),Iu();break;case"change-workspace":y();break;case"toggle-right-sidebar":{const g=os.getState().currentDirectory;if(!g)break;const j=Ne.getState(),b=Qn(g),S=j.contextPanelByDirectory[b];S?.isOpen?j.closeContextPanel(b):S?.activeTabId?j.setActiveContextPanelTab(b,S.activeTabId):j.openContextSurface(b,"git");break}case"open-right-sidebar-git":{const g=os.getState().currentDirectory;if(!g)break;Ne.getState().openContextSurface(Qn(g),"git");break}case"open-right-sidebar-files":{const g=os.getState().currentDirectory;if(!g)break;Ne.getState().openContextSurface(Qn(g),"file");break}case"toggle-terminal":{const g=os.getState().currentDirectory;if(!g)break;Ne.getState().openContextSurface(Qn(g),"terminal");break}case"toggle-terminal-expanded":{const g=os.getState().currentDirectory;if(!g)break;const j=Qn(g),b=Ne.getState(),S=b.contextPanelByDirectory[j];(S?.isOpen?S.tabs.find(v=>v.id===S.activeTabId)?.mode:null)!=="terminal"&&b.openContextSurface(j,"terminal"),b.toggleContextPanelExpanded(j);break}case"copy":{const g=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(g)||WC();break}case"theme-light":m("light");break;case"theme-dark":m("dark");break;case"theme-system":m("system");break;case"add-selection-to-chat":ix();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":os.getState().goBack();break;case"go-forward":os.getState().goForward();break;case"previous-session":x(-1);break;case"next-session":x(1);break;case"previous-project":k(-1);break;case"next-project":k(1);break;case"help-dialog":i();break;case"download-logs":{Tu().catch(()=>{Ke.error("Failed to collect OpenCode status")});break}}},[y,k,x,t,e,d,l,r,a,m,n,i,o]);c.useEffect(()=>{const h=j=>{const b=j.detail;b&&w(b)},g=()=>{p()};return window.addEventListener(Pd,h),window.addEventListener(Vi,g),()=>{window.removeEventListener(Pd,h),window.removeEventListener(Vi,g)}},[w,p]),c.useEffect(()=>{if(typeof window>"u")return;const g=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof g!="function")return;let j=null,b=null;return g("openchamber:menu-action",S=>{const C=S?.payload;typeof C=="string"&&w(C)}).then(S=>{j=S}).catch(()=>{}),g("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Vi))}).then(S=>{b=S}).catch(()=>{}),()=>{(async()=>{try{const C=j?.();C instanceof Promise&&await C}catch{}try{const C=b?.();C instanceof Promise&&await C}catch{}})()}},[w])},VC="openchamber:tray-action",UC=5e3,HC=500,GC=20,Dd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Id=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,hm=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},pm=t=>t.title.trim()||"Question",qC=(t,e)=>Xa(t,e,Qr.getState().ids,Ua.getState().rankById),YC=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},QC=(t,e,n,r,i)=>{if(!t)return"";const o=su(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||YC(t),d=Io(t);let u=d&&i.get(d)||"";if(!u){for(const[m,f]of Tn.getState().directories)if(Io(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(p=>Io(p.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},XC=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=hr.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 lx){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:dx(m),value:cx(f.valueLabel,p)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},JC=async()=>{try{if(Zo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Dn();if(e&&xl(e,t))return"Local OpenChamber";const r=(await Bd()).hosts.find(i=>e?xl(e,th(i)):!1);return r?.label?.trim()?Fd(r.label.trim()):"Instance"}catch{return""}},ZC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=la()}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(Io(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"permission",id:m.id,sessionId:f,sessionTitle:"",label:hm(m),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"form",id:m.id,sessionId:f,sessionTitle:"",label:pm(m),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},eN=(t,e)=>{const n=qa.getState().index.session,r=vs.getState().activeSessions,i=new Map;for(const g of r)if(g?.id&&g.parentID){const j=i.get(g.parentID)??[];j.push(g.id),i.set(g.parentID,j)}const o=g=>{const j=[],b=[...i.get(g)??[]],S=new Set;for(;b.length;){const C=b.pop();S.has(C)||(S.add(C),j.push(C),b.push(...i.get(C)??[]))}return j},l=Ne.getState();let a=0;if(l.dockBadgeEnabled)for(const g of r){if(!g?.id||g.parentID)continue;let j=n.unseenCount[g.id]??0;j===0&&l.notifyOnSubtasks&&(j=o(g.id).reduce((b,S)=>b+(n.unseenCount[S]??0),0)),j>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=ZC(),u=new Map(d.titleById);for(const g of r)g?.id&&g.title&&u.set(g.id,g.title);const m=si.getState().statusById,f=g=>{const j=d.statusById.get(g);return j&&j!=="idle"?j:m.get(g)?.status.type??j??"idle"},p=g=>{const j=g.map(b=>f(b));return j.includes("busy")?"busy":j.includes("retry")?"retry":"idle"},y=Ut.getState().projects,x=rt.getState().availableWorktreesByProject,k=r.filter(g=>g?.id&&!g.parentID).slice().sort(qC).slice(0,GC).map(g=>{const j=[g.id,...o(g.id)],b=As(g)??"";return{id:g.id,title:g.title||"Untitled session",status:p(j),branch:b?d.branchByDirectory.get(b)??"":"",unseen:j.reduce((S,C)=>S+(n.unseenCount[C]??0),0),hasError:j.some(S=>n.unseenHasError[S]??!1),directory:b,subtitle:QC(b,g,y,x,d.branchByDirectory)}}),w=d.approvals.map(g=>({...g,sessionTitle:u.get(g.sessionId)||""})),h=new Set(w.map(g=>g.id));for(const[g,j]of Ya.getState().bySession){const b=u.get(g)||"";for(const S of j.permissions)h.has(S.id)||(h.add(S.id),w.push({kind:"permission",id:S.id,sessionId:g,sessionTitle:b,label:hm(S),directory:j.directory}));for(const S of j.forms)h.has(S.id)||(h.add(S.id),w.push({kind:"form",id:S.id,sessionId:g,sessionTitle:b,label:pm(S),directory:j.directory}))}return{sessions:k,approvals:w,instanceName:t,usage:XC(),dockBadgeCount:a}},tN=()=>{c.useEffect(()=>{if(!Dd()||!qr())return;const t=Id();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const v=eN(i,t),E=JSON.stringify(v);E!==n&&(n=E,Fn("desktop_tray_update",v))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},HC))},a=qa.subscribe(()=>l()),d=vs.subscribe(()=>l()),u=Ne.subscribe((v,E)=>{(v.dockBadgeEnabled!==E.dockBadgeEnabled||v.notifyOnSubtasks!==E.notifyOnSubtasks)&&l()}),m=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),m;JC().then(v=>{e||(i=v,o())});const f=new Map,p=()=>{if(e)return;let v;try{v=la()}catch{return}const E=new Set;for(const[R,A]of v.children.entries())E.add(R),f.has(R)||f.set(R,A.subscribe(()=>l()));for(const[R,A]of f)E.has(R)||(A(),f.delete(R))};let y=null;try{y=la().subscribeRegistry(()=>{p(),l()})}catch{}p();const x=Ut.subscribe(()=>l()),k=rt.subscribe(()=>l()),w=Tn.subscribe(()=>l()),h=si.subscribe(()=>l()),g=Ya.subscribe(()=>l()),j=Ua.subscribe(()=>l()),b=Qr.subscribe(()=>l()),S=hr.subscribe(()=>l());hr.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:v,results:E}=hr.getState();v.length>0&&v.some(A=>!E.some(O=>O.providerId===A))&&hr.getState().fetchQuotas(v)});const C=window.setInterval(()=>{p(),o()},UC);return o(),()=>{m(),window.clearInterval(C),x(),k(),w(),h(),g(),j(),b(),S(),y?.();for(const v of f.values())v();f.clear()}},[]),c.useEffect(()=>{if(!Dd()||!Id()||!qr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&ax(i.sessionId,i.id,i.response).catch(()=>{Ke.error("Failed to respond to permission request")})};let r=null;return e(VC,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{}}},[])},sN=30*6e4,nN=(t,e,n=sN)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Br=null;const rN=()=>{if(Br)return Br;const t=Qt();return Br=(async()=>{const e=await dn.getHostSessionStatusSnapshot();if(!e||Qt()!==t)return;const n=si.getState(),r=vs.getState().entityById,i=nN(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?As(a):null}});for(const[l,a]of i)ux(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?As(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}fx(o)})().finally(()=>{Br=null}),Br},oN=45e3,iN=[1e3,2e3,4e3],aN=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const m=await u().catch(()=>!1);if(i)return;a||=m;const f=a?void 0:iN[l];f!==void 0&&(l+=1),o=n(()=>{o=void 0,d(e)},f??oN)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},lN=t=>{const e=tt.c(3);let n,r;e[0]!==t?(n=()=>{if(!t)return;const i=cN;let o=i();const l=Cr(()=>{o(),o=i()});return()=>{l(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function cN(){const t=Qt();let e=!0;const n=async i=>(i?await mx(zo()):await ai(),!e||Qt()!==t?!1:(rN(),vs.getState().status==="ready")),r=aN(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const dN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,uN=t=>{const e=tt.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!(!n||xn()||!Ma()||!globalThis.window))return Wn(fN)},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function fN(t){if(t.type!=="notification")return;const e=Ne.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&dN())return;Od()?.notifications?.notifyAgentCompletion(t.payload)}const mN=6e4,hN=t=>{const e=tt.c(10),n=Ne(pN),r=hx(gN),o=Gh(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:mN})},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 d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return Wn(m=>{m.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function pN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function gN(t){return t.load}const xN=()=>{const t=tt.c(4),{t:e}=Nt(),n=Ne(bN);let r,i;t[0]!==n||t[1]!==e?(r=()=>Wn(o=>{o.type==="browser-provider-reset"&&(n("builtin"),Ke.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i)};function bN(t){return t.setBrowserProvider}const Td="pwa-install-toast-shown",Ed="pwa-install-toast-dismissed",yN=()=>{const t=tt.c(6),{browserTab:e}=qh(),{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"||!Ma()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(Ke.dismiss(u),u=null)},f=async()=>{if(!d)return;const x=d;d=null,m(),await x.prompt();const{outcome:k}=await x.userChoice;k==="accepted"&&Ke.success(r.current("pwa.installPrompt.started"))},p=x=>{const k=x;if(typeof k.prompt!="function")return;k.preventDefault(),d=k;const w=_o(),h=sh();Yh({dismissed:w.getItem(Ed),sessionShown:h.getItem(Td),hasActiveToast:u!==null})&&(h.setItem(Td,"true"),u=Ke.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{_o().setItem(Ed,"true"),m()}}}))},y=()=>{d=null,m(),Ke.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",y),()=>{m(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",y)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},wN=({open:t,onOpenChange:e})=>{const{t:n}=Nt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[m,f]=c.useState(!1),[p,y]=c.useState(null),[x,k]=c.useState(!1);c.useCallback(async()=>{},[p,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const g=await bs("/api/system/info");if(g.ok){const j=await g.json();if(typeof j.openchamberVersion=="string"&&j.openchamberVersion.trim()){o(j.openchamberVersion);return}}}catch{}o(await px())})()},[t]),c.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const j=await bs("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!j.ok)return;const b=await j.json().catch(()=>null),S=typeof b?.currentVersion=="string"?b.currentVersion.trim():"";!h&&S&&a(S)}catch{}})(),()=>{h=!0}},[t]),c.useEffect(()=>{{y(null),k(!1);return}},[t,r]);const w=i;return s.jsx(Ps,{open:t,onOpenChange:e,children:s.jsx(Ds,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Nu,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[w&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:w})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(_,{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(_,{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(_,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},vN="\x1B",SN=new RegExp(`${vN}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Ao=lr().transform(t=>t.replace(SN,"").trim()).nullish(),jN=Xl({isOpenCodeReady:Jl().optional(),openCodeRunning:Jl().optional(),lastOpenCodeError:Ao,opencodeBinaryResolved:Ao,lastOpenCodeLaunchDiagnostics:Xl({sourceBinary:Ao,binary:Ao}).nullish()}),kN=async(t,e=bs)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=jN.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},Rd=Kn(()=>yn(()=>import("./OnboardingScreen-B8TxloXZ.js"),__vite__mapDeps([151,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.OnboardingScreen}))),CN=()=>{const t=tt.c(3),e=Ne(TN),n=Ne(EN);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(wN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},NN=t=>{const e=tt.c(28),{onRetry:n,isRetrying:r}=t,{t:i}=Nt(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const j=new AbortController,b=Qt(),S=setTimeout(()=>j.abort(),5e3);return kN(j.signal).then(C=>{!j.signal.aborted&&Qt()===b&&l(C)}).catch(RN).finally(()=>clearTimeout(S)),()=>{j.abort(),clearTimeout(S)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);let u;e[2]!==i?(u=i("startup.initRecovery.title"),e[2]=i,e[3]=u):u=e[3];let m;e[4]!==u?(m=s.jsx("h1",{className:"typography-title text-foreground",children:u}),e[4]=u,e[5]=m):m=e[5];const f=o?"startup.initRecovery.openCodeUnavailable":"startup.initRecovery.description";let p;e[6]!==i||e[7]!==f?(p=i(f),e[6]=i,e[7]=f,e[8]=p):p=e[8];let y;e[9]!==p?(y=s.jsx("p",{className:"typography-body text-muted-foreground",children:p}),e[9]=p,e[10]=y):y=e[10];let x;e[11]!==m||e[12]!==y?(x=s.jsxs("div",{className:"flex flex-col gap-2",children:[m,y]}),e[11]=m,e[12]=y,e[13]=x):x=e[13];let k;e[14]!==o||e[15]!==i?(k=o&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[14]=o,e[15]=i,e[16]=k):k=e[16];let w;e[17]!==r||e[18]!==i?(w=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[17]=r,e[18]=i,e[19]=w):w=e[19];let h;e[20]!==r||e[21]!==n||e[22]!==w?(h=s.jsx(ct,{type:"button",onClick:n,disabled:r,children:w}),e[20]=r,e[21]=n,e[22]=w,e[23]=h):h=e[23];let g;return e[24]!==h||e[25]!==x||e[26]!==k?(g=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[x,k,h]})}),e[24]=h,e[25]=x,e[26]=k,e[27]=g):g=e[27],g},Md=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",AN=()=>{if(typeof window>"u"||!lb())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}},PN=t=>{const e=tt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=os(MN),l=rt(ON),a=rt(BN),d=vx(),u=c.useRef(null);let m;e[0]!==n.directory?(m=Md(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let p;e[2]!==o?(p=Md(o),e[2]=o,e[3]=p):p=e[3];const y=p;let x,k;if(e[4]!==y||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(x=()=>{if(r||f&&y!==f)return;const S=`${f}
896
896
  ${n.sessionId}`;u.current===S&&l||(u.current=S,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},k=[y,l,n.directory,n.sessionId,f,r,a,d],e[4]=y,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=d,e[12]=x,e[13]=k):(x=e[12],k=e[13]),c.useEffect(x,k),f&&y!==f)return null;let w;e[14]!==i?(w=s.jsx(Hu,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=w):w=e[15];let h;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(tu,{}),e[16]=h):h=e[16];let g;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(g=s.jsx(eu,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=g):g=e[20];let j;e[21]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(Gu,{}),e[21]=j):j=e[21];let b;return e[22]!==w||e[23]!==g?(b=s.jsxs(s.Fragment,{children:[w,h,g,j]}),e[22]=w,e[23]=g,e[24]=b):b=e[24],b};function DN({apis:t}){c.useEffect(()=>{nh("App:mounted"),rh()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Yt(H=>H.initializeApp),n=Yt(H=>H.isInitialized),r=Yt(H=>H.isConnected),i=Yt(H=>H.providers.length),o=Yt(H=>H.agents.length),l=Yt(H=>H.loadProviders),a=Yt(H=>H.loadAgents),d=rt(H=>H.error),u=rt(H=>H.clearError),m=os(H=>H.currentDirectory),f=os(H=>H.setDirectory),p=os(H=>H.isSwitchingDirectory),[y,x]=c.useState(!1),k=In(H=>H.refreshStatus),w=ta(H=>H.refreshStatus),[h,g]=c.useState(()=>t.runtime.isVSCode),[j,b]=c.useState(!1),[S,C]=c.useState(!1),[v,E]=c.useState(0),[R,A]=c.useState(0),[O,B]=c.useState(!1),T=Ne(H=>H.wideChatLayoutEnabled),M=Ne(H=>H.mobileKeyboardMode),L=c.useMemo(()=>xn(),[]),W=La(H=>H.setPlanModeEnabled),[$,P]=c.useState(()=>bl()),[D,I]=c.useState(()=>{const H=yl();return H!==null?wl({isDesktopShell:!0,bootOutcome:H}):null}),X=c.useRef(!1),Z=c.useMemo(()=>AN(),[]),ne=!Z||j;c.useEffect(()=>(vl(y),kd(y),()=>{vl(!1),kd(!1)}),[y]),c.useEffect(()=>{oh(M)},[M]),c.useEffect(()=>{g(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Cr(H=>{Xh(H),A(J=>J+1),C(!1),E(J=>J+1)}),[]);const ue=Kl(H=>{const J=Qt();return Object.values(H.runsByOriginalSessionID).filter(ce=>ce.status==="running"&&ce.runtimeKey===J).map(ce=>`${ce.originalSessionID}:${ce.phase}:${ce.lastForwardedMessageID??""}:${ce.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(Z)return;const H=Qt(),J=Object.values(Kl.getState().runsByOriginalSessionID).filter(ce=>ce.status==="running"&&ce.runtimeKey===H);for(const ce of J)gx(ce.originalSessionID)},[ue,Z,R]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",T),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[T]),c.useEffect(()=>(Sl(t),()=>Sl(null)),[t]),c.useEffect(()=>{Z||(k(t.github,{force:!0}),w(t.linear,{force:!0}))},[t.github,t.linear,Z,r,k,w,R]),xx();const se=$==="valid",xe=D?.screen==="main";c.useEffect(()=>{if(!ih({isDesktopShell:L,isInitialized:n,bootOutcomeKnown:se,bootViewIsMain:xe}))return;const H=setTimeout(()=>{const J=document.getElementById("initial-loading");J&&(J.classList.add("fade-out"),setTimeout(()=>{J.remove()},300))},150);return()=>clearTimeout(H)},[L,n,se,xe]),c.useEffect(()=>{if(!L||$!=="malformed")return;const H=document.getElementById("initial-loading");H&&(H.textContent="Desktop startup failed — please restart the app.")},[L,$]),c.useEffect(()=>{if(L)return;const H=setTimeout(()=>{const J=document.getElementById("initial-loading");J&&!n&&(J.classList.add("fade-out"),setTimeout(()=>{J.remove()},300))},5e3);return()=>clearTimeout(H)},[L,n]),c.useEffect(()=>{let H=!1;return(async()=>{const ce=await bs("/health",{method:"GET"}).catch(()=>null);if(!ce||!ce.ok||H)return;const je=await ce.json().catch(()=>null);if(!je||H)return;const G=je.planModeExperimentalEnabled;W(G===!0||G===1||G==="1"||G==="true")})(),()=>{H=!0}},[W]),c.useEffect(()=>{h||e()},[e,h]),c.useEffect(()=>{if(h||n)return;let H=!0,J,ce=0;const je=10,G=1e3,we=async()=>{if(!H)return;if(ce>=je){C(!0);return}const Te=Yt.getState();if(Te.isInitialized){C(!1);return}ce+=1,await Te.initializeApp();const he=Yt.getState();if(!H)return;if(he.isInitialized){C(!1);return}if(ce>=je){C(!0);return}const re=Math.min(G*Math.pow(2,ce-1),16e3);J=setTimeout(we,re)};return J=setTimeout(we,G),()=>{H=!1,J&&clearTimeout(J)}},[v,n,h]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!S)return;const H=document.getElementById("initial-loading");H&&(H.classList.add("fade-out"),setTimeout(()=>{H.remove()},300))},[S]),c.useEffect(()=>{if(h||!r||i>0&&o>0)return;let H=!0,J=0;const ce=15,je=async()=>{const we=Yt.getState();if(!(we.providers.length>0&&we.agents.length>0))try{we.providers.length===0&&await l({source:"startupRecovery"}),Yt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};je();const G=setInterval(()=>{if(H){if(++J>=ce){clearInterval(G);return}je()}},2e3);return()=>{H=!1,clearInterval(G)}},[r,h,a,l,i,o]),c.useEffect(()=>{p||h||r&&dn.setDirectory(m)},[m,p,r,h]),c.useEffect(()=>{if(!Z||typeof window>"u")return;const H=je=>{b(je?.visible===!0)},J=je=>{if(je.origin!==window.location.origin||je.source!==window.parent)return;const G=je.data;G?.type===sf&&H(G.payload)},ce=window;return ce.__openchamberSetEmbeddedVisibility=H,window.addEventListener("message",J),ab(),()=>{window.removeEventListener("message",J),ce.__openchamberSetEmbeddedVisibility===H&&delete ce.__openchamberSetEmbeddedVisibility}},[Z]),c.useEffect(()=>{!Z?.directory||h||m!==Z.directory&&f(Z.directory,{showOverlay:!1})},[m,Z,h,f]),c.useEffect(()=>{if(!Z||typeof window>"u")return;const H=J=>{J.storageArea===window.localStorage&&J.key==="ui-store"&&Ne.persist.rehydrate()};return window.addEventListener("storage",H),()=>{window.removeEventListener("storage",H)}},[Z]),c.useEffect(()=>{if(typeof window>"u")return;const H=J=>{const ce=J.detail,je=typeof ce?.sessionId=="string"?ce.sessionId.trim():"";if(!je)return;const G=typeof ce?.directory=="string"&&ce.directory.trim().length>0?ce.directory.trim():null;rt.getState().setCurrentSession(je,G)};return window.addEventListener("openchamber:open-session",H),()=>window.removeEventListener("openchamber:open-session",H)},[]),c.useEffect(()=>{if(typeof window>"u")return;const H=()=>{Fn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",H),()=>window.removeEventListener("openchamber:open-mini-chat",H)},[]),c.useEffect(()=>{if(typeof window>"u")return;const H=()=>{const J=rt.getState().currentSessionId;J&&Au(J)};return window.addEventListener("focus",H),()=>window.removeEventListener("focus",H)},[]),c.useEffect(()=>{if(typeof window>"u")return;const H=J=>{const ce=J.detail,je=typeof ce?.directory=="string"&&ce.directory.trim().length>0?ce.directory.trim():null,G=typeof ce?.projectId=="string"&&ce.projectId.trim().length>0?ce.projectId.trim():null,we=!!(je||G);Ne.getState().setSessionSwitcherOpen(!1),rt.getState().openNewSessionDraft({target:we?"project":"chat",selectedProjectId:we?G:null,directoryOverride:we?je:null,preserveDirectoryOverride:!!je})};return window.addEventListener("openchamber:open-draft-session",H),()=>window.removeEventListener("openchamber:open-draft-session",H)},[]),c.useEffect(()=>{typeof window>"u"||!n||p||X.current||(X.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),bx({enabled:ne}),uN({enabled:ne}),hN(m||null),xN(),yx(),yN(),wx(),Bx(),Jh();const ie=c.useCallback(()=>{x(H=>!H)},[]);KC(ie),tN(),lN(!Z),c.useEffect(()=>{if(Z)return;const H=()=>x(J=>!J);return window.addEventListener("openchamber:memory-debug-toggle",H),()=>window.removeEventListener("openchamber:memory-debug-toggle",H)},[Z]),c.useEffect(()=>{Z||d&&setTimeout(()=>u(),5e3)},[u,Z,d]),c.useEffect(()=>{if(!L||$!=="not-injected")return;let H=!1,J=0;const ce=200,je=2e3,G=50,we=()=>{if(H)return;J++;const Te=bl();if(Te!=="not-injected"){if(H=!0,P(Te),Te==="valid"){const re=yl();re&&I(wl({isDesktopShell:!0,bootOutcome:re}))}return}const he=Math.min(ce*Math.pow(1.1,J),je);if(J>=G){const re=document.getElementById("initial-loading");re&&!re.textContent?.includes("taking longer")&&(re.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(we,he)};return window.setTimeout(we,ce),()=>{H=!0}},[L,$]);const Re=c.useCallback(async()=>{if(ah({isDesktopShell:xn(),isDesktopLocalOriginActive:Zo()})){await lh();return}window.location.reload()},[]),be=c.useCallback(async()=>{if(!O){C(!1),B(!0);try{await Yt.getState().initializeApp()}finally{B(!1)}Yt.getState().isInitialized||E(H=>H+1)}},[O]),fe=H=>{if(H.screen==="recovery")return H.variant};if(L&&D&&D.screen!=="main"){if(D.screen==="chooser")return s.jsx(Cs,{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:D.localAvailable!==!1,onCliAvailable:Re,onChooseRemote:()=>{}})})})});const H=fe(D),J=D.screen==="recovery"&&"url"in D?D.url:void 0;return s.jsx(Cs,{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:H,recoveryHostUrl:J,recoveryHostLabel:void 0,localAvailable:D.localAvailable!==!1,onCliAvailable:Re})})})})}if(Z)return s.jsx(Cs,{children:s.jsx(Vl,{sdk:dn.getSdkClient(),directory:m||"",children:s.jsx(Ul,{apis:t,children:s.jsx(aa,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(PN,{embeddedSessionChat:Z,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:ne}),s.jsx(Hl,{}),s.jsx(Gl,{})]})})})},R)});if(S&&!n&&!h&&!Z)return s.jsx(Cs,{children:s.jsx(NN,{onRetry:()=>{be()},isRetrying:O},R)});const ke=!n&&!L;return s.jsx(Cs,{children:s.jsx(Vl,{sdk:dn.getSdkClient(),directory:m||"",children:s.jsx(Ul,{apis:t,children:s.jsx(uC,{children:s.jsx(aa,{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(Hu,{embeddedBackgroundWorkEnabled:ne}),s.jsx(tu,{}),s.jsx($5,{}),s.jsx(Zh,{ready:n&&(!L||se&&xe)}),s.jsx(Gu,{}),s.jsx(Hl,{}),s.jsx(Gl,{}),!ke&&s.jsxs(s.Fragment,{children:[s.jsx(ep,{}),s.jsx(CN,{}),y&&s.jsx(jC,{onClose:()=>x(!1)})]})]})})})})},R)})}function IN(t){const e=tt.c(2);let n;return e[0]!==t?(n=s.jsx(Qh,{children:s.jsx(DN,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function TN(t){return t.isAboutDialogOpen}function EN(t){return t.setAboutDialogOpen}function RN(){}function MN(t){return t.currentDirectory}function ON(t){return t.currentSessionId}function BN(t){return t.setCurrentSession}const FN=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Sx();ch().then(()=>{Promise.all([dh(),jx()]).catch(t=>{console.error("[main] settings init failed:",t)}),kx(),Cx(),Nx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const gm=document.getElementById("root");if(!gm)throw new Error("Root element not found");Ax();Bm.createRoot(gm).render(s.jsx(ut.StrictMode,{children:s.jsx(Px,{children:s.jsx(Dx,{children:s.jsx(Ix,{children:s.jsx(Tx,{children:s.jsx(IN,{apis:FN})})})})})}));const rA=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{By as W,Cy as a,nA as b,bf as g,rA as m,Oy as u,xf as v};